@tailor-platform/sdk 1.74.0 → 1.75.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 (89) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/application-BJKNlv8c.mjs +3 -0
  3. package/dist/{application-DwmoI6ZQ.mjs → application-DYshsH-K.mjs} +61 -11
  4. package/dist/application-DYshsH-K.mjs.map +1 -0
  5. package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
  6. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -0
  7. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -16
  8. package/dist/cli/index.mjs +23 -34
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.d.mts +2 -2
  11. package/dist/cli/lib.mjs +3 -3
  12. package/dist/cli/lib.mjs.map +1 -1
  13. package/dist/completion/zsh-worker.zsh +9 -9
  14. package/dist/configure/config/types.d.mts +3 -1
  15. package/dist/configure/index.d.mts +3 -1
  16. package/dist/configure/index.mjs +113 -5
  17. package/dist/configure/index.mjs.map +1 -1
  18. package/dist/configure/services/index.d.mts +3 -1
  19. package/dist/configure/services/tailordb/schema.d.mts +5 -19
  20. package/dist/configure/services/workflow/execution-policy.d.mts +71 -0
  21. package/dist/configure/services/workflow/execution-policy.types.d.mts +104 -0
  22. package/dist/configure/services/workflow/index.d.mts +3 -1
  23. package/dist/configure/services/workflow/job.d.mts +7 -3
  24. package/dist/configure/types/field-runtime.d.mts +17 -0
  25. package/dist/configure/types/type.d.mts +1 -18
  26. package/dist/field-runtime-9bfXBAOK.mjs +183 -0
  27. package/dist/field-runtime-9bfXBAOK.mjs.map +1 -0
  28. package/dist/{globals-B8XX5TRB.mjs → globals-CcU1ONiK.mjs} +2 -2
  29. package/dist/globals-CcU1ONiK.mjs.map +1 -0
  30. package/dist/{job-CtU73PGa.mjs → job-D-PbD1P3.mjs} +5 -3
  31. package/dist/job-D-PbD1P3.mjs.map +1 -0
  32. package/dist/plugin/builtin/seed/index.mjs +1 -1
  33. package/dist/{registry-BozuxbPp.mjs → registry-NfSW0BRo.mjs} +4 -3
  34. package/dist/registry-NfSW0BRo.mjs.map +1 -0
  35. package/dist/runtime/globals.d.mts +1 -1
  36. package/dist/runtime/index.d.mts +1 -1
  37. package/dist/runtime/workflow.d.mts +22 -3
  38. package/dist/{runtime-Zkg3SUwi.mjs → runtime-CJ5usBOu.mjs} +456 -397
  39. package/dist/runtime-CJ5usBOu.mjs.map +1 -0
  40. package/dist/{schema-DAdZSFOd.mjs → schema-Dl_y0m9e.mjs} +8 -167
  41. package/dist/schema-Dl_y0m9e.mjs.map +1 -0
  42. package/dist/secretmanager-Bd45j7an.mjs +98 -0
  43. package/dist/secretmanager-Bd45j7an.mjs.map +1 -0
  44. package/dist/{seed-DoMTMLcm.mjs → seed-fm0LeYP2.mjs} +14 -3
  45. package/dist/seed-fm0LeYP2.mjs.map +1 -0
  46. package/dist/{service_pb-CIrhGwHk.mjs → service_pb-4unFyubn.mjs} +16 -6
  47. package/dist/{service_pb-CIrhGwHk.mjs.map → service_pb-4unFyubn.mjs.map} +1 -1
  48. package/dist/{service_pb-DjwIn4jO.mjs → service_pb-D-PXRoMg.mjs} +1 -1
  49. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -1
  50. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -9
  51. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -1
  52. package/dist/types-BwzB2okW.mjs +199 -0
  53. package/dist/types-BwzB2okW.mjs.map +1 -0
  54. package/dist/types-KlawuVKa.mjs +4 -0
  55. package/dist/utils/test/index.mjs +1 -1
  56. package/dist/utils/test/index.mjs.map +1 -1
  57. package/dist/vitest/environment.mjs +1 -1
  58. package/dist/vitest/index.d.mts +8 -1
  59. package/dist/vitest/index.mjs +779 -1
  60. package/dist/vitest/index.mjs.map +1 -1
  61. package/dist/vitest/mock.d.mts +8 -363
  62. package/dist/vitest/mocks/aigateway.d.mts +30 -0
  63. package/dist/vitest/mocks/authconnection.d.mts +28 -0
  64. package/dist/vitest/mocks/file.d.mts +41 -0
  65. package/dist/vitest/mocks/iconv.d.mts +27 -0
  66. package/dist/vitest/mocks/idp.d.mts +44 -0
  67. package/dist/vitest/mocks/secretmanager.d.mts +33 -0
  68. package/dist/vitest/mocks/tailordb.d.mts +71 -0
  69. package/dist/vitest/mocks/workflow.d.mts +117 -0
  70. package/dist/vitest/setup.mjs +2 -2
  71. package/dist/workflow-DSwnYPPP.mjs.map +1 -1
  72. package/docs/configuration.md +24 -0
  73. package/docs/services/workflow.md +78 -0
  74. package/package.json +8 -8
  75. package/dist/application-BndtMTFY.mjs +0 -3
  76. package/dist/application-DwmoI6ZQ.mjs.map +0 -1
  77. package/dist/field-DOsJCPFa.mjs +0 -22
  78. package/dist/field-DOsJCPFa.mjs.map +0 -1
  79. package/dist/globals-B8XX5TRB.mjs.map +0 -1
  80. package/dist/job-CtU73PGa.mjs.map +0 -1
  81. package/dist/mock-Ce1GCi4-.mjs +0 -871
  82. package/dist/mock-Ce1GCi4-.mjs.map +0 -1
  83. package/dist/registry-BozuxbPp.mjs.map +0 -1
  84. package/dist/runtime-Zkg3SUwi.mjs.map +0 -1
  85. package/dist/schema-DAdZSFOd.mjs.map +0 -1
  86. package/dist/seed-DoMTMLcm.mjs.map +0 -1
  87. package/dist/types-qhFZ8y9B.mjs +0 -4
  88. package/dist/types-ywCGpzDZ.mjs +0 -360
  89. package/dist/types-ywCGpzDZ.mjs.map +0 -1
