@tailor-platform/sdk 1.36.0 → 1.38.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 +82 -0
- package/dist/application-C1ipG5Q6.mjs +4 -0
- package/dist/{application-BwboBFcU.mjs → application-DhQrXEld.mjs} +60 -22
- package/dist/application-DhQrXEld.mjs.map +1 -0
- package/dist/{brand-0SscafcY.mjs → brand-D-d15jx3.mjs} +1 -1
- package/dist/{brand-0SscafcY.mjs.map → brand-D-d15jx3.mjs.map} +1 -1
- package/dist/cli/index.mjs +369 -128
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +6 -6
- package/dist/cli/lib.mjs +7 -7
- package/dist/{client-B6icVEv4.mjs → client-BWAbbA1C.mjs} +1 -1
- package/dist/{client-CN15WgW2.mjs → client-xzPXtc_e.mjs} +10 -4
- package/dist/{client-CN15WgW2.mjs.map → client-xzPXtc_e.mjs.map} +1 -1
- package/dist/configure/index.d.mts +4 -5
- package/dist/configure/index.mjs +8 -15
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-CB1UtT3O.mjs → crash-report-BEAiCSCl.mjs} +1 -1
- package/dist/{crash-report-CdxPj_SW.mjs → crash-report-DXhPL8Ue.mjs} +4 -4
- package/dist/{crash-report-CdxPj_SW.mjs.map → crash-report-DXhPL8Ue.mjs.map} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs → enum-constants-Dx82rSjf.mjs} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs.map → enum-constants-Dx82rSjf.mjs.map} +1 -1
- package/dist/errors-D9f2UJpT.mjs +43 -0
- package/dist/errors-D9f2UJpT.mjs.map +1 -0
- package/dist/{file-utils-C4rXlOVt.mjs → file-utils-DeWpvq3T.mjs} +1 -1
- package/dist/{file-utils-C4rXlOVt.mjs.map → file-utils-DeWpvq3T.mjs.map} +1 -1
- package/dist/{index-DZN1QFLM.d.mts → index-CHo73Aat.d.mts} +2 -2
- package/dist/{index-CxSLivW7.d.mts → index-CIIXsk3E.d.mts} +2 -2
- package/dist/{index-C7vIBAg8.d.mts → index-Cln_TTZn.d.mts} +2 -2
- package/dist/{index-CYaunQeL.d.mts → index-Cs3fwmLu.d.mts} +33 -13
- package/dist/{index-DDCyefuU.d.mts → index-D_W9-Lvk.d.mts} +2 -2
- package/dist/{interceptor-f7slMkCC.mjs → interceptor-CzaH2Ur6.mjs} +1 -1
- package/dist/{interceptor-f7slMkCC.mjs.map → interceptor-CzaH2Ur6.mjs.map} +1 -1
- package/dist/{job-CPKYCk_e.mjs → job-DkAklmE4.mjs} +2 -2
- package/dist/{job-CPKYCk_e.mjs.map → job-DkAklmE4.mjs.map} +1 -1
- package/dist/{kysely-type-DtnNdHn3.mjs → kysely-type-CwtvQuxh.mjs} +1 -1
- package/dist/{kysely-type-DtnNdHn3.mjs.map → kysely-type-CwtvQuxh.mjs.map} +1 -1
- package/dist/{logger-qz-Y4sBV.mjs → logger-5_JMzHmw.mjs} +42 -3
- package/dist/logger-5_JMzHmw.mjs.map +1 -0
- package/dist/package-json--6dmp6-h.mjs +4 -0
- package/dist/{package-json-CfUqjJaQ.mjs → package-json-BHViVisJ.mjs} +1 -1
- package/dist/{package-json-CfUqjJaQ.mjs.map → package-json-BHViVisJ.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +1 -2
- package/dist/{plugin-CiPUxkyN.d.mts → plugin-D84blivd.d.mts} +67 -11
- package/dist/{runtime-C7RRDaB3.mjs → runtime-ChpwtPut.mjs} +587 -144
- package/dist/runtime-ChpwtPut.mjs.map +1 -0
- package/dist/{schema-D27cW0Ca.mjs → schema-CnwUqPyM.mjs} +4 -361
- package/dist/schema-CnwUqPyM.mjs.map +1 -0
- package/dist/{seed-BZIFDG27.mjs → seed-DrbB1VXd.mjs} +1 -1
- package/dist/{seed-BZIFDG27.mjs.map → seed-DrbB1VXd.mjs.map} +1 -1
- package/dist/service-Bcp6JB3w.mjs +132 -0
- package/dist/service-Bcp6JB3w.mjs.map +1 -0
- package/dist/telemetry-4IOPW6wE.mjs +4 -0
- package/dist/{telemetry-CREcGK8y.mjs → telemetry-DwHuiNiR.mjs} +2 -2
- package/dist/{telemetry-CREcGK8y.mjs.map → telemetry-DwHuiNiR.mjs.map} +1 -1
- package/dist/types-B9ZMosul.mjs +372 -0
- package/dist/types-B9ZMosul.mjs.map +1 -0
- package/dist/types-C45jRrCM.mjs +4 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/utils/test/index.mjs +7 -3
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/{workflow.generated-8BeGQsVU.d.mts → workflow.generated-BRdcCWfC.d.mts} +2 -2
- package/docs/cli/function.md +42 -16
- package/docs/cli/upgrade.md +51 -0
- package/docs/cli/user.md +1 -1
- package/docs/cli/workflow.md +10 -10
- package/docs/cli-reference.md +23 -14
- package/docs/configuration.md +9 -7
- package/docs/services/auth.md +6 -5
- package/docs/services/executor.md +44 -12
- package/docs/services/resolver.md +6 -13
- package/docs/services/tailordb.md +20 -0
- package/docs/services/workflow.md +4 -3
- package/package.json +10 -10
- package/dist/application-BB5TqXWY.mjs +0 -4
- package/dist/application-BwboBFcU.mjs.map +0 -1
- package/dist/env-_ce3IYbl.d.mts +0 -30
- package/dist/logger-qz-Y4sBV.mjs.map +0 -1
- package/dist/package-json-D5Km1jjt.mjs +0 -4
- package/dist/runtime-C7RRDaB3.mjs.map +0 -1
- package/dist/schema-D27cW0Ca.mjs.map +0 -1
- package/dist/telemetry-C508zIi1.mjs +0 -4
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!-- politty:command:upgrade:heading:start -->
|
|
2
|
+
|
|
3
|
+
## upgrade
|
|
4
|
+
|
|
5
|
+
<!-- politty:command:upgrade:heading:end -->
|
|
6
|
+
|
|
7
|
+
<!-- politty:command:upgrade:description:start -->
|
|
8
|
+
|
|
9
|
+
Run codemods to upgrade your project to a newer SDK version.
|
|
10
|
+
|
|
11
|
+
<!-- politty:command:upgrade:description:end -->
|
|
12
|
+
|
|
13
|
+
<!-- politty:command:upgrade:usage:start -->
|
|
14
|
+
|
|
15
|
+
**Usage**
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
tailor-sdk upgrade [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<!-- politty:command:upgrade:usage:end -->
|
|
22
|
+
|
|
23
|
+
<!-- politty:command:upgrade:options:start -->
|
|
24
|
+
|
|
25
|
+
**Options**
|
|
26
|
+
|
|
27
|
+
| Option | Alias | Description | Required | Default |
|
|
28
|
+
| --------------- | ----- | --------------------------------------------- | -------- | ------- |
|
|
29
|
+
| `--from <FROM>` | - | SDK version before the upgrade (e.g., 1.33.0) | Yes | - |
|
|
30
|
+
| `--dry-run` | `-d` | Preview changes without modifying files | No | `false` |
|
|
31
|
+
| `--path <PATH>` | - | Project directory to upgrade | No | `"."` |
|
|
32
|
+
|
|
33
|
+
<!-- politty:command:upgrade:options:end -->
|
|
34
|
+
|
|
35
|
+
<!-- politty:command:upgrade:global-options-link:start -->
|
|
36
|
+
|
|
37
|
+
See [Global Options](../cli-reference.md#global-options) for options available to all commands.
|
|
38
|
+
|
|
39
|
+
<!-- politty:command:upgrade:global-options-link:end -->
|
|
40
|
+
|
|
41
|
+
### How It Works
|
|
42
|
+
|
|
43
|
+
The `upgrade` command runs codemods that automatically transform your project code for breaking changes between SDK versions. The target version (`--to`) is auto-detected from the installed `@tailor-platform/sdk` in `node_modules`.
|
|
44
|
+
|
|
45
|
+
**Typical workflow:**
|
|
46
|
+
|
|
47
|
+
1. Update your SDK packages to the new version (e.g., `pnpm update @tailor-platform/sdk`)
|
|
48
|
+
2. Run `tailor-sdk upgrade --from <old-version>` to apply codemods
|
|
49
|
+
3. Review changes and commit
|
|
50
|
+
|
|
51
|
+
Use `--dry-run` to preview what changes will be made before applying them.
|
package/docs/cli/user.md
CHANGED
|
@@ -38,7 +38,7 @@ _no options_
|
|
|
38
38
|
|
|
39
39
|
| Option | Alias | Description | Required | Default | Env |
|
|
40
40
|
| --------------------------------- | ----- | --------------------------------- | -------- | ------- | -------------------------------------------- |
|
|
41
|
-
| `--
|
|
41
|
+
| `--machine-user <MACHINE_USER>` | - | Login as a platform machine user. | Yes | - | - |
|
|
42
42
|
| `--client-id <CLIENT_ID>` | - | Client ID | Yes | - | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` |
|
|
43
43
|
| `--client-secret <CLIENT_SECRET>` | - | Client secret | No | - | `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` |
|
|
44
44
|
|
package/docs/cli/workflow.md
CHANGED
|
@@ -165,16 +165,16 @@ tailor-sdk workflow start [options] <name>
|
|
|
165
165
|
|
|
166
166
|
**Options**
|
|
167
167
|
|
|
168
|
-
| Option | Alias | Description | Required | Default | Env
|
|
169
|
-
| ------------------------------- | ----- | -------------------------------------------------------------- | -------- | -------------------- |
|
|
170
|
-
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID`
|
|
171
|
-
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE`
|
|
172
|
-
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH`
|
|
173
|
-
| `--
|
|
174
|
-
| `--arg <ARG>` | `-a` | Workflow argument (JSON string) | No | - | -
|
|
175
|
-
| `--wait` | `-W` | Wait for execution to complete | No | `false` | -
|
|
176
|
-
| `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | -
|
|
177
|
-
| `--logs` | `-l` | Display job execution logs after completion (requires --wait) | No | `false` | -
|
|
168
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
169
|
+
| ------------------------------- | ----- | -------------------------------------------------------------- | -------- | -------------------- | ----------------------------------- |
|
|
170
|
+
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
|
|
171
|
+
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
|
|
172
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
173
|
+
| `--machine-user <MACHINE_USER>` | `-m` | Machine user name | Yes | - | `TAILOR_PLATFORM_MACHINE_USER_NAME` |
|
|
174
|
+
| `--arg <ARG>` | `-a` | Workflow argument (JSON string) | No | - | - |
|
|
175
|
+
| `--wait` | `-W` | Wait for execution to complete | No | `false` | - |
|
|
176
|
+
| `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | - |
|
|
177
|
+
| `--logs` | `-l` | Display job execution logs after completion (requires --wait) | No | `false` | - |
|
|
178
178
|
|
|
179
179
|
<!-- politty:command:workflow start:options:end -->
|
|
180
180
|
|
package/docs/cli-reference.md
CHANGED
|
@@ -53,20 +53,21 @@ tailor-sdk apply --env-file .env --env-file .env.production
|
|
|
53
53
|
|
|
54
54
|
You can use environment variables to configure workspace and authentication:
|
|
55
55
|
|
|
56
|
-
| Variable | Description
|
|
57
|
-
| -------------------------------------------- |
|
|
58
|
-
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands
|
|
59
|
-
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands
|
|
60
|
-
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands
|
|
61
|
-
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`)
|
|
62
|
-
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead
|
|
63
|
-
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name
|
|
64
|
-
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file
|
|
65
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --
|
|
66
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
| -------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
58
|
+
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands |
|
|
59
|
+
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands |
|
|
60
|
+
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands |
|
|
61
|
+
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`) |
|
|
62
|
+
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead |
|
|
63
|
+
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name |
|
|
64
|
+
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file |
|
|
65
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user` |
|
|
66
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user` |
|
|
67
|
+
| `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run` |
|
|
68
|
+
| `VISUAL` / `EDITOR` | Preferred editor for commands that open files (e.g., `vim`, `code`, `nano`) |
|
|
69
|
+
| `TAILOR_CRASH_REPORTS_LOCAL` | Local crash log writing: `on` (default) or `off` |
|
|
70
|
+
| `TAILOR_CRASH_REPORTS_REMOTE` | Automatic crash report submission: `off` (default) or `on` |
|
|
70
71
|
|
|
71
72
|
### Authentication Token Priority
|
|
72
73
|
|
|
@@ -259,6 +260,14 @@ Commands for setting up project infrastructure.
|
|
|
259
260
|
| ------------------------------------------- | ------------------------------------------------------- |
|
|
260
261
|
| [setup github](./cli/setup.md#setup-github) | Generate GitHub Actions workflow for deployment. (beta) |
|
|
261
262
|
|
|
263
|
+
### [Upgrade Commands](./cli/upgrade.md)
|
|
264
|
+
|
|
265
|
+
Commands for upgrading SDK versions with automated code migration.
|
|
266
|
+
|
|
267
|
+
| Command | Description |
|
|
268
|
+
| ----------------------------------- | ------------------------------------------------------------ |
|
|
269
|
+
| [upgrade](./cli/upgrade.md#upgrade) | Run codemods to upgrade your project to a newer SDK version. |
|
|
270
|
+
|
|
262
271
|
### [Completion](./cli/completion.md)
|
|
263
272
|
|
|
264
273
|
Generate shell completion scripts for bash, zsh, and fish.
|
package/docs/configuration.md
CHANGED
|
@@ -218,17 +218,19 @@ export default defineConfig({
|
|
|
218
218
|
|
|
219
219
|
**ignores**: Glob patterns to exclude files. Optional.
|
|
220
220
|
|
|
221
|
-
###
|
|
221
|
+
### Plugins
|
|
222
222
|
|
|
223
|
-
Configure
|
|
223
|
+
Configure plugins using `definePlugins()`. Plugins must be exported as a named export.
|
|
224
224
|
|
|
225
225
|
```typescript
|
|
226
|
-
import {
|
|
226
|
+
import { definePlugins } from "@tailor-platform/sdk";
|
|
227
|
+
import { kyselyTypePlugin } from "@tailor-platform/sdk/plugin/kysely-type";
|
|
228
|
+
import { enumConstantsPlugin } from "@tailor-platform/sdk/plugin/enum-constants";
|
|
227
229
|
|
|
228
|
-
export const
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
export const plugins = definePlugins(
|
|
231
|
+
kyselyTypePlugin({ distPath: "./generated/tailordb.ts" }),
|
|
232
|
+
enumConstantsPlugin({ distPath: "./generated/enums.ts" }),
|
|
231
233
|
);
|
|
232
234
|
```
|
|
233
235
|
|
|
234
|
-
See [Generators](./generator/index.md) for
|
|
236
|
+
See [Generators](./generator/index.md) for legacy `defineGenerators()` documentation.
|
package/docs/services/auth.md
CHANGED
|
@@ -256,9 +256,9 @@ Get a machine user token using the CLI:
|
|
|
256
256
|
tailor-sdk machineuser token <name>
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
###
|
|
259
|
+
### Specifying a machine user invoker
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
Resolvers, executors, and `workflow.trigger()` accept an `authInvoker` option that chooses which machine user runs the operation. Pass the machine user name as a plain string — it is type-narrowed to the names you registered in `machineUsers`.
|
|
262
262
|
|
|
263
263
|
```typescript
|
|
264
264
|
// tailor.config.ts
|
|
@@ -275,7 +275,6 @@ export const auth = defineAuth("my-auth", {
|
|
|
275
275
|
```typescript
|
|
276
276
|
// resolvers/trigger-workflow.ts
|
|
277
277
|
import { createResolver, t } from "@tailor-platform/sdk";
|
|
278
|
-
import { auth } from "../tailor.config";
|
|
279
278
|
import myWorkflow from "../workflows/my-workflow";
|
|
280
279
|
|
|
281
280
|
export default createResolver({
|
|
@@ -288,7 +287,7 @@ export default createResolver({
|
|
|
288
287
|
// Trigger workflow with machine user permissions
|
|
289
288
|
const workflowRunId = await myWorkflow.trigger(
|
|
290
289
|
{ id: input.id },
|
|
291
|
-
{ authInvoker:
|
|
290
|
+
{ authInvoker: "admin-machine-user" },
|
|
292
291
|
);
|
|
293
292
|
return { workflowRunId };
|
|
294
293
|
},
|
|
@@ -298,7 +297,9 @@ export default createResolver({
|
|
|
298
297
|
});
|
|
299
298
|
```
|
|
300
299
|
|
|
301
|
-
|
|
300
|
+
Type narrowing is provided by the generated `tailor.d.ts` (the `MachineUserNameRegistry` interface). Run `tailor-sdk generate` (or `apply`) after defining new machine users to refresh it.
|
|
301
|
+
|
|
302
|
+
> **Deprecated:** The `auth.invoker("<name>")` helper is still available for backward compatibility. Prefer the string form — it does not require importing `auth` from `tailor.config.ts` into runtime files, avoiding bundling config-layer (Node-only) dependencies.
|
|
302
303
|
|
|
303
304
|
## OAuth 2.0 Clients
|
|
304
305
|
|
|
@@ -88,6 +88,25 @@ type WebhookRequest = {
|
|
|
88
88
|
incomingWebhookTrigger<WebhookRequest>();
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
You can customize the HTTP response returned to the webhook caller:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Response body only (shorthand)
|
|
95
|
+
incomingWebhookTrigger<WebhookRequest>({
|
|
96
|
+
response: (args) => ({ challenge: args.body.challenge }),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Response body with custom status code
|
|
100
|
+
incomingWebhookTrigger<WebhookRequest>({
|
|
101
|
+
response: {
|
|
102
|
+
body: (args) => ({ challenge: args.body.challenge }),
|
|
103
|
+
statusCode: 201,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If `body` is set without `statusCode`, the platform uses 200. If neither is set, the platform returns 204.
|
|
109
|
+
|
|
91
110
|
### Resolver Executed Trigger
|
|
92
111
|
|
|
93
112
|
Fires when a resolver is executed:
|
|
@@ -294,19 +313,10 @@ createExecutor({
|
|
|
294
313
|
|
|
295
314
|
### Authentication for Operations
|
|
296
315
|
|
|
297
|
-
GraphQL and Workflow operations can specify an `authInvoker` to execute with machine user credentials:
|
|
316
|
+
GraphQL and Workflow operations can specify an `authInvoker` 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:
|
|
298
317
|
|
|
299
318
|
```typescript
|
|
300
|
-
import {
|
|
301
|
-
|
|
302
|
-
const auth = defineAuth("my-auth", {
|
|
303
|
-
// ... auth configuration
|
|
304
|
-
machineUsers: {
|
|
305
|
-
"batch-processor": {
|
|
306
|
-
attributes: { role: "ADMIN" },
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
});
|
|
319
|
+
import { createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
|
|
310
320
|
|
|
311
321
|
export default createExecutor({
|
|
312
322
|
name: "scheduled-cleanup",
|
|
@@ -314,11 +324,13 @@ export default createExecutor({
|
|
|
314
324
|
operation: {
|
|
315
325
|
kind: "graphql",
|
|
316
326
|
query: `mutation { cleanupOldRecords { count } }`,
|
|
317
|
-
authInvoker:
|
|
327
|
+
authInvoker: "batch-processor",
|
|
318
328
|
},
|
|
319
329
|
});
|
|
320
330
|
```
|
|
321
331
|
|
|
332
|
+
> **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Prefer the string form to avoid importing config-layer modules into runtime files.
|
|
333
|
+
|
|
322
334
|
## Event Payloads
|
|
323
335
|
|
|
324
336
|
Each trigger type provides specific context data in the callback functions.
|
|
@@ -440,6 +452,26 @@ export default createExecutor({
|
|
|
440
452
|
});
|
|
441
453
|
```
|
|
442
454
|
|
|
455
|
+
**With custom response:**
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
export default createExecutor({
|
|
459
|
+
name: "slack-challenge",
|
|
460
|
+
trigger: incomingWebhookTrigger<{
|
|
461
|
+
body: { challenge: string; type: string };
|
|
462
|
+
headers: Record<string, string>;
|
|
463
|
+
}>({
|
|
464
|
+
response: (args) => ({ challenge: args.body.challenge }),
|
|
465
|
+
}),
|
|
466
|
+
operation: {
|
|
467
|
+
kind: "function",
|
|
468
|
+
body: async ({ body }) => {
|
|
469
|
+
console.log(`Received ${body.type} event`);
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
```
|
|
474
|
+
|
|
443
475
|
### Resolver Executed Payload
|
|
444
476
|
|
|
445
477
|
Resolver triggers receive the resolver's result or error:
|
|
@@ -350,19 +350,10 @@ createResolver({
|
|
|
350
350
|
|
|
351
351
|
## Authentication
|
|
352
352
|
|
|
353
|
-
Specify an `authInvoker` to execute the resolver with machine user credentials:
|
|
353
|
+
Specify an `authInvoker` to execute the resolver with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names you defined in your auth config:
|
|
354
354
|
|
|
355
355
|
```typescript
|
|
356
|
-
import {
|
|
357
|
-
|
|
358
|
-
const auth = defineAuth("my-auth", {
|
|
359
|
-
// ... auth configuration
|
|
360
|
-
machineUsers: {
|
|
361
|
-
"batch-processor": {
|
|
362
|
-
attributes: { role: "ADMIN" },
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
});
|
|
356
|
+
import { createResolver, t } from "@tailor-platform/sdk";
|
|
366
357
|
|
|
367
358
|
export default createResolver({
|
|
368
359
|
name: "adminQuery",
|
|
@@ -372,10 +363,12 @@ export default createResolver({
|
|
|
372
363
|
// Executes as "batch-processor" machine user
|
|
373
364
|
return { result: "ok" };
|
|
374
365
|
},
|
|
375
|
-
authInvoker:
|
|
366
|
+
authInvoker: "batch-processor",
|
|
376
367
|
});
|
|
377
368
|
```
|
|
378
369
|
|
|
379
|
-
The
|
|
370
|
+
The machine user name is looked up in the auth service configured on your app (`machineUsers` in `defineAuth`). The namespace is resolved automatically — no need to import `auth` from `tailor.config.ts` in resolver files.
|
|
371
|
+
|
|
372
|
+
> **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Importing `auth` into runtime files pulls config-layer (Node-only) dependencies into the bundle.
|
|
380
373
|
|
|
381
374
|
**Note:** `authInvoker` controls the permissions for database operations and other platform actions, but the `user` object passed to the `body` function still reflects the original caller who invoked the resolver.
|
|
@@ -96,11 +96,31 @@ db.enum([
|
|
|
96
96
|
### Object Fields
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
|
+
// Object field
|
|
99
100
|
db.object({
|
|
100
101
|
street: db.string(),
|
|
101
102
|
city: db.string(),
|
|
102
103
|
country: db.string(),
|
|
103
104
|
});
|
|
105
|
+
|
|
106
|
+
// Object array field
|
|
107
|
+
db.object(
|
|
108
|
+
{
|
|
109
|
+
id: db.uuid(),
|
|
110
|
+
name: db.string(),
|
|
111
|
+
size: db.int(),
|
|
112
|
+
},
|
|
113
|
+
{ array: true },
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Optional object array field
|
|
117
|
+
db.object(
|
|
118
|
+
{
|
|
119
|
+
kind: db.string(),
|
|
120
|
+
days: db.int(),
|
|
121
|
+
},
|
|
122
|
+
{ optional: true, array: true },
|
|
123
|
+
);
|
|
104
124
|
```
|
|
105
125
|
|
|
106
126
|
## Field Modifiers
|
|
@@ -227,11 +227,10 @@ export default createWorkflow({
|
|
|
227
227
|
You can start a workflow execution from a resolver using `workflow.trigger()`.
|
|
228
228
|
|
|
229
229
|
- `workflow.trigger(args, options?)` returns a workflow run ID (`Promise<string>`).
|
|
230
|
-
- To run with machine-user permissions, pass `{ authInvoker:
|
|
230
|
+
- To run with machine-user permissions, pass `{ authInvoker: "<machine-user>" }`. The name is type-narrowed to the machine users defined in your auth config.
|
|
231
231
|
|
|
232
232
|
```typescript
|
|
233
233
|
import { createResolver, t } from "@tailor-platform/sdk";
|
|
234
|
-
import { auth } from "../tailor.config";
|
|
235
234
|
import orderProcessingWorkflow from "../workflows/order-processing";
|
|
236
235
|
|
|
237
236
|
export default createResolver({
|
|
@@ -244,7 +243,7 @@ export default createResolver({
|
|
|
244
243
|
body: async ({ input }) => {
|
|
245
244
|
const workflowRunId = await orderProcessingWorkflow.trigger(
|
|
246
245
|
{ orderId: input.orderId, customerId: input.customerId },
|
|
247
|
-
{ authInvoker:
|
|
246
|
+
{ authInvoker: "manager-machine-user" },
|
|
248
247
|
);
|
|
249
248
|
|
|
250
249
|
return { workflowRunId };
|
|
@@ -255,6 +254,8 @@ export default createResolver({
|
|
|
255
254
|
});
|
|
256
255
|
```
|
|
257
256
|
|
|
257
|
+
> **Deprecated:** `auth.invoker("manager-machine-user")` still works but is deprecated. Using the string form avoids importing `auth` into runtime code.
|
|
258
|
+
|
|
258
259
|
See the full working example in the repository: [example/resolvers/triggerWorkflow.ts](../../../../example/resolvers/triggerWorkflow.ts).
|
|
259
260
|
|
|
260
261
|
## File Organization
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@connectrpc/connect": "2.1.1",
|
|
83
83
|
"@connectrpc/connect-node": "2.1.1",
|
|
84
84
|
"@inquirer/core": "11.1.8",
|
|
85
|
-
"@inquirer/prompts": "8.4.
|
|
85
|
+
"@inquirer/prompts": "8.4.1",
|
|
86
86
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
87
87
|
"@liam-hq/cli": "0.7.24",
|
|
88
88
|
"@napi-rs/keyring": "1.2.0",
|
|
@@ -103,9 +103,9 @@
|
|
|
103
103
|
"date-fns": "4.1.0",
|
|
104
104
|
"es-toolkit": "1.45.1",
|
|
105
105
|
"find-up-simple": "1.0.1",
|
|
106
|
-
"globals": "17.
|
|
106
|
+
"globals": "17.5.0",
|
|
107
107
|
"inflection": "3.0.2",
|
|
108
|
-
"kysely": "0.28.
|
|
108
|
+
"kysely": "0.28.16",
|
|
109
109
|
"madge": "8.0.0",
|
|
110
110
|
"mime-types": "3.0.2",
|
|
111
111
|
"multiline-ts": "4.0.1",
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
"pathe": "2.0.3",
|
|
117
117
|
"pgsql-ast-parser": "12.0.2",
|
|
118
118
|
"pkg-types": "2.3.0",
|
|
119
|
-
"politty": "0.4.
|
|
120
|
-
"rolldown": "1.0.0-rc.
|
|
119
|
+
"politty": "0.4.14",
|
|
120
|
+
"rolldown": "1.0.0-rc.15",
|
|
121
121
|
"semver": "7.7.4",
|
|
122
122
|
"serve": "14.2.6",
|
|
123
123
|
"std-env": "4.0.0",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"@types/node": "24.12.2",
|
|
137
137
|
"@types/semver": "7.7.1",
|
|
138
138
|
"@typescript/native-preview": "7.0.0-dev.20260406.1",
|
|
139
|
-
"@vitest/coverage-v8": "4.1.
|
|
139
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
140
140
|
"eslint": "10.2.0",
|
|
141
141
|
"eslint-plugin-jsdoc": "62.9.0",
|
|
142
142
|
"eslint-plugin-oxlint": "1.59.0",
|
|
@@ -144,10 +144,10 @@
|
|
|
144
144
|
"oxlint": "1.59.0",
|
|
145
145
|
"oxlint-tsgolint": "0.20.0",
|
|
146
146
|
"sonda": "0.11.1",
|
|
147
|
-
"tsdown": "0.21.
|
|
147
|
+
"tsdown": "0.21.8",
|
|
148
148
|
"typescript": "5.9.3",
|
|
149
|
-
"typescript-eslint": "8.58.
|
|
150
|
-
"vitest": "4.1.
|
|
149
|
+
"typescript-eslint": "8.58.1",
|
|
150
|
+
"vitest": "4.1.4",
|
|
151
151
|
"zinfer": "0.1.7"
|
|
152
152
|
},
|
|
153
153
|
"scripts": {
|