@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.
- package/README.md +7 -7
- package/dist/activity.cjs +21 -13
- package/dist/activity.d.cts +14 -12
- package/dist/activity.d.cts.map +1 -1
- package/dist/activity.d.mts +14 -12
- package/dist/activity.d.mts.map +1 -1
- package/dist/activity.mjs +21 -13
- package/dist/activity.mjs.map +1 -1
- package/dist/{errors-CE56feY1.d.cts → errors-BNnNzSwE.d.cts} +48 -67
- package/dist/errors-BNnNzSwE.d.cts.map +1 -0
- package/dist/{errors-CE56feY1.d.mts → errors-BNnNzSwE.d.mts} +48 -67
- package/dist/errors-BNnNzSwE.d.mts.map +1 -0
- package/dist/{internal-o5vk6e1H.cjs → internal-Clwokr1z.cjs} +46 -93
- package/dist/{internal-D0wfFl0y.mjs → internal-DqYK4YQK.mjs} +49 -90
- package/dist/internal-DqYK4YQK.mjs.map +1 -0
- package/dist/workflow.cjs +50 -50
- package/dist/workflow.d.cts +36 -38
- package/dist/workflow.d.cts.map +1 -1
- package/dist/workflow.d.mts +36 -38
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +34 -33
- package/dist/workflow.mjs.map +1 -1
- package/package.json +13 -12
- package/dist/errors-CE56feY1.d.cts.map +0 -1
- package/dist/errors-CE56feY1.d.mts.map +0 -1
- package/dist/internal-D0wfFl0y.mjs.map +0 -1
|
@@ -33,12 +33,6 @@ type ClientInferOutput<T extends {
|
|
|
33
33
|
}> = StandardSchemaV1.InferOutput<T["output"]>;
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/errors.d.ts
|
|
36
|
-
/**
|
|
37
|
-
* Base error class for worker errors
|
|
38
|
-
*/
|
|
39
|
-
declare abstract class WorkerError extends Error {
|
|
40
|
-
protected constructor(message: string, cause?: unknown);
|
|
41
|
-
}
|
|
42
36
|
/**
|
|
43
37
|
* Base class for the contract's runtime validation failures — workflow and
|
|
44
38
|
* activity input/output, plus signal/query/update payloads.
|
|
@@ -71,12 +65,15 @@ declare abstract class ValidationError extends ApplicationFailure {
|
|
|
71
65
|
readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
72
66
|
protected constructor(message: string, type: string, issues: ReadonlyArray<StandardSchemaV1.Issue>);
|
|
73
67
|
}
|
|
68
|
+
declare const ActivityDefinitionNotFoundError_base: import("unthrown").TaggedErrorConstructor<"@temporal-contract/ActivityDefinitionNotFoundError">;
|
|
74
69
|
/**
|
|
75
70
|
* Error thrown when an activity definition is not found in the contract
|
|
76
71
|
*/
|
|
77
|
-
declare class ActivityDefinitionNotFoundError extends
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
declare class ActivityDefinitionNotFoundError extends ActivityDefinitionNotFoundError_base<{
|
|
73
|
+
activityName: string;
|
|
74
|
+
availableDefinitions: readonly string[];
|
|
75
|
+
message: string;
|
|
76
|
+
}> {
|
|
80
77
|
constructor(activityName: string, availableDefinitions?: readonly string[]);
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
@@ -142,14 +139,18 @@ declare class UpdateOutputValidationError extends ValidationError {
|
|
|
142
139
|
readonly updateName: string;
|
|
143
140
|
constructor(updateName: string, issues: ReadonlyArray<StandardSchemaV1.Issue>);
|
|
144
141
|
}
|
|
142
|
+
declare const ChildWorkflowNotFoundError_base: import("unthrown").TaggedErrorConstructor<"@temporal-contract/ChildWorkflowNotFoundError">;
|
|
145
143
|
/**
|
|
146
144
|
* Error thrown when a child workflow is not found in the contract
|
|
147
145
|
*/
|
|
148
|
-
declare class ChildWorkflowNotFoundError extends
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
declare class ChildWorkflowNotFoundError extends ChildWorkflowNotFoundError_base<{
|
|
147
|
+
workflowName: string;
|
|
148
|
+
availableWorkflows: readonly string[];
|
|
149
|
+
message: string;
|
|
150
|
+
}> {
|
|
151
151
|
constructor(workflowName: string, availableWorkflows?: readonly string[]);
|
|
152
152
|
}
|
|
153
|
+
declare const ChildWorkflowError_base: import("unthrown").TaggedErrorConstructor<"@temporal-contract/ChildWorkflowError">;
|
|
153
154
|
/**
|
|
154
155
|
* Generic error for child workflow operations.
|
|
155
156
|
*
|
|
@@ -159,74 +160,54 @@ declare class ChildWorkflowNotFoundError extends WorkerError {
|
|
|
159
160
|
* mirroring the client-side `WorkflowFailedError.cause` behavior, so callers
|
|
160
161
|
* can branch on the failure category in one step instead of unwrapping twice.
|
|
161
162
|
*/
|
|
162
|
-
declare class ChildWorkflowError extends
|
|
163
|
+
declare class ChildWorkflowError extends ChildWorkflowError_base<{
|
|
164
|
+
message: string;
|
|
165
|
+
cause?: unknown;
|
|
166
|
+
}> {
|
|
163
167
|
constructor(message: string, cause?: unknown);
|
|
164
168
|
}
|
|
169
|
+
declare const ChildWorkflowCancelledError_base: import("unthrown").TaggedErrorConstructor<"@temporal-contract/ChildWorkflowCancelledError">;
|
|
165
170
|
/**
|
|
166
|
-
* Discriminated variant
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* `
|
|
171
|
+
* Discriminated variant surfaced when a child workflow operation (start,
|
|
172
|
+
* execute, or wait-for-result) was cancelled — either because the parent
|
|
173
|
+
* workflow itself was cancelled, the child was explicitly cancelled, or its
|
|
174
|
+
* enclosing cancellation scope was. Detected via `@temporalio/workflow`'s
|
|
175
|
+
* `isCancellation(...)`, which sees through nested `ChildWorkflowFailure` /
|
|
176
|
+
* `CancelledFailure` chains.
|
|
172
177
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* the
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
* A sibling of {@link ChildWorkflowError} rather than a subclass: both are
|
|
179
|
+
* distinct {@link TaggedError}s, so call sites discriminate on the `_tag`
|
|
180
|
+
* (or `instanceof ChildWorkflowCancelledError`) instead of relying on an
|
|
181
|
+
* `instanceof ChildWorkflowError` that also matches cancellation. `matchTags`
|
|
182
|
+
* folds the `ChildWorkflowError | ChildWorkflowCancelledError` union
|
|
183
|
+
* exhaustively.
|
|
184
|
+
*/
|
|
185
|
+
declare class ChildWorkflowCancelledError extends ChildWorkflowCancelledError_base<{
|
|
186
|
+
workflowName: string;
|
|
187
|
+
cause?: unknown;
|
|
188
|
+
message: string;
|
|
189
|
+
}> {
|
|
181
190
|
constructor(workflowName: string, cause?: unknown);
|
|
182
191
|
}
|
|
192
|
+
declare const WorkflowCancelledError_base: import("unthrown").TaggedErrorConstructor<"@temporal-contract/WorkflowCancelledError">;
|
|
183
193
|
/**
|
|
184
|
-
* Error surfaced in the `err(...)` branch of
|
|
194
|
+
* Error surfaced in the `err(...)` branch of an `AsyncResult` when a typed
|
|
185
195
|
* cancellation scope is cancelled via Temporal's cancellation propagation.
|
|
186
196
|
* Returned by both `context.cancellableScope` (when the workflow or an
|
|
187
197
|
* ancestor scope cancels) and `context.nonCancellableScope` (when
|
|
188
198
|
* cancellation is raised from inside the scope). Distinct from arbitrary
|
|
189
199
|
* thrown errors so call sites can branch on cancellation explicitly.
|
|
190
200
|
*
|
|
191
|
-
* Non-cancellation errors thrown inside a scope
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*/
|
|
195
|
-
declare class WorkflowCancelledError extends
|
|
201
|
+
* Non-cancellation errors thrown inside a scope are *unmodeled* failures: they
|
|
202
|
+
* surface on the scope's `defect` channel (re-thrown at the edge / inspectable
|
|
203
|
+
* via `result.isDefect()` and `result.cause`), not as a typed `err(...)`.
|
|
204
|
+
*/
|
|
205
|
+
declare class WorkflowCancelledError extends WorkflowCancelledError_base<{
|
|
206
|
+
cause?: unknown;
|
|
207
|
+
message: string;
|
|
208
|
+
}> {
|
|
196
209
|
constructor(cause?: unknown);
|
|
197
210
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Error surfaced in the `err(...)` branch of a `ResultAsync` when the
|
|
200
|
-
* function passed to `cancellableScope` / `nonCancellableScope` throws a
|
|
201
|
-
* non-cancellation error.
|
|
202
|
-
*
|
|
203
|
-
* The original error is preserved on `cause` so call sites can introspect
|
|
204
|
-
* it without losing identity:
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* const result = await context.cancellableScope(async () => {
|
|
209
|
-
* return await context.activities.processStep(args);
|
|
210
|
-
* });
|
|
211
|
-
*
|
|
212
|
-
* if (result.isErr()) {
|
|
213
|
-
* if (result.error instanceof WorkflowCancelledError) {
|
|
214
|
-
* // graceful cancellation
|
|
215
|
-
* } else if (result.error instanceof WorkflowScopeError) {
|
|
216
|
-
* // domain error — `result.error.cause` is the original throwable
|
|
217
|
-
* }
|
|
218
|
-
* }
|
|
219
|
-
* ```
|
|
220
|
-
*
|
|
221
|
-
* Introduced so the scope helpers route every failure through neverthrow's
|
|
222
|
-
* railway. Previously, non-cancellation errors were re-thrown out of the
|
|
223
|
-
* helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`
|
|
224
|
-
* does not catch) — they leaked as unhandled rejections rather than
|
|
225
|
-
* surfacing on the typed error channel callers actually inspect.
|
|
226
|
-
*/
|
|
227
|
-
declare class WorkflowScopeError extends WorkerError {
|
|
228
|
-
constructor(cause: unknown);
|
|
229
|
-
}
|
|
230
211
|
//#endregion
|
|
231
|
-
export {
|
|
232
|
-
//# sourceMappingURL=errors-
|
|
212
|
+
export { ClientInferOutput as _, ChildWorkflowError as a, QueryOutputValidationError as c, UpdateOutputValidationError as d, ValidationError as f, ClientInferInput as g, WorkflowOutputValidationError as h, ChildWorkflowCancelledError as i, SignalInputValidationError as l, WorkflowInputValidationError as m, ActivityInputValidationError as n, ChildWorkflowNotFoundError as o, WorkflowCancelledError as p, ActivityOutputValidationError as r, QueryInputValidationError as s, ActivityDefinitionNotFoundError as t, UpdateInputValidationError as u, WorkerInferInput as v, WorkerInferOutput as y };
|
|
213
|
+
//# sourceMappingURL=errors-BNnNzSwE.d.mts.map
|
|
@@ -0,0 +1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OAAA;AAAA;cAEY,KAAA;AAAA"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
let _temporal_contract_contract = require("@temporal-contract/contract");
|
|
2
2
|
let _temporalio_common = require("@temporalio/common");
|
|
3
|
+
let unthrown = require("unthrown");
|
|
3
4
|
let _temporalio_workflow = require("@temporalio/workflow");
|
|
4
5
|
require("@temporal-contract/contract/result-async");
|
|
5
6
|
//#region src/errors.ts
|
|
6
7
|
/**
|
|
7
|
-
* Base error class for worker errors
|
|
8
|
-
*/
|
|
9
|
-
var WorkerError = class extends Error {
|
|
10
|
-
constructor(message, cause) {
|
|
11
|
-
super(message, { cause });
|
|
12
|
-
this.name = "WorkerError";
|
|
13
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
8
|
* Base class for the contract's runtime validation failures — workflow and
|
|
18
9
|
* activity input/output, plus signal/query/update payloads.
|
|
19
10
|
*
|
|
@@ -58,15 +49,14 @@ var ValidationError = class extends _temporalio_common.ApplicationFailure {
|
|
|
58
49
|
/**
|
|
59
50
|
* Error thrown when an activity definition is not found in the contract
|
|
60
51
|
*/
|
|
61
|
-
var ActivityDefinitionNotFoundError = class extends
|
|
62
|
-
activityName;
|
|
63
|
-
availableDefinitions;
|
|
52
|
+
var ActivityDefinitionNotFoundError = class extends (0, unthrown.TaggedError)("@temporal-contract/ActivityDefinitionNotFoundError", { name: "ActivityDefinitionNotFoundError" }) {
|
|
64
53
|
constructor(activityName, availableDefinitions = []) {
|
|
65
54
|
const available = availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none";
|
|
66
|
-
super(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
super({
|
|
56
|
+
activityName,
|
|
57
|
+
availableDefinitions,
|
|
58
|
+
message: `Activity definition not found for: "${activityName}". Available activities: ${available}`
|
|
59
|
+
});
|
|
70
60
|
}
|
|
71
61
|
};
|
|
72
62
|
/**
|
|
@@ -171,15 +161,14 @@ var UpdateOutputValidationError = class extends ValidationError {
|
|
|
171
161
|
/**
|
|
172
162
|
* Error thrown when a child workflow is not found in the contract
|
|
173
163
|
*/
|
|
174
|
-
var ChildWorkflowNotFoundError = class extends
|
|
175
|
-
workflowName;
|
|
176
|
-
availableWorkflows;
|
|
164
|
+
var ChildWorkflowNotFoundError = class extends (0, unthrown.TaggedError)("@temporal-contract/ChildWorkflowNotFoundError", { name: "ChildWorkflowNotFoundError" }) {
|
|
177
165
|
constructor(workflowName, availableWorkflows = []) {
|
|
178
166
|
const available = availableWorkflows.length > 0 ? availableWorkflows.join(", ") : "none";
|
|
179
|
-
super(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
super({
|
|
168
|
+
workflowName,
|
|
169
|
+
availableWorkflows,
|
|
170
|
+
message: `Child workflow not found: "${workflowName}". Available workflows: ${available}`
|
|
171
|
+
});
|
|
183
172
|
}
|
|
184
173
|
};
|
|
185
174
|
/**
|
|
@@ -191,86 +180,56 @@ var ChildWorkflowNotFoundError = class extends WorkerError {
|
|
|
191
180
|
* mirroring the client-side `WorkflowFailedError.cause` behavior, so callers
|
|
192
181
|
* can branch on the failure category in one step instead of unwrapping twice.
|
|
193
182
|
*/
|
|
194
|
-
var ChildWorkflowError = class extends
|
|
183
|
+
var ChildWorkflowError = class extends (0, unthrown.TaggedError)("@temporal-contract/ChildWorkflowError", { name: "ChildWorkflowError" }) {
|
|
195
184
|
constructor(message, cause) {
|
|
196
|
-
super(
|
|
197
|
-
|
|
185
|
+
super({
|
|
186
|
+
message,
|
|
187
|
+
cause
|
|
188
|
+
});
|
|
198
189
|
}
|
|
199
190
|
};
|
|
200
191
|
/**
|
|
201
|
-
* Discriminated variant
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* `
|
|
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.
|
|
207
198
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* the
|
|
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.
|
|
213
205
|
*/
|
|
214
|
-
var ChildWorkflowCancelledError = class extends
|
|
215
|
-
workflowName;
|
|
206
|
+
var ChildWorkflowCancelledError = class extends (0, unthrown.TaggedError)("@temporal-contract/ChildWorkflowCancelledError", { name: "ChildWorkflowCancelledError" }) {
|
|
216
207
|
constructor(workflowName, cause) {
|
|
217
|
-
super(
|
|
218
|
-
|
|
219
|
-
|
|
208
|
+
super({
|
|
209
|
+
workflowName,
|
|
210
|
+
cause,
|
|
211
|
+
message: `Child workflow "${workflowName}" was cancelled`
|
|
212
|
+
});
|
|
220
213
|
}
|
|
221
214
|
};
|
|
222
215
|
/**
|
|
223
|
-
* Error surfaced in the `err(...)` branch of
|
|
216
|
+
* Error surfaced in the `err(...)` branch of an `AsyncResult` when a typed
|
|
224
217
|
* cancellation scope is cancelled via Temporal's cancellation propagation.
|
|
225
218
|
* Returned by both `context.cancellableScope` (when the workflow or an
|
|
226
219
|
* ancestor scope cancels) and `context.nonCancellableScope` (when
|
|
227
220
|
* cancellation is raised from inside the scope). Distinct from arbitrary
|
|
228
221
|
* thrown errors so call sites can branch on cancellation explicitly.
|
|
229
222
|
*
|
|
230
|
-
* Non-cancellation errors thrown inside a scope
|
|
231
|
-
*
|
|
232
|
-
*
|
|
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(...)`.
|
|
233
226
|
*/
|
|
234
|
-
var WorkflowCancelledError = class extends
|
|
227
|
+
var WorkflowCancelledError = class extends (0, unthrown.TaggedError)("@temporal-contract/WorkflowCancelledError", { name: "WorkflowCancelledError" }) {
|
|
235
228
|
constructor(cause) {
|
|
236
|
-
super(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Error surfaced in the `err(...)` branch of a `ResultAsync` when the
|
|
242
|
-
* function passed to `cancellableScope` / `nonCancellableScope` throws a
|
|
243
|
-
* non-cancellation error.
|
|
244
|
-
*
|
|
245
|
-
* The original error is preserved on `cause` so call sites can introspect
|
|
246
|
-
* it without losing identity:
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* ```ts
|
|
250
|
-
* const result = await context.cancellableScope(async () => {
|
|
251
|
-
* return await context.activities.processStep(args);
|
|
252
|
-
* });
|
|
253
|
-
*
|
|
254
|
-
* if (result.isErr()) {
|
|
255
|
-
* if (result.error instanceof WorkflowCancelledError) {
|
|
256
|
-
* // graceful cancellation
|
|
257
|
-
* } else if (result.error instanceof WorkflowScopeError) {
|
|
258
|
-
* // domain error — `result.error.cause` is the original throwable
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
263
|
-
* Introduced so the scope helpers route every failure through neverthrow's
|
|
264
|
-
* railway. Previously, non-cancellation errors were re-thrown out of the
|
|
265
|
-
* helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`
|
|
266
|
-
* does not catch) — they leaked as unhandled rejections rather than
|
|
267
|
-
* surfacing on the typed error channel callers actually inspect.
|
|
268
|
-
*/
|
|
269
|
-
var WorkflowScopeError = class extends WorkerError {
|
|
270
|
-
constructor(cause) {
|
|
271
|
-
const message = cause instanceof Error ? `Workflow cancellation scope caught a non-cancellation error: ${cause.message}` : "Workflow cancellation scope caught a non-cancellation error";
|
|
272
|
-
super(message, cause);
|
|
273
|
-
this.name = "WorkflowScopeError";
|
|
229
|
+
super({
|
|
230
|
+
cause,
|
|
231
|
+
message: "Workflow cancellation scope was cancelled"
|
|
232
|
+
});
|
|
274
233
|
}
|
|
275
234
|
};
|
|
276
235
|
//#endregion
|
|
@@ -329,7 +288,7 @@ function buildRawActivitiesProxy(workflowActivities, contractActivities, default
|
|
|
329
288
|
const defaultProxy = (0, _temporalio_workflow.proxyActivities)(defaultOptions);
|
|
330
289
|
const overrideEntries = overrides ? Object.entries(overrides).filter((entry) => entry[1] !== void 0) : [];
|
|
331
290
|
if (overrideEntries.length === 0) return defaultProxy;
|
|
332
|
-
const declared = new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
|
|
291
|
+
const declared = /* @__PURE__ */ new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
|
|
333
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"}.`);
|
|
334
293
|
const overriddenFns = {};
|
|
335
294
|
for (const [name, override] of overrideEntries) {
|
|
@@ -555,12 +514,6 @@ Object.defineProperty(exports, "WorkflowOutputValidationError", {
|
|
|
555
514
|
return WorkflowOutputValidationError;
|
|
556
515
|
}
|
|
557
516
|
});
|
|
558
|
-
Object.defineProperty(exports, "WorkflowScopeError", {
|
|
559
|
-
enumerable: true,
|
|
560
|
-
get: function() {
|
|
561
|
-
return WorkflowScopeError;
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
517
|
Object.defineProperty(exports, "buildRawActivitiesProxy", {
|
|
565
518
|
enumerable: true,
|
|
566
519
|
get: function() {
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { summarizeIssues } from "@temporal-contract/contract";
|
|
2
2
|
import { ApplicationFailure, ChildWorkflowFailure } from "@temporalio/common";
|
|
3
|
+
import { TaggedError } from "unthrown";
|
|
3
4
|
import { isCancellation, makeContinueAsNewFunc, proxyActivities } from "@temporalio/workflow";
|
|
4
|
-
import {
|
|
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
|
-
*/
|
|
9
|
-
var WorkerError = class extends Error {
|
|
10
|
-
constructor(message, cause) {
|
|
11
|
-
super(message, { cause });
|
|
12
|
-
this.name = "WorkerError";
|
|
13
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
8
|
* Base class for the contract's runtime validation failures — workflow and
|
|
18
9
|
* activity input/output, plus signal/query/update payloads.
|
|
19
10
|
*
|
|
@@ -58,15 +49,14 @@ var ValidationError = class extends ApplicationFailure {
|
|
|
58
49
|
/**
|
|
59
50
|
* Error thrown when an activity definition is not found in the contract
|
|
60
51
|
*/
|
|
61
|
-
var ActivityDefinitionNotFoundError = class extends
|
|
62
|
-
activityName;
|
|
63
|
-
availableDefinitions;
|
|
52
|
+
var ActivityDefinitionNotFoundError = class extends TaggedError("@temporal-contract/ActivityDefinitionNotFoundError", { name: "ActivityDefinitionNotFoundError" }) {
|
|
64
53
|
constructor(activityName, availableDefinitions = []) {
|
|
65
54
|
const available = availableDefinitions.length > 0 ? availableDefinitions.join(", ") : "none";
|
|
66
|
-
super(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
super({
|
|
56
|
+
activityName,
|
|
57
|
+
availableDefinitions,
|
|
58
|
+
message: `Activity definition not found for: "${activityName}". Available activities: ${available}`
|
|
59
|
+
});
|
|
70
60
|
}
|
|
71
61
|
};
|
|
72
62
|
/**
|
|
@@ -171,15 +161,14 @@ var UpdateOutputValidationError = class extends ValidationError {
|
|
|
171
161
|
/**
|
|
172
162
|
* Error thrown when a child workflow is not found in the contract
|
|
173
163
|
*/
|
|
174
|
-
var ChildWorkflowNotFoundError = class extends
|
|
175
|
-
workflowName;
|
|
176
|
-
availableWorkflows;
|
|
164
|
+
var ChildWorkflowNotFoundError = class extends TaggedError("@temporal-contract/ChildWorkflowNotFoundError", { name: "ChildWorkflowNotFoundError" }) {
|
|
177
165
|
constructor(workflowName, availableWorkflows = []) {
|
|
178
166
|
const available = availableWorkflows.length > 0 ? availableWorkflows.join(", ") : "none";
|
|
179
|
-
super(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
super({
|
|
168
|
+
workflowName,
|
|
169
|
+
availableWorkflows,
|
|
170
|
+
message: `Child workflow not found: "${workflowName}". Available workflows: ${available}`
|
|
171
|
+
});
|
|
183
172
|
}
|
|
184
173
|
};
|
|
185
174
|
/**
|
|
@@ -191,86 +180,56 @@ var ChildWorkflowNotFoundError = class extends WorkerError {
|
|
|
191
180
|
* mirroring the client-side `WorkflowFailedError.cause` behavior, so callers
|
|
192
181
|
* can branch on the failure category in one step instead of unwrapping twice.
|
|
193
182
|
*/
|
|
194
|
-
var ChildWorkflowError = class extends
|
|
183
|
+
var ChildWorkflowError = class extends TaggedError("@temporal-contract/ChildWorkflowError", { name: "ChildWorkflowError" }) {
|
|
195
184
|
constructor(message, cause) {
|
|
196
|
-
super(
|
|
197
|
-
|
|
185
|
+
super({
|
|
186
|
+
message,
|
|
187
|
+
cause
|
|
188
|
+
});
|
|
198
189
|
}
|
|
199
190
|
};
|
|
200
191
|
/**
|
|
201
|
-
* Discriminated variant
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* `
|
|
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.
|
|
207
198
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* the
|
|
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.
|
|
213
205
|
*/
|
|
214
|
-
var ChildWorkflowCancelledError = class extends
|
|
215
|
-
workflowName;
|
|
206
|
+
var ChildWorkflowCancelledError = class extends TaggedError("@temporal-contract/ChildWorkflowCancelledError", { name: "ChildWorkflowCancelledError" }) {
|
|
216
207
|
constructor(workflowName, cause) {
|
|
217
|
-
super(
|
|
218
|
-
|
|
219
|
-
|
|
208
|
+
super({
|
|
209
|
+
workflowName,
|
|
210
|
+
cause,
|
|
211
|
+
message: `Child workflow "${workflowName}" was cancelled`
|
|
212
|
+
});
|
|
220
213
|
}
|
|
221
214
|
};
|
|
222
215
|
/**
|
|
223
|
-
* Error surfaced in the `err(...)` branch of
|
|
216
|
+
* Error surfaced in the `err(...)` branch of an `AsyncResult` when a typed
|
|
224
217
|
* cancellation scope is cancelled via Temporal's cancellation propagation.
|
|
225
218
|
* Returned by both `context.cancellableScope` (when the workflow or an
|
|
226
219
|
* ancestor scope cancels) and `context.nonCancellableScope` (when
|
|
227
220
|
* cancellation is raised from inside the scope). Distinct from arbitrary
|
|
228
221
|
* thrown errors so call sites can branch on cancellation explicitly.
|
|
229
222
|
*
|
|
230
|
-
* Non-cancellation errors thrown inside a scope
|
|
231
|
-
*
|
|
232
|
-
*
|
|
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(...)`.
|
|
233
226
|
*/
|
|
234
|
-
var WorkflowCancelledError = class extends
|
|
227
|
+
var WorkflowCancelledError = class extends TaggedError("@temporal-contract/WorkflowCancelledError", { name: "WorkflowCancelledError" }) {
|
|
235
228
|
constructor(cause) {
|
|
236
|
-
super(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* Error surfaced in the `err(...)` branch of a `ResultAsync` when the
|
|
242
|
-
* function passed to `cancellableScope` / `nonCancellableScope` throws a
|
|
243
|
-
* non-cancellation error.
|
|
244
|
-
*
|
|
245
|
-
* The original error is preserved on `cause` so call sites can introspect
|
|
246
|
-
* it without losing identity:
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* ```ts
|
|
250
|
-
* const result = await context.cancellableScope(async () => {
|
|
251
|
-
* return await context.activities.processStep(args);
|
|
252
|
-
* });
|
|
253
|
-
*
|
|
254
|
-
* if (result.isErr()) {
|
|
255
|
-
* if (result.error instanceof WorkflowCancelledError) {
|
|
256
|
-
* // graceful cancellation
|
|
257
|
-
* } else if (result.error instanceof WorkflowScopeError) {
|
|
258
|
-
* // domain error — `result.error.cause` is the original throwable
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
263
|
-
* Introduced so the scope helpers route every failure through neverthrow's
|
|
264
|
-
* railway. Previously, non-cancellation errors were re-thrown out of the
|
|
265
|
-
* helper, which became a `ResultAsync` rejection (`new ResultAsync(promise)`
|
|
266
|
-
* does not catch) — they leaked as unhandled rejections rather than
|
|
267
|
-
* surfacing on the typed error channel callers actually inspect.
|
|
268
|
-
*/
|
|
269
|
-
var WorkflowScopeError = class extends WorkerError {
|
|
270
|
-
constructor(cause) {
|
|
271
|
-
const message = cause instanceof Error ? `Workflow cancellation scope caught a non-cancellation error: ${cause.message}` : "Workflow cancellation scope caught a non-cancellation error";
|
|
272
|
-
super(message, cause);
|
|
273
|
-
this.name = "WorkflowScopeError";
|
|
229
|
+
super({
|
|
230
|
+
cause,
|
|
231
|
+
message: "Workflow cancellation scope was cancelled"
|
|
232
|
+
});
|
|
274
233
|
}
|
|
275
234
|
};
|
|
276
235
|
//#endregion
|
|
@@ -329,7 +288,7 @@ function buildRawActivitiesProxy(workflowActivities, contractActivities, default
|
|
|
329
288
|
const defaultProxy = proxyActivities(defaultOptions);
|
|
330
289
|
const overrideEntries = overrides ? Object.entries(overrides).filter((entry) => entry[1] !== void 0) : [];
|
|
331
290
|
if (overrideEntries.length === 0) return defaultProxy;
|
|
332
|
-
const declared = new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
|
|
291
|
+
const declared = /* @__PURE__ */ new Set([...Object.keys(workflowActivities ?? {}), ...Object.keys(contractActivities ?? {})]);
|
|
333
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"}.`);
|
|
334
293
|
const overriddenFns = {};
|
|
335
294
|
for (const [name, override] of overrideEntries) {
|
|
@@ -465,6 +424,6 @@ function describeChildWorkflowOperation(operation, childWorkflowName) {
|
|
|
465
424
|
}
|
|
466
425
|
}
|
|
467
426
|
//#endregion
|
|
468
|
-
export {
|
|
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 };
|
|
469
428
|
|
|
470
|
-
//# sourceMappingURL=internal-
|
|
429
|
+
//# sourceMappingURL=internal-DqYK4YQK.mjs.map
|