feat: add iconv runtime wrapper#1069
Conversation
Add @tailor-platform/sdk/iconv as a typed wrapper around the platform's tailor.iconv runtime API for character encoding conversion (Shift_JIS, EUC-JP, IBM EBCDIC variants, etc.). Includes setupIconvMock for unit tests and a docs page mirroring the platform reference. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d5427a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
⚡ pkg.pr.new@tailor-platform/sdk@tailor-platform/create-sdk
|
📖 Docs Consistency Check
|
| File | Issue | Suggested Fix |
|---|---|---|
packages/sdk/docs/testing.md |
Missing documentation for setupIconvMock test helper |
Add a section documenting setupIconvMock similar to how setupWaitPointMock is documented |
Details
Missing setupIconvMock in testing.md
The PR adds a new test helper setupIconvMock() that is:
- Exported from
@tailor-platform/sdk/test(packages/sdk/src/utils/test/index.ts:12) - Documented in
packages/sdk/docs/iconv.md(lines 138-174) - Following the same pattern as other mock helpers
However, packages/sdk/docs/testing.md documents other mock helpers like:
setupWaitPointMock- documented at lines 176 and 296setupWorkflowMock- referenced in workflow testing sections- Database mocking patterns - documented in the "Mock TailorDB Client" section
For consistency, setupIconvMock should be documented in testing.md. This would help users discover the helper when they need to test code that uses @tailor-platform/sdk/iconv.
Suggested location: Add a new subsection under "Unit Tests" (after line 215) titled "Testing Code that Uses iconv" with:
- Basic example of using
setupIconvMock() - How to customize behavior via
onConvert,onDecode,onEncode - Cleanup pattern (deleting
TailorGlobal.tailorinafterEach) - Reference to the full documentation in
iconv.md
✅ Verified Consistent
- API documentation (
iconv.md): All exported functions (convert,convertBuffer,decode,encode,encodings,Iconv) are correctly documented with accurate signatures and return types - README.md: Correctly links to iconv.md under "Runtime Utilities" section (line 88)
- Package exports:
./iconvexport in package.json (lines 47-51) matches the implementation - Test helper export:
setupIconvMockis properly exported from@tailor-platform/sdk/test - SKILL.md: References iconv docs (line 20 and 34)
- Changeset: Accurately describes the changes
- iconv.md Testing section: Provides comprehensive examples of using
setupIconvMock
Recommended Actions
- Add a subsection in
packages/sdk/docs/testing.mddocumentingsetupIconvMockto maintain consistency with other mock helpers - Consider cross-referencing from testing.md to iconv.md's Testing section for the full example
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Code Metrics Report (packages/sdk)
Details | | main (25eda96) | #1069 (38f3ef2) | +/- |
|--------------------|----------------|-----------------|-------|
+ | Coverage | 59.4% | 59.5% | +0.1% |
| Files | 351 | 352 | +1 |
| Lines | 11938 | 11969 | +31 |
+ | Covered | 7092 | 7123 | +31 |
+ | Code to Test Ratio | 1:0.4 | 1:0.4 | +0.0 |
| Code | 78060 | 78270 | +210 |
+ | Test | 31657 | 31750 | +93 |Code coverage of files in pull request scope (73.9% → 82.0%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
|
I plan to handle this in #1131, including the changes from this PR. |
Summary
@tailor-platform/sdk/iconv— a typed wrapper around the platform'stailor.iconvruntime API for character encoding conversion (Shift_JIS, EUC-JP, IBM EBCDIC, etc.)setupIconvMocktest helper to@tailor-platform/sdk/testdocs/iconv.mdreferencing the official Character Encoding Conversion page, plus README and SKILL.md linksCloses a gap previously identified in the SDK: the platform exposes
tailor.iconvglobally via@tailor-platform/function-types, but the SDK had no first-class typed export for it. This PR adds one in the same style as the existing@tailor-platform/sdk/kyselyruntime utility.API surface
Return type narrows to
stringwhentoEncodingis"UTF-8"/"UTF8", otherwiseUint8Array— matches the platform's declared types.Test plan
pnpm vitest run --project=unit src/iconv— 11/11 passing (incl. type-level checks for return-type narrowing)pnpm build—dist/iconv/{index.mjs, index.d.mts}generatedpnpm publint --strict— All goodpnpm knip— cleanimport { convert } from "@tailor-platform/sdk/iconv"resolves cleanly in a downstream project after publish🤖 Generated with Claude Code