@tailor-platform/sdk 1.36.0 → 1.37.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 (76) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/application-ILhZq_oW.mjs +4 -0
  3. package/dist/{application-BwboBFcU.mjs → application-qRGMV8Tr.mjs} +50 -20
  4. package/dist/application-qRGMV8Tr.mjs.map +1 -0
  5. package/dist/{brand-0SscafcY.mjs → brand-D-d15jx3.mjs} +1 -1
  6. package/dist/{brand-0SscafcY.mjs.map → brand-D-d15jx3.mjs.map} +1 -1
  7. package/dist/cli/index.mjs +11 -11
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +6 -6
  10. package/dist/cli/lib.mjs +7 -7
  11. package/dist/{client-B6icVEv4.mjs → client-424n_3T9.mjs} +1 -1
  12. package/dist/{client-CN15WgW2.mjs → client-DllDLYmZ.mjs} +4 -4
  13. package/dist/{client-CN15WgW2.mjs.map → client-DllDLYmZ.mjs.map} +1 -1
  14. package/dist/configure/index.d.mts +5 -5
  15. package/dist/configure/index.mjs +4 -14
  16. package/dist/configure/index.mjs.map +1 -1
  17. package/dist/{crash-report-CdxPj_SW.mjs → crash-report-CDQ2JvgR.mjs} +4 -4
  18. package/dist/{crash-report-CdxPj_SW.mjs.map → crash-report-CDQ2JvgR.mjs.map} +1 -1
  19. package/dist/{crash-report-CB1UtT3O.mjs → crash-report-aHnky_xH.mjs} +1 -1
  20. package/dist/{enum-constants-DI85-fPE.mjs → enum-constants-Dx82rSjf.mjs} +1 -1
  21. package/dist/{enum-constants-DI85-fPE.mjs.map → enum-constants-Dx82rSjf.mjs.map} +1 -1
  22. package/dist/{env-_ce3IYbl.d.mts → env-04IQXqsl.d.mts} +2 -2
  23. package/dist/{file-utils-C4rXlOVt.mjs → file-utils-DeWpvq3T.mjs} +1 -1
  24. package/dist/{file-utils-C4rXlOVt.mjs.map → file-utils-DeWpvq3T.mjs.map} +1 -1
  25. package/dist/{index-C7vIBAg8.d.mts → index-BUT18Kak.d.mts} +2 -2
  26. package/dist/{index-CYaunQeL.d.mts → index-BVJQLjyN.d.mts} +27 -12
  27. package/dist/{index-DDCyefuU.d.mts → index-C3kcXHXJ.d.mts} +2 -2
  28. package/dist/{index-DZN1QFLM.d.mts → index-CeS4FA9o.d.mts} +2 -2
  29. package/dist/{index-CxSLivW7.d.mts → index-DnIg_LfT.d.mts} +2 -2
  30. package/dist/{interceptor-f7slMkCC.mjs → interceptor-dSNiQq71.mjs} +1 -1
  31. package/dist/{interceptor-f7slMkCC.mjs.map → interceptor-dSNiQq71.mjs.map} +1 -1
  32. package/dist/{job-CPKYCk_e.mjs → job-DkAklmE4.mjs} +2 -2
  33. package/dist/{job-CPKYCk_e.mjs.map → job-DkAklmE4.mjs.map} +1 -1
  34. package/dist/{kysely-type-DtnNdHn3.mjs → kysely-type-CwtvQuxh.mjs} +1 -1
  35. package/dist/{kysely-type-DtnNdHn3.mjs.map → kysely-type-CwtvQuxh.mjs.map} +1 -1
  36. package/dist/{logger-qz-Y4sBV.mjs → logger-C8qBDCKO.mjs} +1 -1
  37. package/dist/{logger-qz-Y4sBV.mjs.map → logger-C8qBDCKO.mjs.map} +1 -1
  38. package/dist/package-json--6dmp6-h.mjs +4 -0
  39. package/dist/{package-json-CfUqjJaQ.mjs → package-json-BHViVisJ.mjs} +1 -1
  40. package/dist/{package-json-CfUqjJaQ.mjs.map → package-json-BHViVisJ.mjs.map} +1 -1
  41. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  42. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  43. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  44. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  45. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  46. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  47. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  48. package/dist/plugin/builtin/seed/index.mjs +1 -1
  49. package/dist/plugin/index.d.mts +2 -2
  50. package/dist/{plugin-CiPUxkyN.d.mts → plugin-D6P4g_2L.d.mts} +14 -9
  51. package/dist/{runtime-C7RRDaB3.mjs → runtime-D9ejnCm6.mjs} +566 -95
  52. package/dist/runtime-D9ejnCm6.mjs.map +1 -0
  53. package/dist/{schema-D27cW0Ca.mjs → schema-CnwUqPyM.mjs} +4 -361
  54. package/dist/schema-CnwUqPyM.mjs.map +1 -0
  55. package/dist/{seed-BZIFDG27.mjs → seed-DrbB1VXd.mjs} +1 -1
  56. package/dist/{seed-BZIFDG27.mjs.map → seed-DrbB1VXd.mjs.map} +1 -1
  57. package/dist/telemetry-4IOPW6wE.mjs +4 -0
  58. package/dist/{telemetry-CREcGK8y.mjs → telemetry-DwHuiNiR.mjs} +2 -2
  59. package/dist/{telemetry-CREcGK8y.mjs.map → telemetry-DwHuiNiR.mjs.map} +1 -1
  60. package/dist/types-B9ZMosul.mjs +372 -0
  61. package/dist/types-B9ZMosul.mjs.map +1 -0
  62. package/dist/types-C45jRrCM.mjs +4 -0
  63. package/dist/utils/test/index.d.mts +2 -2
  64. package/dist/utils/test/index.mjs +1 -1
  65. package/dist/{workflow.generated-8BeGQsVU.d.mts → workflow.generated-Bj_DVqGh.d.mts} +2 -2
  66. package/docs/services/auth.md +6 -5
  67. package/docs/services/executor.md +5 -12
  68. package/docs/services/resolver.md +6 -13
  69. package/docs/services/workflow.md +4 -3
  70. package/package.json +4 -4
  71. package/dist/application-BB5TqXWY.mjs +0 -4
  72. package/dist/application-BwboBFcU.mjs.map +0 -1
  73. package/dist/package-json-D5Km1jjt.mjs +0 -4
  74. package/dist/runtime-C7RRDaB3.mjs.map +0 -1
  75. package/dist/schema-D27cW0Ca.mjs.map +0 -1
  76. package/dist/telemetry-C508zIi1.mjs +0 -4
