@tailor-platform/sdk 1.40.1 → 1.43.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 (46) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +23 -0
  3. package/dist/{actor-B2oEmlTc.d.mts → actor-DzCuoMlP.d.mts} +2 -2
  4. package/dist/{application-EvhIIVg0.mjs → application-DQpD_kHR.mjs} +87 -8
  5. package/dist/application-DQpD_kHR.mjs.map +1 -0
  6. package/dist/application-DUcmoFdc.mjs +4 -0
  7. package/dist/brand-Ll48SMXe.mjs.map +1 -1
  8. package/dist/cli/index.mjs +31 -26
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.d.mts +49 -7
  11. package/dist/cli/lib.mjs +3 -3
  12. package/dist/cli/lib.mjs.map +1 -1
  13. package/dist/configure/index.d.mts +5 -5
  14. package/dist/configure/index.mjs +83 -3
  15. package/dist/configure/index.mjs.map +1 -1
  16. package/dist/{index-Chvw1Eod.d.mts → index-0Dk-fDWi.d.mts} +2 -2
  17. package/dist/{index-CiNNNpuH.d.mts → index-BEEL1-6Z.d.mts} +2 -2
  18. package/dist/{index-D_ezppY7.d.mts → index-Br4XCvX1.d.mts} +103 -86
  19. package/dist/{index-BtXZdz-F.d.mts → index-DdsUV-aA.d.mts} +2 -2
  20. package/dist/{index-reFAYSX7.d.mts → index-ZZYEd_0R.d.mts} +2 -2
  21. package/dist/{job-p6zf8Qpg.mjs → job-BOvKyNdT.mjs} +15 -9
  22. package/dist/job-BOvKyNdT.mjs.map +1 -0
  23. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  24. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  25. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  26. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  27. package/dist/plugin/index.d.mts +2 -2
  28. package/dist/{runtime-B9R1TzLD.mjs → runtime-Bn68JXnL.mjs} +195 -77
  29. package/dist/runtime-Bn68JXnL.mjs.map +1 -0
  30. package/dist/{tailor-db-field-CoFKRCYW.d.mts → tailor-db-field-D_z185oq.d.mts} +36 -6
  31. package/dist/utils/test/index.d.mts +36 -3
  32. package/dist/utils/test/index.mjs +78 -9
  33. package/dist/utils/test/index.mjs.map +1 -1
  34. package/dist/{workflow.generated-Btz6srLR.d.mts → workflow.generated-CDCnZNkH.d.mts} +2 -2
  35. package/docs/cli/function.md +83 -1
  36. package/docs/cli-reference.md +3 -1
  37. package/docs/services/executor.md +4 -0
  38. package/docs/services/idp.md +16 -0
  39. package/docs/services/resolver.md +4 -2
  40. package/docs/services/workflow.md +117 -3
  41. package/docs/testing.md +95 -7
  42. package/package.json +17 -17
  43. package/dist/application-CE2s_a6w.mjs +0 -4
  44. package/dist/application-EvhIIVg0.mjs.map +0 -1
  45. package/dist/job-p6zf8Qpg.mjs.map +0 -1
  46. package/dist/runtime-B9R1TzLD.mjs.map +0 -1
@@ -1,8 +1,7 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonValue, K as UserAttributeMap, Kt as Prettify, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, Ut as InferFieldsOutput, V as DefinedAuth, Vt as TailorUser, Wt as JsonCompatible, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as output$1, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-CoFKRCYW.mjs";
3
- import { D as TailorDBType, E as TailorDBInstance, F as AllowedValuesOutput, P as AllowedValues, S as IdPInput, _ as IdPUserField, d as StaticWebsiteDefinitionBrand, f as StaticWebsiteInput, m as SecretsDefinitionBrand, n as AppConfig, t as RetryPolicy, v as IdpDefinitionBrand } from "./workflow.generated-Btz6srLR.mjs";
4
- import { r as TailorEnv, t as TailorActor } from "./actor-B2oEmlTc.mjs";
5
- import { JsonPrimitive, Jsonifiable, Jsonify } from "type-fest";
2
+ import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonCompatible, Ht as TailorUser, Jt as output$1, K as UserAttributeMap, Kt as JsonValue, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, V as DefinedAuth, Vt as TailorInvoker, Wt as InferFieldsOutput, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as Prettify, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-D_z185oq.mjs";
3
+ import { D as TailorDBType, E as TailorDBInstance, F as AllowedValuesOutput, P as AllowedValues, S as IdPInput, _ as IdPUserField, d as StaticWebsiteDefinitionBrand, f as StaticWebsiteInput, m as SecretsDefinitionBrand, n as AppConfig, t as RetryPolicy, v as IdpDefinitionBrand } from "./workflow.generated-CDCnZNkH.mjs";
4
+ import { r as TailorEnv, t as TailorActor } from "./actor-DzCuoMlP.mjs";
6
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
7
6
  import { Client } from "@urql/core";
