@temporal-contract/worker 2.4.0 → 3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-DqYK4YQK.mjs","names":[],"sources":["../src/errors.ts","../src/internal.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { summarizeIssues } from \"@temporal-contract/contract\";\nimport { ApplicationFailure } from \"@temporalio/common\";\nimport { TaggedError } from \"unthrown\";\n\n/**\n * Base class for the contract's runtime validation failures — workflow and\n * activity input/output, plus signal/query/update payloads.\n *\n * These extend Temporal's {@link ApplicationFailure} with `nonRetryable: true`\n * rather than a plain `Error`, and that distinction is load-bearing. The\n * TypeScript SDK classifies a non-`TemporalFailure` thrown from *workflow* code\n * as a Workflow Task failure — presumed to be a transient code bug or\n * non-determinism — and retries the task indefinitely, leaving the execution\n * silently `Running` forever (it looks like the worker \"hung\"). Only a\n * `TemporalFailure` such as `ApplicationFailure` fails the Workflow Execution\n * terminally. The same logic applies at the activity boundary, where Temporal's\n * default retry policy has unlimited attempts: a plain `Error` would retry\n * forever too.\n *\n * Contract validation failures are deterministic — the schema is static, so bad\n * input/output never becomes valid on replay or retry — so they are surfaced as\n * non-retryable, failing fast with a clear error instead of an infinite retry\n * loop.\n *\n * The concrete subclass name is passed through as the failure `type`, so it\n * stays discriminable after crossing Temporal's serialization boundary (where\n * the JS class identity is lost) via `failure.type`. The failing field path is\n * carried in the human-readable `message` (see {@link summarizeIssues}). The\n * raw `issues` remain available as a property for in-process inspection.\n *\n * See issue #251.\n */\nexport abstract class ValidationError extends ApplicationFailure {\n protected constructor(\n message: string,\n type: string,\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n // (message, type, nonRetryable) — terminal, deterministic failure.\n super(message, type, true);\n // `ApplicationFailure`'s `SymbolBasedInstanceOfError` decorator installs a\n // read-only `name` (\"ApplicationFailure\") on the prototype, so a plain\n // `this.name = type` assignment throws. Define an own property to shadow it\n // and surface the concrete subclass name (matching `type`). `writable: true`\n // keeps the field reassignable, matching the previous `this.name = ...`\n // behaviour so consumers (e.g. error-wrapping code) can still adjust it.\n Object.defineProperty(this, \"name\", {\n value: type,\n writable: true,\n configurable: true,\n enumerable: true,\n });\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 TaggedError(\n \"@temporal-contract/ActivityDefinitionNotFoundError\",\n { name: \"ActivityDefinitionNotFoundError\" },\n)<{\n activityName: string;\n availableDefinitions: readonly string[];\n message: string;\n}> {\n constructor(activityName: string, availableDefinitions: readonly string[] = []) {\n const available = availableDefinitions.length > 0 ? availableDefinitions.join(\", \") : \"none\";\n super({\n activityName,\n availableDefinitions,\n message: `Activity definition not found for: \"${activityName}\". Available activities: ${available}`,\n });\n }\n}\n\n/**\n * Error thrown when activity input validation fails\n */\nexport class ActivityInputValidationError extends ValidationError {\n constructor(\n public readonly activityName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Activity \"${activityName}\" input validation failed: ${message}`,\n \"ActivityInputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when activity output validation fails\n */\nexport class ActivityOutputValidationError extends ValidationError {\n constructor(\n public readonly activityName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Activity \"${activityName}\" output validation failed: ${message}`,\n \"ActivityOutputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when workflow input validation fails\n */\nexport class WorkflowInputValidationError extends ValidationError {\n constructor(\n public readonly workflowName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Workflow \"${workflowName}\" input validation failed: ${message}`,\n \"WorkflowInputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when workflow output validation fails\n */\nexport class WorkflowOutputValidationError extends ValidationError {\n constructor(\n public readonly workflowName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Workflow \"${workflowName}\" output validation failed: ${message}`,\n \"WorkflowOutputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when signal input validation fails\n */\nexport class SignalInputValidationError extends ValidationError {\n constructor(\n public readonly signalName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Signal \"${signalName}\" input validation failed: ${message}`,\n \"SignalInputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when query input validation fails\n */\nexport class QueryInputValidationError extends ValidationError {\n constructor(\n public readonly queryName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Query \"${queryName}\" input validation failed: ${message}`,\n \"QueryInputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when query output validation fails\n */\nexport class QueryOutputValidationError extends ValidationError {\n constructor(\n public readonly queryName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Query \"${queryName}\" output validation failed: ${message}`,\n \"QueryOutputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when update input validation fails\n */\nexport class UpdateInputValidationError extends ValidationError {\n constructor(\n public readonly updateName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Update \"${updateName}\" input validation failed: ${message}`,\n \"UpdateInputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when update output validation fails\n */\nexport class UpdateOutputValidationError extends ValidationError {\n constructor(\n public readonly updateName: string,\n issues: ReadonlyArray<StandardSchemaV1.Issue>,\n ) {\n const message = summarizeIssues(issues);\n super(\n `Update \"${updateName}\" output validation failed: ${message}`,\n \"UpdateOutputValidationError\",\n issues,\n );\n }\n}\n\n/**\n * Error thrown when a child workflow is not found in the contract\n */\nexport class ChildWorkflowNotFoundError extends TaggedError(\n \"@temporal-contract/ChildWorkflowNotFoundError\",\n { name: \"ChildWorkflowNotFoundError\" },\n)<{\n workflowName: string;\n availableWorkflows: readonly string[];\n message: string;\n}> {\n constructor(workflowName: string, availableWorkflows: readonly string[] = []) {\n const available = availableWorkflows.length > 0 ? availableWorkflows.join(\", \") : \"none\";\n super({\n workflowName,\n availableWorkflows,\n message: `Child workflow not found: \"${workflowName}\". Available workflows: ${available}`,\n });\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 TaggedError(\"@temporal-contract/ChildWorkflowError\", {\n name: \"ChildWorkflowError\",\n})<{\n message: string;\n cause?: unknown;\n}> {\n constructor(message: string, cause?: unknown) {\n super({ message, cause });\n }\n}\n\n/**\n * Discriminated variant surfaced when a child workflow operation (start,\n * execute, or wait-for-result) was cancelled — either because the parent\n * workflow itself was cancelled, the child was explicitly cancelled, or its\n * enclosing cancellation scope was. Detected via `@temporalio/workflow`'s\n * `isCancellation(...)`, which sees through nested `ChildWorkflowFailure` /\n * `CancelledFailure` chains.\n *\n * A sibling of {@link ChildWorkflowError} rather than a subclass: both are\n * distinct {@link TaggedError}s, so call sites discriminate on the `_tag`\n * (or `instanceof ChildWorkflowCancelledError`) instead of relying on an\n * `instanceof ChildWorkflowError` that also matches cancellation. `matchTags`\n * folds the `ChildWorkflowError | ChildWorkflowCancelledError` union\n * exhaustively.\n */\nexport class ChildWorkflowCancelledError extends TaggedError(\n \"@temporal-contract/ChildWorkflowCancelledError\",\n { name: \"ChildWorkflowCancelledError\" },\n)<{\n workflowName: string;\n cause?: unknown;\n message: string;\n}> {\n constructor(workflowName: string, cause?: unknown) {\n super({ workflowName, cause, message: `Child workflow \"${workflowName}\" was cancelled` });\n }\n}\n\n/**\n * Error surfaced in the `err(...)` branch of an `AsyncResult` 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 are *unmodeled* failures: they\n * surface on the scope's `defect` channel (re-thrown at the edge / inspectable\n * via `result.isDefect()` and `result.cause`), not as a typed `err(...)`.\n */\nexport class WorkflowCancelledError extends TaggedError(\n \"@temporal-contract/WorkflowCancelledError\",\n { name: \"WorkflowCancelledError\" },\n)<{\n cause?: unknown;\n message: string;\n}> {\n constructor(cause?: unknown) {\n super({ cause, message: \"Workflow cancellation scope was cancelled\" });\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 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_makeAsyncResult` 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. Unanticipated rejections\n// (a synchronous throw or a rejected promise from `work()`) are routed through\n// unthrown's `defect` channel rather than escaping as an unhandled rejection.\n// `assertNoDefect` narrows an internally-built `Result` (known to carry only\n// ok/err) to `Ok | Err`, re-throwing a stray defect's cause — so call sites\n// reach `.value` / `.error` without a manual \"impossible defect\" guard.\nexport {\n _internal_makeAsyncResult as makeAsyncResult,\n _internal_assertNoDefect as assertNoDefect,\n} 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 {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,kBAAtB,cAA8C,mBAAmB;CAI7C;CAHlB,YACE,SACA,MACA,QACA;EAEA,MAAM,SAAS,MAAM,IAAI;EAHT,KAAA,SAAA;EAUhB,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,cAAc;GACd,YAAY;EACd,CAAC;EAED,IAAI,MAAM,mBACR,MAAM,kBAAkB,MAAM,KAAK,WAAW;CAElD;AACF;;;;AAKA,IAAa,kCAAb,cAAqD,YACnD,sDACA,EAAE,MAAM,kCAAkC,CAC5C,CAAC,CAIE;CACD,YAAY,cAAsB,uBAA0C,CAAC,GAAG;EAC9E,MAAM,YAAY,qBAAqB,SAAS,IAAI,qBAAqB,KAAK,IAAI,IAAI;EACtF,MAAM;GACJ;GACA;GACA,SAAS,uCAAuC,aAAa,2BAA2B;EAC1F,CAAC;CACH;AACF;;;;AAKA,IAAa,+BAAb,cAAkD,gBAAgB;CAE9C;CADlB,YACE,cACA,QACA;EACA,MAAM,UAAU,gBAAgB,MAAM;EACtC,MACE,aAAa,aAAa,6BAA6B,WACvD,gCACA,MACF;EARgB,KAAA,eAAA;CASlB;AACF;;;;AAKA,IAAa,gCAAb,cAAmD,gBAAg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 -1,34 +1,33 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_internal = require("./internal-o5vk6e1H.cjs");
2
+ const require_internal = require("./internal-Clwokr1z.cjs");
3
+ let unthrown = require("unthrown");
3
4
  let _temporalio_workflow = require("@temporalio/workflow");