@@ -0,0 +1,372 @@
1
+
2
+ //#region src/configure/types/field.ts
3
+ /**
4
+ * Normalize allowed values into EnumValue objects with descriptions.
5
+ * @param values - Allowed values as strings or EnumValue objects
6
+ * @returns Normalized allowed values
7
+ */
8
+ function mapAllowedValues(values) {
9
+ return values.map((value) => {
10
+ if (typeof value === "string") return {
11
+ value,
12
+ description: ""
13
+ };
14
+ return {
15
+ ...value,
16
+ description: value.description ?? ""
17
+ };
18
+ });
19
+ }
20
+
21
+ //#endregion
22
+ //#region src/configure/types/type.ts
23
+ const regex = {
24
+ uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
25
+ date: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,
26
+ time: /^(?<hour>\d{2}):(?<minute>\d{2})$/,
27
+ datetime: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(.(?<millisec>\d{3}))?Z$/,
28
+ decimal: /^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/
29
+ };
30
+ /**
31
+ * Creates a new TailorField instance.
32
+ * @param type - Field type
33
+ * @param options - Field options
34
+ * @param fields - Nested fields for object-like types
35
+ * @param values - Allowed values for enum-like fields
36
+ * @returns A new TailorField
37
+ */
38
+ function createTailorField(type, options, fields, values) {
39
+ const _metadata = { required: true };
40
+ if (options) {
41
+ if (options.optional === true) _metadata.required = false;
42
+ if (options.array === true) _metadata.array = true;
43
+ }
44
+ if (values) _metadata.allowedValues = mapAllowedValues(values);
45
+ /**
46
+ * Validate a single value (not an array element)
47
+ * Used internally for array element validation
48
+ * @param args - Value, context data, and user
49
+ * @returns Array of validation issues
50
+ */
51
+ function validateValue(args) {
52
+ const { value, data, user, pathArray } = args;
53
+ const issues = [];
54
+ switch (type) {
55
+ case "string":
56
+ if (typeof value !== "string") issues.push({
57
+ message: `Expected a string: received ${String(value)}`,
58
+ path: pathArray.length > 0 ? pathArray : void 0
59
+ });
60
+ break;
61
+ case "integer":
62
+ if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
63
+ message: `Expected an integer: received ${String(value)}`,
64
+ path: pathArray.length > 0 ? pathArray : void 0
65
+ });
66
+ break;
67
+ case "float":
68
+ if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
69
+ message: `Expected a number: received ${String(value)}`,
70
+ path: pathArray.length > 0 ? pathArray : void 0
71
+ });
72
+ break;
73
+ case "boolean":
74
+ if (typeof value !== "boolean") issues.push({
75
+ message: `Expected a boolean: received ${String(value)}`,
76
+ path: pathArray.length > 0 ? pathArray : void 0
77
+ });
78
+ break;
79
+ case "uuid":
80
+ if (typeof value !== "string" || !regex.uuid.test(value)) issues.push({
81
+ message: `Expected a valid UUID: received ${String(value)}`,
82
+ path: pathArray.length > 0 ? pathArray : void 0
83
+ });
84
+ break;
85
+ case "date":
86
+ if (typeof value !== "string" || !regex.date.test(value)) issues.push({
87
+ message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
88
+ path: pathArray.length > 0 ? pathArray : void 0
89
+ });
90
+ break;
91
+ case "datetime":
92
+ if (typeof value !== "string" || !regex.datetime.test(value)) issues.push({
93
+ message: `Expected to match ISO format: received ${String(value)}`,
94
+ path: pathArray.length > 0 ? pathArray : void 0
95
+ });
96
+ break;
97
+ case "time":
98
+ if (typeof value !== "string" || !regex.time.test(value)) issues.push({
99
+ message: `Expected to match "HH:mm" format: received ${String(value)}`,
100
+ path: pathArray.length > 0 ? pathArray : void 0
101
+ });
102
+ break;
103
+ case "decimal":
104
+ if (typeof value !== "string" || !regex.decimal.test(value)) issues.push({
105
+ message: `Expected a decimal string: received ${String(value)}`,
106
+ path: pathArray.length > 0 ? pathArray : void 0
107
+ });
108
+ break;
109
+ case "enum":
110
+ if (field._metadata.allowedValues) {
111
+ const allowedValues = field._metadata.allowedValues.map((v) => v.value);
112
+ if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
113
+ message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
114
+ path: pathArray.length > 0 ? pathArray : void 0
115
+ });
116
+ }
117
+ break;
118
+ case "nested":
119
+ if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) issues.push({
120
+ message: `Expected an object: received ${String(value)}`,
121
+ path: pathArray.length > 0 ? pathArray : void 0
122
+ });
123
+ else if (field.fields && Object.keys(field.fields).length > 0) for (const [fieldName, nestedField] of Object.entries(field.fields)) {
124
+ const fieldValue = value?.[fieldName];
125
+ const result = nestedField._parseInternal({
126
+ value: fieldValue,
127
+ data,
128
+ user,
129
+ pathArray: pathArray.concat(fieldName)
130
+ });
131
+ if (result.issues) issues.push(...result.issues);
132
+ }
133
+ break;
134
+ }
135
+ const validateFns = field._metadata.validate;
136
+ if (validateFns && validateFns.length > 0) for (const validateInput of validateFns) {
137
+ const { fn, message } = typeof validateInput === "function" ? {
138
+ fn: validateInput,
139
+ message: "Validation failed"
140
+ } : {
141
+ fn: validateInput[0],
142
+ message: validateInput[1]
143
+ };
144
+ if (!fn({
145
+ value,
146
+ data,
147
+ user
148
+ })) issues.push({
149
+ message,
150
+ path: pathArray.length > 0 ? pathArray : void 0
151
+ });
152
+ }
153
+ return issues;
154
+ }
155
+ /**
156
+ * Internal parse method that tracks field path for nested validation
157
+ * @param args - Parse arguments
158
+ * @returns Parse result with value or issues
159
+ */
160
+ function parseInternal(args) {
161
+ const { value, data, user, pathArray } = args;
162
+ const issues = [];
163
+ const isNullOrUndefined = value === null || value === void 0;
164
+ if (field._metadata.required && isNullOrUndefined) {
165
+ issues.push({
166
+ message: "Required field is missing",
167
+ path: pathArray.length > 0 ? pathArray : void 0
168
+ });
169
+ return { issues };
170
+ }
171
+ if (!field._metadata.required && isNullOrUndefined) return { value: value ?? null };
172
+ if (field._metadata.array) {
173
+ if (!Array.isArray(value)) {
174
+ issues.push({
175
+ message: "Expected an array",
176
+ path: pathArray.length > 0 ? pathArray : void 0
177
+ });
178
+ return { issues };
179
+ }
180
+ for (let i = 0; i < value.length; i++) {
181
+ const elementValue = value[i];
182
+ const elementIssues = validateValue({
183
+ value: elementValue,
184
+ data,
185
+ user,
186
+ pathArray: pathArray.concat(`[${i}]`)
187
+ });
188
+ if (elementIssues.length > 0) issues.push(...elementIssues);
189
+ }
190
+ if (issues.length > 0) return { issues };
191
+ return { value };
192
+ }
193
+ const valueIssues = validateValue({
194
+ value,
195
+ data,
196
+ user,
197
+ pathArray
198
+ });
199
+ issues.push(...valueIssues);
200
+ if (issues.length > 0) return { issues };
201
+ return { value };
202
+ }
203
+ const field = {
204
+ type,
205
+ fields: fields ?? {},
206
+ _defined: void 0,
207
+ _output: void 0,
208
+ _metadata,
209
+ get metadata() {
210
+ return { ...this._metadata };
211
+ },
212
+ description(description) {
213
+ this._metadata.description = description;
214
+ return this;
215
+ },
216
+ typeName(typeName) {
217
+ this._metadata.typeName = typeName;
218
+ return this;
219
+ },
220
+ validate(...validateInputs) {
221
+ this._metadata.validate = validateInputs;
222
+ return this;
223
+ },
224
+ parse(args) {
225
+ return parseInternal({
226
+ value: args.value,
227
+ data: args.data,
228
+ user: args.user,
229
+ pathArray: []
230
+ });
231
+ },
232
+ _parseInternal: parseInternal
233
+ };
234
+ return field;
235
+ }
236
+ /**
237
+ * Create a UUID field for resolver input/output.
238
+ * @param options - Field configuration options
239
+ * @returns A UUID field
240
+ * @example t.uuid()
241
+ */
242
+ function uuid(options) {
243
+ return createTailorField("uuid", options);
244
+ }
245
+ /**
246
+ * Create a string field for resolver input/output.
247
+ * @param options - Field configuration options
248
+ * @returns A string field
249
+ * @example t.string()
250
+ * @example t.string({ optional: true })
251
+ * @example t.string({ array: true })
252
+ */
253
+ function string(options) {
254
+ return createTailorField("string", options);
255
+ }
256
+ /**
257
+ * Create a boolean field for resolver input/output.
258
+ * @param options - Field configuration options
259
+ * @returns A boolean field
260
+ * @example t.bool()
261
+ */
262
+ function bool(options) {
263
+ return createTailorField("boolean", options);
264
+ }
265
+ /**
266
+ * Create an integer field for resolver input/output.
267
+ * @param options - Field configuration options
268
+ * @returns An integer field
269
+ * @example t.int()
270
+ */
271
+ function int(options) {
272
+ return createTailorField("integer", options);
273
+ }
274
+ /**
275
+ * Create a float field for resolver input/output.
276
+ * @param options - Field configuration options
277
+ * @returns A float field
278
+ * @example t.float()
279
+ */
280
+ function float(options) {
281
+ return createTailorField("float", options);
282
+ }
283
+ /**
284
+ * Create a decimal field for resolver input/output (stored as string for precision).
285
+ * @param options - Field configuration options
286
+ * @returns A decimal field
287
+ * @example t.decimal()
288
+ * @example t.decimal({ optional: true })
289
+ */
290
+ function decimal(options) {
291
+ return createTailorField("decimal", options);
292
+ }
293
+ /**
294
+ * Create a date field for resolver input/output.
295
+ * @param options - Field configuration options
296
+ * @returns A date field
297
+ * @example t.date()
298
+ */
299
+ function date(options) {
300
+ return createTailorField("date", options);
301
+ }
302
+ /**
303
+ * Create a datetime field for resolver input/output.
304
+ * @param options - Field configuration options
305
+ * @returns A datetime field
306
+ * @example t.datetime()
307
+ */
308
+ function datetime(options) {
309
+ return createTailorField("datetime", options);
310
+ }
311
+ /**
312
+ * Create a time field for resolver input/output.
313
+ * @param options - Field configuration options
314
+ * @returns A time field
315
+ * @example t.time()
316
+ */
317
+ function time(options) {
318
+ return createTailorField("time", options);
319
+ }
320
+ /**
321
+ * Create an enum field for resolver input/output.
322
+ * @param values - Array of allowed string values
323
+ * @param options - Field configuration options
324
+ * @returns An enum field
325
+ * @example t.enum(["active", "inactive"])
326
+ */
327
+ function _enum(values, options) {
328
+ return createTailorField("enum", options, void 0, values);
329
+ }
330
+ /**
331
+ * Create a nested object field for resolver input/output.
332
+ * @param fields - Record of field definitions
333
+ * @param options - Field options (optional, array)
334
+ * @returns A nested object field
335
+ * @example
336
+ * // Single object:
337
+ * output: t.object({ name: t.string(), email: t.string() })
338
+ * @example
339
+ * // Array of objects:
340
+ * items: t.object({ name: t.string() }, { array: true })
341
+ */
342
+ function object(fields, options) {
343
+ return createTailorField("nested", options, fields);
344
+ }
345
+ const t = {
346
+ uuid,
347
+ string,
348
+ bool,
349
+ int,
350
+ float,
351
+ decimal,
352
+ date,
353
+ datetime,
354
+ time,
355
+ enum: _enum,
356
+ object
357
+ };
358
+
359
+ //#endregion
360
+ //#region src/configure/types/user.ts
361
+ /** Represents an unauthenticated user in the Tailor platform. */
362
+ const unauthenticatedTailorUser = {
363
+ id: "00000000-0000-0000-0000-000000000000",
364
+ type: "",
365
+ workspaceId: "00000000-0000-0000-0000-000000000000",
366
+ attributes: null,
367
+ attributeList: []
368
+ };
369
+
370
+ //#endregion
371
+ export { t as n, mapAllowedValues as r, unauthenticatedTailorUser as t };
372
+ //# sourceMappingURL=types-B9ZMosul.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-B9ZMosul.mjs","names":[],"sources":["../src/configure/types/field.ts","../src/configure/types/type.ts","../src/configure/types/user.ts"],"sourcesContent":["import type { EnumValue } from \"@/types/tailordb\";\n\nexport type AllowedValue = EnumValue;\n\nexport type AllowedValues = readonly [string | EnumValue, ...(string | EnumValue)[]];\n\n/**\n * Normalize allowed values into EnumValue objects with descriptions.\n * @param values - Allowed values as strings or EnumValue objects\n * @returns Normalized allowed values\n */\nexport function mapAllowedValues(values: AllowedValues): AllowedValue[] {\n return values.map((value) => {\n if (typeof value === \"string\") {\n return { value, description: \"\" };\n }\n return { ...value, description: value.description ?? \"\" };\n });\n}\n\nexport type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T\n ? T extends string\n ? T\n : T extends { value: infer K }\n ? K\n : never\n : never;\n","import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport {\n type TailorFieldType,\n type TailorToTs,\n type FieldMetadata,\n type DefinedFieldMetadata,\n type FieldOptions,\n type FieldOutput,\n} from \"./types\";\nimport type { Prettify, InferFieldsOutput } from \"./helpers\";\nimport type { FieldValidateInput } from \"./validation\";\nimport type { TailorUser } from \"@/configure/types\";\nimport type { TailorFieldInput } from \"@/types/field.generated\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>\\d{2}):(?<minute>\\d{2})$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})T(?<hour>\\d{2}):(?<minute>\\d{2}):(?<second>\\d{2})(.(?<millisec>\\d{3}))?Z$/,\n decimal: /^-?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/,\n} as const;\n\n// This helper type intentionally uses `any` as a placeholder for unknown field output.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyField = TailorField<any>;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\n // Runtime input is unknown/untyped; we validate and narrow it inside the parser.\n // oxlint-disable-next-line no-explicit-any\n value: any;\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\n/**\n * TailorField interface representing a field with metadata, type information, and optional nested fields.\n * This is the base field type used by both resolver types and TailorDB types.\n * Using interface to allow self-referencing in the fields property.\n */\nexport interface TailorField<\n Defined extends DefinedFieldMetadata = DefinedFieldMetadata,\n // Generic default output type (kept loose on purpose for library ergonomics).\n // oxlint-disable-next-line no-explicit-any\n Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> extends TailorFieldInput {\n readonly type: T;\n readonly fields: Record<string, TailorAnyField>;\n readonly _defined: Defined;\n readonly _output: Output;\n _metadata: M;\n\n /** Returns a shallow copy of the metadata */\n readonly metadata: M;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Set a custom type name for enum or nested types\n * @param typeName - The custom type name\n * @returns The field with updated metadata\n */\n typeName<CurrentDefined extends Defined>(\n this: CurrentDefined extends { typeName: unknown }\n ? never\n : CurrentDefined extends { type: \"enum\" | \"nested\" }\n ? TailorField<CurrentDefined, Output>\n : never,\n typeName: string,\n ): TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n\n /**\n * Add validation functions to the field\n * @param validate - One or more validation functions\n * @returns The field with updated metadata\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\n\n /**\n * Parse and validate a value against this field's validation rules\n * Returns StandardSchema Result type with success or failure\n * @param args - Value, context data, and user\n * @returns Validation result\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param args - Parse arguments\n * @returns Validation result\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n}\n\n/**\n * Creates a new TailorField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @returns A new TailorField\n */\nfunction createTailorField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyField>,\n values?: AllowedValues,\n): TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n const _metadata: FieldMetadata = { required: true };\n\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"decimal\":\n if (typeof value !== \"string\" || !regex.decimal.test(value)) {\n issues.push({\n message: `Expected a decimal string: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n } else if (field.fields && Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = value?.[fieldName];\n const result = nestedField._parseInternal({\n value: fieldValue,\n data,\n user,\n pathArray: pathArray.concat(fieldName),\n });\n if (result.issues) {\n issues.push(...result.issues);\n }\n }\n }\n break;\n }\n\n // Custom validation functions\n const validateFns = field._metadata.validate;\n if (validateFns && validateFns.length > 0) {\n for (const validateInput of validateFns) {\n const { fn, message } =\n typeof validateInput === \"function\"\n ? { fn: validateInput, message: \"Validation failed\" }\n : { fn: validateInput[0], message: validateInput[1] };\n\n if (!fn({ value, data, user })) {\n issues.push({\n message,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // Validate each array element (without array flag)\n for (let i = 0; i < value.length; i++) {\n const elementValue = value[i];\n const elementPath = pathArray.concat(`[${i}]`);\n\n // Validate element with same type but without array flag\n const elementIssues = validateValue({\n value: elementValue,\n data,\n user,\n pathArray: elementPath,\n });\n if (elementIssues.length > 0) {\n issues.push(...elementIssues);\n }\n }\n\n if (issues.length > 0) {\n return { issues };\n }\n return { value: value as FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = validateValue({ value, data, user, pathArray });\n issues.push(...valueIssues);\n\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value };\n }\n\n const field: TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n > = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n description(description: string) {\n this._metadata.description = description;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n typeName(typeName: string) {\n this._metadata.typeName = typeName;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n this._metadata.validate = validateInputs;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n };\n\n return field;\n}\n\n/**\n * Create a UUID field for resolver input/output.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example t.uuid()\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"uuid\", options);\n}\n\n/**\n * Create a string field for resolver input/output.\n * @param options - Field configuration options\n * @returns A string field\n * @example t.string()\n * @example t.string({ optional: true })\n * @example t.string({ array: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"string\", options);\n}\n\n/**\n * Create a boolean field for resolver input/output.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example t.bool()\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"boolean\", options);\n}\n\n/**\n * Create an integer field for resolver input/output.\n * @param options - Field configuration options\n * @returns An integer field\n * @example t.int()\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"integer\", options);\n}\n\n/**\n * Create a float field for resolver input/output.\n * @param options - Field configuration options\n * @returns A float field\n * @example t.float()\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"float\", options);\n}\n\n/**\n * Create a decimal field for resolver input/output (stored as string for precision).\n * @param options - Field configuration options\n * @returns A decimal field\n * @example t.decimal()\n * @example t.decimal({ optional: true })\n */\nfunction decimal<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"decimal\", options);\n}\n\n/**\n * Create a date field for resolver input/output.\n * @param options - Field configuration options\n * @returns A date field\n * @example t.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"date\", options);\n}\n\n/**\n * Create a datetime field for resolver input/output.\n * @param options - Field configuration options\n * @returns A datetime field\n * @example t.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"datetime\", options);\n}\n\n/**\n * Create a time field for resolver input/output.\n * @param options - Field configuration options\n * @returns A time field\n * @example t.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"time\", options);\n}\n\n/**\n * Create an enum field for resolver input/output.\n * @param values - Array of allowed string values\n * @param options - Field configuration options\n * @returns An enum field\n * @example t.enum([\"active\", \"inactive\"])\n */\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createTailorField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field for resolver input/output.\n * @param fields - Record of field definitions\n * @param options - Field options (optional, array)\n * @returns A nested object field\n * @example\n * // Single object:\n * output: t.object({ name: t.string(), email: t.string() })\n * @example\n * // Array of objects:\n * items: t.object({ name: t.string() }, { array: true })\n */\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createTailorField(\"nested\", options, fields) as TailorField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n return objectField;\n}\n\nexport const t = {\n uuid,\n string,\n bool,\n int,\n float,\n decimal,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n};\n","// Interfaces for module augmentation\n// Users can extend these via: declare module \"@tailor-platform/sdk\" { interface AttributeMap { ... } }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface AttributeMap {}\nexport interface AttributeList {\n __tuple?: []; // Marker for tuple type\n}\n\nexport type InferredAttributeMap = keyof AttributeMap extends never\n ? Record<string, string | string[] | boolean | boolean[] | undefined>\n : AttributeMap;\n\nexport type InferredAttributeList = AttributeList[\"__tuple\"] extends []\n ? string[]\n : AttributeList[\"__tuple\"];\n\n/** Represents a user in the Tailor platform. */\nexport type TailorUser = {\n /**\n * The ID of the user.\n * For unauthenticated users, this will be a nil UUID.\n */\n id: string;\n /**\n * The type of the user.\n * For unauthenticated users, this will be an empty string.\n */\n type: \"user\" | \"machine_user\" | \"\";\n /** The ID of the workspace the user belongs to. */\n workspaceId: string;\n /**\n * A map of the user's attributes.\n * For unauthenticated users, this will be null.\n */\n attributes: InferredAttributeMap | null;\n /**\n * A list of the user's attributes.\n * For unauthenticated users, this will be an empty array.\n */\n attributeList: InferredAttributeList;\n};\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser: TailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n};\n"],"mappings":";;;;;;;AAWA,SAAgB,iBAAiB,QAAuC;AACtE,QAAO,OAAO,KAAK,UAAU;AAC3B,MAAI,OAAO,UAAU,SACnB,QAAO;GAAE;GAAO,aAAa;GAAI;AAEnC,SAAO;GAAE,GAAG;GAAO,aAAa,MAAM,eAAe;GAAI;GACzD;;;;;ACFJ,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,UACE;CACF,SAAS;CACV;;;;;;;;;AAiHD,SAAS,kBAKP,MACA,SACA,QACA,QAIA;CACA,MAAM,YAA2B,EAAE,UAAU,MAAM;AAEnD,KAAI,SAAS;AACX,MAAI,QAAQ,aAAa,KACvB,WAAU,WAAW;AAEvB,MAAI,QAAQ,UAAU,KACpB,WAAU,QAAQ;;AAGtB,KAAI,OACF,WAAU,gBAAgB,iBAAiB,OAAO;;;;;;;CASpD,SAAS,cAAc,MAA2D;EAChF,MAAM,EAAE,OAAO,MAAM,MAAM,cAAc;EACzC,MAAM,SAAmC,EAAE;AAG3C,UAAQ,MAAR;GACE,KAAK;AACH,QAAI,OAAO,UAAU,SACnB,QAAO,KAAK;KACV,SAAS,+BAA+B,OAAO,MAAM;KACrD,MAAM,UAAU,SAAS,IAAI,YAAY;KAC1C,CAAC;AAEJ;GAEF,KAAK;AACH,QAAI,OAAO,UAAU,YAAY,CAAC,OAAO,UAAU,MAAM,CACvD,Q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+
2
+ import { n as t, t as unauthenticatedTailorUser } from "./types-B9ZMosul.mjs";
3
+
4
+ export { t };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { U as TailorDBType, rt as TailorField } from "../../plugin-CiPUxkyN.mjs";
3
- import { n as output, rt as WORKFLOW_TEST_ENV_KEY } from "../../index-CYaunQeL.mjs";
2
+ import { U as TailorDBType, rt as TailorField } from "../../plugin-D6P4g_2L.mjs";
3
+ import { n as output, rt as WORKFLOW_TEST_ENV_KEY } from "../../index-BVJQLjyN.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/mock.d.ts
@@ -1,5 +1,5 @@
1
1
 
