@temporal-contract/worker 2.2.0 → 2.3.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.
package/dist/activity.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal = require("./internal-Cwch3OHR.cjs");
2
+ const require_internal = require("./internal-DcM-YWYX.cjs");
3
3
  let _temporalio_common = require("@temporalio/common");
4
4
  //#region src/activity.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-DTq5OTwH.cjs";
1
+ import { n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-BP48RaOI.cjs";
2
2
  import { ActivityDefinition, ContractDefinition } from "@temporal-contract/contract";
3
3
  import { ResultAsync } from "neverthrow";
4
4
  import { ApplicationFailure, ApplicationFailure as ApplicationFailure$1 } from "@temporalio/common";
@@ -1 +1 @@
1
- {"version":3,"file":"activity.d.cts","names":[],"sources":["../src/activity.ts"],"mappings":";;;;;;AA+BwD;;;;;;;;;AAAA,KAWnD,4BAAA,mBAA+C,kBAAA,KAClD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,WAAA,CAAY,iBAAA,CAAkB,SAAA,GAAY,oBAAA;;;;;;;;;;;;;;AAAkB;;;;;;;;;;KAyB5D,uCAAA,mBAA0D,kBAAA,KAE5D,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,+BAAA,CAAgC,SAAA,8CAIZ,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,+BAAA,CAAgC,SAAA,cAAuB,SAAA;AAAA,KAI5D,+BAAA,qBAAoD,MAAA,SAAe,kBAAA,mBAC1D,WAAA,GAA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CAIZ,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,+BAAA,CAAgC,SAAA,cAAuB,SAAA;AAAA,KAI5D,+BAAA,qBAAoD,MAAA,SAAe,kBAAA,mBAC1D,WAAA,GAAc,4BAAA,CAA6B,WAAA,CAAY,CAAA;;;;KAMhE,+BAAA,mBAAkD,kBAAA;EACrD,QAAA,EAAU,SAAA;EACV,UAAA,EAAY,uCAAA,CAAwC,SAAA;AAAA;AAAA,KAGjD,sBAAA,mBAAyC,kBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;AAAA,KAE1B,yBAAA,qBAA8C,MAAA,SAAe,kBAAA,mBACpD,WAAA,GAAc,sBAAA,CAAuB,WAAA,CAAY,CAAA;AAAA,KAG1D,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAC,6BACtD,CAAA,sBAEE,CAAA;;;;;;;;;KAWQ,iBAAA,mBAAoC,kBAAA,KAE7C,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,yBAAA,CAA0B,SAAA,wBAG5B,mBAAA,uBAEwB,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,yBAAA,CAA0B,SAAA,cAAuB,SAAA,8BAE/C,SAAA;;;;;;;;;;;;;;;;;;;AA/CwD;AAAA;;;;;;;;;;;;;;;;;AAQP;AAAA;;;;;;;;;;;;;;;;;;;;AAKvB;AAAA;;;;iBAmGxB,wBAAA,mBAA2C,kBAAA,EACzD,OAAA,EAAS,+BAAA,CAAgC,SAAA,IACxC,iBAAA,CAAkB,SAAA"}
@@ -1,4 +1,4 @@
1
- import { n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-DbPMxULo.mjs";
1
+ import { n as ActivityInputValidationError, r as ActivityOutputValidationError, t as ActivityDefinitionNotFoundError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-BP48RaOI.mjs";
2
2
  import { ActivityDefinition, ContractDefinition } from "@temporal-contract/contract";
3
3
  import { ApplicationFailure, ApplicationFailure as ApplicationFailure$1 } from "@temporalio/common";
4
4
  import { ResultAsync } from "neverthrow";
@@ -1 +1 @@
1
- {"version":3,"file":"activity.d.mts","names":[],"sources":["../src/activity.ts"],"mappings":";;;;;;AA+BwD;;;;;;;;;AAAA,KAWnD,4BAAA,mBAA+C,kBAAA,KAClD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,WAAA,CAAY,iBAAA,CAAkB,SAAA,GAAY,oBAAA;;;;;;;;;;;;;;AAAkB;;;;;;;;;;KAyB5D,uCAAA,mBAA0D,kBAAA,KAE5D,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,+BAAA,CAAgC,SAAA,8CAIZ,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,+BAAA,CAAgC,SAAA,cAAuB,SAAA;AAAA,KAI5D,+BAAA,qBAAoD,MAAA,SAAe,kBAAA,mBAC1D,WAAA,GAAc,4BAAA,CAA6B,WAAA,CAAY,CAAA;;;;KAMhE,+BAAA,mBAAkD,kBAAA;EACrD,QAAA,EAAU,SAAA;EACV,UAAA,EAAY,uCAAA,CAAwC,SAAA;AAAA;AAAA,KAGjD,sBAAA,mBAAyC,kBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;AAAA,KAE1B,yBAAA,qBAA8C,MAAA,SAAe,kBAAA,mBACpD,WAAA,GAAc,sBAAA,CAAuB,WAAA,CAAY,CAAA;AAAA,KAG1D,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAA,6BACrD,CAAA,sBAEE,CAAA;;;;;;;;;KAWQ,iBAAA,mBAAoC,kBAAA,KAE7C,SAAA,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Ac,sBAAA,CAAuB,WAAA,CAAY,CAAA;AAAA,KAG1D,mBAAA,OAA0B,CAAA,oBAAqB,CAAA,EAAG,CAAC,6BACtD,CAAA,sBAEE,CAAA;;;;;;;;;KAWQ,iBAAA,mBAAoC,kBAAA,KAE7C,SAAA,uBAAgC,MAAA,SAAe,kBAAA,IAC5C,yBAAA,CAA0B,SAAA,wBAG5B,mBAAA,uBAEwB,SAAA,gBAAyB,SAAA,cAAuB,SAAA,wBAAiC,MAAA,SAEnG,kBAAA,IAEE,yBAAA,CAA0B,SAAA,cAAuB,SAAA,8BAE/C,SAAA;;;;;;;;;;;;;;;;;;;AA/CwD;AAAA;;;;;;;;;;;;;;;;;AAQP;AAAA;;;;;;;;;;;;;;;;;;;;AAKvB;AAAA;;;;iBAmGxB,wBAAA,mBAA2C,kBAAA,EACzD,OAAA,EAAS,+BAAA,CAAgC,SAAA,IACxC,iBAAA,CAAkB,SAAA"}
package/dist/activity.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as ActivityInputValidationError, i as extractHandlerInput, l as ActivityOutputValidationError, s as ActivityDefinitionNotFoundError } from "./internal-BzG1KhEK.mjs";
1
+ import { c as ActivityInputValidationError, i as extractHandlerInput, l as ActivityOutputValidationError, s as ActivityDefinitionNotFoundError } from "./internal-D8Dl9D43.mjs";
2
2
  import { ApplicationFailure } from "@temporalio/common";
3
3
  //#region src/activity.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"activity.mjs","names":[],"sources":["../src/activity.ts"],"sourcesContent":["// Entry point for activity implementations.\n//\n// Activities run *outside* the workflow sandbox, so they use neverthrow's\n// `ResultAsync` directly. Workflow code (see workflow.ts) uses the same\n// neverthrow API — neverthrow's evaluation is compatible with Temporal's\n// deterministic replay machinery.\n//\n// Errors flow through Temporal's `ApplicationFailure` (re-exported from\n// `@temporalio/common`) — it's the SDK's first-class failure shape, so we\n// don't wrap it in a custom class. `ApplicationFailure` exposes\n// `nonRetryable`, `type`, `details`, and `category` natively, and survives\n// the activity → workflow serialization boundary unchanged.\nimport { ActivityDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport type { ResultAsync } from \"neverthrow\";\nimport { ApplicationFailure } from \"@temporalio/common\";\nimport { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\nimport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\n\nexport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\n\n// Re-export the canonical activity-failure class so consumers don't need\n// a separate `@temporalio/common` import to construct one.\nexport { ApplicationFailure } from \"@temporalio/common\";\n\n/**\n * Activity implementation using neverthrow's `ResultAsync`.\n *\n * Returns `ResultAsync<Output, ApplicationFailure>` for explicit error\n * handling instead of throwing. The wrapper rethrows `err()` payloads at\n * the activity boundary; Temporal recognizes `ApplicationFailure` natively\n * and applies the configured retry policy (with `nonRetryable: true`\n * opting an instance out per-call).\n */\ntype ResultActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => ResultAsync<WorkerInferOutput<TActivity>, ApplicationFailure>;\n\n/**\n * Map of all activity implementations for a contract (global + all workflow-specific).\n *\n * **Shape note — input is nested by workflow, output is flat.** This\n * asymmetry is deliberate:\n *\n * - The implementation map you write **mirrors the contract's structure**:\n * global activities sit at the root, workflow-local activities nest\n * under their owning workflow's name. Mirroring the contract gives\n * IDE autocomplete that matches `defineContract`, prevents typos that\n * put a workflow-local activity at the global level, and makes\n * ownership visible at definition time.\n * - The handler returned by {@link declareActivitiesHandler} (see\n * {@link ActivitiesHandler}) is **flat** because Temporal's worker\n * sees a single activity namespace at runtime —\n * `proxyActivities<...>()` resolves names from one map regardless of\n * which workflow consumes them. `defineContract` enforces no name\n * collisions across global + workflow-local scopes, so the flat\n * output has no ambiguity to resolve.\n *\n * In short: write nested (mirror the contract); the wrapper flattens\n * for Temporal.\n */\ntype ContractResultActivitiesImplementations<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ResultActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ResultActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n };\n\ntype ResultActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ResultActivityImplementation<TActivities[K]>;\n};\n\n/**\n * Options for creating activities handler\n */\ntype DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n activities: ContractResultActivitiesImplementations<TContract>;\n};\n\ntype ActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => Promise<WorkerInferOutput<TActivity>>;\n\ntype ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ActivityImplementation<TActivities[K]>;\n};\n\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Activities handler ready for Temporal's `Worker.create({ activities })`.\n *\n * Flat shape: every activity (global + all workflow-local) lives at the\n * root of the returned map. See the doc comment on\n * {@link ContractResultActivitiesImplementations} for why the input you\n * write is nested by workflow while this output is flat.\n */\nexport type ActivitiesHandler<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged at root level (flat)\n UnionToIntersection<\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n }[keyof TContract[\"workflows\"]]\n >;\n\n/**\n * Create a typed activities handler with automatic validation and Result pattern.\n *\n * This wraps all activity implementations with:\n * - Validation at network boundaries\n * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling\n * - Automatic conversion from Result to Promise (throwing on Error)\n *\n * TypeScript ensures ALL activities (global + workflow-specific) are implemented.\n *\n * Use this to create the activities object for the Temporal Worker.\n *\n * @example\n * ```ts\n * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';\n * import { ResultAsync, errAsync, okAsync } from 'neverthrow';\n * import myContract from './contract';\n *\n * export const activities = declareActivitiesHandler({\n * contract: myContract,\n * activities: {\n * // Activity returns ResultAsync instead of throwing.\n * sendEmail: (args) =>\n * ResultAsync.fromPromise(\n * emailService.send(args),\n * (error) =>\n * // Wrap technical errors in ApplicationFailure. `nonRetryable`\n * // is per-instance: set it to true on permanent failures so\n * // Temporal stops retrying immediately.\n * ApplicationFailure.create({\n * type: 'EMAIL_SEND_FAILED',\n * message: 'Failed to send email',\n * nonRetryable: false,\n * cause: error instanceof Error ? error : undefined,\n * }),\n * ).map(() => ({ sent: true })),\n * },\n * });\n *\n * // Use with Temporal Worker\n * import { Worker } from '@temporalio/worker';\n *\n * const worker = await Worker.create({\n * workflowsPath: require.resolve('./workflows'),\n * activities: activities,\n * taskQueue: contract.taskQueue,\n * });\n * ```\n *\n * @remarks\n * The wrapper accepts implementations in the\n * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary\n * Promise-returning Temporal handlers (`err(...)` → thrown\n * `ApplicationFailure`; `ok(...)` → output validated against the\n * contract and resolved). It does **not** hide Temporal's\n * `@temporalio/activity` runtime: inside the body you can still call\n * `Context.current()` from `@temporalio/activity` to access heartbeats\n * (`heartbeat(details)`, `heartbeatDetails`), activity info (attempt\n * number, workflow IDs), and the async-completion task token. See the\n * \"Working with the Activity Context\" section of the worker\n * implementation guide for end-to-end examples.\n */\nexport function declareActivitiesHandler<TContract extends ContractDefinition>(\n options: DeclareActivitiesHandlerOptions<TContract>,\n): ActivitiesHandler<TContract> {\n const { contract, activities } = options;\n\n // Prepare Temporal-compatible activities with validation and Result unwrapping\n const wrappedActivities = {} as ActivitiesHandler<TContract>;\n\n // Helper to create a wrapped implementation from a definition and impl\n function makeWrapped(\n activityName: string,\n activityDef: ActivityDefinition,\n activityImpl: (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n ) {\n return async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate input\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n // Execute neverthrow activity (returns ResultAsync<T, ApplicationFailure>);\n // awaiting yields a Result<T, ApplicationFailure>.\n const result = await activityImpl(inputResult.value);\n\n // Process result: validate output or throw error\n if (result.isOk()) {\n // Validate output on success\n const outputResult = await activityDef.output[\"~standard\"].validate(result.value);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n return outputResult.value;\n } else {\n // Convert err(...) payload to thrown ApplicationFailure for Temporal.\n // Temporal recognizes this class natively and applies the\n // configured retry policy (honoring `nonRetryable: true`).\n throw result.error;\n }\n };\n }\n\n // 1) Wrap global activities defined directly under contract.activities\n if (contract.activities) {\n for (const [activityName, impl] of Object.entries(activities)) {\n // Skip workflow namespaces if present at root\n if (contract.workflows && activityName in contract.workflows) {\n continue;\n }\n\n const activityDef = contract.activities[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(activityName, Object.keys(contract.activities));\n }\n\n // Assign wrapped global activity\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n activityName,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n\n // 2) Wrap workflow-scoped activities at root level (flat)\n if (contract.workflows) {\n for (const [workflowName, workflowDef] of Object.entries(contract.workflows)) {\n const wfActivitiesImpl = (activities as Record<string, unknown>)[workflowName] as\n | Record<string, unknown>\n | undefined;\n if (!wfActivitiesImpl) {\n // If no implementations provided for this workflow, skip (TypeScript typing should enforce completeness for declared ones)\n continue;\n }\n\n const wfDefs = workflowDef.activities ?? {};\n\n for (const [activityName, impl] of Object.entries(wfActivitiesImpl)) {\n const activityDef = wfDefs[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(\n `${workflowName}.${activityName}`,\n Object.keys(wfDefs),\n );\n }\n\n // Assign workflow activity directly at root level (flat structure)\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n `${workflowName}.${activityName}`,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n }\n\n return wrappedActivities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqMA,SAAgB,yBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,eAAe;CAGjC,MAAM,oBAAoB,EAAE;CAG5B,SAAS,YACP,cACA,aACA,cACA;AACA,SAAO,OAAO,GAAG,SAAoB;GACnC,MAAM,QAAQ,oBAAoB,KAAK;GAGvC,MAAM,cAAc,MAAM,YAAY,MAAM,aAAa,SAAS,MAAM;AACxE,OAAI,YAAY,OACd,OAAM,IAAI,6BAA6B,cAAc,YAAY,OAAO;GAK1E,MAAM,SAAS,MAAM,aAAa,YAAY,MAAM;AAGpD,OAAI,OAAO,MAAM,EAAE;IAEjB,MAAM,eAAe,MAAM,YAAY,OAAO,aAAa,SAAS,OAAO,MAAM;AACjF,QAAI,aAAa,OACf,OAAM,IAAI,8BAA8B,cAAc,aAAa,OAAO;AAE5E,WAAO,aAAa;SAKpB,OAAM,OAAO;;;AAMnB,KAAI,SAAS,WACX,MAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,WAAW,EAAE;AAE7D,MAAI,SAAS,aAAa,gBAAgB,SAAS,UACjD;EAGF,MAAM,cAAc,SAAS,WAAW;AACxC,MAAI,CAAC,YACH,OAAM,IAAI,gCAAgC,cAAc,OAAO,KAAK,SAAS,WAAW,CAAC;AAI1F,oBAA8C,gBAAgB,YAC7D,cACA,aACA,KACD;;AAKL,KAAI,SAAS,UACX,MAAK,MAAM,CAAC,cAAc,gBAAgB,OAAO,QAAQ,SAAS,UAAU,EAAE;EAC5E,MAAM,mBAAoB,WAAuC;AAGjE,MAAI,CAAC,iBAEH;EAGF,MAAM,SAAS,YAAY,cAAc,EAAE;AAE3C,OAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,iBAAiB,EAAE;GACnE,MAAM,cAAc,OAAO;AAC3B,OAAI,CAAC,YACH,OAAM,IAAI,gCACR,GAAG,aAAa,GAAG,gBACnB,OAAO,KAAK,OAAO,CACpB;AAIF,qBAA8C,gBAAgB,YAC7D,GAAG,aAAa,GAAG,gBACnB,aACA,KACD;;;AAKP,QAAO"}
1
+ {"version":3,"file":"activity.mjs","names":[],"sources":["../src/activity.ts"],"sourcesContent":["// Entry point for activity implementations.\n//\n// Activities run *outside* the workflow sandbox, so they use neverthrow's\n// `ResultAsync` directly. Workflow code (see workflow.ts) uses the same\n// neverthrow API — neverthrow's evaluation is compatible with Temporal's\n// deterministic replay machinery.\n//\n// Errors flow through Temporal's `ApplicationFailure` (re-exported from\n// `@temporalio/common`) — it's the SDK's first-class failure shape, so we\n// don't wrap it in a custom class. `ApplicationFailure` exposes\n// `nonRetryable`, `type`, `details`, and `category` natively, and survives\n// the activity → workflow serialization boundary unchanged.\nimport { ActivityDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport type { ResultAsync } from \"neverthrow\";\nimport { ApplicationFailure } from \"@temporalio/common\";\nimport { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\nimport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\n\nexport {\n ActivityDefinitionNotFoundError,\n ActivityInputValidationError,\n ActivityOutputValidationError,\n} from \"./errors.js\";\n\n// Re-export the canonical activity-failure class so consumers don't need\n// a separate `@temporalio/common` import to construct one.\nexport { ApplicationFailure } from \"@temporalio/common\";\n\n/**\n * Activity implementation using neverthrow's `ResultAsync`.\n *\n * Returns `ResultAsync<Output, ApplicationFailure>` for explicit error\n * handling instead of throwing. The wrapper rethrows `err()` payloads at\n * the activity boundary; Temporal recognizes `ApplicationFailure` natively\n * and applies the configured retry policy (with `nonRetryable: true`\n * opting an instance out per-call).\n */\ntype ResultActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => ResultAsync<WorkerInferOutput<TActivity>, ApplicationFailure>;\n\n/**\n * Map of all activity implementations for a contract (global + all workflow-specific).\n *\n * **Shape note — input is nested by workflow, output is flat.** This\n * asymmetry is deliberate:\n *\n * - The implementation map you write **mirrors the contract's structure**:\n * global activities sit at the root, workflow-local activities nest\n * under their owning workflow's name. Mirroring the contract gives\n * IDE autocomplete that matches `defineContract`, prevents typos that\n * put a workflow-local activity at the global level, and makes\n * ownership visible at definition time.\n * - The handler returned by {@link declareActivitiesHandler} (see\n * {@link ActivitiesHandler}) is **flat** because Temporal's worker\n * sees a single activity namespace at runtime —\n * `proxyActivities<...>()` resolves names from one map regardless of\n * which workflow consumes them. `defineContract` enforces no name\n * collisions across global + workflow-local scopes, so the flat\n * output has no ambiguity to resolve.\n *\n * In short: write nested (mirror the contract); the wrapper flattens\n * for Temporal.\n */\ntype ContractResultActivitiesImplementations<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ResultActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ResultActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n };\n\ntype ResultActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ResultActivityImplementation<TActivities[K]>;\n};\n\n/**\n * Options for creating activities handler\n */\ntype DeclareActivitiesHandlerOptions<TContract extends ContractDefinition> = {\n contract: TContract;\n activities: ContractResultActivitiesImplementations<TContract>;\n};\n\ntype ActivityImplementation<TActivity extends ActivityDefinition> = (\n args: WorkerInferInput<TActivity>,\n) => Promise<WorkerInferOutput<TActivity>>;\n\ntype ActivitiesImplementations<TActivities extends Record<string, ActivityDefinition>> = {\n [K in keyof TActivities]: ActivityImplementation<TActivities[K]>;\n};\n\ntype UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\n/**\n * Activities handler ready for Temporal's `Worker.create({ activities })`.\n *\n * Flat shape: every activity (global + all workflow-local) lives at the\n * root of the returned map. See the doc comment on\n * {@link ContractResultActivitiesImplementations} for why the input you\n * write is nested by workflow while this output is flat.\n */\nexport type ActivitiesHandler<TContract extends ContractDefinition> =\n // Global activities\n (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? ActivitiesImplementations<TContract[\"activities\"]>\n : {}) &\n // All workflow-specific activities merged at root level (flat)\n UnionToIntersection<\n {\n [TWorkflow in keyof TContract[\"workflows\"]]: TContract[\"workflows\"][TWorkflow][\"activities\"] extends Record<\n string,\n ActivityDefinition\n >\n ? ActivitiesImplementations<TContract[\"workflows\"][TWorkflow][\"activities\"]>\n : {};\n }[keyof TContract[\"workflows\"]]\n >;\n\n/**\n * Create a typed activities handler with automatic validation and Result pattern.\n *\n * This wraps all activity implementations with:\n * - Validation at network boundaries\n * - `ResultAsync<T, ApplicationFailure>` pattern for explicit error handling\n * - Automatic conversion from Result to Promise (throwing on Error)\n *\n * TypeScript ensures ALL activities (global + workflow-specific) are implemented.\n *\n * Use this to create the activities object for the Temporal Worker.\n *\n * @example\n * ```ts\n * import { declareActivitiesHandler, ApplicationFailure } from '@temporal-contract/worker/activity';\n * import { ResultAsync, errAsync, okAsync } from 'neverthrow';\n * import myContract from './contract';\n *\n * export const activities = declareActivitiesHandler({\n * contract: myContract,\n * activities: {\n * // Activity returns ResultAsync instead of throwing.\n * sendEmail: (args) =>\n * ResultAsync.fromPromise(\n * emailService.send(args),\n * (error) =>\n * // Wrap technical errors in ApplicationFailure. `nonRetryable`\n * // is per-instance: set it to true on permanent failures so\n * // Temporal stops retrying immediately.\n * ApplicationFailure.create({\n * type: 'EMAIL_SEND_FAILED',\n * message: 'Failed to send email',\n * nonRetryable: false,\n * cause: error instanceof Error ? error : undefined,\n * }),\n * ).map(() => ({ sent: true })),\n * },\n * });\n *\n * // Use with Temporal Worker\n * import { Worker } from '@temporalio/worker';\n *\n * const worker = await Worker.create({\n * workflowsPath: require.resolve('./workflows'),\n * activities: activities,\n * taskQueue: contract.taskQueue,\n * });\n * ```\n *\n * @remarks\n * The wrapper accepts implementations in the\n * `ResultAsync<T, ApplicationFailure>` shape and produces ordinary\n * Promise-returning Temporal handlers (`err(...)` → thrown\n * `ApplicationFailure`; `ok(...)` → output validated against the\n * contract and resolved). It does **not** hide Temporal's\n * `@temporalio/activity` runtime: inside the body you can still call\n * `Context.current()` from `@temporalio/activity` to access heartbeats\n * (`heartbeat(details)`, `heartbeatDetails`), activity info (attempt\n * number, workflow IDs), and the async-completion task token. See the\n * \"Working with the Activity Context\" section of the worker\n * implementation guide for end-to-end examples.\n */\nexport function declareActivitiesHandler<TContract extends ContractDefinition>(\n options: DeclareActivitiesHandlerOptions<TContract>,\n): ActivitiesHandler<TContract> {\n const { contract, activities } = options;\n\n // Prepare Temporal-compatible activities with validation and Result unwrapping\n const wrappedActivities = {} as ActivitiesHandler<TContract>;\n\n // Helper to create a wrapped implementation from a definition and impl\n function makeWrapped(\n activityName: string,\n activityDef: ActivityDefinition,\n activityImpl: (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n ) {\n return async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate input\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n // Execute neverthrow activity (returns ResultAsync<T, ApplicationFailure>);\n // awaiting yields a Result<T, ApplicationFailure>.\n const result = await activityImpl(inputResult.value);\n\n // Process result: validate output or throw error\n if (result.isOk()) {\n // Validate output on success\n const outputResult = await activityDef.output[\"~standard\"].validate(result.value);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n return outputResult.value;\n } else {\n // Convert err(...) payload to thrown ApplicationFailure for Temporal.\n // Temporal recognizes this class natively and applies the\n // configured retry policy (honoring `nonRetryable: true`).\n throw result.error;\n }\n };\n }\n\n // 1) Wrap global activities defined directly under contract.activities\n if (contract.activities) {\n for (const [activityName, impl] of Object.entries(activities)) {\n // Skip workflow namespaces if present at root\n if (contract.workflows && activityName in contract.workflows) {\n continue;\n }\n\n const activityDef = contract.activities[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(activityName, Object.keys(contract.activities));\n }\n\n // Assign wrapped global activity\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n activityName,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n\n // 2) Wrap workflow-scoped activities at root level (flat)\n if (contract.workflows) {\n for (const [workflowName, workflowDef] of Object.entries(contract.workflows)) {\n const wfActivitiesImpl = (activities as Record<string, unknown>)[workflowName] as\n | Record<string, unknown>\n | undefined;\n if (!wfActivitiesImpl) {\n // If no implementations provided for this workflow, skip (TypeScript typing should enforce completeness for declared ones)\n continue;\n }\n\n const wfDefs = workflowDef.activities ?? {};\n\n for (const [activityName, impl] of Object.entries(wfActivitiesImpl)) {\n const activityDef = wfDefs[activityName];\n if (!activityDef) {\n throw new ActivityDefinitionNotFoundError(\n `${workflowName}.${activityName}`,\n Object.keys(wfDefs),\n );\n }\n\n // Assign workflow activity directly at root level (flat structure)\n (wrappedActivities as Record<string, unknown>)[activityName] = makeWrapped(\n `${workflowName}.${activityName}`,\n activityDef,\n impl as (args: unknown) => ResultAsync<unknown, ApplicationFailure>,\n );\n }\n }\n }\n\n return wrappedActivities;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqMA,SAAgB,yBACd,SAC8B;CAC9B,MAAM,EAAE,UAAU,eAAe;CAGjC,MAAM,oBAAoB,CAAC;CAG3B,SAAS,YACP,cACA,aACA,cACA;EACA,OAAO,OAAO,GAAG,SAAoB;GACnC,MAAM,QAAQ,oBAAoB,IAAI;GAGtC,MAAM,cAAc,MAAM,YAAY,MAAM,YAAY,CAAC,SAAS,KAAK;GACvE,IAAI,YAAY,QACd,MAAM,IAAI,6BAA6B,cAAc,YAAY,MAAM;GAKzE,MAAM,SAAS,MAAM,aAAa,YAAY,KAAK;GAGnD,IAAI,OAAO,KAAK,GAAG;IAEjB,MAAM,eAAe,MAAM,YAAY,OAAO,YAAY,CAAC,SAAS,OAAO,KAAK;IAChF,IAAI,aAAa,QACf,MAAM,IAAI,8BAA8B,cAAc,aAAa,MAAM;IAE3E,OAAO,aAAa;GACtB,OAIE,MAAM,OAAO;EAEjB;CACF;CAGA,IAAI,SAAS,YACX,KAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,UAAU,GAAG;EAE7D,IAAI,SAAS,aAAa,gBAAgB,SAAS,WACjD;EAGF,MAAM,cAAc,SAAS,WAAW;EACxC,IAAI,CAAC,aACH,MAAM,IAAI,gCAAgC,cAAc,OAAO,KAAK,SAAS,UAAU,CAAC;EAI1F,kBAA+C,gBAAgB,YAC7D,cACA,aACA,IACF;CACF;CAIF,IAAI,SAAS,WACX,KAAK,MAAM,CAAC,cAAc,gBAAgB,OAAO,QAAQ,SAAS,SAAS,GAAG;EAC5E,MAAM,mBAAoB,WAAuC;EAGjE,IAAI,CAAC,kBAEH;EAGF,MAAM,SAAS,YAAY,cAAc,CAAC;EAE1C,KAAK,MAAM,CAAC,cAAc,SAAS,OAAO,QAAQ,gBAAgB,GAAG;GACnE,MAAM,cAAc,OAAO;GAC3B,IAAI,CAAC,aACH,MAAM,IAAI,gCACR,GAAG,aAAa,GAAG,gBACnB,OAAO,KAAK,MAAM,CACpB;GAIF,kBAA+C,gBAAgB,YAC7D,GAAG,aAAa,GAAG,gBACnB,aACA,IACF;EACF;CACF;CAGF,OAAO;AACT"}
@@ -205,4 +205,4 @@ declare class WorkflowScopeError extends WorkerError {
205
205
  }
206
206
  //#endregion
207
207
  export { ClientInferOutput as _, ChildWorkflowError as a, QueryOutputValidationError as c, UpdateOutputValidationError as d, WorkflowCancelledError as f, ClientInferInput as g, WorkflowScopeError as h, ChildWorkflowCancelledError as i, SignalInputValidationError as l, WorkflowOutputValidationError as m, ActivityInputValidationError as n, ChildWorkflowNotFoundError as o, WorkflowInputValidationError as p, ActivityOutputValidationError as r, QueryInputValidationError as s, ActivityDefinitionNotFoundError as t, UpdateInputValidationError as u, WorkerInferInput as v, WorkerInferOutput as y };
208
- //# sourceMappingURL=errors-DTq5OTwH.d.cts.map
208
+ //# sourceMappingURL=errors-BP48RaOI.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BP48RaOI.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAChF,CAAA;;;;AARC;KAeS,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;uBC1Ba,WAAA,SAAoB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,WAAA;EAAA,SAE5B,SAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,SAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;AA3HG;;;AAAA,cAsIjD,0BAAA,SAAmC,WAAA;EAAA,SAE5B,UAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,UAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;AAlIH;AAaxD;cAgIa,2BAAA,SAAoC,WAAA;EAAA,SAE7B,UAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,UAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;;cAW9C,0BAAA,SAAmC,WAAW;EAAA,SAEvC,YAAA;EAAA,SACA,kBAAA;cADA,YAAA,UACA,kBAAA;AAAA;;;;;;;;;;cAiBP,kBAAA,SAA2B,WAAW;cACrC,OAAA,UAAiB,KAAA;AAAA;;;;;;;;;;AAhJkC;AAWjE;;;;cAyJa,2BAAA,SAAoC,kBAAkB;EAAA,SAE/C,YAAA;cAAA,YAAA,UAChB,KAAA;AAAA;;;;;;;;;;;;;cAmBS,sBAAA,SAA+B,WAAW;cACzC,KAAA;AAAA;AA7KmD;AAWjE;;;;;;;;;;;;;;;;;;;;;;;AAGiE;AAWjE;;;;AAzBiE,cAgNpD,kBAAA,SAA2B,WAAW;cACrC,KAAA;AAAA"}
@@ -205,4 +205,4 @@ declare class WorkflowScopeError extends WorkerError {
205
205
  }
206
206
  //#endregion
207
207
  export { ClientInferOutput as _, ChildWorkflowError as a, QueryOutputValidationError as c, UpdateOutputValidationError as d, WorkflowCancelledError as f, ClientInferInput as g, WorkflowScopeError as h, ChildWorkflowCancelledError as i, SignalInputValidationError as l, WorkflowOutputValidationError as m, ActivityInputValidationError as n, ChildWorkflowNotFoundError as o, WorkflowInputValidationError as p, ActivityOutputValidationError as r, QueryInputValidationError as s, ActivityDefinitionNotFoundError as t, UpdateInputValidationError as u, WorkerInferInput as v, WorkerInferOutput as y };
208
- //# sourceMappingURL=errors-DbPMxULo.d.mts.map
208
+ //# sourceMappingURL=errors-BP48RaOI.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BP48RaOI.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAChF,CAAA;;;;AARC;KAeS,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;uBC1Ba,WAAA,SAAoB,KAAK;EAAA,UAC7B,WAAA,CAAa,OAAA,UAAiB,KAAA;AAAA;;;;cAa5B,+BAAA,SAAwC,WAAW;EAAA,SAE5C,YAAA;EAAA,SACA,oBAAA;cADA,YAAA,UACA,oBAAA;AAAA;;;;cAaP,4BAAA,SAAqC,WAAA;EAAA,SAE9B,YAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,YAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;;cAW9C,6BAAA,SAAsC,WAAA;EAAA,SAE/B,YAAA;EAAA,SACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;cADvC,YAAA,UACA,MAAA,EAAQ,aAAA,CAAc,gBAAA,CAAiB,KAAA;AAAA;;;;cAW9C,4BAAA,SAAqC,WAAA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9C,0BAAA,SAAmC,WAAW;EAAA,SAEvC,YAAA;EAAA,SACA,kBAAA;cADA,YAAA,UACA,kBAAA;AAAA;;;;;;;;;;cAiBP,kBAAA,SAA2B,WAAW;cACrC,OAAA,UAAiB,KAAA;AAAA;;;;;;;;;;AAhJkC;AAWjE;;;;cAyJa,2BAAA,SAAoC,kBAAkB;EAAA,SAE/C,YAAA;cAAA,YAAA,UAChB,KAAA;AAAA;;;;;;;;;;;;;cAmBS,sBAAA,SAA+B,WAAW;cACzC,KAAA;AAAA;AA7KmD;AAWjE;;;;;;;;;;;;;;;;;;;;;;;AAGiE;AAWjE;;;;AAzBiE,cAgNpD,kBAAA,SAA2B,WAAW;cACrC,KAAA;AAAA"}
@@ -17,6 +17,8 @@ var WorkerError = class extends Error {
17
17
  * Error thrown when an activity definition is not found in the contract
18
18
  */
19
19
  var ActivityDefinitionNotFoundError = class extends WorkerError {
20
+ activityName;
21
+ availableDefinitions;
20
22
  constructor(activityName, availableDefinitions = []) {
21
23
  const available = availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none";
22
24
  super(`Activity definition not found for: "${activityName}". Available activities: ${available}`);
@@ -29,6 +31,8 @@ var ActivityDefinitionNotFoundError = class extends WorkerError {
29
31
  * Error thrown when activity input validation fails
30
32
  */
31
33
  var ActivityInputValidationError = class extends WorkerError {
34
+ activityName;
35
+ issues;
32
36
  constructor(activityName, issues) {
33
37
  const message = summarizeIssues(issues);
34
38
  super(`Activity "${activityName}" input validation failed: ${message}`);
@@ -41,6 +45,8 @@ var ActivityInputValidationError = class extends WorkerError {
41
45
  * Error thrown when activity output validation fails
42
46
  */
43
47
  var ActivityOutputValidationError = class extends WorkerError {
48
+ activityName;
49
+ issues;
44
50
  constructor(activityName, issues) {
45
51
  const message = summarizeIssues(issues);
46
52
  super(`Activity "${activityName}" output validation failed: ${message}`);
@@ -53,6 +59,8 @@ var ActivityOutputValidationError = class extends WorkerError {
53
59
  * Error thrown when workflow input validation fails
54
60
  */
55
61
  var WorkflowInputValidationError = class extends WorkerError {
62
+ workflowName;
63
+ issues;
56
64
  constructor(workflowName, issues) {
57
65
  const message = summarizeIssues(issues);
58
66
  super(`Workflow "${workflowName}" input validation failed: ${message}`);
@@ -65,6 +73,8 @@ var WorkflowInputValidationError = class extends WorkerError {
65
73
  * Error thrown when workflow output validation fails
66
74
  */
67
75
  var WorkflowOutputValidationError = class extends WorkerError {
76
+ workflowName;
77
+ issues;
68
78
  constructor(workflowName, issues) {
69
79
  const message = summarizeIssues(issues);
70
80
  super(`Workflow "${workflowName}" output validation failed: ${message}`);
@@ -77,6 +87,8 @@ var WorkflowOutputValidationError = class extends WorkerError {
77
87
  * Error thrown when signal input validation fails
78
88
  */
79
89
  var SignalInputValidationError = class extends WorkerError {
90
+ signalName;
91
+ issues;
80
92
  constructor(signalName, issues) {
81
93
  const message = summarizeIssues(issues);
82
94
  super(`Signal "${signalName}" input validation failed: ${message}`);
@@ -89,6 +101,8 @@ var SignalInputValidationError = class extends WorkerError {
89
101
  * Error thrown when query input validation fails
90
102
  */
91
103
  var QueryInputValidationError = class extends WorkerError {
104
+ queryName;
105
+ issues;
92
106
  constructor(queryName, issues) {
93
107
  const message = summarizeIssues(issues);
94
108
  super(`Query "${queryName}" input validation failed: ${message}`);
@@ -101,6 +115,8 @@ var QueryInputValidationError = class extends WorkerError {
101
115
  * Error thrown when query output validation fails
102
116
  */
103
117
  var QueryOutputValidationError = class extends WorkerError {
118
+ queryName;
119
+ issues;
104
120
  constructor(queryName, issues) {
105
121
  const message = summarizeIssues(issues);
106
122
  super(`Query "${queryName}" output validation failed: ${message}`);
@@ -113,6 +129,8 @@ var QueryOutputValidationError = class extends WorkerError {
113
129
  * Error thrown when update input validation fails
114
130
  */
115
131
  var UpdateInputValidationError = class extends WorkerError {
132
+ updateName;
133
+ issues;
116
134
  constructor(updateName, issues) {
117
135
  const message = summarizeIssues(issues);
118
136
  super(`Update "${updateName}" input validation failed: ${message}`);
@@ -125,6 +143,8 @@ var UpdateInputValidationError = class extends WorkerError {
125
143
  * Error thrown when update output validation fails
126
144
  */
127
145
  var UpdateOutputValidationError = class extends WorkerError {
146
+ updateName;
147
+ issues;
128
148
  constructor(updateName, issues) {
129
149
  const message = summarizeIssues(issues);
130
150
  super(`Update "${updateName}" output validation failed: ${message}`);
@@ -137,6 +157,8 @@ var UpdateOutputValidationError = class extends WorkerError {
137
157
  * Error thrown when a child workflow is not found in the contract
138
158
  */
139
159
  var ChildWorkflowNotFoundError = class extends WorkerError {
160
+ workflowName;
161
+ availableWorkflows;
140
162
  constructor(workflowName, availableWorkflows = []) {
141
163
  const available = availableWorkflows.length > 0 ? availableWorkflows.join(", ") : "none";
142
164
  super(`Child workflow not found: "${workflowName}". Available workflows: ${available}`);
@@ -175,6 +197,7 @@ var ChildWorkflowError = class extends WorkerError {
175
197
  * the worker-side analogue of the client-side cause-forwarding pattern.
176
198
  */
177
199
  var ChildWorkflowCancelledError = class extends ChildWorkflowError {
200
+ workflowName;
178
201
  constructor(workflowName, cause) {
179
202
  super(`Child workflow "${workflowName}" was cancelled`, cause);
180
203
  this.workflowName = workflowName;
@@ -429,4 +452,4 @@ function describeChildWorkflowOperation(operation, childWorkflowName) {
429
452
  //#endregion
430
453
  export { UpdateOutputValidationError as _, formatChildWorkflowValidationMessage as a, WorkflowOutputValidationError as b, ActivityInputValidationError as c, ChildWorkflowError as d, ChildWorkflowNotFoundError as f, UpdateInputValidationError as g, SignalInputValidationError as h, extractHandlerInput as i, ActivityOutputValidationError as l, QueryOutputValidationError as m, classifyChildWorkflowError as n, makeResultAsync as o, QueryInputValidationError as p, createContinueAsNew as r, ActivityDefinitionNotFoundError as s, buildRawActivitiesProxy as t, ChildWorkflowCancelledError as u, WorkflowCancelledError as v, WorkflowScopeError as x, WorkflowInputValidationError as y };
431
454
 
432
- //# sourceMappingURL=internal-BzG1KhEK.mjs.map
455
+ //# sourceMappingURL=internal-D8Dl9D43.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal-BzG1KhEK.mjs","names":[],"sources":["../src/errors.ts","../src/internal.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"@temporal-contract/contract\";\n\n/**\n * Base error class for worker errors\n */\nabstract class WorkerError extends Error {\n protected constructor(message: string, cause?: unknown) {\n super(message, { cause });\n this.name = \"WorkerError\";\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when an activity definition is not found in the contract\n */\nexport class ActivityDefinitionNotFoundError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly availableDefinitions: readonly string[] = [],\n ) {\n const available = availableDefinitions.length > 0 ? availableDefinitions.join(\", \") : \"none\";\n super(\n `Activity definition not found for: \"${activityName}\". Available activities: ${available}`,\n );\n this.name = \"ActivityDefinitionNotFoundError\";\n }\n}\n\n/**\n * Error thrown when activity input validation fails\n */\nexport class ActivityInputValidationError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Activity \"${activityName}\" input validation failed: ${message}`);\n this.name = \"ActivityInputValidationError\";\n }\n}\n\n/**\n * Error thrown when activity output validation fails\n */\nexport class ActivityOutputValidationError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Activity \"${activityName}\" output validation failed: ${message}`);\n this.name = \"ActivityOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when workflow input validation fails\n */\nexport class WorkflowInputValidationError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Workflow \"${workflowName}\" input validation failed: ${message}`);\n this.name = \"WorkflowInputValidationError\";\n }\n}\n\n/**\n * Error thrown when workflow output validation fails\n */\nexport class WorkflowOutputValidationError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Workflow \"${workflowName}\" output validation failed: ${message}`);\n this.name = \"WorkflowOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when signal input validation fails\n */\nexport class SignalInputValidationError extends WorkerError {\n constructor(\n public readonly signalName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Signal \"${signalName}\" input validation failed: ${message}`);\n this.name = \"SignalInputValidationError\";\n }\n}\n\n/**\n * Error thrown when query input validation fails\n */\nexport class QueryInputValidationError extends WorkerError {\n constructor(\n public readonly queryName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Query \"${queryName}\" input validation failed: ${message}`);\n this.name = \"QueryInputValidationError\";\n }\n}\n\n/**\n * Error thrown when query output validation fails\n */\nexport class QueryOutputValidationError extends WorkerError {\n constructor(\n public readonly queryName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Query \"${queryName}\" output validation failed: ${message}`);\n this.name = \"QueryOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when update input validation fails\n */\nexport class UpdateInputValidationError extends WorkerError {\n constructor(\n public readonly updateName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Update \"${updateName}\" input validation failed: ${message}`);\n this.name = \"UpdateInputValidationError\";\n }\n}\n\n/**\n * Error thrown when update output validation fails\n */\nexport class UpdateOutputValidationError extends WorkerError {\n constructor(\n public readonly updateName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Update \"${updateName}\" output validation failed: ${message}`);\n this.name = \"UpdateOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when a child workflow is not found in the contract\n */\nexport class ChildWorkflowNotFoundError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly availableWorkflows: readonly string[] = [],\n ) {\n const available = availableWorkflows.length > 0 ? availableWorkflows.join(\", \") : \"none\";\n super(`Child workflow not found: \"${workflowName}\". Available workflows: ${available}`);\n this.name = \"ChildWorkflowNotFoundError\";\n }\n}\n\n/**\n * Generic error for child workflow operations.\n *\n * When the child execution itself fails (Temporal's `ChildWorkflowFailure`),\n * `cause` is set to the *unwrapped* underlying failure (`ApplicationFailure`,\n * `TimeoutFailure`, `TerminatedFailure`, etc.) lifted from Temporal's wrapper —\n * mirroring the client-side `WorkflowFailedError.cause` behavior, so callers\n * can branch on the failure category in one step instead of unwrapping twice.\n */\nexport class ChildWorkflowError extends WorkerError {\n constructor(message: string, cause?: unknown) {\n super(message, cause);\n this.name = \"ChildWorkflowError\";\n }\n}\n\n/**\n * Discriminated variant of {@link ChildWorkflowError} surfaced when a child\n * workflow operation (start, execute, or wait-for-result) was cancelled —\n * either because the parent workflow itself was cancelled, the child was\n * explicitly cancelled, or its enclosing cancellation scope was. Detected via\n * `@temporalio/workflow`'s `isCancellation(...)`, which sees through nested\n * `ChildWorkflowFailure` / `CancelledFailure` chains.\n *\n * Extends {@link ChildWorkflowError} so existing `instanceof ChildWorkflowError`\n * checks still match cancellation, while `instanceof ChildWorkflowCancelledError`\n * lets call sites narrow further when they need to branch on cancellation\n * explicitly without inspecting `error.cause` against a Temporal SDK class —\n * the worker-side analogue of the client-side cause-forwarding pattern.\n */\nexport class ChildWorkflowCancelledError extends ChildWorkflowError {\n constructor(\n public readonly workflowName: string,\n cause?: unknown,\n ) {\n super(`Child workflow \"${workflowName}\" was cancelled`, cause);\n this.name = \"ChildWorkflowCancelledError\";\n }\n}\n\n/**\n * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed\n * cancellation scope is cancelled via Temporal's cancellation propagation.\n * Returned by both `context.cancellableScope` (when the workflow or an\n * ancestor scope cancels) and `context.nonCancellableScope` (when\n * cancellation is raised from inside the scope). Distinct from arbitrary\n * thrown errors so call sites can branch on cancellation explicitly.\n *\n * Non-cancellation errors thrown inside a scope surface as a sibling\n * {@link WorkflowScopeError} on the same `err(...)` channel, so callers can\n * use `instanceof` to discriminate without falling back to `try/catch`.\n */\nexport class WorkflowCancelledError extends WorkerError {\n constructor(cause?: unknown) {\n super(\"Workflow cancellation scope was cancelled\", cause);\n this.name = \"WorkflowCancelledError\";\n }\n}\n\n/**\n * Error surfaced in the `err(...)` branch of a `ResultAsync` when the\n * function passed to `cancellableScope` / `nonCancellableScope` throws a\n * non-cancellation error.\n *\n * The original error is preserved on `cause` so call sites can introspect\n * it without losing identity:\n *\n * @example\n * ```ts\n * const result = await context.cancellableScope(async () => {\n * return await context.activities.processStep(args);\n * });\n *\n * if (result.isErr()) {\n * if (result.error instanceof WorkflowCancelledError) {\n * // graceful cancellation\n * } else if (result.error instanceof WorkflowScopeError) {\n * // domain error — `result.error.cause` is the original throwable\n * }\n * }\n * ```\n *\n * Introduced so the scope helpers route every failure through neverthrow's\n * railway. Previously, non-cancellation errors were re-thrown out of the\n * helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`\n * does not catch) — they leaked as unhandled rejections rather than\n * surfacing on the typed error channel callers actually inspect.\n */\nexport class WorkflowScopeError extends WorkerError {\n constructor(cause: unknown) {\n const message =\n cause instanceof Error\n ? `Workflow cancellation scope caught a non-cancellation error: ${cause.message}`\n : \"Workflow cancellation scope caught a non-cancellation error\";\n super(message, cause);\n this.name = \"WorkflowScopeError\";\n }\n}\n","/**\n * Internal helpers shared across the worker package's entry points.\n *\n * Not part of the public API — this module is not listed in the package's\n * `exports` map, so consumers can't import from `@temporal-contract/worker/internal`.\n * In-package tests import it directly via relative path.\n */\nimport { isCancellation, makeContinueAsNewFunc, proxyActivities } from \"@temporalio/workflow\";\nimport type { ActivityOptions, ContinueAsNewOptions } from \"@temporalio/workflow\";\nimport { ChildWorkflowFailure } from \"@temporalio/common\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n type ActivityDefinition,\n type ContractDefinition,\n summarizeIssues,\n} from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n WorkflowInputValidationError,\n} from \"./errors.js\";\n\n/**\n * Build the message attached to a `ChildWorkflowError` for input/output\n * validation failures. Centralized so the worker formats child-workflow\n * validation diagnostics identically across call sites. Composes the shared\n * `summarizeIssues` from `@temporal-contract/contract`.\n */\nexport function formatChildWorkflowValidationMessage(\n workflowName: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n): string {\n return `Child workflow \"${workflowName}\" ${direction} validation failed: ${summarizeIssues(issues)}`;\n}\n\n// Re-export the shared `_internal_makeResultAsync` helper from the contract\n// package so worker call sites can wrap their `() => Promise<Result<T, E>>`\n// work functions identically to the client side. This closes the\n// `new ResultAsync(work())` gap — the bare constructor doesn't catch\n// rejections, so a synchronous throw or a rejected promise from `work()`\n// would otherwise escape neverthrow's railway as an unhandled rejection.\nexport { _internal_makeResultAsync as makeResultAsync } from \"@temporal-contract/contract/result-async\";\n\n/**\n * Extract the single payload from a Temporal handler's `...args` array.\n *\n * Temporal invokes handlers with whatever was passed via `args: [...]` at the\n * call site. The typed-contract layer always sends `args: [validatedInput]`,\n * so the common case is a one-element array containing the wrapped input.\n *\n * If a non-typed-contract caller passes multiple positional arguments\n * (`args: [a, b, c]`), we surface the whole array as the input — the schema\n * will then reject it unless the contract specifically modeled a tuple.\n */\nexport function extractHandlerInput(args: unknown[]): unknown {\n return args.length === 1 ? args[0] : args;\n}\n\ntype ActivityFn = (...args: unknown[]) => Promise<unknown>;\n\n/**\n * Build the raw `Record<name, fn>` proxy of activities for a workflow,\n * applying per-activity `ActivityOptions` overrides where requested.\n *\n * **Fast path (no overrides):** a single `proxyActivities(defaultOptions)`\n * call is made and returned directly. The proxy synthesizes a function for\n * any property access by name, so downstream code that looks up\n * `proxy[activityName]` works identically to before.\n *\n * **Override path:** one extra `proxyActivities(merged)` call is made *only*\n * for each activity that has an override. Activities without an entry keep\n * using the single default proxy. The result is a `Proxy` that returns the\n * override-bound function for named keys and falls back to the default proxy\n * for everything else — so the per-execution overhead scales with the number\n * of overrides, not the number of activities.\n *\n * Per-override merge is shallow: the override's properties replace the\n * default's, including the entire nested `retry` block. This matches\n * Temporal's \"one ActivityOptions per `proxyActivities` call\" semantics.\n */\nexport function buildRawActivitiesProxy(\n workflowActivities: Record<string, ActivityDefinition> | undefined,\n contractActivities: Record<string, ActivityDefinition> | undefined,\n defaultOptions: ActivityOptions,\n overrides: Partial<Record<string, ActivityOptions>> | undefined,\n): Record<string, ActivityFn> {\n const defaultProxy = proxyActivities<Record<string, ActivityFn>>(defaultOptions);\n\n // Fast path: no overrides → use the single default proxy directly.\n // (`createValidatedActivities` accesses by name, so the Proxy's get-trap\n // suffices; we don't need an enumerable map.)\n const overrideEntries = overrides\n ? Object.entries(overrides).filter(\n (entry): entry is [string, ActivityOptions] => entry[1] !== undefined,\n )\n : [];\n if (overrideEntries.length === 0) {\n return defaultProxy;\n }\n\n // Validate every override key corresponds to a declared activity.\n // Without this, a typo at runtime (or a stale options bag from a renamed\n // activity) silently builds a proxy for a non-existent activity.\n const declared = new Set<string>([\n ...Object.keys(workflowActivities ?? {}),\n ...Object.keys(contractActivities ?? {}),\n ]);\n for (const [name] of overrideEntries) {\n if (!declared.has(name)) {\n throw new Error(\n `activityOptionsByName entry \"${name}\" does not match any declared activity. Available: ${[...declared].join(\", \") || \"none\"}.`,\n );\n }\n }\n\n // Override path: build one proxy per override; combine with the default\n // proxy via a get-trap so unmatched keys still get the default options.\n const overriddenFns: Record<string, ActivityFn> = {};\n for (const [name, override] of overrideEntries) {\n const mergedOptions: ActivityOptions = { ...defaultOptions, ...override };\n const overrideProxy = proxyActivities<Record<string, ActivityFn>>(mergedOptions);\n const fn = overrideProxy[name];\n if (fn !== undefined) {\n overriddenFns[name] = fn;\n }\n }\n\n return new Proxy(overriddenFns, {\n get(target, prop) {\n if (typeof prop !== \"string\") return undefined;\n return target[prop] ?? defaultProxy[prop];\n },\n });\n}\n\n/**\n * Continue-as-new options the typed wrapper does not own. `workflowType` and\n * `taskQueue` are derived from the contract; everything else is forwarded to\n * Temporal's `makeContinueAsNewFunc`.\n */\nexport type TypedContinueAsNewOptions = Omit<ContinueAsNewOptions, \"workflowType\" | \"taskQueue\">;\n\n/**\n * Build the typed `continueAsNew` function bound to the running workflow's\n * contract. Two overloads — same-workflow and cross-contract — share one\n * implementation; the public type signature lives on `WorkflowContext` so\n * call sites are type-safe.\n *\n * Validation runs *before* Temporal's `makeContinueAsNewFunc(...)` is invoked.\n * On failure, throws a `WorkflowInputValidationError` (matching the behaviour\n * of `declareWorkflow`'s incoming-input validation), which surfaces back to\n * Temporal as a workflow failure rather than silently proceeding with an\n * invalid run.\n *\n * Temporal's `continueAsNew` never returns — it throws a `ContinueAsNew`\n * exception that the runtime intercepts. The returned function preserves\n * `Promise<never>` to encode that.\n *\n * @internal\n */\nexport function createContinueAsNew(\n currentContract: ContractDefinition,\n currentWorkflowName: string | number | symbol,\n) {\n return async function continueAsNew(\n arg1: unknown,\n arg2?: unknown,\n arg3?: unknown,\n arg4?: TypedContinueAsNewOptions,\n ): Promise<never> {\n // Cross-contract dispatch is only triggered when the call signature\n // unambiguously matches `(contract, workflowName, args, options?)`:\n //\n // 1. `arg1` is a non-null object that *looks like* a contract — it has a\n // string `taskQueue` and a non-null `workflows` object.\n // 2. `arg2` is a string — the destination workflow name.\n // 3. `arg2` resolves to a workflow definition on `arg1.workflows` with a\n // Standard Schema `input.~standard.validate` function.\n //\n // Without (2)+(3), a same-workflow input that happens to have `taskQueue`\n // and `workflows` keys (or `workflows = null`, where `typeof === \"object\"`)\n // would be silently misclassified. The full triple of structural checks\n // makes the false-positive surface vanishingly small.\n const isCrossContract = looksLikeCrossContractCall(arg1, arg2);\n\n let targetContract: ContractDefinition;\n let targetName: string;\n let rawArgs: unknown;\n let options: TypedContinueAsNewOptions | undefined;\n\n if (isCrossContract) {\n targetContract = arg1 as ContractDefinition;\n targetName = arg2 as string;\n rawArgs = arg3;\n options = arg4;\n } else {\n targetContract = currentContract;\n targetName = String(currentWorkflowName);\n rawArgs = arg1;\n options = arg2 as TypedContinueAsNewOptions | undefined;\n }\n\n const targetDef = targetContract.workflows[targetName];\n if (!targetDef) {\n throw new WorkflowInputValidationError(targetName, [\n {\n message: `continueAsNew target workflow \"${targetName}\" is not declared on the supplied contract.`,\n },\n ]);\n }\n\n const inputResult = await targetDef.input[\"~standard\"].validate(rawArgs);\n if (inputResult.issues) {\n throw new WorkflowInputValidationError(targetName, inputResult.issues);\n }\n\n // workflowType/taskQueue come from the destination contract; user\n // options are spread last so power users can override (e.g. retry,\n // memo). The public TypedContinueAsNewOptions type Omits workflowType\n // and taskQueue so this isn't a footgun on the typed call path.\n const fn = makeContinueAsNewFunc({\n workflowType: targetName,\n taskQueue: targetContract.taskQueue,\n ...options,\n });\n\n await fn(inputResult.value);\n // Unreachable — Temporal's continueAsNew throws to terminate the run.\n /* c8 ignore next */\n return undefined as never;\n };\n}\n\n/**\n * Structural check: does `(arg1, arg2)` look like the\n * `(contract, workflowName, ...)` cross-contract overload of `continueAsNew`?\n *\n * Returns `true` only when:\n * 1. `arg1` is a non-null object with a string `taskQueue` and a non-null\n * object `workflows` (handles `workflows: null`, where\n * `typeof null === \"object\"`).\n * 2. `arg2` is a string.\n *\n * Both halves matter. A same-workflow input that happens to contain\n * `taskQueue` and `workflows` keys would otherwise be misclassified — but\n * none of the same-workflow signatures (`continueAsNew(args)`,\n * `continueAsNew(args, options)`) accept a string as `arg2`, so the\n * second check makes the false-positive surface vanishingly small.\n *\n * We deliberately do *not* check that `arg1.workflows[arg2]` is a valid\n * workflow definition. If it isn't, the dispatcher falls through to the\n * `targetContract.workflows[targetName]` lookup which throws a clear\n * \"target workflow X is not declared\" error — better than silently\n * misrouting a typo back to the current workflow.\n */\nfunction looksLikeCrossContractCall(arg1: unknown, arg2: unknown): boolean {\n if (typeof arg1 !== \"object\" || arg1 === null) return false;\n if (typeof arg2 !== \"string\") return false;\n const candidate = arg1 as Record<string, unknown>;\n if (typeof candidate[\"taskQueue\"] !== \"string\") return false;\n const workflows = candidate[\"workflows\"];\n return typeof workflows === \"object\" && workflows !== null;\n}\n\n/**\n * Map a thrown error from `startChild` / `executeChild` / `handle.result()`\n * (the worker-side child-workflow API) into the discriminated union surfaced\n * by the typed worker. Mirrors the client's `classifyResultError`:\n *\n * - Cancellation (detected via `@temporalio/workflow`'s `isCancellation`,\n * which sees through nested `ChildWorkflowFailure → CancelledFailure`\n * chains) → {@link ChildWorkflowCancelledError}, with the original error\n * carried as `cause`.\n * - Temporal's `ChildWorkflowFailure` (a wrapper whose actionable failure —\n * `ApplicationFailure`, `TimeoutFailure`, `TerminatedFailure`, etc. — lives\n * on its `cause` field) → {@link ChildWorkflowError}, with that *inner*\n * cause forwarded so consumers can match `err.cause instanceof\n * ApplicationFailure` without unwrapping twice. (If the wrapper's `cause`\n * is `undefined`, the wrapper itself is forwarded so identity is\n * preserved.)\n * - Anything else → {@link ChildWorkflowError} carrying the raw thrown value\n * as `cause`.\n *\n * The `operation` discriminator drives the human-readable error message so\n * call sites don't have to format their own.\n *\n * Note: `ChildWorkflowNotFoundError` is *not* produced here — it's only\n * thrown from the input-validation path when the workflow definition is\n * missing on the contract, before any Temporal call happens.\n */\nexport function classifyChildWorkflowError(\n operation: \"startChild\" | \"executeChild\" | \"result\",\n error: unknown,\n childWorkflowName: string,\n): ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError {\n // Cancellation takes priority: a cancelled child surfaces as a\n // `ChildWorkflowFailure` whose cause is a `CancelledFailure`, and we want\n // the cancellation discriminant rather than the generic wrapper.\n if (isCancellation(error)) {\n return new ChildWorkflowCancelledError(childWorkflowName, error);\n }\n\n // Temporal wraps the actionable failure (ApplicationFailure, TimeoutFailure,\n // TerminatedFailure, etc.) inside a ChildWorkflowFailure. Forward the\n // inner cause so consumers can branch on the failure category without\n // unwrapping twice. Fall back to the wrapper itself if `cause` is missing\n // so callers don't lose the error identity.\n if (error instanceof ChildWorkflowFailure) {\n const inner = error.cause ?? error;\n const innerMessage = inner instanceof Error ? inner.message : String(inner);\n return new ChildWorkflowError(\n `${describeChildWorkflowOperation(operation, childWorkflowName)}: ${innerMessage}`,\n inner,\n );\n }\n\n const message = error instanceof Error ? error.message : String(error);\n return new ChildWorkflowError(\n `${describeChildWorkflowOperation(operation, childWorkflowName)}: ${message}`,\n error,\n );\n}\n\nfunction describeChildWorkflowOperation(\n operation: \"startChild\" | \"executeChild\" | \"result\",\n childWorkflowName: string,\n): string {\n switch (operation) {\n case \"startChild\":\n return `Failed to start child workflow \"${childWorkflowName}\"`;\n case \"executeChild\":\n return `Failed to execute child workflow \"${childWorkflowName}\"`;\n case \"result\":\n return `Child workflow \"${childWorkflowName}\" execution failed`;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAe,cAAf,cAAmC,MAAM;CACvC,YAAsB,SAAiB,OAAiB;AACtD,QAAM,SAAS,EAAE,OAAO,CAAC;AACzB,OAAK,OAAO;AAEZ,MAAI,MAAM,kBACR,OAAM,kBAAkB,MAAM,KAAK,YAAY;;;;;;AAQrD,IAAa,kCAAb,cAAqD,YAAY;CAC/D,YACE,cACA,uBAA0D,EAAE,EAC5D;EACA,MAAM,YAAY,qBAAqB,SAAS,IAAI,qBAAqB,KAAK,KAAK,GAAG;AACtF,QACE,uCAAuC,aAAa,2BAA2B,YAChF;AANe,OAAA,eAAA;AACA,OAAA,uBAAA;AAMhB,OAAK,OAAO;;;;;;AAOhB,IAAa,+BAAb,cAAkD,YAAY;CAC5D,YACE,cACA,QACA;EACA,MAAM,UAAU,gBAAgB,OAAO;AACvC,QAAM,aAAa,aAAa,6BAA6B,UAAU;AAJvD,OAAA,eAAA;AACA,OAAA,SAAA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AAO,qCAAqC,kBAAkB;EAChE,KAAK,SACH,QAAO,mBAAmB,kBAAkB"}
1
+ {"version":3,"file":"internal-D8Dl9D43.mjs","names":[],"sources":["../src/errors.ts","../src/internal.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"@temporal-contract/contract\";\n\n/**\n * Base error class for worker errors\n */\nabstract class WorkerError extends Error {\n protected constructor(message: string, cause?: unknown) {\n super(message, { cause });\n this.name = \"WorkerError\";\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when an activity definition is not found in the contract\n */\nexport class ActivityDefinitionNotFoundError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly availableDefinitions: readonly string[] = [],\n ) {\n const available = availableDefinitions.length > 0 ? availableDefinitions.join(\", \") : \"none\";\n super(\n `Activity definition not found for: \"${activityName}\". Available activities: ${available}`,\n );\n this.name = \"ActivityDefinitionNotFoundError\";\n }\n}\n\n/**\n * Error thrown when activity input validation fails\n */\nexport class ActivityInputValidationError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Activity \"${activityName}\" input validation failed: ${message}`);\n this.name = \"ActivityInputValidationError\";\n }\n}\n\n/**\n * Error thrown when activity output validation fails\n */\nexport class ActivityOutputValidationError extends WorkerError {\n constructor(\n public readonly activityName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Activity \"${activityName}\" output validation failed: ${message}`);\n this.name = \"ActivityOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when workflow input validation fails\n */\nexport class WorkflowInputValidationError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Workflow \"${workflowName}\" input validation failed: ${message}`);\n this.name = \"WorkflowInputValidationError\";\n }\n}\n\n/**\n * Error thrown when workflow output validation fails\n */\nexport class WorkflowOutputValidationError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Workflow \"${workflowName}\" output validation failed: ${message}`);\n this.name = \"WorkflowOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when signal input validation fails\n */\nexport class SignalInputValidationError extends WorkerError {\n constructor(\n public readonly signalName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Signal \"${signalName}\" input validation failed: ${message}`);\n this.name = \"SignalInputValidationError\";\n }\n}\n\n/**\n * Error thrown when query input validation fails\n */\nexport class QueryInputValidationError extends WorkerError {\n constructor(\n public readonly queryName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Query \"${queryName}\" input validation failed: ${message}`);\n this.name = \"QueryInputValidationError\";\n }\n}\n\n/**\n * Error thrown when query output validation fails\n */\nexport class QueryOutputValidationError extends WorkerError {\n constructor(\n public readonly queryName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Query \"${queryName}\" output validation failed: ${message}`);\n this.name = \"QueryOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when update input validation fails\n */\nexport class UpdateInputValidationError extends WorkerError {\n constructor(\n public readonly updateName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Update \"${updateName}\" input validation failed: ${message}`);\n this.name = \"UpdateInputValidationError\";\n }\n}\n\n/**\n * Error thrown when update output validation fails\n */\nexport class UpdateOutputValidationError extends WorkerError {\n constructor(\n public readonly updateName: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(`Update \"${updateName}\" output validation failed: ${message}`);\n this.name = \"UpdateOutputValidationError\";\n }\n}\n\n/**\n * Error thrown when a child workflow is not found in the contract\n */\nexport class ChildWorkflowNotFoundError extends WorkerError {\n constructor(\n public readonly workflowName: string,\n public readonly availableWorkflows: readonly string[] = [],\n ) {\n const available = availableWorkflows.length > 0 ? availableWorkflows.join(\", \") : \"none\";\n super(`Child workflow not found: \"${workflowName}\". Available workflows: ${available}`);\n this.name = \"ChildWorkflowNotFoundError\";\n }\n}\n\n/**\n * Generic error for child workflow operations.\n *\n * When the child execution itself fails (Temporal's `ChildWorkflowFailure`),\n * `cause` is set to the *unwrapped* underlying failure (`ApplicationFailure`,\n * `TimeoutFailure`, `TerminatedFailure`, etc.) lifted from Temporal's wrapper —\n * mirroring the client-side `WorkflowFailedError.cause` behavior, so callers\n * can branch on the failure category in one step instead of unwrapping twice.\n */\nexport class ChildWorkflowError extends WorkerError {\n constructor(message: string, cause?: unknown) {\n super(message, cause);\n this.name = \"ChildWorkflowError\";\n }\n}\n\n/**\n * Discriminated variant of {@link ChildWorkflowError} surfaced when a child\n * workflow operation (start, execute, or wait-for-result) was cancelled —\n * either because the parent workflow itself was cancelled, the child was\n * explicitly cancelled, or its enclosing cancellation scope was. Detected via\n * `@temporalio/workflow`'s `isCancellation(...)`, which sees through nested\n * `ChildWorkflowFailure` / `CancelledFailure` chains.\n *\n * Extends {@link ChildWorkflowError} so existing `instanceof ChildWorkflowError`\n * checks still match cancellation, while `instanceof ChildWorkflowCancelledError`\n * lets call sites narrow further when they need to branch on cancellation\n * explicitly without inspecting `error.cause` against a Temporal SDK class —\n * the worker-side analogue of the client-side cause-forwarding pattern.\n */\nexport class ChildWorkflowCancelledError extends ChildWorkflowError {\n constructor(\n public readonly workflowName: string,\n cause?: unknown,\n ) {\n super(`Child workflow \"${workflowName}\" was cancelled`, cause);\n this.name = \"ChildWorkflowCancelledError\";\n }\n}\n\n/**\n * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed\n * cancellation scope is cancelled via Temporal's cancellation propagation.\n * Returned by both `context.cancellableScope` (when the workflow or an\n * ancestor scope cancels) and `context.nonCancellableScope` (when\n * cancellation is raised from inside the scope). Distinct from arbitrary\n * thrown errors so call sites can branch on cancellation explicitly.\n *\n * Non-cancellation errors thrown inside a scope surface as a sibling\n * {@link WorkflowScopeError} on the same `err(...)` channel, so callers can\n * use `instanceof` to discriminate without falling back to `try/catch`.\n */\nexport class WorkflowCancelledError extends WorkerError {\n constructor(cause?: unknown) {\n super(\"Workflow cancellation scope was cancelled\", cause);\n this.name = \"WorkflowCancelledError\";\n }\n}\n\n/**\n * Error surfaced in the `err(...)` branch of a `ResultAsync` when the\n * function passed to `cancellableScope` / `nonCancellableScope` throws a\n * non-cancellation error.\n *\n * The original error is preserved on `cause` so call sites can introspect\n * it without losing identity:\n *\n * @example\n * ```ts\n * const result = await context.cancellableScope(async () => {\n * return await context.activities.processStep(args);\n * });\n *\n * if (result.isErr()) {\n * if (result.error instanceof WorkflowCancelledError) {\n * // graceful cancellation\n * } else if (result.error instanceof WorkflowScopeError) {\n * // domain error — `result.error.cause` is the original throwable\n * }\n * }\n * ```\n *\n * Introduced so the scope helpers route every failure through neverthrow's\n * railway. Previously, non-cancellation errors were re-thrown out of the\n * helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`\n * does not catch) — they leaked as unhandled rejections rather than\n * surfacing on the typed error channel callers actually inspect.\n */\nexport class WorkflowScopeError extends WorkerError {\n constructor(cause: unknown) {\n const message =\n cause instanceof Error\n ? `Workflow cancellation scope caught a non-cancellation error: ${cause.message}`\n : \"Workflow cancellation scope caught a non-cancellation error\";\n super(message, cause);\n this.name = \"WorkflowScopeError\";\n }\n}\n","/**\n * Internal helpers shared across the worker package's entry points.\n *\n * Not part of the public API — this module is not listed in the package's\n * `exports` map, so consumers can't import from `@temporal-contract/worker/internal`.\n * In-package tests import it directly via relative path.\n */\nimport { isCancellation, makeContinueAsNewFunc, proxyActivities } from \"@temporalio/workflow\";\nimport type { ActivityOptions, ContinueAsNewOptions } from \"@temporalio/workflow\";\nimport { ChildWorkflowFailure } from \"@temporalio/common\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n type ActivityDefinition,\n type ContractDefinition,\n summarizeIssues,\n} from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n WorkflowInputValidationError,\n} from \"./errors.js\";\n\n/**\n * Build the message attached to a `ChildWorkflowError` for input/output\n * validation failures. Centralized so the worker formats child-workflow\n * validation diagnostics identically across call sites. Composes the shared\n * `summarizeIssues` from `@temporal-contract/contract`.\n */\nexport function formatChildWorkflowValidationMessage(\n workflowName: string,\n direction: \"input\" | \"output\",\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n): string {\n return `Child workflow \"${workflowName}\" ${direction} validation failed: ${summarizeIssues(issues)}`;\n}\n\n// Re-export the shared `_internal_makeResultAsync` helper from the contract\n// package so worker call sites can wrap their `() => Promise<Result<T, E>>`\n// work functions identically to the client side. This closes the\n// `new ResultAsync(work())` gap — the bare constructor doesn't catch\n// rejections, so a synchronous throw or a rejected promise from `work()`\n// would otherwise escape neverthrow's railway as an unhandled rejection.\nexport { _internal_makeResultAsync as makeResultAsync } from \"@temporal-contract/contract/result-async\";\n\n/**\n * Extract the single payload from a Temporal handler's `...args` array.\n *\n * Temporal invokes handlers with whatever was passed via `args: [...]` at the\n * call site. The typed-contract layer always sends `args: [validatedInput]`,\n * so the common case is a one-element array containing the wrapped input.\n *\n * If a non-typed-contract caller passes multiple positional arguments\n * (`args: [a, b, c]`), we surface the whole array as the input — the schema\n * will then reject it unless the contract specifically modeled a tuple.\n */\nexport function extractHandlerInput(args: unknown[]): unknown {\n return args.length === 1 ? args[0] : args;\n}\n\ntype ActivityFn = (...args: unknown[]) => Promise<unknown>;\n\n/**\n * Build the raw `Record<name, fn>` proxy of activities for a workflow,\n * applying per-activity `ActivityOptions` overrides where requested.\n *\n * **Fast path (no overrides):** a single `proxyActivities(defaultOptions)`\n * call is made and returned directly. The proxy synthesizes a function for\n * any property access by name, so downstream code that looks up\n * `proxy[activityName]` works identically to before.\n *\n * **Override path:** one extra `proxyActivities(merged)` call is made *only*\n * for each activity that has an override. Activities without an entry keep\n * using the single default proxy. The result is a `Proxy` that returns the\n * override-bound function for named keys and falls back to the default proxy\n * for everything else — so the per-execution overhead scales with the number\n * of overrides, not the number of activities.\n *\n * Per-override merge is shallow: the override's properties replace the\n * default's, including the entire nested `retry` block. This matches\n * Temporal's \"one ActivityOptions per `proxyActivities` call\" semantics.\n */\nexport function buildRawActivitiesProxy(\n workflowActivities: Record<string, ActivityDefinition> | undefined,\n contractActivities: Record<string, ActivityDefinition> | undefined,\n defaultOptions: ActivityOptions,\n overrides: Partial<Record<string, ActivityOptions>> | undefined,\n): Record<string, ActivityFn> {\n const defaultProxy = proxyActivities<Record<string, ActivityFn>>(defaultOptions);\n\n // Fast path: no overrides → use the single default proxy directly.\n // (`createValidatedActivities` accesses by name, so the Proxy's get-trap\n // suffices; we don't need an enumerable map.)\n const overrideEntries = overrides\n ? Object.entries(overrides).filter(\n (entry): entry is [string, ActivityOptions] => entry[1] !== undefined,\n )\n : [];\n if (overrideEntries.length === 0) {\n return defaultProxy;\n }\n\n // Validate every override key corresponds to a declared activity.\n // Without this, a typo at runtime (or a stale options bag from a renamed\n // activity) silently builds a proxy for a non-existent activity.\n const declared = new Set<string>([\n ...Object.keys(workflowActivities ?? {}),\n ...Object.keys(contractActivities ?? {}),\n ]);\n for (const [name] of overrideEntries) {\n if (!declared.has(name)) {\n throw new Error(\n `activityOptionsByName entry \"${name}\" does not match any declared activity. Available: ${[...declared].join(\", \") || \"none\"}.`,\n );\n }\n }\n\n // Override path: build one proxy per override; combine with the default\n // proxy via a get-trap so unmatched keys still get the default options.\n const overriddenFns: Record<string, ActivityFn> = {};\n for (const [name, override] of overrideEntries) {\n const mergedOptions: ActivityOptions = { ...defaultOptions, ...override };\n const overrideProxy = proxyActivities<Record<string, ActivityFn>>(mergedOptions);\n const fn = overrideProxy[name];\n if (fn !== undefined) {\n overriddenFns[name] = fn;\n }\n }\n\n return new Proxy(overriddenFns, {\n get(target, prop) {\n if (typeof prop !== \"string\") return undefined;\n return target[prop] ?? defaultProxy[prop];\n },\n });\n}\n\n/**\n * Continue-as-new options the typed wrapper does not own. `workflowType` and\n * `taskQueue` are derived from the contract; everything else is forwarded to\n * Temporal's `makeContinueAsNewFunc`.\n */\nexport type TypedContinueAsNewOptions = Omit<ContinueAsNewOptions, \"workflowType\" | \"taskQueue\">;\n\n/**\n * Build the typed `continueAsNew` function bound to the running workflow's\n * contract. Two overloads — same-workflow and cross-contract — share one\n * implementation; the public type signature lives on `WorkflowContext` so\n * call sites are type-safe.\n *\n * Validation runs *before* Temporal's `makeContinueAsNewFunc(...)` is invoked.\n * On failure, throws a `WorkflowInputValidationError` (matching the behaviour\n * of `declareWorkflow`'s incoming-input validation), which surfaces back to\n * Temporal as a workflow failure rather than silently proceeding with an\n * invalid run.\n *\n * Temporal's `continueAsNew` never returns — it throws a `ContinueAsNew`\n * exception that the runtime intercepts. The returned function preserves\n * `Promise<never>` to encode that.\n *\n * @internal\n */\nexport function createContinueAsNew(\n currentContract: ContractDefinition,\n currentWorkflowName: string | number | symbol,\n) {\n return async function continueAsNew(\n arg1: unknown,\n arg2?: unknown,\n arg3?: unknown,\n arg4?: TypedContinueAsNewOptions,\n ): Promise<never> {\n // Cross-contract dispatch is only triggered when the call signature\n // unambiguously matches `(contract, workflowName, args, options?)`:\n //\n // 1. `arg1` is a non-null object that *looks like* a contract — it has a\n // string `taskQueue` and a non-null `workflows` object.\n // 2. `arg2` is a string — the destination workflow name.\n // 3. `arg2` resolves to a workflow definition on `arg1.workflows` with a\n // Standard Schema `input.~standard.validate` function.\n //\n // Without (2)+(3), a same-workflow input that happens to have `taskQueue`\n // and `workflows` keys (or `workflows = null`, where `typeof === \"object\"`)\n // would be silently misclassified. The full triple of structural checks\n // makes the false-positive surface vanishingly small.\n const isCrossContract = looksLikeCrossContractCall(arg1, arg2);\n\n let targetContract: ContractDefinition;\n let targetName: string;\n let rawArgs: unknown;\n let options: TypedContinueAsNewOptions | undefined;\n\n if (isCrossContract) {\n targetContract = arg1 as ContractDefinition;\n targetName = arg2 as string;\n rawArgs = arg3;\n options = arg4;\n } else {\n targetContract = currentContract;\n targetName = String(currentWorkflowName);\n rawArgs = arg1;\n options = arg2 as TypedContinueAsNewOptions | undefined;\n }\n\n const targetDef = targetContract.workflows[targetName];\n if (!targetDef) {\n throw new WorkflowInputValidationError(targetName, [\n {\n message: `continueAsNew target workflow \"${targetName}\" is not declared on the supplied contract.`,\n },\n ]);\n }\n\n const inputResult = await targetDef.input[\"~standard\"].validate(rawArgs);\n if (inputResult.issues) {\n throw new WorkflowInputValidationError(targetName, inputResult.issues);\n }\n\n // workflowType/taskQueue come from the destination contract; user\n // options are spread last so power users can override (e.g. retry,\n // memo). The public TypedContinueAsNewOptions type Omits workflowType\n // and taskQueue so this isn't a footgun on the typed call path.\n const fn = makeContinueAsNewFunc({\n workflowType: targetName,\n taskQueue: targetContract.taskQueue,\n ...options,\n });\n\n await fn(inputResult.value);\n // Unreachable — Temporal's continueAsNew throws to terminate the run.\n /* c8 ignore next */\n return undefined as never;\n };\n}\n\n/**\n * Structural check: does `(arg1, arg2)` look like the\n * `(contract, workflowName, ...)` cross-contract overload of `continueAsNew`?\n *\n * Returns `true` only when:\n * 1. `arg1` is a non-null object with a string `taskQueue` and a non-null\n * object `workflows` (handles `workflows: null`, where\n * `typeof null === \"object\"`).\n * 2. `arg2` is a string.\n *\n * Both halves matter. A same-workflow input that happens to contain\n * `taskQueue` and `workflows` keys would otherwise be misclassified — but\n * none of the same-workflow signatures (`continueAsNew(args)`,\n * `continueAsNew(args, options)`) accept a string as `arg2`, so the\n * second check makes the false-positive surface vanishingly small.\n *\n * We deliberately do *not* check that `arg1.workflows[arg2]` is a valid\n * workflow definition. If it isn't, the dispatcher falls through to the\n * `targetContract.workflows[targetName]` lookup which throws a clear\n * \"target workflow X is not declared\" error — better than silently\n * misrouting a typo back to the current workflow.\n */\nfunction looksLikeCrossContractCall(arg1: unknown, arg2: unknown): boolean {\n if (typeof arg1 !== \"object\" || arg1 === null) return false;\n if (typeof arg2 !== \"string\") return false;\n const candidate = arg1 as Record<string, unknown>;\n if (typeof candidate[\"taskQueue\"] !== \"string\") return false;\n const workflows = candidate[\"workflows\"];\n return typeof workflows === \"object\" && workflows !== null;\n}\n\n/**\n * Map a thrown error from `startChild` / `executeChild` / `handle.result()`\n * (the worker-side child-workflow API) into the discriminated union surfaced\n * by the typed worker. Mirrors the client's `classifyResultError`:\n *\n * - Cancellation (detected via `@temporalio/workflow`'s `isCancellation`,\n * which sees through nested `ChildWorkflowFailure → CancelledFailure`\n * chains) → {@link ChildWorkflowCancelledError}, with the original error\n * carried as `cause`.\n * - Temporal's `ChildWorkflowFailure` (a wrapper whose actionable failure —\n * `ApplicationFailure`, `TimeoutFailure`, `TerminatedFailure`, etc. — lives\n * on its `cause` field) → {@link ChildWorkflowError}, with that *inner*\n * cause forwarded so consumers can match `err.cause instanceof\n * ApplicationFailure` without unwrapping twice. (If the wrapper's `cause`\n * is `undefined`, the wrapper itself is forwarded so identity is\n * preserved.)\n * - Anything else → {@link ChildWorkflowError} carrying the raw thrown value\n * as `cause`.\n *\n * The `operation` discriminator drives the human-readable error message so\n * call sites don't have to format their own.\n *\n * Note: `ChildWorkflowNotFoundError` is *not* produced here — it's only\n * thrown from the input-validation path when the workflow definition is\n * missing on the contract, before any Temporal call happens.\n */\nexport function classifyChildWorkflowError(\n operation: \"startChild\" | \"executeChild\" | \"result\",\n error: unknown,\n childWorkflowName: string,\n): ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError {\n // Cancellation takes priority: a cancelled child surfaces as a\n // `ChildWorkflowFailure` whose cause is a `CancelledFailure`, and we want\n // the cancellation discriminant rather than the generic wrapper.\n if (isCancellation(error)) {\n return new ChildWorkflowCancelledError(childWorkflowName, error);\n }\n\n // Temporal wraps the actionable failure (ApplicationFailure, TimeoutFailure,\n // TerminatedFailure, etc.) inside a ChildWorkflowFailure. Forward the\n // inner cause so consumers can branch on the failure category without\n // unwrapping twice. Fall back to the wrapper itself if `cause` is missing\n // so callers don't lose the error identity.\n if (error instanceof ChildWorkflowFailure) {\n const inner = error.cause ?? error;\n const innerMessage = inner instanceof Error ? inner.message : String(inner);\n return new ChildWorkflowError(\n `${describeChildWorkflowOperation(operation, childWorkflowName)}: ${innerMessage}`,\n inner,\n );\n }\n\n const message = error instanceof Error ? error.message : String(error);\n return new ChildWorkflowError(\n `${describeChildWorkflowOperation(operation, childWorkflowName)}: ${message}`,\n error,\n );\n}\n\nfunction describeChildWorkflowOperation(\n operation: \"startChild\" | \"executeChild\" | \"result\",\n childWorkflowName: string,\n): string {\n switch (operation) {\n case \"startChild\":\n return `Failed to start child workflow \"${childWorkflowName}\"`;\n case \"executeChild\":\n return `Failed to execute child workflow \"${childWorkflowName}\"`;\n case \"result\":\n return `Child workflow \"${childWorkflowName}\" execution failed`;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAe,cAAf,cAAmC,MAAM;CACvC,YAAsB,SAAiB,OAAiB;EACtD,MAAM,SAAS,EAAE,MAAM,CAAC;EACxB,KAAK,OAAO;EAEZ,IAAI,MAAM,mBACR,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAElD;AACF;;;;AAKA,IAAa,kCAAb,cAAqD,YAAY;CAE7C;CACA;CAFlB,YACE,cACA,uBAA0D,CAAC,GAC3D;EACA,MAAM,YAAY,qBAAqB,SAAS,IAAI,qBAAqB,KAAK,IAAI,IAAI;EACtF,MACE,uCAAuC,aAAa,2BAA2B,WACjF;EANgB,KAAA,eAAA;EACA,KAAA,uBAAA;EAMhB,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,+BAAb,cAAkD,YAAY;CAE1C;CACA;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AM,SAAS;EAC7B,MAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC1E,OAAO,IAAI,mBACT,GAAG,+BAA+B,WAAW,iBAAiB,EAAE,IAAI,gBACpE,KACF;CACF;CAEA,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,OAAO,IAAI,mBACT,GAAG,+BAA+B,WAAW,iBAAiB,EAAE,IAAI,WACpE,KACF;AACF;AAEA,SAAS,+BACP,WACA,mBACQ;CACR,QAAQ,WAAR;EACE,KAAK,cACH,OAAO,mCAAmC,kBAAkB;EAC9D,KAAK,gBACH,OAAO,qCAAqC,kBAAkB;EAChE,KAAK,UACH,OAAO,mBAAmB,kBAAkB;CAChD;AACF"}
@@ -17,6 +17,8 @@ var WorkerError = class extends Error {
17
17
  * Error thrown when an activity definition is not found in the contract
18
18
  */
19
19
  var ActivityDefinitionNotFoundError = class extends WorkerError {
20
+ activityName;
21
+ availableDefinitions;
20
22
  constructor(activityName, availableDefinitions = []) {
21
23
  const available = availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none";
22
24
  super(`Activity definition not found for: "${activityName}". Available activities: ${available}`);
@@ -29,6 +31,8 @@ var ActivityDefinitionNotFoundError = class extends WorkerError {
29
31
  * Error thrown when activity input validation fails
30
32
  */
31
33
  var ActivityInputValidationError = class extends WorkerError {
34
+ activityName;
35
+ issues;
32
36
  constructor(activityName, issues) {
33
37
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
34
38
  super(`Activity "${activityName}" input validation failed: ${message}`);
@@ -41,6 +45,8 @@ var ActivityInputValidationError = class extends WorkerError {
41
45
  * Error thrown when activity output validation fails
42
46
  */
43
47
  var ActivityOutputValidationError = class extends WorkerError {
48
+ activityName;
49
+ issues;
44
50
  constructor(activityName, issues) {
45
51
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
46
52
  super(`Activity "${activityName}" output validation failed: ${message}`);
@@ -53,6 +59,8 @@ var ActivityOutputValidationError = class extends WorkerError {
53
59
  * Error thrown when workflow input validation fails
54
60
  */
55
61
  var WorkflowInputValidationError = class extends WorkerError {
62
+ workflowName;
63
+ issues;
56
64
  constructor(workflowName, issues) {
57
65
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
58
66
  super(`Workflow "${workflowName}" input validation failed: ${message}`);
@@ -65,6 +73,8 @@ var WorkflowInputValidationError = class extends WorkerError {
65
73
  * Error thrown when workflow output validation fails
66
74
  */
67
75
  var WorkflowOutputValidationError = class extends WorkerError {
76
+ workflowName;
77
+ issues;
68
78
  constructor(workflowName, issues) {
69
79
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
70
80
  super(`Workflow "${workflowName}" output validation failed: ${message}`);
@@ -77,6 +87,8 @@ var WorkflowOutputValidationError = class extends WorkerError {
77
87
  * Error thrown when signal input validation fails
78
88
  */
79
89
  var SignalInputValidationError = class extends WorkerError {
90
+ signalName;
91
+ issues;
80
92
  constructor(signalName, issues) {
81
93
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
82
94
  super(`Signal "${signalName}" input validation failed: ${message}`);
@@ -89,6 +101,8 @@ var SignalInputValidationError = class extends WorkerError {
89
101
  * Error thrown when query input validation fails
90
102
  */
91
103
  var QueryInputValidationError = class extends WorkerError {
104
+ queryName;
105
+ issues;
92
106
  constructor(queryName, issues) {
93
107
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
94
108
  super(`Query "${queryName}" input validation failed: ${message}`);
@@ -101,6 +115,8 @@ var QueryInputValidationError = class extends WorkerError {
101
115
  * Error thrown when query output validation fails
102
116
  */
103
117
  var QueryOutputValidationError = class extends WorkerError {
118
+ queryName;
119
+ issues;
104
120
  constructor(queryName, issues) {
105
121
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
106
122
  super(`Query "${queryName}" output validation failed: ${message}`);
@@ -113,6 +129,8 @@ var QueryOutputValidationError = class extends WorkerError {
113
129
  * Error thrown when update input validation fails
114
130
  */
115
131
  var UpdateInputValidationError = class extends WorkerError {
132
+ updateName;
133
+ issues;
116
134
  constructor(updateName, issues) {
117
135
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
118
136
  super(`Update "${updateName}" input validation failed: ${message}`);
@@ -125,6 +143,8 @@ var UpdateInputValidationError = class extends WorkerError {
125
143
  * Error thrown when update output validation fails
126
144
  */
127
145
  var UpdateOutputValidationError = class extends WorkerError {
146
+ updateName;
147
+ issues;
128
148
  constructor(updateName, issues) {
129
149
  const message = (0, _temporal_contract_contract.summarizeIssues)(issues);
130
150
  super(`Update "${updateName}" output validation failed: ${message}`);
@@ -137,6 +157,8 @@ var UpdateOutputValidationError = class extends WorkerError {
137
157
  * Error thrown when a child workflow is not found in the contract
138
158
  */
139
159
  var ChildWorkflowNotFoundError = class extends WorkerError {
160
+ workflowName;
161
+ availableWorkflows;
140
162
  constructor(workflowName, availableWorkflows = []) {
141
163
  const available = availableWorkflows.length > 0 ? availableWorkflows.join(", ") : "none";
142
164
  super(`Child workflow not found: "${workflowName}". Available workflows: ${available}`);
@@ -175,6 +197,7 @@ var ChildWorkflowError = class extends WorkerError {
175
197
  * the worker-side analogue of the client-side cause-forwarding pattern.
176
198
  */
177
199
  var ChildWorkflowCancelledError = class extends ChildWorkflowError {
200
+ workflowName;
178
201
  constructor(workflowName, cause) {
179
202
  super(`Child workflow "${workflowName}" was cancelled`, cause);
180
203
  this.workflowName = workflowName;
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.cts","names":[],"sources":["../src/worker.ts"],"mappings":";;;;;;;AASA;KAAY,mBAAA,mBAAsC,kBAAA,IAAsB,IAAA,CACtE,aAAA;EAD6B;;;EAO7B,QAAA,EAAU,SAAA;EAAA;;;EAKV,UAAA,EAAY,iBAAA,CAAkB,SAAA;AAAA;;;;;;;;;;;;AA+BhC;;;;;;;;;;;;;;;;;iBAAsB,YAAA,mBAA+B,kBAAA,CAAA,CACnD,OAAA,EAAS,mBAAA,CAAoB,SAAA,IAC5B,OAAA,CAAQ,MAAA;;AAkCX;;;;;;;;;;;;;;;;;;;;;;iBAAgB,oBAAA,CAAqB,OAAA,UAAiB,YAAA"}
1
+ {"version":3,"file":"worker.d.cts","names":[],"sources":["../src/worker.ts"],"mappings":";;;;;;;AASA;KAAY,mBAAA,mBAAsC,kBAAA,IAAsB,IAAA,CACtE,aAAA;EAD6B;;;EAO7B,QAAA,EAAU,SAAA;EAAA;;;EAKV,UAAA,EAAY,iBAAA,CAAkB,SAAA;AAAA;;;;;;;;;;;AAAS;AA+BzC;;;;;;;;;;;;;;;;;iBAAsB,YAAA,mBAA+B,kBAAA,EACnD,OAAA,EAAS,mBAAA,CAAoB,SAAA,IAC5B,OAAA,CAAQ,MAAA;AAAM;AAkCjB;;;;AAA0E;;;;;;;;;;;;;;;;;;AAlCzD,iBAkCD,oBAAA,CAAqB,OAAA,UAAiB,YAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.mts","names":[],"sources":["../src/worker.ts"],"mappings":";;;;;;;AASA;KAAY,mBAAA,mBAAsC,kBAAA,IAAsB,IAAA,CACtE,aAAA;EAD6B;;;EAO7B,QAAA,EAAU,SAAA;EAAA;;;EAKV,UAAA,EAAY,iBAAA,CAAkB,SAAA;AAAA;;;;;;;;;;;;AA+BhC;;;;;;;;;;;;;;;;;iBAAsB,YAAA,mBAA+B,kBAAA,CAAA,CACnD,OAAA,EAAS,mBAAA,CAAoB,SAAA,IAC5B,OAAA,CAAQ,MAAA;;AAkCX;;;;;;;;;;;;;;;;;;;;;;iBAAgB,oBAAA,CAAqB,OAAA,UAAiB,YAAA"}
1
+ {"version":3,"file":"worker.d.mts","names":[],"sources":["../src/worker.ts"],"mappings":";;;;;;;AASA;KAAY,mBAAA,mBAAsC,kBAAA,IAAsB,IAAA,CACtE,aAAA;EAD6B;;;EAO7B,QAAA,EAAU,SAAA;EAAA;;;EAKV,UAAA,EAAY,iBAAA,CAAkB,SAAA;AAAA;;;;;;;;;;;AAAS;AA+BzC;;;;;;;;;;;;;;;;;iBAAsB,YAAA,mBAA+B,kBAAA,EACnD,OAAA,EAAS,mBAAA,CAAoB,SAAA,IAC5B,OAAA,CAAQ,MAAA;AAAM;AAkCjB;;;;AAA0E;;;;;;;;;;;;;;;;;;AAlCzD,iBAkCD,oBAAA,CAAqB,OAAA,UAAiB,YAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"worker.mjs","names":[],"sources":["../src/worker.ts"],"sourcesContent":["// Entry point for worker creation utilities\nimport { ContractDefinition } from \"@temporal-contract/contract\";\nimport { Worker, WorkerOptions } from \"@temporalio/worker\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ActivitiesHandler } from \"./activity.js\";\n\n/**\n * Options for creating a Temporal worker\n */\nexport type CreateWorkerOptions<TContract extends ContractDefinition> = Omit<\n WorkerOptions,\n \"activities\" | \"taskQueue\"\n> & {\n /**\n * The contract definition for this worker\n */\n contract: TContract;\n\n /**\n * Activities handler for this worker\n */\n activities: ActivitiesHandler<TContract>;\n};\n\n/**\n * Create a typed Temporal worker with contract-based configuration\n *\n * This helper simplifies worker creation by:\n * - Using the contract's task queue automatically\n * - Providing type-safe configuration\n *\n * @example\n * ```ts\n * import { NativeConnection } from '@temporalio/worker';\n * import { createWorker } from '@temporal-contract/worker/worker';\n * import { activities } from './activities';\n * import myContract from './contract';\n *\n * const connection = await NativeConnection.connect({\n * address: 'localhost:7233',\n * });\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * workflowsPath: require.resolve('./workflows'),\n * activities,\n * });\n *\n * await worker.run();\n * ```\n */\nexport async function createWorker<TContract extends ContractDefinition>(\n options: CreateWorkerOptions<TContract>,\n): Promise<Worker> {\n const { contract, activities, ...workerOptions } = options;\n\n // Create the worker with contract's task queue\n return await Worker.create({\n ...workerOptions,\n activities,\n taskQueue: contract.taskQueue,\n });\n}\n\n/**\n * Helper to resolve a workflow file path relative to the current module's URL.\n *\n * Useful when using ES modules (`import.meta.url`) to locate workflow files.\n * The `relativePath` should include the file extension explicitly (e.g. `./workflows.js`)\n * to ensure the resolved path is unambiguous in both source and built contexts.\n *\n * @param baseURL - The base URL to resolve from, typically `import.meta.url`\n * @param relativePath - Relative path to the workflows file, **including extension**\n *\n * @example\n * ```ts\n * import { workflowsPathFromURL } from '@temporal-contract/worker/worker';\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * // Include the extension explicitly to work in both source (.ts) and build (.js) contexts\n * workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),\n * activities,\n * });\n * ```\n */\nexport function workflowsPathFromURL(baseURL: string, relativePath: string): string {\n return fileURLToPath(new URL(relativePath, baseURL));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,eAAsB,aACpB,SACiB;CACjB,MAAM,EAAE,UAAU,YAAY,GAAG,kBAAkB;AAGnD,QAAO,MAAM,OAAO,OAAO;EACzB,GAAG;EACH;EACA,WAAW,SAAS;EACrB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AA0BJ,SAAgB,qBAAqB,SAAiB,cAA8B;AAClF,QAAO,cAAc,IAAI,IAAI,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"worker.mjs","names":[],"sources":["../src/worker.ts"],"sourcesContent":["// Entry point for worker creation utilities\nimport { ContractDefinition } from \"@temporal-contract/contract\";\nimport { Worker, WorkerOptions } from \"@temporalio/worker\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ActivitiesHandler } from \"./activity.js\";\n\n/**\n * Options for creating a Temporal worker\n */\nexport type CreateWorkerOptions<TContract extends ContractDefinition> = Omit<\n WorkerOptions,\n \"activities\" | \"taskQueue\"\n> & {\n /**\n * The contract definition for this worker\n */\n contract: TContract;\n\n /**\n * Activities handler for this worker\n */\n activities: ActivitiesHandler<TContract>;\n};\n\n/**\n * Create a typed Temporal worker with contract-based configuration\n *\n * This helper simplifies worker creation by:\n * - Using the contract's task queue automatically\n * - Providing type-safe configuration\n *\n * @example\n * ```ts\n * import { NativeConnection } from '@temporalio/worker';\n * import { createWorker } from '@temporal-contract/worker/worker';\n * import { activities } from './activities';\n * import myContract from './contract';\n *\n * const connection = await NativeConnection.connect({\n * address: 'localhost:7233',\n * });\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * workflowsPath: require.resolve('./workflows'),\n * activities,\n * });\n *\n * await worker.run();\n * ```\n */\nexport async function createWorker<TContract extends ContractDefinition>(\n options: CreateWorkerOptions<TContract>,\n): Promise<Worker> {\n const { contract, activities, ...workerOptions } = options;\n\n // Create the worker with contract's task queue\n return await Worker.create({\n ...workerOptions,\n activities,\n taskQueue: contract.taskQueue,\n });\n}\n\n/**\n * Helper to resolve a workflow file path relative to the current module's URL.\n *\n * Useful when using ES modules (`import.meta.url`) to locate workflow files.\n * The `relativePath` should include the file extension explicitly (e.g. `./workflows.js`)\n * to ensure the resolved path is unambiguous in both source and built contexts.\n *\n * @param baseURL - The base URL to resolve from, typically `import.meta.url`\n * @param relativePath - Relative path to the workflows file, **including extension**\n *\n * @example\n * ```ts\n * import { workflowsPathFromURL } from '@temporal-contract/worker/worker';\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * // Include the extension explicitly to work in both source (.ts) and build (.js) contexts\n * workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),\n * activities,\n * });\n * ```\n */\nexport function workflowsPathFromURL(baseURL: string, relativePath: string): string {\n return fileURLToPath(new URL(relativePath, baseURL));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,eAAsB,aACpB,SACiB;CACjB,MAAM,EAAE,UAAU,YAAY,GAAG,kBAAkB;CAGnD,OAAO,MAAM,OAAO,OAAO;EACzB,GAAG;EACH;EACA,WAAW,SAAS;CACtB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,qBAAqB,SAAiB,cAA8B;CAClF,OAAO,cAAc,IAAI,IAAI,cAAc,OAAO,CAAC;AACrD"}
package/dist/workflow.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal = require("./internal-Cwch3OHR.cjs");
2
+ const require_internal = require("./internal-DcM-YWYX.cjs");
3
3
  let _temporalio_workflow = require("@temporalio/workflow");
4
4
  let neverthrow = require("neverthrow");
5
5
  let _temporal_contract_contract_result_async = require("@temporal-contract/contract/result-async");
@@ -365,7 +365,7 @@ function declareWorkflow({ workflowName, contract, implementation, activityOptio
365
365
  contextActivities = createValidatedActivities(require_internal.buildRawActivitiesProxy(definition.activities, contract.activities, activityOptions, activityOptionsByName), definition.activities, contract.activities);
366
366
  Object.freeze(contextActivities);
367
367
  }
368
- return async (...args) => {
368
+ const workflowFn = async (...args) => {
369
369
  const input = require_internal.extractHandlerInput(args);
370
370
  const inputResult = await definition.input["~standard"].validate(input);
371
371
  if (inputResult.issues) throw new require_internal.WorkflowInputValidationError(workflowName, inputResult.issues);
@@ -386,6 +386,11 @@ function declareWorkflow({ workflowName, contract, implementation, activityOptio
386
386
  if (outputResult.issues) throw new require_internal.WorkflowOutputValidationError(workflowName, outputResult.issues);
387
387
  return outputResult.value;
388
388
  };
389
+ Object.defineProperty(workflowFn, "name", {
390
+ value: workflowName,
391
+ configurable: true
392
+ });
393
+ return workflowFn;
389
394
  }
390
395
  //#endregion
391
396
  exports.ActivityInputValidationError = require_internal.ActivityInputValidationError;
@@ -1,4 +1,4 @@
1
- import { _ as ClientInferOutput, a as ChildWorkflowError, c as QueryOutputValidationError, d as UpdateOutputValidationError, f as WorkflowCancelledError, g as ClientInferInput, h as WorkflowScopeError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowOutputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowInputValidationError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-DTq5OTwH.cjs";
1
+ import { _ as ClientInferOutput, a as ChildWorkflowError, c as QueryOutputValidationError, d as UpdateOutputValidationError, f as WorkflowCancelledError, g as ClientInferInput, h as WorkflowScopeError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowOutputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowInputValidationError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-BP48RaOI.cjs";
2
2
  import { ActivityDefinition, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, QueryNamesOf, SignalDefinition, SignalNamesOf, UpdateDefinition, UpdateNamesOf } from "@temporal-contract/contract";
3
3
  import { ResultAsync } from "neverthrow";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.cts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;KAkCY,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,aACb,OAAA;;;;;;;KAQA,0BAAA,gBAA0C,eAAA,KACpD,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,iBAAA,CAAkB,MAAA;;;;;;;KAQX,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,OAAA;;;;;;;;KCsFnB,yBAAA,GAA4B,IAAA,CAAK,oBAAA;;;;;;;;KChHjC,yBAAA,wBACa,kBAAA,mCACU,cAAA,0BAC/B,IAAA,CAAK,oBAAA;EACP,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA;AAAA;;;;KAMzC,wBAAA,mBAA2C,qBAAA;EFJ3C;;;EEQV,MAAA,QAAc,WAAA,CACZ,iBAAA,CAAkB,SAAA,GAClB,kBAAA,GAAqB,2BAAA;EFFa;;;EEQpC,UAAA;AAAA;;;A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A,wBAEjC,QAAA,EAAU,cAAA,EACV,YAAA,EAAc,kBAAA,EACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA,IACnD,OAAA,GAAU,yBAAA,GACT,OAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"workflow.d.cts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;KAkCY,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,aACb,OAAA;;;;;;;KAQA,0BAAA,gBAA0C,eAAA,KACpD,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,iBAAA,CAAkB,MAAA;;;;;;;KAQX,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,OAAA;;;;;;;;KCsFnB,yBAAA,GAA4B,IAAI,CAAC,oBAAA;;;;;;;;KChHjC,yBAAA,wBACa,kBAAA,mCACU,cAAA,0BAC/B,IAAA,CAAK,oBAAA;EACP,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA;AAAA;;;;KAMzC,wBAAA,mBAA2C,qBAAA;EFJ3C;;AAAO;EEQjB,MAAA,QAAc,WAAA,CACZ,iBAAA,CAAkB,SAAA,GAClB,kBAAA,GAAqB,2BAAA;EFFa;;;EEQpC,UAAA;AAAA;;;AFlBF;;;;;AAAA,KGfY,qBAAA,mBAAwC,kBAAA,KAClD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;KAKnB,uBAAA,mBAA0C,kBAAA,IACpD,SAAA,uBAAgC,MAAA,SAAe,kBAAA,kBAE7B,SAAA,iBAA0B,qBAAA,CAAsB,SAAA,eAAwB,CAAA;;;;KAOhF,+BAAA,WAA0C,qBAAA,IACpD,CAAA,uBAAwB,MAAA,S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ancelledError, g as ClientInferInput, h as WorkflowScopeError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowOutputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowInputValidationError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-DbPMxULo.mjs";
1
+ import { _ as ClientInferOutput, a as ChildWorkflowError, c as QueryOutputValidationError, d as UpdateOutputValidationError, f as WorkflowCancelledError, g as ClientInferInput, h as WorkflowScopeError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowOutputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowInputValidationError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-BP48RaOI.mjs";
2
2
  import { ActivityDefinition, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, QueryNamesOf, SignalDefinition, SignalNamesOf, UpdateDefinition, UpdateNamesOf } from "@temporal-contract/contract";
3
3
  import { ActivityOptions, ChildWorkflowOptions, ContinueAsNewOptions, WorkflowInfo } from "@temporalio/workflow";
4
4
  import { ResultAsync } from "neverthrow";
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;;KAkCY,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,aACb,OAAA;;;;;;;KAQA,0BAAA,gBAA0C,eAAA,KACpD,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,iBAAA,CAAkB,MAAA;;;;;;;KAQX,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,OAAA;;;;;;;;KCsFnB,yBAAA,G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AoQrC,mBAAA,MACE,EAAA,QAAU,CAAA,GAAI,OAAA,CAAQ,CAAA,MACnB,WAAA,CAAY,CAAA,EAAG,sBAAA,GAAyB,kBAAA;EApT/B;;;;;;;;;;;;;;;;;;AA8CsD;;;;;;;;;EAmSpE,aAAA;IApRM,8EAuRF,IAAA,EAAM,gBAAA,CAAiB,SAAA,cAAuB,aAAA,IAC9C,OAAA,GAAU,yBAAA,GACT,OAAA,SAxR+C;IAAA,wBA2RzB,kBAAA,mCACU,cAAA,wBAEjC,QAAA,EAAU,cAAA,EACV,YAAA,EAAc,kBAAA,EACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA,IACnD,OAAA,GAAU,yBAAA,GACT,OAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;;KAkCY,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,aACb,OAAA;;;;;;;KAQA,0BAAA,gBAA0C,eAAA,KACpD,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,iBAAA,CAAkB,MAAA;;;;;;;KAQX,2BAAA,iBAA4C,gBAAA,KACtD,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,OAAA;;;;;;;;KCsFnB,yBAAA,GAA4B,IAAI,CAAC,oBAAA;;;;;;;;KChHjC,yBAAA,wBACa,kBAAA,mCACU,cAAA,0BAC/B,IAAA,CAAK,oBAAA;EACP,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA;AAAA;;;;KAMzC,wBAAA,mBAA2C,qBAAA;EFJ3C;;AAAO;EEQjB,MAAA,QAAc,WAAA,CACZ,iBAAA,CAAkB,SAAA,GAClB,kBAAA,GAAqB,2BAAA;EFFa;;;EEQpC,UAAA;AAAA;;;A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AU,yBAAA,GACT,OAAA,SAxR+C;IAAA,wBA2RzB,kBAAA,mCACU,cAAA,wBAEjC,QAAA,EAAU,cAAA,EACV,YAAA,EAAc,kBAAA,EACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA,IACnD,OAAA,GAAU,yBAAA,GACT,OAAA;EAAA;AAAA"}
package/dist/workflow.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as UpdateOutputValidationError, a as formatChildWorkflowValidationMessage, b as WorkflowOutputValidationError, c as ActivityInputValidationError, d as ChildWorkflowError, f as ChildWorkflowNotFoundError, g as UpdateInputValidationError, h as SignalInputValidationError, i as extractHandlerInput, l as ActivityOutputValidationError, m as QueryOutputValidationError, n as classifyChildWorkflowError, o as makeResultAsync, p as QueryInputValidationError, r as createContinueAsNew, t as buildRawActivitiesProxy, u as ChildWorkflowCancelledError, v as WorkflowCancelledError, x as WorkflowScopeError, y as WorkflowInputValidationError } from "./internal-BzG1KhEK.mjs";
1
+ import { _ as UpdateOutputValidationError, a as formatChildWorkflowValidationMessage, b as WorkflowOutputValidationError, c as ActivityInputValidationError, d as ChildWorkflowError, f as ChildWorkflowNotFoundError, g as UpdateInputValidationError, h as SignalInputValidationError, i as extractHandlerInput, l as ActivityOutputValidationError, m as QueryOutputValidationError, n as classifyChildWorkflowError, o as makeResultAsync, p as QueryInputValidationError, r as createContinueAsNew, t as buildRawActivitiesProxy, u as ChildWorkflowCancelledError, v as WorkflowCancelledError, x as WorkflowScopeError, y as WorkflowInputValidationError } from "./internal-D8Dl9D43.mjs";
2
2
  import { CancellationScope, defineQuery, defineSignal, defineUpdate, executeChild, isCancellation, setHandler, startChild, workflowInfo } from "@temporalio/workflow";
3
3
  import { err, ok } from "neverthrow";
4
4
  //#region src/cancellation.ts
@@ -363,7 +363,7 @@ function declareWorkflow({ workflowName, contract, implementation, activityOptio
363
363
  contextActivities = createValidatedActivities(buildRawActivitiesProxy(definition.activities, contract.activities, activityOptions, activityOptionsByName), definition.activities, contract.activities);
364
364
  Object.freeze(contextActivities);
365
365
  }
366
- return async (...args) => {
366
+ const workflowFn = async (...args) => {
367
367
  const input = extractHandlerInput(args);
368
368
  const inputResult = await definition.input["~standard"].validate(input);
369
369
  if (inputResult.issues) throw new WorkflowInputValidationError(workflowName, inputResult.issues);
@@ -384,6 +384,11 @@ function declareWorkflow({ workflowName, contract, implementation, activityOptio
384
384
  if (outputResult.issues) throw new WorkflowOutputValidationError(workflowName, outputResult.issues);
385
385
  return outputResult.value;
386
386
  };
387
+ Object.defineProperty(workflowFn, "name", {
388
+ value: workflowName,
389
+ configurable: true
390
+ });
391
+ return workflowFn;
387
392
  }
388
393
  //#endregion
389
394
  export { ActivityInputValidationError, ActivityOutputValidationError, ChildWorkflowCancelledError, ChildWorkflowError, ChildWorkflowNotFoundError, QueryInputValidationError, QueryOutputValidationError, SignalInputValidationError, UpdateInputValidationError, UpdateOutputValidationError, WorkflowCancelledError, WorkflowInputValidationError, WorkflowOutputValidationError, WorkflowScopeError, declareWorkflow };
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/cancellation.ts","../src/handlers.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"sourcesContent":["/**\n * Typed wrappers around Temporal's `CancellationScope` so workflows can\n * opt into cancellation control without reaching for\n * `@temporalio/workflow` directly. The wrappers fold cancellation into\n * the same `ResultAsync<...>` shape used elsewhere in the worker\n * context — callers branch on `err(WorkflowCancelledError)` instead of\n * catching `CancelledFailure`.\n *\n * Non-cancellation errors thrown inside the scope are wrapped in a\n * {@link WorkflowScopeError} (with the original error preserved on\n * `cause`) and surfaced on the same `err(...)` channel. Together with\n * `WorkflowCancelledError` this makes the failure modes exhaustive on\n * `result.match(...)` — nothing escapes as an unhandled rejection.\n */\nimport { CancellationScope, isCancellation } from \"@temporalio/workflow\";\nimport { type ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport { WorkflowCancelledError, WorkflowScopeError } from \"./errors.js\";\nimport { makeResultAsync } from \"./internal.js\";\n\n/**\n * Run `fn` inside a cancellable Temporal scope. If the workflow (or an\n * ancestor scope) is cancelled while the function is in flight, the\n * resulting ResultAsync resolves to `err(WorkflowCancelledError)`,\n * letting callers handle cancellation explicitly — typically to perform\n * a graceful exit from the current step.\n *\n * Non-cancellation errors thrown by `fn` resolve to\n * `err(WorkflowScopeError)` (with the original error on `cause`) so\n * domain failures surface on the same typed error channel rather than\n * leaking as unhandled rejections.\n *\n * @example\n * ```ts\n * const result = await context.cancellableScope(async () => {\n * return await context.activities.processStep(...);\n * });\n *\n * result.match(\n * (output) => { ... },\n * (error) => {\n * if (error instanceof WorkflowCancelledError) {\n * // graceful exit\n * } else {\n * // error instanceof WorkflowScopeError — domain failure on `cause`\n * }\n * },\n * );\n * ```\n */\nexport function cancellableScope<T>(\n fn: () => T | Promise<T>,\n): ResultAsync<T, WorkflowCancelledError | WorkflowScopeError> {\n const work = async (): Promise<Result<T, WorkflowCancelledError | WorkflowScopeError>> => {\n try {\n // Wrap so synchronous returns satisfy CancellationScope.cancellable's\n // `() => Promise<T>` signature without forcing every caller to write\n // `async () => ...` for purely synchronous bodies.\n const value = await CancellationScope.cancellable(async () => fn());\n return ok(value);\n } catch (error) {\n if (isCancellation(error)) {\n return err(new WorkflowCancelledError(error));\n }\n return err(new WorkflowScopeError(error));\n }\n };\n // makeResultAsync is the shared safety net from `@temporal-contract/contract`\n // — `new ResultAsync(work())` does not catch, so a synchronous throw inside\n // `work` (e.g. a buggy refactor) would escape neverthrow's railway. The\n // catch-all here funnels that back into `err(WorkflowScopeError)` for\n // parity with the in-band path above.\n return makeResultAsync(work, (e) => new WorkflowScopeError(e));\n}\n\n/**\n * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests\n * from outside the scope are ignored for its duration — the idiomatic way\n * to perform cleanup that must not be interrupted (e.g. releasing a\n * resource after a graceful shutdown).\n *\n * Mirrors `cancellableScope`'s `ResultAsync<...>` shape for symmetry; the\n * `err(WorkflowCancelledError)` branch only triggers when cancellation is\n * raised from inside the scope (rare). Non-cancellation errors surface as\n * `err(WorkflowScopeError)`.\n *\n * @example\n * ```ts\n * await context.nonCancellableScope(async () => {\n * await context.activities.releaseResources(...);\n * });\n * ```\n */\nexport function nonCancellableScope<T>(\n fn: () => T | Promise<T>,\n): ResultAsync<T, WorkflowCancelledError | WorkflowScopeError> {\n const work = async (): Promise<Result<T, WorkflowCancelledError | WorkflowScopeError>> => {\n try {\n const value = await CancellationScope.nonCancellable(async () => fn());\n return ok(value);\n } catch (error) {\n if (isCancellation(error)) {\n return err(new WorkflowCancelledError(error));\n }\n return err(new WorkflowScopeError(error));\n }\n };\n return makeResultAsync(work, (e) => new WorkflowScopeError(e));\n}\n","// Top-level helpers for binding signal / query / update handlers to a\n// running workflow. Previously nested inside `declareWorkflow`'s closure\n// (#185), they're hoisted here so the bodies aren't reallocated on each\n// workflow invocation. The typed call-site surface is preserved at the\n// context-assignment site in `workflow.ts` (the arrow that forwards into\n// these helpers carries the contract-derived generic constraints).\n//\n// Internally these are loosely typed (string names, broad `*Definition`\n// inputs); the call sites already do the cast against the typed\n// `WorkflowContext` shape, so the typed-vs-runtime split is the same as\n// it was before the hoist.\nimport type {\n AnyWorkflowDefinition,\n QueryDefinition,\n SignalDefinition,\n UpdateDefinition,\n} from \"@temporal-contract/contract\";\nimport { defineQuery, defineSignal, defineUpdate, setHandler } from \"@temporalio/workflow\";\nimport {\n QueryInputValidationError,\n QueryOutputValidationError,\n SignalInputValidationError,\n UpdateInputValidationError,\n UpdateOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\nimport type { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\n\n/**\n * Signal handler implementation\n *\n * Processes signal input and can optionally perform asynchronous operations.\n * Should not return a value (signals are fire-and-forget).\n */\nexport type SignalHandlerImplementation<TSignal extends SignalDefinition> = (\n args: WorkerInferInput<TSignal>,\n) => void | Promise<void>;\n\n/**\n * Query handler implementation\n *\n * Processes query input and returns a synchronous response.\n * Must be synchronous to satisfy Temporal's query constraints.\n */\nexport type QueryHandlerImplementation<TQuery extends QueryDefinition> = (\n args: WorkerInferInput<TQuery>,\n) => WorkerInferOutput<TQuery>;\n\n/**\n * Update handler implementation\n *\n * Processes update input and returns a validated response after modifying workflow state.\n * Can perform asynchronous operations.\n */\nexport type UpdateHandlerImplementation<TUpdate extends UpdateDefinition> = (\n args: WorkerInferInput<TUpdate>,\n) => Promise<WorkerInferOutput<TUpdate>>;\n\n/**\n * Bind a typed signal handler to the running workflow. Validates the\n * signal payload against the contract's input schema before invoking the\n * user-supplied handler.\n *\n * The runtime guard against a missing `signals` block — and an unknown\n * signal name within it — covers the union-typed-`workflowName` case\n * where the type system's keyset constraint collapses; without the\n * check, a caller would see `Cannot read properties of undefined`\n * instead of a controlled error.\n */\nexport function bindSignalHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n signalName: string,\n handler: SignalHandlerImplementation<SignalDefinition>,\n): void {\n if (!workflowDefinition.signals) {\n throw new Error(\n `Signal \"${signalName}\" cannot be defined: workflow \"${workflowName}\" has no signals in its contract`,\n );\n }\n const signalDef = (workflowDefinition.signals as Record<string, SignalDefinition>)[signalName];\n if (!signalDef) {\n throw new Error(`Signal \"${signalName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const signal = defineSignal(signalName);\n setHandler(signal, async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = await signalDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new SignalInputValidationError(signalName, inputResult.issues);\n }\n await handler(inputResult.value);\n });\n}\n\n/**\n * Bind a typed query handler to the running workflow. Validates input\n * and output against the contract synchronously.\n *\n * Temporal's query API requires a synchronous handler — async\n * validation breaks replay determinism. The handler trips a clear error\n * if the schema library returns a Promise from `validate(...)`, instead\n * of letting the async path silently corrupt query semantics.\n */\nexport function bindQueryHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n queryName: string,\n handler: QueryHandlerImplementation<QueryDefinition>,\n): void {\n if (!workflowDefinition.queries) {\n throw new Error(\n `Query \"${queryName}\" cannot be defined: workflow \"${workflowName}\" has no queries in its contract`,\n );\n }\n const queryDef = (workflowDefinition.queries as Record<string, QueryDefinition>)[queryName];\n if (!queryDef) {\n throw new Error(`Query \"${queryName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const query = defineQuery(queryName);\n setHandler(query, (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = queryDef.input[\"~standard\"].validate(input);\n\n if (inputResult instanceof Promise) {\n throw new Error(\n `Query \"${queryName}\" validation must be synchronous. Use a schema library that supports synchronous validation for queries.`,\n );\n }\n if (inputResult.issues) {\n throw new QueryInputValidationError(queryName, inputResult.issues);\n }\n\n const result = handler(inputResult.value);\n\n const outputResult = queryDef.output[\"~standard\"].validate(result);\n if (outputResult instanceof Promise) {\n throw new Error(\n `Query \"${queryName}\" output validation must be synchronous. Use a schema library that supports synchronous validation for queries.`,\n );\n }\n if (outputResult.issues) {\n throw new QueryOutputValidationError(queryName, outputResult.issues);\n }\n\n return outputResult.value;\n });\n}\n\n/**\n * Bind a typed update handler to the running workflow.\n *\n * Input validation runs in Temporal's `validator` slot — a synchronous\n * pre-admission hook. If it throws, Temporal rejects the update *before*\n * appending a workflow history event: clients see\n * `WorkflowUpdateValidationRejectedError` and the workflow's history is\n * unaffected. This is the documented contract for `setHandler`'s\n * `validator` option, and it is strictly better than running validation\n * inside the handler body — which forces Temporal to admit the update,\n * write a history event, and surface a `WorkflowUpdateFailedError` to\n * the client only after the fact.\n *\n * Because the validator slot is synchronous, the input schema must also\n * validate synchronously. Standard Schema is allowed to be async (Zod's\n * `.refine(async)` is the typical case), but we trip a clear error when\n * that happens rather than silently breaking admission semantics — same\n * approach as `bindQueryHandler`. Users who need async input checks\n * should run them inside the handler body and accept the post-admission\n * failure mode, or restructure their schema.\n *\n * Output validation continues to run inside the handler body. Update\n * outputs are *not* admission-gated — the handler must execute to\n * produce a value to validate against — so the async-allowed shape is\n * preserved.\n */\nexport function bindUpdateHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n updateName: string,\n handler: UpdateHandlerImplementation<UpdateDefinition>,\n): void {\n if (!workflowDefinition.updates) {\n throw new Error(\n `Update \"${updateName}\" cannot be defined: workflow \"${workflowName}\" has no updates in its contract`,\n );\n }\n const updateDef = (workflowDefinition.updates as Record<string, UpdateDefinition>)[updateName];\n if (!updateDef) {\n throw new Error(`Update \"${updateName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const update = defineUpdate(updateName);\n setHandler(\n update,\n async (...args: unknown[]) => {\n // The validator already accepted the payload — re-parse here so the\n // handler receives the schema's transformed value (Standard Schema\n // may rewrite shapes during validation, e.g. Zod `.transform`). This\n // is sync because the validator already proved the schema is sync;\n // any async result here would mean the schema changed under us,\n // which is a programmer error worth surfacing.\n const input = extractHandlerInput(args);\n const inputResult = updateDef.input[\"~standard\"].validate(input);\n if (inputResult instanceof Promise) {\n throw new Error(\n `Update \"${updateName}\" input validation must be synchronous. Use a schema library that supports synchronous validation for update inputs (Temporal's update validator slot is synchronous).`,\n );\n }\n if (inputResult.issues) {\n // The validator should have caught this; if we reach here, the\n // schema produced different issues on a second call (non-pure\n // validator). Surface it as the same typed error class for\n // consistency.\n throw new UpdateInputValidationError(updateName, inputResult.issues);\n }\n\n const result = await handler(inputResult.value);\n\n const outputResult = await updateDef.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new UpdateOutputValidationError(updateName, outputResult.issues);\n }\n\n return outputResult.value;\n },\n {\n validator: (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = updateDef.input[\"~standard\"].validate(input);\n\n if (inputResult instanceof Promise) {\n throw new Error(\n `Update \"${updateName}\" input validation must be synchronous. Use a schema library that supports synchronous validation for update inputs (Temporal's update validator slot is synchronous).`,\n );\n }\n if (inputResult.issues) {\n throw new UpdateInputValidationError(updateName, inputResult.issues);\n }\n },\n },\n );\n}\n","/**\n * Child workflow types + helpers used by `declareWorkflow`. Split out of\n * `workflow.ts` to keep that file focused on `declareWorkflow` and its\n * `WorkflowContext` type. Not part of the worker package's public exports.\n */\nimport type { AnyWorkflowDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowHandle,\n ChildWorkflowOptions,\n executeChild,\n startChild,\n} from \"@temporalio/workflow\";\nimport { ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n} from \"./errors.js\";\nimport {\n classifyChildWorkflowError,\n formatChildWorkflowValidationMessage,\n makeResultAsync,\n} from \"./internal.js\";\nimport type { ClientInferInput, ClientInferOutput, WorkerInferInput } from \"./types.js\";\n\n/**\n * Options for starting a child workflow. `taskQueue` and `args` come from\n * the contract; everything else is forwarded to Temporal's\n * `startChild` / `executeChild`.\n */\nexport type TypedChildWorkflowOptions<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n> = Omit<ChildWorkflowOptions, \"taskQueue\" | \"args\"> & {\n args: ClientInferInput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n};\n\n/**\n * Typed handle for a child workflow with neverthrow `ResultAsync` pattern.\n */\nexport type TypedChildWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {\n /**\n * Get child workflow result with `ResultAsync` pattern.\n */\n result: () => ResultAsync<\n ClientInferOutput<TWorkflow>,\n ChildWorkflowError | ChildWorkflowCancelledError\n >;\n\n /**\n * Child workflow ID.\n */\n workflowId: string;\n};\n\nasync function validateChildWorkflowOutput<TChildWorkflow extends AnyWorkflowDefinition>(\n childDefinition: TChildWorkflow,\n result: unknown,\n childWorkflowName: string,\n): Promise<Result<ClientInferOutput<TChildWorkflow>, ChildWorkflowError>> {\n const outputResult = await childDefinition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(\n new ChildWorkflowError(\n formatChildWorkflowValidationMessage(childWorkflowName, \"output\", outputResult.issues),\n ),\n );\n }\n return ok(outputResult.value as ClientInferOutput<TChildWorkflow>);\n}\n\nasync function getAndValidateChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n args: unknown,\n): Promise<\n Result<\n {\n definition: TChildContract[\"workflows\"][TChildWorkflowName];\n validatedInput: WorkerInferInput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n taskQueue: string;\n },\n ChildWorkflowError\n >\n> {\n const childDefinition = childContract.workflows[childWorkflowName];\n\n if (!childDefinition) {\n return err(\n new ChildWorkflowNotFoundError(\n childWorkflowName,\n Object.keys(childContract.workflows) as string[],\n ),\n );\n }\n\n const inputResult = await childDefinition.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(\n new ChildWorkflowError(\n formatChildWorkflowValidationMessage(childWorkflowName, \"input\", inputResult.issues),\n ),\n );\n }\n\n const validatedInput = inputResult.value as WorkerInferInput<\n TChildContract[\"workflows\"][TChildWorkflowName]\n >;\n\n return ok({\n definition: childDefinition as TChildContract[\"workflows\"][TChildWorkflowName],\n validatedInput,\n taskQueue: childContract.taskQueue,\n });\n}\n\nfunction createTypedChildHandle<TChildWorkflow extends AnyWorkflowDefinition>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handle: ChildWorkflowHandle<any>,\n childDefinition: TChildWorkflow,\n childWorkflowName: string,\n): TypedChildWorkflowHandle<TChildWorkflow> {\n return {\n workflowId: handle.workflowId,\n result: (): ResultAsync<\n ClientInferOutput<TChildWorkflow>,\n ChildWorkflowError | ChildWorkflowCancelledError\n > => {\n const work = async (): Promise<\n Result<ClientInferOutput<TChildWorkflow>, ChildWorkflowError | ChildWorkflowCancelledError>\n > => {\n try {\n const result = await handle.result();\n return validateChildWorkflowOutput(childDefinition, result, childWorkflowName);\n } catch (error) {\n return err(classifyChildWorkflowError(\"result\", error, childWorkflowName));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Child workflow execution failed: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n },\n };\n}\n\nexport function createStartChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n): ResultAsync<\n TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n> {\n type Ok = TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>;\n const work = async (): Promise<\n Result<Ok, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>\n > => {\n const validationResult = await getAndValidateChildWorkflow(\n childContract,\n childWorkflowName,\n options.args,\n );\n\n if (validationResult.isErr()) {\n return err(validationResult.error);\n }\n\n const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;\n\n try {\n const { args: _args, ...temporalOptions } = options;\n const handle = await startChild(childWorkflowName, {\n ...temporalOptions,\n taskQueue,\n args: [validatedInput],\n });\n\n const typedHandle = createTypedChildHandle(handle, childDefinition, childWorkflowName) as Ok;\n\n return ok(typedHandle);\n } catch (error) {\n return err(classifyChildWorkflowError(\"startChild\", error, String(childWorkflowName)));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Failed to start child workflow: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n}\n\nexport function createExecuteChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n): ResultAsync<\n ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n> {\n type Ok = ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n const work = async (): Promise<\n Result<Ok, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>\n > => {\n const validationResult = await getAndValidateChildWorkflow(\n childContract,\n childWorkflowName,\n options.args,\n );\n\n if (validationResult.isErr()) {\n return err(validationResult.error);\n }\n\n const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;\n\n try {\n const { args: _args, ...temporalOptions } = options;\n const result = await executeChild(childWorkflowName, {\n ...temporalOptions,\n taskQueue,\n args: [validatedInput],\n });\n\n const outputValidationResult = await validateChildWorkflowOutput(\n childDefinition,\n result,\n childWorkflowName,\n );\n\n if (outputValidationResult.isErr()) {\n return err(outputValidationResult.error);\n }\n\n return ok(outputValidationResult.value as Ok);\n } catch (error) {\n return err(classifyChildWorkflowError(\"executeChild\", error, String(childWorkflowName)));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Failed to execute child workflow: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n}\n","/**\n * Activity inference types + the validated-activities proxy used by\n * `declareWorkflow`. Split out of `workflow.ts` to keep that file focused\n * on `declareWorkflow` and its `WorkflowContext` type. Not part of the\n * worker package's public exports.\n */\nimport type {\n ActivityDefinition,\n AnyWorkflowDefinition,\n ContractDefinition,\n} from \"@temporal-contract/contract\";\nimport { ActivityInputValidationError, ActivityOutputValidationError } from \"./errors.js\";\nimport type { ClientInferInput, ClientInferOutput } from \"./types.js\";\n\n/**\n * Activity function signature from workflow execution perspective.\n *\n * Workflows call activities with validated input (z.input parsed) and receive validated output (z.output).\n */\nexport type WorkflowInferActivity<TActivity extends ActivityDefinition> = (\n args: ClientInferInput<TActivity>,\n) => Promise<ClientInferOutput<TActivity>>;\n\n/**\n * All global activities from a contract (workflow execution perspective).\n */\nexport type WorkflowInferActivities<TContract extends ContractDefinition> =\n TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? {\n [K in keyof TContract[\"activities\"]]: WorkflowInferActivity<TContract[\"activities\"][K]>;\n }\n : {};\n\n/**\n * Workflow-specific activities (workflow execution perspective).\n */\nexport type WorkflowInferWorkflowActivities<T extends AnyWorkflowDefinition> =\n T[\"activities\"] extends Record<string, ActivityDefinition>\n ? {\n [K in keyof T[\"activities\"]]: WorkflowInferActivity<T[\"activities\"][K]>;\n }\n : {};\n\n/**\n * All activities available in a workflow context (workflow execution perspective).\n *\n * Combines workflow-specific activities with global contract activities.\n */\nexport type WorkflowInferWorkflowContextActivities<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = WorkflowInferWorkflowActivities<TContract[\"workflows\"][TWorkflowName]> &\n WorkflowInferActivities<TContract>;\n\n/**\n * Wrap the raw activities proxy with input/output validation against the\n * Standard Schema definitions on the contract. The wrapper enforces data\n * integrity at the workflow → activity boundary in addition to the\n * activity-side validation that `declareActivitiesHandler` already runs.\n */\nexport function createValidatedActivities<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>(\n rawActivities: Record<string, (...args: unknown[]) => Promise<unknown>>,\n workflowActivitiesDefinition: Record<string, ActivityDefinition> | undefined,\n contractActivitiesDefinition: Record<string, ActivityDefinition> | undefined,\n): WorkflowInferWorkflowContextActivities<TContract, TWorkflowName> {\n const validatedActivities = {} as WorkflowInferWorkflowContextActivities<\n TContract,\n TWorkflowName\n >;\n\n // Merge workflow-specific and global contract activities. defineContract\n // guarantees there are no name collisions across scopes, so spread order\n // is just a stable iteration choice (workflow-local last).\n const allActivitiesDefinition = {\n ...contractActivitiesDefinition,\n ...workflowActivitiesDefinition,\n };\n\n for (const [activityName, activityDef] of Object.entries(allActivitiesDefinition)) {\n const rawActivity = rawActivities[activityName];\n\n if (!rawActivity) {\n throw new Error(\n `Activity implementation not found for: \"${activityName}\". ` +\n `Available activities: ${Object.keys(rawActivities).length > 0 ? Object.keys(rawActivities).join(\", \") : \"none\"}`,\n );\n }\n\n (validatedActivities as Record<string, unknown>)[activityName] = async (input: unknown) => {\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n const result = await rawActivity(inputResult.value);\n\n const outputResult = await activityDef.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n\n return outputResult.value;\n };\n }\n\n return validatedActivities;\n}\n","// Entry point for workflow implementations.\n//\n// Workflows run inside Temporal's deterministic sandbox, which intercepts\n// timers, randomness, and Promise scheduling for replay. neverthrow's\n// `Result`/`ResultAsync` rely only on Promise scheduling, so they replay\n// deterministically alongside Temporal's machinery. Activity code (see\n// activity.ts) uses the same neverthrow API.\nimport type {\n ActivityDefinition,\n ContractDefinition,\n QueryDefinition,\n QueryNamesOf,\n SignalDefinition,\n SignalNamesOf,\n UpdateDefinition,\n UpdateNamesOf,\n} from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n WorkflowCancelledError,\n WorkflowInputValidationError,\n WorkflowOutputValidationError,\n WorkflowScopeError,\n} from \"./errors.js\";\nimport { cancellableScope, nonCancellableScope } from \"./cancellation.js\";\nimport {\n bindQueryHandler,\n bindSignalHandler,\n bindUpdateHandler,\n type QueryHandlerImplementation,\n type SignalHandlerImplementation,\n type UpdateHandlerImplementation,\n} from \"./handlers.js\";\nimport {\n ClientInferInput,\n ClientInferOutput,\n WorkerInferInput,\n WorkerInferOutput,\n} from \"./types.js\";\nimport type { ResultAsync } from \"neverthrow\";\nimport {\n buildRawActivitiesProxy,\n createContinueAsNew,\n extractHandlerInput,\n type TypedContinueAsNewOptions,\n} from \"./internal.js\";\nimport {\n createStartChildWorkflow,\n createExecuteChildWorkflow,\n type TypedChildWorkflowHandle,\n type TypedChildWorkflowOptions,\n} from \"./child-workflow.js\";\nimport {\n createValidatedActivities,\n type WorkflowInferWorkflowContextActivities,\n} from \"./activities-proxy.js\";\nimport { ActivityOptions, WorkflowInfo, workflowInfo } from \"@temporalio/workflow\";\n\nexport {\n ActivityInputValidationError,\n ActivityOutputValidationError,\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n QueryInputValidationError,\n QueryOutputValidationError,\n SignalInputValidationError,\n UpdateInputValidationError,\n UpdateOutputValidationError,\n WorkflowCancelledError,\n WorkflowInputValidationError,\n WorkflowOutputValidationError,\n WorkflowScopeError,\n} from \"./errors.js\";\n\n/**\n * Create a typed workflow implementation with automatic validation\n *\n * This wraps a workflow implementation with:\n * - Input/output validation\n * - Typed workflow context with activities\n * - Workflow info access\n *\n * Workflows must be defined in separate files and imported by the Temporal Worker\n * via workflowsPath.\n *\n * @example\n * ```ts\n * // workflows/processOrder.ts\n * import { declareWorkflow } from '@temporal-contract/worker/workflow';\n * import myContract from '../contract';\n *\n * export const processOrder = declareWorkflow({\n * workflowName: 'processOrder',\n * contract: myContract,\n * activityOptions: {\n * startToCloseTimeout: '1 minute',\n * },\n * // Optional: override `activityOptions` for specific activities. Each\n * // entry shallow-merges over the workflow default — the override wins on\n * // every property it specifies, including the whole `retry` block.\n * activityOptionsByName: {\n * chargePayment: {\n * startToCloseTimeout: '5 minutes',\n * retry: { maximumAttempts: 5 },\n * },\n * },\n * implementation: async (context, args) => {\n * // context.activities: typed activities (workflow + global)\n * // context.info: WorkflowInfo\n *\n * const inventory = await context.activities.validateInventory({\n * orderId: args.orderId,\n * });\n *\n * if (!inventory.available) {\n * return { orderId: args.orderId, status: 'out_of_stock' };\n * }\n *\n * const payment = await context.activities.chargePayment({\n * customerId: args.customerId,\n * amount: 100,\n * });\n *\n * return {\n * orderId: args.orderId,\n * status: payment.success ? 'success' : 'failed',\n * transactionId: payment.transactionId,\n * };\n * },\n * });\n * ```\n *\n * Then in your worker setup:\n * ```ts\n * // worker.ts\n * import { createWorker } from '@temporal-contract/worker/worker';\n * import { activities } from './activities';\n * import myContract from './contract';\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),\n * activities,\n * });\n * ```\n */\nexport function declareWorkflow<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>({\n workflowName,\n contract,\n implementation,\n activityOptions,\n activityOptionsByName,\n}: DeclareWorkflowOptions<TContract, TWorkflowName>): (\n ...args: unknown[]\n) => Promise<WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>> {\n // Get the workflow definition from the contract\n const definition = contract.workflows[workflowName] as TContract[\"workflows\"][TWorkflowName];\n\n // Build the activities proxy *once* at declaration time, not per workflow\n // invocation. Temporal's `proxyActivities` is documented as a module-scope\n // helper — it registers stub functions and may carry bookkeeping\n // (validator pre-registration, payload-converter caching) that breaks if\n // re-invoked on every workflow run. The call depends only on contract-time\n // immutables (`definition.activities`, `contract.activities`,\n // `activityOptions`, `activityOptionsByName`), all of which are available\n // here, so hoisting is safe and deterministic.\n //\n // The validation wrapper (`createValidatedActivities`) is stateless across\n // invocations — it merely closes over the activity definitions and the raw\n // proxy, both immutable — so it is hoisted alongside the proxy. The\n // resulting `contextActivities` object is shared by every workflow run,\n // which is fine because the wrapped activity functions take their input\n // as an argument and validate it per-call (no closed-over per-invocation\n // state).\n //\n // Design note — intentional double-validation:\n // Input and output are validated here (workflow side) AND again inside\n // `declareActivitiesHandler` (activity worker side). This is deliberate:\n //\n // 1. Workflow-side validation catches bad data *before* it crosses the\n // task-queue network boundary, giving an early, descriptive error\n // instead of a confusing deserialization failure inside the activity.\n // 2. Activity-side validation is the authoritative guard, since the\n // activity may be called by other callers that do not use this library.\n //\n // The overhead is minimal relative to the network round-trip.\n let contextActivities: unknown = {};\n\n if (definition.activities || contract.activities) {\n const rawActivities = buildRawActivitiesProxy(\n definition.activities,\n contract.activities,\n activityOptions,\n activityOptionsByName,\n );\n\n contextActivities = createValidatedActivities(\n rawActivities,\n definition.activities,\n contract.activities,\n );\n\n // Shared across workflow invocations after the proxyActivities hoist\n // (PR #211); freeze so user code can't mutate one invocation's view of\n // activities and have it leak into others. The freeze is shallow, which\n // is sufficient because `createValidatedActivities` returns a flat\n // `{ [name]: (input) => Promise<output> }` map — every value is a\n // stateless validation wrapper function, not a nested object users could\n // reach into. The matching `Readonly<...>` on `WorkflowContext.activities`\n // surfaces the immutability at the type level.\n Object.freeze(contextActivities);\n }\n\n return async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate workflow input\n const inputResult = await definition.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new WorkflowInputValidationError(workflowName, inputResult.issues);\n }\n const validatedInput = inputResult.value as WorkerInferInput<\n TContract[\"workflows\"][TWorkflowName]\n >;\n\n // Create workflow context.\n //\n // The defineSignal / defineQuery / defineUpdate arrows forward to the\n // hoisted helpers in `./handlers.ts`. The arrows themselves are thin\n // closures that close over `definition` and `workflowName`; the heavy\n // logic — runtime guards, validation, Temporal `defineSignal/Query/\n // Update` + `setHandler` wiring — lives at module scope so it isn't\n // reallocated on each workflow invocation.\n //\n // The cast at each assignment preserves the typed call-site surface\n // (the `K extends keyof ...` constraints declared on\n // `WorkflowContext.defineSignal/Query/Update`), while the helpers\n // themselves take loosely-typed arguments at the runtime boundary.\n const context: WorkflowContext<TContract, TWorkflowName> = {\n activities: contextActivities as WorkflowInferWorkflowContextActivities<\n TContract,\n TWorkflowName\n >,\n info: workflowInfo(),\n startChildWorkflow: createStartChildWorkflow,\n executeChildWorkflow: createExecuteChildWorkflow,\n cancellableScope,\n nonCancellableScope,\n defineSignal: ((signalName, handler) =>\n bindSignalHandler(\n definition,\n workflowName,\n signalName,\n handler as unknown as SignalHandlerImplementation<SignalDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineSignal\"],\n defineQuery: ((queryName, handler) =>\n bindQueryHandler(\n definition,\n workflowName,\n queryName,\n handler as unknown as QueryHandlerImplementation<QueryDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineQuery\"],\n defineUpdate: ((updateName, handler) =>\n bindUpdateHandler(\n definition,\n workflowName,\n updateName,\n handler as unknown as UpdateHandlerImplementation<UpdateDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineUpdate\"],\n continueAsNew: createContinueAsNew(contract, workflowName) as WorkflowContext<\n TContract,\n TWorkflowName\n >[\"continueAsNew\"],\n };\n\n // Execute workflow (pass validated input as tuple)\n const result = await implementation(context, validatedInput);\n\n // Validate workflow output\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new WorkflowOutputValidationError(workflowName, outputResult.issues);\n }\n\n return outputResult.value as WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>;\n };\n}\n\n/**\n * Union of all activity names available to a workflow — the workflow-local\n * activities plus the contract's global activities.\n */\ntype ActivityNamesFor<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> =\n | (TContract[\"workflows\"][TWorkflowName][\"activities\"] extends Record<string, ActivityDefinition>\n ? keyof TContract[\"workflows\"][TWorkflowName][\"activities\"] & string\n : never)\n | (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? keyof TContract[\"activities\"] & string\n : never);\n\n/**\n * Options for declaring a workflow implementation\n */\ntype DeclareWorkflowOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n workflowName: TWorkflowName;\n contract: TContract;\n implementation: WorkflowImplementation<TContract, TWorkflowName>;\n /**\n * Default activity options applied to every activity reachable from this\n * workflow (workflow-local + global) unless overridden in\n * {@link activityOptionsByName}. See Temporal's `ActivityOptions` for the\n * full set of fields:\n * - `startToCloseTimeout`: Maximum time for a single attempt to run\n * - `scheduleToCloseTimeout`: End-to-end timeout including queuing and retries\n * - `scheduleToStartTimeout`: Maximum time the activity can wait in the queue\n * - `heartbeatTimeout`: Time between heartbeats before the activity is considered dead\n * - `retry`: Retry policy for failed activities\n *\n * @example\n * ```ts\n * activityOptions: {\n * startToCloseTimeout: '5m',\n * retry: { maximumAttempts: 3 },\n * }\n * ```\n */\n activityOptions: ActivityOptions;\n /**\n * Per-activity `ActivityOptions` overrides. Each entry shallow-merges over\n * {@link activityOptions} for that activity only — the override wins on\n * every property it specifies, replacing the default value (including the\n * entire nested `retry` block when present, matching Temporal's\n * single-options-per-`proxyActivities`-call semantics).\n *\n * Activity names are typed against the contract; typos surface as TypeScript\n * errors rather than running silently with the default options.\n *\n * @example\n * ```ts\n * activityOptions: { startToCloseTimeout: '1 minute' }, // default\n * activityOptionsByName: {\n * chargePayment: {\n * startToCloseTimeout: '5 minutes',\n * retry: { maximumAttempts: 5 },\n * },\n * fastValidation: { startToCloseTimeout: '5 seconds' },\n * },\n * ```\n */\n activityOptionsByName?: Partial<\n Record<ActivityNamesFor<TContract, TWorkflowName>, ActivityOptions>\n >;\n};\n\n/**\n * Workflow implementation function\n *\n * Receives a workflow context (with typed activities and utilities) and validated input arguments.\n * Returns the workflow output which will be validated against the contract schema.\n */\ntype WorkflowImplementation<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = (\n context: WorkflowContext<TContract, TWorkflowName>,\n args: WorkerInferInput<TContract[\"workflows\"][TWorkflowName]>,\n) => Promise<WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>>;\n\n/**\n * Workflow execution context providing typed activities, workflow info, and interaction handlers\n *\n * Provides access to:\n * - Typed activities (both workflow-specific and global)\n * - Workflow metadata and execution info\n * - Signal, query, and update handler registration\n * - Child workflow execution capabilities\n */\ntype WorkflowContext<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n activities: Readonly<WorkflowInferWorkflowContextActivities<TContract, TWorkflowName>>;\n info: WorkflowInfo;\n\n /**\n * Define a signal handler within the workflow implementation\n * Allows the signal handler to access workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineSignal('increment', async (signalArgs) => {\n * currentValue += signalArgs.amount;\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineSignal: <K extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n signalName: K,\n handler: SignalHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]> extends Record<\n string,\n SignalDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]>[K] extends SignalDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Define a query handler within the workflow implementation\n * Allows the query handler to access workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineQuery('getCurrentValue', () => {\n * return { value: currentValue };\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineQuery: <K extends QueryNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n queryName: K,\n handler: QueryHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]> extends Record<\n string,\n QueryDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]>[K] extends QueryDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Define an update handler within the workflow implementation\n * Allows the update handler to access and modify workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineUpdate('multiply', async (updateArgs) => {\n * currentValue *= updateArgs.factor;\n * return { newValue: currentValue };\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineUpdate: <K extends UpdateNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n updateName: K,\n handler: UpdateHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]> extends Record<\n string,\n UpdateDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]>[K] extends UpdateDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Start a child workflow and return a typed handle with ResultAsync pattern\n *\n * Supports both same-contract and cross-contract child workflows:\n * - Same contract: Pass workflowName from current contract\n * - Cross-contract: Pass contract and workflowName to invoke workflows from other workers\n *\n * @example\n * ```ts\n * // Same contract child workflow\n * const childResult = await context.startChildWorkflow(myContract, 'processPayment', {\n * workflowId: 'payment-123',\n * args: { amount: 100 }\n * });\n *\n * // Cross-contract child workflow (from another worker)\n * const otherResult = await context.startChildWorkflow(otherContract, 'sendNotification', {\n * workflowId: 'notification-123',\n * args: { message: 'Hello' }\n * });\n *\n * childResult.match(\n * async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * (error) => console.error('Failed to start:', error),\n * );\n * ```\n */\n startChildWorkflow: <\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n >(\n contract: TChildContract,\n workflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n ) => ResultAsync<\n TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n >;\n\n /**\n * Execute a child workflow (start and wait for result) with ResultAsync pattern\n *\n * Supports both same-contract and cross-contract child workflows:\n * - Same contract: Pass workflowName from current contract\n * - Cross-contract: Pass contract and workflowName to invoke workflows from other workers\n *\n * @example\n * ```ts\n * // Same contract child workflow\n * const result = await context.executeChildWorkflow(myContract, 'processPayment', {\n * workflowId: 'payment-123',\n * args: { amount: 100 }\n * });\n *\n * // Cross-contract child workflow (from another worker)\n * const otherResult = await context.executeChildWorkflow(otherContract, 'sendNotification', {\n * workflowId: 'notification-123',\n * args: { message: 'Hello' }\n * });\n *\n * result.match(\n * (output) => console.log('Payment processed:', output),\n * (error) => console.error('Processing failed:', error),\n * );\n * ```\n */\n executeChildWorkflow: <\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n >(\n contract: TChildContract,\n workflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n ) => ResultAsync<\n ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n >;\n\n /**\n * Run `fn` inside a cancellable Temporal scope. If the workflow (or an\n * ancestor scope) is cancelled while `fn` is in flight, the resulting\n * ResultAsync resolves to `err(WorkflowCancelledError)` instead of\n * rejecting — letting callers handle cancellation explicitly, typically\n * to perform a graceful exit from the current step.\n *\n * Non-cancellation errors thrown by `fn` resolve to\n * `err(WorkflowScopeError)` (with the original error preserved on\n * `cause`). Both failure modes ride neverthrow's railway, so\n * `result.match(...)` is exhaustive — nothing escapes as an unhandled\n * rejection.\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * const result = await context.cancellableScope(async () => {\n * return context.activities.processStep(args);\n * });\n *\n * if (result.isErr()) {\n * if (result.error instanceof WorkflowCancelledError) {\n * // workflow was cancelled — perform cleanup that must not be cancelled:\n * await context.nonCancellableScope(async () => {\n * await context.activities.releaseResources(args);\n * });\n * return { status: \"cancelled\" };\n * }\n * // result.error instanceof WorkflowScopeError — domain failure\n * return { status: \"failed\" };\n * }\n *\n * return { status: \"ok\" };\n * }\n * ```\n */\n cancellableScope: <T>(\n fn: () => T | Promise<T>,\n ) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;\n\n /**\n * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests\n * from outside the scope are ignored for its duration — the idiomatic way\n * to perform cleanup work that must not be interrupted.\n *\n * Returns the same `ResultAsync<...>` shape as\n * {@link WorkflowContext.cancellableScope} for symmetry; the\n * `err(WorkflowCancelledError)` branch only triggers when cancellation is\n * raised from *inside* the scope, which is rare. Non-cancellation errors\n * surface as `err(WorkflowScopeError)`.\n */\n nonCancellableScope: <T>(\n fn: () => T | Promise<T>,\n ) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;\n\n /**\n * Continue this workflow execution as a new run, optionally with a different\n * workflow type from another contract.\n *\n * Args are validated against the destination workflow's input schema before\n * Temporal's `continueAsNew` is invoked. On validation failure, throws a\n * {@link WorkflowInputValidationError}; on success, Temporal terminates the\n * current execution and starts a fresh one — which is why the function\n * never returns normally (`Promise<never>`).\n *\n * Idiomatic usage:\n *\n * @example\n * ```ts\n * // Same workflow, validated args\n * implementation: async (context, args) => {\n * if (shouldRoll(args)) {\n * return context.continueAsNew({ ...args, retryCount: args.retryCount + 1 });\n * }\n * return ...;\n * }\n *\n * // Cross-contract continueAsNew (less common — taskQueue and workflow type\n * // come from the other contract)\n * return context.continueAsNew(otherContract, \"otherWorkflow\", { ...newArgs });\n * ```\n */\n continueAsNew: {\n /** Same-workflow continuation — args typed against this workflow's input. */\n (\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>,\n options?: TypedContinueAsNewOptions,\n ): Promise<never>;\n /** Cross-contract continuation — args typed against the destination workflow. */\n <\n TOtherContract extends ContractDefinition,\n TOtherWorkflowName extends keyof TOtherContract[\"workflows\"] & string,\n >(\n contract: TOtherContract,\n workflowName: TOtherWorkflowName,\n args: ClientInferInput<TOtherContract[\"workflows\"][TOtherWorkflowName]>,\n options?: TypedContinueAsNewOptions,\n ): Promise<never>;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,iBACd,IAC6D;CAC7D,MAAM,OAAO,YAA6E;AACxF,MAAI;AAKF,UAAO,GAAG,MADU,kBAAkB,YAAY,YAAY,IAAI,CAAC,CACnD;WACT,OAAO;AACd,OAAI,eAAe,MAAM,CACvB,QAAO,IAAI,IA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YAAY,OAAO;EAE1E,MAAM,iBAAiB,YAAY;EAuDnC,MAAM,SAAS,MAAM,eAAe;GArClC,YAAY;GAIZ,MAAM,cAAc;GACpB,oBAAoB;GACpB,sBAAsB;GACtB;GACA;GACA,gBAAgB,YAAY,YAC1B,kBACE,YACA,cACA,YACA,QACD;GACH,eAAe,WAAW,YACxB,iBACE,YACA,cACA,WACA,QACD;GACH,gBAAgB,YAAY,YAC1B,kBACE,YACA,cACA,YACA,QACD;GACH,eAAe,oBAAoB,UAAU,aAAa;GAOjB,EAAE,eAAe;EAG5D,MAAM,eAAe,MAAM,WAAW,OAAO,aAAa,SAAS,OAAO;AAC1E,MAAI,aAAa,OACf,OAAM,IAAI,8BAA8B,cAAc,aAAa,OAAO;AAG5E,SAAO,aAAa"}
1
+ {"version":3,"file":"workflow.mjs","names":[],"sources":["../src/cancellation.ts","../src/handlers.ts","../src/child-workflow.ts","../src/activities-proxy.ts","../src/workflow.ts"],"sourcesContent":["/**\n * Typed wrappers around Temporal's `CancellationScope` so workflows can\n * opt into cancellation control without reaching for\n * `@temporalio/workflow` directly. The wrappers fold cancellation into\n * the same `ResultAsync<...>` shape used elsewhere in the worker\n * context — callers branch on `err(WorkflowCancelledError)` instead of\n * catching `CancelledFailure`.\n *\n * Non-cancellation errors thrown inside the scope are wrapped in a\n * {@link WorkflowScopeError} (with the original error preserved on\n * `cause`) and surfaced on the same `err(...)` channel. Together with\n * `WorkflowCancelledError` this makes the failure modes exhaustive on\n * `result.match(...)` — nothing escapes as an unhandled rejection.\n */\nimport { CancellationScope, isCancellation } from \"@temporalio/workflow\";\nimport { type ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport { WorkflowCancelledError, WorkflowScopeError } from \"./errors.js\";\nimport { makeResultAsync } from \"./internal.js\";\n\n/**\n * Run `fn` inside a cancellable Temporal scope. If the workflow (or an\n * ancestor scope) is cancelled while the function is in flight, the\n * resulting ResultAsync resolves to `err(WorkflowCancelledError)`,\n * letting callers handle cancellation explicitly — typically to perform\n * a graceful exit from the current step.\n *\n * Non-cancellation errors thrown by `fn` resolve to\n * `err(WorkflowScopeError)` (with the original error on `cause`) so\n * domain failures surface on the same typed error channel rather than\n * leaking as unhandled rejections.\n *\n * @example\n * ```ts\n * const result = await context.cancellableScope(async () => {\n * return await context.activities.processStep(...);\n * });\n *\n * result.match(\n * (output) => { ... },\n * (error) => {\n * if (error instanceof WorkflowCancelledError) {\n * // graceful exit\n * } else {\n * // error instanceof WorkflowScopeError — domain failure on `cause`\n * }\n * },\n * );\n * ```\n */\nexport function cancellableScope<T>(\n fn: () => T | Promise<T>,\n): ResultAsync<T, WorkflowCancelledError | WorkflowScopeError> {\n const work = async (): Promise<Result<T, WorkflowCancelledError | WorkflowScopeError>> => {\n try {\n // Wrap so synchronous returns satisfy CancellationScope.cancellable's\n // `() => Promise<T>` signature without forcing every caller to write\n // `async () => ...` for purely synchronous bodies.\n const value = await CancellationScope.cancellable(async () => fn());\n return ok(value);\n } catch (error) {\n if (isCancellation(error)) {\n return err(new WorkflowCancelledError(error));\n }\n return err(new WorkflowScopeError(error));\n }\n };\n // makeResultAsync is the shared safety net from `@temporal-contract/contract`\n // — `new ResultAsync(work())` does not catch, so a synchronous throw inside\n // `work` (e.g. a buggy refactor) would escape neverthrow's railway. The\n // catch-all here funnels that back into `err(WorkflowScopeError)` for\n // parity with the in-band path above.\n return makeResultAsync(work, (e) => new WorkflowScopeError(e));\n}\n\n/**\n * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests\n * from outside the scope are ignored for its duration — the idiomatic way\n * to perform cleanup that must not be interrupted (e.g. releasing a\n * resource after a graceful shutdown).\n *\n * Mirrors `cancellableScope`'s `ResultAsync<...>` shape for symmetry; the\n * `err(WorkflowCancelledError)` branch only triggers when cancellation is\n * raised from inside the scope (rare). Non-cancellation errors surface as\n * `err(WorkflowScopeError)`.\n *\n * @example\n * ```ts\n * await context.nonCancellableScope(async () => {\n * await context.activities.releaseResources(...);\n * });\n * ```\n */\nexport function nonCancellableScope<T>(\n fn: () => T | Promise<T>,\n): ResultAsync<T, WorkflowCancelledError | WorkflowScopeError> {\n const work = async (): Promise<Result<T, WorkflowCancelledError | WorkflowScopeError>> => {\n try {\n const value = await CancellationScope.nonCancellable(async () => fn());\n return ok(value);\n } catch (error) {\n if (isCancellation(error)) {\n return err(new WorkflowCancelledError(error));\n }\n return err(new WorkflowScopeError(error));\n }\n };\n return makeResultAsync(work, (e) => new WorkflowScopeError(e));\n}\n","// Top-level helpers for binding signal / query / update handlers to a\n// running workflow. Previously nested inside `declareWorkflow`'s closure\n// (#185), they're hoisted here so the bodies aren't reallocated on each\n// workflow invocation. The typed call-site surface is preserved at the\n// context-assignment site in `workflow.ts` (the arrow that forwards into\n// these helpers carries the contract-derived generic constraints).\n//\n// Internally these are loosely typed (string names, broad `*Definition`\n// inputs); the call sites already do the cast against the typed\n// `WorkflowContext` shape, so the typed-vs-runtime split is the same as\n// it was before the hoist.\nimport type {\n AnyWorkflowDefinition,\n QueryDefinition,\n SignalDefinition,\n UpdateDefinition,\n} from \"@temporal-contract/contract\";\nimport { defineQuery, defineSignal, defineUpdate, setHandler } from \"@temporalio/workflow\";\nimport {\n QueryInputValidationError,\n QueryOutputValidationError,\n SignalInputValidationError,\n UpdateInputValidationError,\n UpdateOutputValidationError,\n} from \"./errors.js\";\nimport { extractHandlerInput } from \"./internal.js\";\nimport type { WorkerInferInput, WorkerInferOutput } from \"./types.js\";\n\n/**\n * Signal handler implementation\n *\n * Processes signal input and can optionally perform asynchronous operations.\n * Should not return a value (signals are fire-and-forget).\n */\nexport type SignalHandlerImplementation<TSignal extends SignalDefinition> = (\n args: WorkerInferInput<TSignal>,\n) => void | Promise<void>;\n\n/**\n * Query handler implementation\n *\n * Processes query input and returns a synchronous response.\n * Must be synchronous to satisfy Temporal's query constraints.\n */\nexport type QueryHandlerImplementation<TQuery extends QueryDefinition> = (\n args: WorkerInferInput<TQuery>,\n) => WorkerInferOutput<TQuery>;\n\n/**\n * Update handler implementation\n *\n * Processes update input and returns a validated response after modifying workflow state.\n * Can perform asynchronous operations.\n */\nexport type UpdateHandlerImplementation<TUpdate extends UpdateDefinition> = (\n args: WorkerInferInput<TUpdate>,\n) => Promise<WorkerInferOutput<TUpdate>>;\n\n/**\n * Bind a typed signal handler to the running workflow. Validates the\n * signal payload against the contract's input schema before invoking the\n * user-supplied handler.\n *\n * The runtime guard against a missing `signals` block — and an unknown\n * signal name within it — covers the union-typed-`workflowName` case\n * where the type system's keyset constraint collapses; without the\n * check, a caller would see `Cannot read properties of undefined`\n * instead of a controlled error.\n */\nexport function bindSignalHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n signalName: string,\n handler: SignalHandlerImplementation<SignalDefinition>,\n): void {\n if (!workflowDefinition.signals) {\n throw new Error(\n `Signal \"${signalName}\" cannot be defined: workflow \"${workflowName}\" has no signals in its contract`,\n );\n }\n const signalDef = (workflowDefinition.signals as Record<string, SignalDefinition>)[signalName];\n if (!signalDef) {\n throw new Error(`Signal \"${signalName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const signal = defineSignal(signalName);\n setHandler(signal, async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = await signalDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new SignalInputValidationError(signalName, inputResult.issues);\n }\n await handler(inputResult.value);\n });\n}\n\n/**\n * Bind a typed query handler to the running workflow. Validates input\n * and output against the contract synchronously.\n *\n * Temporal's query API requires a synchronous handler — async\n * validation breaks replay determinism. The handler trips a clear error\n * if the schema library returns a Promise from `validate(...)`, instead\n * of letting the async path silently corrupt query semantics.\n */\nexport function bindQueryHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n queryName: string,\n handler: QueryHandlerImplementation<QueryDefinition>,\n): void {\n if (!workflowDefinition.queries) {\n throw new Error(\n `Query \"${queryName}\" cannot be defined: workflow \"${workflowName}\" has no queries in its contract`,\n );\n }\n const queryDef = (workflowDefinition.queries as Record<string, QueryDefinition>)[queryName];\n if (!queryDef) {\n throw new Error(`Query \"${queryName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const query = defineQuery(queryName);\n setHandler(query, (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = queryDef.input[\"~standard\"].validate(input);\n\n if (inputResult instanceof Promise) {\n throw new Error(\n `Query \"${queryName}\" validation must be synchronous. Use a schema library that supports synchronous validation for queries.`,\n );\n }\n if (inputResult.issues) {\n throw new QueryInputValidationError(queryName, inputResult.issues);\n }\n\n const result = handler(inputResult.value);\n\n const outputResult = queryDef.output[\"~standard\"].validate(result);\n if (outputResult instanceof Promise) {\n throw new Error(\n `Query \"${queryName}\" output validation must be synchronous. Use a schema library that supports synchronous validation for queries.`,\n );\n }\n if (outputResult.issues) {\n throw new QueryOutputValidationError(queryName, outputResult.issues);\n }\n\n return outputResult.value;\n });\n}\n\n/**\n * Bind a typed update handler to the running workflow.\n *\n * Input validation runs in Temporal's `validator` slot — a synchronous\n * pre-admission hook. If it throws, Temporal rejects the update *before*\n * appending a workflow history event: clients see\n * `WorkflowUpdateValidationRejectedError` and the workflow's history is\n * unaffected. This is the documented contract for `setHandler`'s\n * `validator` option, and it is strictly better than running validation\n * inside the handler body — which forces Temporal to admit the update,\n * write a history event, and surface a `WorkflowUpdateFailedError` to\n * the client only after the fact.\n *\n * Because the validator slot is synchronous, the input schema must also\n * validate synchronously. Standard Schema is allowed to be async (Zod's\n * `.refine(async)` is the typical case), but we trip a clear error when\n * that happens rather than silently breaking admission semantics — same\n * approach as `bindQueryHandler`. Users who need async input checks\n * should run them inside the handler body and accept the post-admission\n * failure mode, or restructure their schema.\n *\n * Output validation continues to run inside the handler body. Update\n * outputs are *not* admission-gated — the handler must execute to\n * produce a value to validate against — so the async-allowed shape is\n * preserved.\n */\nexport function bindUpdateHandler(\n workflowDefinition: AnyWorkflowDefinition,\n workflowName: string,\n updateName: string,\n handler: UpdateHandlerImplementation<UpdateDefinition>,\n): void {\n if (!workflowDefinition.updates) {\n throw new Error(\n `Update \"${updateName}\" cannot be defined: workflow \"${workflowName}\" has no updates in its contract`,\n );\n }\n const updateDef = (workflowDefinition.updates as Record<string, UpdateDefinition>)[updateName];\n if (!updateDef) {\n throw new Error(`Update \"${updateName}\" not found in workflow \"${workflowName}\" contract`);\n }\n\n const update = defineUpdate(updateName);\n setHandler(\n update,\n async (...args: unknown[]) => {\n // The validator already accepted the payload — re-parse here so the\n // handler receives the schema's transformed value (Standard Schema\n // may rewrite shapes during validation, e.g. Zod `.transform`). This\n // is sync because the validator already proved the schema is sync;\n // any async result here would mean the schema changed under us,\n // which is a programmer error worth surfacing.\n const input = extractHandlerInput(args);\n const inputResult = updateDef.input[\"~standard\"].validate(input);\n if (inputResult instanceof Promise) {\n throw new Error(\n `Update \"${updateName}\" input validation must be synchronous. Use a schema library that supports synchronous validation for update inputs (Temporal's update validator slot is synchronous).`,\n );\n }\n if (inputResult.issues) {\n // The validator should have caught this; if we reach here, the\n // schema produced different issues on a second call (non-pure\n // validator). Surface it as the same typed error class for\n // consistency.\n throw new UpdateInputValidationError(updateName, inputResult.issues);\n }\n\n const result = await handler(inputResult.value);\n\n const outputResult = await updateDef.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new UpdateOutputValidationError(updateName, outputResult.issues);\n }\n\n return outputResult.value;\n },\n {\n validator: (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n const inputResult = updateDef.input[\"~standard\"].validate(input);\n\n if (inputResult instanceof Promise) {\n throw new Error(\n `Update \"${updateName}\" input validation must be synchronous. Use a schema library that supports synchronous validation for update inputs (Temporal's update validator slot is synchronous).`,\n );\n }\n if (inputResult.issues) {\n throw new UpdateInputValidationError(updateName, inputResult.issues);\n }\n },\n },\n );\n}\n","/**\n * Child workflow types + helpers used by `declareWorkflow`. Split out of\n * `workflow.ts` to keep that file focused on `declareWorkflow` and its\n * `WorkflowContext` type. Not part of the worker package's public exports.\n */\nimport type { AnyWorkflowDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowHandle,\n ChildWorkflowOptions,\n executeChild,\n startChild,\n} from \"@temporalio/workflow\";\nimport { ResultAsync, type Result, ok, err } from \"neverthrow\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n} from \"./errors.js\";\nimport {\n classifyChildWorkflowError,\n formatChildWorkflowValidationMessage,\n makeResultAsync,\n} from \"./internal.js\";\nimport type { ClientInferInput, ClientInferOutput, WorkerInferInput } from \"./types.js\";\n\n/**\n * Options for starting a child workflow. `taskQueue` and `args` come from\n * the contract; everything else is forwarded to Temporal's\n * `startChild` / `executeChild`.\n */\nexport type TypedChildWorkflowOptions<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n> = Omit<ChildWorkflowOptions, \"taskQueue\" | \"args\"> & {\n args: ClientInferInput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n};\n\n/**\n * Typed handle for a child workflow with neverthrow `ResultAsync` pattern.\n */\nexport type TypedChildWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {\n /**\n * Get child workflow result with `ResultAsync` pattern.\n */\n result: () => ResultAsync<\n ClientInferOutput<TWorkflow>,\n ChildWorkflowError | ChildWorkflowCancelledError\n >;\n\n /**\n * Child workflow ID.\n */\n workflowId: string;\n};\n\nasync function validateChildWorkflowOutput<TChildWorkflow extends AnyWorkflowDefinition>(\n childDefinition: TChildWorkflow,\n result: unknown,\n childWorkflowName: string,\n): Promise<Result<ClientInferOutput<TChildWorkflow>, ChildWorkflowError>> {\n const outputResult = await childDefinition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n return err(\n new ChildWorkflowError(\n formatChildWorkflowValidationMessage(childWorkflowName, \"output\", outputResult.issues),\n ),\n );\n }\n return ok(outputResult.value as ClientInferOutput<TChildWorkflow>);\n}\n\nasync function getAndValidateChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n args: unknown,\n): Promise<\n Result<\n {\n definition: TChildContract[\"workflows\"][TChildWorkflowName];\n validatedInput: WorkerInferInput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n taskQueue: string;\n },\n ChildWorkflowError\n >\n> {\n const childDefinition = childContract.workflows[childWorkflowName];\n\n if (!childDefinition) {\n return err(\n new ChildWorkflowNotFoundError(\n childWorkflowName,\n Object.keys(childContract.workflows) as string[],\n ),\n );\n }\n\n const inputResult = await childDefinition.input[\"~standard\"].validate(args);\n if (inputResult.issues) {\n return err(\n new ChildWorkflowError(\n formatChildWorkflowValidationMessage(childWorkflowName, \"input\", inputResult.issues),\n ),\n );\n }\n\n const validatedInput = inputResult.value as WorkerInferInput<\n TChildContract[\"workflows\"][TChildWorkflowName]\n >;\n\n return ok({\n definition: childDefinition as TChildContract[\"workflows\"][TChildWorkflowName],\n validatedInput,\n taskQueue: childContract.taskQueue,\n });\n}\n\nfunction createTypedChildHandle<TChildWorkflow extends AnyWorkflowDefinition>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handle: ChildWorkflowHandle<any>,\n childDefinition: TChildWorkflow,\n childWorkflowName: string,\n): TypedChildWorkflowHandle<TChildWorkflow> {\n return {\n workflowId: handle.workflowId,\n result: (): ResultAsync<\n ClientInferOutput<TChildWorkflow>,\n ChildWorkflowError | ChildWorkflowCancelledError\n > => {\n const work = async (): Promise<\n Result<ClientInferOutput<TChildWorkflow>, ChildWorkflowError | ChildWorkflowCancelledError>\n > => {\n try {\n const result = await handle.result();\n return validateChildWorkflowOutput(childDefinition, result, childWorkflowName);\n } catch (error) {\n return err(classifyChildWorkflowError(\"result\", error, childWorkflowName));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Child workflow execution failed: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n },\n };\n}\n\nexport function createStartChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n): ResultAsync<\n TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n> {\n type Ok = TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>;\n const work = async (): Promise<\n Result<Ok, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>\n > => {\n const validationResult = await getAndValidateChildWorkflow(\n childContract,\n childWorkflowName,\n options.args,\n );\n\n if (validationResult.isErr()) {\n return err(validationResult.error);\n }\n\n const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;\n\n try {\n const { args: _args, ...temporalOptions } = options;\n const handle = await startChild(childWorkflowName, {\n ...temporalOptions,\n taskQueue,\n args: [validatedInput],\n });\n\n const typedHandle = createTypedChildHandle(handle, childDefinition, childWorkflowName) as Ok;\n\n return ok(typedHandle);\n } catch (error) {\n return err(classifyChildWorkflowError(\"startChild\", error, String(childWorkflowName)));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Failed to start child workflow: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n}\n\nexport function createExecuteChildWorkflow<\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n>(\n childContract: TChildContract,\n childWorkflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n): ResultAsync<\n ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n> {\n type Ok = ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>;\n const work = async (): Promise<\n Result<Ok, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>\n > => {\n const validationResult = await getAndValidateChildWorkflow(\n childContract,\n childWorkflowName,\n options.args,\n );\n\n if (validationResult.isErr()) {\n return err(validationResult.error);\n }\n\n const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;\n\n try {\n const { args: _args, ...temporalOptions } = options;\n const result = await executeChild(childWorkflowName, {\n ...temporalOptions,\n taskQueue,\n args: [validatedInput],\n });\n\n const outputValidationResult = await validateChildWorkflowOutput(\n childDefinition,\n result,\n childWorkflowName,\n );\n\n if (outputValidationResult.isErr()) {\n return err(outputValidationResult.error);\n }\n\n return ok(outputValidationResult.value as Ok);\n } catch (error) {\n return err(classifyChildWorkflowError(\"executeChild\", error, String(childWorkflowName)));\n }\n };\n return makeResultAsync(\n work,\n (error) =>\n new ChildWorkflowError(\n `Failed to execute child workflow: ${error instanceof Error ? error.message : String(error)}`,\n error,\n ),\n );\n}\n","/**\n * Activity inference types + the validated-activities proxy used by\n * `declareWorkflow`. Split out of `workflow.ts` to keep that file focused\n * on `declareWorkflow` and its `WorkflowContext` type. Not part of the\n * worker package's public exports.\n */\nimport type {\n ActivityDefinition,\n AnyWorkflowDefinition,\n ContractDefinition,\n} from \"@temporal-contract/contract\";\nimport { ActivityInputValidationError, ActivityOutputValidationError } from \"./errors.js\";\nimport type { ClientInferInput, ClientInferOutput } from \"./types.js\";\n\n/**\n * Activity function signature from workflow execution perspective.\n *\n * Workflows call activities with validated input (z.input parsed) and receive validated output (z.output).\n */\nexport type WorkflowInferActivity<TActivity extends ActivityDefinition> = (\n args: ClientInferInput<TActivity>,\n) => Promise<ClientInferOutput<TActivity>>;\n\n/**\n * All global activities from a contract (workflow execution perspective).\n */\nexport type WorkflowInferActivities<TContract extends ContractDefinition> =\n TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? {\n [K in keyof TContract[\"activities\"]]: WorkflowInferActivity<TContract[\"activities\"][K]>;\n }\n : {};\n\n/**\n * Workflow-specific activities (workflow execution perspective).\n */\nexport type WorkflowInferWorkflowActivities<T extends AnyWorkflowDefinition> =\n T[\"activities\"] extends Record<string, ActivityDefinition>\n ? {\n [K in keyof T[\"activities\"]]: WorkflowInferActivity<T[\"activities\"][K]>;\n }\n : {};\n\n/**\n * All activities available in a workflow context (workflow execution perspective).\n *\n * Combines workflow-specific activities with global contract activities.\n */\nexport type WorkflowInferWorkflowContextActivities<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = WorkflowInferWorkflowActivities<TContract[\"workflows\"][TWorkflowName]> &\n WorkflowInferActivities<TContract>;\n\n/**\n * Wrap the raw activities proxy with input/output validation against the\n * Standard Schema definitions on the contract. The wrapper enforces data\n * integrity at the workflow → activity boundary in addition to the\n * activity-side validation that `declareActivitiesHandler` already runs.\n */\nexport function createValidatedActivities<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>(\n rawActivities: Record<string, (...args: unknown[]) => Promise<unknown>>,\n workflowActivitiesDefinition: Record<string, ActivityDefinition> | undefined,\n contractActivitiesDefinition: Record<string, ActivityDefinition> | undefined,\n): WorkflowInferWorkflowContextActivities<TContract, TWorkflowName> {\n const validatedActivities = {} as WorkflowInferWorkflowContextActivities<\n TContract,\n TWorkflowName\n >;\n\n // Merge workflow-specific and global contract activities. defineContract\n // guarantees there are no name collisions across scopes, so spread order\n // is just a stable iteration choice (workflow-local last).\n const allActivitiesDefinition = {\n ...contractActivitiesDefinition,\n ...workflowActivitiesDefinition,\n };\n\n for (const [activityName, activityDef] of Object.entries(allActivitiesDefinition)) {\n const rawActivity = rawActivities[activityName];\n\n if (!rawActivity) {\n throw new Error(\n `Activity implementation not found for: \"${activityName}\". ` +\n `Available activities: ${Object.keys(rawActivities).length > 0 ? Object.keys(rawActivities).join(\", \") : \"none\"}`,\n );\n }\n\n (validatedActivities as Record<string, unknown>)[activityName] = async (input: unknown) => {\n const inputResult = await activityDef.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new ActivityInputValidationError(activityName, inputResult.issues);\n }\n\n const result = await rawActivity(inputResult.value);\n\n const outputResult = await activityDef.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new ActivityOutputValidationError(activityName, outputResult.issues);\n }\n\n return outputResult.value;\n };\n }\n\n return validatedActivities;\n}\n","// Entry point for workflow implementations.\n//\n// Workflows run inside Temporal's deterministic sandbox, which intercepts\n// timers, randomness, and Promise scheduling for replay. neverthrow's\n// `Result`/`ResultAsync` rely only on Promise scheduling, so they replay\n// deterministically alongside Temporal's machinery. Activity code (see\n// activity.ts) uses the same neverthrow API.\nimport type {\n ActivityDefinition,\n ContractDefinition,\n QueryDefinition,\n QueryNamesOf,\n SignalDefinition,\n SignalNamesOf,\n UpdateDefinition,\n UpdateNamesOf,\n} from \"@temporal-contract/contract\";\nimport {\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n WorkflowCancelledError,\n WorkflowInputValidationError,\n WorkflowOutputValidationError,\n WorkflowScopeError,\n} from \"./errors.js\";\nimport { cancellableScope, nonCancellableScope } from \"./cancellation.js\";\nimport {\n bindQueryHandler,\n bindSignalHandler,\n bindUpdateHandler,\n type QueryHandlerImplementation,\n type SignalHandlerImplementation,\n type UpdateHandlerImplementation,\n} from \"./handlers.js\";\nimport {\n ClientInferInput,\n ClientInferOutput,\n WorkerInferInput,\n WorkerInferOutput,\n} from \"./types.js\";\nimport type { ResultAsync } from \"neverthrow\";\nimport {\n buildRawActivitiesProxy,\n createContinueAsNew,\n extractHandlerInput,\n type TypedContinueAsNewOptions,\n} from \"./internal.js\";\nimport {\n createStartChildWorkflow,\n createExecuteChildWorkflow,\n type TypedChildWorkflowHandle,\n type TypedChildWorkflowOptions,\n} from \"./child-workflow.js\";\nimport {\n createValidatedActivities,\n type WorkflowInferWorkflowContextActivities,\n} from \"./activities-proxy.js\";\nimport { ActivityOptions, WorkflowInfo, workflowInfo } from \"@temporalio/workflow\";\n\nexport {\n ActivityInputValidationError,\n ActivityOutputValidationError,\n ChildWorkflowCancelledError,\n ChildWorkflowError,\n ChildWorkflowNotFoundError,\n QueryInputValidationError,\n QueryOutputValidationError,\n SignalInputValidationError,\n UpdateInputValidationError,\n UpdateOutputValidationError,\n WorkflowCancelledError,\n WorkflowInputValidationError,\n WorkflowOutputValidationError,\n WorkflowScopeError,\n} from \"./errors.js\";\n\n/**\n * Create a typed workflow implementation with automatic validation\n *\n * This wraps a workflow implementation with:\n * - Input/output validation\n * - Typed workflow context with activities\n * - Workflow info access\n *\n * Workflows must be defined in separate files and imported by the Temporal Worker\n * via workflowsPath.\n *\n * @example\n * ```ts\n * // workflows/processOrder.ts\n * import { declareWorkflow } from '@temporal-contract/worker/workflow';\n * import myContract from '../contract';\n *\n * export const processOrder = declareWorkflow({\n * workflowName: 'processOrder',\n * contract: myContract,\n * activityOptions: {\n * startToCloseTimeout: '1 minute',\n * },\n * // Optional: override `activityOptions` for specific activities. Each\n * // entry shallow-merges over the workflow default — the override wins on\n * // every property it specifies, including the whole `retry` block.\n * activityOptionsByName: {\n * chargePayment: {\n * startToCloseTimeout: '5 minutes',\n * retry: { maximumAttempts: 5 },\n * },\n * },\n * implementation: async (context, args) => {\n * // context.activities: typed activities (workflow + global)\n * // context.info: WorkflowInfo\n *\n * const inventory = await context.activities.validateInventory({\n * orderId: args.orderId,\n * });\n *\n * if (!inventory.available) {\n * return { orderId: args.orderId, status: 'out_of_stock' };\n * }\n *\n * const payment = await context.activities.chargePayment({\n * customerId: args.customerId,\n * amount: 100,\n * });\n *\n * return {\n * orderId: args.orderId,\n * status: payment.success ? 'success' : 'failed',\n * transactionId: payment.transactionId,\n * };\n * },\n * });\n * ```\n *\n * Then in your worker setup:\n * ```ts\n * // worker.ts\n * import { createWorker } from '@temporal-contract/worker/worker';\n * import { activities } from './activities';\n * import myContract from './contract';\n *\n * const worker = await createWorker({\n * contract: myContract,\n * connection,\n * workflowsPath: workflowsPathFromURL(import.meta.url, './workflows.js'),\n * activities,\n * });\n * ```\n */\nexport function declareWorkflow<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n>({\n workflowName,\n contract,\n implementation,\n activityOptions,\n activityOptionsByName,\n}: DeclareWorkflowOptions<TContract, TWorkflowName>): (\n ...args: unknown[]\n) => Promise<WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>> {\n // Get the workflow definition from the contract\n const definition = contract.workflows[workflowName] as TContract[\"workflows\"][TWorkflowName];\n\n // Build the activities proxy *once* at declaration time, not per workflow\n // invocation. Temporal's `proxyActivities` is documented as a module-scope\n // helper — it registers stub functions and may carry bookkeeping\n // (validator pre-registration, payload-converter caching) that breaks if\n // re-invoked on every workflow run. The call depends only on contract-time\n // immutables (`definition.activities`, `contract.activities`,\n // `activityOptions`, `activityOptionsByName`), all of which are available\n // here, so hoisting is safe and deterministic.\n //\n // The validation wrapper (`createValidatedActivities`) is stateless across\n // invocations — it merely closes over the activity definitions and the raw\n // proxy, both immutable — so it is hoisted alongside the proxy. The\n // resulting `contextActivities` object is shared by every workflow run,\n // which is fine because the wrapped activity functions take their input\n // as an argument and validate it per-call (no closed-over per-invocation\n // state).\n //\n // Design note — intentional double-validation:\n // Input and output are validated here (workflow side) AND again inside\n // `declareActivitiesHandler` (activity worker side). This is deliberate:\n //\n // 1. Workflow-side validation catches bad data *before* it crosses the\n // task-queue network boundary, giving an early, descriptive error\n // instead of a confusing deserialization failure inside the activity.\n // 2. Activity-side validation is the authoritative guard, since the\n // activity may be called by other callers that do not use this library.\n //\n // The overhead is minimal relative to the network round-trip.\n let contextActivities: unknown = {};\n\n if (definition.activities || contract.activities) {\n const rawActivities = buildRawActivitiesProxy(\n definition.activities,\n contract.activities,\n activityOptions,\n activityOptionsByName,\n );\n\n contextActivities = createValidatedActivities(\n rawActivities,\n definition.activities,\n contract.activities,\n );\n\n // Shared across workflow invocations after the proxyActivities hoist\n // (PR #211); freeze so user code can't mutate one invocation's view of\n // activities and have it leak into others. The freeze is shallow, which\n // is sufficient because `createValidatedActivities` returns a flat\n // `{ [name]: (input) => Promise<output> }` map — every value is a\n // stateless validation wrapper function, not a nested object users could\n // reach into. The matching `Readonly<...>` on `WorkflowContext.activities`\n // surfaces the immutability at the type level.\n Object.freeze(contextActivities);\n }\n\n const workflowFn = async (...args: unknown[]) => {\n const input = extractHandlerInput(args);\n\n // Validate workflow input\n const inputResult = await definition.input[\"~standard\"].validate(input);\n if (inputResult.issues) {\n throw new WorkflowInputValidationError(workflowName, inputResult.issues);\n }\n const validatedInput = inputResult.value as WorkerInferInput<\n TContract[\"workflows\"][TWorkflowName]\n >;\n\n // Create workflow context.\n //\n // The defineSignal / defineQuery / defineUpdate arrows forward to the\n // hoisted helpers in `./handlers.ts`. The arrows themselves are thin\n // closures that close over `definition` and `workflowName`; the heavy\n // logic — runtime guards, validation, Temporal `defineSignal/Query/\n // Update` + `setHandler` wiring — lives at module scope so it isn't\n // reallocated on each workflow invocation.\n //\n // The cast at each assignment preserves the typed call-site surface\n // (the `K extends keyof ...` constraints declared on\n // `WorkflowContext.defineSignal/Query/Update`), while the helpers\n // themselves take loosely-typed arguments at the runtime boundary.\n const context: WorkflowContext<TContract, TWorkflowName> = {\n activities: contextActivities as WorkflowInferWorkflowContextActivities<\n TContract,\n TWorkflowName\n >,\n info: workflowInfo(),\n startChildWorkflow: createStartChildWorkflow,\n executeChildWorkflow: createExecuteChildWorkflow,\n cancellableScope,\n nonCancellableScope,\n defineSignal: ((signalName, handler) =>\n bindSignalHandler(\n definition,\n workflowName,\n signalName,\n handler as unknown as SignalHandlerImplementation<SignalDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineSignal\"],\n defineQuery: ((queryName, handler) =>\n bindQueryHandler(\n definition,\n workflowName,\n queryName,\n handler as unknown as QueryHandlerImplementation<QueryDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineQuery\"],\n defineUpdate: ((updateName, handler) =>\n bindUpdateHandler(\n definition,\n workflowName,\n updateName,\n handler as unknown as UpdateHandlerImplementation<UpdateDefinition>,\n )) as WorkflowContext<TContract, TWorkflowName>[\"defineUpdate\"],\n continueAsNew: createContinueAsNew(contract, workflowName) as WorkflowContext<\n TContract,\n TWorkflowName\n >[\"continueAsNew\"],\n };\n\n // Execute workflow (pass validated input as tuple)\n const result = await implementation(context, validatedInput);\n\n // Validate workflow output\n const outputResult = await definition.output[\"~standard\"].validate(result);\n if (outputResult.issues) {\n throw new WorkflowOutputValidationError(workflowName, outputResult.issues);\n }\n\n return outputResult.value as WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>;\n };\n\n // Temporal's client.workflow.start(fn, ...) reads `fn.name` to derive the\n // workflow type; without this the anonymous arrow above would surface as \"\".\n Object.defineProperty(workflowFn, \"name\", { value: workflowName, configurable: true });\n\n return workflowFn;\n}\n\n/**\n * Union of all activity names available to a workflow — the workflow-local\n * activities plus the contract's global activities.\n */\ntype ActivityNamesFor<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> =\n | (TContract[\"workflows\"][TWorkflowName][\"activities\"] extends Record<string, ActivityDefinition>\n ? keyof TContract[\"workflows\"][TWorkflowName][\"activities\"] & string\n : never)\n | (TContract[\"activities\"] extends Record<string, ActivityDefinition>\n ? keyof TContract[\"activities\"] & string\n : never);\n\n/**\n * Options for declaring a workflow implementation\n */\ntype DeclareWorkflowOptions<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n workflowName: TWorkflowName;\n contract: TContract;\n implementation: WorkflowImplementation<TContract, TWorkflowName>;\n /**\n * Default activity options applied to every activity reachable from this\n * workflow (workflow-local + global) unless overridden in\n * {@link activityOptionsByName}. See Temporal's `ActivityOptions` for the\n * full set of fields:\n * - `startToCloseTimeout`: Maximum time for a single attempt to run\n * - `scheduleToCloseTimeout`: End-to-end timeout including queuing and retries\n * - `scheduleToStartTimeout`: Maximum time the activity can wait in the queue\n * - `heartbeatTimeout`: Time between heartbeats before the activity is considered dead\n * - `retry`: Retry policy for failed activities\n *\n * @example\n * ```ts\n * activityOptions: {\n * startToCloseTimeout: '5m',\n * retry: { maximumAttempts: 3 },\n * }\n * ```\n */\n activityOptions: ActivityOptions;\n /**\n * Per-activity `ActivityOptions` overrides. Each entry shallow-merges over\n * {@link activityOptions} for that activity only — the override wins on\n * every property it specifies, replacing the default value (including the\n * entire nested `retry` block when present, matching Temporal's\n * single-options-per-`proxyActivities`-call semantics).\n *\n * Activity names are typed against the contract; typos surface as TypeScript\n * errors rather than running silently with the default options.\n *\n * @example\n * ```ts\n * activityOptions: { startToCloseTimeout: '1 minute' }, // default\n * activityOptionsByName: {\n * chargePayment: {\n * startToCloseTimeout: '5 minutes',\n * retry: { maximumAttempts: 5 },\n * },\n * fastValidation: { startToCloseTimeout: '5 seconds' },\n * },\n * ```\n */\n activityOptionsByName?: Partial<\n Record<ActivityNamesFor<TContract, TWorkflowName>, ActivityOptions>\n >;\n};\n\n/**\n * Workflow implementation function\n *\n * Receives a workflow context (with typed activities and utilities) and validated input arguments.\n * Returns the workflow output which will be validated against the contract schema.\n */\ntype WorkflowImplementation<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = (\n context: WorkflowContext<TContract, TWorkflowName>,\n args: WorkerInferInput<TContract[\"workflows\"][TWorkflowName]>,\n) => Promise<WorkerInferOutput<TContract[\"workflows\"][TWorkflowName]>>;\n\n/**\n * Workflow execution context providing typed activities, workflow info, and interaction handlers\n *\n * Provides access to:\n * - Typed activities (both workflow-specific and global)\n * - Workflow metadata and execution info\n * - Signal, query, and update handler registration\n * - Child workflow execution capabilities\n */\ntype WorkflowContext<\n TContract extends ContractDefinition,\n TWorkflowName extends keyof TContract[\"workflows\"] & string,\n> = {\n activities: Readonly<WorkflowInferWorkflowContextActivities<TContract, TWorkflowName>>;\n info: WorkflowInfo;\n\n /**\n * Define a signal handler within the workflow implementation\n * Allows the signal handler to access workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineSignal('increment', async (signalArgs) => {\n * currentValue += signalArgs.amount;\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineSignal: <K extends SignalNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n signalName: K,\n handler: SignalHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]> extends Record<\n string,\n SignalDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]>[K] extends SignalDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"signals\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Define a query handler within the workflow implementation\n * Allows the query handler to access workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineQuery('getCurrentValue', () => {\n * return { value: currentValue };\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineQuery: <K extends QueryNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n queryName: K,\n handler: QueryHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]> extends Record<\n string,\n QueryDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]>[K] extends QueryDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"queries\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Define an update handler within the workflow implementation\n * Allows the update handler to access and modify workflow state\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * let currentValue = args.initialValue;\n *\n * context.defineUpdate('multiply', async (updateArgs) => {\n * currentValue *= updateArgs.factor;\n * return { newValue: currentValue };\n * });\n *\n * // ... rest of workflow\n * }\n * ```\n */\n defineUpdate: <K extends UpdateNamesOf<TContract[\"workflows\"][TWorkflowName]>>(\n updateName: K,\n handler: UpdateHandlerImplementation<\n NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]> extends Record<\n string,\n UpdateDefinition\n >\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]>[K] extends UpdateDefinition\n ? NonNullable<TContract[\"workflows\"][TWorkflowName][\"updates\"]>[K]\n : never\n : never\n >,\n ) => void;\n\n /**\n * Start a child workflow and return a typed handle with ResultAsync pattern\n *\n * Supports both same-contract and cross-contract child workflows:\n * - Same contract: Pass workflowName from current contract\n * - Cross-contract: Pass contract and workflowName to invoke workflows from other workers\n *\n * @example\n * ```ts\n * // Same contract child workflow\n * const childResult = await context.startChildWorkflow(myContract, 'processPayment', {\n * workflowId: 'payment-123',\n * args: { amount: 100 }\n * });\n *\n * // Cross-contract child workflow (from another worker)\n * const otherResult = await context.startChildWorkflow(otherContract, 'sendNotification', {\n * workflowId: 'notification-123',\n * args: { message: 'Hello' }\n * });\n *\n * childResult.match(\n * async (handle) => {\n * const result = await handle.result();\n * // ... handle result\n * },\n * (error) => console.error('Failed to start:', error),\n * );\n * ```\n */\n startChildWorkflow: <\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n >(\n contract: TChildContract,\n workflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n ) => ResultAsync<\n TypedChildWorkflowHandle<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n >;\n\n /**\n * Execute a child workflow (start and wait for result) with ResultAsync pattern\n *\n * Supports both same-contract and cross-contract child workflows:\n * - Same contract: Pass workflowName from current contract\n * - Cross-contract: Pass contract and workflowName to invoke workflows from other workers\n *\n * @example\n * ```ts\n * // Same contract child workflow\n * const result = await context.executeChildWorkflow(myContract, 'processPayment', {\n * workflowId: 'payment-123',\n * args: { amount: 100 }\n * });\n *\n * // Cross-contract child workflow (from another worker)\n * const otherResult = await context.executeChildWorkflow(otherContract, 'sendNotification', {\n * workflowId: 'notification-123',\n * args: { message: 'Hello' }\n * });\n *\n * result.match(\n * (output) => console.log('Payment processed:', output),\n * (error) => console.error('Processing failed:', error),\n * );\n * ```\n */\n executeChildWorkflow: <\n TChildContract extends ContractDefinition,\n TChildWorkflowName extends keyof TChildContract[\"workflows\"] & string,\n >(\n contract: TChildContract,\n workflowName: TChildWorkflowName,\n options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>,\n ) => ResultAsync<\n ClientInferOutput<TChildContract[\"workflows\"][TChildWorkflowName]>,\n ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError\n >;\n\n /**\n * Run `fn` inside a cancellable Temporal scope. If the workflow (or an\n * ancestor scope) is cancelled while `fn` is in flight, the resulting\n * ResultAsync resolves to `err(WorkflowCancelledError)` instead of\n * rejecting — letting callers handle cancellation explicitly, typically\n * to perform a graceful exit from the current step.\n *\n * Non-cancellation errors thrown by `fn` resolve to\n * `err(WorkflowScopeError)` (with the original error preserved on\n * `cause`). Both failure modes ride neverthrow's railway, so\n * `result.match(...)` is exhaustive — nothing escapes as an unhandled\n * rejection.\n *\n * @example\n * ```ts\n * implementation: async (context, args) => {\n * const result = await context.cancellableScope(async () => {\n * return context.activities.processStep(args);\n * });\n *\n * if (result.isErr()) {\n * if (result.error instanceof WorkflowCancelledError) {\n * // workflow was cancelled — perform cleanup that must not be cancelled:\n * await context.nonCancellableScope(async () => {\n * await context.activities.releaseResources(args);\n * });\n * return { status: \"cancelled\" };\n * }\n * // result.error instanceof WorkflowScopeError — domain failure\n * return { status: \"failed\" };\n * }\n *\n * return { status: \"ok\" };\n * }\n * ```\n */\n cancellableScope: <T>(\n fn: () => T | Promise<T>,\n ) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;\n\n /**\n * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests\n * from outside the scope are ignored for its duration — the idiomatic way\n * to perform cleanup work that must not be interrupted.\n *\n * Returns the same `ResultAsync<...>` shape as\n * {@link WorkflowContext.cancellableScope} for symmetry; the\n * `err(WorkflowCancelledError)` branch only triggers when cancellation is\n * raised from *inside* the scope, which is rare. Non-cancellation errors\n * surface as `err(WorkflowScopeError)`.\n */\n nonCancellableScope: <T>(\n fn: () => T | Promise<T>,\n ) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;\n\n /**\n * Continue this workflow execution as a new run, optionally with a different\n * workflow type from another contract.\n *\n * Args are validated against the destination workflow's input schema before\n * Temporal's `continueAsNew` is invoked. On validation failure, throws a\n * {@link WorkflowInputValidationError}; on success, Temporal terminates the\n * current execution and starts a fresh one — which is why the function\n * never returns normally (`Promise<never>`).\n *\n * Idiomatic usage:\n *\n * @example\n * ```ts\n * // Same workflow, validated args\n * implementation: async (context, args) => {\n * if (shouldRoll(args)) {\n * return context.continueAsNew({ ...args, retryCount: args.retryCount + 1 });\n * }\n * return ...;\n * }\n *\n * // Cross-contract continueAsNew (less common — taskQueue and workflow type\n * // come from the other contract)\n * return context.continueAsNew(otherContract, \"otherWorkflow\", { ...newArgs });\n * ```\n */\n continueAsNew: {\n /** Same-workflow continuation — args typed against this workflow's input. */\n (\n args: ClientInferInput<TContract[\"workflows\"][TWorkflowName]>,\n options?: TypedContinueAsNewOptions,\n ): Promise<never>;\n /** Cross-contract continuation — args typed against the destination workflow. */\n <\n TOtherContract extends ContractDefinition,\n TOtherWorkflowName extends keyof TOtherContract[\"workflows\"] & string,\n >(\n contract: TOtherContract,\n workflowName: TOtherWorkflowName,\n args: ClientInferInput<TOtherContract[\"workflows\"][TOtherWorkflowName]>,\n options?: TypedContinueAsNewOptions,\n ): Promise<never>;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,iBACd,IAC6D;CAC7D,MAAM,OAAO,YAA6E;EACxF,IAAI;GAKF,OAAO,GAAG,MADU,kBAAkB,YAAY,YAAY,GAAG,CAAC,CACnD;EACjB,SAAS,OAAO;GACd,IAAI,eAAe,KAAK,GACtB,OAAO,IAAI,IAAI,uBAAuB,KAAK,C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,iBAAiB;CACjC;CAEA,MAAM,aAAa,OAAO,GAAG,SAAoB;EAC/C,MAAM,QAAQ,oBAAoB,IAAI;EAGtC,MAAM,cAAc,MAAM,WAAW,MAAM,YAAY,CAAC,SAAS,KAAK;EACtE,IAAI,YAAY,QACd,MAAM,IAAI,6BAA6B,cAAc,YAAY,MAAM;EAEzE,MAAM,iBAAiB,YAAY;EAuDnC,MAAM,SAAS,MAAM,eAAe;GArClC,YAAY;GAIZ,MAAM,aAAa;GACnB,oBAAoB;GACpB,sBAAsB;GACtB;GACA;GACA,gBAAgB,YAAY,YAC1B,kBACE,YACA,cACA,YACA,OACF;GACF,eAAe,WAAW,YACxB,iBACE,YACA,cACA,WACA,OACF;GACF,gBAAgB,YAAY,YAC1B,kBACE,YACA,cACA,YACA,OACF;GACF,eAAe,oBAAoB,UAAU,YAAY;EAOjB,GAAG,cAAc;EAG3D,MAAM,eAAe,MAAM,WAAW,OAAO,YAAY,CAAC,SAAS,MAAM;EACzE,IAAI,aAAa,QACf,MAAM,IAAI,8BAA8B,cAAc,aAAa,MAAM;EAG3E,OAAO,aAAa;CACtB;CAIA,OAAO,eAAe,YAAY,QAAQ;EAAE,OAAO;EAAc,cAAc;CAAK,CAAC;CAErF,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporal-contract/worker",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Worker utilities with neverthrow Result/ResultAsync for implementing temporal-contract workflows and activities",
5
5
  "keywords": [
6
6
  "contract",
@@ -60,25 +60,25 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@standard-schema/spec": "1.1.0",
63
- "@temporal-contract/contract": "2.2.0"
63
+ "@temporal-contract/contract": "2.3.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@temporalio/client": "1.17.0",
67
- "@temporalio/common": "1.17.0",
68
- "@temporalio/worker": "1.17.0",
69
- "@temporalio/workflow": "1.17.0",
70
- "@types/node": "24.12.2",
71
- "@vitest/coverage-v8": "4.1.5",
66
+ "@temporalio/client": "1.18.0",
67
+ "@temporalio/common": "1.18.0",
68
+ "@temporalio/worker": "1.18.0",
69
+ "@temporalio/workflow": "1.18.0",
70
+ "@types/node": "24.13.1",
71
+ "@vitest/coverage-v8": "4.1.8",
72
72
  "neverthrow": "8.2.0",
73
- "tsdown": "0.21.10",
73
+ "tsdown": "0.22.2",
74
74
  "typedoc": "0.28.19",
75
- "typedoc-plugin-markdown": "4.11.0",
75
+ "typedoc-plugin-markdown": "4.12.0",
76
76
  "typescript": "6.0.3",
77
- "vitest": "4.1.5",
77
+ "vitest": "4.1.8",
78
78
  "zod": "4.4.3",
79
- "@temporal-contract/client": "2.2.0",
80
- "@temporal-contract/testing": "2.2.0",
79
+ "@temporal-contract/client": "2.3.0",
81
80
  "@temporal-contract/typedoc": "0.1.0",
81
+ "@temporal-contract/testing": "2.3.0",
82
82
  "@temporal-contract/tsconfig": "1.0.0"
83
83
  },
84
84
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-DTq5OTwH.d.cts","names":[],"sources":["../src/types.ts","../src/errors.ts"],"mappings":";;;;;;AAOA;;KAAY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAChF,CAAA;;;;;KAOU,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;uBC1Ba,WAAA,SAAoB,KAAA;EAAA,UACxB,WAAA,CAAa,OAAA,UAAiB,KAAA;AAAA;;;;cAa5B,+BAAA,SAAwC,WAAA;EAAA,SAEjC,YAAA;EAAA,SACA,oB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