@tailor-platform/sdk 2.3.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +1 -1
  3. package/dist/{application-F-nl107y.mjs → application-C8a0UJ-z.mjs} +201 -149
  4. package/dist/application-C8a0UJ-z.mjs.map +1 -0
  5. package/dist/application-D4zOiLLa.mjs +3 -0
  6. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +4 -4
  7. package/dist/cli/commands/tailordb/migrate/generate.d.mts +3 -3
  8. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -5
  9. package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
  10. package/dist/cli/lib.mjs +2 -2
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/cli/main.mjs +174 -106
  13. package/dist/cli/main.mjs.map +1 -1
  14. package/dist/cli/ts-hook.mjs +3 -1
  15. package/dist/completion/zsh-worker.zsh +19 -11
  16. package/dist/configure/config/index.d.mts +1 -1
  17. package/dist/configure/index.d.mts +2 -1
  18. package/dist/configure/index.mjs +2 -2
  19. package/dist/configure/index.mjs.map +1 -1
  20. package/dist/configure/services/aigateway/index.d.mts +5 -4
  21. package/dist/configure/services/aigateway/types.d.mts +6 -1
  22. package/dist/configure/services/auth/types.d.mts +2 -2
  23. package/dist/configure/services/tailordb/permission.d.mts +1 -1
  24. package/dist/configure/services/tailordb/schema.d.mts +1 -1
  25. package/dist/configure/services/tailordb/types.d.mts +7 -4
  26. package/dist/configure/types/auth-namespace-name.d.mts +18 -0
  27. package/dist/{crashreport-CINZ5dVN.mjs → crashreport-Cd4TqfZq.mjs} +1 -1
  28. package/dist/{crashreport-CIIfLnoO.mjs → crashreport-Q0pDAlrj.mjs} +8 -4
  29. package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-Q0pDAlrj.mjs.map} +1 -1
  30. package/dist/{errors-BVb6vYGy.mjs → errors-Bxut5_Sy.mjs} +2 -2
  31. package/dist/{errors-BVb6vYGy.mjs.map → errors-Bxut5_Sy.mjs.map} +1 -1
  32. package/dist/file-BUcmVIH2.mjs.map +1 -1
  33. package/dist/kysely/index.mjs +2 -1
  34. package/dist/kysely/index.mjs.map +1 -1
  35. package/dist/{logger-DSdExfor.mjs → logger-D0bEznPv.mjs} +9 -5
  36. package/dist/{logger-DSdExfor.mjs.map → logger-D0bEznPv.mjs.map} +1 -1
  37. package/dist/package-json-8b0O9TlX.mjs.map +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  39. package/dist/plugin/builtin/enum-constants/index.mjs +5 -5
  40. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  41. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  42. package/dist/plugin/builtin/file-utils/index.mjs +14 -11
  43. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  44. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  45. package/dist/plugin/builtin/kysely-type/index.mjs +9 -9
  46. package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -1
  47. package/dist/plugin/builtin/seed/index.mjs +1 -1
  48. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -4
  49. package/dist/plugin/get-generated-type.d.mts +4 -4
  50. package/dist/plugin/index.mjs +13 -13
  51. package/dist/plugin/index.mjs.map +1 -1
  52. package/dist/plugin/types.d.mts +2 -2
  53. package/dist/plugin/with-context.d.mts +1 -1
  54. package/dist/{register-ts-hook-ClI226n2.mjs → register-ts-hook-Vqjza10T.mjs} +552 -416
  55. package/dist/register-ts-hook-Vqjza10T.mjs.map +1 -0
  56. package/dist/{repl-editor-BCozyiNq.mjs → repl-editor-F9LotMNx.mjs} +3 -2
  57. package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-F9LotMNx.mjs.map} +1 -1
  58. package/dist/runtime/file.d.mts +14 -14
  59. package/dist/{schema--xYWRGfe.mjs → schema-D4TC4BC3.mjs} +4 -3
  60. package/dist/schema-D4TC4BC3.mjs.map +1 -0
  61. package/dist/seed/index.d.mts +4 -4
  62. package/dist/seed/index.mjs +3 -3
  63. package/dist/seed/index.mjs.map +1 -1
  64. package/dist/{seed-xqM9WIHP.mjs → seed-Cibjmtry.mjs} +46 -40
  65. package/dist/seed-Cibjmtry.mjs.map +1 -0
  66. package/dist/{service-C_WpbKHu.mjs → service-2grcAOCJ.mjs} +24 -24
  67. package/dist/service-2grcAOCJ.mjs.map +1 -0
  68. package/dist/service-CaBPNDIZ.mjs +3 -0
  69. package/dist/{service-hZskxZmg.mjs → service-LTfp03ZZ.mjs} +7 -5
  70. package/dist/{service-hZskxZmg.mjs.map → service-LTfp03ZZ.mjs.map} +1 -1
  71. package/dist/types/aigateway.generated.d.mts +2 -2
  72. package/dist/types/auth.generated.d.mts +3 -3
  73. package/dist/types/executor.generated.d.mts +1 -1
  74. package/dist/types/tailordb.generated.d.mts +12 -12
  75. package/dist/utils/test/index.d.mts +4 -4
  76. package/dist/utils/test/index.mjs +4 -4
  77. package/dist/utils/test/index.mjs.map +1 -1
  78. package/dist/vitest/index.mjs +13 -7
  79. package/dist/vitest/index.mjs.map +1 -1
  80. package/dist/vitest/mocks/file.d.mts +1 -1
  81. package/docs/cli/application.md +3 -1
  82. package/docs/cli/function.md +17 -13
  83. package/docs/cli/tailordb.md +30 -30
  84. package/docs/cli/workspace.md +2 -2
  85. package/docs/cli-reference.md +21 -21
  86. package/docs/configuration.md +2 -2
  87. package/docs/migration/v2.md +4 -4
  88. package/docs/migration/v3.md +41 -0
  89. package/docs/quickstart.md +1 -1
  90. package/docs/services/aigateway.md +33 -9
  91. package/docs/services/executor.md +5 -1
  92. package/docs/services/tailordb-migration.md +47 -47
  93. package/docs/services/tailordb.md +7 -7
  94. package/docs/testing.md +1 -1
  95. package/package.json +6 -6
  96. package/dist/application-BZfk4HKm.mjs +0 -3
  97. package/dist/application-F-nl107y.mjs.map +0 -1
  98. package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
  99. package/dist/schema--xYWRGfe.mjs.map +0 -1
  100. package/dist/seed-xqM9WIHP.mjs.map +0 -1
  101. package/dist/service-C_WpbKHu.mjs.map +0 -1
  102. package/dist/service-D1RCdzIL.mjs +0 -3