2
- import { t as WORKFLOW_TEST_ENV_KEY } from "../../job-CPKYCk_e.mjs";
2
+ import { t as WORKFLOW_TEST_ENV_KEY } from "../../job-DkAklmE4.mjs";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import * as path from "node:path";
5
5
 
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { Nt as BuiltinIdP, S as TailorDBServiceInput, T as AuthConfig } from "./plugin-CiPUxkyN.mjs";
2
+ import { Nt as BuiltinIdP, S as TailorDBServiceInput, T as AuthConfig } from "./plugin-D6P4g_2L.mjs";
3
3
 
4
4
  //#region src/types/idp.generated.d.ts
5
5
  /**
@@ -411,4 +411,4 @@ type RetryPolicy = {
411
411
  };
412
412
  //#endregion
413
413
  export { IdpDefinitionBrand as _, ResolverExternalConfig as a, IdPGqlOperationsInput as b, WorkflowServiceConfig as c, defineStaticWebSite as d, SecretsConfig as f, IdPUserField as g, IdPExternalConfig as h, ExecutorServiceInput as i, WorkflowServiceInput as l, IdPConfig as m, AppConfig as n, ResolverServiceConfig as o, defineSecretManager as p, ExecutorServiceConfig as r, ResolverServiceInput as s, RetryPolicy as t, StaticWebsiteConfig as u, IdPEmailConfig as v, IdPInput as x, IdPGqlOperations as y };
414
- //# sourceMappingURL=workflow.generated-8BeGQsVU.d.mts.map
414
+ //# sourceMappingURL=workflow.generated-Bj_DVqGh.d.mts.map
@@ -256,9 +256,9 @@ Get a machine user token using the CLI:
256
256
  tailor-sdk machineuser token <name>
257
257
  ```
258
258
 
259
- ### Using auth.invoker()
259
+ ### Specifying a machine user invoker
260
260
 
261
- The `auth.invoker()` method creates a type-safe reference to a machine user for use in workflow triggers. This specifies which machine user's permissions should be used when executing the workflow.
261
+ Resolvers, executors, and `workflow.trigger()` accept an `authInvoker` option that chooses which machine user runs the operation. Pass the machine user name as a plain string it is type-narrowed to the names you registered in `machineUsers`.
262
262
 
263
263
  ```typescript
264
264
  // tailor.config.ts
@@ -275,7 +275,6 @@ export const auth = defineAuth("my-auth", {
275
275
  ```typescript
276
276
  // resolvers/trigger-workflow.ts
277
277
  import { createResolver, t } from "@tailor-platform/sdk";
278
- import { auth } from "../tailor.config";
279
278
  import myWorkflow from "../workflows/my-workflow";
280
279
 
281
280
  export default createResolver({
@@ -288,7 +287,7 @@ export default createResolver({
288
287
  // Trigger workflow with machine user permissions
289
288
  const workflowRunId = await myWorkflow.trigger(
290
289
  { id: input.id },
291
- { authInvoker: auth.invoker("admin-machine-user") },
290
+ { authInvoker: "admin-machine-user" },
292
291
  );
293
292
  return { workflowRunId };
294
293
  },
@@ -298,7 +297,9 @@ export default createResolver({
298
297
  });
299
298
  ```
300
299
 
301
- The `invoker()` method is type-safe and only accepts machine user names defined in the auth configuration.
300
+ Type narrowing is provided by the generated `tailor.d.ts` (the `MachineUserNameRegistry` interface). Run `tailor-sdk generate` (or `apply`) after defining new machine users to refresh it.
301
+
302
+ > **Deprecated:** The `auth.invoker("<name>")` helper is still available for backward compatibility. Prefer the string form — it does not require importing `auth` from `tailor.config.ts` into runtime files, avoiding bundling config-layer (Node-only) dependencies.
302
303
 
303
304
  ## OAuth 2.0 Clients
304
305
 
@@ -294,19 +294,10 @@ createExecutor({
294
294
 
295
295
  ### Authentication for Operations
296
296
 
297
- GraphQL and Workflow operations can specify an `authInvoker` to execute with machine user credentials:
297
+ GraphQL and Workflow operations can specify an `authInvoker` to execute with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names defined in your auth config:
298
298
 
299
299
  ```typescript
300
- import { defineAuth, createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
301
-
302
- const auth = defineAuth("my-auth", {
303
- // ... auth configuration
304
- machineUsers: {
305
- "batch-processor": {
306
- attributes: { role: "ADMIN" },
307
- },
308
- },
309
- });
300
+ import { createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
310
301
 
311
302
  export default createExecutor({
312
303
  name: "scheduled-cleanup",
@@ -314,11 +305,13 @@ export default createExecutor({
314
305
  operation: {
315
306
  kind: "graphql",
316
307
  query: `mutation { cleanupOldRecords { count } }`,
317
- authInvoker: auth.invoker("batch-processor"),
308
+ authInvoker: "batch-processor",
318
309
  },
319
310
  });
320
311
  ```
321
312
 
313
+ > **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Prefer the string form to avoid importing config-layer modules into runtime files.
314
+
322
315
  ## Event Payloads
323
316
 
324
317
  Each trigger type provides specific context data in the callback functions.
@@ -350,19 +350,10 @@ createResolver({
350
350
 
351
351
  ## Authentication
352
352
 
353
- Specify an `authInvoker` to execute the resolver with machine user credentials:
353
+ Specify an `authInvoker` to execute the resolver with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names you defined in your auth config:
354
354
 
355
355
  ```typescript
356
- import { defineAuth, createResolver, t } from "@tailor-platform/sdk";
357
-
358
- const auth = defineAuth("my-auth", {
359
- // ... auth configuration
360
- machineUsers: {
361
- "batch-processor": {
362
- attributes: { role: "ADMIN" },
363
- },
364
- },
365
- });
356
+ import { createResolver, t } from "@tailor-platform/sdk";
366
357
 
367
358
  export default createResolver({
368
359
  name: "adminQuery",
@@ -372,10 +363,12 @@ export default createResolver({
372
363
  // Executes as "batch-processor" machine user
373
364
  return { result: "ok" };
374
365
  },
375
- authInvoker: auth.invoker("batch-processor"),
366
+ authInvoker: "batch-processor",
376
367
  });
377
368
  ```
378
369
 
379
- The `authInvoker` option accepts the return value of `auth.invoker()`, which specifies the auth namespace and machine user name.
370
+ The machine user name is looked up in the auth service configured on your app (`machineUsers` in `defineAuth`). The namespace is resolved automatically — no need to import `auth` from `tailor.config.ts` in resolver files.
371
+
372
+ > **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Importing `auth` into runtime files pulls config-layer (Node-only) dependencies into the bundle.
380
373
 
381
374
  **Note:** `authInvoker` controls the permissions for database operations and other platform actions, but the `user` object passed to the `body` function still reflects the original caller who invoked the resolver.
@@ -227,11 +227,10 @@ export default createWorkflow({
227
227
  You can start a workflow execution from a resolver using `workflow.trigger()`.
228
228
 
229
229
  - `workflow.trigger(args, options?)` returns a workflow run ID (`Promise<string>`).
230
- - To run with machine-user permissions, pass `{ authInvoker: auth.invoker("<machine-user>") }`.
230
+ - To run with machine-user permissions, pass `{ authInvoker: "<machine-user>" }`. The name is type-narrowed to the machine users defined in your auth config.
231
231
 
232
232
  ```typescript
233
233
  import { createResolver, t } from "@tailor-platform/sdk";
234
- import { auth } from "../tailor.config";
235
234
  import orderProcessingWorkflow from "../workflows/order-processing";
236
235
 
237
236
  export default createResolver({
@@ -244,7 +243,7 @@ export default createResolver({
244
243
  body: async ({ input }) => {
245
244
  const workflowRunId = await orderProcessingWorkflow.trigger(
246
245
  { orderId: input.orderId, customerId: input.customerId },
247
- { authInvoker: auth.invoker("manager-machine-user") },
246
+ { authInvoker: "manager-machine-user" },
248
247
  );
249
248
 
250
249
  return { workflowRunId };
@@ -255,6 +254,8 @@ export default createResolver({
255
254
  });
256
255
  ```
257
256
 
257
+ > **Deprecated:** `auth.invoker("manager-machine-user")` still works but is deprecated. Using the string form avoids importing `auth` into runtime code.
258
+
258
259
  See the full working example in the repository: [example/resolvers/triggerWorkflow.ts](../../../../example/resolvers/triggerWorkflow.ts).
259
260
 
260
261
  ## File Organization
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.36.0",
3
+ "version": "1.37.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -82,7 +82,7 @@
82
82
  "@connectrpc/connect": "2.1.1",
83
83
  "@connectrpc/connect-node": "2.1.1",
84
84
  "@inquirer/core": "11.1.8",
85
- "@inquirer/prompts": "8.4.0",
85
+ "@inquirer/prompts": "8.4.1",
86
86
  "@jridgewell/trace-mapping": "0.3.31",
87
87
  "@liam-hq/cli": "0.7.24",
88
88
  "@napi-rs/keyring": "1.2.0",
@@ -117,7 +117,7 @@
117
117
  "pgsql-ast-parser": "12.0.2",
118
118
  "pkg-types": "2.3.0",
119
119
  "politty": "0.4.13",
120
- "rolldown": "1.0.0-rc.13",
120
+ "rolldown": "1.0.0-rc.15",
121
121
  "semver": "7.7.4",
122
122
  "serve": "14.2.6",
123
123
  "std-env": "4.0.0",
@@ -146,7 +146,7 @@
146
146
  "sonda": "0.11.1",
147
147
  "tsdown": "0.21.7",
148
148
  "typescript": "5.9.3",
149
- "typescript-eslint": "8.58.0",
149
+ "typescript-eslint": "8.58.1",
150
150
  "vitest": "4.1.2",
151
151
  "zinfer": "0.1.7"
152
152
  },
@@ -1,4 +0,0 @@
1
-
2
- import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-BwboBFcU.mjs";
3
-
4
- export { defineApplication };