@tailor-platform/sdk 2.0.0-next.1 → 2.0.0-next.2

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 (119) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/application-Dtqap5jM.mjs +3 -0
  3. package/dist/{client-z_oHGVNy.mjs → application-XuMWK4eq.mjs} +5861 -20
  4. package/dist/application-XuMWK4eq.mjs.map +1 -0
  5. package/dist/cli/index.mjs +179 -122
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +75 -16
  8. package/dist/cli/lib.mjs +5 -6
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/completion/zsh-worker.zsh +105 -26
  11. package/dist/configure/index.d.mts +9 -8
  12. package/dist/configure/index.mjs +56 -19
  13. package/dist/configure/index.mjs.map +1 -1
  14. package/dist/context-Bd266-ru.mjs.map +1 -1
  15. package/dist/{context-BuuIb8CC.d.mts → context-C2lEi9uw.d.mts} +7 -28
  16. package/dist/{crashreport-pr6Rhvza.mjs → crashreport-BMWcxeSE.mjs} +1 -1
  17. package/dist/{crashreport-BsjAkFWw.mjs → crashreport-DFq-vsU0.mjs} +5 -7
  18. package/dist/{crashreport-BsjAkFWw.mjs.map → crashreport-DFq-vsU0.mjs.map} +1 -1
  19. package/dist/{file-_oUZo76X.mjs → file-BbdFGdMV.mjs} +2 -10
  20. package/dist/file-BbdFGdMV.mjs.map +1 -0
  21. package/dist/{file-BB8Vs9O_.d.mts → file-Dq3NIt_F.d.mts} +3 -42
  22. package/dist/{file-utils-DcyIPFQh.mjs → file-utils-CYZnO1pX.mjs} +5 -5
  23. package/dist/file-utils-CYZnO1pX.mjs.map +1 -0
  24. package/dist/{globals-Crz8o65k.mjs → globals-Cf0sxIt8.mjs} +2 -2
  25. package/dist/{globals-Crz8o65k.mjs.map → globals-Cf0sxIt8.mjs.map} +1 -1
  26. package/dist/{http-adapter.generated-WgMnb7Sb.d.mts → http-adapter.generated-DFsXDdm5.d.mts} +11 -10
  27. package/dist/{index-BlpzXncY.d.mts → index-BI-_j9Z3.d.mts} +29 -32
  28. package/dist/{index-DjUdWlzf.d.mts → index-C4JirJH8.d.mts} +2 -2
  29. package/dist/{index-5vPyRu1y.d.mts → index-CZfWhr0a.d.mts} +2 -2
  30. package/dist/{index-CK7u9isy.d.mts → index-Cg8VKAdN.d.mts} +4 -4
  31. package/dist/{index-B7AKc18V.d.mts → index-DYRjoLXD.d.mts} +2 -2
  32. package/dist/{index-ZePLwxw7.d.mts → index-lFpcjHPU.d.mts} +8 -15
  33. package/dist/{index-CNYe5lnW.d.mts → index-nW7hE6oE.d.mts} +2 -2
  34. package/dist/{mock-BjFj5o1I.mjs → mock-FPxmnt-y.mjs} +4 -49
  35. package/dist/{mock-BjFj5o1I.mjs.map → mock-FPxmnt-y.mjs.map} +1 -1
  36. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  37. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  38. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  39. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  40. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  41. package/dist/plugin/builtin/seed/index.mjs +1 -1
  42. package/dist/plugin/index.d.mts +4 -3
  43. package/dist/plugin/index.mjs.map +1 -1
  44. package/dist/{registry-DdsYlL_P.mjs → registry-DH4m7eYo.mjs} +4 -2
  45. package/dist/registry-DH4m7eYo.mjs.map +1 -0
  46. package/dist/runtime/context.d.mts +1 -1
  47. package/dist/runtime/file.d.mts +2 -2
  48. package/dist/runtime/file.mjs +2 -2
  49. package/dist/runtime/globals.d.mts +6 -6
  50. package/dist/runtime/index.d.mts +4 -4
  51. package/dist/runtime/index.mjs +2 -2
  52. package/dist/runtime/workflow.d.mts +2 -2
  53. package/dist/runtime/workflow.mjs +1 -1
  54. package/dist/{runtime-n9NCkjee.mjs → runtime-CY4JvrDj.mjs} +777 -234
  55. package/dist/runtime-CY4JvrDj.mjs.map +1 -0
  56. package/dist/{schema-BhkpP5Hw.mjs → schema-Dtw9Orye.mjs} +16 -13
  57. package/dist/schema-Dtw9Orye.mjs.map +1 -0
  58. package/dist/{secret-file-DBqZhjFQ.mjs → secret-file-VSVGy1V0.mjs} +27 -2
  59. package/dist/{secret-file-DBqZhjFQ.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
  60. package/dist/{seed-jf3008-h.mjs → seed-izIEyP3z.mjs} +3 -4
  61. package/dist/seed-izIEyP3z.mjs.map +1 -0
  62. package/dist/service-DCqIWibD.mjs +3 -0
  63. package/dist/{service-DU1mVzri.mjs → service-DU1mVzri2.mjs} +1 -1
  64. package/dist/service-DU1mVzri2.mjs.map +1 -0
  65. package/dist/{service-CCL8ruDf.mjs → service-DjyqbCaJ.mjs} +7 -7
  66. package/dist/{service-CCL8ruDf.mjs.map → service-DjyqbCaJ.mjs.map} +1 -1
  67. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  68. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  69. package/dist/{types-ClhIrW_C.mjs → types-74etvaxy.mjs} +1 -1
  70. package/dist/{types-DhO_VEZd.d.mts → types-BDRml5C3.d.mts} +12 -12
  71. package/dist/{types-B2RpYyA_.mjs → types-BQijbo4m.mjs} +9 -9
  72. package/dist/types-BQijbo4m.mjs.map +1 -0
  73. package/dist/{types-DwDgacni.d.mts → types-BX4q6Mo6.d.mts} +3 -2
  74. package/dist/types-BZ7QKVE8.d.mts +21 -0
  75. package/dist/{types-DCUhgpyI.d.mts → types-CdcQh4Z2.d.mts} +5 -76
  76. package/dist/utils/test/index.d.mts +6 -15
  77. package/dist/utils/test/index.mjs +4 -13
  78. package/dist/utils/test/index.mjs.map +1 -1
  79. package/dist/vitest/environment.mjs +1 -1
  80. package/dist/vitest/index.d.mts +2 -2
  81. package/dist/vitest/index.mjs +4 -4
  82. package/dist/vitest/setup.mjs +2 -2
  83. package/dist/{workflow-DgemCAz3.mjs → workflow-BOmaZwwG.mjs} +8 -3
  84. package/dist/workflow-BOmaZwwG.mjs.map +1 -0
  85. package/dist/{workflow-BbKvGLQg.d.mts → workflow-BVy4XWjS.d.mts} +15 -10
  86. package/dist/{workflow.generated-DtQwEo-x.d.mts → workflow.generated-ClEjBYhm.d.mts} +3 -3
  87. package/docs/cli/executor.md +53 -0
  88. package/docs/cli/setup.md +35 -33
  89. package/docs/cli/workflow.md +157 -20
  90. package/docs/cli-reference.md +26 -20
  91. package/docs/github-actions.md +29 -16
  92. package/docs/migration/v2.md +475 -0
  93. package/docs/runtime.md +1 -1
  94. package/docs/services/auth.md +12 -12
  95. package/docs/services/executor.md +3 -3
  96. package/docs/services/resolver.md +6 -6
  97. package/docs/services/tailordb.md +14 -12
  98. package/docs/services/workflow.md +4 -4
  99. package/docs/testing.md +59 -47
  100. package/package.json +7 -7
  101. package/dist/application-DB2r36Et.mjs +0 -3
  102. package/dist/application-DqS1yBg3.mjs +0 -5680
  103. package/dist/application-DqS1yBg3.mjs.map +0 -1
  104. package/dist/client-Dbohmtkv.mjs +0 -3
  105. package/dist/client-z_oHGVNy.mjs.map +0 -1
  106. package/dist/file-_oUZo76X.mjs.map +0 -1
  107. package/dist/file-utils-DcyIPFQh.mjs.map +0 -1
  108. package/dist/job-fuc3j1Ma.mjs +0 -53
  109. package/dist/job-fuc3j1Ma.mjs.map +0 -1
  110. package/dist/registry-DdsYlL_P.mjs.map +0 -1
  111. package/dist/runtime-n9NCkjee.mjs.map +0 -1
  112. package/dist/schema-BhkpP5Hw.mjs.map +0 -1
  113. package/dist/seed-jf3008-h.mjs.map +0 -1
  114. package/dist/service-D6yonf2I.mjs +0 -3
  115. package/dist/service-DU1mVzri.mjs.map +0 -1
  116. package/dist/test-env-key-D9kM6ETE.mjs +0 -49
  117. package/dist/test-env-key-D9kM6ETE.mjs.map +0 -1
  118. package/dist/types-B2RpYyA_.mjs.map +0 -1
  119. package/dist/workflow-DgemCAz3.mjs.map +0 -1
@@ -1,77 +1,6 @@
1
+ import { i as InferredAttributeMap, o as TailorPrincipal } from "./types-BZ7QKVE8.mjs";
1
2
  import { NonEmptyObject } from "type-fest";
2
3
 
3
- //#region src/runtime/types.d.ts
4
- interface AttributeMap {}
5
- interface AttributeList {
6
- __tuple?: [];
7
- }
8
- type InferredAttributeMap = keyof AttributeMap extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : AttributeMap;
9
- type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
10
- /** Represents a user in the Tailor platform. */
11
- type TailorUser = {
12
- /**
13
- * The ID of the user.
14
- * For unauthenticated users, this will be a nil UUID.
15
- */
16
- id: string;
17
- /**
18
- * The type of the user.
19
- * For unauthenticated users, this will be an empty string.
20
- */
21
- type: "user" | "machine_user" | ""; /** The ID of the workspace the user belongs to. */
22
- workspaceId: string;
23
- /**
24
- * A map of the user's attributes.
25
- * For unauthenticated users, this will be null.
26
- */
27
- attributes: InferredAttributeMap | null;
28
- /**
29
- * A list of the user's attributes.
30
- * For unauthenticated users, this will be an empty array.
31
- */
32
- attributeList: InferredAttributeList;
33
- };
34
- /**
35
- * The invoker of the current function execution.
36
- *
37
- * Reflects `authInvoker` delegation: when `authInvoker` is specified, this is
38
- * the machine user; otherwise it is the calling user.
39
- * Distinct from resolver's `user` (the authenticated caller) and executor's
40
- * `actor` (the subject of the event).
41
- *
42
- * `null` for anonymous requests.
43
- *
44
- * TODO(v2): unify with `TailorUser` — same underlying principal shape.
45
- */
46
- type TailorInvoker = {
47
- /** The ID of the invoker (user ID or machine user ID). */id: string; /** The type of the invoker. */
48
- type: "user" | "machine_user"; /** The ID of the workspace the invoker belongs to. */
49
- workspaceId: string; /** A map of the invoker's attributes. */
50
- attributes: InferredAttributeMap; /** A list of the invoker's attribute IDs. */
51
- attributeList: InferredAttributeList;
52
- } | null;
53
- /** User type enum values from the Tailor Platform server. */
54
- type TailorActorType = "USER_TYPE_USER" | "USER_TYPE_MACHINE_USER" | "USER_TYPE_UNSPECIFIED";
55
- /** Represents an actor in event triggers. */
56
- type TailorActor = {
57
- /** The ID of the workspace the user belongs to. */workspaceId: string; /** The ID of the user. */
58
- userId: string;
59
- /**
60
- * A map of the user's attributes.
61
- * Maps from server's `attributeMap` field.
62
- */
63
- attributes: InferredAttributeMap | null;
64
- /**
65
- * A list of the user's attributes.
66
- * Maps from server's `attributes` field.
67
- */
68
- attributeList: InferredAttributeList; /** The type of the user. */
69
- userType: TailorActorType;
70
- };
71
- interface Env {}
72
- /** Represents environment variables in the Tailor platform. */
73
- type TailorEnv = keyof Env extends never ? Record<string, string | number | boolean> : Env;
74
- //#endregion
75
4
  //#region src/types/helpers.d.ts
76
5
  type Prettify<T> = { [K in keyof T as string extends K ? never : K]: T[K] } & {};
77
6
  type DeepWritable<T> = T extends Date | RegExp | Function ? T : T extends object ? { -readonly [P in keyof T]: DeepWritable<T[P]> } & {} : T;
@@ -157,7 +86,7 @@ type ArrayFieldOutput<T, O extends FieldOptions> = [O] extends [{
157
86
  type ValidateFn<O, D = unknown> = (args: {
158
87
  value: O;
159
88
  data: D;
160
- user: TailorUser;
89
+ invoker: TailorPrincipal | null;
161
90
  }) => boolean;
162
91
  /**
163
92
  * Validation configuration with custom error message
@@ -728,7 +657,7 @@ type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, Use
728
657
  type HookFn<TValue, TData, TReturn> = (args: {
729
658
  value: TValue;
730
659
  data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
731
- user: TailorUser;
660
+ invoker: TailorPrincipal | null;
732
661
  }) => TReturn;
733
662
  type Hook<TData, TReturn> = {
734
663
  create?: HookFn<TReturn | null, TData, TReturn>;
@@ -780,5 +709,5 @@ type TailorDBServiceInput = {
780
709
  [namespace: string]: TailorDBServiceConfigInput | TailorDBExternalConfig;
781
710
  };
782
711
  //#endregion
783
- export { Validators as A, TailorActor as B, FieldMetadata as C, TailorField as D, FieldValidateInput as E, output as F, TailorInvoker as H, AttributeList as I, AttributeMap as L, JsonCompatible as M, JsonValue$1 as N, TailorFieldType as O, Prettify as P, Env as R, EnumValue as S, FieldOutput as T, TailorUser as U, TailorEnv as V, TailorDBTypeMetadata as _, Hooks as a, ArrayFieldOutput as b, RawRelationConfig as c, TailorAnyDBField as d, TailorAnyDBType as f, TailorDBType as g, TailorDBServiceInput as h, Hook as i, InferFieldsOutput as j, TailorToTs as k, RelationType as l, TailorDBInstance as m, DefinedDBFieldMetadata as n, IndexDef as o, TailorDBField as p, ExcludeNestedDBFields as r, PluginAttachment as s, DBFieldMetadata as t, SerialConfig as u, TypeFeatures as v, FieldOptions as w, DefinedFieldMetadata as x, TailorDBTypeParsedSettings as y, InferredAttributeMap as z };
784
- //# sourceMappingURL=types-DCUhgpyI.d.mts.map
712
+ export { Validators as A, FieldMetadata as C, TailorField as D, FieldValidateInput as E, output as F, JsonCompatible as M, JsonValue$1 as N, TailorFieldType as O, Prettify as P, EnumValue as S, FieldOutput as T, TailorDBTypeMetadata as _, Hooks as a, ArrayFieldOutput as b, RawRelationConfig as c, TailorAnyDBField as d, TailorAnyDBType as f, TailorDBType as g, TailorDBServiceInput as h, Hook as i, InferFieldsOutput as j, TailorToTs as k, RelationType as l, TailorDBInstance as m, DefinedDBFieldMetadata as n, IndexDef as o, TailorDBField as p, ExcludeNestedDBFields as r, PluginAttachment as s, DBFieldMetadata as t, SerialConfig as u, TypeFeatures as v, FieldOptions as w, DefinedFieldMetadata as x, TailorDBTypeParsedSettings as y };
713
+ //# sourceMappingURL=types-CdcQh4Z2.d.mts.map
@@ -1,7 +1,6 @@
1
- import { H as TailorInvoker } from "../../types-DCUhgpyI.mjs";
2
- import { o as TailorDBType } from "../../http-adapter.generated-WgMnb7Sb.mjs";
3
- import { u as WORKFLOW_TEST_ENV_KEY } from "../../index-ZePLwxw7.mjs";
4
- import { bt as TailorField, n as output } from "../../index-BlpzXncY.mjs";
1
+ import { o as TailorPrincipal } from "../../types-BZ7QKVE8.mjs";
2
+ import { o as TailorDBType } from "../../http-adapter.generated-DFsXDdm5.mjs";
3
+ import { n as output, yt as TailorField } from "../../index-BI-_j9Z3.mjs";
5
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
5
 
7
6
  //#region src/utils/test/mock.d.ts
@@ -44,9 +43,9 @@ declare function setupWorkflowMock(handler: JobHandler): {
44
43
  * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled
45
44
  * resolver/executor/workflow tests.
46
45
  * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, "getInvoker").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.
47
- * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.
46
+ * @param invoker - The `TailorPrincipal` value to return, or `null` for anonymous.
48
47
  */
49
- declare function setupInvokerMock(invoker: TailorInvoker): void;
48
+ declare function setupInvokerMock(invoker: TailorPrincipal | null): void;
50
49
  /**
51
50
  * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.
52
51
  * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.
@@ -89,14 +88,6 @@ declare function setupWaitPointMock(config?: {
89
88
  declare function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction>;
90
89
  //#endregion
91
90
  //#region src/utils/test/index.d.ts
92
- /** Represents an unauthenticated user in the Tailor platform. */
93
- declare const unauthenticatedTailorUser: {
94
- readonly id: "00000000-0000-0000-0000-000000000000";
95
- readonly type: "";
96
- readonly workspaceId: "00000000-0000-0000-0000-000000000000";
97
- readonly attributes: null;
98
- readonly attributeList: [];
99
- };
100
91
  /**
101
92
  * Creates a hook function that processes TailorDB type fields
102
93
  * - Uses existing id from data if provided, otherwise generates UUID for id fields
@@ -125,5 +116,5 @@ declare function createStandardSchema<T = Record<string, unknown>>(schemaType: T
125
116
  };
126
117
  };
127
118
  //#endregion
128
- export { WORKFLOW_TEST_ENV_KEY, createImportMain, createStandardSchema, createTailorDBHook, setupInvokerMock, setupTailorErrorsMock, setupTailordbMock, setupWaitPointMock, setupWorkflowMock, unauthenticatedTailorUser };
119
+ export { createImportMain, createStandardSchema, createTailorDBHook, setupInvokerMock, setupTailorErrorsMock, setupTailordbMock, setupWaitPointMock, setupWorkflowMock };
129
120
  //# sourceMappingURL=index.d.mts.map
@@ -1,4 +1,3 @@
1
- import { t as WORKFLOW_TEST_ENV_KEY } from "../../test-env-key-D9kM6ETE.mjs";
2
1
  import { pathToFileURL } from "node:url";
3
2
  import * as path from "node:path";
4
3
 
@@ -75,7 +74,7 @@ function setupWorkflowMock(handler) {
75
74
  * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled
76
75
  * resolver/executor/workflow tests.
77
76
  * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, "getInvoker").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.
78
- * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.
77
+ * @param invoker - The `TailorPrincipal` value to return, or `null` for anonymous.
79
78
  */
80
79
  function setupInvokerMock(invoker) {
81
80
  const raw = invoker ? {
@@ -168,14 +167,6 @@ function createImportMain(baseDir) {
168
167
 
169
168
  //#endregion
170
169
  //#region src/utils/test/index.ts
171
- /** Represents an unauthenticated user in the Tailor platform. */
172
- const unauthenticatedTailorUser = {
173
- id: "00000000-0000-0000-0000-000000000000",
174
- type: "",
175
- workspaceId: "00000000-0000-0000-0000-000000000000",
176
- attributes: null,
177
- attributeList: []
178
- };
179
170
  /**
180
171
  * Creates a hook function that processes TailorDB type fields
181
172
  * - Uses existing id from data if provided, otherwise generates UUID for id fields
@@ -199,7 +190,7 @@ function createTailorDBHook(type) {
199
190
  hooked[key] = field.metadata.hooks.create({
200
191
  value: data[key],
201
192
  data,
202
- user: unauthenticatedTailorUser
193
+ invoker: null
203
194
  });
204
195
  if (hooked[key] instanceof Date) hooked[key] = hooked[key].toISOString();
205
196
  } else if (data && typeof data === "object") hooked[key] = data[key];
@@ -224,7 +215,7 @@ function createStandardSchema(schemaType, hook) {
224
215
  const result = schemaType.parse({
225
216
  value: hooked,
226
217
  data: hooked,
227
- user: unauthenticatedTailorUser
218
+ invoker: null
228
219
  });
229
220
  if (result.issues) return result;
230
221
  return { value: hooked };
@@ -233,5 +224,5 @@ function createStandardSchema(schemaType, hook) {
233
224
  }
234
225
 
235
226
  //#endregion
236
- export { WORKFLOW_TEST_ENV_KEY, createImportMain, createStandardSchema, createTailorDBHook, setupInvokerMock, setupTailorErrorsMock, setupTailordbMock, setupWaitPointMock, setupWorkflowMock, unauthenticatedTailorUser };
227
+ export { createImportMain, createStandardSchema, createTailorDBHook, setupInvokerMock, setupTailorErrorsMock, setupTailordbMock, setupWaitPointMock, setupWorkflowMock };
237
228
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"@/runtime/context\";\nimport type { TailorInvoker } from \"@/runtime/types\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorInvoker): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: () => {\n throw new Error(\n \"tailor.workflow.triggerJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"@/configure/services/workflow/job\";\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"@/runtime/context\";\nimport type { TailorPrincipal } from \"@/runtime/types\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorPrincipal` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorPrincipal | null): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: () => {\n throw new Error(\n \"tailor.workflow.triggerJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n invoker: null,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n invoker: null,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-Crz8o65k.mjs";
1
+ import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-Cf0sxIt8.mjs";
2
2
  import * as globals from "globals";
3
3
 
4
4
  //#region src/vitest/environment.ts
@@ -1,5 +1,5 @@
1
- import { V as TailorEnv } from "../types-DCUhgpyI.mjs";
2
- import { i as Workflow, s as WorkflowJob } from "../index-ZePLwxw7.mjs";
1
+ import { a as TailorEnv } from "../types-BZ7QKVE8.mjs";
2
+ import { i as Workflow, s as WorkflowJob } from "../index-lFpcjHPU.mjs";
3
3
  import { Kysely, OperationNode, OperationNodeKind, Transaction } from "kysely";
4
4
  import { Mock } from "vitest";
5
5
  import { Plugin } from "vitest/config";
@@ -1,8 +1,8 @@
1
- import { i as getRegisteredJob, t as TRIGGER_DEFAULT } from "../registry-DdsYlL_P.mjs";
2
- import { a as writeWorkflowTestEnv, i as readWorkflowTestEnv, n as buildJobContext, r as clearWorkflowTestEnv } from "../test-env-key-D9kM6ETE.mjs";
1
+ import { i as getRegisteredJob, t as TRIGGER_DEFAULT } from "../registry-DH4m7eYo.mjs";
2
+ import { a as writeWorkflowTestEnv, n as clearWorkflowTestEnv, r as readWorkflowTestEnv, t as buildJobContext } from "../test-env-key-D7UkZp99.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
- import { i as platformSerialize } from "../globals-Crz8o65k.mjs";
5
- import { a as mockSecretmanager, i as mockIdp, n as mockFile, o as mockTailordb, r as mockIconv, s as mockWorkflow, t as mockAuthconnection } from "../mock-BjFj5o1I.mjs";
4
+ import { i as platformSerialize } from "../globals-Cf0sxIt8.mjs";
5
+ import { a as mockSecretmanager, i as mockIdp, n as mockFile, o as mockTailordb, r as mockIconv, s as mockWorkflow, t as mockAuthconnection } from "../mock-FPxmnt-y.mjs";
6
6
  import { builtinModules } from "node:module";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { dirname, isAbsolute, matchesGlob, relative, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { t as RUNTIME_FLAG_KEY } from "../globals-Crz8o65k.mjs";
2
- import { a as mockSecretmanager } from "../mock-BjFj5o1I.mjs";
1
+ import { t as RUNTIME_FLAG_KEY } from "../globals-Cf0sxIt8.mjs";
2
+ import { a as mockSecretmanager } from "../mock-FPxmnt-y.mjs";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { afterEach, beforeAll, beforeEach } from "vitest";
5
5
 
@@ -10,10 +10,15 @@ var workflow_exports = /* @__PURE__ */ __exportAll({
10
10
  const api = () => globalThis.tailor.workflow;
11
11
  /**
12
12
  * See {@link TailorWorkflowAPI.triggerWorkflow}.
13
- * @param args - Forwarded to {@link TailorWorkflowAPI.triggerWorkflow}
13
+ * @param workflowName - Workflow name as defined in tailor.config
14
+ * @param args - Arguments forwarded to the workflow's main job
15
+ * @param options - Optional trigger options
14
16
  * @returns The execution ID of the triggered workflow
15
17
  */
16
- const triggerWorkflow = (...args) => api().triggerWorkflow(...args);
18
+ function triggerWorkflow(workflowName, args, options) {
19
+ if (options?.invoker === void 0) return api().triggerWorkflow(workflowName, args);
20
+ return api().triggerWorkflow(workflowName, args, { authInvoker: options.invoker });
21
+ }
17
22
  /**
18
23
  * See {@link TailorWorkflowAPI.triggerJobFunction}.
19
24
  * @param args - Forwarded to {@link TailorWorkflowAPI.triggerJobFunction}
@@ -35,4 +40,4 @@ const resolve = (...args) => api().resolve(...args);
35
40
 
36
41
  //#endregion
37
42
  export { workflow_exports as a, wait as i, triggerJobFunction as n, triggerWorkflow as r, resolve as t };
38
- //# sourceMappingURL=workflow-DgemCAz3.mjs.map
43
+ //# sourceMappingURL=workflow-BOmaZwwG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-BOmaZwwG.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 Invoker {\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 invoker to specify which machine user should execute the workflow */\n invoker?: Invoker;\n}\n\nexport interface PlatformTriggerWorkflowOptions {\n authInvoker?: Invoker;\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 platform trigger options\n * @returns The execution ID of the triggered workflow\n */\n triggerWorkflow(\n workflowName: string,\n args?: any,\n options?: PlatformTriggerWorkflowOptions,\n ): 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 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\n * @returns The execution ID of the triggered workflow\n */\nexport function triggerWorkflow(\n workflowName: string,\n args?: any,\n options?: TriggerWorkflowOptions,\n): Promise<string> {\n if (options?.invoker === undefined) {\n return api().triggerWorkflow(workflowName, args);\n }\n return api().triggerWorkflow(workflowName, args, { authInvoker: options.invoker });\n}\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":";;;;;;;;;AAmFA,MAAM,YACH,WAA2D,OAAO;;;;;;;;AASrE,SAAgB,gBACd,cACA,MACA,SACiB;CACjB,IAAI,SAAS,YAAY,QACvB,OAAO,IAAI,CAAC,CAAC,gBAAgB,cAAc,IAAI;CAEjD,OAAO,IAAI,CAAC,CAAC,gBAAgB,cAAc,MAAM,EAAE,aAAa,QAAQ,QAAQ,CAAC;AACnF;;;;;;AAOA,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,5 +1,5 @@
1
1
  declare namespace workflow_d_exports {
2
- export { AuthInvoker, TailorWorkflowAPI, TriggerWorkflowOptions, resolve, triggerJobFunction, triggerWorkflow, wait };
2
+ export { Invoker, PlatformTriggerWorkflowOptions, TailorWorkflowAPI, TriggerWorkflowOptions, resolve, triggerJobFunction, triggerWorkflow, wait };
3
3
  }
4
4
  /**
5
5
  * Workflow utilities.
@@ -16,7 +16,7 @@ declare namespace workflow_d_exports {
16
16
  * Specifies the machine user that should be used to execute the workflow.
17
17
  * This allows workflows to run with specific authentication context.
18
18
  */
19
- interface AuthInvoker {
19
+ interface Invoker {
20
20
  /** The namespace where the machine user is defined */
21
21
  namespace: string;
22
22
  /** The name of the machine user to use for workflow execution */
@@ -24,8 +24,11 @@ interface AuthInvoker {
24
24
  }
25
25
  /** Options for {@link triggerWorkflow}. */
26
26
  interface TriggerWorkflowOptions {
27
- /** Optional authentication invoker to specify which machine user should execute the workflow */
28
- authInvoker?: AuthInvoker;
27
+ /** Optional invoker to specify which machine user should execute the workflow */
28
+ invoker?: Invoker;
29
+ }
30
+ interface PlatformTriggerWorkflowOptions {
31
+ authInvoker?: Invoker;
29
32
  }
30
33
  /**
31
34
  * Platform API surface for `tailor.workflow`. Describes the shape the platform
@@ -40,10 +43,10 @@ interface TailorWorkflowAPI {
40
43
  * Triggers a workflow and returns its execution ID.
41
44
  * @param workflowName - Workflow name as defined in tailor.config
42
45
  * @param args - Arguments forwarded to the workflow's main job
43
- * @param options - Optional trigger options (e.g. `authInvoker`)
46
+ * @param options - Optional platform trigger options
44
47
  * @returns The execution ID of the triggered workflow
45
48
  */
46
- triggerWorkflow(workflowName: string, args?: any, options?: TriggerWorkflowOptions): Promise<string>;
49
+ triggerWorkflow(workflowName: string, args?: any, options?: PlatformTriggerWorkflowOptions): Promise<string>;
47
50
  /**
48
51
  * Triggers a job function and returns its result.
49
52
  * @param jobName - Job name as defined in the workflow
@@ -69,10 +72,12 @@ interface TailorWorkflowAPI {
69
72
  }
70
73
  /**
71
74
  * See {@link TailorWorkflowAPI.triggerWorkflow}.
72
- * @param args - Forwarded to {@link TailorWorkflowAPI.triggerWorkflow}
75
+ * @param workflowName - Workflow name as defined in tailor.config
76
+ * @param args - Arguments forwarded to the workflow's main job
77
+ * @param options - Optional trigger options
73
78
  * @returns The execution ID of the triggered workflow
74
79
  */
75
- declare const triggerWorkflow: TailorWorkflowAPI["triggerWorkflow"];
80
+ declare function triggerWorkflow(workflowName: string, args?: any, options?: TriggerWorkflowOptions): Promise<string>;
76
81
  /**
77
82
  * See {@link TailorWorkflowAPI.triggerJobFunction}.
78
83
  * @param args - Forwarded to {@link TailorWorkflowAPI.triggerJobFunction}
@@ -92,5 +97,5 @@ declare const wait: TailorWorkflowAPI["wait"];
92
97
  */
93
98
  declare const resolve: TailorWorkflowAPI["resolve"];
94
99
  //#endregion
95
- export { triggerJobFunction as a, workflow_d_exports as c, resolve as i, TailorWorkflowAPI as n, triggerWorkflow as o, TriggerWorkflowOptions as r, wait as s, AuthInvoker as t };
96
- //# sourceMappingURL=workflow-BbKvGLQg.d.mts.map
100
+ export { resolve as a, wait as c, TriggerWorkflowOptions as i, workflow_d_exports as l, PlatformTriggerWorkflowOptions as n, triggerJobFunction as o, TailorWorkflowAPI as r, triggerWorkflow as s, Invoker as t };
101
+ //# sourceMappingURL=workflow-BVy4XWjS.d.mts.map
@@ -1,5 +1,5 @@
1
- import { h as TailorDBServiceInput } from "./types-DCUhgpyI.mjs";
2
- import { t as AuthConfig, x as BuiltinIdP } from "./types-DwDgacni.mjs";
1
+ import { h as TailorDBServiceInput } from "./types-CdcQh4Z2.mjs";
2
+ import { t as AuthConfig, x as BuiltinIdP } from "./types-BX4q6Mo6.mjs";
3
3
 
4
4
  //#region src/types/aigateway.generated.d.ts
5
5
  type AIGateway = {
@@ -668,4 +668,4 @@ type ConcurrencyPolicy = {
668
668
  };
669
669
  //#endregion
670
670
  export { AIGatewayConfig as C, IdPInput as S, AIGatewayInput as T, IdPExternalConfig as _, ExecutorServiceInput as a, IdPGqlOperations as b, ResolverServiceInput as c, StaticWebsiteConfig as d, StaticWebsiteDefinitionBrand as f, IdPConfig as g, SecretsDefinitionBrand as h, ExecutorServiceConfig as i, WorkflowServiceConfig as l, SecretsConfig as m, RetryPolicy as n, ResolverExternalConfig as o, StaticWebsiteInput as p, AppConfig as r, ResolverServiceConfig as s, ConcurrencyPolicy as t, WorkflowServiceInput as u, IdpDefinitionBrand as v, AIGatewayDefinitionBrand as w, IdPGqlOperationsInput as x, IdPEmailConfig as y };
671
- //# sourceMappingURL=workflow.generated-DtQwEo-x.d.mts.map
671
+ //# sourceMappingURL=workflow.generated-ClEjBYhm.d.mts.map
@@ -179,6 +179,7 @@ tailor-sdk executor jobs [options] <executor-name> [job-id]
179
179
  | `--attempts` | - | Show job attempts (only with job ID) (detail mode only) | No | `false` | - |
180
180
  | `--wait` | `-W` | Wait for job completion and downstream execution (workflow/function) if applicable (detail mode only) | No | `false` | - |
181
181
  | `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | - |
182
+ | `--timeout <TIMEOUT>` | `-t` | Maximum time to wait when using --wait (e.g., '30s', '5m') | No | `"5m"` | - |
182
183
  | `--order <ORDER>` | - | Sort order (asc or desc) | No | `"desc"` | - |
183
184
  | `--limit <LIMIT>` | - | Maximum number of jobs to list (0: unlimited, default: 50) (list mode only) | No | `50` | - |
184
185
  | `--logs` | `-l` | Display function execution logs after completion (requires --wait) | No | `false` | - |
@@ -283,6 +284,7 @@ tailor-sdk executor trigger [options] <executor-name>
283
284
  | `--header <HEADER>` | `-H` | Request header (format: 'Key: Value', can be specified multiple times) | No | - | - |
284
285
  | `--wait` | `-W` | Wait for job completion and downstream execution (workflow/function) if applicable | No | `false` | - |
285
286
  | `--interval <INTERVAL>` | `-i` | Polling interval when using --wait (e.g., '3s', '500ms', '1m') | No | `"3s"` | - |
287
+ | `--timeout <TIMEOUT>` | `-t` | Maximum time to wait when using --wait (e.g., '30s', '5m') | No | `"5m"` | - |
286
288
  | `--logs` | `-l` | Display function execution logs after completion (requires --wait) | No | `false` | - |
287
289
 
288
290
  <!-- politty:command:executor trigger:options:end -->
@@ -323,6 +325,57 @@ $ tailor-sdk executor trigger my-executor -W -l
323
325
 
324
326
  <!-- politty:command:executor trigger:examples:end -->
325
327
 
328
+ **Shell automation**
329
+
330
+ Trigger an executor and wait for the executor job plus any downstream workflow or
331
+ function execution:
332
+
333
+ ```bash
334
+ tailor-sdk executor trigger daily-workflow \
335
+ --wait \
336
+ --timeout 5m \
337
+ --interval 5s \
338
+ --json
339
+ ```
340
+
341
+ Wait for an existing job when another process already captured the job ID:
342
+
343
+ ```bash
344
+ tailor-sdk executor jobs daily-workflow "$job_id" \
345
+ --wait \
346
+ --timeout 5m \
347
+ --logs \
348
+ --json
349
+ ```
350
+
351
+ **Programmatic API**
352
+
353
+ Import your executor definition and pass it to the typed API:
354
+
355
+ ```ts
356
+ import { triggerExecutor, watchExecutorJob } from "@tailor-platform/sdk/cli";
357
+ import dailyWorkflow from "../executors/dailyWorkflow";
358
+
359
+ const { jobId } = await triggerExecutor({
360
+ executor: dailyWorkflow,
361
+ });
362
+
363
+ if (!jobId) {
364
+ throw new Error("Executor trigger did not return a job ID");
365
+ }
366
+
367
+ const result = await watchExecutorJob({
368
+ executor: dailyWorkflow,
369
+ jobId,
370
+ timeout: 5 * 60 * 1000,
371
+ interval: 5000,
372
+ });
373
+
374
+ if (result.timedOut) {
375
+ throw new Error(`Executor job ${result.job.id} timed out at ${result.job.status}`);
376
+ }
377
+ ```
378
+
326
379
  <!-- politty:command:executor trigger:notes:start -->
327
380
 
328
381
  **Notes**