4
- let neverthrow = require("neverthrow");
5
5
  let _temporal_contract_contract_result_async = require("@temporal-contract/contract/result-async");
6
6
  //#region src/cancellation.ts
7
7
  /**
8
8
  * Typed wrappers around Temporal's `CancellationScope` so workflows can
9
9
  * opt into cancellation control without reaching for
10
10
  * `@temporalio/workflow` directly. The wrappers fold cancellation into
11
- * the same `ResultAsync<...>` shape used elsewhere in the worker
11
+ * the same `AsyncResult<...>` shape used elsewhere in the worker
12
12
  * context — callers branch on `err(WorkflowCancelledError)` instead of
13
13
  * catching `CancelledFailure`.
14
14
  *
15
- * Non-cancellation errors thrown inside the scope are wrapped in a
16
- * {@link WorkflowScopeError} (with the original error preserved on
17
- * `cause`) and surfaced on the same `err(...)` channel. Together with
18
- * `WorkflowCancelledError` this makes the failure modes exhaustive on
19
- * `result.match(...)` — nothing escapes as an unhandled rejection.
15
+ * Non-cancellation errors thrown inside the scope are *unmodeled* failures:
16
+ * they ride unthrown's `defect` channel (re-thrown at the edge / inspectable
17
+ * via `result.isDefect()` and `result.cause`) rather than a typed `err(...)`,
18
+ * keeping the modeled error channel to the single anticipated outcome
19
+ * cancellation.
20
20
  */
