@tailor-platform/sdk 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +183 -0
- package/README.md +1 -1
- package/dist/{application-BpLeawBg.mjs → application-C8a0UJ-z.mjs} +312 -166
- package/dist/application-C8a0UJ-z.mjs.map +1 -0
- package/dist/application-D4zOiLLa.mjs +3 -0
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +47 -24
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +6 -0
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +22 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +30 -11
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.mjs +2 -2
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +366 -137
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/ts-hook.mjs +55 -8
- package/dist/completion/zsh-worker.zsh +38 -10
- package/dist/configure/config/index.d.mts +1 -1
- package/dist/configure/index.d.mts +3 -2
- package/dist/configure/index.mjs +92 -25
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +5 -4
- package/dist/configure/services/aigateway/types.d.mts +6 -1
- package/dist/configure/services/auth/types.d.mts +2 -2
- package/dist/configure/services/index.d.mts +2 -2
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +1 -1
- package/dist/configure/services/tailordb/types.d.mts +7 -4
- package/dist/configure/services/workflow/index.d.mts +2 -2
- package/dist/configure/services/workflow/wait-point.d.mts +72 -13
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/{crashreport-CINZ5dVN.mjs → crashreport-Cd4TqfZq.mjs} +1 -1
- package/dist/{crashreport-CIIfLnoO.mjs → crashreport-Q0pDAlrj.mjs} +8 -4
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-Q0pDAlrj.mjs.map} +1 -1
- package/dist/{errors-CWj21238.mjs → errors-Bxut5_Sy.mjs} +17 -3
- package/dist/{errors-CWj21238.mjs.map → errors-Bxut5_Sy.mjs.map} +1 -1
- package/dist/file-BUcmVIH2.mjs.map +1 -1
- package/dist/kysely/index.d.mts +2 -1
- package/dist/kysely/index.mjs +2 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{logger-DSdExfor.mjs → logger-D0bEznPv.mjs} +9 -5
- package/dist/{logger-DSdExfor.mjs.map → logger-D0bEznPv.mjs.map} +1 -1
- package/dist/package-json-8b0O9TlX.mjs.map +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -5
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +14 -11
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +9 -9
- package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -4
- package/dist/plugin/get-generated-type.d.mts +4 -4
- package/dist/plugin/index.mjs +13 -13
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +2 -2
- package/dist/plugin/with-context.d.mts +1 -1
- package/dist/{register-ts-hook-CTth1eqj.mjs → register-ts-hook-Vqjza10T.mjs} +2516 -857
- package/dist/register-ts-hook-Vqjza10T.mjs.map +1 -0
- package/dist/{repl-editor-BCozyiNq.mjs → repl-editor-F9LotMNx.mjs} +3 -2
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-F9LotMNx.mjs.map} +1 -1
- package/dist/runtime/file.d.mts +14 -14
- package/dist/{schema--xYWRGfe.mjs → schema-D4TC4BC3.mjs} +4 -3
- package/dist/schema-D4TC4BC3.mjs.map +1 -0
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +3 -3
- package/dist/seed/index.mjs.map +1 -1
- package/dist/{seed-xqM9WIHP.mjs → seed-Cibjmtry.mjs} +46 -40
- package/dist/seed-Cibjmtry.mjs.map +1 -0
- package/dist/{service-goqlJJgA.mjs → service-2grcAOCJ.mjs} +61 -27
- package/dist/service-2grcAOCJ.mjs.map +1 -0
- package/dist/service-CaBPNDIZ.mjs +3 -0
- package/dist/{service-CCwl3Avt.mjs → service-LTfp03ZZ.mjs} +7 -5
- package/dist/{service-CCwl3Avt.mjs.map → service-LTfp03ZZ.mjs.map} +1 -1
- package/dist/types/aigateway.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +3 -3
- package/dist/types/executor.generated.d.mts +1 -1
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +4 -4
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/index.mjs +95 -7
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/workflow.d.mts +13 -1
- package/dist/wait-point-invoker-__oE88_P.mjs +148 -0
- package/dist/wait-point-invoker-__oE88_P.mjs.map +1 -0
- package/dist/wait-point-registry-TL99zotw.mjs +47 -0
- package/dist/wait-point-registry-TL99zotw.mjs.map +1 -0
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +17 -13
- package/docs/cli/setup.md +14 -1
- package/docs/cli/tailordb.md +30 -27
- package/docs/cli/workspace.md +2 -2
- package/docs/cli-reference.md +23 -22
- package/docs/configuration.md +2 -2
- package/docs/github-actions.md +73 -28
- package/docs/migration/v2.md +58 -4
- package/docs/migration/v3.md +41 -0
- package/docs/quickstart.md +1 -1
- package/docs/services/aigateway.md +33 -9
- package/docs/services/executor.md +5 -1
- package/docs/services/tailordb-migration.md +146 -44
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +52 -2
- package/docs/testing.md +13 -1
- package/package.json +8 -8
- package/dist/application-BpLeawBg.mjs.map +0 -1
- package/dist/application-BxLLiLsr.mjs +0 -3
- package/dist/register-ts-hook-CTth1eqj.mjs.map +0 -1
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-_XmjSEGr.mjs +0 -3
- package/dist/service-goqlJJgA.mjs.map +0 -1
- package/dist/test-env-key-D7UkZp99.mjs +0 -75
- package/dist/test-env-key-D7UkZp99.mjs.map +0 -1
package/docs/configuration.md
CHANGED
|
@@ -243,7 +243,7 @@ export default defineConfig({
|
|
|
243
243
|
|
|
244
244
|
If the same config defines an auth before-login hook, make sure the config module can be evaluated without Node-only globals in the platform runtime. Avoid arbitrary `process.env` reads in that module; pass literal values, or values generated into a config module before deployment, and read them from the hook's `env` argument.
|
|
245
245
|
|
|
246
|
-
When the SDK deploys application code or runs detected service code with `function
|
|
246
|
+
When the SDK deploys application code or runs detected service code with `function run`, it passes the resolved values as the `env` argument. Do not read `process.env` from deployed resolvers, executors, workflow jobs, auth hooks, or migration scripts; Node-side environment variables are not available there. Put sensitive values in [Secret Manager](./services/secret.md) instead of `env`.
|
|
247
247
|
|
|
248
248
|
| Code location | Runtime access |
|
|
249
249
|
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -252,7 +252,7 @@ When the SDK deploys application code or runs detected service code with `functi
|
|
|
252
252
|
| Workflow job body | `body: (input, { env }) => ...` |
|
|
253
253
|
| Auth before-login hook | `handler: async ({ env }) => ...` |
|
|
254
254
|
| TailorDB migration script | `main(trx, { env }: MigrationContext)` |
|
|
255
|
-
| `function
|
|
255
|
+
| `function run` | Same `env` argument shape as the detected resolver, executor, or workflow job |
|
|
256
256
|
|
|
257
257
|
```typescript
|
|
258
258
|
// In resolvers
|
package/docs/github-actions.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# GitHub Actions Integration
|
|
2
2
|
|
|
3
|
-
`tailor setup` generates
|
|
4
|
-
|
|
3
|
+
`tailor setup` generates GitHub repository automation for your Tailor Platform
|
|
4
|
+
application, including deploy workflows and Renovate configuration.
|
|
5
5
|
|
|
6
6
|
> **Beta:** This command is under active development. CLI flags, the generated
|
|
7
7
|
> workflow, and the `.github/tailor.lock` schema may change before general
|
|
@@ -14,16 +14,13 @@ lives):
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
# Branch target: deploy to stg on every push to main
|
|
17
|
-
tailor setup
|
|
17
|
+
tailor setup branch --name my-app-stg
|
|
18
18
|
|
|
19
19
|
# Tag target: deploy to production when a tag is pushed, with an approval gate
|
|
20
|
-
tailor setup
|
|
21
|
-
--
|
|
20
|
+
tailor setup tag --name my-app-prod \
|
|
21
|
+
--branch main --environment production
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
`setup` defaults to the GitHub provider; `--provider github` (`-p github`) is
|
|
25
|
-
accepted but optional, and other providers are not yet supported.
|
|
26
|
-
|
|
27
24
|
After running the command, follow the **Next steps** printed to the terminal to
|
|
28
25
|
set the required secrets, set the `TAILOR_PLATFORM_WORKSPACE_ID` variable, and
|
|
29
26
|
commit the generated files.
|
|
@@ -44,9 +41,9 @@ The branch target fires on pull requests and pushes to the branch you specify
|
|
|
44
41
|
(defaulting to the repository's default branch when `--branch` is omitted):
|
|
45
42
|
|
|
46
43
|
```bash
|
|
47
|
-
tailor setup
|
|
44
|
+
tailor setup branch --name my-app-stg
|
|
48
45
|
# Equivalent to:
|
|
49
|
-
tailor setup
|
|
46
|
+
tailor setup branch --name my-app-stg --branch main
|
|
50
47
|
```
|
|
51
48
|
|
|
52
49
|
What it does:
|
|
@@ -69,7 +66,7 @@ Pass `--erd-preview` on a branch target to add TailorDB ERD preview artifacts
|
|
|
69
66
|
to pull requests:
|
|
70
67
|
|
|
71
68
|
```bash
|
|
72
|
-
tailor setup
|
|
69
|
+
tailor setup branch --name my-app-stg --erd-preview
|
|
73
70
|
```
|
|
74
71
|
|
|
75
72
|
The generated workflow runs `tailor tailordb erd`, which is provided by the
|
|
@@ -90,11 +87,10 @@ ERD preview does not use Tailor Platform credentials. Fork pull requests still
|
|
|
90
87
|
build artifacts, but the comment step is skipped because fork tokens cannot
|
|
91
88
|
write PR comments.
|
|
92
89
|
|
|
93
|
-
`--erd-preview` is only available for branch targets
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
all-added or all-removed viewer artifacts. Re-run `setup` after adding or
|
|
90
|
+
`--erd-preview` is only available for branch targets. The namespace list is
|
|
91
|
+
recorded in `.github/tailor.lock`; the pull request workflow compares the head
|
|
92
|
+
and base lock files so newly added or removed namespaces can still produce
|
|
93
|
+
all-added or all-removed viewer artifacts. Re-run `setup branch` after adding or
|
|
98
94
|
removing TailorDB namespaces. `setup check` reports drift when the recorded ERD
|
|
99
95
|
preview namespaces no longer match the current config.
|
|
100
96
|
|
|
@@ -104,8 +100,8 @@ The tag target fires when a tag matching `--tag-pattern` (default `v*`) is
|
|
|
104
100
|
pushed:
|
|
105
101
|
|
|
106
102
|
```bash
|
|
107
|
-
tailor setup
|
|
108
|
-
--tag
|
|
103
|
+
tailor setup tag --name my-app-prod \
|
|
104
|
+
--tag-pattern "v*" --branch main --environment production
|
|
109
105
|
```
|
|
110
106
|
|
|
111
107
|
What it does:
|
|
@@ -131,7 +127,7 @@ What it does:
|
|
|
131
127
|
| Branch | The branch that triggers the workflow (push + PR base). Defaults to the repo's default branch. |
|
|
132
128
|
| Tag | The branch whose history the tag must be reachable from. Omit to disable the guard entirely. |
|
|
133
129
|
|
|
134
|
-
The workspace name (`--
|
|
130
|
+
The workspace name (`--name`, or the config `name` when omitted) must
|
|
135
131
|
be 3–63 characters of lowercase letters, numbers, and hyphens, and cannot start
|
|
136
132
|
or end with a hyphen. It is used for the generated file name, the workflow
|
|
137
133
|
`name:`, the plan label, and the default GitHub Environment name; it does not
|
|
@@ -174,7 +170,7 @@ environment is planned.)
|
|
|
174
170
|
|
|
175
171
|
## Generated files
|
|
176
172
|
|
|
177
|
-
Running
|
|
173
|
+
Running a workflow setup subcommand creates or updates:
|
|
178
174
|
|
|
179
175
|
### `.github/workflows/tailor-<workspace-name>.yml`
|
|
180
176
|
|
|
@@ -276,7 +272,7 @@ you can deploy any commit regardless of branch membership.
|
|
|
276
272
|
For a monorepo where your SDK app lives in a subdirectory, pass `--dir`:
|
|
277
273
|
|
|
278
274
|
```bash
|
|
279
|
-
tailor setup
|
|
275
|
+
tailor setup branch --name my-app --dir apps/backend
|
|
280
276
|
```
|
|
281
277
|
|
|
282
278
|
The generated workflow adds a `paths` filter on `apps/backend/**` so the
|
|
@@ -341,11 +337,11 @@ A typical setup with staging and production:
|
|
|
341
337
|
|
|
342
338
|
```bash
|
|
343
339
|
# Staging: main → stg (deploy on every push to main)
|
|
344
|
-
tailor setup
|
|
340
|
+
tailor setup branch --name my-app-stg
|
|
345
341
|
|
|
346
342
|
# Production: tagged commits → prod, with approval gate and branch guard
|
|
347
|
-
tailor setup
|
|
348
|
-
--
|
|
343
|
+
tailor setup tag --name my-app-prod \
|
|
344
|
+
--branch main --environment production
|
|
349
345
|
```
|
|
350
346
|
|
|
351
347
|
Then provision each workspace and set its id on the matching environment (the
|
|
@@ -364,6 +360,41 @@ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET --env production
|
|
|
364
360
|
|
|
365
361
|
Commit both workflow files and `.github/tailor.lock`.
|
|
366
362
|
|
|
363
|
+
## Keeping dependencies and actions updated
|
|
364
|
+
|
|
365
|
+
Run this command once from the repository root to add Renovate configuration:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
tailor setup renovate
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
It generates `renovate.json`, which extends Tailor's shared Renovate preset. The
|
|
372
|
+
preset groups `@tailor-platform/*` package updates into one pull request and
|
|
373
|
+
lets Renovate update the SHA-pinned GitHub Actions used by generated workflows.
|
|
374
|
+
Enable Renovate for the repository by following the
|
|
375
|
+
[Renovate onboarding guide](https://docs.renovatebot.com/getting-started/installing-onboarding/),
|
|
376
|
+
then commit the generated file.
|
|
377
|
+
|
|
378
|
+
If the repository already has Renovate configuration, the command adds
|
|
379
|
+
`github>tailor-inc/renovate-config` to its `extends` array in place instead of
|
|
380
|
+
writing a new file, leaving your other settings untouched. It checks Renovate's
|
|
381
|
+
standard root, `.github`, `.gitlab`, and `.renovaterc` locations, including the
|
|
382
|
+
deprecated `package.json` configuration. When that configuration already extends
|
|
383
|
+
the preset, the command reports that Renovate is set up and changes nothing.
|
|
384
|
+
|
|
385
|
+
Configuration written in JSON5 or JSONC — with comments or trailing commas —
|
|
386
|
+
cannot be edited without losing those comments, so the command leaves it
|
|
387
|
+
unchanged and asks you to add the preset to its `extends` array yourself.
|
|
388
|
+
|
|
389
|
+
`renovate.json` is yours to edit — it is not tracked in `.github/tailor.lock`.
|
|
390
|
+
Add your own rules freely; re-running `tailor setup renovate` does not overwrite
|
|
391
|
+
them. To remove it, delete the file.
|
|
392
|
+
|
|
393
|
+
Renovate updates the SDK dependency and action pins, but it does not regenerate
|
|
394
|
+
the workflow template. After an SDK update, `tailor setup check --ci` reports a
|
|
395
|
+
template-version warning until you re-run the relevant workflow setup
|
|
396
|
+
subcommand.
|
|
397
|
+
|
|
367
398
|
## Checking for drift
|
|
368
399
|
|
|
369
400
|
`tailor setup check` audits the workflows recorded in
|
|
@@ -374,12 +405,26 @@ newer template is available, `tailor.config.ts` is no longer under the recorded
|
|
|
374
405
|
trigger. It exits non-zero when it finds drift, so you can run it in CI. Each
|
|
375
406
|
finding names a stable rule key for future suppression.
|
|
376
407
|
|
|
408
|
+
Workflows generated by `setup branch`, `setup tag`, `setup preview`, and
|
|
409
|
+
`setup coordinate` self-audit: each contains a `tailor-drift-check` step that
|
|
410
|
+
runs the check in CI. Preview workflows run it alongside each preview deploy,
|
|
411
|
+
so pull requests that deploy no preview (drafts, fork PRs, and unlabeled PRs
|
|
412
|
+
in label-triggered mode) skip the check. A single run audits every target
|
|
413
|
+
recorded in `.github/tailor.lock`, so per-app composite actions generated by
|
|
414
|
+
`setup action` are covered by their coordinator's step and do not carry one of
|
|
415
|
+
their own.
|
|
416
|
+
|
|
417
|
+
Drift findings are advisory by default. Set the repository variable
|
|
418
|
+
`TAILOR_PLATFORM_FAIL_ON_DRIFT` to `true` to make unsuppressed findings fail
|
|
419
|
+
the job. Execution and configuration errors fail regardless of this variable.
|
|
420
|
+
|
|
377
421
|
## Updating the generated workflow
|
|
378
422
|
|
|
379
|
-
When you upgrade the SDK, re-run
|
|
380
|
-
template improvements. If the SDK detects that you
|
|
381
|
-
section, it stops and asks you to use `--force` to
|
|
382
|
-
move your customizations into your own steps before
|
|
423
|
+
When you upgrade the SDK, re-run the relevant workflow setup subcommand with
|
|
424
|
+
the same flags to pick up template improvements. If the SDK detects that you
|
|
425
|
+
have hand-edited a managed section, it stops and asks you to use `--force` to
|
|
426
|
+
overwrite your edits, or to move your customizations into your own steps before
|
|
427
|
+
regenerating.
|
|
383
428
|
|
|
384
429
|
The `.github/tailor.lock` file records the flags used at generation time,
|
|
385
430
|
so you can check what arguments were used previously.
|
package/docs/migration/v2.md
CHANGED
|
@@ -8,6 +8,60 @@ Run the codemods, then finish anything reported as not migrated automatically:
|
|
|
8
8
|
npx @tailor-platform/sdk-codemod --from <current-version> --to <target-version>
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Type-only imports → `import type`
|
|
12
|
+
|
|
13
|
+
**Migration:** Manual
|
|
14
|
+
|
|
15
|
+
The v2 CLI runs TypeScript by stripping types from each file in isolation,
|
|
16
|
+
with no cross-file type information. A plain (non-`type`) import of a
|
|
17
|
+
type-only export therefore survives stripping and fails when the module
|
|
18
|
+
loads:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
SyntaxError: The requested module './types.ts' does not provide an export named 'Row'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`tailor generate` / `tailor deploy` stop at this error before doing any work.
|
|
25
|
+
Import types with `import type` (or the inline `type` modifier), and
|
|
26
|
+
re-export them with `export type`, in every module the CLI loads. Generated
|
|
27
|
+
Kysely types (`DB`, `Insertable`, `Selectable`, table row types) are almost
|
|
28
|
+
entirely type-only, so v1 projects typically hit this in many files at once.
|
|
29
|
+
Set `"verbatimModuleSyntax": true` in tsconfig.json to catch every violation
|
|
30
|
+
at typecheck; projects scaffolded by v2 `tailor init` enable it by default.
|
|
31
|
+
|
|
32
|
+
Before:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { DB, getDB } from "./generated/db";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { type DB, getDB } from "./generated/db";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary>Prompt for an AI agent (to perform this migration)</summary>
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
In Tailor SDK v2 the CLI loads TypeScript by stripping types from each file
|
|
49
|
+
in isolation, so type-only exports do not exist at runtime and plain imports
|
|
50
|
+
of them fail to load with "does not provide an export named '<name>'".
|
|
51
|
+
Migrate the project so every type-only import and re-export is marked:
|
|
52
|
+
|
|
53
|
+
1. Add `"verbatimModuleSyntax": true` to compilerOptions in tsconfig.json.
|
|
54
|
+
2. Run `tsc --noEmit` and fix every reported violation: add the `type`
|
|
55
|
+
modifier to type-only named imports (`import type { Row }` or
|
|
56
|
+
`import { type Row, marker }`) and change type-only re-exports to
|
|
57
|
+
`export type { ... }`.
|
|
58
|
+
|
|
59
|
+
Only add `type` modifiers; do not reorder, remove, or otherwise change
|
|
60
|
+
imports that are used as values.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
</details>
|
|
64
|
+
|
|
11
65
|
## defineGenerators → definePlugins
|
|
12
66
|
|
|
13
67
|
**Migration:** Partially automatic
|
|
@@ -1368,7 +1422,7 @@ single generation pass and resolves once it completes.
|
|
|
1368
1422
|
|
|
1369
1423
|
**Migration:** Partially automatic
|
|
1370
1424
|
|
|
1371
|
-
`seedPlugin` no longer generates the `exec.mjs` seed runner. Seeding and validation move to the `tailor seed` commands provided by the `@tailor-platform/sdk-plugin-seed` CLI plugin: install it as a devDependency, replace `node <distPath>/exec.mjs` invocations with `tailor seed apply` and `node <distPath>/exec.mjs validate` with `tailor seed validate`, and delete the stale generated `<distPath>/exec.mjs` file. Seed data and schema generation (`data/*.jsonl`, `data/*.schema.ts`) is unchanged, and the `tailor seed apply` options mirror the old script (`--machine-user`, `--namespace`, `--skip-idp`, `--truncate`, `--yes`,
|
|
1425
|
+
`seedPlugin` no longer generates the `exec.mjs` seed runner. Seeding and validation move to the `tailor seed` commands provided by the `@tailor-platform/sdk-plugin-seed` CLI plugin: install it as a devDependency, replace `node <distPath>/exec.mjs` invocations with `tailor seed apply` and `node <distPath>/exec.mjs validate` with `tailor seed validate`, and delete the stale generated `<distPath>/exec.mjs` file. Seed data and schema generation (`data/*.jsonl`, `data/*.schema.ts`) is unchanged, and the `tailor seed apply` options mirror the old script (`--machine-user`, `--namespace`, `--skip-idp`, `--truncate`, `--yes`, entity-name arguments), plus a new `--upsert` flag to update existing rows instead of failing on duplicate ids.
|
|
1372
1426
|
|
|
1373
1427
|
Before:
|
|
1374
1428
|
|
|
@@ -1394,8 +1448,8 @@ CLI plugin (@tailor-platform/sdk-plugin-seed) replaces it:
|
|
|
1394
1448
|
- Install @tailor-platform/sdk-plugin-seed as a devDependency next to
|
|
1395
1449
|
@tailor-platform/sdk.
|
|
1396
1450
|
- Replace `node <distPath>/exec.mjs [options] [types...]` invocations with
|
|
1397
|
-
`tailor seed apply [options] [
|
|
1398
|
-
--namespace/-n, --skip-idp, --truncate, --yes, and
|
|
1451
|
+
`tailor seed apply [options] [entities...]` (same options: --machine-user/-m,
|
|
1452
|
+
--namespace/-n, --skip-idp, --truncate, --yes, and entity-name arguments,
|
|
1399
1453
|
plus a new --upsert flag to update existing rows instead of failing on
|
|
1400
1454
|
duplicate ids).
|
|
1401
1455
|
- Replace `node <distPath>/exec.mjs validate [path]` with
|
|
@@ -1609,7 +1663,7 @@ The CLI stores human users by their stable subject ID instead of email (email is
|
|
|
1609
1663
|
|
|
1610
1664
|
### Node.js minimum version raised to 22.15.0
|
|
1611
1665
|
|
|
1612
|
-
v2 requires Node.js **22.15.0** or later. This is the first version that includes `module.registerHooks()`, which the SDK uses to register its TypeScript loader hook synchronously in the main thread. No source change is required; ensure your environment runs Node.js 22.
|
|
1666
|
+
v2 requires Node.js **22.15.0** or later. This is the first version that includes `module.registerHooks()`, which the SDK uses to register its TypeScript loader hook synchronously in the main thread. The actual floor is now **22.18.0**: Node 22.15.0–22.17.x has a bug ([nodejs/node#58607](https://github.com/nodejs/node/issues/58607)) that crashes `tailor seed validate` when requiring `node:`-scheme-only builtins such as `node:sqlite`, fixed upstream in 22.18.0. No source change is required; ensure your environment runs Node.js 22.18.0+.
|
|
1613
1667
|
|
|
1614
1668
|
### Legacy bundle artifact cleanup removed from deploy
|
|
1615
1669
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Migrating to v3
|
|
2
|
+
|
|
3
|
+
<!-- Generated from the sdk-codemod registry. Run `pnpm codemod:docs:update` and edit `packages/sdk-codemod/src/registry.ts` instead of this file. -->
|
|
4
|
+
|
|
5
|
+
Run the codemods, then finish anything reported as not migrated automatically:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx @tailor-platform/sdk-codemod --from <current-version> --to <target-version>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## function test-run → function run
|
|
12
|
+
|
|
13
|
+
**Migration:** Partially automatic
|
|
14
|
+
|
|
15
|
+
Rename `tailor function test-run` invocations to `tailor function run`. `test-run` remains as a deprecated alias until it is removed in v3.
|
|
16
|
+
|
|
17
|
+
Before:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
tailor function test-run resolvers/add.ts --arg '{"a":1,"b":2}'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
After:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
tailor function run resolvers/add.ts --arg '{"a":1,"b":2}'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<details>
|
|
30
|
+
<summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
The `tailor function test-run` subcommand is renamed to `tailor function run`;
|
|
34
|
+
the old name is removed in v3. Replace any remaining `function test-run`
|
|
35
|
+
invocations the codemod did not rewrite (e.g. wrapped across lines or invoked
|
|
36
|
+
through a package runner such as `npx @tailor-platform/sdk`) with
|
|
37
|
+
`function run`. Leave prose that merely mentions the old subcommand name
|
|
38
|
+
unchanged unless it documents a command to type.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
</details>
|
package/docs/quickstart.md
CHANGED
|
@@ -12,7 +12,7 @@ Contact us [here](https://www.tailor.tech/demo) to get started.
|
|
|
12
12
|
|
|
13
13
|
### Install Node.js
|
|
14
14
|
|
|
15
|
-
The SDK requires Node.js 22.
|
|
15
|
+
The SDK requires Node.js 22.18.0 or later. Install Node.js via your package manager by following the official Node.js instructions.
|
|
16
16
|
|
|
17
17
|
Alternatively, you can use [Bun](https://bun.sh/) as the runtime.
|
|
18
18
|
|
|
@@ -26,9 +26,7 @@ Configure an AI Gateway using `defineAIGateway()`:
|
|
|
26
26
|
```typescript
|
|
27
27
|
import { defineAIGateway, defineConfig } from "@tailor-platform/sdk";
|
|
28
28
|
|
|
29
|
-
const aiGateway = defineAIGateway("my-aigateway", {
|
|
30
|
-
authNamespace: "default",
|
|
31
|
-
});
|
|
29
|
+
const aiGateway = defineAIGateway("my-aigateway", {});
|
|
32
30
|
|
|
33
31
|
export default defineConfig({
|
|
34
32
|
name: "my-app",
|
|
@@ -40,14 +38,42 @@ export default defineConfig({
|
|
|
40
38
|
|
|
41
39
|
### authNamespace
|
|
42
40
|
|
|
43
|
-
The auth namespace used to resolve request tokens against your workspace's auth configuration.
|
|
41
|
+
The auth namespace used to resolve request tokens against your workspace's auth configuration. Optional — when omitted, it defaults to your application's own Auth service (local or external, the name passed to `defineAuth()`), which is what most AI Gateways need. Omitting it without an Auth service configured is rejected by `deploy`/`generate`, asking you to either define one or set `authNamespace` explicitly:
|
|
44
42
|
|
|
45
43
|
```typescript
|
|
46
|
-
defineAIGateway
|
|
47
|
-
|
|
44
|
+
import { defineAIGateway, defineAuth, defineConfig } from "@tailor-platform/sdk";
|
|
45
|
+
|
|
46
|
+
const auth = defineAuth("my-auth", {
|
|
47
|
+
// ...auth configuration...
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const aiGateway = defineAIGateway("my-aigateway", {}); // defaults to "my-auth"
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
name: "my-app",
|
|
54
|
+
auth,
|
|
55
|
+
aiGateways: [aiGateway],
|
|
48
56
|
});
|
|
49
57
|
```
|
|
50
58
|
|
|
59
|
+
Type-checked and autocompleted against your own Auth service name via the generated `tailor.d.ts` (the `AuthNamespaceNameRegistry` interface). Run `tailor generate` (or `deploy`) after defining an Auth service to refresh it. Before the first generate run, `authNamespace` accepts any string.
|
|
60
|
+
|
|
61
|
+
To authenticate against a **different** application's Auth service, reference it as an [external resource](../configuration.md#external-resources) in your own config — `authNamespace` then defaults to it like any other Auth service:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { defineAIGateway, defineConfig } from "@tailor-platform/sdk";
|
|
65
|
+
|
|
66
|
+
const aiGateway = defineAIGateway("my-aigateway", {}); // defaults to "shared-auth"
|
|
67
|
+
|
|
68
|
+
export default defineConfig({
|
|
69
|
+
name: "my-app",
|
|
70
|
+
auth: { name: "shared-auth", external: true },
|
|
71
|
+
aiGateways: [aiGateway],
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
An `authNamespace` that doesn't match any auth namespace in your workspace surfaces only at runtime, as `401 Unauthorized` on every request to the gateway.
|
|
76
|
+
|
|
51
77
|
### cors
|
|
52
78
|
|
|
53
79
|
Optional list of allowed origins for browser-based clients. Each entry is one of:
|
|
@@ -61,7 +87,6 @@ An optional `:port` may be appended in all URL forms. Omitting `cors` (or passin
|
|
|
61
87
|
|
|
62
88
|
```typescript
|
|
63
89
|
defineAIGateway("my-aigateway", {
|
|
64
|
-
authNamespace: "default",
|
|
65
90
|
cors: ["https://app.example.com", "https://*.example.com"],
|
|
66
91
|
});
|
|
67
92
|
```
|
|
@@ -81,8 +106,7 @@ const website = defineStaticWebSite("my-frontend", {
|
|
|
81
106
|
});
|
|
82
107
|
|
|
83
108
|
const aiGateway = defineAIGateway("my-aigateway", {
|
|
84
|
-
//
|
|
85
|
-
authNamespace: "default",
|
|
109
|
+
// authNamespace omitted: defaults to this app's own Auth service, declared below.
|
|
86
110
|
cors: [website.url],
|
|
87
111
|
});
|
|
88
112
|
|
|
@@ -374,7 +374,7 @@ must return the same input type.
|
|
|
374
374
|
|
|
375
375
|
### Authentication for Operations
|
|
376
376
|
|
|
377
|
-
|
|
377
|
+
`graphql`, `function`, `jobFunction`, and `workflow` operations can specify an `invoker` to execute with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names defined in your auth config:
|
|
378
378
|
|
|
379
379
|
```typescript
|
|
380
380
|
import { createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
|
|
@@ -390,6 +390,10 @@ export default createExecutor({
|
|
|
390
390
|
});
|
|
391
391
|
```
|
|
392
392
|
|
|
393
|
+
The machine user is resolved in your application's auth namespace — the name of your Auth service, local or external. `webhook` is the only operation kind that does not accept `invoker`, since it calls an external URL rather than acting inside your workspace.
|
|
394
|
+
|
|
395
|
+
Without an `invoker`, the operation runs as whoever raised the trigger event, or anonymously when there is no such principal — as with a `schedule` trigger. Declare an `invoker` whenever the operation needs an identity of its own.
|
|
396
|
+
|
|
393
397
|
## Event Payloads
|
|
394
398
|
|
|
395
399
|
Each trigger type provides specific context data in the callback functions.
|