feat(sdk): vendor function-types and add @tailor-platform/sdk/runtime#1131
Open
toiroakr wants to merge 40 commits into
Open
feat(sdk): vendor function-types and add @tailor-platform/sdk/runtime#1131toiroakr wants to merge 40 commits into
toiroakr wants to merge 40 commits into
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: 10382b8 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 wait-point module previously declared an inline shape for globalThis.tailor.workflow that duplicated TailorWorkflowAPI. Import the canonical type from @/runtime/workflow instead, and type the test file's globalThis cast with TailorRuntime as well. Configure module is allowed to import from @/runtime per the import boundary rules.
This comment has been minimized.
This comment has been minimized.
…es-dep - v2/tailordb-namespace rewrites references to the deprecated capital-cased `Tailordb` ambient namespace (`Tailordb.QueryResult`, `Tailordb.CommandType`, `Tailordb.Client`, `typeof Tailordb.Client`) to the new lowercase `tailordb.*` namespace re-published by the SDK. - v2/drop-function-types-dep removes `@tailor-platform/function-types` from `package.json` dependency maps (`dependencies` / `devDependencies` / `peerDependencies` / `optionalDependencies`) and from `tsconfig.json` `compilerOptions.types`, since the declarations are now vendored inside the SDK. Also restore the capital-cased `Tailordb` ambient namespace as a `@deprecated` alias of the new lowercase `tailordb.*` namespace so existing code that uses `Tailordb.QueryResult` etc. continues to type-check against the vendored declarations, and revert `packages/sdk/src/cli/shared/mock.ts` to its main version which still uses `Tailordb.QueryResult<O>`.
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.
Code Metrics Report (packages/sdk)
Details | | main (b2bd4aa) | #1131 (c189cd7) | +/- |
|--------------------|----------------|-----------------|-------|
+ | Coverage | 62.3% | 62.6% | +0.2% |
| Files | 364 | 372 | +8 |
| Lines | 12773 | 12831 | +58 |
+ | Covered | 7967 | 8033 | +66 |
+ | Code to Test Ratio | 1:0.4 | 1:0.4 | +0.0 |
| Code | 83913 | 84811 | +898 |
+ | Test | 35136 | 35570 | +434 |Code coverage of files in pull request scope (85.6% → 89.8%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
Comment on lines
133
to
141
| /** | ||
| * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled | ||
| * resolver/executor/workflow tests. | ||
| * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, "getInvoker").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source. | ||
| * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous. | ||
| */ | ||
| export function setupInvokerMock(invoker: TailorInvoker): void { | ||
| const raw: tailor.context.Invoker | null = invoker | ||
| const raw: ContextInvoker | null = invoker | ||
| ? { |
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.