@tailor-platform/sdk 1.81.0 → 1.83.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 (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/application-CP7JKG9R.mjs +3 -0
  3. package/dist/{application-DDe0er6L.mjs → application-Cp0FxIm2.mjs} +26 -10
  4. package/dist/application-Cp0FxIm2.mjs.map +1 -0
  5. package/dist/cli/index.mjs +9 -9
  6. package/dist/cli/lib.mjs +2 -2
  7. package/dist/cli/skills.mjs +1 -1
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/config/types.d.mts +3 -1
  10. package/dist/configure/index.mjs +3 -3
  11. package/dist/configure/index.mjs.map +1 -1
  12. package/dist/configure/services/workflow/execution-policy.d.mts +2 -2
  13. package/dist/{crashreport-BNWUM6Kf.mjs → crashreport-DMYuHnBN.mjs} +2 -2
  14. package/dist/{crashreport-BNWUM6Kf.mjs.map → crashreport-DMYuHnBN.mjs.map} +1 -1
  15. package/dist/{crashreport-BafWvjjX.mjs → crashreport-ecqnz51B.mjs} +1 -1
  16. package/dist/{globals-DUqEetIh.mjs → globals-DraXTdqg.mjs} +6 -5
  17. package/dist/globals-DraXTdqg.mjs.map +1 -0
  18. package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
  19. package/dist/logger-CXQq9YIp.mjs.map +1 -0
  20. package/dist/{logger-B-fqZe2W.mjs → logger-t5ASCDZm.mjs} +6 -7
  21. package/dist/{logger-B-fqZe2W.mjs.map → logger-t5ASCDZm.mjs.map} +1 -1
  22. package/dist/{register-typescript-runtime-QAWucsg0.mjs → register-typescript-runtime-CCHyKeXO.mjs} +129 -19
  23. package/dist/register-typescript-runtime-CCHyKeXO.mjs.map +1 -0
  24. package/dist/{registry-CXi7rJq7.mjs → registry-Ct0Wgxp1.mjs} +3 -3
  25. package/dist/registry-Ct0Wgxp1.mjs.map +1 -0
  26. package/dist/runtime/index.mjs +2 -2
  27. package/dist/runtime/logger.mjs +1 -1
  28. package/dist/runtime/workflow.d.mts +39 -21
  29. package/dist/runtime/workflow.mjs +2 -2
  30. package/dist/{service-CDPatibu.mjs → service-B0MaodSg.mjs} +2 -2
  31. package/dist/{service-CDPatibu.mjs.map → service-B0MaodSg.mjs.map} +1 -1
  32. package/dist/{service-Cp0I7ZFe.mjs → service-CIGSGg9I.mjs} +2 -2
  33. package/dist/{service-Cp0I7ZFe.mjs.map → service-CIGSGg9I.mjs.map} +1 -1
  34. package/dist/service-KnAiVofD.mjs +3 -0
  35. package/dist/utils/test/index.mjs +18 -12
  36. package/dist/utils/test/index.mjs.map +1 -1
  37. package/dist/utils/test/mock.d.mts +2 -2
  38. package/dist/vitest/environment.mjs +1 -1
  39. package/dist/vitest/index.mjs +30 -24
  40. package/dist/vitest/index.mjs.map +1 -1
  41. package/dist/vitest/mocks/workflow.d.mts +20 -15
  42. package/dist/vitest/setup.mjs +1 -1
  43. package/dist/{workflow-CkIDJpdg.mjs → workflow-B2mwc7aT.mjs} +17 -9
  44. package/dist/workflow-B2mwc7aT.mjs.map +1 -0
  45. package/docs/configuration.md +3 -1
  46. package/docs/runtime.md +1 -1
  47. package/docs/services/tailordb-migration.md +5 -3
  48. package/docs/services/workflow.md +2 -2
  49. package/docs/testing.md +1 -1
  50. package/package.json +3 -3
  51. package/dist/application-B1_7Wm37.mjs +0 -3
  52. package/dist/application-DDe0er6L.mjs.map +0 -1
  53. package/dist/globals-DUqEetIh.mjs.map +0 -1
  54. package/dist/logger-BwS4ppwO.mjs.map +0 -1
  55. package/dist/register-typescript-runtime-QAWucsg0.mjs.map +0 -1
  56. package/dist/registry-CXi7rJq7.mjs.map +0 -1
  57. package/dist/service-Cg7Qibit.mjs +0 -3
  58. package/dist/workflow-CkIDJpdg.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"#/runtime/context\";\nimport type { TailorInvoker } from \"#/runtime/types\";\nimport type { TriggerJobFunctionOptions } from \"#/runtime/workflow\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (\n jobName: string,\n args: unknown,\n options?: TriggerJobFunctionOptions,\n ) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorInvoker): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: () => {\n throw new Error(\n \"tailor.workflow.triggerJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"#/configure/index\";\nimport type { TailorDBType } from \"#/configure/services/tailordb/schema\";\nimport type { TailorField } from \"#/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"#/configure/services/workflow/job\";\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;;;;AAwDA,MAAM,aAAa;;;;;;;AAQnB,SAAgB,kBAAkB,iBAAgC,CAAC,GAGjE;CACA,MAAM,kBAA0D,CAAC;CACjE,MAAM,iBAA2D,CAAC;CAElE,MAAM,mBAAmB;EACvB,AAAQ;EAER,YAAY,EAAE,aAAqC;GACjD,KAAK,SAAS;IAAE;IAAW,OAAO;GAAM;GACxC,eAAe,KAAK,KAAK,MAAM;EACjC;EAEA,MAAM,UAAyB,CAE/B;EAEA,MAAM,MAAqB;GACzB,KAAK,OAAO,QAAQ;EACtB;EAEA,MAAM,YAAY,OAAe,SAAoB,CAAC,GAAiC;GACrF,gBAAgB,KAAK;IAAE;IAAO;GAAO,CAAC;GACtC,OAAO,EAAE,MAAM,SAAS,OAAO,MAAM,EAAE;EACzC;CACF;CAEA,WAAW,WAAW,EACpB,QAAQ,mBACV;CAEA,OAAO;EAAE;EAAiB;CAAe;AAC3C;;;;;;;;;AAUA,SAAgB,kBAAkB,SAEhC;CACA,MAAM,gBAAsD,CAAC;CAE7D,WAAW,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AO,SAAS,UACjC,OAAO,OAAQ,KAAiC;GAElD,OAAO;EACT,GACA,CAAC,CACH;CACF;AACF;;;;;;;;;AAUA,SAAgB,qBAEd,YACA,MACA;CACA,OAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,KAAK;GACzB,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;GACR,CAAC;GACD,IAAI,OAAO,QACT,OAAO;GAET,OAAO,EAAE,OAAO,OAAY;EAC9B;CACF,EACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"#/runtime/context\";\nimport type { TailorInvoker } from \"#/runtime/types\";\nimport type { ExecJobFunctionOptions } from \"#/runtime/workflow\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n execJobFunction: (\n jobName: string,\n args: unknown,\n options?: ExecJobFunctionOptions,\n ) => unknown;\n startJobFunction: (\n jobName: string,\n args: unknown,\n options?: ExecJobFunctionOptions,\n ) => unknown;\n triggerJobFunction: (\n jobName: string,\n args: unknown,\n options?: ExecJobFunctionOptions,\n ) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.execJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n const execJobFunction = (jobName: string, args: unknown): unknown => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n };\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n execJobFunction,\n startJobFunction: execJobFunction,\n triggerJobFunction: execJobFunction,\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorInvoker): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `execJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n const throwUnmocked = (): never => {\n throw new Error(\n \"tailor.workflow.execJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n };\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n execJobFunction: throwUnmocked,\n startJobFunction: throwUnmocked,\n triggerJobFunction: throwUnmocked,\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"#/configure/index\";\nimport type { TailorDBType } from \"#/configure/services/tailordb/schema\";\nimport type { TailorField } from \"#/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"#/configure/services/workflow/job\";\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n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Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.
25
+ * Sets up a mock for `globalThis.tailor.workflow.execJobFunction` used in bundled workflow tests.
26
26
  * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,
27
27
  * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.
28
28
  * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.
@@ -50,7 +50,7 @@ declare function setupInvokerMock(invoker: TailorInvoker): void;
50
50
  declare function setupTailorErrorsMock(): void;
51
51
  /**
52
52
  * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.
53
- * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,
53
+ * `execJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,
54
54
  * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.
55
55
  * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.
56
56
  * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.
@@ -1,4 +1,4 @@
1
- import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-DUqEetIh.mjs";
1
+ import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-DraXTdqg.mjs";
2
2
  import * as globals from "globals";
3
3
 
4
4
  //#region src/vitest/environment.ts
@@ -1,4 +1,4 @@
1
- import { a as getRegisteredWorkflow, i as getRegisteredJob, t as TRIGGER_DEFAULT, u as platformSerialize } from "../registry-CXi7rJq7.mjs";
1
+ import { a as getRegisteredWorkflow, i as getRegisteredJob, t as TRIGGER_DEFAULT, u as platformSerialize } from "../registry-Ct0Wgxp1.mjs";
2
2
  import { a as writeWorkflowTestEnv, i as readWorkflowTestEnv, n as buildJobContext, r as clearWorkflowTestEnv } from "../test-env-key-DuZycyWM.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
4
  import { i as withDispose, n as tailorRoot, r as tailordbRoot, t as mockSecretmanager } from "../secretmanager-IY4UvinW.mjs";
@@ -1314,10 +1314,10 @@ function replaceTrigger(definition) {
1314
1314
  * Acquire a disposable mock for workflow operations (`tailor.workflow`).
1315
1315
  * Restored on dispose.
1316
1316
  *
1317
- * Canonical names (`startWorkflow`, `startJobFunction`, `resumeWorkflowExecution`)
1318
- * and their frozen aliases (`triggerWorkflow`, `triggerJobFunction`, `resumeWorkflow`)
1319
- * share the same underlying `vi.fn`, so calls through either name are recorded
1320
- * once and handlers configured on either name apply to both.
1317
+ * Canonical names (`startWorkflow`, `execJobFunction`, `resumeWorkflowExecution`)
1318
+ * and their aliases (`triggerWorkflow`, `startJobFunction`, `triggerJobFunction`,
1319
+ * `resumeWorkflow`) share the same underlying `vi.fn`, so calls through any
1320
+ * name are recorded once and handlers configured on any name apply to all.
1321
1321
  * @returns Disposable workflow mock control object
1322
1322
  * @example
1323
1323
  * ```typescript
@@ -1340,31 +1340,32 @@ function mockWorkflow() {
1340
1340
  const workflowSpies = /* @__PURE__ */ new Map();
1341
1341
  const waitPointMocks = /* @__PURE__ */ new Map();
1342
1342
  const scopedMocks = /* @__PURE__ */ new Set();
1343
- const defaultTriggerJob = (jobName, args, _options) => {
1343
+ const defaultExecJob = (jobName, args, _options) => {
1344
1344
  const body = getRegisteredJob(jobName);
1345
1345
  return body ? body(args, buildJobContext()) : null;
1346
1346
  };
1347
1347
  const defaultTriggerWorkflow = async (workflowName, args, _options) => {
1348
1348
  const wf = getRegisteredWorkflow(workflowName);
1349
1349
  if (wf) {
1350
- const out = triggerJobFunction(wf.mainJobName, platformSerialize(args));
1350
+ const out = execJobFunction(wf.mainJobName, platformSerialize(args));
1351
1351
  if (out instanceof Promise) await out;
1352
1352
  }
1353
1353
  return TRIGGER_DEFAULT;
1354
1354
  };
1355
1355
  const defaultResumeWorkflow = async (executionId) => executionId;
1356
- const triggerJobFunction = vi.fn(defaultTriggerJob);
1356
+ const execJobFunction = vi.fn(defaultExecJob);
1357
1357
  const triggerWorkflow = vi.fn(defaultTriggerWorkflow);
1358
1358
  const resumeWorkflow = vi.fn(defaultResumeWorkflow);
1359
1359
  const wait = vi.fn((_key, _payload) => null);
1360
1360
  const resolve = vi.fn(async (_executionId, _key, _callback) => {});
1361
1361
  const jobFunctionShim = (...call) => {
1362
- const out = call.length >= 3 ? triggerJobFunction(call[0], platformSerialize(call[1]), call[2]) : triggerJobFunction(call[0], platformSerialize(call[1]));
1362
+ const out = call.length >= 3 ? execJobFunction(call[0], platformSerialize(call[1]), call[2]) : execJobFunction(call[0], platformSerialize(call[1]));
1363
1363
  return out instanceof Promise ? out.then((v) => platformSerialize(v)) : platformSerialize(out);
1364
1364
  };
1365
1365
  const workflowShim = (...call) => call.length >= 3 ? triggerWorkflow(call[0], platformSerialize(call[1]), call[2]) : triggerWorkflow(call[0], platformSerialize(call[1]));
1366
1366
  const resumeShim = (executionId) => resumeWorkflow(executionId);
1367
1367
  root.workflow = {
1368
+ execJobFunction: jobFunctionShim,
1368
1369
  startJobFunction: jobFunctionShim,
1369
1370
  triggerJobFunction: jobFunctionShim,
1370
1371
  startWorkflow: workflowShim,
@@ -1378,13 +1379,18 @@ function mockWorkflow() {
1378
1379
  })
1379
1380
  };
1380
1381
  return withDispose({
1381
- /** The `startJobFunction` `vi.fn`. */
1382
- startJobFunction: triggerJobFunction,
1382
+ /** The `execJobFunction` `vi.fn`. */
1383
+ execJobFunction,
1383
1384
  /**
1384
- * Frozen alias of `startJobFunction` (same `vi.fn` reference).
1385
- * @deprecated Use `startJobFunction` instead.
1385
+ * Alias of `execJobFunction` (same `vi.fn` reference).
1386
+ * @deprecated Use `execJobFunction` instead.
1386
1387
  */
1387
- triggerJobFunction,
1388
+ startJobFunction: execJobFunction,
1389
+ /**
1390
+ * Frozen alias of `execJobFunction` (same `vi.fn` reference).
1391
+ * @deprecated Use `execJobFunction` instead.
1392
+ */
1393
+ triggerJobFunction: execJobFunction,
1388
1394
  /** The `startWorkflow` `vi.fn`. */
1389
1395
  startWorkflow: triggerWorkflow,
1390
1396
  /**
@@ -1466,29 +1472,29 @@ function mockWorkflow() {
1466
1472
  * @param handler - Function returning a result for a job name, args, and options
1467
1473
  */
1468
1474
  setJobHandler(handler) {
1469
- triggerJobFunction.mockImplementation((name, args, options) => handler(name, args, options));
1475
+ execJobFunction.mockImplementation((name, args, options) => handler(name, args, options));
1470
1476
  },
1471
1477
  /**
1472
- * Enqueue a single result for the next `triggerJobFunction` call (FIFO;
1478
+ * Enqueue a single result for the next `execJobFunction` call (FIFO;
1473
1479
  * takes priority over `setJobHandler`).
1474
1480
  * @param result - Result to return from the next call
1475
1481
  */
1476
1482
  enqueueResult(result) {
1477
- triggerJobFunction.mockImplementationOnce(() => result);
1483
+ execJobFunction.mockImplementationOnce(() => result);
1478
1484
  },
1479
1485
  /**
1480
- * Enqueue results for multiple subsequent `triggerJobFunction` calls (FIFO).
1486
+ * Enqueue results for multiple subsequent `execJobFunction` calls (FIFO).
1481
1487
  * @param results - Results to enqueue, one per upcoming call
1482
1488
  */
1483
1489
  enqueueResults(...results) {
1484
- for (const result of results) triggerJobFunction.mockImplementationOnce(() => result);
1490
+ for (const result of results) execJobFunction.mockImplementationOnce(() => result);
1485
1491
  },
1486
1492
  /**
1487
- * All jobs triggered via `triggerJobFunction`, in order.
1493
+ * All jobs executed via `execJobFunction`, in order.
1488
1494
  * @returns Triggered jobs array
1489
1495
  */
1490
1496
  get triggeredJobs() {
1491
- return triggerJobFunction.mock.calls.map(([jobName, args, options]) => ({
1497
+ return execJobFunction.mock.calls.map(([jobName, args, options]) => ({
1492
1498
  jobName,
1493
1499
  args,
1494
1500
  ...options !== void 0 && { options }
@@ -1558,7 +1564,7 @@ function mockWorkflow() {
1558
1564
  },
1559
1565
  /** Clear recorded calls while preserving configured responses. */
1560
1566
  clear() {
1561
- triggerJobFunction.mockClear();
1567
+ execJobFunction.mockClear();
1562
1568
  triggerWorkflow.mockClear();
1563
1569
  resumeWorkflow.mockClear();
1564
1570
  wait.mockClear();
@@ -1567,8 +1573,8 @@ function mockWorkflow() {
1567
1573
  },
1568
1574
  /** Reset all workflow responses and recorded calls (keeps the mock installed). */
1569
1575
  reset() {
1570
- triggerJobFunction.mockReset();
1571
- triggerJobFunction.mockImplementation(defaultTriggerJob);
1576
+ execJobFunction.mockReset();
1577
+ execJobFunction.mockImplementation(defaultExecJob);
1572
1578
  triggerWorkflow.mockReset();
1573
1579
  triggerWorkflow.mockImplementation(defaultTriggerWorkflow);
1574
1580
  resumeWorkflow.mockReset();