@@ -46,10 +46,10 @@ declare function mockFile(options?: MockFileOptions): {
46
46
  calls: FileCall[];
47
47
  clear(): void;
48
48
  reset(): void;
49
+ delete: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<void>>;
49
50
  upload: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string, data: string | ArrayBuffer | Uint8Array | number[], options?: FileUploadOptions) => Promise<FileUploadResponse>>;
50
51
  download: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadResponse>>;
51
52
  downloadAsBase64: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadAsBase64Response>>;
52
- delete: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<void>>;
53
53
  getMetadata: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileMetadata>>;
54
54
  downloadStream: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadStreamResponse>>;
55
55
  uploadStream: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string, readableStream: ReadableStream<Uint8Array | ArrayBuffer>, options?: FileUploadStreamOptions) => Promise<FileUploadResponse>>;
@@ -190,7 +190,9 @@ Pass the global `--json` / `-j` flag to get machine-readable output.
190
190
  ```json
191
191
  {
192
192
  "summary": { "create": 2, "update": 1, "delete": 0, "replace": 0 },
193
- "changes": [{ "action": "create", "name": "Order", "labels": ["type"], "namespace": "tailordb" }],
193
+ "changes": [
194
+ { "action": "create", "name": "Order", "labels": ["table"], "namespace": "tailordb" }
195
+ ],
194
196
  "warnings": [
195
197
  { "type": "unmanaged", "resourceType": "tailorDB", "name": "LegacyType" },
196
198
  { "type": "skippedSecret", "resourceType": "secret", "name": "DB_PASSWORD" }
@@ -16,12 +16,12 @@ See [Global Options](../cli-reference.md#global-options) for options available t
16
16
 
17
17
  **Commands**
18
18
 
19
- | Command | Description |
20
- | ----------------------------------------- | --------------------------------------------------------------- |
21
- | [`function get`](#function-get) | Get a function registry by name |
22
- | [`function list`](#function-list) | List function registries in a workspace |
23
- | [`function logs`](#function-logs) | List or get function execution logs. |
24
- | [`function test-run`](#function-test-run) | Run a function on the Tailor Platform server without deploying. |
19
+ | Command | Aliases | Description |
20
+ | --------------------------------- | ---------- | --------------------------------------------------------------- |
21
+ | [`function get`](#function-get) | - | Get a function registry by name |
22
+ | [`function list`](#function-list) | - | List function registries in a workspace |
23
+ | [`function logs`](#function-logs) | - | List or get function execution logs. |
24
+ | [`function run`](#function-run) | `test-run` | Run a function on the Tailor Platform server without deploying. |
25
25
 
26
26
  ### function get
27
27
 
@@ -119,18 +119,20 @@ $ tailor function logs <execution-id> --json
119
119
 
120
120
  **Notes**
121
121
 
122
- When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to your original source files (clickable file links and code snippets, matching `function test-run` output).
122
+ When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to your original source files (clickable file links and code snippets, matching `function run` output).
123
123
 
124
124
  Stack traces are mapped only when the execution includes a content hash for the exact build that ran. If the content hash is missing or the build is no longer available, the command falls back to a plain-text error display.
125
125
 
126
- ### function test-run
126
+ ### function run
127
127
 
128
128
  Run a function on the Tailor Platform server without deploying.
129
129
 
130
+ **Aliases:** `test-run`
131
+
130
132
  **Usage**
131
133
 
132
134
  ```
