feat(sdk): vendor function-types and add @tailor-platform/sdk/runtime#1131
Merged
Conversation
Internalize the external @tailor-platform/function-types package into the SDK and expose it as a new `@tailor-platform/sdk/runtime` entry. The runtime entry provides typed wrappers (iconv, secretmanager, authconnection, idp, workflow, context, file) for the platform's `tailor.*` and `tailordb.*` globals, and importing it activates the corresponding ambient global types as a side effect. Importing from `@tailor-platform/sdk` also activates those globals automatically — existing projects do not need to add anything to tsconfig. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 12a206d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Restructure src/runtime/globals.ts so every shape (interfaces, response types, error class) is defined as a top-level exported type. The `declare global` block now aliases those module-scope types into the `tailor.*` / `Tailordb` namespaces. As a result, the bundled `dist/runtime/*.d.mts` and `dist/vitest/index.d.mts` no longer reference `tailor.*` types — consumers can import and use the runtime wrappers without activating any ambient globals. Importing `@tailor-platform/sdk/runtime` no longer auto-activates the ambient declarations either. Users who still want unqualified `tailor.iconv.convert(...)` calls can opt in via a side-effect import of `@tailor-platform/sdk/runtime/globals` or by listing it in tsconfig `compilerOptions.types`. Also introduce `contextMock` so tests can configure invokers without spying on `globalThis.tailor.context.getInvoker`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…function-types # Conflicts: # pnpm-lock.yaml
⚡ pkg.pr.new@tailor-platform/sdk@tailor-platform/create-sdk
|
6 tasks
Rename setWorkflowExecutionId -> setTriggerHandler and setWaitResult -> setWaitHandler in src/runtime/__tests__/workflow.test.ts. The previous identifiers do not exist on workflowMock and broke typecheck:go and unit tests on Node 22/24, Coverage, and SDK E2E.
This comment has been minimized.
This comment has been minimized.
Split the runtime data types and the typed globalThis accessor into a
private _runtime.ts module so that the wrappers under
@tailor-platform/sdk/runtime/{iconv,secretmanager,authconnection,idp,
workflow,context,file} no longer side-effect import ./globals.
Previously, importing any wrapper transitively activated the declare
global block in ./globals, which contradicted the documented opt-in
contract (the user was supposed to explicitly import
@tailor-platform/sdk/runtime/globals to get ambient tailor.* / tailordb
types). After this change, only the explicit globals entry activates
those declarations; the wrappers reach the runtime via a typed lazy
runtime accessor that reads globalThis.tailor / globalThis.tailordb
without polluting the consumer scope. Test files are updated to follow
the same rule.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The vitest test colocation will be handled in a separate PR. This restores the `__tests__/` layout and the corresponding `vitest.config.ts` include / exclude patterns and `knip.json` ignore list so this PR no longer mixes the colocation refactor with the function-types vendoring work.
This comment has been minimized.
This comment has been minimized.
The replacement types are vendored inside the SDK and activated automatically, so users can simply remove @tailor-platform/function-types from their package.json without a dedicated codemod. Drop the codemod, its fixtures, the registry entry, the test registration, and the build target. Update the related changeset entries accordingly.
This comment has been minimized.
This comment has been minimized.
# Conflicts: # packages/sdk/eslint.config.js # pnpm-lock.yaml
This comment has been minimized.
This comment has been minimized.
The v2/tailordb-namespace codemod rewrites Tailordb.Client references to tailordb.Client in both value and type positions, but the new lowercase namespace tailordb only declared QueryResult and CommandType. Add a Client type alias (= TailordbClientInstance) so codemod output like `const c: tailordb.Client = ...` type-checks via namespace+var merging.
This comment has been minimized.
This comment has been minimized.
remiposo
reviewed
May 25, 2026
- Add Iconv / Client type aliases to ambient namespace tailor.iconv / tailor.idp so they remain usable in type position, matching the original @tailor-platform/function-types declarations (which declared these as classes inside the namespace). - Switch internal CLI tailordb stub to use lowercase tailordb.QueryResult instead of the deprecated capital-cased Tailordb.QueryResult. - Harden stripBannerExceptConfigureEntry regex to tolerate CRLF line endings so the strip works regardless of how tsdown formats banners.
Code Metrics Report (packages/sdk)
Details | | main (a0658d0) | #1131 (af250cf) | +/- |
|--------------------|----------------|-----------------|-------|
+ | Coverage | 63.6% | 63.8% | +0.2% |
| Files | 367 | 375 | +8 |
| Lines | 12949 | 13007 | +58 |
+ | Covered | 8244 | 8310 | +66 |
+ | Code to Test Ratio | 1:0.4 | 1:0.4 | +0.0 |
| Code | 85698 | 86602 | +904 |
+ | Test | 36485 | 36919 | +434 |Code coverage of files in pull request scope (85.4% → 89.6%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@tailor-platform/function-types(vendored assrc/runtime/globals.ts) and remove the external dependency.@tailor-platform/sdk/runtimeentry exposing typed wrappers for the runtime APIs:iconv,secretmanager,authconnection,idp,workflow,context,file. Wrappers and their associated types are self-contained — they work without activating any ambient globals.tailor.*/tailordb.*types are still activated automatically when you import from@tailor-platform/sdk, so existing code keeps type-checking with no changes. This implicit activation will be removed in v2.0; new code is encouraged to use the typed wrappers from@tailor-platform/sdk/runtime, or to opt into the globals explicitly viaimport "@tailor-platform/sdk/runtime/globals"(or by listing the entry intsconfig.json'scompilerOptions.types).Tailordbambient namespace (Tailordb.QueryResult,Tailordb.CommandType,Tailordb.Client) as a@deprecatedalias of the new lowercasetailordb.*namespace, so source-level callers of the old function-types names keep type-checking. Scheduled for removal in v2.0.v2/tailordb-namespacecodemod in@tailor-platform/sdk-codemodto rewriteTailordb.QueryResult/Tailordb.CommandType/Tailordb.Client/typeof Tailordb.Clientto the lowercasetailordb.*form. Removing@tailor-platform/function-typesfrompackage.json(andtsconfig.jsoncompilerOptions.typesif listed) can be done manually once you've upgraded — no codemod is needed because the replacement declarations are activated automatically.@/runtime/iconvnamespace.