8
7
  import { StandardCRON } from "ts-cron-validator";
@@ -132,6 +131,7 @@ declare function defineAuth<const Name extends string, const MachineUserAttribut
132
131
  type Context<Input extends Record<string, TailorAnyField> | undefined> = {
133
132
  input: Input extends Record<string, TailorAnyField> ? InferFieldsOutput<Input> : never;
134
133
  user: TailorUser;
134
+ invoker?: TailorInvoker;
135
135
  env: TailorEnv;
136
136
  };
137
137
  type OutputType<O> = O extends TailorAnyField ? output$1<O> : O extends Record<string, TailorAnyField> ? InferFieldsOutput<O> : never;
@@ -154,7 +154,7 @@ type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Ou
154
154
  * Create a resolver definition for the Tailor SDK.
155
155
  *
156
156
  * The `body` function receives a context with `input` (typed from `config.input`),
157
- * `user` (TailorUser with id, type, workspaceId, attributes, attributeList), and `env` (TailorEnv).
157
+ * `user`, `invoker` (reflects `authInvoker` delegation), and `env`.
158
158
  * The return value of `body` must match the `output` type.
159
159
  *
160
160
  * `output` accepts either a single TailorField (e.g. `t.string()`) or a
@@ -205,33 +205,21 @@ type QueryType = Resolver["operation"];
205
205
  */
206
206
  type WorkflowJobContext = {
207
207
  env: TailorEnv;
208
+ invoker?: TailorInvoker;
208
209
  };
209
210
  /**
210
- * Allowed output types for workflow job body functions.
211
- * Includes Jsonifiable (JSON-serializable values including objects with toJSON like Date),
212
- * undefined, and void.
211
+ * The body function type for a workflow job.
212
+ * Resolves to the callable signature when `I` / `O` are JsonValue-compatible,
213
+ * or to a template-literal error string that surfaces at the `body:` property.
213
214
  */
214
- type WorkflowJobOutput = Jsonifiable | undefined | void;
215
- /**
216
- * Convert output type to what trigger returns after JSON serialization.
217
- * - Jsonifiable values are converted via Jsonify (Date -> string, etc.)
218
- * - undefined remains undefined
219
- * - void becomes void
220
- */
221
- type JsonifyOutput<T> = T extends Jsonifiable ? Jsonify<T> : T;
222
- /**
223
- * Input type constraint for workflow jobs.
224
- * Accepts any type that is JSON-compatible (primitives, arrays, objects with JSON-compatible values).
225
- * Excludes objects with toJSON method (like Date) since they won't be serialized in input.
226
- */
227
- type WorkflowJobInput = undefined | JsonCompatible<unknown>;
215
+ type JobBody<I, O> = [null] extends [I] ? "ERROR: Input cannot be null at the top level" : [I] extends [undefined] ? [O] extends [JsonCompatible<O> | undefined | void] ? (input: I, context: WorkflowJobContext) => O | Promise<O> : "ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)" : [undefined] extends [I] ? "ERROR: Input cannot include undefined at the top level" : [I] extends [JsonCompatible<I>] ? [O] extends [JsonCompatible<O> | undefined | void] ? (input: I, context: WorkflowJobContext) => O | Promise<O> : "ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)" : "ERROR: Input must be JsonValue-compatible (plain objects/arrays; no class instances or functions)";
228
216
  /**
229
217
  * WorkflowJob represents a job that can be triggered in a workflow.
230
218
  *
231
219
  * Type constraints:
232
- * - Input: Must be JSON-compatible (no Date/toJSON objects) or undefined. Interfaces are allowed.
233
- * - Output: Must be Jsonifiable, undefined, or void
234
- * - Trigger returns Jsonify<Output> (Date becomes string after JSON.stringify)
220
+ * - Input: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions) or undefined.
221
+ * - Output: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions), undefined, or void.
222
+ * - Trigger returns `Awaited<Output>` as-is (no Jsonify transformation).
235
223
  */