133
- tailor function test-run [options] <file>
135
+ tailor function run [options] <file>
134
136
  ```
135
137
 
136
138
  **Arguments**
@@ -157,19 +159,19 @@ See [Global Options](../cli-reference.md#global-options) for options available t
157
159
  **Run a resolver with input arguments**
158
160
 
159
161
  ```bash
160
- $ tailor function test-run resolvers/add.ts --arg '{"a":1,"b":2}'
162
+ $ tailor function run resolvers/add.ts --arg '{"a":1,"b":2}'
161
163
  ```
162
164
 
163
165
  **Run a specific workflow job by name**
164
166
 
165
167
  ```bash
166
- $ tailor function test-run workflows/sample.ts --name validate-order
168
+ $ tailor function run workflows/sample.ts --name validate-order
167
169
  ```
168
170
 
169
171
  **Run a pre-bundled .js file directly**
170
172
 
171
173
  ```bash
172
- $ tailor function test-run build/resolvers/add.js --arg '{"a":1,"b":2}'
174
+ $ tailor function run build/resolvers/add.js --arg '{"a":1,"b":2}'
173
175
  ```
174
176
 
175
177
  **Notes**
@@ -177,6 +179,8 @@ $ tailor function test-run build/resolvers/add.js --arg '{"a":1,"b":2}'
177
179
  You can pass either a source file (`.ts`) or a pre-bundled file (`.js`).
178
180
  When a `.js` file is provided, detection and bundling are skipped and the file is executed as-is.
179
181
 
182
+ `test-run` is a deprecated alias of this command and will be removed in v3.
183
+
180
184
  > [!WARNING]
181
- > Workflow job `.start()` calls do not work in test-run mode.
185
+ > Workflow job `.start()` calls do not work in this mode.
182
186
  > Started jobs are not executed; only the target job's `body` function runs in isolation.
@@ -28,14 +28,14 @@ Truncate (delete all records from) TailorDB tables.
28
28
  **Usage**
29
29
 
30
30
  ```
