@tailor-platform/sdk 2.4.0 → 2.5.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 (234) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/aigateway-DsWDjzk4.mjs +2 -0
  3. package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
  4. package/dist/application-DFOUovmN.mjs +1 -0
  5. package/dist/application-D_4vg1KR.mjs +192 -0
  6. package/dist/application-D_4vg1KR.mjs.map +1 -0
  7. package/dist/assert-WeXvmG4j.mjs +2 -0
  8. package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
  9. package/dist/authconnection-CynFBIv8.mjs +2 -0
  10. package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
  11. package/dist/brand-C8nMKhJC.mjs +2 -0
  12. package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
  13. package/dist/cli/commands/deploy/deploy.d.mts +2 -2
  14. package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
  15. package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
  16. package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
  17. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
  18. package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
  19. package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
  20. package/dist/cli/commands/executor/jobs.d.mts +1 -1
  21. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
  22. package/dist/cli/commands/show.d.mts +1 -1
  23. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -11
  24. package/dist/cli/commands/tailordb/migrate/generate.d.mts +4 -0
  25. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
  26. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
  27. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
  28. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
  29. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
  30. package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
  31. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
  32. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
  33. package/dist/cli/lib.d.mts +8 -4
  34. package/dist/cli/lib.mjs +1 -9
  35. package/dist/cli/lib.mjs.map +1 -1
  36. package/dist/cli/main.mjs +1170 -7754
  37. package/dist/cli/main.mjs.map +1 -1
  38. package/dist/cli/shared/seed-chunker.d.mts +5 -5
  39. package/dist/completion/zsh-worker.zsh +82 -9
  40. package/dist/configure/config/index.d.mts +1 -1
  41. package/dist/configure/config/types.d.mts +2 -2
  42. package/dist/configure/index.d.mts +48 -12
  43. package/dist/configure/index.mjs +1 -1267
  44. package/dist/configure/index.mjs.map +1 -1
  45. package/dist/configure/services/auth/types.d.mts +1 -1
  46. package/dist/configure/services/idp/types.d.mts +1 -1
  47. package/dist/configure/services/tailordb/schema.d.mts +4 -8
  48. package/dist/configure/services/tailordb/types.d.mts +1 -1
  49. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  50. package/dist/configure/services/workflow/job.d.mts +12 -2
  51. package/dist/configure/types/field.types.d.mts +1 -1
  52. package/dist/configure/types/permission-operand.types.d.mts +1 -1
  53. package/dist/context-D0QjfxzD.mjs +2 -0
  54. package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
  55. package/dist/crashreport-B-_HTKLr.mjs +42 -0
  56. package/dist/{crashreport-Q0pDAlrj.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
  57. package/dist/crashreport-BmsRIdpy.mjs +1 -0
  58. package/dist/errors-DSEXKRVD.mjs +2 -0
  59. package/dist/errors-DSEXKRVD.mjs.map +1 -0
  60. package/dist/file-COPYfju_.mjs +2 -0
  61. package/dist/file-COPYfju_.mjs.map +1 -0
  62. package/dist/globals-CMHSnj4w.mjs +2 -0
  63. package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
  64. package/dist/iconv-DlFMt2gW.mjs +2 -0
  65. package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
  66. package/dist/idp-G_ojPBB5.mjs +2 -0
  67. package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
  68. package/dist/interceptor-DQg3cR_9.mjs +2 -0
  69. package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
  70. package/dist/kysely/index.mjs +1 -32
  71. package/dist/kysely/index.mjs.map +1 -1
  72. package/dist/kysely-type-BTi3BMtL.mjs +43 -0
  73. package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
  74. package/dist/logger-BcGy-u7G.mjs +9 -0
  75. package/dist/{logger-D0bEznPv.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
  76. package/dist/logger-DP2BjQ93.mjs +2 -0
  77. package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
  78. package/dist/multiline-EyzjEwn9.mjs +3 -0
  79. package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
  80. package/dist/node-builtins-oBl7EbyV.mjs +2 -0
  81. package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
  82. package/dist/package-json-C690ceex.mjs +2 -0
  83. package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
  84. package/dist/package-json-CmqhDJ__.mjs +1 -0
  85. package/dist/parser/service/tailordb/type-source.d.mts +5 -5
  86. package/dist/parser/service/tailordb/types.d.mts +4 -4
  87. package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
  88. package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
  89. package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
  90. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  91. package/dist/plugin/builtin/file-utils/index.mjs +22 -104
  92. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  93. package/dist/plugin/builtin/kysely-type/index.d.mts +8 -1
  94. package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
  95. package/dist/plugin/builtin/seed/index.d.mts +5 -0
  96. package/dist/plugin/builtin/seed/index.mjs +1 -3
  97. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +0 -2
  98. package/dist/plugin/{get-generated-type.d.mts → get-generated-table.d.mts} +5 -5
  99. package/dist/plugin/index.d.mts +3 -2
  100. package/dist/plugin/index.mjs +1 -251
  101. package/dist/plugin/index.mjs.map +1 -1
  102. package/dist/plugin/types.d.mts +30 -23
  103. package/dist/plugin/with-context.d.mts +3 -3
  104. package/dist/register-ts-hook-Drnaproy.mjs +640 -0
  105. package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
  106. package/dist/registry-HlEaGvl5.mjs +2 -0
  107. package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
  108. package/dist/repl-editor-BG1aDOfH.mjs +2 -0
  109. package/dist/{repl-editor-F9LotMNx.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
  110. package/dist/runtime/aigateway.mjs +1 -3
  111. package/dist/runtime/authconnection.mjs +1 -3
  112. package/dist/runtime/context.mjs +1 -3
  113. package/dist/runtime/file.d.mts +21 -21
  114. package/dist/runtime/file.mjs +1 -3
  115. package/dist/runtime/globals.mjs +1 -1
  116. package/dist/runtime/iconv.mjs +1 -3
  117. package/dist/runtime/idp.mjs +1 -3
  118. package/dist/runtime/index.mjs +1 -11
  119. package/dist/runtime/logger.mjs +1 -3
  120. package/dist/runtime/secretmanager.mjs +1 -3
  121. package/dist/runtime/types.d.mts +1 -1
  122. package/dist/runtime/workflow.mjs +1 -3
  123. package/dist/schema-Ze_dI5VX.mjs +2 -0
  124. package/dist/schema-Ze_dI5VX.mjs.map +1 -0
  125. package/dist/secret-file-C9wp_FCX.mjs +2 -0
  126. package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
  127. package/dist/secretmanager-5olfnI1b.mjs +2 -0
  128. package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
  129. package/dist/secretmanager-vHQoXdQz.mjs +2 -0
  130. package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
  131. package/dist/seed/index.mjs +8 -244
  132. package/dist/seed/index.mjs.map +1 -1
  133. package/dist/seed-DwqRFdqP.mjs +207 -0
  134. package/dist/seed-DwqRFdqP.mjs.map +1 -0
  135. package/dist/service-BVe9u2Rt.mjs +7 -0
  136. package/dist/service-BVe9u2Rt.mjs.map +1 -0
  137. package/dist/service-CpZELSBa.mjs +1 -0
  138. package/dist/service-DlgaUO4V.mjs +2 -0
  139. package/dist/{service-LTfp03ZZ.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
  140. package/dist/service_pb-DGKCLuAs.mjs +2 -0
  141. package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
  142. package/dist/service_pb-_aeFE-Nv.mjs +1 -0
  143. package/dist/telemetry-Bklv9kQY.mjs +2 -0
  144. package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
  145. package/dist/telemetry-DXHP3VVi.mjs +1 -0
  146. package/dist/type-source--ZNcV8RJ.mjs +2 -0
  147. package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
  148. package/dist/types/executor.generated.d.mts +1 -1
  149. package/dist/user-agent-vdHYF3QL.mjs +2 -0
  150. package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
  151. package/dist/utils/test/index.mjs +1 -109
  152. package/dist/utils/test/index.mjs.map +1 -1
  153. package/dist/vitest/environment.mjs +1 -41
  154. package/dist/vitest/environment.mjs.map +1 -1
  155. package/dist/vitest/index.mjs +1 -1986
  156. package/dist/vitest/index.mjs.map +1 -1
  157. package/dist/vitest/mocks/file.d.mts +8 -8
  158. package/dist/vitest/setup.mjs +1 -140
  159. package/dist/vitest/setup.mjs.map +1 -1
  160. package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
  161. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
  162. package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
  163. package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
  164. package/dist/workflow-Cs9ISw6j.mjs +2 -0
  165. package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
  166. package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
  167. package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
  168. package/docs/cli/function.md +66 -6
  169. package/docs/cli/setup.md +24 -14
  170. package/docs/cli/tailordb.md +2 -0
  171. package/docs/cli-reference.md +9 -8
  172. package/docs/github-actions.md +10 -9
  173. package/docs/migration/v2.md +13 -1
  174. package/docs/migration/v3.md +82 -0
  175. package/docs/plugin/custom.md +130 -85
  176. package/docs/plugin/index.md +3 -3
  177. package/docs/services/tailordb-migration.md +21 -7
  178. package/docs/services/workflow.md +10 -9
  179. package/package.json +11 -11
  180. package/postinstall.mjs +1 -1
  181. package/dist/aigateway-DR4Kwuik.mjs +0 -9
  182. package/dist/application-C8a0UJ-z.mjs +0 -6071
  183. package/dist/application-C8a0UJ-z.mjs.map +0 -1
  184. package/dist/application-D4zOiLLa.mjs +0 -3
  185. package/dist/assert-DBxo8jPo.mjs +0 -9
  186. package/dist/authconnection-CZvi9ANm.mjs +0 -9
  187. package/dist/brand-Eo4pLXPJ.mjs +0 -36
  188. package/dist/context-DYQVYWqZ.mjs +0 -23
  189. package/dist/crashreport-Cd4TqfZq.mjs +0 -3
  190. package/dist/crashreport-Q0pDAlrj.mjs +0 -427
  191. package/dist/errors-Bxut5_Sy.mjs +0 -89
  192. package/dist/errors-Bxut5_Sy.mjs.map +0 -1
  193. package/dist/file-BUcmVIH2.mjs +0 -58
  194. package/dist/file-BUcmVIH2.mjs.map +0 -1
  195. package/dist/globals-B2nlxBrz.mjs +0 -126
  196. package/dist/iconv-QWaZh0TT.mjs +0 -38
  197. package/dist/idp-RA_swu-h.mjs +0 -82
  198. package/dist/interceptor-e33JtsC-.mjs +0 -33
  199. package/dist/logger-BtX0suGY.mjs +0 -48
  200. package/dist/logger-D0bEznPv.mjs +0 -362
  201. package/dist/multiline-sfHpTZZK.mjs +0 -38
  202. package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
  203. package/dist/package-json-8b0O9TlX.mjs +0 -17
  204. package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
  205. package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
  206. package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
  207. package/dist/plugin/builtin/seed/types.d.mts +0 -2
  208. package/dist/register-ts-hook-Vqjza10T.mjs +0 -25679
  209. package/dist/register-ts-hook-Vqjza10T.mjs.map +0 -1
  210. package/dist/registry-BIGVUrMB.mjs +0 -54
  211. package/dist/repl-editor-F9LotMNx.mjs +0 -252
  212. package/dist/schema-D4TC4BC3.mjs +0 -640
  213. package/dist/schema-D4TC4BC3.mjs.map +0 -1
  214. package/dist/secret-file-C3J4Gy8r.mjs +0 -64
  215. package/dist/secretmanager-CYlpffsz.mjs +0 -13
  216. package/dist/secretmanager-IY4UvinW.mjs +0 -131
  217. package/dist/seed-Cibjmtry.mjs +0 -489
  218. package/dist/seed-Cibjmtry.mjs.map +0 -1
  219. package/dist/service-2grcAOCJ.mjs +0 -898
  220. package/dist/service-2grcAOCJ.mjs.map +0 -1
  221. package/dist/service-CaBPNDIZ.mjs +0 -3
  222. package/dist/service-LTfp03ZZ.mjs +0 -133
  223. package/dist/service_pb-BEWj1pOV.mjs +0 -167
  224. package/dist/service_pb-BjlhvK9E.mjs +0 -3
  225. package/dist/telemetry-BRVdwh14.mjs +0 -84
  226. package/dist/telemetry-CkbkeJxl.mjs +0 -3
  227. package/dist/type-source-DH_LH20p.mjs +0 -13
  228. package/dist/type-source-DH_LH20p.mjs.map +0 -1
  229. package/dist/user-agent-Bgsszb5I.mjs +0 -28
  230. package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
  231. package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
  232. package/dist/wait-point-registry-TL99zotw.mjs +0 -47
  233. package/dist/workflow-Bamae_Yc.mjs +0 -34
  234. package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
@@ -1,1268 +1,2 @@
1
- import { i as parseInternal, n as mapAllowedValues, t as db } from "../schema-D4TC4BC3.mjs";
2
- import { t as brandValue } from "../brand-Eo4pLXPJ.mjs";
3
- import { a as registerJob, n as dispatchStartJob, r as dispatchStartWorkflow } from "../registry-BIGVUrMB.mjs";
4
- import { l as withWorkflowTestInvoker, n as attachWaitPointKey, r as createWaitPointInvoker, t as attachWaitPointInvoker } from "../wait-point-invoker-__oE88_P.mjs";
5
- import { r as registerWaitPoint } from "../wait-point-registry-TL99zotw.mjs";
6
-
7
- //#region src/configure/types/type.ts
8
- function createTailorField(type, options, fields, values, metadata) {
9
- const _metadata = metadata ? {
10
- ...metadata,
11
- ...metadata.allowedValues && { allowedValues: metadata.allowedValues.map((v) => ({ ...v })) },
12
- ...metadata.validate && { validate: metadata.validate.map((v) => Array.isArray(v) ? [...v] : v) }
13
- } : { required: true };
14
- if (!metadata) {
15
- if (options) {
16
- if (options.optional === true) _metadata.required = false;
17
- if (options.array === true) _metadata.array = true;
18
- }
19
- if (values) _metadata.allowedValues = mapAllowedValues(values);
20
- }
21
- function parseInternal$1(args) {
22
- return parseInternal({
23
- ...args,
24
- field
25
- });
26
- }
27
- /**
28
- * Clone the field and apply metadata updates to the clone.
29
- * The original instance is never mutated, so a field shared across places
30
- * cannot leak metadata between them.
31
- * @param metadataUpdates - Metadata properties to overwrite on the clone
32
- * @returns A new field with the updated metadata
33
- */
34
- function cloneWith(metadataUpdates) {
35
- const cloned = field.clone();
36
- Object.assign(cloned._metadata, metadataUpdates);
37
- return cloned;
38
- }
39
- const field = {
40
- type,
41
- fields: fields ?? {},
42
- _defined: void 0,
43
- _output: void 0,
44
- _metadata,
45
- get metadata() {
46
- return { ...this._metadata };
47
- },
48
- description(description) {
49
- return cloneWith({ description });
50
- },
51
- typeName(typeName) {
52
- return cloneWith({ typeName });
53
- },
54
- validate(...validateInputs) {
55
- return cloneWith({ validate: validateInputs });
56
- },
57
- parse(args) {
58
- return parseInternal$1({
59
- value: args.value,
60
- data: args.data,
61
- invoker: args.invoker,
62
- pathArray: []
63
- });
64
- },
65
- clone() {
66
- let clonedFields = fields;
67
- if (fields) {
68
- const cloned = {};
69
- for (const [key, nestedField] of Object.entries(fields)) cloned[key] = nestedField.clone();
70
- clonedFields = cloned;
71
- }
72
- return createTailorField(type, options, clonedFields, values, this._metadata);
73
- }
74
- };
75
- return field;
76
- }
77
- /**
78
- * Create a UUID field for resolver input/output.
79
- * @param options - Field configuration options
80
- * @returns A UUID field
81
- * @example t.uuid()
82
- */
83
- function uuid(options) {
84
- return createTailorField("uuid", options);
85
- }
86
- /**
87
- * Create a string field for resolver input/output.
88
- * @param options - Field configuration options
89
- * @returns A string field
90
- * @example t.string()
91
- * @example t.string({ optional: true })
92
- * @example t.string({ array: true })
93
- */
94
- function string(options) {
95
- return createTailorField("string", options);
96
- }
97
- /**
98
- * Create a boolean field for resolver input/output.
99
- * @param options - Field configuration options
100
- * @returns A boolean field
101
- * @example t.bool()
102
- */
103
- function bool(options) {
104
- return createTailorField("boolean", options);
105
- }
106
- /**
107
- * Create an integer field for resolver input/output.
108
- * @param options - Field configuration options
109
- * @returns An integer field
110
- * @example t.int()
111
- */
112
- function int(options) {
113
- return createTailorField("integer", options);
114
- }
115
- /**
116
- * Create a float field for resolver input/output.
117
- * @param options - Field configuration options
118
- * @returns A float field
119
- * @example t.float()
120
- */
121
- function float(options) {
122
- return createTailorField("float", options);
123
- }
124
- /**
125
- * Create a decimal field for resolver input/output (stored as string for precision).
126
- * @param options - Field configuration options
127
- * @returns A decimal field
128
- * @example t.decimal()
129
- * @example t.decimal({ optional: true })
130
- */
131
- function decimal(options) {
132
- return createTailorField("decimal", options);
133
- }
134
- /**
135
- * Create a date field for resolver input/output.
136
- * @param options - Field configuration options
137
- * @returns A date field
138
- * @example t.date()
139
- */
140
- function date(options) {
141
- return createTailorField("date", options);
142
- }
143
- /**
144
- * Create a datetime field for resolver input/output.
145
- * @param options - Field configuration options
146
- * @returns A datetime field
147
- * @example t.datetime()
148
- */
149
- function datetime(options) {
150
- return createTailorField("datetime", options);
151
- }
152
- /**
153
- * Create a time field for resolver input/output.
154
- * @param options - Field configuration options
155
- * @returns A time field
156
- * @example t.time()
157
- */
158
- function time(options) {
159
- return createTailorField("time", options);
160
- }
161
- /**
162
- * Create an enum field for resolver input/output.
163
- * @param values - Array of allowed string values
164
- * @param options - Field configuration options
165
- * @returns An enum field
166
- * @example t.enum(["active", "inactive"])
167
- */
168
- function _enum(values, options) {
169
- return createTailorField("enum", options, void 0, values);
170
- }
171
- /**
172
- * Create a nested object field for resolver input/output.
173
- * @param fields - Record of field definitions
174
- * @param options - Field options (optional, array)
175
- * @returns A nested object field
176
- * @example
177
- * // Single object:
178
- * output: t.object({ name: t.string(), email: t.string() })
179
- * @example
180
- * // Array of objects:
181
- * items: t.object({ name: t.string() }, { array: true })
182
- */
183
- function object(fields, options) {
184
- return createTailorField("nested", options, fields);
185
- }
186
- const t$1 = {
187
- uuid,
188
- string,
189
- bool,
190
- int,
191
- float,
192
- decimal,
193
- date,
194
- datetime,
195
- time,
196
- enum: _enum,
197
- object
198
- };
199
-
200
- //#endregion
201
- //#region src/configure/services/auth/index.ts
202
- /* @__NO_SIDE_EFFECTS__ */
203
- function defineAuth(name, config) {
204
- return {
205
- ...config,
206
- name
207
- };
208
- }
209
-
210
- //#endregion
211
- //#region src/configure/services/tailordb/permission.ts
212
- /**
213
- * Grants full record-level access without any conditions.
214
- *
215
- * Unsafe and intended only for local development, prototyping, or tests.
216
- * Do not use this in production environments, as it effectively disables
217
- * authorization checks.
218
- */
219
- const unsafeAllowAllTypePermission = {
220
- create: [{
221
- conditions: [],
222
- permit: true
223
- }],
224
- read: [{
225
- conditions: [],
226
- permit: true
227
- }],
228
- update: [{
229
- conditions: [],
230
- permit: true
231
- }],
232
- delete: [{
233
- conditions: [],
234
- permit: true
235
- }]
236
- };
237
- /**
238
- * Grants full GraphQL access (all actions) without any conditions.
239
- *
240
- * Unsafe and intended only for local development, prototyping, or tests.
241
- * Do not use this in production environments, as it effectively disables
242
- * authorization checks.
243
- */
244
- const unsafeAllowAllGqlPermission = [{
245
- conditions: [],
246
- actions: "all",
247
- permit: true
248
- }];
249
-
250
- //#endregion
251
- //#region src/configure/services/resolver/resolver.ts
252
- /**
253
- * Create a resolver definition for the Tailor SDK.
254
- *
255
- * The `body` function receives a context with `input` (typed from `config.input`),
256
- * `caller`, `invoker` (reflects configured machine-user delegation), and `env`.
257
- * The return value of `body` must match the `output` type.
258
- *
259
- * `output` accepts either a single TailorField (e.g. `t.string()`) or a
260
- * Record of fields (e.g. `{ name: t.string(), age: t.int() }`).
261
- *
262
- * `publishEvents` enables publishing execution events for this resolver.
263
- * If not specified, this is automatically set to true when an executor uses this resolver
264
- * with `resolverExecutedTrigger`. If explicitly set to false while an executor uses this
265
- * resolver, an error will be thrown during apply.
266
- *
267
- * `permission` declares the resolver's access requirement, checked against `context.user` (the
268
- * original caller, unaffected by `authInvoker`) before `body` runs. Omitted (default):
269
- * unchanged, anonymous callers can reach the resolver. `"allowAnonymous"`: explicitly documents
270
- * that anonymous callers are allowed. An array of `{ conditions, permit }` policies (in the same
271
- * style as TailorDB's `.permission()`) rejects non-matching callers: at least one `permit: true`
272
- * policy is required (denied unless it matches), and a matching `permit: false` policy always
273
- * overrides that grant.
274
- * @template Input
275
- * @template Output
276
- * @param config - Resolver configuration
277
- * @returns Normalized resolver configuration
278
- * @example
279
- * import { createResolver, t } from "@tailor-platform/sdk";
280
- *
281
- * export default createResolver({
282
- * name: "getUser",
283
- * operation: "query",
284
- * permission: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
285
- * input: {
286
- * id: t.string(),
287
- * },
288
- * body: async ({ input, caller }) => {
289
- * const db = getDB("tailordb");
290
- * const result = await db.selectFrom("User").selectAll().where("id", "=", input.id).executeTakeFirst();
291
- * return { name: result?.name ?? "", email: result?.email ?? "" };
292
- * },
293
- * output: t.object({
294
- * name: t.string(),
295
- * email: t.string(),
296
- * }),
297
- * });
298
- */
299
- /* @__NO_SIDE_EFFECTS__ */
300
- function createResolver(config) {
301
- const isTailorField = (obj) => typeof obj === "object" && obj !== null && "type" in obj && typeof obj.type === "string";
302
- const normalizedOutput = isTailorField(config.output) ? config.output : t$1.object(config.output);
303
- return brandValue({
304
- ...config,
305
- output: normalizedOutput
306
- }, "resolver");
307
- }
308
-
309
- //#endregion
310
- //#region src/configure/services/executor/executor.ts
311
- /* @__NO_SIDE_EFFECTS__ */
312
- function createExecutor(config) {
313
- return brandValue(config, "executor");
314
- }
315
-
316
- //#endregion
317
- //#region src/configure/services/executor/trigger/event.ts
318
- const recordEventMap = {
319
- created: "tailordb.type_record.created",
320
- updated: "tailordb.type_record.updated",
321
- deleted: "tailordb.type_record.deleted"
322
- };
323
- /**
324
- * Create a trigger that fires when a TailorDB record is created.
325
- * @template T
326
- * @param options - Trigger options
327
- * @returns Record created trigger
328
- */
329
- function recordCreatedTrigger(options) {
330
- const { type, condition } = options;
331
- return {
332
- kind: "tailordb",
333
- events: ["tailordb.type_record.created"],
334
- typeName: type.name,
335
- condition,
336
- __args: {}
337
- };
338
- }
339
- /**
340
- * Create a trigger that fires when a TailorDB record is updated.
341
- * @template T
342
- * @param options - Trigger options
343
- * @returns Record updated trigger
344
- */
345
- function recordUpdatedTrigger(options) {
346
- const { type, condition } = options;
347
- return {
348
- kind: "tailordb",
349
- events: ["tailordb.type_record.updated"],
350
- typeName: type.name,
351
- condition,
352
- __args: {}
353
- };
354
- }
355
- /**
356
- * Create a trigger that fires when a TailorDB record is deleted.
357
- * @template T
358
- * @param options - Trigger options
359
- * @returns Record deleted trigger
360
- */
361
- function recordDeletedTrigger(options) {
362
- const { type, condition } = options;
363
- return {
364
- kind: "tailordb",
365
- events: ["tailordb.type_record.deleted"],
366
- typeName: type.name,
367
- condition,
368
- __args: {}
369
- };
370
- }
371
- /**
372
- * Create a trigger that fires on multiple TailorDB record event types.
373
- * @template T
374
- * @template K
375
- * @param options - Trigger options with events array
376
- * @returns TailorDB record trigger
377
- */
378
- function recordTrigger(options) {
379
- const { type, events, condition } = options;
380
- return {
381
- kind: "tailordb",
382
- events: events.map((k) => recordEventMap[k]),
383
- typeName: type.name,
384
- condition,
385
- __args: {}
386
- };
387
- }
388
- /**
389
- * Create a trigger that fires when a resolver is executed.
390
- * @template R
391
- * @param options - Trigger options
392
- * @returns Resolver executed trigger
393
- */
394
- function resolverExecutedTrigger(options) {
395
- const { resolver, condition } = options;
396
- return {
397
- kind: "resolverExecuted",
398
- resolverName: resolver.name,
399
- condition,
400
- __args: {}
401
- };
402
- }
403
- const idpUserEventMap = {
404
- created: "idp.user.created",
405
- updated: "idp.user.updated",
406
- deleted: "idp.user.deleted"
407
- };
408
- /**
409
- * Create a trigger that fires when an IdP user is created.
410
- * @param options - Trigger options
411
- * @param options.idp - IdP namespace name to subscribe to
412
- * @returns IdP user created trigger
413
- */
414
- function idpUserCreatedTrigger(options) {
415
- return {
416
- kind: "idpUser",
417
- events: ["idp.user.created"],
418
- ...options?.idp != null ? { idp: options.idp } : {},
419
- __args: {}
420
- };
421
- }
422
- /**
423
- * Create a trigger that fires when an IdP user is updated.
424
- * @param options - Trigger options
425
- * @param options.idp - IdP namespace name to subscribe to
426
- * @returns IdP user updated trigger
427
- */
428
- function idpUserUpdatedTrigger(options) {
429
- return {
430
- kind: "idpUser",
431
- events: ["idp.user.updated"],
432
- ...options?.idp != null ? { idp: options.idp } : {},
433
- __args: {}
434
- };
435
- }
436
- /**
437
- * Create a trigger that fires when an IdP user is deleted.
438
- * @param options - Trigger options
439
- * @param options.idp - IdP namespace name to subscribe to
440
- * @returns IdP user deleted trigger
441
- */
442
- function idpUserDeletedTrigger(options) {
443
- return {
444
- kind: "idpUser",
445
- events: ["idp.user.deleted"],
446
- ...options?.idp != null ? { idp: options.idp } : {},
447
- __args: {}
448
- };
449
- }
450
- /**
451
- * Create a trigger that fires on multiple IdP user event types.
452
- * @template K
453
- * @param options - Trigger options with events array
454
- * @param options.events - IdP user event kinds to subscribe to
455
- * @param options.idp - IdP namespace name to subscribe to
456
- * @returns IdP user trigger
457
- */
458
- function idpUserTrigger(options) {
459
- const { events, idp } = options;
460
- return {
461
- kind: "idpUser",
462
- events: events.map((k) => idpUserEventMap[k]),
463
- ...idp != null ? { idp } : {},
464
- __args: {}
465
- };
466
- }
467
- const authAccessTokenEventMap = {
468
- issued: "auth.access_token.issued",
469
- refreshed: "auth.access_token.refreshed",
470
- revoked: "auth.access_token.revoked"
471
- };
472
- /**
473
- * Create a trigger that fires when an access token is issued.
474
- * @returns Auth access token issued trigger
475
- */
476
- function authAccessTokenIssuedTrigger() {
477
- return {
478
- kind: "authAccessToken",
479
- events: ["auth.access_token.issued"],
480
- __args: {}
481
- };
482
- }
483
- /**
484
- * Create a trigger that fires when an access token is refreshed.
485
- * @returns Auth access token refreshed trigger
486
- */
487
- function authAccessTokenRefreshedTrigger() {
488
- return {
489
- kind: "authAccessToken",
490
- events: ["auth.access_token.refreshed"],
491
- __args: {}
492
- };
493
- }
494
- /**
495
- * Create a trigger that fires when an access token is revoked.
496
- * @returns Auth access token revoked trigger
497
- */
498
- function authAccessTokenRevokedTrigger() {
499
- return {
500
- kind: "authAccessToken",
501
- events: ["auth.access_token.revoked"],
502
- __args: {}
503
- };
504
- }
505
- /**
506
- * Create a trigger that fires on multiple auth access token event types.
507
- * @template K
508
- * @param options - Trigger options with events array
509
- * @returns Auth access token trigger
510
- */
511
- function authAccessTokenTrigger(options) {
512
- const { events } = options;
513
- return {
514
- kind: "authAccessToken",
515
- events: events.map((k) => authAccessTokenEventMap[k]),
516
- __args: {}
517
- };
518
- }
519
- const workflowExecutionEventMap = {
520
- started: "workflow.workflow_execution.started",
521
- completed: "workflow.workflow_execution.completed",
522
- retried: "workflow.workflow_execution.retried",
523
- resumed: "workflow.workflow_execution.resumed",
524
- wait_started: "workflow.workflow_execution.wait_started",
525
- wait_resolved: "workflow.workflow_execution.wait_resolved"
526
- };
527
- function workflowExecutionTriggerConfig(events, options) {
528
- return {
529
- kind: "workflowExecution",
530
- events,
531
- workflowName: options.workflow.name,
532
- condition: options.condition,
533
- __args: {}
534
- };
535
- }
536
- /**
537
- * Create a trigger that fires when a workflow execution starts running.
538
- * @param options - Trigger options
539
- * @param options.workflow - Workflow to subscribe to
540
- * @param options.condition - Condition function to filter events
541
- * @returns Workflow execution started trigger
542
- */
543
- function workflowExecutionStartedTrigger(options) {
544
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.started"], options);
545
- }
546
- /**
547
- * Create a trigger that fires when a workflow execution succeeds or fails.
548
- * @param options - Trigger options
549
- * @param options.workflow - Workflow to subscribe to
550
- * @param options.condition - Condition function to filter events
551
- * @returns Workflow execution completed trigger
552
- */
553
- function workflowExecutionCompletedTrigger(options) {
554
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.completed"], options);
555
- }
556
- /**
557
- * Create a trigger that fires when a workflow execution is retried by its retry policy.
558
- * @param options - Trigger options
559
- * @param options.workflow - Workflow to subscribe to
560
- * @param options.condition - Condition function to filter events
561
- * @returns Workflow execution retried trigger
562
- */
563
- function workflowExecutionRetriedTrigger(options) {
564
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.retried"], options);
565
- }
566
- /**
567
- * Create a trigger that fires when a failed workflow execution is manually resumed.
568
- * @param options - Trigger options
569
- * @param options.workflow - Workflow to subscribe to
570
- * @param options.condition - Condition function to filter events
571
- * @returns Workflow execution resumed trigger
572
- */
573
- function workflowExecutionResumedTrigger(options) {
574
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.resumed"], options);
575
- }
576
- /**
577
- * Create a trigger that fires when a workflow execution starts waiting on a wait point.
578
- * @param options - Trigger options
579
- * @param options.workflow - Workflow to subscribe to
580
- * @param options.condition - Condition function to filter events
581
- * @returns Workflow execution wait started trigger
582
- */
583
- function workflowExecutionWaitStartedTrigger(options) {
584
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.wait_started"], options);
585
- }
586
- /**
587
- * Create a trigger that fires when a waiting workflow execution is released.
588
- * @param options - Trigger options
589
- * @param options.workflow - Workflow to subscribe to
590
- * @param options.condition - Condition function to filter events
591
- * @returns Workflow execution wait resolved trigger
592
- */
593
- function workflowExecutionWaitResolvedTrigger(options) {
594
- return workflowExecutionTriggerConfig(["workflow.workflow_execution.wait_resolved"], options);
595
- }
596
- /**
597
- * Create a trigger that fires on multiple workflow execution event types.
598
- * @template K
599
- * @param options - Trigger options with events array
600
- * @param options.events - Workflow execution event kinds to subscribe to
601
- * @param options.workflow - Workflow to subscribe to
602
- * @param options.condition - Condition function to filter events
603
- * @returns Workflow execution trigger
604
- */
605
- function workflowExecutionTrigger(options) {
606
- const { events, workflow, condition } = options;
607
- return workflowExecutionTriggerConfig(events.map((k) => workflowExecutionEventMap[k]), {
608
- workflow,
609
- condition
610
- });
611
- }
612
- const workflowJobExecutionEventMap = {
613
- started: "workflow.workflow_execution.job_execution.started",
614
- completed: "workflow.workflow_execution.job_execution.completed",
615
- wait_started: "workflow.workflow_execution.job_execution.wait_started",
616
- wait_resolved: "workflow.workflow_execution.job_execution.wait_resolved"
617
- };
618
- function workflowJobExecutionTriggerConfig(events, options) {
619
- return {
620
- kind: "workflowJobExecution",
621
- events,
622
- workflowName: options.workflow.name,
623
- condition: options.condition,
624
- __args: {}
625
- };
626
- }
627
- /**
628
- * Create a trigger that fires when a job inside a workflow starts running.
629
- * @param options - Trigger options
630
- * @param options.workflow - Workflow whose job executions to subscribe to
631
- * @param options.condition - Condition function to filter events
632
- * @returns Workflow job execution started trigger
633
- */
634
- function workflowJobExecutionStartedTrigger(options) {
635
- return workflowJobExecutionTriggerConfig(["workflow.workflow_execution.job_execution.started"], options);
636
- }
637
- /**
638
- * Create a trigger that fires when a job inside a workflow succeeds or fails.
639
- *
640
- * A job released from a wait point reports `wait_resolved` instead of
641
- * `completed`; subscribe to both to observe every way a job can end.
642
- * @param options - Trigger options
643
- * @param options.workflow - Workflow whose job executions to subscribe to
644
- * @param options.condition - Condition function to filter events
645
- * @returns Workflow job execution completed trigger
646
- */
647
- function workflowJobExecutionCompletedTrigger(options) {
648
- return workflowJobExecutionTriggerConfig(["workflow.workflow_execution.job_execution.completed"], options);
649
- }
650
- /**
651
- * Create a trigger that fires when a job inside a workflow starts waiting on a wait point.
652
- * @param options - Trigger options
653
- * @param options.workflow - Workflow whose job executions to subscribe to
654
- * @param options.condition - Condition function to filter events
655
- * @returns Workflow job execution wait started trigger
656
- */
657
- function workflowJobExecutionWaitStartedTrigger(options) {
658
- return workflowJobExecutionTriggerConfig(["workflow.workflow_execution.job_execution.wait_started"], options);
659
- }
660
- /**
661
- * Create a trigger that fires when a waiting job inside a workflow is released.
662
- * @param options - Trigger options
663
- * @param options.workflow - Workflow whose job executions to subscribe to
664
- * @param options.condition - Condition function to filter events
665
- * @returns Workflow job execution wait resolved trigger
666
- */
667
- function workflowJobExecutionWaitResolvedTrigger(options) {
668
- return workflowJobExecutionTriggerConfig(["workflow.workflow_execution.job_execution.wait_resolved"], options);
669
- }
670
- /**
671
- * Create a trigger that fires on multiple workflow job execution event types.
672
- * @template K
673
- * @param options - Trigger options with events array
674
- * @param options.events - Workflow job execution event kinds to subscribe to
675
- * @param options.workflow - Workflow whose job executions to subscribe to
676
- * @param options.condition - Condition function to filter events
677
- * @returns Workflow job execution trigger
678
- */
679
- function workflowJobExecutionTrigger(options) {
680
- const { events, workflow, condition } = options;
681
- return workflowJobExecutionTriggerConfig(events.map((k) => workflowJobExecutionEventMap[k]), {
682
- workflow,
683
- condition
684
- });
685
- }
686
-
687
- //#endregion
688
- //#region src/configure/services/executor/trigger/schedule.ts
689
- /**
690
- * Create a schedule-based trigger using a CRON expression and optional timezone.
691
- * @template T
692
- * @param options - Schedule options
693
- * @returns Schedule trigger
694
- */
695
- function scheduleTrigger(options) {
696
- const { cron, timezone } = options;
697
- return {
698
- kind: "schedule",
699
- cron,
700
- timezone,
701
- __args: {}
702
- };
703
- }
704
-
705
- //#endregion
706
- //#region src/configure/services/executor/trigger/webhook.ts
707
- /**
708
- * Create a trigger for incoming webhook requests.
709
- * @template T
710
- * @param options - Optional trigger options including response configuration
711
- * @returns Incoming webhook trigger
712
- */
713
- function incomingWebhookTrigger(options) {
714
- const response = typeof options?.response === "function" ? { body: options.response } : options?.response;
715
- return {
716
- kind: "incomingWebhook",
717
- ...response ? { response } : {},
718
- __args: {}
719
- };
720
- }
721
-
722
- //#endregion
723
- //#region src/configure/services/workflow/execution-policy.ts
724
- const EXECUTION_POLICY_EXACT_KEY_REGEX = /^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9]$/;
725
- function createExecutionPolicyInstance(initialName, initialKey, concurrencyPolicy, matchType, separator, allowNameSetter, allowKeySetter) {
726
- const isPrefix = matchType === "prefix";
727
- const raw = {
728
- name: initialName,
729
- key: initialKey,
730
- matchType,
731
- ...concurrencyPolicy && { concurrencyPolicy },
732
- ...isPrefix && { keyFor: (suffix) => {
733
- const key = `${raw.key}${separator}${suffix}`;
734
- if (!EXECUTION_POLICY_EXACT_KEY_REGEX.test(key)) throw new Error(`Invalid execution policy key "${key}" built by keyFor("${suffix}"): must match [a-z0-9_:.-] (2-64 chars; must start and end with [a-z0-9]).`);
735
- return key;
736
- } }
737
- };
738
- return {
739
- instance: brandValue(raw, "execution-policy"),
740
- setName: allowNameSetter ? (n) => {
741
- raw.name = n;
742
- } : void 0,
743
- setKey: allowKeySetter ? (k) => {
744
- raw.key = k;
745
- } : void 0
746
- };
747
- }
748
- /**
749
- * Define a single workflow job function execution policy.
750
- *
751
- * Use this when declaring a policy outside the
752
- * {@link defineWorkflowExecutionPolicies} builder — for example, when the
753
- * runtime key prefix needs to differ from the corresponding workspace-unique
754
- * name.
755
- *
756
- * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
757
- * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
758
- * @param name - Workspace-unique name. Must match `^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`.
759
- * @param def - Optional overrides for `key` (defaults to `name`), `matchType`, `separator` (the `keyFor` join character, defaults to `.`), and concurrency
760
- * @returns An execution policy instance
761
- * @example
762
- * export const perTenant = defineWorkflowExecutionPolicy("tenant-api", {
763
- * matchType: "prefix",
764
- * concurrencyPolicy: { maxConcurrentExecutions: 3 },
765
- * });
766
- *
767
- * perTenant.keyFor(tenantId); // "tenant-api.<tenantId>"
768
- */
769
- /* @__NO_SIDE_EFFECTS__ */
770
- function defineWorkflowExecutionPolicy(name, def) {
771
- return createExecutionPolicyInstance(name, def?.key ?? name, def?.concurrencyPolicy, def?.matchType ?? "exact", def?.separator ?? ".", false, false).instance;
772
- }
773
- /**
774
- * Define a group of workflow job function execution policies. Property names
775
- * become the workspace-unique `name` and default `key` verbatim, matching the
776
- * mental model of {@link createWaitPoints}. Provide `name` / `key` explicitly
777
- * to override the property-name default (for example, when the property name
778
- * is not valid for the execution policy grammar or when the runtime key
779
- * prefix needs to differ).
780
- *
781
- * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
782
- * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
783
- * `matchType` can be combined with an explicit `key`, or left to apply to
784
- * the property-name-derived prefix.
785
- *
786
- * The return type mirrors the builder's return type so JSDoc on each property
787
- * is preserved in IDE autocompletion.
788
- * @param builder - Callback that receives a `define` factory and returns a record of policies
789
- * @param options - Group-wide options; `separator` overrides the `.` `keyFor` uses to join the prefix and suffix for every prefix policy in the group
790
- * @returns The same object returned by the builder (with `name` / `key` resolved on each instance)
791
- * @example
792
- * export const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
793
- * premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
794
- * "tenant-api": define({
795
- * matchType: "prefix",
796
- * concurrencyPolicy: { maxConcurrentExecutions: 3 },
797
- * }),
798
- * }));
799
- *
800
- * // In a workflow job function:
801
- * await tailor.workflow.execJobFunction("worker", args, {
802
- * executionPolicyKey: executionPolicies.premium.key,
803
- * });
804
- * await tailor.workflow.execJobFunction("worker", args, {
805
- * executionPolicyKey: executionPolicies["tenant-api"].keyFor(input.tenantId),
806
- * });
807
- */
808
- /* @__NO_SIDE_EFFECTS__ */
809
- function defineWorkflowExecutionPolicies(builder, options) {
810
- const separator = options?.separator ?? ".";
811
- const nameSetters = /* @__PURE__ */ new Map();
812
- const keySetters = /* @__PURE__ */ new Map();
813
- const define = (def) => {
814
- const explicitName = def?.name;
815
- const explicitKey = def?.key;
816
- const { instance, setName, setKey } = createExecutionPolicyInstance(explicitName ?? "__pending__", explicitKey ?? explicitName ?? "__pending__", def?.concurrencyPolicy, def?.matchType ?? "exact", separator, explicitName === void 0, explicitKey === void 0 && explicitName === void 0);
817
- if (setName) nameSetters.set(instance, setName);
818
- if (setKey) keySetters.set(instance, setKey);
819
- return instance;
820
- };
821
- const result = builder(define);
822
- for (const propName of Object.keys(result)) {
823
- const instance = result[propName];
824
- nameSetters.get(instance)?.(propName);
825
- keySetters.get(instance)?.(propName);
826
- }
827
- return result;
828
- }
829
-
830
- //#endregion
831
- //#region src/configure/services/workflow/job.ts
832
- /**
833
- * Create a workflow job definition.
834
- *
835
- * All jobs must be named exports from the workflow file.
836
- * Job names must be unique across the entire project.
837
- *
838
- * Input and output must be JsonValue-compatible (primitives, plain objects, arrays).
839
- * Functions and objects with a `toJSON` method are rejected at the type level;
840
- * class instances exposing methods are rejected via the property walk.
841
- * @param config - Job configuration with name and body function.
842
- * @param config.name - Unique job name across the project.
843
- * @param config.body - Function that processes the job input.
844
- * @returns A WorkflowJob that can be started from other jobs.
845
- * @example
846
- * // Simple job with async body:
847
- * export const fetchData = createWorkflowJob({
848
- * name: "fetch-data",
849
- * body: async (input: { id: string }) => {
850
- * const db = getDB("tailordb");
851
- * return await db.selectFrom("Table").selectAll().where("id", "=", input.id).executeTakeFirst();
852
- * },
853
- * });
854
- * @example
855
- * // Orchestrator job that fans out to other jobs.
856
- * export const orchestrate = createWorkflowJob({
857
- * name: "orchestrate",
858
- * body: (input: { orderId: string }) => {
859
- * const inventory = checkInventory.start({ orderId: input.orderId });
860
- * const payment = processPayment.start({ orderId: input.orderId });
861
- * return { inventory, payment };
862
- * },
863
- * });
864
- */
865
- function createWorkflowJob(config) {
866
- const userBody = config.body;
867
- const body = process.env.__TAILOR_PLATFORM_BUNDLE ? userBody : (input, context) => withWorkflowTestInvoker(context.invoker, () => userBody(input, context));
868
- if (!process.env.__TAILOR_PLATFORM_BUNDLE) registerJob(config.name, body);
869
- const start = process.env.__TAILOR_PLATFORM_BUNDLE ? () => {
870
- throw new Error("This workflow job's .start() is rewritten at build time and is unavailable in the bundle");
871
- } : function start(args, options) {
872
- return arguments.length >= 2 ? dispatchStartJob(config.name, args, options) : dispatchStartJob(config.name, args);
873
- };
874
- return brandValue({
875
- name: config.name,
876
- start,
877
- body,
878
- ...config.publishEvents !== void 0 ? { publishEvents: config.publishEvents } : {}
879
- }, "workflow-job");
880
- }
881
-
882
- //#endregion
883
- //#region src/configure/services/workflow/wait-point.ts
884
- const KEY_REGEX = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
885
- const PARAM_VALUE_REGEX = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
886
- const MAX_KEY_LENGTH = 63;
887
- const KEY_GRAMMAR = "[a-z0-9-] (3-63 characters; must start and end with [a-z0-9])";
888
- function parseKey(key) {
889
- const segments = key.split("-");
890
- return {
891
- segments,
892
- paramNames: segments.filter((s) => s.startsWith("$") && s.length > 1).map((s) => s.slice(1))
893
- };
894
- }
895
- function composeKey(key, parsed, params) {
896
- const composed = parsed.segments.map((segment) => {
897
- if (!segment.startsWith("$") || segment.length === 1) return segment;
898
- const name = segment.slice(1);
899
- const value = params[name];
900
- if (typeof value !== "string") throw new Error(`Wait point "${key}" needs a string for parameter "${name}" but received ${value === void 0 ? "undefined" : typeof value}.`);
901
- if (!PARAM_VALUE_REGEX.test(value)) throw new Error(`Wait point "${key}" cannot use ${JSON.stringify(value)} for parameter "${name}": values may only contain [a-z0-9-] and cannot be empty or start or end with "-".`);
902
- return value;
903
- }).join("-");
904
- if (composed.length > MAX_KEY_LENGTH) throw new Error(`Wait point key "${composed}" built from "${key}" is ${composed.length} characters; the limit is ${MAX_KEY_LENGTH}.`);
905
- if (!KEY_REGEX.test(composed)) throw new Error(`Wait point key "${composed}" built from "${key}" must match ${KEY_GRAMMAR}.`);
906
- return composed;
907
- }
908
- function createBoundWaitPoint(invoker, readKey) {
909
- return {
910
- wait(payload) {
911
- return Promise.resolve(invoker.wait(readKey(), payload));
912
- },
913
- async resolve(executionId, callback) {
914
- await invoker.resolve(readKey(), executionId, callback);
915
- }
916
- };
917
- }
918
- /**
919
- * Create a WaitPointInstance that delegates to the platform runtime.
920
- * Use `mockWorkflow` from `@tailor-platform/sdk/vitest` to mock
921
- * `globalThis.tailor.workflow.wait/resolve` in tests.
922
- * @param initialKey - Initial key (can be updated via the returned setter)
923
- * @returns The instance and a setter to update the key after construction
924
- */
925
- function createWaitPointInstance(initialKey) {
926
- let key = initialKey;
927
- const invoker = createWaitPointInvoker();
928
- const instance = brandValue(createBoundWaitPoint(invoker, () => key), "wait-point");
929
- attachWaitPointInvoker(instance, invoker);
930
- return {
931
- instance,
932
- setKey: (k) => {
933
- key = k;
934
- }
935
- };
936
- }
937
- function createParameterizedWaitPointInstance(key, parsed, declaredBy) {
938
- const invoker = createWaitPointInvoker();
939
- const unbound = () => {
940
- throw new Error(declaredBy === "define" ? `Wait point key "${key}" has $params, so it identifies no single suspension on its own. Bind them first: waitPoint.with({ ... }).wait(...).` : `Wait point key "${key}" has $params, which createWaitPoint cannot type. Declare it through createWaitPoints instead: createWaitPoints((define) => ({ myWaitPoint: define.for("${key}")<Payload, Result>() })).`);
941
- };
942
- const instance = brandValue({
943
- with(params) {
944
- const composed = composeKey(key, parsed, params);
945
- return attachWaitPointKey(createBoundWaitPoint(invoker, () => composed), composed);
946
- },
947
- wait: unbound,
948
- resolve: unbound
949
- }, "wait-point");
950
- attachWaitPointInvoker(instance, invoker);
951
- return instance;
952
- }
953
- function createKeyedWaitPoint(key, declaredBy) {
954
- registerWaitPoint({
955
- key,
956
- declaredBy
957
- });
958
- const parsed = parseKey(key);
959
- return parsed.paramNames.length > 0 ? createParameterizedWaitPointInstance(key, parsed, declaredBy) : createWaitPointInstance(key).instance;
960
- }
961
- /**
962
- * Create a single typed wait point with a fixed key.
963
- *
964
- * The key must match `[a-z0-9-]` (3-63 characters, starting and ending with
965
- * `[a-z0-9]`), which `deploy` reports on. For a key with `$params`, use
966
- * {@link createWaitPoints}: binding params needs the key inferred as a literal
967
- * type, which only its `define` offers.
968
- *
969
- * `Payload` and `Result` must be JsonValue-compatible.
970
- * Functions and objects with a `toJSON` method are rejected at the type level;
971
- * class instances exposing methods are rejected via the property walk.
972
- * @param key - The wait point key used to match wait and resolve calls
973
- * @returns A WaitPointInstance with typed `.wait()` and `.resolve()` methods
974
- * @example
975
- * export const approval = createWaitPoint<{ message: string }, { approved: boolean }>("approval");
976
- *
977
- * await approval.wait({ message: "Please approve" });
978
- */
979
- function createWaitPoint(key) {
980
- return createKeyedWaitPoint(key, "createWaitPoint");
981
- }
982
- /**
983
- * Create a group of typed wait points for human-in-the-loop workflows.
984
- * Property names become the wait point keys, so they must match
985
- * `[a-z0-9-]`, which `deploy` reports on — pass an explicit key to `define`
986
- * when they do not.
987
- *
988
- * The return type is the same as the builder's return type, so JSDoc on each
989
- * property is preserved and visible in IDE autocompletion.
990
- *
991
- * `Payload` and `Result` must be JsonValue-compatible.
992
- * Functions and objects with a `toJSON` method are rejected at the type level;
993
- * class instances exposing methods are rejected via the property walk.
994
- * @param builder - Callback that receives a `define` factory and returns an object of wait points
995
- * @returns The same object returned by the builder (with correct keys set on each instance)
996
- * @example
997
- * export const waitPoints = createWaitPoints(define => ({
998
- * // Preceding JSDoc on this property is shown in IDE autocompletion
999
- * approval: define<{ message: string }, { approved: boolean }>(),
1000
- * // A key with $params is bound per call through `.with()`
1001
- * lineApproval: define.for("line-approval-$lineId")<{ message: string }, { approved: boolean }>(),
1002
- * }));
1003
- *
1004
- * await waitPoints.approval.wait({ message: "Please approve" });
1005
- * await waitPoints.lineApproval.with({ lineId: line.id }).wait({ message: "Please approve" });
1006
- *
1007
- * // For 2-level access, use destructured export with JSDoc attached to the export itself.
1008
- */
1009
- function createWaitPoints(builder) {
1010
- const setters = /* @__PURE__ */ new Map();
1011
- const result = builder(Object.assign(() => {
1012
- const { instance, setKey } = createWaitPointInstance("__pending__");
1013
- setters.set(instance, setKey);
1014
- return instance;
1015
- }, { for: (key) => {
1016
- const instance = createKeyedWaitPoint(key, "define");
1017
- return () => instance;
1018
- } }));
1019
- for (const propName of Object.keys(result)) {
1020
- const setter = setters.get(result[propName]);
1021
- if (!setter) continue;
1022
- registerWaitPoint({
1023
- key: propName,
1024
- declaredBy: "property"
1025
- });
1026
- setter(propName);
1027
- }
1028
- return result;
1029
- }
1030
-
1031
- //#endregion
1032
- //#region src/configure/services/workflow/workflow.ts
1033
- /**
1034
- * Create a workflow definition that can be started via the Tailor SDK.
1035
- * In production, the bundler rewrites `.start()` calls into direct platform workflow calls.
1036
- *
1037
- * The workflow MUST be the default export of the file.
1038
- * All jobs referenced by the workflow MUST be named exports.
1039
- * @template Job
1040
- * @param config - Workflow configuration
1041
- * @returns Defined workflow
1042
- * @example
1043
- * export const fetchData = createWorkflowJob({ name: "fetch-data", body: async (input: { id: string }) => ({ id: input.id }) });
1044
- * export const processData = createWorkflowJob({
1045
- * name: "process-data",
1046
- * body: (input: { id: string }) => {
1047
- * const data = fetchData.start({ id: input.id });
1048
- * return { data };
1049
- * },
1050
- * });
1051
- *
1052
- * // Workflow must be default export; mainJob is the entry point
1053
- * export default createWorkflow({
1054
- * name: "data-processing",
1055
- * mainJob: processData,
1056
- * });
1057
- */
1058
- function createWorkflow(config) {
1059
- return brandValue({
1060
- ...config,
1061
- start: process.env.__TAILOR_PLATFORM_BUNDLE ? async () => {
1062
- throw new Error("workflow.start() is rewritten at build time and unavailable in the bundle");
1063
- } : async function start(args, options) {
1064
- return arguments.length >= 2 ? await dispatchStartWorkflow(config.name, args, options) : await dispatchStartWorkflow(config.name, args);
1065
- }
1066
- }, "workflow");
1067
- }
1068
-
1069
- //#endregion
1070
- //#region src/configure/services/staticwebsite/index.ts
1071
- /**
1072
- * Define a static website configuration for the Tailor SDK.
1073
- * @param name - Static website name
1074
- * @param config - Static website configuration
1075
- * @returns Defined static website
1076
- */
1077
- /* @__NO_SIDE_EFFECTS__ */
1078
- function defineStaticWebSite(name, config) {
1079
- return {
1080
- ...config,
1081
- name,
1082
- get url() {
1083
- return `${name}:url`;
1084
- }
1085
- };
1086
- }
1087
-
1088
- //#endregion
1089
- //#region src/configure/services/aigateway/index.ts
1090
- /**
1091
- * Define an AI Gateway configuration for the Tailor SDK.
1092
- * @param name - AI Gateway name
1093
- * @param config - AI Gateway configuration
1094
- * @returns Defined AI Gateway
1095
- */
1096
- /* @__NO_SIDE_EFFECTS__ */
1097
- function defineAIGateway(name, config) {
1098
- return {
1099
- ...config,
1100
- name
1101
- };
1102
- }
1103
-
1104
- //#endregion
1105
- //#region src/configure/services/idp/permission.ts
1106
- /**
1107
- * Grants full IdP permission access without any conditions.
1108
- *
1109
- * Unsafe and intended only for local development, prototyping, or tests.
1110
- * Do not use this in production environments, as it effectively disables
1111
- * authorization checks.
1112
- */
1113
- const unsafeAllowAllIdPPermission = {
1114
- create: [{
1115
- conditions: [],
1116
- permit: true
1117
- }],
1118
- read: [{
1119
- conditions: [],
1120
- permit: true
1121
- }],
1122
- update: [{
1123
- conditions: [],
1124
- permit: true
1125
- }],
1126
- delete: [{
1127
- conditions: [],
1128
- permit: true
1129
- }],
1130
- sendPasswordResetEmail: [{
1131
- conditions: [],
1132
- permit: true
1133
- }],
1134
- unenrollMfa: [{
1135
- conditions: [],
1136
- permit: true
1137
- }]
1138
- };
1139
-
1140
- //#endregion
1141
- //#region src/configure/services/idp/index.ts
1142
- /**
1143
- * Define an IdP service configuration for the Tailor SDK.
1144
- * @template TClients
1145
- * @param name - IdP service name
1146
- * @param config - IdP configuration
1147
- * @returns Defined IdP service
1148
- */
1149
- /* @__NO_SIDE_EFFECTS__ */
1150
- function defineIdp(name, config) {
1151
- return {
1152
- ...config,
1153
- name,
1154
- provider(providerName, clientName) {
1155
- return {
1156
- name: providerName,
1157
- kind: "BuiltInIdP",
1158
- namespace: name,
1159
- clientName
1160
- };
1161
- }
1162
- };
1163
- }
1164
-
1165
- //#endregion
1166
- //#region src/configure/services/secrets/index.ts
1167
- /* @__NO_SIDE_EFFECTS__ */
1168
- function defineSecretManager(config, options) {
1169
- const result = {
1170
- vaults: config,
1171
- options: { ignoreNullishValues: options?.ignoreNullishValues ?? false }
1172
- };
1173
- Object.defineProperty(result, "get", {
1174
- value: async (vault, secret) => {
1175
- return tailor.secretmanager.getSecret(vault, secret);
1176
- },
1177
- enumerable: false
1178
- });
1179
- Object.defineProperty(result, "getAll", {
1180
- value: async (vault, secrets) => {
1181
- const record = await tailor.secretmanager.getSecrets(vault, secrets);
1182
- return secrets.map((s) => record[s]);
1183
- },
1184
- enumerable: false
1185
- });
1186
- return result;
1187
- }
1188
-
1189
- //#endregion
1190
- //#region src/configure/services/http-adapter/http-adapter.ts
1191
- /**
1192
- * Defines an HTTP adapter that translates HTTP requests to GraphQL queries
1193
- * and shapes the GraphQL response back into an HTTP response.
1194
- *
1195
- * The adapter MUST be the default export of its file.
1196
- * Files are discovered via the `httpAdapter.files` glob in `defineConfig()`.
1197
- *
1198
- * `input` is an object keyed by lowercase HTTP method (`get`, `post`, `put`,
1199
- * `patch`, `delete`). Each handler can return a GraphQL query string or a
1200
- * typed document node. At least one method must be declared; the methods the
1201
- * adapter serves are derived from these keys.
1202
- *
1203
- * `output` is optional and shared across all methods. If `input` returns typed
1204
- * document nodes, `output` receives the corresponding result type as
1205
- * `resp.data`. If you need different response shapes per method, discriminate
1206
- * inside `output` based on the GraphQL response shape.
1207
- *
1208
- * Each handler runs server-side and must be synchronous: Node APIs, `fetch`,
1209
- * `async`/`await`, Promises, and top-level `await` are not available.
1210
- *
1211
- * Optional fields: `enabled` (default `true`; set `false` to deploy the adapter
1212
- * without serving it) and `priority` (non-negative integer, default `0`; when
1213
- * multiple adapters match the same request path, the lowest value wins).
1214
- * @param config - HTTP adapter configuration
1215
- * @returns Branded HTTP adapter definition
1216
- * @example
1217
- * export default createHttpAdapter({
1218
- * name: "get-user",
1219
- * pathPattern: "/users/*",
1220
- * input: {
1221
- * get: (req) => ({
1222
- * query: `query($id: ID!) { user(id: $id) { id name } }`,
1223
- * variables: { id: req.path.split("/")[2] },
1224
- * }),
1225
- * },
1226
- * output: (resp) => ({
1227
- * statusCode: 200,
1228
- * headers: { "content-type": "application/json" },
1229
- * body: JSON.stringify(resp.data),
1230
- * }),
1231
- * });
1232
- */
1233
- function createHttpAdapter(config) {
1234
- return brandValue({ ...config }, "http-adapter");
1235
- }
1236
-
1237
- //#endregion
1238
- //#region src/configure/config/index.ts
1239
- /**
1240
- * Define a Tailor SDK application configuration with shallow exactness.
1241
- * @template Config
1242
- * @param config - Application configuration
1243
- * @returns The same configuration object
1244
- */
1245
- /* @__NO_SIDE_EFFECTS__ */
1246
- function defineConfig(config) {
1247
- return config;
1248
- }
1249
- /**
1250
- * Define plugins to be used with the Tailor SDK.
1251
- * Plugins can generate additional types, resolvers, and executors
1252
- * based on existing TailorDB tables.
1253
- * @param configs - Plugin configurations
1254
- * @returns Plugin configurations as given
1255
- */
1256
- /* @__NO_SIDE_EFFECTS__ */
1257
- function definePlugins(...configs) {
1258
- return configs;
1259
- }
1260
-
1261
- //#endregion
1262
- //#region src/configure/index.ts
1263
- /** TailorDB field type builders. */
1264
- const t = t$1;
1265
-
1266
- //#endregion
1267
- export { authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineConfig, defineIdp, definePlugins, defineSecretManager, defineStaticWebSite, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission, workflowExecutionCompletedTrigger, workflowExecutionResumedTrigger, workflowExecutionRetriedTrigger, workflowExecutionStartedTrigger, workflowExecutionTrigger, workflowExecutionWaitResolvedTrigger, workflowExecutionWaitStartedTrigger, workflowJobExecutionCompletedTrigger, workflowJobExecutionStartedTrigger, workflowJobExecutionTrigger, workflowJobExecutionWaitResolvedTrigger, workflowJobExecutionWaitStartedTrigger };
1
+ import{i as e,n as t,t as n}from"../schema-Ze_dI5VX.mjs";import{t as r}from"../brand-C8nMKhJC.mjs";import{a as i,n as a,r as o}from"../registry-HlEaGvl5.mjs";import{l as s,n as c,r as l,t as u}from"../wait-point-invoker-eiP-IIux.mjs";import{r as d}from"../wait-point-registry-BrkwfyjS.mjs";function createTailorField(n,r,i,a,o){let s=o?{...o,...o.allowedValues&&{allowedValues:o.allowedValues.map(e=>({...e}))},...o.validate&&{validate:o.validate.map(e=>Array.isArray(e)?[...e]:e)}}:{required:!0};o||(r&&(r.optional===!0&&(s.required=!1),r.array===!0&&(s.array=!0)),a&&(s.allowedValues=t(a)));function parseInternal$1(t){return e({...t,field:c})}function cloneWith(e){let t=c.clone();return Object.assign(t._metadata,e),t}let c={type:n,fields:i??{},_defined:void 0,_output:void 0,_metadata:s,get metadata(){return{...this._metadata}},description(e){return cloneWith({description:e})},typeName(e){return cloneWith({typeName:e})},validate(...e){return cloneWith({validate:e})},parse(e){return parseInternal$1({value:e.value,data:e.data,invoker:e.invoker,pathArray:[]})},clone(){let e=i;if(i){let t={};for(let[e,n]of Object.entries(i))t[e]=n.clone();e=t}return createTailorField(n,r,e,a,this._metadata)}};return c}function uuid(e){return createTailorField(`uuid`,e)}function string(e){return createTailorField(`string`,e)}function bool(e){return createTailorField(`boolean`,e)}function int(e){return createTailorField(`integer`,e)}function float(e){return createTailorField(`float`,e)}function decimal(e){return createTailorField(`decimal`,e)}function date(e){return createTailorField(`date`,e)}function datetime(e){return createTailorField(`datetime`,e)}function time(e){return createTailorField(`time`,e)}function _enum(e,t){return createTailorField(`enum`,t,void 0,e)}function object(e,t){return createTailorField(`nested`,t,e)}const f={uuid,string,bool,int,float,decimal,date,datetime,time,enum:_enum,object};function defineAuth(e,t){return{...t,name:e}}const p={create:[{conditions:[],permit:!0}],read:[{conditions:[],permit:!0}],update:[{conditions:[],permit:!0}],delete:[{conditions:[],permit:!0}]},m=[{conditions:[],actions:`all`,permit:!0}];function createResolver(e){let t=(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`)(e.output)?e.output:f.object(e.output);return r({...e,output:t},`resolver`)}function createExecutor(e){return r(e,`executor`)}const h={created:`tailordb.type_record.created`,updated:`tailordb.type_record.updated`,deleted:`tailordb.type_record.deleted`};function recordCreatedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.created`],tableName:t.name,condition:n,__args:{}}}function recordUpdatedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.updated`],tableName:t.name,condition:n,__args:{}}}function recordDeletedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.deleted`],tableName:t.name,condition:n,__args:{}}}function recordTrigger(e){let{type:t,events:n,condition:r}=e;return{kind:`tailordb`,events:n.map(e=>h[e]),tableName:t.name,condition:r,__args:{}}}function resolverExecutedTrigger(e){let{resolver:t,condition:n}=e;return{kind:`resolverExecuted`,resolverName:t.name,condition:n,__args:{}}}const g={created:`idp.user.created`,updated:`idp.user.updated`,deleted:`idp.user.deleted`};function idpUserCreatedTrigger(e){return{kind:`idpUser`,events:[`idp.user.created`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserUpdatedTrigger(e){return{kind:`idpUser`,events:[`idp.user.updated`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserDeletedTrigger(e){return{kind:`idpUser`,events:[`idp.user.deleted`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserTrigger(e){let{events:t,idp:n}=e;return{kind:`idpUser`,events:t.map(e=>g[e]),...n==null?{}:{idp:n},__args:{}}}const _={issued:`auth.access_token.issued`,refreshed:`auth.access_token.refreshed`,revoked:`auth.access_token.revoked`};function authAccessTokenIssuedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.issued`],__args:{}}}function authAccessTokenRefreshedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.refreshed`],__args:{}}}function authAccessTokenRevokedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.revoked`],__args:{}}}function authAccessTokenTrigger(e){let{events:t}=e;return{kind:`authAccessToken`,events:t.map(e=>_[e]),__args:{}}}const v={started:`workflow.workflow_execution.started`,completed:`workflow.workflow_execution.completed`,retried:`workflow.workflow_execution.retried`,resumed:`workflow.workflow_execution.resumed`,wait_started:`workflow.workflow_execution.wait_started`,wait_resolved:`workflow.workflow_execution.wait_resolved`};function workflowExecutionTriggerConfig(e,t){return{kind:`workflowExecution`,events:e,workflowName:t.workflow.name,condition:t.condition,__args:{}}}function workflowExecutionStartedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.started`],e)}function workflowExecutionCompletedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.completed`],e)}function workflowExecutionRetriedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.retried`],e)}function workflowExecutionResumedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.resumed`],e)}function workflowExecutionWaitStartedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.wait_started`],e)}function workflowExecutionWaitResolvedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.wait_resolved`],e)}function workflowExecutionTrigger(e){let{events:t,workflow:n,condition:r}=e;return workflowExecutionTriggerConfig(t.map(e=>v[e]),{workflow:n,condition:r})}const y={started:`workflow.workflow_execution.job_execution.started`,completed:`workflow.workflow_execution.job_execution.completed`,wait_started:`workflow.workflow_execution.job_execution.wait_started`,wait_resolved:`workflow.workflow_execution.job_execution.wait_resolved`};function workflowJobExecutionTriggerConfig(e,t){return{kind:`workflowJobExecution`,events:e,workflowName:t.workflow.name,condition:t.condition,__args:{}}}function workflowJobExecutionStartedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.started`],e)}function workflowJobExecutionCompletedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.completed`],e)}function workflowJobExecutionWaitStartedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.wait_started`],e)}function workflowJobExecutionWaitResolvedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.wait_resolved`],e)}function workflowJobExecutionTrigger(e){let{events:t,workflow:n,condition:r}=e;return workflowJobExecutionTriggerConfig(t.map(e=>y[e]),{workflow:n,condition:r})}function scheduleTrigger(e){let{cron:t,timezone:n}=e;return{kind:`schedule`,cron:t,timezone:n,__args:{}}}function incomingWebhookTrigger(e){let t=typeof e?.response==`function`?{body:e.response}:e?.response;return{kind:`incomingWebhook`,...t?{response:t}:{},__args:{}}}const b=/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9]$/;function createExecutionPolicyInstance(e,t,n,i,a,o,s){let c=i===`prefix`,l={name:e,key:t,matchType:i,...n&&{concurrencyPolicy:n},...c&&{keyFor:e=>{let t=`${l.key}${a}${e}`;if(!b.test(t))throw Error(`Invalid execution policy key "${t}" built by keyFor("${e}"): must match [a-z0-9_:.-] (2-64 chars; must start and end with [a-z0-9]).`);return t}}};return{instance:r(l,`execution-policy`),setName:o?e=>{l.name=e}:void 0,setKey:s?e=>{l.key=e}:void 0}}function defineWorkflowExecutionPolicy(e,t){return createExecutionPolicyInstance(e,t?.key??e,t?.concurrencyPolicy,t?.matchType??`exact`,t?.separator??`.`,!1,!1).instance}function defineWorkflowExecutionPolicies(e,t){let n=t?.separator??`.`,r=new Map,i=new Map,a=e(e=>{let t=e?.name,a=e?.key,{instance:o,setName:s,setKey:c}=createExecutionPolicyInstance(t??`__pending__`,a??t??`__pending__`,e?.concurrencyPolicy,e?.matchType??`exact`,n,t===void 0,a===void 0&&t===void 0);return s&&r.set(o,s),c&&i.set(o,c),o});for(let e of Object.keys(a)){let t=a[e];r.get(t)?.(e),i.get(t)?.(e)}return a}function createWorkflowJob(e){let t=e.body,n=process.env.__TAILOR_PLATFORM_BUNDLE?t:(e,n)=>s(n.invoker,()=>t(e,n));process.env.__TAILOR_PLATFORM_BUNDLE||i(e.name,n);let o=process.env.__TAILOR_PLATFORM_BUNDLE?()=>{throw Error(`.start() on workflow job "${e.name}" is rewritten at build time and is unavailable in the bundle`)}:function(t,n){return arguments.length>=2?a(e.name,t,n):a(e.name,t)};return r({name:e.name,start:o,body:n,...e.publishEvents===void 0?{}:{publishEvents:e.publishEvents}},`workflow-job`)}const x=/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/,S=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function parseKey(e){let t=e.split(`-`);return{segments:t,paramNames:t.filter(e=>e.startsWith(`$`)&&e.length>1).map(e=>e.slice(1))}}function composeKey(e,t,n){let r=t.segments.map(t=>{if(!t.startsWith(`$`)||t.length===1)return t;let r=t.slice(1),i=n[r];if(typeof i!=`string`)throw Error(`Wait point "${e}" needs a string for parameter "${r}" but received ${i===void 0?`undefined`:typeof i}.`);if(!S.test(i))throw Error(`Wait point "${e}" cannot use ${JSON.stringify(i)} for parameter "${r}": values may only contain [a-z0-9-] and cannot be empty or start or end with "-".`);return i}).join(`-`);if(r.length>63)throw Error(`Wait point key "${r}" built from "${e}" is ${r.length} characters; the limit is 63.`);if(!x.test(r))throw Error(`Wait point key "${r}" built from "${e}" must match [a-z0-9-] (3-63 characters; must start and end with [a-z0-9]).`);return r}function createBoundWaitPoint(e,t){return{wait(n){return Promise.resolve(e.wait(t(),n))},async resolve(n,r){await e.resolve(t(),n,r)}}}function createWaitPointInstance(e){let t=e,n=l(),i=r(createBoundWaitPoint(n,()=>t),`wait-point`);return u(i,n),{instance:i,setKey:e=>{t=e}}}function createParameterizedWaitPointInstance(e,t,n){let i=l(),unbound=()=>{throw Error(n===`define`?`Wait point key "${e}" has $params, so it identifies no single suspension on its own. Bind them first: waitPoint.with({ ... }).wait(...).`:`Wait point key "${e}" has $params, which createWaitPoint cannot type. Declare it through createWaitPoints instead: createWaitPoints((define) => ({ myWaitPoint: define.for("${e}")<Payload, Result>() })).`)},a=r({with(n){let r=composeKey(e,t,n);return c(createBoundWaitPoint(i,()=>r),r)},wait:unbound,resolve:unbound},`wait-point`);return u(a,i),a}function createKeyedWaitPoint(e,t){d({key:e,declaredBy:t});let n=parseKey(e);return n.paramNames.length>0?createParameterizedWaitPointInstance(e,n,t):createWaitPointInstance(e).instance}function createWaitPoint(e){return createKeyedWaitPoint(e,`createWaitPoint`)}function createWaitPoints(e){let t=new Map,n=e(Object.assign(()=>{let{instance:e,setKey:n}=createWaitPointInstance(`__pending__`);return t.set(e,n),e},{for:e=>{let t=createKeyedWaitPoint(e,`define`);return()=>t}}));for(let e of Object.keys(n)){let r=t.get(n[e]);r&&(d({key:e,declaredBy:`property`}),r(e))}return n}function createWorkflow(e){return r({...e,start:process.env.__TAILOR_PLATFORM_BUNDLE?async()=>{throw Error(`workflow.start() is rewritten at build time and unavailable in the bundle`)}:async function(t,n){return arguments.length>=2?await o(e.name,t,n):await o(e.name,t)}},`workflow`)}function defineStaticWebSite(e,t){return{...t,name:e,get url(){return`${e}:url`}}}function defineAIGateway(e,t){return{...t,name:e}}const C={create:[{conditions:[],permit:!0}],read:[{conditions:[],permit:!0}],update:[{conditions:[],permit:!0}],delete:[{conditions:[],permit:!0}],sendPasswordResetEmail:[{conditions:[],permit:!0}],unenrollMfa:[{conditions:[],permit:!0}]};function defineIdp(e,t){return{...t,name:e,provider(t,n){return{name:t,kind:`BuiltInIdP`,namespace:e,clientName:n}}}}function defineSecretManager(e,t){let n={vaults:e,options:{ignoreNullishValues:t?.ignoreNullishValues??!1}};return Object.defineProperty(n,"get",{value:async(e,t)=>tailor.secretmanager.getSecret(e,t),enumerable:!1}),Object.defineProperty(n,"getAll",{value:async(e,t)=>{let n=await tailor.secretmanager.getSecrets(e,t);return t.map(e=>n[e])},enumerable:!1}),n}function createHttpAdapter(e){return r({...e},`http-adapter`)}function defineConfig(e){return e}function definePlugins(...e){return e}const w=f;export{authAccessTokenIssuedTrigger,authAccessTokenRefreshedTrigger,authAccessTokenRevokedTrigger,authAccessTokenTrigger,createExecutor,createHttpAdapter,createResolver,createWaitPoint,createWaitPoints,createWorkflow,createWorkflowJob,n as db,defineAIGateway,defineAuth,defineConfig,defineIdp,definePlugins,defineSecretManager,defineStaticWebSite,defineWorkflowExecutionPolicies,defineWorkflowExecutionPolicy,idpUserCreatedTrigger,idpUserDeletedTrigger,idpUserTrigger,idpUserUpdatedTrigger,incomingWebhookTrigger,recordCreatedTrigger,recordDeletedTrigger,recordTrigger,recordUpdatedTrigger,resolverExecutedTrigger,scheduleTrigger,w as t,m as unsafeAllowAllGqlPermission,C as unsafeAllowAllIdPPermission,p as unsafeAllowAllTypePermission,workflowExecutionCompletedTrigger,workflowExecutionResumedTrigger,workflowExecutionRetriedTrigger,workflowExecutionStartedTrigger,workflowExecutionTrigger,workflowExecutionWaitResolvedTrigger,workflowExecutionWaitStartedTrigger,workflowJobExecutionCompletedTrigger,workflowJobExecutionStartedTrigger,workflowJobExecutionTrigger,workflowJobExecutionWaitResolvedTrigger,workflowJobExecutionWaitStartedTrigger};
1268
2
  //# sourceMappingURL=index.mjs.map