@temporal-contract/worker 1.0.0 → 2.0.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.
@@ -195,13 +195,13 @@ var ChildWorkflowError = class extends WorkerError {
195
195
  }
196
196
  };
197
197
  /**
198
- * Error returned in the `Result.Error` branch when a typed cancellation
199
- * scope is cancelled via Temporal's cancellation propagation. Returned by
200
- * both `context.cancellableScope` (when the workflow or an ancestor scope
201
- * cancels) and `context.nonCancellableScope` (when cancellation is raised
202
- * from inside the scope). Distinct from arbitrary thrown errors so call
203
- * sites can branch on cancellation explicitly while still surfacing
204
- * non-cancellation errors as Future rejections.
198
+ * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed
199
+ * cancellation scope is cancelled via Temporal's cancellation propagation.
200
+ * Returned by both `context.cancellableScope` (when the workflow or an
201
+ * ancestor scope cancels) and `context.nonCancellableScope` (when
202
+ * cancellation is raised from inside the scope). Distinct from arbitrary
203
+ * thrown errors so call sites can branch on cancellation explicitly while
204
+ * still surfacing non-cancellation errors as ResultAsync rejections.
205
205
  */
206
206
  var WorkflowCancelledError = class extends WorkerError {
207
207
  constructor(cause) {
@@ -351,4 +351,4 @@ function looksLikeCrossContractCall(arg1, arg2) {
351
351
  //#endregion
352
352
  export { formatChildWorkflowValidationMessage as _, ActivityInputValidationError as a, ChildWorkflowNotFoundError as c, SignalInputValidationError as d, UpdateInputValidationError as f, WorkflowOutputValidationError as g, WorkflowInputValidationError as h, ActivityDefinitionNotFoundError as i, QueryInputValidationError as l, WorkflowCancelledError as m, createContinueAsNew as n, ActivityOutputValidationError as o, UpdateOutputValidationError as p, extractHandlerInput as r, ChildWorkflowError as s, buildRawActivitiesProxy as t, QueryOutputValidationError as u };
353
353
 
354
- //# sourceMappingURL=internal-BoNcEtYh.mjs.map
354
+ //# sourceMappingURL=internal--45IXCxX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal--45IXCxX.mjs","names":[],"sources":["../src/format.ts","../src/errors.ts","../src/internal.ts"],"sourcesContent":["/**\n * Issue / validation-message formatters.\n *\n * Lives in its own module (separate from `errors.ts` and `internal.ts`) so\n * both can import these helpers without forming a circular dependency:\n * `errors.ts` -> `format.ts` and `internal.ts` -> `format.ts` are both safe,\n * even when `internal.ts` later needs to import error classes from\n * `errors.ts` (as `createContinueAsNew` does).\n *\n * Not part of the package's public exports map.\n */\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * Pattern for string keys safe to render with dot notation. A \"safe\" key is a\n * JavaScript identifier (letters/digits/underscore/$, not starting with a\n * digit). Anything else — keys containing dots, spaces, leading digits, the\n * empty string, the literal string `\"0\"` etc. — gets bracket-quoted so the\n * path is unambiguous. Reserved words are accepted: we are formatting a\n * diagnostic, not generating runnable code.\n */\nconst SAFE_IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/**\n * Render a Standard Schema {@link StandardSchemaV1.Issue} into a human-readable\n * string that includes the failing field's path.\n */\nexport function formatIssue(issue: StandardSchemaV1.Issue): string {\n if (issue.path === undefined || issue.path.length === 0) {\n return issue.message;\n }\n let path = \"\";\n for (let i = 0; i < issue.path.length; i++) {\n const segment = issue.path[i];\n const key =\n segment !== null && typeof segment === \"object\" && \"key\" in segment ? segment.key : segment;\n if (typeof key === \"number\") {\n path += `[${key}]`;\n } else if (typeof key === \"string\" && SAFE_IDENTIFIER.test(key)) {\n path += i === 0 ? key : `.${key}`;\n } else if (typeof key === \"string\") {\n path += `[${JSON.stringify(key)}]`;\n } else {\n path += `[${String(key)}]`;\n }\n }\n return `at ${path}: ${issue.message}`;\n}\n\n/**\n * Join a list of validation issues into a single message, with each issue\n * rendered via {@link formatIssue} so field paths surface in the error text.\n */\nexport function summarizeIssues(issues: ReadonlyArray<StandardSchemaV1.Issue>): string {\n return issues.map(formatIssue).join(\"; \");\n}\n\n/**\n * Build the message attached to a `ChildWorkflowError` for input/output\n * validation failures. Centralized so the worker and any future call sites\n * format identically.\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","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"./format.js\";\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 */\nexport class ChildWorkflowError extends WorkerError {\n constructor(message: string, cause?: unknown) {\n super(message, cause);\n this.name = \"ChildWorkflowError\";\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 while\n * still surfacing non-cancellation errors as ResultAsync rejections.\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 * 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 { makeContinueAsNewFunc, proxyActivities } from \"@temporalio/workflow\";\nimport type { ActivityOptions, ContinueAsNewOptions } from \"@temporalio/workflow\";\nimport type { ActivityDefinition, ContractDefinition } from \"@temporal-contract/contract\";\nimport { WorkflowInputValidationError } from \"./errors.js\";\n\n// Re-export the formatters so workflow.ts and existing tests can keep\n// importing from `./internal.js`. Their canonical home is `./format.js`,\n// which both `errors.ts` and `internal.ts` import from to avoid a\n// circular dependency once `internal.ts` started importing error classes.\nexport { formatIssue, summarizeIssues, formatChildWorkflowValidationMessage } from \"./format.js\";\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"],"mappings":";;;;;;;;;;AAqBA,MAAM,kBAAkB;;;;;AAMxB,SAAgB,YAAY,OAAuC;AACjE,KAAI,MAAM,SAAS,KAAA,KAAa,MAAM,KAAK,WAAW,EACpD,QAAO,MAAM;CAEf,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,KAAK,QAAQ,KAAK;EAC1C,MAAM,UAAU,MAAM,KAAK;EAC3B,MAAM,MACJ,YAAY,QAAQ,OAAO,YAAY,YAAY,SAAS,UAAU,QAAQ,MAAM;AACtF,MAAI,OAAO,QAAQ,SACjB,SAAQ,IAAI,IAAI;WACP,OAAO,QAAQ,YAAY,gBAAgB,KAAK,IAA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the `Result.Error` branch when a typed cancellation
199
- * scope is cancelled via Temporal's cancellation propagation. Returned by
200
- * both `context.cancellableScope` (when the workflow or an ancestor scope
201
- * cancels) and `context.nonCancellableScope` (when cancellation is raised
202
- * from inside the scope). Distinct from arbitrary thrown errors so call
203
- * sites can branch on cancellation explicitly while still surfacing
204
- * non-cancellation errors as Future rejections.
198
+ * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed
199
+ * cancellation scope is cancelled via Temporal's cancellation propagation.
200
+ * Returned by both `context.cancellableScope` (when the workflow or an
201
+ * ancestor scope cancels) and `context.nonCancellableScope` (when
202
+ * cancellation is raised from inside the scope). Distinct from arbitrary
203
+ * thrown errors so call sites can branch on cancellation explicitly while
204
+ * still surfacing non-cancellation errors as ResultAsync rejections.
205
205
  */
206
206
  var WorkflowCancelledError = class extends WorkerError {
207
207
  constructor(cause) {
package/dist/workflow.cjs CHANGED
@@ -1,24 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal = require("./internal-Tj4m4f_K.cjs");
2
+ const require_internal = require("./internal-C8MB-kez.cjs");
3
3
  let _temporalio_workflow = require("@temporalio/workflow");
4
- let _temporal_contract_boxed = require("@temporal-contract/boxed");
4
+ let neverthrow = require("neverthrow");
5
5
  //#region src/cancellation.ts
6
6
  /**
7
7
  * Typed wrappers around Temporal's `CancellationScope` so workflows can
8
8
  * opt into cancellation control without reaching for
9
9
  * `@temporalio/workflow` directly. The wrappers fold cancellation into
10
- * the same `Future<Result<...>>` shape used elsewhere in the worker
11
- * context — callers branch on `Result.Error(WorkflowCancelledError)`
12
- * instead of catching `CancelledFailure`.
10
+ * the same `ResultAsync<...>` shape used elsewhere in the worker
11
+ * context — callers branch on `err(WorkflowCancelledError)` instead of
12
+ * catching `CancelledFailure`.
13
13
  *
14
14
  * Non-cancellation errors thrown inside the scope are *not* swallowed:
15
- * the Future rejects with the original error so user-domain failures
15
+ * the ResultAsync rejects with the original error so user-domain failures
16
16
  * keep their identity.
17
17
  */
18
18
  /**
19
19
  * Run `fn` inside a cancellable Temporal scope. If the workflow (or an
20
20
  * ancestor scope) is cancelled while the function is in flight, the
21
- * resulting Future resolves to `Result.Error(WorkflowCancelledError)`,
21
+ * resulting ResultAsync resolves to `err(WorkflowCancelledError)`,
22
22
  * letting callers handle cancellation explicitly — typically to perform
23
23
  * a graceful exit from the current step.
24
24
  *
@@ -28,24 +28,24 @@ let _temporal_contract_boxed = require("@temporal-contract/boxed");
28
28
  * return await context.activities.processStep(...);
29
29
  * });
30
30
  *
31
- * result.match({
32
- * Ok: (output) => { ... },
33
- * Error: (err) => {
34
- * // err instanceof WorkflowCancelledError — graceful exit
31
+ * result.match(
32
+ * (output) => { ... },
33
+ * (cancelled) => {
34
+ * // cancelled instanceof WorkflowCancelledError — graceful exit
35
35
  * },
36
- * });
36
+ * );
37
37
  * ```
38
38
  */
39
39
  function cancellableScope(fn) {
40
- return _temporal_contract_boxed.Future.fromAsync(async () => {
40
+ const work = async () => {
41
41
  try {
42
- const value = await _temporalio_workflow.CancellationScope.cancellable(async () => fn());
43
- return _temporal_contract_boxed.Result.Ok(value);
42
+ return (0, neverthrow.ok)(await _temporalio_workflow.CancellationScope.cancellable(async () => fn()));
44
43
  } catch (error) {
45
- if ((0, _temporalio_workflow.isCancellation)(error)) return _temporal_contract_boxed.Result.Error(new require_internal.WorkflowCancelledError(error));
44
+ if ((0, _temporalio_workflow.isCancellation)(error)) return (0, neverthrow.err)(new require_internal.WorkflowCancelledError(error));
46
45
  throw error;
47
46
  }
48
- });
47
+ };
48
+ return new neverthrow.ResultAsync(work());
49
49
  }
50
50
  /**
51
51
  * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests
@@ -53,9 +53,9 @@ function cancellableScope(fn) {
53
53
  * to perform cleanup that must not be interrupted (e.g. releasing a
54
54
  * resource after a graceful shutdown).
55
55
  *
56
- * Mirrors `cancellableScope`'s `Future<Result<...>>` shape for symmetry;
57
- * the `Result.Error` branch only triggers when cancellation is raised
58
- * from inside the scope (rare).
56
+ * Mirrors `cancellableScope`'s `ResultAsync<...>` shape for symmetry;
57
+ * the `err(...)` branch only triggers when cancellation is raised from
58
+ * inside the scope (rare).
59
59
  *
60
60
  * @example
61
61
  * ```ts
@@ -65,15 +65,15 @@ function cancellableScope(fn) {
65
65
  * ```
66
66
  */
67
67
  function nonCancellableScope(fn) {
68
- return _temporal_contract_boxed.Future.fromAsync(async () => {
68
+ const work = async () => {
69
69
  try {
70
- const value = await _temporalio_workflow.CancellationScope.nonCancellable(async () => fn());
71
- return _temporal_contract_boxed.Result.Ok(value);
70
+ return (0, neverthrow.ok)(await _temporalio_workflow.CancellationScope.nonCancellable(async () => fn()));
72
71
  } catch (error) {
73
- if ((0, _temporalio_workflow.isCancellation)(error)) return _temporal_contract_boxed.Result.Error(new require_internal.WorkflowCancelledError(error));
72
+ if ((0, _temporalio_workflow.isCancellation)(error)) return (0, neverthrow.err)(new require_internal.WorkflowCancelledError(error));
74
73
  throw error;
75
74
  }
76
- });
75
+ };
76
+ return new neverthrow.ResultAsync(work());
77
77
  }
78
78
  //#endregion
79
79
  //#region src/handlers.ts
@@ -271,16 +271,16 @@ function createValidatedActivities(rawActivities, workflowActivitiesDefinition,
271
271
  }
272
272
  async function validateChildWorkflowOutput(childDefinition, result, childWorkflowName) {
273
273
  const outputResult = await childDefinition.output["~standard"].validate(result);
274
- if (outputResult.issues) return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "output", outputResult.issues)));
275
- return _temporal_contract_boxed.Result.Ok(outputResult.value);
274
+ if (outputResult.issues) return (0, neverthrow.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "output", outputResult.issues)));
275
+ return (0, neverthrow.ok)(outputResult.value);
276
276
  }