@@ -0,0 +1,117 @@
1
+ import { TailorEnv } from "../../runtime/types.mjs";
2
+ import { TriggerJobFunctionOptions } from "../../runtime/workflow.mjs";
3
+
4
+ //#region src/vitest/mocks/workflow.d.ts
5
+ type JobHandler = (jobName: string, args: unknown, options?: TriggerJobFunctionOptions) => unknown;
6
+ type TriggerWorkflowOptions = {
7
+ authInvoker?: {
8
+ namespace: string;
9
+ machineUserName: string;
10
+ };
11
+ };
12
+ type TriggerHandlerFn = (workflowName: string, args: unknown, options?: TriggerWorkflowOptions) => string;
13
+ type ResumeHandlerFn = (executionId: string) => string;
14
+ type WaitHandlerFn = (key: string, payload: unknown) => unknown;
15
+ type ResolveHandler = (executionId: string, key: string, callback: (payload: unknown) => unknown) => unknown | Promise<unknown>;
16
+ type SetWaitHandler = {
17
+ (handler: WaitHandlerFn): void;
18
+ (handler: unknown): void;
19
+ };
20
+ interface TriggeredJob {
21
+ jobName: string;
22
+ args: unknown;
23
+ options?: TriggerJobFunctionOptions;
24
+ }
25
+ /**
26
+ * Acquire a disposable mock for workflow operations (`tailor.workflow`).
27
+ * Restored on dispose.
28
+ * @returns Disposable workflow mock control object
29
+ * @example
30
+ * ```typescript
31
+ * import { mockWorkflow } from "@tailor-platform/sdk/vitest";
32
+ *
33
+ * test("job handler", async () => {
34
+ * using wf = mockWorkflow();
35
+ * wf.setJobHandler((name) => (name === "validate" ? { valid: true } : null));
36
+ * await runWorkflowUnderTest(); // calls tailor.workflow.triggerJobFunction("validate", {})
37
+ * expect(wf.triggerJobFunction).toHaveBeenCalledWith("validate", {});
38
+ * });
39
+ * ```
40
+ */
41
+ declare function mockWorkflow(): {
42
+ /** The `triggerJobFunction` `vi.fn`. */triggerJobFunction: import("vitest").Mock<(jobName: string, args?: unknown, _options?: TriggerJobFunctionOptions) => unknown>; /** The `triggerWorkflow` `vi.fn`. */
43
+ triggerWorkflow: import("vitest").Mock<(workflowName: string, args?: unknown, _options?: TriggerWorkflowOptions) => Promise<string>>; /** The `resumeWorkflow` `vi.fn`. */
44
+ resumeWorkflow: import("vitest").Mock<(executionId: string) => Promise<string>>; /** The `wait` `vi.fn`. */
45
+ wait: import("vitest").Mock<(_key: string, _payload?: unknown) => unknown>; /** The `resolve` `vi.fn`. */
46
+ resolve: import("vitest").Mock<(_executionId: string, _key: string, _callback: (payload: unknown) => unknown) => Promise<void>>;
47
+ /**
48
+ * Set a fallback job handler. Called when the enqueue queue is empty.
49
+ * @param handler - Function returning a result for a job name, args, and options
50
+ */
51
+ setJobHandler(handler: JobHandler): void;
52
+ /**
53
+ * Enqueue a single result for the next `triggerJobFunction` call (FIFO;
54
+ * takes priority over `setJobHandler`).
55
+ * @param result - Result to return from the next call
56
+ */
57
+ enqueueResult(result: unknown): void;
58
+ /**
59
+ * Enqueue results for multiple subsequent `triggerJobFunction` calls (FIFO).
60
+ * @param results - Results to enqueue, one per upcoming call
61
+ */
62
+ enqueueResults(...results: unknown[]): void;
63
+ /**
64
+ * All jobs triggered via `triggerJobFunction`, in order.
65
+ * @returns Triggered jobs array
66
+ */
67
+ readonly triggeredJobs: TriggeredJob[];
68
+ /**
69
+ * Configure what `triggerWorkflow` returns. Pass a string (same id every
70
+ * call) or `(name, args, options) => string`. Default: a placeholder UUID.
71
+ * @param handler - Static execution ID or a function returning one
72
+ */
73
+ setTriggerHandler(handler: string | TriggerHandlerFn): void;
74
+ /**
75
+ * Configure what `resumeWorkflow` returns. Pass a string (same id every
76
+ * call) or `(executionId) => string`. Default: echoes the input executionId.
77
+ * @param handler - Static execution ID or a function returning one
78
+ */
79
+ setResumeHandler(handler: string | ResumeHandlerFn): void;
80
+ /**
81
+ * Configure what `wait` returns. Pass `(key, payload) => unknown` or any
82
+ * other value to return it for every call. Default: `null`.
83
+ * @param handler - Static value or a function returning one
84
+ */
85
+ setWaitHandler: SetWaitHandler;
86
+ /**
87
+ * Set the `env` passed to job bodies invoked via `createWorkflowJob().trigger()`.
88
+ * Cleared on dispose / reset.
89
+ * @param env - Env passed to job bodies.
90
+ */
91
+ setEnv(env: TailorEnv): void;
92
+ /**
93
+ * Configure how `resolve` runs the user-supplied callback. Default: callback
94
+ * is not invoked (records the call only).
95
+ * @param handler - Function invoked per `resolve` call
96
+ */
97
+ setResolveHandler(handler: ResolveHandler): void;
98
+ /**
99
+ * `wait` calls reshaped as `{ key, payload }` for assertions.
100
+ * @returns Wait call records
101
+ */
102
+ readonly waitCalls: {
103
+ key: string;
104
+ payload: unknown;
105
+ }[];
106
+ /**
107
+ * `resolve` calls reshaped as `{ executionId, key }` for assertions.
108
+ * @returns Resolve call records
109
+ */
110
+ readonly resolveCalls: {
111
+ executionId: string;
112
+ key: string;
113
+ }[]; /** Reset all workflow responses and recorded calls (keeps the mock installed). */
114
+ reset(): void;
115
+ } & Disposable;
116
+ //#endregion
117
+ export { mockWorkflow };
@@ -1,5 +1,5 @@
1
- import { t as RUNTIME_FLAG_KEY } from "../globals-B8XX5TRB.mjs";
2
- import { o as mockSecretmanager } from "../mock-Ce1GCi4-.mjs";
1
+ import { t as RUNTIME_FLAG_KEY } from "../globals-CcU1ONiK.mjs";
2
+ import { t as mockSecretmanager } from "../secretmanager-Bd45j7an.mjs";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { afterEach, beforeAll, beforeEach } from "vitest";
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-DSwnYPPP.mjs","names":[],"sources":["../src/runtime/workflow.ts"],"sourcesContent":["/**\n * Workflow utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.\n * At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { workflow } from \"@tailor-platform/sdk/runtime\";\n *\n * const executionId = await workflow.triggerWorkflow(\"myWorkflow\", { data: \"value\" });\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Specifies the machine user that should be used to execute the workflow.\n * This allows workflows to run with specific authentication context.\n */\nexport interface AuthInvoker {\n /** The namespace where the machine user is defined */\n namespace: string;\n /** The name of the machine user to use for workflow execution */\n machineUserName: string;\n}\n\n/** Options for {@link triggerWorkflow}. */\nexport interface TriggerWorkflowOptions {\n /** Optional authentication invoker to specify which machine user should execute the workflow */\n authInvoker?: AuthInvoker;\n}\n\n/**\n * Platform API surface for `tailor.workflow`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.workflow`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as workflow from\n * \"@tailor-platform/sdk/runtime/workflow\"` or pick individual methods.\n */\nexport interface TailorWorkflowAPI {\n /**\n * Triggers a workflow and returns its execution ID.\n * @param workflowName - Workflow name as defined in tailor.config\n * @param args - Arguments forwarded to the workflow's main job\n * @param options - Optional trigger options (e.g. `authInvoker`)\n * @returns The execution ID of the triggered workflow\n */\n triggerWorkflow(\n workflowName: string,\n args?: any,\n options?: TriggerWorkflowOptions,\n ): Promise<string>;\n\n /**\n * Resumes a failed or pending-retry workflow execution and returns its execution ID.\n * @param executionId - The execution to resume\n * @returns The execution ID of the resumed workflow\n */\n resumeWorkflow(executionId: string): Promise<string>;\n\n /**\n * Triggers a job function and returns its result.\n * @param jobName - Job name as defined in the workflow\n * @param args - Arguments forwarded to the job\n * @returns The job's return value\n */\n triggerJobFunction(jobName: string, args?: any): any;\n\n /**\n * Suspends the current workflow execution and waits for an external signal to resume.\n * @param key - Wait point key\n * @param payload - Optional payload to record with the wait point\n * @returns The payload supplied by the corresponding `resolve` call\n */\n wait(key: string, payload?: any): any;\n\n /**\n * Resolves a waiting workflow execution, causing it to resume.\n * @param executionId - The execution to resume\n * @param key - Wait point key to resolve\n * @param callback - Callback receiving the wait payload; its return value is forwarded to `wait`\n * @returns A promise that resolves once the resolve has been recorded\n */\n resolve(executionId: string, key: string, callback: (waitPayload: any) => any): Promise<void>;\n}\n\nconst api = (): TailorWorkflowAPI =>\n (globalThis as { tailor: { workflow: TailorWorkflowAPI } }).tailor.workflow;\n\n/**\n * See {@link TailorWorkflowAPI.triggerWorkflow}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerWorkflow}\n * @returns The execution ID of the triggered workflow\n */\nexport const triggerWorkflow: TailorWorkflowAPI[\"triggerWorkflow\"] = (...args) =>\n api().triggerWorkflow(...args);\n\n/**\n * See {@link TailorWorkflowAPI.resumeWorkflow}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.resumeWorkflow}\n * @returns The execution ID of the resumed workflow\n */\nexport const resumeWorkflow: TailorWorkflowAPI[\"resumeWorkflow\"] = (...args) =>\n api().resumeWorkflow(...args);\n\n/**\n * See {@link TailorWorkflowAPI.triggerJobFunction}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerJobFunction}\n * @returns The job's return value\n */\nexport const triggerJobFunction: TailorWorkflowAPI[\"triggerJobFunction\"] = (...args) =>\n api().triggerJobFunction(...args);\n\n/**\n * See {@link TailorWorkflowAPI.wait}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.wait}\n * @returns The payload supplied by the corresponding `resolve` call\n */\nexport const wait: TailorWorkflowAPI[\"wait\"] = (...args) => api().wait(...args);\n\n/**\n * See {@link TailorWorkflowAPI.resolve}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.resolve}\n * @returns A promise that resolves once the resolve has been recorded\n */\nexport const resolve: TailorWorkflowAPI[\"resolve\"] = (...args) => api().resolve(...args);\n"],"mappings":";;;;;;;;;;AAsFA,MAAM,YACH,WAA2D,OAAO;;;;;;AAOrE,MAAa,mBAAyD,GAAG,SACvE,IAAI,CAAC,CAAC,gBAAgB,GAAG,IAAI;;;;;;AAO/B,MAAa,kBAAuD,GAAG,SACrE,IAAI,CAAC,CAAC,eAAe,GAAG,IAAI;;;;;;AAO9B,MAAa,sBAA+D,GAAG,SAC7E,IAAI,CAAC,CAAC,mBAAmB,GAAG,IAAI;;;;;;AAOlC,MAAa,QAAmC,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI;;;;;;AAO9E,MAAa,WAAyC,GAAG,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG,IAAI"}
1
+ {"version":3,"file":"workflow-DSwnYPPP.mjs","names":[],"sources":["../src/runtime/workflow.ts"],"sourcesContent":["/**\n * Workflow utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.\n * At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { workflow } from \"@tailor-platform/sdk/runtime\";\n *\n * const executionId = await workflow.triggerWorkflow(\"myWorkflow\", { data: \"value\" });\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Specifies the machine user that should be used to execute the workflow.\n * This allows workflows to run with specific authentication context.\n */\nexport interface AuthInvoker {\n /** The namespace where the machine user is defined */\n namespace: string;\n /** The name of the machine user to use for workflow execution */\n machineUserName: string;\n}\n\n/** Options for {@link triggerWorkflow}. */\nexport interface TriggerWorkflowOptions {\n /** Optional authentication invoker to specify which machine user should execute the workflow */\n authInvoker?: AuthInvoker;\n}\n\ndeclare const executionPolicyKeyBrand: unique symbol;\n\n/**\n * A concrete runtime key produced by an execution policy instance — either an\n * exact-match policy's `.key`, or a wildcard policy's `.keyFor(suffix)` (see\n * `defineWorkflowExecutionPolicies`). Branded so an arbitrary string that\n * wasn't derived from a declared policy can't be passed as `executionPolicyKey`.\n */\nexport type ExecutionPolicyKey = string & { readonly [executionPolicyKeyBrand]: never };\n\n/** Options for {@link triggerJobFunction}. */\nexport interface TriggerJobFunctionOptions {\n /**\n * Execution policy key matched by the platform against the policies\n * declared with `defineWorkflowExecutionPolicies` in `tailor.config.ts`.\n */\n executionPolicyKey?: ExecutionPolicyKey;\n}\n\n/**\n * Platform API surface for `tailor.workflow`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.workflow`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as workflow from\n * \"@tailor-platform/sdk/runtime/workflow\"` or pick individual methods.\n */\nexport interface TailorWorkflowAPI {\n /**\n * Triggers a workflow and returns its execution ID.\n * @param workflowName - Workflow name as defined in tailor.config\n * @param args - Arguments forwarded to the workflow's main job\n * @param options - Optional trigger options (e.g. `authInvoker`)\n * @returns The execution ID of the triggered workflow\n */\n triggerWorkflow(\n workflowName: string,\n args?: any,\n options?: TriggerWorkflowOptions,\n ): Promise<string>;\n\n /**\n * Resumes a failed or pending-retry workflow execution and returns its execution ID.\n * @param executionId - The execution to resume\n * @returns The execution ID of the resumed workflow\n */\n resumeWorkflow(executionId: string): Promise<string>;\n\n /**\n * Triggers a job function and returns its result.\n * @param jobName - Job name as defined in the workflow\n * @param args - Arguments forwarded to the job\n * @param options - Optional trigger options (e.g. `executionPolicyKey`)\n * @returns The job's return value\n */\n triggerJobFunction(jobName: string, args?: any, options?: TriggerJobFunctionOptions): any;\n\n /**\n * Suspends the current workflow execution and waits for an external signal to resume.\n * @param key - Wait point key\n * @param payload - Optional payload to record with the wait point\n * @returns The payload supplied by the corresponding `resolve` call\n */\n wait(key: string, payload?: any): any;\n\n /**\n * Resolves a waiting workflow execution, causing it to resume.\n * @param executionId - The execution to resume\n * @param key - Wait point key to resolve\n * @param callback - Callback receiving the wait payload; its return value is forwarded to `wait`\n * @returns A promise that resolves once the resolve has been recorded\n */\n resolve(executionId: string, key: string, callback: (waitPayload: any) => any): Promise<void>;\n}\n\nconst api = (): TailorWorkflowAPI =>\n (globalThis as { tailor: { workflow: TailorWorkflowAPI } }).tailor.workflow;\n\n/**\n * See {@link TailorWorkflowAPI.triggerWorkflow}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerWorkflow}\n * @returns The execution ID of the triggered workflow\n */\nexport const triggerWorkflow: TailorWorkflowAPI[\"triggerWorkflow\"] = (...args) =>\n api().triggerWorkflow(...args);\n\n/**\n * See {@link TailorWorkflowAPI.resumeWorkflow}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.resumeWorkflow}\n * @returns The execution ID of the resumed workflow\n */\nexport const resumeWorkflow: TailorWorkflowAPI[\"resumeWorkflow\"] = (...args) =>\n api().resumeWorkflow(...args);\n\n/**\n * See {@link TailorWorkflowAPI.triggerJobFunction}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerJobFunction}\n * @returns The job's return value\n */\nexport const triggerJobFunction: TailorWorkflowAPI[\"triggerJobFunction\"] = (...args) =>\n api().triggerJobFunction(...args);\n\n/**\n * See {@link TailorWorkflowAPI.wait}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.wait}\n * @returns The payload supplied by the corresponding `resolve` call\n */\nexport const wait: TailorWorkflowAPI[\"wait\"] = (...args) => api().wait(...args);\n\n/**\n * See {@link TailorWorkflowAPI.resolve}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.resolve}\n * @returns A promise that resolves once the resolve has been recorded\n */\nexport const resolve: TailorWorkflowAPI[\"resolve\"] = (...args) => api().resolve(...args);\n"],"mappings":";;;;;;;;;;AA0GA,MAAM,YACH,WAA2D,OAAO;;;;;;AAOrE,MAAa,mBAAyD,GAAG,SACvE,IAAI,CAAC,CAAC,gBAAgB,GAAG,IAAI;;;;;;AAO/B,MAAa,kBAAuD,GAAG,SACrE,IAAI,CAAC,CAAC,eAAe,GAAG,IAAI;;;;;;AAO9B,MAAa,sBAA+D,GAAG,SAC7E,IAAI,CAAC,CAAC,mBAAmB,GAAG,IAAI;;;;;;AAOlC,MAAa,QAAmC,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI;;;;;;AAO9E,MAAa,WAAyC,GAAG,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG,IAAI"}
@@ -286,6 +286,30 @@ export default defineConfig({
286
286
 
287
287
  **ignores**: Glob patterns to exclude files. Optional.
288
288
 
289
+ ### Workflow Execution Policies
290
+
291
+ Register workspace-scoped execution policies that workflow job functions reference at runtime for per-key concurrency control. See [Execution Policies](./services/workflow.md#execution-policies) in the Workflow guide for the declaration API.
292
+
293
+ ```typescript
294
+ import { defineWorkflowExecutionPolicies } from "@tailor-platform/sdk";
295
+
296
+ const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
297
+ premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
298
+ tenantApi: define({
299
+ name: "tenant-api",
300
+ matchType: "prefix",
301
+ concurrencyPolicy: { maxConcurrentExecutions: 3 },
302
+ }),
303
+ }));
304
+
305
+ export default defineConfig({
306
+ workflow: {
307
+ files: ["workflows/**/*.ts"],
308
+ executionPolicies,
309
+ },
310
+ });
311
+ ```
312
+
289
313
  ### Plugins
290
314
 
291
315
  Configure plugins using `definePlugins()`. Plugins must be exported as a named export.
@@ -351,6 +351,84 @@ export default createWorkflow({
351
351
  });
352
352
  ```
353
353
 
354
+ ## Execution Policies
355
+
356
+ Execution policies apply a per-key concurrency cap to workflow job function dispatches. Declare them at the workspace level and pass a matching key when triggering a job; the platform serializes dispatches that resolve to the same key and suspends any that would exceed the cap until slots free up.
357
+
358
+ ### Declaring Policies
359
+
360
+ Use `defineWorkflowExecutionPolicies` with a builder callback. Property names supply the workspace-unique name and default key prefix verbatim, matching the mental model of `defineWaitPoints`. Override `name` or `key` in the body when the property identifier is not valid execution policy grammar or the key prefix needs to differ. Set `matchType: "prefix"` to register the prefix as a wildcard that matches every dispatch key starting with it (the default, `"exact"`, matches only a dispatch key equal to it).
361
+
362
+ ```typescript
363
+ import { defineWorkflowExecutionPolicies } from "@tailor-platform/sdk";
364
+
365
+ export const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
366
+ /** Shared cap across every "premium" worker dispatch. */
367
+ premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
368
+ /** Per-tenant cap: one pool per resolved tenant key. */
369
+ tenantApi: define({
370
+ name: "tenant-api",
371
+ matchType: "prefix",
372
+ concurrencyPolicy: { maxConcurrentExecutions: 3 },
373
+ }),
374
+ }));
375
+ ```
376
+
377
+ For a single policy, use `defineWorkflowExecutionPolicy(name, def?)`; the key prefix defaults to `name` when `key` is omitted.
378
+
379
+ `concurrencyPolicy` is optional; when omitted, the policy registers the key as valid without a user-defined limit (platform safety nets still apply).
380
+
381
+ Register the policies on your config so the SDK creates them on the workspace during deploy:
382
+
383
+ ```typescript
384
+ // tailor.config.ts
385
+ import { defineConfig } from "@tailor-platform/sdk";
386
+ import { executionPolicies } from "./workflows/policies";
387
+
388
+ export default defineConfig({
389
+ workflow: {
390
+ files: ["workflows/**/*.ts"],
391
+ executionPolicies,
392
+ },
393
+ });
394
+ ```
395
+
396
+ ### Key Grammar
397
+
398
+ `key` accepts `[a-z0-9_:.-]` and must start with `[a-z0-9]`. An exact key must also end with `[a-z0-9]`; a wildcard prefix (`matchType: "prefix"`) may end with any of those characters, since the platform appends a trailing `*` after it. The platform-registered key — including that trailing `*` when wildcarded — is 2 to 64 characters long, so a wildcard prefix must be at most 63 characters. `foo:bar` is a valid exact key; `tenant-api` with `matchType: "prefix"` registers `tenant-api*` as a wildcard prefix.
399
+
400
+ An exact-key policy applies to dispatches whose runtime key equals the policy key. A wildcard policy applies to every dispatch whose runtime key begins with the prefix; each concrete resolved key gets its own independent pool of the declared size (a `cap = 3` wildcard yields three concurrent dispatches per resolved key, not three across every match). The longest matching prefix wins when a dispatch could match more than one wildcard.
401
+
402
+ ### Referencing a Policy from a Workflow
403
+
404
+ Pass the runtime key through the `executionPolicyKey` option on `job.trigger()` or `tailor.workflow.triggerJobFunction()`. For exact-key policies, use `<policy>.key` directly — it's typed so only a value that came from a declared policy can be passed. For wildcard policies (`matchType: "prefix"`), there is no `<policy>.key` — call `<policy>.keyFor(suffix)` to build the concrete key. `keyFor` joins the prefix and suffix with `.` by default; override it with `separator` — the second argument to `defineWorkflowExecutionPolicies` (applies to every policy in the group), or a `def` field on a single `defineWorkflowExecutionPolicy`.
405
+
406
+ ```typescript
407
+ import { createWorkflowJob } from "@tailor-platform/sdk";
408
+ import { executionPolicies } from "./policies";
409
+ import { sendNotification } from "./jobs/send-notification";
410
+ import { fetchTenant } from "./jobs/fetch-tenant";
411
+
412
+ export const mainJob = createWorkflowJob({
413
+ name: "main-job",
414
+ body: async (input: { tenantId: string }) => {
415
+ // Exact key policy: pass .key directly.
416
+ await sendNotification.trigger(
417
+ { message: "Order processed" },
418
+ { executionPolicyKey: executionPolicies.premium.key },
419
+ );
420
+
421
+ // Wildcard policy: build the concrete key with keyFor().
422
+ await fetchTenant.trigger(
423
+ { tenantId: input.tenantId },
424
+ { executionPolicyKey: executionPolicies.tenantApi.keyFor(input.tenantId) },
425
+ );
426
+ },
427
+ });
428
+ ```
429
+
430
+ The same `executionPolicyKey` option is available on `tailor.workflow.triggerJobFunction(name, args, options)` for jobs invoked by name.
431
+
354
432
  ## Triggering a Workflow from a Resolver
355
433
 
356
434
  You can start a workflow execution from a resolver using `workflow.trigger()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.74.0",