236
224
  interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {
237
225
  name: Name;
@@ -241,8 +229,6 @@ interface WorkflowJob<Name extends string = string, Input = undefined, Output =
241
229
  * During bundling, calls to .trigger() are transformed to
242
230
  * tailor.workflow.triggerJobFunction("<job-name>", args).
243
231
  *
244
- * Returns Jsonify<Output> because the value passes through JSON.stringify.
245
- *
246
232
  * Inside a workflow job body, .trigger() calls are transformed by the bundler
247
233
  * into synchronous `triggerJobFunction` calls. You may use `await` for
248
234
  * readability — the bundler strips it automatically at build time.
@@ -254,69 +240,31 @@ interface WorkflowJob<Name extends string = string, Input = undefined, Output =
254
240
  * return { a, b };
255
241
  * }
256
242
  */
257
- trigger: [Input] extends [undefined] ? () => Promise<JsonifyOutput<Awaited<Output>>> : (input: Input) => Promise<JsonifyOutput<Awaited<Output>>>;
243
+ trigger: [Input] extends [undefined] ? () => Promise<Awaited<Output>> : (input: Input) => Promise<Awaited<Output>>;
258
244
  body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;
259
245
  }
260
- /**
261
- * Helper type to check if all property types are valid.
262
- * Uses -? to remove optional modifiers so all properties are treated uniformly.
263
- */
264
- type AllPropertiesValid<T> = { [K in keyof T]-?: IsValidInput<T[K]> extends true ? true : false }[keyof T] extends true ? true : false;
265
- /**
266
- * Check if a type contains any non-JSON-compatible values.
267
- * Returns `true` if the type is valid for input, `false` otherwise.
268
- *
269
- * Accepts:
270
- * - JSON primitives (string, number, boolean, null)
271
- * - undefined
272
- * - Optional primitives (e.g., string | undefined)
273
- * - Arrays of valid types
274
- * - Objects with valid field types
275
- *
276
- * Rejects:
277
- * - Objects with toJSON methods (like Date)
278
- * - Other non-JSON-serializable types
279
- */
280
- type IsValidInput<T> = T extends undefined ? true : T extends JsonPrimitive ? true : T extends readonly (infer U)[] ? IsValidInput<U> : T extends object ? T extends {
281
- toJSON: () => unknown;
282
- } ? false : AllPropertiesValid<T> : false;
283
- /**
284
- * Helper type to check if all property types are valid for output.
285
- * Uses -? to remove optional modifiers so all properties are treated uniformly.
286
- */
287
- type AllPropertiesValidOutput<T> = { [K in keyof T]-?: IsValidOutput<T[K]> extends true ? true : false }[keyof T] extends true ? true : false;
288
- /**
289
- * Check if a type is valid for output.
290
- * Returns `true` if the type is valid, `false` otherwise.
291
- *
292
- * Accepts:
293
- * - JSON primitives (string, number, boolean, null)
294
- * - undefined and void
295
- * - Optional primitives (e.g., string | undefined)
296
- * - Jsonifiable types (Date, objects with toJSON)
297
- * - Arrays of valid types
298
- * - Objects with valid field types
299
- */
300
- type IsValidOutput<T> = T extends undefined | void ? true : T extends JsonPrimitive ? true : T extends readonly (infer U)[] ? IsValidOutput<U> : T extends object ? AllPropertiesValidOutput<T> : false;
301
- /**
302
- * Body function type with conditional constraint.
303
- * If input contains invalid types (like Date), the body type becomes `never` to cause an error.
304
- */
305
- type WorkflowJobBody<I, O> = IsValidInput<I> extends true ? IsValidOutput<O> extends true ? (input: I, context: WorkflowJobContext) => O | Promise<O> : never : never;
306
246
  /**
307
247
  * Environment variable key for workflow testing.
308
248
  * Contains JSON-serialized TailorEnv object.
309
249
  */
310
250
  declare const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
251
+ interface CreateWorkflowJobConfig<Name extends string, I, O> {
252
+ readonly name: Name;
253
+ readonly body: JobBody<I, O>;
254
+ }
311
255
  /**
312
256
  * Create a workflow job definition.
313
257
  *
314
258
  * All jobs must be named exports from the workflow file.
315
259
  * Job names must be unique across the entire project.
316
- * @param config - Job configuration with name and body function
317
- * @param config.name - Unique job name across the project
318
- * @param config.body - Async function that processes the job input
319
- * @returns A WorkflowJob that can be triggered from other jobs
260
+ *
261
+ * Input and output must be JsonValue-compatible (primitives, plain objects, arrays).
262
+ * Functions and objects with a `toJSON` method are rejected at the type level;
263
+ * class instances exposing methods are rejected via the property walk.
264
+ * @param config - Job configuration with name and body function.
265
+ * @param config.name - Unique job name across the project.
266
+ * @param config.body - Async function that processes the job input.
267
+ * @returns A WorkflowJob that can be triggered from other jobs.
320
268
  * @example
321
269
  * // Simple job with async body:
322
270
  * export const fetchData = createWorkflowJob({
@@ -338,10 +286,7 @@ declare const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
338
286
  * },
339
287
  * });
340
288
  */