31
- tailor tailordb truncate [options] [types]
31
+ tailor tailordb truncate [options] [tables]
32
32
  ```
33
33
 
34
34
  **Arguments**
35
35
 
36
- | Argument | Description | Required |
37
- | -------- | ---------------------- | -------- |
38
- | `types` | Type names to truncate | No |
36
+ | Argument | Description | Required |
37
+ | -------- | ----------------------- | -------- |
38
+ | `tables` | Table names to truncate | No |
39
39
 
40
40
  **Options**
41
41
 
@@ -62,21 +62,21 @@ tailor tailordb truncate --all --yes
62
62
  # Truncate all tables in a specific namespace
63
63
  tailor tailordb truncate --namespace myNamespace
64
64
 
65
- # Truncate specific types (namespace is auto-detected)
65
+ # Truncate specific tables (namespace is auto-detected)
66
66
  tailor tailordb truncate User Post Comment
67
67
 
68
- # Truncate specific types with confirmation skipped
68
+ # Truncate specific tables with confirmation skipped
69
69
  tailor tailordb truncate User Post --yes
70
70
  ```
71
71
 
72
72
  **Notes:**
73
73
 
74
- - You must specify exactly one of: `--all`, `--namespace`, or type names
75
- - When truncating specific types, the namespace is automatically detected from your config
74
+ - You must specify exactly one of: `--all`, `--namespace`, or table names
75
+ - When truncating specific tables, the namespace is automatically detected from your config
76
76
  - Confirmation prompts vary based on the operation:
77
77
  - `--all`: requires typing `truncate all`
78
78
  - `--namespace`: requires typing `truncate <namespace-name>`
79
- - Specific types: requires typing `yes`
79
+ - Specific tables: requires typing `yes`
80
80
  - Use `--yes` flag to skip confirmation prompts (useful for scripts and CI/CD)
81
81
  - Namespaces declared with `{ external: true }` are skipped by `--all` and rejected with a dedicated error when targeted by `--namespace`. Run truncate from the app that owns the namespace.
82
82
 
@@ -94,22 +94,22 @@ tailor tailordb migration <command>
94
94
 
95
95
  **Commands**
96
96
 
