@temporal-contract/worker 2.3.1 → 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.
@@ -1,170 +1,174 @@
1
1
  import { summarizeIssues } from "@temporal-contract/contract";
2
+ import { ApplicationFailure, ChildWorkflowFailure } from "@temporalio/common";
3
+ import { TaggedError } from "unthrown";
2
4
  import { isCancellation, makeContinueAsNewFunc, proxyActivities } from "@temporalio/workflow";
3
- import { ChildWorkflowFailure } from "@temporalio/common";
4
- import { _internal_makeResultAsync as makeResultAsync } from "@temporal-contract/contract/result-async";
5
+ import { _internal_assertNoDefect as assertNoDefect, _internal_makeAsyncResult as makeAsyncResult } from "@temporal-contract/contract/result-async";
5
6
  //#region src/errors.ts
6
7
  /**
7
- * Base error class for worker errors
8
+ * Base class for the contract's runtime validation failures — workflow and
9
+ * activity input/output, plus signal/query/update payloads.
10
+ *
11
+ * These extend Temporal's {@link ApplicationFailure} with `nonRetryable: true`
12
+ * rather than a plain `Error`, and that distinction is load-bearing. The
13
+ * TypeScript SDK classifies a non-`TemporalFailure` thrown from *workflow* code
14
+ * as a Workflow Task failure — presumed to be a transient code bug or
15
+ * non-determinism — and retries the task indefinitely, leaving the execution
16
+ * silently `Running` forever (it looks like the worker "hung"). Only a
17
+ * `TemporalFailure` such as `ApplicationFailure` fails the Workflow Execution
18
+ * terminally. The same logic applies at the activity boundary, where Temporal's
19
+ * default retry policy has unlimited attempts: a plain `Error` would retry
20
+ * forever too.
21
+ *
22
+ * Contract validation failures are deterministic — the schema is static, so bad
23
+ * input/output never becomes valid on replay or retry — so they are surfaced as
24
+ * non-retryable, failing fast with a clear error instead of an infinite retry
25
+ * loop.
26
+ *
27
+ * The concrete subclass name is passed through as the failure `type`, so it
28
+ * stays discriminable after crossing Temporal's serialization boundary (where
29
+ * the JS class identity is lost) via `failure.type`. The failing field path is
30
+ * carried in the human-readable `message` (see {@link summarizeIssues}). The
31
+ * raw `issues` remain available as a property for in-process inspection.
32
+ *
33
+ * See issue #251.
8
34
  */