341
- declare const createWorkflowJob: <const Name extends string, I = undefined, O = undefined>(config: {
342
- readonly name: Name;
343
- readonly body: WorkflowJobBody<I, O>;
344
- }) => WorkflowJob<Name, I, Awaited<O>>;
289
+ declare const createWorkflowJob: <const Name extends string, I = undefined, O = undefined>(config: CreateWorkflowJobConfig<Name, I, O>) => WorkflowJob<Name, I, Awaited<O>>;
345
290
  //#endregion
346
291
  //#region src/configure/services/workflow/workflow.d.ts
347
292
  interface WorkflowConfig<Job extends WorkflowJob<any, any, any> = WorkflowJob<any, any, any>> {
@@ -390,9 +335,11 @@ interface WorkflowDefinition<Job extends WorkflowJob<any, any, any>> {
390
335
  declare function createWorkflow<Job extends WorkflowJob<any, any, any>>(config: WorkflowDefinition<Job>): Workflow<Job>;
391
336
  //#endregion
392
337
  //#region src/configure/services/executor/operation.d.ts
393
- /** Function-based executor operation. The body receives the trigger args. */
338
+ /** Function-based executor operation. The body receives the trigger args and the `invoker`. */
394
339
  type FunctionOperation<Args> = Omit<FunctionOperation$1, "body" | "authInvoker"> & {
395
- body: (args: Args) => void | Promise<void>;
340
+ body: (args: Args & {
341
+ invoker?: TailorInvoker;
342
+ }) => void | Promise<void>;
396
343
  authInvoker?: AuthInvoker<string> | MachineUserName;
397
344
  };
398
345
  type UrqlOperationArgs = Parameters<Client["query"] | Client["mutation"]>;
@@ -803,6 +750,76 @@ declare function createExecutor<Args, O extends Operation<Args> | {
803
750
  workflow: Workflow;
804
751
  }>(config: Executor<Trigger<Args>, O>): Executor<Trigger<Args>, O>;
805
752
  //#endregion
753
+ //#region src/configure/services/workflow/wait-point.d.ts
754
+ /**
755
+ * A single wait point instance with typed `.wait()` and `.resolve()` methods.
756
+ *
757
+ * - `.wait(payload?)` suspends execution until resolved. Returns the result from `.resolve()`.
758
+ * - `.resolve(executionId, callback)` resumes a suspended execution.
759
+ *
760
+ * Both `Payload` and `Result` must be JsonValue-compatible (primitives, plain objects, arrays).
761
+ * Functions and objects with a `toJSON` method are rejected at the type level.
762
+ */
763
+ interface WaitPointInstance<Payload = undefined, Result = undefined> {
764
+ wait: [Payload] extends [undefined] ? () => Promise<Result> : (payload: Payload) => Promise<Result>;
765
+ resolve: (executionId: string, callback: (payload: [Payload] extends [undefined] ? undefined : Payload) => Result | Promise<Result>) => Promise<void>;
766
+ }
767
+ /**
768
+ * The type produced by `define<Payload, Result>()` / `defineWaitPoint<Payload, Result>(key)`.
769
+ * Resolves to `WaitPointInstance<Payload, Result>` when both types are JsonValue-compatible,
770
+ * or to a template-literal error string that surfaces at the call site.
771
+ */
772
+ type WaitPointDef<Payload, Result> = [null] extends [Payload] ? "ERROR: Payload cannot be null at the top level" : [undefined] extends [Result] ? "ERROR: Result cannot be (or include) undefined (resolve callback must return a value)" : [Payload] extends [undefined] ? [Result] extends [JsonCompatible<Result>] ? WaitPointInstance<Payload, Result> : "ERROR: Result must be JsonValue-compatible (plain objects/arrays; no class instances or functions)" : [undefined] extends [Payload] ? "ERROR: Payload cannot include undefined at the top level" : [Payload] extends [JsonCompatible<Payload>] ? [Result] extends [JsonCompatible<Result>] ? WaitPointInstance<Payload, Result> : "ERROR: Result must be JsonValue-compatible (plain objects/arrays; no class instances or functions)" : "ERROR: Payload must be JsonValue-compatible (plain objects/arrays; no class instances or functions)";
773
+ /**
774
+ * The `define` function passed to the `defineWaitPoints` builder callback.
775
+ * Returns an actual WaitPointInstance (not a phantom marker) so that the
776
+ * builder's return type can flow through as-is, preserving JSDoc comments
777
+ * on each property for IDE autocompletion.
778
+ *
779
+ * JSON validation is encoded in the return type rather than in type-parameter
780
+ * constraints, because tsgo rejects self-referential constraints like
781
+ * `Payload extends JsonCompatible<Payload>` as circular.
782
+ */
783
+ type DefineFn = <Payload = undefined, Result = undefined>() => WaitPointDef<Payload, Result>;
784
+ /**
785
+ * Define a single typed wait point with an explicit key.
786
+ *
787
+ * `Payload` and `Result` must be JsonValue-compatible.
788
+ * Functions and objects with a `toJSON` method are rejected at the type level;
789
+ * class instances exposing methods are rejected via the property walk.
790
+ * @param key - The wait point key used to match wait and resolve calls
791
+ * @returns A WaitPointInstance with typed `.wait()` and `.resolve()` methods
792
+ * @example
793
+ * export const approval = defineWaitPoint<{ message: string }, { approved: boolean }>("approval");
794
+ *
795
+ * await approval.wait({ message: "Please approve" });
796
+ */
797
+ declare function defineWaitPoint<Payload = undefined, Result = undefined>(key: string): WaitPointDef<Payload, Result>;
798
+ /**
799
+ * Define a group of typed wait points for human-in-the-loop workflows.
800
+ * Property names become the wait point keys.
801
+ *
802
+ * The return type is the same as the builder's return type, so JSDoc on each
803
+ * property is preserved and visible in IDE autocompletion.
804
+ *
805
+ * `Payload` and `Result` must be JsonValue-compatible.
806
+ * Functions and objects with a `toJSON` method are rejected at the type level;
807
+ * class instances exposing methods are rejected via the property walk.
808
+ * @param builder - Callback that receives a `define` factory and returns an object of wait points
809
+ * @returns The same object returned by the builder (with correct keys set on each instance)
810
+ * @example
811
+ * export const waitPoints = defineWaitPoints(define => ({
812
+ * // Preceding JSDoc on this property is shown in IDE autocompletion
813
+ * approval: define<{ message: string }, { approved: boolean }>(),
814
+ * }));
815
+ *
816
+ * // IDE shows the JSDoc when typing `waitPoints.`
817
+ * await waitPoints.approval.wait({ message: "Please approve" });
818
+ *
819
+ * // For 2-level access, use destructured export with JSDoc attached to the export itself.
820
+ */
821
+ declare function defineWaitPoints<T extends Record<string, WaitPointInstance<any, any>>>(builder: (define: DefineFn) => T): T;
822
+ //#endregion
806
823
  //#region src/configure/services/staticwebsite/index.d.ts
807
824
  /**
808
825
  * Define a static website configuration for the Tailor SDK.
@@ -1075,5 +1092,5 @@ declare namespace t {
1075
1092
  type infer<T> = TailorOutput<T>;
1076
1093
  }
1077
1094
  //#endregion
1078
- export { resolverExecutedTrigger as $, IdpUserArgs as A, TailorDBTrigger as B, ScheduleTrigger as C, AuthAccessTokenRefreshedArgs as D, AuthAccessTokenIssuedArgs as E, RecordCreatedArgs as F, idpUserCreatedTrigger as G, authAccessTokenRefreshedTrigger as H, RecordDeletedArgs as I, idpUserUpdatedTrigger as J, idpUserDeletedTrigger as K, RecordUpdatedArgs as L, IdpUserDeletedArgs as M, IdpUserTrigger as N, AuthAccessTokenRevokedArgs as O, IdpUserUpdatedArgs as P, recordUpdatedTrigger as Q, ResolverExecutedArgs as R, ScheduleArgs as S, AuthAccessTokenArgs as T, authAccessTokenRevokedTrigger as U, authAccessTokenIssuedTrigger as V, authAccessTokenTrigger as W, recordDeletedTrigger as X, recordCreatedTrigger as Y, recordTrigger as Z, IncomingWebhookResponse as _, defineAuth as _t, defineGenerators as a, Workflow as at, IncomingWebhookTriggerOptions as b, MachineUserNameRegistry as bt, defineIdp as c, WORKFLOW_TEST_ENV_KEY as ct, unsafeAllowAllIdPPermission as d, WorkflowJobInput as dt, FunctionOperation as et, defineStaticWebSite as f, WorkflowJobOutput as ft, IncomingWebhookRequest as g, AuthInvoker as gt, IncomingWebhookArgs as h, createResolver as ht, defineConfig as i, WorkflowOperation as it, IdpUserCreatedArgs as j, AuthAccessTokenTrigger as k, IdPPermission as l, WorkflowJob as lt, Trigger as m, QueryType as mt, output as n, Operation as nt, definePlugins as o, WorkflowConfig as ot, createExecutor as p, createWorkflowJob as pt, idpUserTrigger as q, t as r, WebhookOperation as rt, defineSecretManager as s, createWorkflow as st, infer as t, GqlOperation as tt, IdPPermissionCondition as u, WorkflowJobContext as ut, IncomingWebhookResponseConfig as v, TailorField as vt, scheduleTrigger as w, incomingWebhookTrigger as x, IncomingWebhookTrigger as y, MachineUserName as yt, ResolverExecutedTrigger as z };
1079
- //# sourceMappingURL=index-D_ezppY7.d.mts.map
1095
+ export { recordDeletedTrigger as $, AuthAccessTokenRefreshedArgs as A, RecordUpdatedArgs as B, IncomingWebhookTriggerOptions as C, scheduleTrigger as D, ScheduleTrigger as E, IdpUserDeletedArgs as F, authAccessTokenRefreshedTrigger as G, ResolverExecutedTrigger as H, IdpUserTrigger as I, idpUserCreatedTrigger as J, authAccessTokenRevokedTrigger as K, IdpUserUpdatedArgs as L, AuthAccessTokenTrigger as M, IdpUserArgs as N, AuthAccessTokenArgs as O, IdpUserCreatedArgs as P, recordCreatedTrigger as Q, RecordCreatedArgs as R, IncomingWebhookTrigger as S, ScheduleArgs as T, TailorDBTrigger as U, ResolverExecutedArgs as V, authAccessTokenIssuedTrigger as W, idpUserTrigger as X, idpUserDeletedTrigger as Y, idpUserUpdatedTrigger as Z, Trigger as _, AuthInvoker as _t, defineGenerators as a, Operation as at, IncomingWebhookResponse as b, MachineUserName as bt, defineIdp as c, Workflow as ct, unsafeAllowAllIdPPermission as d, WORKFLOW_TEST_ENV_KEY as dt, recordTrigger as et, defineStaticWebSite as f, WorkflowJob as ft, createExecutor as g, createResolver as gt, defineWaitPoints as h, QueryType as ht, defineConfig as i, GqlOperation as it, AuthAccessTokenRevokedArgs as j, AuthAccessTokenIssuedArgs as k, IdPPermission as l, WorkflowConfig as lt, defineWaitPoint as m, createWorkflowJob as mt, output as n, resolverExecutedTrigger as nt, definePlugins as o, WebhookOperation as ot, WaitPointInstance as p, WorkflowJobContext as pt, authAccessTokenTrigger as q, t as r, FunctionOperation as rt, defineSecretManager as s, WorkflowOperation as st, infer as t, recordUpdatedTrigger as tt, IdPPermissionCondition as u, createWorkflow as ut, IncomingWebhookArgs as v, defineAuth as vt, incomingWebhookTrigger as w, IncomingWebhookResponseConfig as x, MachineUserNameRegistry as xt, IncomingWebhookRequest as y, TailorField as yt, RecordDeletedArgs as z };
1096
+ //# sourceMappingURL=index-Br4XCvX1.d.mts.map
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { o as Plugin } from "./tailor-db-field-CoFKRCYW.mjs";
2
+ import { o as Plugin } from "./tailor-db-field-D_z185oq.mjs";
3
3
 
4
4
  //#region src/plugin/builtin/file-utils/index.d.ts
5
5
  /** Unique identifier for the file utilities generator plugin. */
@@ -16,4 +16,4 @@ type FileUtilsPluginOptions = {
16
16
  declare function fileUtilsPlugin(options: FileUtilsPluginOptions): Plugin<unknown, FileUtilsPluginOptions>;
17
17
  //#endregion
18
18
  export { fileUtilsPlugin as n, FileUtilsGeneratorID as t };
19
- //# sourceMappingURL=index-BtXZdz-F.d.mts.map
19
+ //# sourceMappingURL=index-DdsUV-aA.d.mts.map
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { o as Plugin } from "./tailor-db-field-CoFKRCYW.mjs";
2
+ import { o as Plugin } from "./tailor-db-field-D_z185oq.mjs";
3
3
 
4
4
  //#region src/plugin/builtin/enum-constants/index.d.ts
5
5
  /** Unique identifier for the enum constants generator plugin. */
@@ -16,4 +16,4 @@ type EnumConstantsPluginOptions = {
16
16
  declare function enumConstantsPlugin(options: EnumConstantsPluginOptions): Plugin<unknown, EnumConstantsPluginOptions>;
17
17
  //#endregion
18
18
  export { enumConstantsPlugin as n, EnumConstantsGeneratorID as t };
19
- //# sourceMappingURL=index-reFAYSX7.d.mts.map
19
+ //# sourceMappingURL=index-ZZYEd_0R.d.mts.map
@@ -12,10 +12,14 @@ const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
12
12
  *
13
13
  * All jobs must be named exports from the workflow file.
14
14
  * Job names must be unique across the entire project.
15
- * @param config - Job configuration with name and body function
16
- * @param config.name - Unique job name across the project
17
- * @param config.body - Async function that processes the job input
18
- * @returns A WorkflowJob that can be triggered from other jobs
15
+ *
16
+ * Input and output must be JsonValue-compatible (primitives, plain objects, arrays).
17
+ * Functions and objects with a `toJSON` method are rejected at the type level;
18
+ * class instances exposing methods are rejected via the property walk.
19
+ * @param config - Job configuration with name and body function.
20
+ * @param config.name - Unique job name across the project.
21
+ * @param config.body - Async function that processes the job input.
22
+ * @returns A WorkflowJob that can be triggered from other jobs.
19
23
  * @example
20
24
  * // Simple job with async body:
21
25
  * export const fetchData = createWorkflowJob({
@@ -38,17 +42,19 @@ const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
38
42
  * });
39
43
  */
40
44
  const createWorkflowJob = (config) => {
45
+ const body = config.body;
41
46
  return brandValue({
42
47
  name: config.name,
43
48
  trigger: async (args) => {
44
- const env = JSON.parse(process.env["TAILOR_TEST_WORKFLOW_ENV"] || "{}");
45
- const result = await config.body(args, { env });
46
- return result ? JSON.parse(JSON.stringify(result)) : result;
49
+ return await body(args, {
50
+ env: JSON.parse(process.env["TAILOR_TEST_WORKFLOW_ENV"] || "{}"),
51
+ invoker: null
52
+ });
47
53
  },
48
- body: config.body
54
+ body
49
55
  }, "workflow-job");
50
56
  };
51
57
 
52
58
  //#endregion
53
59
  export { createWorkflowJob as n, WORKFLOW_TEST_ENV_KEY as t };
54
- //# sourceMappingURL=job-p6zf8Qpg.mjs.map
60
+ //# sourceMappingURL=job-BOvKyNdT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-BOvKyNdT.mjs","names":[],"sources":["../src/configure/services/workflow/job.ts"],"sourcesContent":["import { brandValue } from \"@/utils/brand\";\nimport type { TailorEnv } from \"@/types/env\";\nimport type { JsonCompatible } from \"@/types/helpers\";\nimport type { TailorInvoker } from \"@/types/user\";\n\n/**\n * Context object passed as the second argument to workflow job body functions.\n */\nexport type WorkflowJobContext = {\n env: TailorEnv;\n invoker?: TailorInvoker;\n};\n\n/**\n * The body function type for a workflow job.\n * Resolves to the callable signature when `I` / `O` are JsonValue-compatible,\n * or to a template-literal error string that surfaces at the `body:` property.\n */\ntype JobBody<I, O> = [null] extends [I]\n ? \"ERROR: Input cannot be null at the top level\"\n : [I] extends [undefined]\n ? [O] extends [JsonCompatible<O> | undefined | void]\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : \"ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\"\n : [undefined] extends [I]\n ? \"ERROR: Input cannot include undefined at the top level\"\n : [I] extends [JsonCompatible<I>]\n ? [O] extends [JsonCompatible<O> | undefined | void]\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : \"ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\"\n : \"ERROR: Input must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\";\n\n/**\n * WorkflowJob represents a job that can be triggered in a workflow.\n *\n * Type constraints:\n * - Input: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions) or undefined.\n * - Output: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions), undefined, or void.\n * - Trigger returns `Awaited<Output>` as-is (no Jsonify transformation).\n */\nexport interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {\n name: Name;\n /**\n * Trigger this job with the given input.\n * At runtime, this is a placeholder that calls the body function.\n * During bundling, calls to .trigger() are transformed to\n * tailor.workflow.triggerJobFunction(\"<job-name>\", args).\n *\n * Inside a workflow job body, .trigger() calls are transformed by the bundler\n * into synchronous `triggerJobFunction` calls. You may use `await` for\n * readability — the bundler strips it automatically at build time.\n * @example\n * // Both styles work — await is stripped by the bundler:\n * body: async (input) => {\n * const a = await jobA.trigger({ id: input.id });\n * const b = await jobB.trigger({ id: input.id });\n * return { a, b };\n * }\n */\n trigger: [Input] extends [undefined]\n ? () => Promise<Awaited<Output>>\n : (input: Input) => Promise<Awaited<Output>>;\n body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;\n}\n\n/**\n * Environment variable key for workflow testing.\n * Contains JSON-serialized TailorEnv object.\n */\nexport const WORKFLOW_TEST_ENV_KEY = \"TAILOR_TEST_WORKFLOW_ENV\";\n\ninterface CreateWorkflowJobConfig<Name extends string, I, O> {\n readonly name: Name;\n readonly body: JobBody<I, O>;\n}\n\n/**\n * Create a workflow job definition.\n *\n * All jobs must be named exports from the workflow file.\n * Job names must be unique across the entire project.\n *\n * Input and output must be JsonValue-compatible (primitives, plain objects, arrays).\n * Functions and objects with a `toJSON` method are rejected at the type level;\n * class instances exposing methods are rejected via the property walk.\n * @param config - Job configuration with name and body function.\n * @param config.name - Unique job name across the project.\n * @param config.body - Async function that processes the job input.\n * @returns A WorkflowJob that can be triggered from other jobs.\n * @example\n * // Simple job with async body:\n * export const fetchData = createWorkflowJob({\n * name: \"fetch-data\",\n * body: async (input: { id: string }) => {\n * const db = getDB(\"tailordb\");\n * return await db.selectFrom(\"Table\").selectAll().where(\"id\", \"=\", input.id).executeTakeFirst();\n * },\n * });\n * @example\n * // Orchestrator job that fans out to other jobs.\n * // await is optional — the bundler strips it at build time.\n * export const orchestrate = createWorkflowJob({\n * name: \"orchestrate\",\n * body: async (input: { orderId: string }) => {\n * const inventory = await checkInventory.trigger({ orderId: input.orderId });\n * const payment = await processPayment.trigger({ orderId: input.orderId });\n * return { inventory, payment };\n * },\n * });\n */\nexport const createWorkflowJob = <const Name extends string, I = undefined, O = undefined>(\n config: CreateWorkflowJobConfig<Name, I, O>,\n): WorkflowJob<Name, I, Awaited<O>> => {\n const body = config.body as (input: I, context: WorkflowJobContext) => O | Promise<O>;\n return brandValue(\n {\n name: config.name,\n trigger: async (args?: unknown) => {\n const env: TailorEnv = JSON.parse(process.env[WORKFLOW_TEST_ENV_KEY] || \"{}\");\n return await body(args as I, { env, invoker: null });\n },\n body,\n } as WorkflowJob<Name, I, Awaited<O>>,\n \"workflow-job\",\n );\n};\n"],"mappings":";;;;;;;;AAqEA,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCrC,MAAa,qBACX,WACqC;CACrC,MAAM,OAAO,OAAO;AACpB,QAAO,WACL;EACE,MAAM,OAAO;EACb,SAAS,OAAO,SAAmB;AAEjC,UAAO,MAAM,KAAK,MAAW;IAAE,KADR,KAAK,MAAM,QAAQ,mCAA8B,KAAK;IACzC,SAAS;IAAM,CAAC;;EAEtD;EACD,EACD,eACD"}
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-reFAYSX7.mjs";
2
+ import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-ZZYEd_0R.mjs";
3
3
  export { EnumConstantsGeneratorID, enumConstantsPlugin };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-BtXZdz-F.mjs";
2
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-DdsUV-aA.mjs";
3
3
  export { FileUtilsGeneratorID, fileUtilsPlugin };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-Chvw1Eod.mjs";
2
+ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-0Dk-fDWi.mjs";
3
3
  export { KyselyGeneratorID, kyselyTypePlugin };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { n as seedPlugin, t as SeedGeneratorID } from "../../../index-CiNNNpuH.mjs";
2
+ import { n as seedPlugin, t as SeedGeneratorID } from "../../../index-BEEL1-6Z.mjs";
3
3
  export { SeedGeneratorID, seedPlugin };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { n as TailorAnyDBType } from "../tailor-db-field-CoFKRCYW.mjs";
3
- import { r as TailorEnv, t as TailorActor } from "../actor-B2oEmlTc.mjs";
2
+ import { n as TailorAnyDBType } from "../tailor-db-field-D_z185oq.mjs";
3
+ import { r as TailorEnv, t as TailorActor } from "../actor-DzCuoMlP.mjs";
4
4
 
5
5
  //#region src/plugin/with-context.d.ts
6
6
  /**