21
21
  /**
22
22
  * Run `fn` inside a cancellable Temporal scope. If the workflow (or an
23
23
  * ancestor scope) is cancelled while the function is in flight, the
24
- * resulting ResultAsync resolves to `err(WorkflowCancelledError)`,
24
+ * resulting AsyncResult resolves to `err(WorkflowCancelledError)`,
25
25
  * letting callers handle cancellation explicitly — typically to perform
26
26
  * a graceful exit from the current step.
27
27
  *
28
- * Non-cancellation errors thrown by `fn` resolve to
29
- * `err(WorkflowScopeError)` (with the original error on `cause`) so
30
- * domain failures surface on the same typed error channel rather than
31
- * leaking as unhandled rejections.
28
+ * Non-cancellation errors thrown by `fn` are unmodeled failures: they surface
29
+ * on the `defect` channel rather than as a typed `err(...)`, so a genuine bug
30
+ * is not silently treated as an anticipated domain outcome.
32
31
  *
33
32
  * @example
34
33
  * ```ts
@@ -36,28 +35,27 @@ let _temporal_contract_contract_result_async = require("@temporal-contract/contr
36
35
  * return await context.activities.processStep(...);
37
36
  * });
38
37
  *
39
- * result.match(
40
- * (output) => { ... },
41
- * (error) => {
42
- * if (error instanceof WorkflowCancelledError) {
43
- * // graceful exit
44
- * } else {
45
- * // error instanceof WorkflowScopeError domain failure on `cause`
46
- * }
38
+ * result.match({
39
+ * ok: (output) => { ... },
40
+ * err: (error) => {
41
+ * // error instanceof WorkflowCancelledError — graceful exit
42
+ * },
43
+ * defect: (cause) => {
44
+ * // a non-cancellation failure thrown inside the scope (a bug)
47
45
  * },
48
- * );
46
+ * });
49
47
  * ```
50
48
  */
