@tailor-platform/sdk 1.83.0 → 1.85.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 +58 -0
- package/dist/application-C-zsrNjn.mjs +3 -0
- package/dist/{application-Cp0FxIm2.mjs → application-m5tYtz0-.mjs} +246 -68
- package/dist/application-m5tYtz0-.mjs.map +1 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +2 -0
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
- package/dist/cli/commands/generate/service.d.mts +1 -1
- package/dist/cli/commands/generate/types.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/index.mjs +291 -29
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +1 -1
- package/dist/cli/lib.mjs +92 -36
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/shared/client.d.mts +28 -3
- package/dist/cli/skills.d.mts +1 -1
- package/dist/completion/zsh-worker.zsh +85 -22
- package/dist/configure/index.d.mts +2 -2
- package/dist/configure/index.mjs +170 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/executor/index.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +245 -2
- package/dist/configure/services/executor/trigger/index.d.mts +3 -3
- package/dist/configure/services/index.d.mts +2 -2
- package/dist/configure/services/tailordb/index.d.mts +0 -1
- package/dist/configure/services/workflow/job.d.mts +9 -0
- package/dist/configure/services/workflow/workflow.d.mts +10 -0
- package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
- package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/{register-typescript-runtime-CCHyKeXO.mjs → register-typescript-runtime-nG-n9lPw.mjs} +752 -403
- package/dist/register-typescript-runtime-nG-n9lPw.mjs.map +1 -0
- package/dist/{seed-DFFigL8V.mjs → seed-6eTFj-3Q.mjs} +158 -41
- package/dist/seed-6eTFj-3Q.mjs.map +1 -0
- package/dist/{service-B0MaodSg.mjs → service-CPJWhTLn.mjs} +29 -2
- package/dist/service-CPJWhTLn.mjs.map +1 -0
- package/dist/service-Cigg_U-v.mjs +3 -0
- package/dist/{service_pb-BwZRiNug.mjs → service_pb-D5--My_M.mjs} +5 -5
- package/dist/service_pb-D5--My_M.mjs.map +1 -0
- package/dist/{service_pb-wRkxUta6.mjs → service_pb-i8CmnQP4.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
- package/dist/types/executor.generated.d.mts +23 -3
- package/dist/vitest/index.mjs +3 -35
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/{workspace_resource_pb-UGK1SSn_.mjs → workspace_resource_pb-DXnO2AT-.mjs} +7 -7
- package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
- package/docs/cli/tailordb.md +36 -12
- package/docs/cli-reference.md +16 -15
- package/docs/generator/builtin.md +7 -0
- package/docs/services/executor.md +83 -3
- package/docs/services/idp.md +3 -3
- package/docs/services/tailordb-migration.md +24 -4
- package/docs/services/workflow.md +26 -0
- package/package.json +17 -18
- package/dist/application-CP7JKG9R.mjs +0 -3
- package/dist/application-Cp0FxIm2.mjs.map +0 -1
- package/dist/register-typescript-runtime-CCHyKeXO.mjs.map +0 -1
- package/dist/seed-DFFigL8V.mjs.map +0 -1
- package/dist/service-B0MaodSg.mjs.map +0 -1
- package/dist/service-KnAiVofD.mjs +0 -3
- package/dist/service_pb-BwZRiNug.mjs.map +0 -1
- package/dist/workspace_resource_pb-UGK1SSn_.mjs.map +0 -1
package/docs/cli/tailordb.md
CHANGED
|
@@ -95,13 +95,14 @@ tailor-sdk tailordb migration <command>
|
|
|
95
95
|
|
|
96
96
|
**Commands**
|
|
97
97
|
|
|
98
|
-
| Command | Description
|
|
99
|
-
| ------------------------------------------------------------- |
|
|
100
|
-
| [`tailordb migration generate`](#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot.
|
|
101
|
-
| [`tailordb migration script`](#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory.
|
|
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).
|
|
98
|
+
| Command | Description |
|
|
99
|
+
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
100
|
+
| [`tailordb migration generate`](#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot. |
|
|
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 validate`](#tailordb-migration-validate) | Validate the full migration history and detect 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. |
|
|
105
106
|
|
|
106
107
|
See [Global Options](../cli-reference.md#global-options) for options available to all commands.
|
|
107
108
|
|
|
@@ -128,7 +129,7 @@ See [Global Options](../cli-reference.md#global-options) for options available t
|
|
|
128
129
|
|
|
129
130
|
#### tailordb migration script
|
|
130
131
|
|
|
131
|
-
Add a migration script (migrate.ts) template to an existing migration directory.
|
|
132
|
+
Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none.
|
|
132
133
|
|
|
133
134
|
**Usage**
|
|
134
135
|
|
|
@@ -144,10 +145,12 @@ tailor-sdk tailordb migration script [options] <number>
|
|
|
144
145
|
|
|
145
146
|
**Options**
|
|
146
147
|
|
|
147
|
-
| Option | Alias | Description
|
|
148
|
-
| ------------------------- | ----- |
|
|
149
|
-
| `--config <CONFIG>` | `-c` | Path to SDK config file
|
|
150
|
-
| `--namespace <NAMESPACE>` | `-n` | Target TailorDB namespace (required if multiple namespaces exist)
|
|
148
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
149
|
+
| ------------------------- | ----- | -------------------------------------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
|
|
150
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
151
|
+
| `--namespace <NAMESPACE>` | `-n` | Target TailorDB namespace (required if multiple namespaces exist) | No | - | - |
|
|
152
|
+
| `--no-script` | - | Record that this migration intentionally runs without a migration script (requires --reason) | No | - | - |
|
|
153
|
+
| `--reason <REASON>` | - | Reason why no migration script is needed (used with --no-script) | No | - | - |
|
|
151
154
|
|
|
152
155
|
See [Global Options](../cli-reference.md#global-options) for options available to all commands.
|
|
153
156
|
|
|
@@ -228,6 +231,27 @@ tailor-sdk tailordb migration sync [options] <number>
|
|
|
228
231
|
|
|
229
232
|
See [Global Options](../cli-reference.md#global-options) for options available to all commands.
|
|
230
233
|
|
|
234
|
+
#### tailordb migration validate
|
|
235
|
+
|
|
236
|
+
Validate the full migration history and detect 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.
|
|
237
|
+
|
|
238
|
+
**Usage**
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
tailor-sdk tailordb migration validate [options]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Options**
|
|
245
|
+
|
|
246
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
247
|
+
| ------------------------------- | ----- | --------------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
|
|
248
|
+
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
|
|
249
|
+
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
|
|
250
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
251
|
+
| `--namespace <NAMESPACE>` | `-n` | Target TailorDB namespace (validates all namespaces if not specified) | No | - | - |
|
|
252
|
+
|
|
253
|
+
See [Global Options](../cli-reference.md#global-options) for options available to all commands.
|
|
254
|
+
|
|
231
255
|
**See also:** For migration concepts, configuration, workflow, and troubleshooting, see the [TailorDB Migrations guide](../services/tailordb-migration.md).
|
|
232
256
|
|
|
233
257
|
### tailordb erd
|
package/docs/cli-reference.md
CHANGED
|
@@ -128,21 +128,22 @@ Commands for managing Tailor Platform applications (work with `tailor.config.ts`
|
|
|
128
128
|
|
|
129
129
|
Commands for managing TailorDB tables, data, and schema migrations.
|
|
130
130
|
|
|
131
|
-
| Command | Description
|
|
132
|
-
| ---------------------------------------------------------------------------- |
|
|
133
|
-
| [tailordb](./cli/tailordb.md#tailordb) | Manage TailorDB tables and data.
|
|
134
|
-
| [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate (delete all records from) TailorDB tables.
|
|
135
|
-
| [tailordb migration](./cli/tailordb.md#tailordb-migration) | Manage TailorDB schema migrations.
|
|
136
|
-
| [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.
|
|
137
|
-
| [tailordb migration script](./cli/tailordb.md#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory.
|
|
138
|
-
| [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number.
|
|
139
|
-
| [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations.
|
|
140
|
-
| [tailordb migration sync](./cli/tailordb.md#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift).
|
|
141
|
-
| [tailordb
|
|
142
|
-
| [tailordb erd
|
|
143
|
-
| [tailordb erd
|
|
144
|
-
| [tailordb erd
|
|
145
|
-
| [tailordb erd
|
|
131
|
+
| Command | Description |
|
|
132
|
+
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
133
|
+
| [tailordb](./cli/tailordb.md#tailordb) | Manage TailorDB tables and data. |
|
|
134
|
+
| [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate (delete all records from) TailorDB tables. |
|
|
135
|
+
| [tailordb migration](./cli/tailordb.md#tailordb-migration) | Manage TailorDB schema migrations. |
|
|
136
|
+
| [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. |
|
|
137
|
+
| [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. |
|
|
138
|
+
| [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number. |
|
|
139
|
+
| [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
|
|
140
|
+
| [tailordb migration sync](./cli/tailordb.md#tailordb-migration-sync) | Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift). |
|
|
141
|
+
| [tailordb migration validate](./cli/tailordb.md#tailordb-migration-validate) | Validate the full migration history and detect 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. |
|
|
142
|
+
| [tailordb erd](./cli/tailordb.md#tailordb-erd) | Generate TailorDB ERD viewer artifacts from local TailorDB schema. (beta) |
|
|
143
|
+
| [tailordb erd export](./cli/tailordb.md#tailordb-erd-export) | Export TailorDB ERD static viewer from local TailorDB schema. |
|
|
144
|
+
| [tailordb erd diff](./cli/tailordb.md#tailordb-erd-diff) | Render TailorDB ERD schema diff HTML from exported ERD viewers. |
|
|
145
|
+
| [tailordb erd serve](./cli/tailordb.md#tailordb-erd-serve) | Generate and serve TailorDB ERD locally with watch reload. (beta) |
|
|
146
|
+
| [tailordb erd deploy](./cli/tailordb.md#tailordb-erd-deploy) | Deploy ERD static website for TailorDB namespace(s). |
|
|
146
147
|
|
|
147
148
|
### [Query Commands](./cli/query.md)
|
|
148
149
|
|
|
@@ -248,10 +248,17 @@ node seed/exec.mjs -m admin
|
|
|
248
248
|
|
|
249
249
|
# With other options
|
|
250
250
|
node seed/exec.mjs -m admin --truncate --yes
|
|
251
|
+
|
|
252
|
+
# Update rows that already exist instead of failing on duplicate ids
|
|
253
|
+
node seed/exec.mjs --upsert
|
|
251
254
|
```
|
|
252
255
|
|
|
253
256
|
The `--machine-user` option is required at runtime if `machineUserName` is not configured in the generator options.
|
|
254
257
|
|
|
258
|
+
Without `--upsert`, a row whose id already exists fails the whole batch for that type, so nothing is written. With `--upsert`, every TailorDB row must include an `id`; rows with new ids are inserted and rows with existing ids are updated. Optional fields absent from an existing row keep their stored values, while required fields must still be present. Built-In IdP users are looked up by name, so new users are created and existing users are updated.
|
|
259
|
+
|
|
260
|
+
The machine user selected for `--upsert` needs read permission for every seeded TailorDB type. Existing ids are detected with a read query, so a row hidden by read permissions is treated as new and its insert fails as a duplicate.
|
|
261
|
+
|
|
255
262
|
The generated files are compatible with gql-ingest for bulk data import.
|
|
256
263
|
|
|
257
264
|
The `exec.mjs` is fully regenerated on every `sdk generate` and starts with an `@generated` header — do not hand-edit it. Its `--truncate` path reuses the `tailordb truncate` command, so namespaces declared with `{ external: true }` are skipped automatically and a shell app cannot wipe a sibling app's data via `seed:reset`.
|
|
@@ -136,9 +136,9 @@ When the project defines multiple IdPs, pass `idp` to target a specific one. The
|
|
|
136
136
|
idpUserCreatedTrigger({ idp: "my-idp" });
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
Omitting `idp` is allowed only when the project has exactly one IdP; otherwise `
|
|
139
|
+
Omitting `idp` is allowed only when the project has exactly one IdP; otherwise `deploy` fails with an error listing the configured IdPs.
|
|
140
140
|
|
|
141
|
-
These triggers require the IdP to publish user lifecycle events. The SDK enables `publishUserEvents` automatically during `
|
|
141
|
+
These triggers require the IdP to publish user lifecycle events. The SDK enables `publishUserEvents` automatically during `deploy` on each IdP that is targeted by an `idpUser` trigger; set the value explicitly on `defineIdp()` to override. See [IdP service - publishUserEvents](./idp.md#publishuserevents).
|
|
142
142
|
|
|
143
143
|
### Auth Access Token Triggers
|
|
144
144
|
|
|
@@ -152,6 +152,37 @@ Fire on auth access token lifecycle events:
|
|
|
152
152
|
authAccessTokenIssuedTrigger();
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
### Workflow Execution Triggers
|
|
156
|
+
|
|
157
|
+
Fire when a workflow execution changes state. Use the single-event helpers or `workflowExecutionTrigger()` for multiple events:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { createExecutor, workflowExecutionTrigger } from "@tailor-platform/sdk";
|
|
161
|
+
import orderWorkflow from "../workflows/order";
|
|
162
|
+
|
|
163
|
+
export default createExecutor({
|
|
164
|
+
name: "order-workflow-finished",
|
|
165
|
+
trigger: workflowExecutionTrigger({
|
|
166
|
+
workflow: orderWorkflow,
|
|
167
|
+
events: ["completed", "retried"],
|
|
168
|
+
}),
|
|
169
|
+
operation: {
|
|
170
|
+
kind: "function",
|
|
171
|
+
body: async (args) => {
|
|
172
|
+
if (args.event === "completed" && !args.success) {
|
|
173
|
+
console.error(args.error);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The available workflow events are `started`, `completed`, `retried`, `resumed`, `wait_started`, and `wait_resolved`. To observe job-level events, use `workflowJobExecutionStartedTrigger()`, `workflowJobExecutionCompletedTrigger()`, `workflowJobExecutionWaitStartedTrigger()`, `workflowJobExecutionWaitResolvedTrigger()`, or `workflowJobExecutionTrigger()`.
|
|
181
|
+
|
|
182
|
+
`completed` events include `success`; when it is `false`, `error` contains the failure message. A job released from a wait point emits `wait_resolved` instead of `completed`.
|
|
183
|
+
|
|
184
|
+
These triggers require the workflow to publish execution events. The SDK enables `publishEvents` automatically during `deploy` on each targeted workflow, and on every job of a workflow targeted by a `workflowJobExecution*` trigger; set the value explicitly to override. See [Workflow service - Execution Events](./workflow.md#execution-events).
|
|
185
|
+
|
|
155
186
|
### Multi-Event Triggers
|
|
156
187
|
|
|
157
188
|
Handle multiple event types in a single executor using multi-event trigger factories. These accept an `events` array of short event names:
|
|
@@ -200,7 +231,14 @@ idpUserTrigger({ events: ["created", "deleted"], idp: "my-idp" });
|
|
|
200
231
|
authAccessTokenTrigger({ events: ["issued", "revoked"] });
|
|
201
232
|
```
|
|
202
233
|
|
|
203
|
-
|
|
234
|
+
#### `workflowExecutionTrigger()` and `workflowJobExecutionTrigger()`
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
workflowExecutionTrigger({ workflow: orderWorkflow, events: ["started", "completed"] });
|
|
238
|
+
workflowJobExecutionTrigger({ workflow: orderWorkflow, events: ["started", "wait_resolved"] });
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
The `event` field on args matches the short event name, enabling type narrowing. Record triggers use names such as `"created"`, auth token triggers use `"issued"`, and workflow triggers use `"started"`, `"completed"`, and `"wait_resolved"`. The `rawEvent` field contains the full event type string (e.g., `"tailordb.type_record.created"`).
|
|
204
242
|
|
|
205
243
|
## Operation Types
|
|
206
244
|
|
|
@@ -551,3 +589,45 @@ interface AuthAccessTokenContext {
|
|
|
551
589
|
userId: string; // The user associated with the token
|
|
552
590
|
}
|
|
553
591
|
```
|
|
592
|
+
|
|
593
|
+
### Workflow Execution Event Payload
|
|
594
|
+
|
|
595
|
+
Workflow execution triggers receive execution context:
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
interface WorkflowExecutionContext {
|
|
599
|
+
workspaceId: string; // Workspace identifier
|
|
600
|
+
env: TailorEnv; // Environment variables from tailor.config.ts
|
|
601
|
+
actor: TailorActor | null; // Principal that triggered the workflow
|
|
602
|
+
workflowId: string; // Workflow resource ID
|
|
603
|
+
workflowName: string; // Workflow name
|
|
604
|
+
workflowExecutionId: string; // Workflow execution ID
|
|
605
|
+
event: "started" | "completed" | "retried" | "resumed" | "wait_started" | "wait_resolved";
|
|
606
|
+
rawEvent: string; // Full event type
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
Completed events narrow on `success`. Failed executions include `error`; retried executions include `retryCount` and `retryAfter`.
|
|
611
|
+
|
|
612
|
+
```typescript
|
|
613
|
+
body: async (args) => {
|
|
614
|
+
if (args.event === "completed" && !args.success) {
|
|
615
|
+
console.error(args.error);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Workflow Job Execution Event Payload
|
|
621
|
+
|
|
622
|
+
Workflow job execution triggers include every `WorkflowExecutionContext` field above, plus job-specific fields:
|
|
623
|
+
|
|
624
|
+
```typescript
|
|
625
|
+
interface WorkflowJobExecutionContext {
|
|
626
|
+
workflowJobExecutionId: string; // Job execution ID
|
|
627
|
+
jobFunctionName: string; // Name passed to createWorkflowJob
|
|
628
|
+
event: "started" | "completed" | "wait_started" | "wait_resolved";
|
|
629
|
+
rawEvent: string; // Full event type
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
`wait_started` events include `waitKey`, plus JSON-serialized `waitPayload` when the wait point recorded one; `wait_resolved` events include `waitKey`.
|
package/docs/services/idp.md
CHANGED
|
@@ -195,7 +195,7 @@ defineIdp("my-idp", {
|
|
|
195
195
|
|
|
196
196
|
- `enableMfa` - Make TOTP MFA available for users in this namespace. Default `false`. When enabled, users can register an authenticator app (Google Authenticator, 1Password, etc.) from the IdP self-service page.
|
|
197
197
|
- `requireMfa` - Force password-authenticated users to enroll and pass an MFA challenge on each sign-in. Default `false`. Social sign-in (`allowGoogleOauth` / `allowMicrosoftOauth`) is not affected; the upstream provider's MFA covers those sessions.
|
|
198
|
-
- `allowedReturnOrigins` - Origins the IdP self-service pages (such as `/mfa/settings`) are allowed to redirect back to. Each entry is either a literal origin (`https://app.example.com`, scheme + host + optional port, no path/query/fragment) or a static-website placeholder `<name>:url` (e.g. `website.url`) that the CLI resolves to the deployed website's URL at
|
|
198
|
+
- `allowedReturnOrigins` - Origins the IdP self-service pages (such as `/mfa/settings`) are allowed to redirect back to. Each entry is either a literal origin (`https://app.example.com`, scheme + host + optional port, no path/query/fragment) or a static-website placeholder `<name>:url` (e.g. `website.url`) that the CLI resolves to the deployed website's URL at deployment time. Required when `enableMfa` is `true`.
|
|
199
199
|
- `mfaIssuer` - Label shown next to the user account in authenticator apps when TOTP is enrolled. Up to 64 characters. Falls back to `"Tailor Platform IdP"` when empty.
|
|
200
200
|
|
|
201
201
|
**Constraints:** the following combinations are rejected at parse time.
|
|
@@ -330,10 +330,10 @@ defineIdp("my-idp", {
|
|
|
330
330
|
});
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
**Auto-configuration:** When `publishUserEvents` is omitted, the SDK enables it automatically during `
|
|
333
|
+
**Auto-configuration:** When `publishUserEvents` is omitted, the SDK enables it automatically during `deploy` for each IdP that is targeted by an executor's `idpUser` trigger. Targeting is per-IdP: an executor specifies which IdP it subscribes to via the trigger's `idp` option (required in multi-IdP projects). Set the value explicitly to override:
|
|
334
334
|
|
|
335
335
|
- `publishUserEvents: true`: always publish events.
|
|
336
|
-
- `publishUserEvents: false`: never publish events. `
|
|
336
|
+
- `publishUserEvents: false`: never publish events. `deploy` rejects this with an error if any executor's `idpUser` trigger targets this IdP — either remove `publishUserEvents: false` or remove the matching trigger.
|
|
337
337
|
|
|
338
338
|
## Using idp.provider()
|
|
339
339
|
|
|
@@ -131,6 +131,16 @@ tailor-sdk tailordb migration script 0002
|
|
|
131
131
|
|
|
132
132
|
This writes `migrations/0002/migrate.ts` and `migrations/0002/db.ts` next to the existing `diff.json`. The removed field stays readable inside `migrate.ts` because the pre-migration phase keeps it on the type until the script finishes (see [Per-migration phases](#per-migration-phases)). The next `tailor-sdk deploy` runs the script automatically — `migrate.ts` is executed whenever the file exists on disk, regardless of whether the diff itself required it.
|
|
133
133
|
|
|
134
|
+
### Breaking changes without a script
|
|
135
|
+
|
|
136
|
+
Breaking changes require `migrate.ts`. If it is missing at deploy time (for example, the generated script was deleted), `tailor-sdk deploy` fails before applying the migration or anything after it. When there is genuinely nothing to migrate — say, the affected type holds no data yet — record an explicit acknowledgment instead of keeping an empty script:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
tailor-sdk tailordb migration script 0002 --no-script --reason "no data yet, safe to skip"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This stores the reason in `migrations/0002/diff.json` (commit the change). The next `tailor-sdk deploy` applies the schema change as usual, skips only the script step, and logs the recorded reason. The command refuses to record a skip while `migrate.ts` exists — delete the script first. If `migrate.ts` is added back later, the script takes precedence over the acknowledgment and runs.
|
|
143
|
+
|
|
134
144
|
## Configuration
|
|
135
145
|
|
|
136
146
|
```typescript
|
|
@@ -226,6 +236,7 @@ The `env` values are injected at bundle time (the same mechanism as resolvers/ex
|
|
|
226
236
|
| Remove index | No | No | Schema change only (removing the unique constraint from an index is also non-breaking) |
|
|
227
237
|
| Add unique constraint | Yes | Yes | Script must resolve duplicate values |
|
|
228
238
|
| Remove unique constraint | No | No | Schema change only |
|
|
239
|
+
| Change decimal scale | Yes | Yes | Auto-generated script re-saves existing rows under the new scale. Decreasing scale rounds values half-up and can lose precision. If the same change adds a unique constraint, duplicate handling runs after re-saving. |
|
|
229
240
|
| Add enum value | No | No | Schema change only |
|
|
230
241
|
| Remove enum value | Yes | Yes | Script migrates records with removed values |
|
|
231
242
|
| Add type | No | No | Schema change only |
|
|
@@ -254,7 +265,7 @@ When you run `tailor-sdk deploy`, the SDK detects pending migrations (anything p
|
|
|
254
265
|
For each pending migration:
|
|
255
266
|
|
|
256
267
|
1. **Pre-migration**: Type changes that would be breaking are applied in a relaxed form first. Newly-required fields are added as optional; fields whose `optional → required` transition is breaking are temporarily kept optional. Fields that are being removed in this migration are temporarily kept on the type so that `migrate.ts` can still read them (for example, to `innerJoin` through a foreign key that is about to be dropped). Breaking type-level index changes are relaxed the same way: a newly-added unique index is withheld, and an index gaining a unique constraint (or a unique index changing its field set) keeps its previous definition, so `migrate.ts` can resolve duplicates first. Non-breaking changes that are part of the same migration are also applied here.
|
|
257
|
-
2. **Script execution**: If `migrate.ts` exists on disk for this migration, it is bundled and sent to the platform via the script execution API and runs as the configured machine user inside a transaction. The script is hard-required for breaking changes (`diff.requiresMigrationScript`)
|
|
268
|
+
2. **Script execution**: If `migrate.ts` exists on disk for this migration, it is bundled and sent to the platform via the script execution API and runs as the configured machine user inside a transaction. The script is hard-required for breaking changes (`diff.requiresMigrationScript`) — deploy fails if the file is missing, unless a `--no-script` acknowledgment was recorded (see [Breaking changes without a script](#breaking-changes-without-a-script)). It is also executed when present for warning-tier diffs — see [Warnings and optional migration scripts](#warnings-and-optional-migration-scripts).
|
|
258
269
|
3. **Post-migration**: Required constraints are enforced; field and type deletions are applied (the columns/tables are physically dropped here); the `sdk-migration` label is bumped to this migration's number.
|
|
259
270
|
|
|
260
271
|
This split is what allows existing rows to be backfilled before the database starts rejecting nulls, and what lets `migrate.ts` traverse foreign-key fields that the same migration removes.
|
|
@@ -279,7 +290,15 @@ Namespace: tailordb
|
|
|
279
290
|
|
|
280
291
|
The error also points you at `migration status`, `migration generate`, `migration sync`, and `migration set` — see [Remote schema drift detected](#remote-schema-drift-detected) for which one applies.
|
|
281
292
|
|
|
282
|
-
To
|
|
293
|
+
To run the same checks without deploying — plus migration file integrity (numbering, parseable contents, and a `migrate.ts` or a recorded `--no-script` acknowledgment for every migration that requires a script):
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
tailor-sdk tailordb migration validate
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
It reports issues per namespace, exits with a non-zero code when any check fails, and supports `--json` for machine-readable output.
|
|
300
|
+
|
|
301
|
+
To bypass both checks during deploy (not recommended outside of recovery scenarios):
|
|
283
302
|
|
|
284
303
|
```bash
|
|
285
304
|
tailor-sdk deploy --no-schema-check
|
|
@@ -344,7 +363,8 @@ Migration numbers are assigned sequentially, so two developers branching off the
|
|
|
344
363
|
### CI / CD
|
|
345
364
|
|
|
346
365
|
- For non-interactive environments, pass `--yes` to `migration generate` and `--yes` to `apply`. `apply` runs migrations automatically when the `migrations/` directory is configured.
|
|
347
|
-
- Run `tailor-sdk tailordb migration
|
|
366
|
+
- Run `tailor-sdk tailordb migration validate` in CI to catch uncommitted migrations, broken migration files, and remote schema drift before deploying. It exits with a non-zero code when validation fails and supports `--json`.
|
|
367
|
+
- `tailor-sdk tailordb migration status` shows applied and pending migrations for a human-readable comparison. Its exit code is non-zero only on errors, so check the output.
|
|
348
368
|
- Avoid running migrations in parallel against the same workspace — there is no locking. Serialize deploys per environment.
|
|
349
369
|
|
|
350
370
|
### Resetting a deployed project
|
|
@@ -481,4 +501,4 @@ For genuinely different schemas across environments, prefer separate workspaces
|
|
|
481
501
|
|
|
482
502
|
**Cause:** `diff.requiresMigrationScript` is true but `migrate.ts` is missing from the migration directory.
|
|
483
503
|
|
|
484
|
-
**Resolution:**
|
|
504
|
+
**Resolution:** Restore the file from version control, or create it with `tailor-sdk tailordb migration script <N> --namespace <namespace>`. If the migration intentionally needs no data transformation, record that decision with `tailor-sdk tailordb migration script <N> --namespace <namespace> --no-script --reason "<why no data migration is needed>"` instead.
|
|
@@ -201,6 +201,32 @@ export default createWorkflow({
|
|
|
201
201
|
});
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
+
## Execution Events
|
|
205
|
+
|
|
206
|
+
Workflows can publish execution lifecycle events for executors. When an executor subscribes to a workflow's events, the SDK enables publishing automatically. A `workflowExecution*` trigger enables it on the workflow, and a `workflowJobExecution*` trigger enables it on every job that workflow runs. See [Workflow Execution Triggers](./executor.md#workflow-execution-triggers).
|
|
207
|
+
|
|
208
|
+
Set `publishEvents` explicitly to override that. Use `true` to publish workflow-level events with no subscribing executor:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
export default createWorkflow({
|
|
212
|
+
name: "order-processing",
|
|
213
|
+
mainJob: processOrder,
|
|
214
|
+
publishEvents: true,
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
A job takes the same field for its own execution events:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
export const processOrder = createWorkflowJob({
|
|
222
|
+
name: "process-order",
|
|
223
|
+
publishEvents: true,
|
|
224
|
+
body: async () => ({ processed: true }),
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Use `false` to keep publishing off. `deploy` fails if an executor subscribes to events the value opts out of, so the subscription cannot silently go unfulfilled.
|
|
229
|
+
|
|
204
230
|
## Wait Points
|
|
205
231
|
|
|
206
232
|
Wait points allow a workflow job to suspend execution and wait for an external signal before resuming. This enables human-in-the-loop patterns such as approvals, reviews, and manual confirmations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.85.0",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -149,9 +149,9 @@
|
|
|
149
149
|
}
|
|
150
150
|
},
|
|
151
151
|
"dependencies": {
|
|
152
|
-
"@0no-co/graphql.web": "1.3.
|
|
152
|
+
"@0no-co/graphql.web": "1.3.3",
|
|
153
153
|
"@badgateway/oauth2-client": "3.3.1",
|
|
154
|
-
"@bufbuild/protobuf": "2.
|
|
154
|
+
"@bufbuild/protobuf": "2.13.0",
|
|
155
155
|
"@bufbuild/protovalidate": "1.2.0",
|
|
156
156
|
"@connectrpc/connect": "2.1.2",
|
|
157
157
|
"@connectrpc/connect-node": "2.1.2",
|
|
@@ -160,11 +160,11 @@
|
|
|
160
160
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
161
161
|
"@napi-rs/keyring": "1.3.0",
|
|
162
162
|
"@opentelemetry/api": "1.9.1",
|
|
163
|
-
"@opentelemetry/exporter-trace-otlp-proto": "0.
|
|
164
|
-
"@opentelemetry/resources": "2.
|
|
165
|
-
"@opentelemetry/sdk-trace-node": "2.
|
|
163
|
+
"@opentelemetry/exporter-trace-otlp-proto": "0.221.0",
|
|
164
|
+
"@opentelemetry/resources": "2.10.0",
|
|
165
|
+
"@opentelemetry/sdk-trace-node": "2.10.0",
|
|
166
166
|
"@opentelemetry/semantic-conventions": "1.43.0",
|
|
167
|
-
"@oxc-project/types": "0.
|
|
167
|
+
"@oxc-project/types": "0.142.0",
|
|
168
168
|
"@standard-schema/spec": "1.1.0",
|
|
169
169
|
"@tailor-platform/function-kysely-tailordb": "0.1.3",
|
|
170
170
|
"@toiroakr/lines-db": "0.10.1",
|
|
@@ -174,23 +174,23 @@
|
|
|
174
174
|
"chokidar": "5.0.0",
|
|
175
175
|
"confbox": "0.2.4",
|
|
176
176
|
"date-fns": "4.4.0",
|
|
177
|
-
"es-toolkit": "1.
|
|
177
|
+
"es-toolkit": "1.50.0",
|
|
178
178
|
"find-up-simple": "1.0.1",
|
|
179
179
|
"get-east-asian-width": "1.6.0",
|
|
180
180
|
"get-tsconfig": "4.14.0",
|
|
181
|
-
"globals": "17.
|
|
181
|
+
"globals": "17.8.0",
|
|
182
182
|
"graphql": "17.0.2",
|
|
183
183
|
"inflection": "3.0.2",
|
|
184
184
|
"kysely": "0.29.4",
|
|
185
185
|
"madge": "8.0.0",
|
|
186
186
|
"mime-types": "3.0.2",
|
|
187
187
|
"open": "11.0.0",
|
|
188
|
-
"oxc-parser": "0.
|
|
189
|
-
"p-limit": "7.3.
|
|
188
|
+
"oxc-parser": "0.142.0",
|
|
189
|
+
"p-limit": "7.3.1",
|
|
190
190
|
"pathe": "2.0.3",
|
|
191
191
|
"pgsql-ast-parser": "12.0.2",
|
|
192
192
|
"pkg-types": "2.3.1",
|
|
193
|
-
"politty": "0.11.
|
|
193
|
+
"politty": "0.11.6",
|
|
194
194
|
"rolldown": "1.2.0",
|
|
195
195
|
"semver": "7.8.5",
|
|
196
196
|
"sql-highlight": "6.1.0",
|
|
@@ -198,23 +198,22 @@
|
|
|
198
198
|
"ts-cron-validator": "1.1.5",
|
|
199
199
|
"tsx": "4.23.1",
|
|
200
200
|
"type-fest": "5.8.0",
|
|
201
|
-
"undici": "8.7.0",
|
|
202
201
|
"xdg-basedir": "5.1.0",
|
|
203
202
|
"zod": "4.4.3"
|
|
204
203
|
},
|
|
205
204
|
"devDependencies": {
|
|
206
|
-
"@opentelemetry/sdk-trace-base": "2.
|
|
205
|
+
"@opentelemetry/sdk-trace-base": "2.10.0",
|
|
207
206
|
"@types/madge": "5.0.3",
|
|
208
207
|
"@types/mime-types": "3.0.1",
|
|
209
208
|
"@types/node": "24.13.3",
|
|
210
209
|
"@types/semver": "7.7.1",
|
|
211
210
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
212
211
|
"@vitest/coverage-v8": "4.1.10",
|
|
213
|
-
"oxfmt": "0.
|
|
214
|
-
"oxlint": "1.
|
|
215
|
-
"oxlint-tsgolint": "0.
|
|
212
|
+
"oxfmt": "0.61.0",
|
|
213
|
+
"oxlint": "1.76.0",
|
|
214
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
216
215
|
"sonda": "0.14.0",
|
|
217
|
-
"tsdown": "0.22.
|
|
216
|
+
"tsdown": "0.22.14",
|
|
218
217
|
"typescript": "6.0.3",
|
|
219
218
|
"vitest": "4.1.10",
|
|
220
219
|
"zinfer": "0.2.7",
|