3
+ "version": "1.75.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -155,9 +155,9 @@
155
155
  "@jridgewell/trace-mapping": "0.3.31",
156
156
  "@napi-rs/keyring": "1.3.0",
157
157
  "@opentelemetry/api": "1.9.1",
158
- "@opentelemetry/exporter-trace-otlp-proto": "0.219.0",
159
- "@opentelemetry/resources": "2.8.0",
160
- "@opentelemetry/sdk-trace-node": "2.8.0",
158
+ "@opentelemetry/exporter-trace-otlp-proto": "0.220.0",
159
+ "@opentelemetry/resources": "2.9.0",
160
+ "@opentelemetry/sdk-trace-node": "2.9.0",
161
161
  "@opentelemetry/semantic-conventions": "1.41.1",
162
162
  "@oxc-project/types": "0.138.0",
163
163
  "@standard-schema/spec": "1.1.0",
@@ -190,19 +190,19 @@
190
190
  "std-env": "4.1.0",
191
191
  "table": "6.9.0",
192
192
  "ts-cron-validator": "1.1.5",
193
- "tsx": "4.22.4",
193
+ "tsx": "4.22.5",
194
194
  "type-fest": "5.7.0",
195
- "undici": "8.5.0",
195
+ "undici": "8.6.0",
196
196
  "xdg-basedir": "5.1.0",
197
197
  "zod": "4.4.3"
198
198
  },
199
199
  "devDependencies": {
200
- "@opentelemetry/sdk-trace-base": "2.8.0",
200
+ "@opentelemetry/sdk-trace-base": "2.9.0",
201
201
  "@types/madge": "5.0.3",
202
202
  "@types/mime-types": "3.0.1",
203
203
  "@types/node": "24.13.2",
204
204
  "@types/semver": "7.7.1",
205
- "@typescript/native-preview": "7.0.0-dev.20260621.1",
205
+ "@typescript/native-preview": "7.0.0-dev.20260703.1",
206
206
  "@vitest/coverage-v8": "4.1.9",
207
207
  "oxfmt": "0.57.0",
208
208
  "oxlint": "1.72.0",
@@ -1,3 +0,0 @@
1
- import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-DwmoI6ZQ.mjs";
2
-
3
- export { defineApplication, generatePluginFilesIfNeeded };