51
49
  function cancellableScope(fn) {
52
50
  const work = async () => {
53
51
  try {
54
- return (0, neverthrow.ok)(await _temporalio_workflow.CancellationScope.cancellable(async () => fn()));
52
+ return (0, unthrown.ok)(await _temporalio_workflow.CancellationScope.cancellable(async () => fn()));
55
53
  } catch (error) {
56
- if ((0, _temporalio_workflow.isCancellation)(error)) return (0, neverthrow.err)(new require_internal.WorkflowCancelledError(error));
57
- return (0, neverthrow.err)(new require_internal.WorkflowScopeError(error));
54
+ if ((0, _temporalio_workflow.isCancellation)(error)) return (0, unthrown.err)(new require_internal.WorkflowCancelledError(error));
55
+ throw error;
58
56
  }
59
57
  };
60
- return (0, _temporal_contract_contract_result_async._internal_makeResultAsync)(work, (e) => new require_internal.WorkflowScopeError(e));
58
+ return (0, _temporal_contract_contract_result_async._internal_makeAsyncResult)(work);
61
59
  }
62
60
  /**
63
61
  * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests
@@ -65,10 +63,10 @@ function cancellableScope(fn) {
65
63
  * to perform cleanup that must not be interrupted (e.g. releasing a
66
64
  * resource after a graceful shutdown).
67
65
  *
68
- * Mirrors `cancellableScope`'s `ResultAsync<...>` shape for symmetry; the
66
+ * Mirrors `cancellableScope`'s `AsyncResult<...>` shape for symmetry; the
69
67
  * `err(WorkflowCancelledError)` branch only triggers when cancellation is
70
- * raised from inside the scope (rare). Non-cancellation errors surface as
71
- * `err(WorkflowScopeError)`.
68
+ * raised from inside the scope (rare). Non-cancellation errors surface on the
69
+ * `defect` channel.
72
70
  *
73
71
  * @example
74
72
  * ```ts
@@ -80,13 +78,13 @@ function cancellableScope(fn) {
80
78
  function nonCancellableScope(fn) {
81
79
  const work = async () => {
82
80
  try {
83
- return (0, neverthrow.ok)(await _temporalio_workflow.CancellationScope.nonCancellable(async () => fn()));
81
+ return (0, unthrown.ok)(await _temporalio_workflow.CancellationScope.nonCancellable(async () => fn()));
84
82
  } catch (error) {
85
- if ((0, _temporalio_workflow.isCancellation)(error)) return (0, neverthrow.err)(new require_internal.WorkflowCancelledError(error));
86
- return (0, neverthrow.err)(new require_internal.WorkflowScopeError(error));
83
+ if ((0, _temporalio_workflow.isCancellation)(error)) return (0, unthrown.err)(new require_internal.WorkflowCancelledError(error));
84
+ throw error;
87
85
  }
88
86
  };
89
- return (0, _temporal_contract_contract_result_async._internal_makeResultAsync)(work, (e) => new require_internal.WorkflowScopeError(e));
87
+ return (0, _temporal_contract_contract_result_async._internal_makeAsyncResult)(work);
90
88
  }
91
89
  //#endregion
92
90
  //#region src/handlers.ts
@@ -187,16 +185,16 @@ function bindUpdateHandler(workflowDefinition, workflowName, updateName, handler
187
185
  //#region src/child-workflow.ts
188
186
  async function validateChildWorkflowOutput(childDefinition, result, childWorkflowName) {
189
187
  const outputResult = await childDefinition.output["~standard"].validate(result);
190
- if (outputResult.issues) return (0, neverthrow.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "output", outputResult.issues)));
191
- return (0, neverthrow.ok)(outputResult.value);
188
+ if (outputResult.issues) return (0, unthrown.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "output", outputResult.issues)));
189
+ return (0, unthrown.ok)(outputResult.value);
192
190
  }
193
191
  async function getAndValidateChildWorkflow(childContract, childWorkflowName, args) {
194
192
  const childDefinition = childContract.workflows[childWorkflowName];
195
- if (!childDefinition) return (0, neverthrow.err)(new require_internal.ChildWorkflowNotFoundError(childWorkflowName, Object.keys(childContract.workflows)));
193
+ if (!childDefinition) return (0, unthrown.err)(new require_internal.ChildWorkflowNotFoundError(childWorkflowName, Object.keys(childContract.workflows)));
196
194
  const inputResult = await childDefinition.input["~standard"].validate(args);
197
- if (inputResult.issues) return (0, neverthrow.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "input", inputResult.issues)));
195
+ if (inputResult.issues) return (0, unthrown.err)(new require_internal.ChildWorkflowError(require_internal.formatChildWorkflowValidationMessage(childWorkflowName, "input", inputResult.issues)));
198
196
  const validatedInput = inputResult.value;
199
- return (0, neverthrow.ok)({
197
+ return (0, unthrown.ok)({
200
198
  definition: childDefinition,
201
199
  validatedInput,
202
200
  taskQueue: childContract.taskQueue
@@ -210,35 +208,37 @@ function createTypedChildHandle(handle, childDefinition, childWorkflowName) {
210
208
  try {
211
209
  return validateChildWorkflowOutput(childDefinition, await handle.result(), childWorkflowName);
212
210
  } catch (error) {
213
- return (0, neverthrow.err)(require_internal.classifyChildWorkflowError("result", error, childWorkflowName));
211
+ return (0, unthrown.err)(require_internal.classifyChildWorkflowError("result", error, childWorkflowName));
214
212
  }
215
213
  };
216
- return (0, _temporal_contract_contract_result_async._internal_makeResultAsync)(work, (error) => new require_internal.ChildWorkflowError(`Child workflow execution failed: ${error instanceof Error ? error.message : String(error)}`, error));
214
+ return (0, _temporal_contract_contract_result_async._internal_makeAsyncResult)(work);
217
215
  }
218
216
  };
219
217
  }
220
218
  function createStartChildWorkflow(childContract, childWorkflowName, options) {
221
219
  const work = async () => {
222
220
  const validationResult = await getAndValidateChildWorkflow(childContract, childWorkflowName, options.args);
223
- if (validationResult.isErr()) return (0, neverthrow.err)(validationResult.error);
221
+ (0, _temporal_contract_contract_result_async._internal_assertNoDefect)(validationResult);
222
+ if (validationResult.isErr()) return (0, unthrown.err)(validationResult.error);
224
223
  const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;
225
224
  try {
226
225
  const { args: _args, ...temporalOptions } = options;
227
- return (0, neverthrow.ok)(createTypedChildHandle(await (0, _temporalio_workflow.startChild)(childWorkflowName, {
226
+ return (0, unthrown.ok)(createTypedChildHandle(await (0, _temporalio_workflow.startChild)(childWorkflowName, {
228
227
  ...temporalOptions,
229
228
  taskQueue,
230
229
  args: [validatedInput]
231
230
  }), childDefinition, childWorkflowName));
232
231
  } catch (error) {
233
- return (0, neverthrow.err)(require_internal.classifyChildWorkflowError("startChild", error, String(childWorkflowName)));
232
+ return (0, unthrown.err)(require_internal.classifyChildWorkflowError("startChild", error, String(childWorkflowName)));
234
233
  }
235
234
  };
236
- return (0, _temporal_contract_contract_result_async._internal_makeResultAsync)(work, (error) => new require_internal.ChildWorkflowError(`Failed to start child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
235
+ return (0, _temporal_contract_contract_result_async._internal_makeAsyncResult)(work);
237
236
  }
238
237
  function createExecuteChildWorkflow(childContract, childWorkflowName, options) {
239
238
  const work = async () => {
240
239
  const validationResult = await getAndValidateChildWorkflow(childContract, childWorkflowName, options.args);
241
- if (validationResult.isErr()) return (0, neverthrow.err)(validationResult.error);
240
+ (0, _temporal_contract_contract_result_async._internal_assertNoDefect)(validationResult);
241
+ if (validationResult.isErr()) return (0, unthrown.err)(validationResult.error);
242
242
  const { definition: childDefinition, validatedInput, taskQueue } = validationResult.value;
243
243
  try {
244
244
  const { args: _args, ...temporalOptions } = options;
@@ -247,13 +247,14 @@ function createExecuteChildWorkflow(childContract, childWorkflowName, options) {
247
247
  taskQueue,
248
248
  args: [validatedInput]
249
249
  }), childWorkflowName);
250
- if (outputValidationResult.isErr()) return (0, neverthrow.err)(outputValidationResult.error);
251
- return (0, neverthrow.ok)(outputValidationResult.value);
250
+ (0, _temporal_contract_contract_result_async._internal_assertNoDefect)(outputValidationResult);
251
+ if (outputValidationResult.isErr()) return (0, unthrown.err)(outputValidationResult.error);
252
+ return (0, unthrown.ok)(outputValidationResult.value);
252
253
  } catch (error) {
253
- return (0, neverthrow.err)(require_internal.classifyChildWorkflowError("executeChild", error, String(childWorkflowName)));
254
+ return (0, unthrown.err)(require_internal.classifyChildWorkflowError("executeChild", error, String(childWorkflowName)));
254
255
  }
255
256
  };
256
- return (0, _temporal_contract_contract_result_async._internal_makeResultAsync)(work, (error) => new require_internal.ChildWorkflowError(`Failed to execute child workflow: ${error instanceof Error ? error.message : String(error)}`, error));
257
+ return (0, _temporal_contract_contract_result_async._internal_makeAsyncResult)(work);
257
258
  }
258
259
  //#endregion
259
260
  //#region src/activities-proxy.ts
@@ -411,5 +412,4 @@ exports.ValidationError = require_internal.ValidationError;
411
412
  exports.WorkflowCancelledError = require_internal.WorkflowCancelledError;
412
413
  exports.WorkflowInputValidationError = require_internal.WorkflowInputValidationError;
413
414
  exports.WorkflowOutputValidationError = require_internal.WorkflowOutputValidationError;
414
- exports.WorkflowScopeError = require_internal.WorkflowScopeError;
415
415
  exports.declareWorkflow = declareWorkflow;
@@ -1,6 +1,6 @@
1
- import { _ as ClientInferInput, a as ChildWorkflowError, b as WorkerInferOutput, c as QueryOutputValidationError, d as UpdateOutputValidationError, f as ValidationError, g as WorkflowScopeError, h as WorkflowOutputValidationError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowInputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowCancelledError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as ClientInferOutput, y as WorkerInferInput } from "./errors-CE56feY1.cjs";
1
+ import { _ as ClientInferOutput, a as ChildWorkflowError, c as QueryOutputValidationError, d as UpdateOutputValidationError, f as ValidationError, g as ClientInferInput, h as WorkflowOutputValidationError, i as ChildWorkflowCancelledError, l as SignalInputValidationError, m as WorkflowInputValidationError, n as ActivityInputValidationError, o as ChildWorkflowNotFoundError, p as WorkflowCancelledError, r as ActivityOutputValidationError, s as QueryInputValidationError, u as UpdateInputValidationError, v as WorkerInferInput, y as WorkerInferOutput } from "./errors-BNnNzSwE.cjs";
2
2
  import { ActivityDefinition, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, QueryNamesOf, SignalDefinition, SignalNamesOf, UpdateDefinition, UpdateNamesOf } from "@temporal-contract/contract";
3
- import { ResultAsync } from "neverthrow";
3
+ import { AsyncResult } from "unthrown";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
  import { ActivityOptions, ChildWorkflowOptions, ContinueAsNewOptions, WorkflowInfo } from "@temporalio/workflow";
6
6
  //#region src/handlers.d.ts
@@ -44,13 +44,13 @@ type TypedChildWorkflowOptions<TChildContract extends ContractDefinition, TChild
44
44
  args: ClientInferInput<TChildContract["workflows"][TChildWorkflowName]>;
45
45
  };
46
46
  /**
47
- * Typed handle for a child workflow with neverthrow `ResultAsync` pattern.
47
+ * Typed handle for a child workflow with unthrown `AsyncResult` pattern.
48
48
  */