97
- | Command | Description |
98
- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
99
- | [`tailordb migration generate`](#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot. |
100
- | [`tailordb migration rebaseline`](#tailordb-migration-rebaseline) | Collapse the full migration history into a new 0000 baseline. |
101
- | [`tailordb migration script`](#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none. |
102
- | [`tailordb migration set`](#tailordb-migration-set) | Set migration checkpoint to a specific number. |
103
- | [`tailordb migration status`](#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
104
- | [`tailordb migration sync`](#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift). |
105
- | [`tailordb migration test`](#tailordb-migration-test) | Test pending migrations with seed fixtures or cloned data in a temporary workspace. |
106
- | [`tailordb migration validate`](#tailordb-migration-validate) | Validate the full migration history, unreviewed generated migration scripts, and schema drift (local types vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found. |
97
+ | Command | Description |
98
+ | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
+ | [`tailordb migration generate`](#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local tables and the previous migration snapshot. |
100
+ | [`tailordb migration rebaseline`](#tailordb-migration-rebaseline) | Collapse the full migration history into a new 0000 baseline. |
101
+ | [`tailordb migration script`](#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none. |
102
+ | [`tailordb migration set`](#tailordb-migration-set) | Set migration checkpoint to a specific number. |
103
+ | [`tailordb migration status`](#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
104
+ | [`tailordb migration sync`](#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift). |
105
+ | [`tailordb migration test`](#tailordb-migration-test) | Test pending migrations with seed fixtures or cloned data in a temporary workspace. |
106
+ | [`tailordb migration validate`](#tailordb-migration-validate) | Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found. |
107
107
 
108
108
  See [Global Options](../cli-reference.md#global-options) for options available to all commands.
109
109
 
110
110
  #### tailordb migration generate
111
111
 
112
- Generate migration files by detecting schema differences between current local types and the previous migration snapshot.
112
+ Generate migration files by detecting schema differences between current local tables and the previous migration snapshot.
113
113
 
114
114
  **Usage**
115
115
 
@@ -119,15 +119,15 @@ tailor tailordb migration generate [options]
119
119
 
120
120
  **Options**
121
121
 
122
- | Option | Alias | Description | Required | Default | Env |
123
- | ------------------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------- | -------------------- |
124
- | `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
125
- | `--config <CONFIG>` | `-c` | Path to Tailor config file | No | `"tailor.config.ts"` | `TAILOR_CONFIG_PATH` |
126
- | `--name <NAME>` | `-n` | Optional description for the migration | No | - | - |
127
- | `--init` | - | Delete existing migrations and start fresh | No | `false` | - |
128
- | `--rename <RENAME>` | - | Record a field or type rename instead of remove + add (format: "Type.oldField:newField" or "OldType:NewType"; repeatable). Renames require a migration script that copies the data. | No | - | - |
129
- | `--drop <DROP>` | - | Confirm that a removed field or type is a genuine removal, not a rename (format: "Type.field" or "Type"; repeatable). Required in non-interactive runs for a removal with rename candidates. | No | - | - |
130
- | `--expand-contract <EXPAND_CONTRACT>` | - | Convert a field type through a temporary field (format: "Type.field"; repeatable). Generates two migrations. | No | - | - |
122
+ | Option | Alias | Description | Required | Default | Env |
123
+ | ------------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------- | -------------------- |
124
+ | `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
125
+ | `--config <CONFIG>` | `-c` | Path to Tailor config file | No | `"tailor.config.ts"` | `TAILOR_CONFIG_PATH` |
126
+ | `--name <NAME>` | `-n` | Optional description for the migration | No | - | - |
127
+ | `--init` | - | Delete existing migrations and start fresh | No | `false` | - |
128
+ | `--rename <RENAME>` | - | Record a field or table rename instead of remove + add (format: "Table.oldField:newField" or "OldTable:NewTable"; repeatable). Renames require a migration script that copies the data. | No | - | - |
129
+ | `--drop <DROP>` | - | Confirm that a removed field or table is a genuine removal, not a rename (format: "Table.field" or "Table"; repeatable). Required in non-interactive runs for a removal with rename candidates. | No | - | - |
130
+ | `--expand-contract <EXPAND_CONTRACT>` | - | Convert a field type through a temporary field (format: "Table.field"; repeatable). Generates two migrations. | No | - | - |
131
131
 
132
132
  See [Global Options](../cli-reference.md#global-options) for options available to all commands.
133
133
 
@@ -309,7 +309,7 @@ The source workspace is read-only. Without --target-workspace-id, the command cr
309
309
 
310
310
  #### tailordb migration validate
311
311
 
312
- Validate the full migration history, unreviewed generated migration scripts, and schema drift (local types vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.
312
+ Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.
313
313
 
314
314
  **Usage**
315
315
 
@@ -338,7 +338,7 @@ tailor profile create [options] <name>
338
338
  | `--user <USER>` | `-u` | User email address or machine user client ID | Yes | - | - |
339
339
  | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | Yes | - | - |
340
340
  | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands while the profile is active. | No | `"write"` | - |
341
- | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token). | No | - | - |
341
+ | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function run, machineuser token). | No | - | - |
342
342
  | `--machine-user-override <MACHINE_USER_OVERRIDE>` | - | Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user. | No | - | - |
343
343
  | `--platform-url <PLATFORM_URL>` | - | Platform API base URL for this profile. | No | - | `TAILOR_PLATFORM_URL` |
344
344
  | `--oauth2-client-id <OAUTH2_CLIENT_ID>` | - | OAuth2 client ID for logging in to this profile's platform. | No | - | `TAILOR_PLATFORM_OAUTH2_CLIENT_ID` |
@@ -399,7 +399,7 @@ tailor profile update [options] <name>
399
399
  | `--user <USER>` | `-u` | New user email address or machine user client ID | No | - |
400
400
  | `--workspace-id <WORKSPACE_ID>` | `-w` | New workspace ID | No | - |
401
401
  | `--permission <PERMISSION>` | - | Profile permission. 'read' blocks all write commands; 'write' lifts the restriction. | No | - |
402
- | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token). Pass an empty string to clear. | No | - |
402
+ | `--machine-user <MACHINE_USER>` | `-m` | Default machine user name for application-data commands (query, workflow start, function run, machineuser token). Pass an empty string to clear. | No | - |
403
403
  | `--machine-user-override <MACHINE_USER_OVERRIDE>` | - | Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user; 'allow' lifts the restriction. | No | - |
404
404
  | `--platform-url <PLATFORM_URL>` | - | Platform API base URL for this profile. Pass an empty string to clear. | No | - |
405
405
  | `--oauth2-client-id <OAUTH2_CLIENT_ID>` | - | OAuth2 client ID for logging in to this profile's platform. Pass an empty string to clear. | No | - |
@@ -76,7 +76,7 @@ You can use environment variables to configure workspace and authentication:
76
76
  | `TAILOR_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file |
77
77
  | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user` |
78
78
  | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user` |
79
- | `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run`, `machineuser token` |
79
+ | `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function run`, `machineuser token` |
80
80
  | `TAILOR_PLATFORM_URL` | Platform API base URL. Saved into profiles created with `profile create --platform-url` |
81
81
  | `TAILOR_PLATFORM_OAUTH2_CLIENT_ID` | OAuth2 client ID for user login. Saved into profiles created with `profile create --oauth2-client-id` |
82
82
  | `TAILOR_PLATFORM_CONSOLE_URL` | Console base URL. Saved into profiles created with `profile create --console-url` |
@@ -200,19 +200,19 @@ Commands for managing Tailor Platform applications (work with `tailor.config.ts`
200
200
 
201
201
  Commands for managing TailorDB tables, data, and schema migrations.
202
202
 
203
- | Command | Description |
204
- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
205
- | [tailordb](./cli/tailordb.md#tailordb) | Manage TailorDB tables and data. |
206
- | [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate (delete all records from) TailorDB tables. |
207
- | [tailordb migration](./cli/tailordb.md#tailordb-migration) | Manage TailorDB schema migrations. |
208
- | [tailordb migration generate](./cli/tailordb.md#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot. |
209
- | [tailordb migration rebaseline](./cli/tailordb.md#tailordb-migration-rebaseline) | Collapse the full migration history into a new 0000 baseline. |
210
- | [tailordb migration script](./cli/tailordb.md#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none. |
211
- | [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number. |
212
- | [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
213
- | [tailordb migration sync](./cli/tailordb.md#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift). |
214
- | [tailordb migration test](./cli/tailordb.md#tailordb-migration-test) | Test pending migrations with seed fixtures or cloned data in a temporary workspace. |
215
- | [tailordb migration validate](./cli/tailordb.md#tailordb-migration-validate) | Validate the full migration history, unreviewed generated migration scripts, and schema drift (local types vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found. |
203
+ | Command | Description |
204
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
205
+ | [tailordb](./cli/tailordb.md#tailordb) | Manage TailorDB tables and data. |
206
+ | [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate (delete all records from) TailorDB tables. |
207
+ | [tailordb migration](./cli/tailordb.md#tailordb-migration) | Manage TailorDB schema migrations. |
208
+ | [tailordb migration generate](./cli/tailordb.md#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local tables and the previous migration snapshot. |
209
+ | [tailordb migration rebaseline](./cli/tailordb.md#tailordb-migration-rebaseline) | Collapse the full migration history into a new 0000 baseline. |
210
+ | [tailordb migration script](./cli/tailordb.md#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none. |
211
+ | [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number. |
212
+ | [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
213
+ | [tailordb migration sync](./cli/tailordb.md#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift). |
214
+ | [tailordb migration test](./cli/tailordb.md#tailordb-migration-test) | Test pending migrations with seed fixtures or cloned data in a temporary workspace. |
215
+ | [tailordb migration validate](./cli/tailordb.md#tailordb-migration-validate) | Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found. |
216
216
 
217
217
  ### [Query Commands](./cli/query.md)
218
218
 
@@ -323,13 +323,13 @@ Commands for managing workflows and executions.
323
323
 
324
324
  Commands for managing function registries and viewing function execution logs.
325
325
 
326
- | Command | Description |
327
- | -------------------------------------------------------- | --------------------------------------------------------------- |
328
- | [function](./cli/function.md#function) | Manage functions |
329
- | [function get](./cli/function.md#function-get) | Get a function registry by name |
330
- | [function list](./cli/function.md#function-list) | List function registries in a workspace |
331
- | [function logs](./cli/function.md#function-logs) | List or get function execution logs. |
332
- | [function test-run](./cli/function.md#function-test-run) | Run a function on the Tailor Platform server without deploying. |
326
+ | Command | Description |
327
+ | ------------------------------------------------ | --------------------------------------------------------------- |
328
+ | [function](./cli/function.md#function) | Manage functions |
329
+ | [function get](./cli/function.md#function-get) | Get a function registry by name |
330
+ | [function list](./cli/function.md#function-list) | List function registries in a workspace |
331
+ | [function logs](./cli/function.md#function-logs) | List or get function execution logs. |
332
+ | [function run](./cli/function.md#function-run) | Run a function on the Tailor Platform server without deploying. |
333
333
 
334
334
  ### [Executor Commands](./cli/executor.md)
335
335
 
@@ -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 test-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`.
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 test-run` | Same `env` argument shape as the detected resolver, executor, or workflow job |
255
+ | `function run` | Same `env` argument shape as the detected resolver, executor, or workflow job |
256
256
 
257
257
  ```typescript
258
258
  // In resolvers
@@ -1422,7 +1422,7 @@ single generation pass and resolves once it completes.
1422
1422
 
1423
1423
  **Migration:** Partially automatic
1424
1424
 
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`, type-name arguments), plus a new `--upsert` flag to update existing rows instead of failing on duplicate ids.
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.
1426
1426
 
1427
1427
  Before:
1428
1428
 
@@ -1448,8 +1448,8 @@ CLI plugin (@tailor-platform/sdk-plugin-seed) replaces it:
1448
1448
  - Install @tailor-platform/sdk-plugin-seed as a devDependency next to
1449
1449
  @tailor-platform/sdk.
1450
1450
  - Replace `node <distPath>/exec.mjs [options] [types...]` invocations with
1451
- `tailor seed apply [options] [types...]` (same options: --machine-user/-m,
1452
- --namespace/-n, --skip-idp, --truncate, --yes, and type-name arguments,
1451
+ `tailor seed apply [options] [entities...]` (same options: --machine-user/-m,
1452
+ --namespace/-n, --skip-idp, --truncate, --yes, and entity-name arguments,
1453
1453
  plus a new --upsert flag to update existing rows instead of failing on
1454
1454
  duplicate ids).
1455
1455
  - Replace `node <distPath>/exec.mjs validate [path]` with
@@ -1663,7 +1663,7 @@ The CLI stores human users by their stable subject ID instead of email (email is
1663
1663
 
1664
1664
  ### Node.js minimum version raised to 22.15.0
1665
1665
 
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. No source change is required; ensure your environment runs Node.js 22.15.0+.
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+.
1667
1667
 
1668
1668
  ### Legacy bundle artifact cleanup removed from deploy
1669
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>
@@ -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.0 or later. Install Node.js via your package manager by following the official Node.js instructions.
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. Must match an existing auth namespace.
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("my-aigateway", {
47
- authNamespace: "default",
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
- // Name of an auth namespace in your workspace; request tokens are resolved against it.
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
- GraphQL 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:
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.