277
277
  async function getAndValidateChildWorkflow(childContract, childWorkflowName, args) {
278
278
  const childDefinition = childContract.workflows[childWorkflowName];
279
- if (!childDefinition) return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowNotFoundError(String(childWorkflowName), Object.keys(childContract.workflows)));
279
+ if (!childDefinition) return (0, neverthrow.err)(new require_internal.ChildWorkflowNotFoundError(String(childWorkflowName), Object.keys(childContract.workflows)));
280
280
  const inputResult = await childDefinition.input["~standard"].validate(args);
281
- if (inputResult.issues) return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(String(childWorkflowName), "input", inputResult.issues)));
281
+ if (inputResult.issues) return (0, neverthrow.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(String(childWorkflowName), "input", inputResult.issues)));
282
282
  const validatedInput = inputResult.value;
283
- return _temporal_contract_boxed.Result.Ok({
283
+ return (0, neverthrow.ok)({
284
284
  definition: childDefinition,
285
285
  validatedInput,
286
286
  taskQueue: childContract.taskQueue
@@ -290,38 +290,39 @@ function createTypedChildHandle(handle, childDefinition, childWorkflowName) {
290
290
  return {
291
291
  workflowId: handle.workflowId,
292
292
  result: () => {
293
- return _temporal_contract_boxed.Future.fromAsync(async () => {
293
+ const work = async () => {
294
294
  try {
295
295
  return validateChildWorkflowOutput(childDefinition, await handle.result(), childWorkflowName);
296
296
  } catch (error) {
297
- return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowError(`Child workflow execution failed: ${error instanceof Error ? error.message : String(error)}`, error));
297
+ return (0, neverthrow.err)(new require_internal.ChildWorkflowError(`Child workflow execution failed: ${error instanceof Error ? error.message : String(error)}`, error));
298
298
  }
299
- });
299
+ };
300
+ return new neverthrow.ResultAsync(work());
300
301
  }
301
302
  };
302
303
  }
303
304
  function createStartChildWorkflow(childContract, childWorkflowName, options) {
304
- return _temporal_contract_boxed.Future.fromAsync(async () => {
305
+ const work = async () => {
305
306
  const validationResult = await getAndValidateChildWorkflow(childContract, childWorkflowName, options.args);
306
- if (validationResult.isError()) return _temporal_contract_boxed.Result.Error(validationResult.error);
307
+ if (validationResult.isErr()) return (0, neverthrow.err)(validationResult.error);
307
308
  const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;
308
309
  try {
309
310
  const { args: _args, ...temporalOptions } = options;
310
- const typedHandle = createTypedChildHandle(await (0, _temporalio_workflow.startChild)(childWorkflowName, {
311
+ return (0, neverthrow.ok)(createTypedChildHandle(await (0, _temporalio_workflow.startChild)(childWorkflowName, {
311
312
  ...temporalOptions,
312
313
  taskQueue,
313
314
  args: [validatedInput]
314
- }), childDefinition, String(childWorkflowName));
315
- return _temporal_contract_boxed.Result.Ok(typedHandle);
315
+ }), childDefinition, String(childWorkflowName)));
316
316
  } catch (error) {
317
- return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowError(`Failed to start child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
317
+ return (0, neverthrow.err)(new require_internal.ChildWorkflowError(`Failed to start child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
318
318
  }
319
- });
319
+ };
320
+ return new neverthrow.ResultAsync(work());
320
321
  }
321
322
  function createExecuteChildWorkflow(childContract, childWorkflowName, options) {
322
- return _temporal_contract_boxed.Future.fromAsync(async () => {
323
+ const work = async () => {
323
324
  const validationResult = await getAndValidateChildWorkflow(childContract, childWorkflowName, options.args);
324
- if (validationResult.isError()) return _temporal_contract_boxed.Result.Error(validationResult.error);
325
+ if (validationResult.isErr()) return (0, neverthrow.err)(validationResult.error);
325
326
  const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;
326
327
  try {
327
328
  const { args: _args, ...temporalOptions } = options;
@@ -330,12 +331,13 @@ function createExecuteChildWorkflow(childContract, childWorkflowName, options) {
330
331
  taskQueue,
331
332
  args: [validatedInput]
332
333
  }), String(childWorkflowName));
333
- if (outputValidationResult.isError()) return _temporal_contract_boxed.Result.Error(outputValidationResult.error);
334
- return _temporal_contract_boxed.Result.Ok(outputValidationResult.value);
334
+ if (outputValidationResult.isErr()) return (0, neverthrow.err)(outputValidationResult.error);
335
+ return (0, neverthrow.ok)(outputValidationResult.value);
335
336
  } catch (error) {
336
- return _temporal_contract_boxed.Result.Error(new require_internal.ChildWorkflowError(`Failed to execute child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
337
+ return (0, neverthrow.err)(new require_internal.ChildWorkflowError(`Failed to execute child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
337
338
  }
338
- });
339
+ };
340
+ return new neverthrow.ResultAsync(work());
339
341
  }
340
342
  //#endregion
341
343
  exports.ActivityInputValidationError = require_internal.ActivityInputValidationError;
@@ -1,7 +1,7 @@
1
- import { _ as WorkerInferOutput, a as ChildWorkflowNotFoundError, c as SignalInputValidationError, d as WorkflowCancelledError, f as WorkflowInputValidationError, g as WorkerInferInput, h as ClientInferOutput, i as ChildWorkflowError, l as UpdateInputValidationError, m as ClientInferInput, n as ActivityInputValidationError, o as QueryInputValidationError, p as WorkflowOutputValidationError, r as ActivityOutputValidationError, s as QueryOutputValidationError, u as UpdateOutputValidationError } from "./errors-CG1y7SHO.cjs";
1
+ import { _ as WorkerInferOutput, a as ChildWorkflowNotFoundError, c as SignalInputValidationError, d as WorkflowCancelledError, f as WorkflowInputValidationError, g as WorkerInferInput, h as ClientInferOutput, i as ChildWorkflowError, l as UpdateInputValidationError, m as ClientInferInput, n as ActivityInputValidationError, o as QueryInputValidationError, p as WorkflowOutputValidationError, r as ActivityOutputValidationError, s as QueryOutputValidationError, u as UpdateOutputValidationError } from "./errors-BeIXtRJe.cjs";
2
2
  import { ActivityDefinition, ContractDefinition, QueryDefinition, SignalDefinition, UpdateDefinition, WorkflowDefinition } from "@temporal-contract/contract";
3
+ import { ResultAsync } from "neverthrow";
3
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
- import { Future, Result } from "@temporal-contract/boxed";
5
5
  import { ActivityOptions, ChildWorkflowOptions, ContinueAsNewOptions, WorkflowInfo } from "@temporalio/workflow";
6
6
 
7
7
  //#region src/handlers.d.ts
@@ -247,7 +247,7 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
247
247
  */
248
248
  defineUpdate: <K extends keyof TContract["workflows"][TWorkflowName]["updates"]>(updateName: K, handler: UpdateHandlerImplementation<TContract["workflows"][TWorkflowName]["updates"][K] extends UpdateDefinition ? TContract["workflows"][TWorkflowName]["updates"][K] : never>) => void;
249
249
  /**
250
- * Start a child workflow and return a typed handle with Future/Result pattern
250
+ * Start a child workflow and return a typed handle with ResultAsync pattern
251
251
  *
252
252
  * Supports both same-contract and cross-contract child workflows:
253
253
  * - Same contract: Pass workflowName from current contract
@@ -267,18 +267,18 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
267
267
  * args: { message: 'Hello' }
268
268
  * });
269
269
  *
270
- * childResult.match({
271
- * Ok: async (handle) => {
270
+ * childResult.match(
271
+ * async (handle) => {
272
272
  * const result = await handle.result();
273
273
  * // ... handle result
274
274
  * },
275
- * Error: (error) => console.error('Failed to start:', error),
276
- * });
275
+ * (error) => console.error('Failed to start:', error),
276
+ * );
277
277
  * ```
278
278
  */
279
- startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => Future<Result<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>>;
279
+ startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>;
280
280
  /**
281
- * Execute a child workflow (start and wait for result) with Future/Result pattern
281
+ * Execute a child workflow (start and wait for result) with ResultAsync pattern
282
282
  *
283
283
  * Supports both same-contract and cross-contract child workflows:
284
284
  * - Same contract: Pass workflowName from current contract
@@ -298,22 +298,23 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
298
298
  * args: { message: 'Hello' }
299
299
  * });
300
300
  *
301
- * result.match({
302
- * Ok: (output) => console.log('Payment processed:', output),
303
- * Error: (error) => console.error('Processing failed:', error),
304
- * });
301
+ * result.match(
302
+ * (output) => console.log('Payment processed:', output),
303
+ * (error) => console.error('Processing failed:', error),
304
+ * );
305
305
  * ```
306
306
  */
307
- executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => Future<Result<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>>;
307
+ executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>;
308
308
  /**
309
309
  * Run `fn` inside a cancellable Temporal scope. If the workflow (or an
310
310
  * ancestor scope) is cancelled while `fn` is in flight, the resulting
311
- * Future resolves to `Result.Error(WorkflowCancelledError)` instead of
311
+ * ResultAsync resolves to `err(WorkflowCancelledError)` instead of
312
312
  * rejecting — letting callers handle cancellation explicitly, typically
313
313
  * to perform a graceful exit from the current step.
314
314
  *
315
- * Non-cancellation errors thrown by `fn` propagate as Future rejections
316
- * unchanged, preserving their identity for upstream `try/catch` blocks.
315
+ * Non-cancellation errors thrown by `fn` propagate as ResultAsync
316
+ * rejections unchanged, preserving their identity for upstream
317
+ * `try/catch` blocks.
317
318
  *
318
319
  * @example
319
320
  * ```ts
@@ -322,7 +323,7 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
322
323
  * return context.activities.processStep(args);
323
324
  * });
324
325
  *
325
- * if (result.isError()) {
326
+ * if (result.isErr()) {
326
327
  * // workflow was cancelled — perform cleanup that must not be cancelled:
327
328
  * await context.nonCancellableScope(async () => {
328
329
  * await context.activities.releaseResources(args);
@@ -334,18 +335,18 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
334
335
  * }
335
336
  * ```
336
337
  */
337
- cancellableScope: <T>(fn: () => T | Promise<T>) => Future<Result<T, WorkflowCancelledError>>;
338
+ cancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError>;
338
339
  /**
339
340
  * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests
340
341
  * from outside the scope are ignored for its duration — the idiomatic way
341
342
  * to perform cleanup work that must not be interrupted.
342
343
  *
343
- * Returns the same `Future<Result<...>>` shape as
344
- * {@link WorkflowContext.cancellableScope} for symmetry; the
345
- * `Result.Error` branch only triggers when cancellation is raised from
346
- * *inside* the scope, which is rare.
344
+ * Returns the same `ResultAsync<...>` shape as
345
+ * {@link WorkflowContext.cancellableScope} for symmetry; the `err(...)`
346
+ * branch only triggers when cancellation is raised from *inside* the
347
+ * scope, which is rare.
347
348
  */
348
- nonCancellableScope: <T>(fn: () => T | Promise<T>) => Future<Result<T, WorkflowCancelledError>>;
349
+ nonCancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError>;
349
350
  /**
350
351
  * Continue this workflow execution as a new run, optionally with a different
351
352
  * workflow type from another contract.
@@ -385,13 +386,13 @@ type TypedChildWorkflowOptions<TChildContract extends ContractDefinition, TChild
385
386
  args: ClientInferInput<TChildContract["workflows"][TChildWorkflowName]>;
386
387
  };
387
388
  /**
388
- * Typed handle for a child workflow with Future/Result pattern
389
+ * Typed handle for a child workflow with neverthrow ResultAsync pattern
389
390
  */
390
391
  type TypedChildWorkflowHandle<TWorkflow extends WorkflowDefinition> = {
391
392
  /**
392
393
  * Get child workflow result with Result pattern
393
394
  */
394
- result: () => Future<Result<ClientInferOutput<TWorkflow>, ChildWorkflowError>>;
395
+ result: () => ResultAsync<ClientInferOutput<TWorkflow>, ChildWorkflowError>;
395
396
  /**
396
397
  * Child workflow ID
397
398
  */
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.cts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;AAkCA;KAAY,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;;;;;;;;KC2DnB,yBAAA,GAA4B,IAAA,CAAK,oBAAA;;;;;;;;;;;;;;;;;;;ADvE7C;;;;;;;;;;;;;;;;;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;AC6DA;;;;;;;;AC8BA;;;;;;iBAAgB,eAAA,mBACI,kBAAA,8BACU,SAAA,cAAA,CAAA;EAE5B,YAAA;EACA,QAAA;EACA,cAAA;EACA,eAAA;EACA;AAAA,GACC,sBAAA,CAAuB,SAAA,EAAW,aAAA,QAChC,IAAA,gBACA,OAAA,CAAQ,iBAAA,CAAkB,SAAA,cAAuB,aAAA;;;;;KAmHjD,gBAAA,mBACe,kBAAA,8BACU,SAAA,kBAEzB,SAAA,cAAuB,aAAA,wBAAqC,MAAA,SAAe,kBAAA,UAClE,SAAA,cAAuB,aAAA,qCAEhC,SAAA,uBAAgC,MAAA,SAAe,kBAAA,UACtC,SAAA;;;;KAMT,sBAAA,mBACe,kBAAA,8BACU,SAAA;EAE5B,YAAA,EAAc,aAAA;EACd,QAAA,EAAU,SAAA;EACV,cAAA,EAAgB,sBAAA,CAAuB,SAAA,EAAW,aAAA;EAjJlD;;;;;;;;;;;;;;;;;;;EAqKA,eAAA,EAAiB,eAAA;EA3JY;;;;AA6G9B;;;;;;;;;;;;;;;;;;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IAAA,wBA0NmB,kBAAA,mCACU,cAAA,eAEjC,QAAA,EAAU,cAAA,EACV,YAAA,EAAc,kBAAA,EACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA,IACnD,OAAA,GAAU,yBAAA,GACT,OAAA;EAAA;AAAA;;;;KAOF,yBAAA,wBACoB,kBAAA,mCACU,cAAA,iBAC/B,IAAA,CAAK,oBAAA;EACP,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA;AAAA;;;;KAMhD,wBAAA,mBAA2C,kBAAA;EAzNkB;;;EA6NhE,MAAA,QAAc,WAAA,CAAY,iBAAA,CAAkB,SAAA,GAAY,kBAAA;EA9NtD;;;EAmOF,UAAA;AAAA;;;;;;KAQG,qBAAA,mBAAwC,kBAAA,KAC3C,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;KAK1B,uBAAA,mBAA0C,kBAAA,IAC7C,SAAA,uBAAgC,MAAA,SAAe,kBAAA,kBAE7B,SAAA,iBAA0B,qBAAA,CAAsB,SAAA,eAAwB,CAAA;;;;KAOvF,+BAAA,WAA0C,kBAAA,IAC7C,CAAA,uBAAwB,MAAA,SAAe,kBAAA,kBAErB,CAAA,iBAAkB,qBAAA,CAAsB,CAAA,eAAgB,CAAA;;;;;;KASvE,sCAAA,mBACe,kBAAA,8BACU,SAAA,iBAC1B,+BAAA,CAAgC,SAAA,cAAuB,aAAA,KACzD,uBAAA,CAAwB,SAAA"}
@@ -1,6 +1,6 @@
1
- import { _ as WorkerInferOutput, a as ChildWorkflowNotFoundError, c as SignalInputValidationError, d as WorkflowCancelledError, f as WorkflowInputValidationError, g as WorkerInferInput, h as ClientInferOutput, i as ChildWorkflowError, l as UpdateInputValidationError, m as ClientInferInput, n as ActivityInputValidationError, o as QueryInputValidationError, p as WorkflowOutputValidationError, r as ActivityOutputValidationError, s as QueryOutputValidationError, u as UpdateOutputValidationError } from "./errors-DZhaNhwr.mjs";
1
+ import { _ as WorkerInferOutput, a as ChildWorkflowNotFoundError, c as SignalInputValidationError, d as WorkflowCancelledError, f as WorkflowInputValidationError, g as WorkerInferInput, h as ClientInferOutput, i as ChildWorkflowError, l as UpdateInputValidationError, m as ClientInferInput, n as ActivityInputValidationError, o as QueryInputValidationError, p as WorkflowOutputValidationError, r as ActivityOutputValidationError, s as QueryOutputValidationError, u as UpdateOutputValidationError } from "./errors-BjNG_jUi.mjs";
2
2
  import { ActivityOptions, ChildWorkflowOptions, ContinueAsNewOptions, WorkflowInfo } from "@temporalio/workflow";
3
- import { Future, Result } from "@temporal-contract/boxed";
3
+ import { ResultAsync } from "neverthrow";
4
4
  import { ActivityDefinition, ContractDefinition, QueryDefinition, SignalDefinition, UpdateDefinition, WorkflowDefinition } from "@temporal-contract/contract";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
 
@@ -247,7 +247,7 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
247
247
  */
248
248
  defineUpdate: <K extends keyof TContract["workflows"][TWorkflowName]["updates"]>(updateName: K, handler: UpdateHandlerImplementation<TContract["workflows"][TWorkflowName]["updates"][K] extends UpdateDefinition ? TContract["workflows"][TWorkflowName]["updates"][K] : never>) => void;
249
249
  /**
250
- * Start a child workflow and return a typed handle with Future/Result pattern
250
+ * Start a child workflow and return a typed handle with ResultAsync pattern
251
251
  *
252
252
  * Supports both same-contract and cross-contract child workflows:
253
253
  * - Same contract: Pass workflowName from current contract
@@ -267,18 +267,18 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
267
267
  * args: { message: 'Hello' }
268
268
  * });
269
269
  *
270
- * childResult.match({
271
- * Ok: async (handle) => {
270
+ * childResult.match(
271
+ * async (handle) => {
272
272
  * const result = await handle.result();
273
273
  * // ... handle result
274
274
  * },
275
- * Error: (error) => console.error('Failed to start:', error),
276
- * });
275
+ * (error) => console.error('Failed to start:', error),
276
+ * );
277
277
  * ```
278
278
  */
279
- startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => Future<Result<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>>;
279
+ startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>;
280
280
  /**
281
- * Execute a child workflow (start and wait for result) with Future/Result pattern
281
+ * Execute a child workflow (start and wait for result) with ResultAsync pattern
282
282
  *
283
283
  * Supports both same-contract and cross-contract child workflows:
284
284
  * - Same contract: Pass workflowName from current contract
@@ -298,22 +298,23 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
298
298
  * args: { message: 'Hello' }
299
299
  * });
300
300
  *
301
- * result.match({
302
- * Ok: (output) => console.log('Payment processed:', output),
303
- * Error: (error) => console.error('Processing failed:', error),
304
- * });
301
+ * result.match(
302
+ * (output) => console.log('Payment processed:', output),
303
+ * (error) => console.error('Processing failed:', error),
304
+ * );
305
305
  * ```
306
306
  */
307
- executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => Future<Result<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>>;
307
+ executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"]>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError>;
308
308
  /**
309
309
  * Run `fn` inside a cancellable Temporal scope. If the workflow (or an
310
310
  * ancestor scope) is cancelled while `fn` is in flight, the resulting
311
- * Future resolves to `Result.Error(WorkflowCancelledError)` instead of
311
+ * ResultAsync resolves to `err(WorkflowCancelledError)` instead of
312
312
  * rejecting — letting callers handle cancellation explicitly, typically
313
313
  * to perform a graceful exit from the current step.
314
314
  *
315
- * Non-cancellation errors thrown by `fn` propagate as Future rejections
316
- * unchanged, preserving their identity for upstream `try/catch` blocks.
315
+ * Non-cancellation errors thrown by `fn` propagate as ResultAsync
316
+ * rejections unchanged, preserving their identity for upstream
317
+ * `try/catch` blocks.
317
318
  *
318
319
  * @example
319
320
  * ```ts
@@ -322,7 +323,7 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
322
323
  * return context.activities.processStep(args);
323
324
  * });
324
325
  *
325
- * if (result.isError()) {
326
+ * if (result.isErr()) {
326
327
  * // workflow was cancelled — perform cleanup that must not be cancelled:
327
328
  * await context.nonCancellableScope(async () => {
328
329
  * await context.activities.releaseResources(args);
@@ -334,18 +335,18 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
334
335
  * }
335
336
  * ```
336
337
  */
337
- cancellableScope: <T>(fn: () => T | Promise<T>) => Future<Result<T, WorkflowCancelledError>>;
338
+ cancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError>;
338
339
  /**
339
340
  * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests
340
341
  * from outside the scope are ignored for its duration — the idiomatic way
341
342
  * to perform cleanup work that must not be interrupted.
342
343
  *
343
- * Returns the same `Future<Result<...>>` shape as
344
- * {@link WorkflowContext.cancellableScope} for symmetry; the
345
- * `Result.Error` branch only triggers when cancellation is raised from
346
- * *inside* the scope, which is rare.
344
+ * Returns the same `ResultAsync<...>` shape as
345
+ * {@link WorkflowContext.cancellableScope} for symmetry; the `err(...)`
346
+ * branch only triggers when cancellation is raised from *inside* the
347
+ * scope, which is rare.
347
348
  */
348
- nonCancellableScope: <T>(fn: () => T | Promise<T>) => Future<Result<T, WorkflowCancelledError>>;
349
+ nonCancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError>;
349
350
  /**
350
351
  * Continue this workflow execution as a new run, optionally with a different
351
352
  * workflow type from another contract.
@@ -385,13 +386,13 @@ type TypedChildWorkflowOptions<TChildContract extends ContractDefinition, TChild
385
386
  args: ClientInferInput<TChildContract["workflows"][TChildWorkflowName]>;
386
387
  };
387
388
  /**
388
- * Typed handle for a child workflow with Future/Result pattern
389
+ * Typed handle for a child workflow with neverthrow ResultAsync pattern
389
390
  */
390
391
  type TypedChildWorkflowHandle<TWorkflow extends WorkflowDefinition> = {
391
392
  /**
392
393
  * Get child workflow result with Result pattern
393
394
  */
394
- result: () => Future<Result<ClientInferOutput<TWorkflow>, ChildWorkflowError>>;
395
+ result: () => ResultAsync<ClientInferOutput<TWorkflow>, ChildWorkflowError>;
395
396
  /**
396
397
  * Child workflow ID
397
398
  */
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.mts","names":[],"sources":["../src/handlers.ts","../src/internal.ts","../src/workflow.ts"],"mappings":";;;;;;;;;;;;AAkCA;KAAY,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;;;;;;;;KC2DnB,yBAAA,GAA4B,IAAA,CAAK,oBAAA;;;;;;;;;;;;;;;;;;;ADvE7C;;;;;;;;;;;;;;;;;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;AC6DA;;;;;;;;AC8BA;;;;;;iBAAgB,eAAA,mBACI,kBAAA,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