49
49
  type TypedChildWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {
50
50
  /**
51
- * Get child workflow result with `ResultAsync` pattern.
51
+ * Get child workflow result with `AsyncResult` pattern.
52
52
  */
53
- result: () => ResultAsync<ClientInferOutput<TWorkflow>, ChildWorkflowError | ChildWorkflowCancelledError>;
53
+ result: () => AsyncResult<ClientInferOutput<TWorkflow>, ChildWorkflowError | ChildWorkflowCancelledError>;
54
54
  /**
55
55
  * Child workflow ID.
56
56
  */
@@ -312,7 +312,7 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
312
312
  */
313
313
  defineUpdate: <K extends UpdateNamesOf<TContract["workflows"][TWorkflowName]>>(updateName: K, handler: UpdateHandlerImplementation<NonNullable<TContract["workflows"][TWorkflowName]["updates"]> extends Record<string, UpdateDefinition> ? NonNullable<TContract["workflows"][TWorkflowName]["updates"]>[K] extends UpdateDefinition ? NonNullable<TContract["workflows"][TWorkflowName]["updates"]>[K] : never : never>) => void;
314
314
  /**
315
- * Start a child workflow and return a typed handle with ResultAsync pattern
315
+ * Start a child workflow and return a typed handle with AsyncResult pattern
316
316
  *
317
317
  * Supports both same-contract and cross-contract child workflows:
318
318
  * - Same contract: Pass workflowName from current contract
@@ -332,18 +332,19 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
332
332
  * args: { message: 'Hello' }
333
333
  * });
334
334
  *
335
- * childResult.match(
336
- * async (handle) => {
335
+ * await childResult.match({
336
+ * ok: async (handle) => {
337
337
  * const result = await handle.result();
338
338
  * // ... handle result
339
339
  * },
340
- * (error) => console.error('Failed to start:', error),
341
- * );
340
+ * err: (error) => console.error('Failed to start:', error),
341
+ * defect: (cause) => console.error('Unexpected failure:', cause),
342
+ * });
342
343
  * ```
343
344
  */
344
- startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"] & string>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>;
345
+ startChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"] & string>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => AsyncResult<TypedChildWorkflowHandle<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>;
345
346
  /**
346
- * Execute a child workflow (start and wait for result) with ResultAsync pattern
347
+ * Execute a child workflow (start and wait for result) with AsyncResult pattern
347
348
  *
348
349
  * Supports both same-contract and cross-contract child workflows:
349
350
  * - Same contract: Pass workflowName from current contract
@@ -363,62 +364,59 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
363
364
  * args: { message: 'Hello' }
364
365
  * });
365
366
  *
366
- * result.match(
367
- * (output) => console.log('Payment processed:', output),
368
- * (error) => console.error('Processing failed:', error),
369
- * );
367
+ * await result.match({
368
+ * ok: (output) => console.log('Payment processed:', output),
369
+ * err: (error) => console.error('Processing failed:', error),
370
+ * defect: (cause) => console.error('Unexpected failure:', cause),
371
+ * });
370
372
  * ```
371
373
  */
372
- executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"] & string>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => ResultAsync<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>;
374
+ executeChildWorkflow: <TChildContract extends ContractDefinition, TChildWorkflowName extends keyof TChildContract["workflows"] & string>(contract: TChildContract, workflowName: TChildWorkflowName, options: TypedChildWorkflowOptions<TChildContract, TChildWorkflowName>) => AsyncResult<ClientInferOutput<TChildContract["workflows"][TChildWorkflowName]>, ChildWorkflowError | ChildWorkflowCancelledError | ChildWorkflowNotFoundError>;
373
375
  /**
374
376
  * Run `fn` inside a cancellable Temporal scope. If the workflow (or an
375
377
  * ancestor scope) is cancelled while `fn` is in flight, the resulting
376
- * ResultAsync resolves to `err(WorkflowCancelledError)` instead of
378
+ * AsyncResult resolves to `err(WorkflowCancelledError)` instead of
377
379
  * rejecting — letting callers handle cancellation explicitly, typically
378
380
  * to perform a graceful exit from the current step.
379
381
  *
380
- * Non-cancellation errors thrown by `fn` resolve to
381
- * `err(WorkflowScopeError)` (with the original error preserved on
382
- * `cause`). Both failure modes ride neverthrow's railway, so
383
- * `result.match(...)` is exhaustive nothing escapes as an unhandled
384
- * rejection.
382
+ * Non-cancellation errors thrown by `fn` are *unmodeled* failures: they ride
383
+ * unthrown's `defect` channel (inspectable via `result.isDefect()` /
384
+ * `result.cause`, re-thrown at the edge), keeping the modeled error channel
385
+ * to the single anticipated outcome cancellation.
385
386
  *
386
387
  * @example
387
388
  * ```ts
389
+ *
388
390
  * implementation: async (context, args) => {
389
391
  * const result = await context.cancellableScope(async () => {
390
392
  * return context.activities.processStep(args);
391
393
  * });
392
394
  *
393
- * if (result.isErr()) {
394
- * if (result.error instanceof WorkflowCancelledError) {
395
- * // workflow was cancelled — perform cleanup that must not be cancelled:
396
- * await context.nonCancellableScope(async () => {
397
- * await context.activities.releaseResources(args);
398
- * });
399
- * return { status: "cancelled" };
400
- * }
401
- * // result.error instanceof WorkflowScopeError — domain failure
402
- * return { status: "failed" };
395
+ * if (result.isErr() && result.error instanceof WorkflowCancelledError) {
396
+ * // workflow was cancelled — perform cleanup that must not be cancelled:
397
+ * await context.nonCancellableScope(async () => {
398
+ * await context.activities.releaseResources(args);
399
+ * });
400
+ * return { status: "cancelled" };
403
401
  * }
404
402
  *
405
403
  * return { status: "ok" };
406
404
  * }
407
405
  * ```
408
406
  */
409
- cancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;
407
+ cancellableScope: <T>(fn: () => T | Promise<T>) => AsyncResult<T, WorkflowCancelledError>;
410
408
  /**
411
409
  * Run `fn` inside a non-cancellable Temporal scope. Cancellation requests
412
410
  * from outside the scope are ignored for its duration — the idiomatic way
413
411
  * to perform cleanup work that must not be interrupted.
414
412
  *
415
- * Returns the same `ResultAsync<...>` shape as
413
+ * Returns the same `AsyncResult<...>` shape as
416
414
  * {@link WorkflowContext.cancellableScope} for symmetry; the
417
415
  * `err(WorkflowCancelledError)` branch only triggers when cancellation is
418
416
  * raised from *inside* the scope, which is rare. Non-cancellation errors
419
- * surface as `err(WorkflowScopeError)`.
417
+ * surface on the `defect` channel.
420
418
  */
421
- nonCancellableScope: <T>(fn: () => T | Promise<T>) => ResultAsync<T, WorkflowCancelledError | WorkflowScopeError>;
419
+ nonCancellableScope: <T>(fn: () => T | Promise<T>) => AsyncResult<T, WorkflowCancelledError>;
422
420
  /**
423
421
  * Continue this workflow execution as a new run, optionally with a different
424
422
  * workflow type from another contract.
@@ -452,5 +450,5 @@ type WorkflowContext<TContract extends ContractDefinition, TWorkflowName extends
452
450
  };
453
451
  }; //# sourceMappingURL=workflow.d.ts.map
454
452
  //#endregion
455
- export { ActivityInputValidationError, ActivityOutputValidationError, ChildWorkflowCancelledError, ChildWorkflowError, ChildWorkflowNotFoundError, QueryInputValidationError, QueryOutputValidationError, SignalInputValidationError, UpdateInputValidationError, UpdateOutputValidationError, ValidationError, WorkflowCancelledError, WorkflowInputValidationError, WorkflowOutputValidationError, WorkflowScopeError, declareWorkflow };
453
+ export { ActivityInputValidationError, ActivityOutputValidationError, ChildWorkflowCancelledError, ChildWorkflowError, ChildWorkflowNotFoundError, QueryInputValidationError, QueryOutputValidationError, SignalInputValidationError, UpdateInputValidationError, UpdateOutputValidationError, ValidationError, WorkflowCancelledError, WorkflowInputValidationError, WorkflowOutputValidationError, declareWorkflow };
456
454
  //# sourceMappingURL=workflow.d.cts.map
@@ -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,IAAI,CAAC,oBAAA;;;;;;;;KChHjC,yBAAA,wBACa,kB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AAA;EAxP7C;;;;;;;;AACoE;AAAA;;EAoQpE,mBAAA,MACE,EAAA,QAAU,CAAA,GAAI,OAAA,CAAQ,CAAA,MACnB,WAAA,CAAY,CAAA,EAAG,sBAAA,GAAyB,kBAAA;EA3P3B;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwRlB,aAAA;IAnR6B,8EAsRzB,IAAA,EAAM,gBAAA,CAAiB,SAAA,cAAuB,aAAA,IAC9C,OAAA,GAAU,yBAAA,GACT,OAAA,SAxR4D;IAAA,wBA2RtC,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.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;;;;;;;;KC0FnB,yBAAA,GAA4B,IAAI,CAAC,oBAAA;;;;;;;;KCnHjC,yBAAA,wBACa,kBAAA,mCACU,cAAA,0BAC/B,IAAA,CAAK,oBAAA;EACP,IAAA,EAAM,gBAAA,CAAiB,cAAA,cAA4B,kBAAA;AAAA;;;;KAMzC,wBAAA,mBAA2C,qBAAA;EFL3C;;AAAO;EESjB,MAAA,QAAc,WAAA,CACZ,iBAAA,CAAkB,SAAA,GAClB,kBAAA,GAAqB,2BAAA;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