9
- var WorkerError = class extends Error {
10
- constructor(message, cause) {
11
- super(message, { cause });
12
- this.name = "WorkerError";
35
+ var ValidationError = class extends ApplicationFailure {
36
+ issues;
37
+ constructor(message, type, issues) {
38
+ super(message, type, true);
39
+ this.issues = issues;
40
+ Object.defineProperty(this, "name", {
41
+ value: type,
42
+ writable: true,
43
+ configurable: true,
44
+ enumerable: true
45
+ });
13
46
  if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
14
47
  }
15
48
  };
16
49
  /**
17
50
  * Error thrown when an activity definition is not found in the contract
18
51
  */
19
- var ActivityDefinitionNotFoundError = class extends WorkerError {
20
- activityName;
21
- availableDefinitions;
52
+ var ActivityDefinitionNotFoundError = class extends TaggedError("@temporal-contract/ActivityDefinitionNotFoundError", { name: "ActivityDefinitionNotFoundError" }) {
22
53
  constructor(activityName, availableDefinitions = []) {
23
54
  const available = availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none";
24
- super(`Activity definition not found for: "${activityName}". Available activities: ${available}`);
25
- this.activityName = activityName;
26
- this.availableDefinitions = availableDefinitions;
27
- this.name = "ActivityDefinitionNotFoundError";
55
+ super({
56
+ activityName,
57
+ availableDefinitions,
58
+ message: `Activity definition not found for: "${activityName}". Available activities: ${available}`
59
+ });
28
60
  }
29
61
  };
30
62
  /**
31
63
  * Error thrown when activity input validation fails
32
64
  */
33
- var ActivityInputValidationError = class extends WorkerError {
65
+ var ActivityInputValidationError = class extends ValidationError {
34
66
  activityName;
35
- issues;
36
67
  constructor(activityName, issues) {
37
68
  const message = summarizeIssues(issues);
38
- super(`Activity "${activityName}" input validation failed: ${message}`);
69
+ super(`Activity "${activityName}" input validation failed: ${message}`, "ActivityInputValidationError", issues);
39
70
  this.activityName = activityName;
40
- this.issues = issues;
41
- this.name = "ActivityInputValidationError";
42
71
  }
43
72
  };
44
73
  /**
45
74
  * Error thrown when activity output validation fails
46
75
  */
47
- var ActivityOutputValidationError = class extends WorkerError {
76
+ var ActivityOutputValidationError = class extends ValidationError {
48
77
  activityName;
49
- issues;
50
78
  constructor(activityName, issues) {
51
79
  const message = summarizeIssues(issues);
52
- super(`Activity "${activityName}" output validation failed: ${message}`);
80
+ super(`Activity "${activityName}" output validation failed: ${message}`, "ActivityOutputValidationError", issues);
53
81
  this.activityName = activityName;
54
- this.issues = issues;
55
- this.name = "ActivityOutputValidationError";
56
82
  }
57
83
  };
58
84
  /**
59
85
  * Error thrown when workflow input validation fails
60
86
  */
61
- var WorkflowInputValidationError = class extends WorkerError {
87
+ var WorkflowInputValidationError = class extends ValidationError {
62
88
  workflowName;
63
- issues;
64
89
  constructor(workflowName, issues) {
65
90
  const message = summarizeIssues(issues);
66
- super(`Workflow "${workflowName}" input validation failed: ${message}`);
91
+ super(`Workflow "${workflowName}" input validation failed: ${message}`, "WorkflowInputValidationError", issues);
67
92
  this.workflowName = workflowName;
68
- this.issues = issues;
69
- this.name = "WorkflowInputValidationError";
70
93
  }
71
94
  };
72
95
  /**
73
96
  * Error thrown when workflow output validation fails
74
97
  */
75
- var WorkflowOutputValidationError = class extends WorkerError {
98
+ var WorkflowOutputValidationError = class extends ValidationError {
76
99
  workflowName;
77
- issues;
78
100
  constructor(workflowName, issues) {
79
101
  const message = summarizeIssues(issues);
80
- super(`Workflow "${workflowName}" output validation failed: ${message}`);
102
+ super(`Workflow "${workflowName}" output validation failed: ${message}`, "WorkflowOutputValidationError", issues);
81
103
  this.workflowName = workflowName;
82
- this.issues = issues;
83
- this.name = "WorkflowOutputValidationError";
84
104
  }
85
105
  };
86
106
  /**
87
107
  * Error thrown when signal input validation fails
88
108
  */
89
- var SignalInputValidationError = class extends WorkerError {
109
+ var SignalInputValidationError = class extends ValidationError {
90
110
  signalName;
91
- issues;
92
111
  constructor(signalName, issues) {
93
112
  const message = summarizeIssues(issues);
94
- super(`Signal "${signalName}" input validation failed: ${message}`);
113
+ super(`Signal "${signalName}" input validation failed: ${message}`, "SignalInputValidationError", issues);
95
114
  this.signalName = signalName;
96
- this.issues = issues;
97
- this.name = "SignalInputValidationError";
98
115
  }
99
116
  };
100
117
  /**
101
118
  * Error thrown when query input validation fails
102
119
  */
103
- var QueryInputValidationError = class extends WorkerError {
120
+ var QueryInputValidationError = class extends ValidationError {
104
121
  queryName;
105
- issues;
106
122
  constructor(queryName, issues) {
107
123
  const message = summarizeIssues(issues);
108
- super(`Query "${queryName}" input validation failed: ${message}`);
124
+ super(`Query "${queryName}" input validation failed: ${message}`, "QueryInputValidationError", issues);
109
125
  this.queryName = queryName;
110
- this.issues = issues;
111
- this.name = "QueryInputValidationError";
112
126
  }
113
127
  };
114
128
  /**
115
129
  * Error thrown when query output validation fails
116
130
  */
117
- var QueryOutputValidationError = class extends WorkerError {
131
+ var QueryOutputValidationError = class extends ValidationError {
118
132
  queryName;
119
- issues;
120
133
  constructor(queryName, issues) {
121
134
  const message = summarizeIssues(issues);
122
- super(`Query "${queryName}" output validation failed: ${message}`);
135
+ super(`Query "${queryName}" output validation failed: ${message}`, "QueryOutputValidationError", issues);
123
136
  this.queryName = queryName;
124
- this.issues = issues;
125
- this.name = "QueryOutputValidationError";
126
137
  }
127
138
  };
128
139
  /**
129
140
  * Error thrown when update input validation fails
130
141
  */
131
- var UpdateInputValidationError = class extends WorkerError {
142
+ var UpdateInputValidationError = class extends ValidationError {
132
143
  updateName;
133
- issues;
134
144
  constructor(updateName, issues) {
135
145
  const message = summarizeIssues(issues);
136
- super(`Update "${updateName}" input validation failed: ${message}`);
146
+ super(`Update "${updateName}" input validation failed: ${message}`, "UpdateInputValidationError", issues);
137
147
  this.updateName = updateName;
138
- this.issues = issues;
139
- this.name = "UpdateInputValidationError";
140
148
  }
141
149
  };
142
150
  /**
143
151
  * Error thrown when update output validation fails
144
152
  */
145
- var UpdateOutputValidationError = class extends WorkerError {
153
+ var UpdateOutputValidationError = class extends ValidationError {
146
154
  updateName;
147
- issues;
148
155
  constructor(updateName, issues) {
149
156
  const message = summarizeIssues(issues);
150
- super(`Update "${updateName}" output validation failed: ${message}`);
157
+ super(`Update "${updateName}" output validation failed: ${message}`, "UpdateOutputValidationError", issues);
151
158
  this.updateName = updateName;
152
- this.issues = issues;
153
- this.name = "UpdateOutputValidationError";
154
159
  }
155
160
  };
156
161
  /**
157
162
  * Error thrown when a child workflow is not found in the contract
158
163
  */
159
- var ChildWorkflowNotFoundError = class extends WorkerError {
160
- workflowName;
161
- availableWorkflows;
164
+ var ChildWorkflowNotFoundError = class extends TaggedError("@temporal-contract/ChildWorkflowNotFoundError", { name: "ChildWorkflowNotFoundError" }) {
162
165
  constructor(workflowName, availableWorkflows = []) {
163
166
  const available = availableWorkflows.length > 0 ? availableWorkflows.join(", ") : "none";
164
- super(`Child workflow not found: "${workflowName}". Available workflows: ${available}`);
165
- this.workflowName = workflowName;
166
- this.availableWorkflows = availableWorkflows;
167
- this.name = "ChildWorkflowNotFoundError";
167
+ super({
168
+ workflowName,
169
+ availableWorkflows,
170
+ message: `Child workflow not found: "${workflowName}". Available workflows: ${available}`
171
+ });
168
172
  }
169
173
  };
170
174
  /**
@@ -176,86 +180,56 @@ var ChildWorkflowNotFoundError = class extends WorkerError {
176
180
  * mirroring the client-side `WorkflowFailedError.cause` behavior, so callers
177
181
  * can branch on the failure category in one step instead of unwrapping twice.
178
182
  */
179
- var ChildWorkflowError = class extends WorkerError {
183
+ var ChildWorkflowError = class extends TaggedError("@temporal-contract/ChildWorkflowError", { name: "ChildWorkflowError" }) {
180
184
  constructor(message, cause) {
181
- super(message, cause);
182
- this.name = "ChildWorkflowError";
185
+ super({
186
+ message,
187
+ cause
188
+ });
183
189
  }
184
190
  };
185
191
  /**
186
- * Discriminated variant of {@link ChildWorkflowError} surfaced when a child
187
- * workflow operation (start, execute, or wait-for-result) was cancelled —
188
- * either because the parent workflow itself was cancelled, the child was
189
- * explicitly cancelled, or its enclosing cancellation scope was. Detected via
190
- * `@temporalio/workflow`'s `isCancellation(...)`, which sees through nested
191
- * `ChildWorkflowFailure` / `CancelledFailure` chains.
192
+ * Discriminated variant surfaced when a child workflow operation (start,
193
+ * execute, or wait-for-result) was cancelled — either because the parent
194
+ * workflow itself was cancelled, the child was explicitly cancelled, or its
195
+ * enclosing cancellation scope was. Detected via `@temporalio/workflow`'s
196
+ * `isCancellation(...)`, which sees through nested `ChildWorkflowFailure` /
197
+ * `CancelledFailure` chains.
192
198
  *
193
- * Extends {@link ChildWorkflowError} so existing `instanceof ChildWorkflowError`
194
- * checks still match cancellation, while `instanceof ChildWorkflowCancelledError`
195
- * lets call sites narrow further when they need to branch on cancellation
196
- * explicitly without inspecting `error.cause` against a Temporal SDK class —
197
- * the worker-side analogue of the client-side cause-forwarding pattern.
199
+ * A sibling of {@link ChildWorkflowError} rather than a subclass: both are
200
+ * distinct {@link TaggedError}s, so call sites discriminate on the `_tag`
201
+ * (or `instanceof ChildWorkflowCancelledError`) instead of relying on an
202
+ * `instanceof ChildWorkflowError` that also matches cancellation. `matchTags`
203
+ * folds the `ChildWorkflowError | ChildWorkflowCancelledError` union
204
+ * exhaustively.
198
205
  */
199
- var ChildWorkflowCancelledError = class extends ChildWorkflowError {
200
- workflowName;
206
+ var ChildWorkflowCancelledError = class extends TaggedError("@temporal-contract/ChildWorkflowCancelledError", { name: "ChildWorkflowCancelledError" }) {
201
207
  constructor(workflowName, cause) {
202
- super(`Child workflow "${workflowName}" was cancelled`, cause);
203
- this.workflowName = workflowName;
204
- this.name = "ChildWorkflowCancelledError";
208
+ super({
209
+ workflowName,
210
+ cause,
211
+ message: `Child workflow "${workflowName}" was cancelled`
212
+ });
205
213
  }
206
214
  };
207
215
  /**
208
- * Error surfaced in the `err(...)` branch of a `ResultAsync` when a typed
216
+ * Error surfaced in the `err(...)` branch of an `AsyncResult` when a typed
209
217
  * cancellation scope is cancelled via Temporal's cancellation propagation.
210
218
  * Returned by both `context.cancellableScope` (when the workflow or an
211
219
  * ancestor scope cancels) and `context.nonCancellableScope` (when
212
220
  * cancellation is raised from inside the scope). Distinct from arbitrary
213
221
  * thrown errors so call sites can branch on cancellation explicitly.
214
222
  *
215
- * Non-cancellation errors thrown inside a scope surface as a sibling
216
- * {@link WorkflowScopeError} on the same `err(...)` channel, so callers can
217
- * use `instanceof` to discriminate without falling back to `try/catch`.
218
- */
219
- var WorkflowCancelledError = class extends WorkerError {
220
- constructor(cause) {
221
- super("Workflow cancellation scope was cancelled", cause);
222
- this.name = "WorkflowCancelledError";
223
- }
224
- };
225
- /**
226
- * Error surfaced in the `err(...)` branch of a `ResultAsync` when the
227
- * function passed to `cancellableScope` / `nonCancellableScope` throws a
228
- * non-cancellation error.
229
- *
230
- * The original error is preserved on `cause` so call sites can introspect
231
- * it without losing identity:
232
- *
233
- * @example
234
- * ```ts
235
- * const result = await context.cancellableScope(async () => {
236
- * return await context.activities.processStep(args);
237
- * });
238
- *
239
- * if (result.isErr()) {
240
- * if (result.error instanceof WorkflowCancelledError) {
241
- * // graceful cancellation
242
- * } else if (result.error instanceof WorkflowScopeError) {
243
- * // domain error — `result.error.cause` is the original throwable
244
- * }
245
- * }
246
- * ```
247
- *
248
- * Introduced so the scope helpers route every failure through neverthrow's
249
- * railway. Previously, non-cancellation errors were re-thrown out of the
250
- * helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`
251
- * does not catch) — they leaked as unhandled rejections rather than
252
- * surfacing on the typed error channel callers actually inspect.
223
+ * Non-cancellation errors thrown inside a scope are *unmodeled* failures: they
224
+ * surface on the scope's `defect` channel (re-thrown at the edge / inspectable
225
+ * via `result.isDefect()` and `result.cause`), not as a typed `err(...)`.
253
226
  */
254
- var WorkflowScopeError = class extends WorkerError {
227
+ var WorkflowCancelledError = class extends TaggedError("@temporal-contract/WorkflowCancelledError", { name: "WorkflowCancelledError" }) {
255
228
  constructor(cause) {
256
- const message = cause instanceof Error ? `Workflow cancellation scope caught a non-cancellation error: ${cause.message}` : "Workflow cancellation scope caught a non-cancellation error";
257
- super(message, cause);
258
- this.name = "WorkflowScopeError";
229
+ super({
230
+ cause,
231
+ message: "Workflow cancellation scope was cancelled"
232
+ });
259
233
  }
260
234
  };
261
235
  //#endregion
@@ -314,7 +288,7 @@ function buildRawActivitiesProxy(workflowActivities, contractActivities, default
314
288
  const defaultProxy = proxyActivities(defaultOptions);
315
289
  const overrideEntries = overrides ? Object.entries(overrides).filter((entry) => entry[1] !== void 0) : [];
316
290
  if (overrideEntries.length === 0) return defaultProxy;
317
- const declared = new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
291
+ const declared = /* @__PURE__ */ new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
318
292
  for (const [name] of overrideEntries) if (!declared.has(name)) throw new Error(`activityOptionsByName entry "${name}" does not match any declared activity. Available: ${[...declared].join(", ") || "none"}.`);
319
293
  const overriddenFns = {};
320
294
  for (const [name, override] of overrideEntries) {
@@ -450,6 +424,6 @@ function describeChildWorkflowOperation(operation, childWorkflowName) {
450
424
  }
451
425
  }
452
426
  //#endregion
453
- export { UpdateOutputValidationError as _, formatChildWorkflowValidationMessage as a, WorkflowOutputValidationError as b, ActivityInputValidationError as c, ChildWorkflowError as d, ChildWorkflowNotFoundError as f, UpdateInputValidationError as g, SignalInputValidationError as h, extractHandlerInput as i, ActivityOutputValidationError as l, QueryOutputValidationError as m, classifyChildWorkflowError as n, makeResultAsync as o, QueryInputValidationError as p, createContinueAsNew as r, ActivityDefinitionNotFoundError as s, buildRawActivitiesProxy as t, ChildWorkflowCancelledError as u, WorkflowCancelledError as v, WorkflowScopeError as x, WorkflowInputValidationError as y };
427
+ export { WorkflowOutputValidationError as S, UpdateInputValidationError as _, extractHandlerInput as a, WorkflowCancelledError as b, ActivityDefinitionNotFoundError as c, ChildWorkflowCancelledError as d, ChildWorkflowError as f, SignalInputValidationError as g, QueryOutputValidationError as h, createContinueAsNew as i, ActivityInputValidationError as l, QueryInputValidationError as m, buildRawActivitiesProxy as n, formatChildWorkflowValidationMessage as o, ChildWorkflowNotFoundError as p, classifyChildWorkflowError as r, makeAsyncResult as s, assertNoDefect as t, ActivityOutputValidationError as u, UpdateOutputValidationError as v, WorkflowInputValidationError as x, ValidationError as y };
454
428
 
455
- //# sourceMappingURL=internal-D8Dl9D43.mjs.map
429
+ //# sourceMappingURL=internal-DqYK4YQK.mjs.map
@@ -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;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