@temporal-contract/client 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +63 -75
- package/dist/index.d.cts +41 -23
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +41 -23
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +59 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, ServerFailure, TerminatedFailure, TimeoutFailure } from "@temporalio/common";
|
|
1
2
|
import { ResultAsync } from "neverthrow";
|
|
3
|
+
import { ActivityDefinition, AnySchema, AnyWorkflowDefinition, ContractDefinition, QueryDefinition, SearchAttributeDefinition, SearchAttributeKindToType, SignalDefinition, SignalNamesOf, UpdateDefinition } from "@temporal-contract/contract";
|
|
2
4
|
import { Client, ScheduleClient, ScheduleDescription, ScheduleOptions, ScheduleOptionsStartWorkflowAction, ScheduleOverlapPolicy, ScheduleSpec, WorkflowHandle, WorkflowSignalWithStartOptions, WorkflowStartOptions } from "@temporalio/client";
|
|
3
|
-
import { ActivityDefinition, AnySchema, ContractDefinition, QueryDefinition, SearchAttributeDefinition, SearchAttributeKindToType, SignalDefinition, UpdateDefinition, WorkflowDefinition } from "@temporal-contract/contract";
|
|
4
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
6
|
|
|
6
7
|
//#region src/types.d.ts
|
|
@@ -26,7 +27,7 @@ type ClientInferOutput<T extends {
|
|
|
26
27
|
* Infer workflow function signature from client perspective
|
|
27
28
|
* Client sends z.output and receives z.input
|
|
28
29
|
*/
|
|
29
|
-
type ClientInferWorkflow<TWorkflow extends
|
|
30
|
+
type ClientInferWorkflow<TWorkflow extends AnyWorkflowDefinition> = (args: ClientInferInput<TWorkflow>) => Promise<ClientInferOutput<TWorkflow>>;
|
|
30
31
|
/**
|
|
31
32
|
* Infer activity function signature from client perspective
|
|
32
33
|
* Client sends z.output and receives z.input
|
|
@@ -61,26 +62,37 @@ type ClientInferActivities<TContract extends ContractDefinition> = TContract["ac
|
|
|
61
62
|
/**
|
|
62
63
|
* Infer activities from a workflow definition (client perspective)
|
|
63
64
|
*/
|
|
64
|
-
type ClientInferWorkflowActivities<T extends
|
|
65
|
+
type ClientInferWorkflowActivities<T extends AnyWorkflowDefinition> = T["activities"] extends Record<string, ActivityDefinition> ? { [K in keyof T["activities"]]: ClientInferActivity<T["activities"][K]> } : {};
|
|
65
66
|
/**
|
|
66
67
|
* Infer signals from a workflow definition (client perspective)
|
|
67
68
|
*/
|
|
68
|
-
type ClientInferWorkflowSignals<T extends
|
|
69
|
+
type ClientInferWorkflowSignals<T extends AnyWorkflowDefinition> = T["signals"] extends Record<string, SignalDefinition> ? { [K in keyof T["signals"]]: ClientInferSignal<T["signals"][K]> } : {};
|
|
69
70
|
/**
|
|
70
71
|
* Infer queries from a workflow definition (client perspective)
|
|
71
72
|
*/
|
|
72
|
-
type ClientInferWorkflowQueries<T extends
|
|
73
|
+
type ClientInferWorkflowQueries<T extends AnyWorkflowDefinition> = T["queries"] extends Record<string, QueryDefinition> ? { [K in keyof T["queries"]]: ClientInferQuery<T["queries"][K]> } : {};
|
|
73
74
|
/**
|
|
74
75
|
* Infer updates from a workflow definition (client perspective)
|
|
75
76
|
*/
|
|
76
|
-
type ClientInferWorkflowUpdates<T extends
|
|
77
|
+
type ClientInferWorkflowUpdates<T extends AnyWorkflowDefinition> = T["updates"] extends Record<string, UpdateDefinition> ? { [K in keyof T["updates"]]: ClientInferUpdate<T["updates"][K]> } : {};
|
|
77
78
|
/**
|
|
78
79
|
* Infer all activities available in a workflow context (client perspective)
|
|
79
80
|
* Combines workflow-specific activities with global activities
|
|
80
81
|
*/
|
|
81
|
-
type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
|
|
82
|
+
type ClientInferWorkflowContextActivities<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = ClientInferWorkflowActivities<TContract["workflows"][TWorkflowName]> & ClientInferActivities<TContract>;
|
|
82
83
|
//#endregion
|
|
83
84
|
//#region src/errors.d.ts
|
|
85
|
+
/**
|
|
86
|
+
* Union of the actionable Temporal failure types that can surface as the
|
|
87
|
+
* `cause` of a `WorkflowFailedError`. These all extend Temporal's internal
|
|
88
|
+
* `TemporalFailure` base class — we list them by leaf type rather than by
|
|
89
|
+
* the base class so consumer code can use a single `switch (true)` over
|
|
90
|
+
* `instanceof` discriminants without an exhaustiveness escape hatch.
|
|
91
|
+
*
|
|
92
|
+
* Re-exported from the package entry point so consumers can import it
|
|
93
|
+
* directly: `import type { TemporalFailure } from "@temporal-contract/client"`.
|
|
94
|
+
*/
|
|
95
|
+
type TemporalFailure = ApplicationFailure | CancelledFailure | TerminatedFailure | TimeoutFailure | ChildWorkflowFailure | ServerFailure | ActivityFailure;
|
|
84
96
|
/**
|
|
85
97
|
* Base class for all typed client errors with boxed pattern
|
|
86
98
|
*/
|
|
@@ -143,18 +155,24 @@ declare class WorkflowExecutionNotFoundError extends TypedClientError {
|
|
|
143
155
|
* on a workflow's result and the workflow completes with a failure —
|
|
144
156
|
* Temporal's `WorkflowFailedError`.
|
|
145
157
|
*
|
|
146
|
-
* `cause` is the *unwrapped* underlying
|
|
158
|
+
* `cause` is the *unwrapped* underlying {@link TemporalFailure} (typically an
|
|
147
159
|
* `ApplicationFailure`, `CancelledFailure`, `TerminatedFailure`, or
|
|
148
160
|
* `TimeoutFailure`) lifted from Temporal's wrapper, so callers can branch
|
|
149
161
|
* on the failure category in one step (`err.cause instanceof
|
|
150
|
-
* ApplicationFailure`) instead of unwrapping twice via the SDK wrapper.
|
|
162
|
+
* ApplicationFailure`) instead of unwrapping twice via the SDK wrapper. The
|
|
163
|
+
* SDK declares `WorkflowFailedError.cause` as the wider `Error | undefined`
|
|
164
|
+
* (since `cause` lives on `Error`), but the runtime guarantee — driven by
|
|
165
|
+
* Temporal's wire format — is that it is always a `TemporalFailure` subclass
|
|
166
|
+
* when the wrapper is surfaced. `classifyResultError` narrows that wider
|
|
167
|
+
* static type to the public {@link TemporalFailure} union with a cast, so
|
|
168
|
+
* consumers see the precise leaf-failure typing instead of a bare `Error`.
|
|
151
169
|
*
|
|
152
170
|
* Returned from `executeWorkflow` and `handle.result()`.
|
|
153
171
|
*/
|
|
154
172
|
declare class WorkflowFailedError extends TypedClientError {
|
|
155
173
|
readonly workflowId: string;
|
|
156
|
-
readonly cause?:
|
|
157
|
-
constructor(workflowId: string, cause?:
|
|
174
|
+
readonly cause?: TemporalFailure | undefined;
|
|
175
|
+
constructor(workflowId: string, cause?: TemporalFailure | undefined);
|
|
158
176
|
}
|
|
159
177
|
/**
|
|
160
178
|
* Thrown when workflow input or output validation fails
|
|
@@ -213,7 +231,7 @@ type TypedScheduleActionOverrides = Pick<ScheduleOptionsStartWorkflowAction<neve
|
|
|
213
231
|
* Workflow-action–level overrides nest under {@link action} so memo and
|
|
214
232
|
* other fields with the same name don't collide between the two scopes.
|
|
215
233
|
*/
|
|
216
|
-
type TypedScheduleCreateOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = {
|
|
234
|
+
type TypedScheduleCreateOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = {
|
|
217
235
|
/** Schedule ID. Recommended to use a meaningful business identifier. */scheduleId: string; /** When the schedule should fire (cron, interval, calendar). */
|
|
218
236
|
spec: ScheduleSpec; /** Workflow input — validated against the contract's input schema. */
|
|
219
237
|
args: ClientInferInput<TContract["workflows"][TWorkflowName]>; /** Temporal schedule policies (overlap, catchupWindow, pauseOnFailure, etc.). */
|
|
@@ -261,7 +279,7 @@ declare class TypedScheduleClient<TContract extends ContractDefinition> {
|
|
|
261
279
|
* `workflowType` are pulled from the contract automatically; the typed
|
|
262
280
|
* options shape omits them so call sites don't have to repeat themselves.
|
|
263
281
|
*/
|
|
264
|
-
create<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, options: TypedScheduleCreateOptions<TContract, TWorkflowName>): ResultAsync<TypedScheduleHandle, WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError>;
|
|
282
|
+
create<TWorkflowName extends keyof TContract["workflows"] & string>(workflowName: TWorkflowName, options: TypedScheduleCreateOptions<TContract, TWorkflowName>): ResultAsync<TypedScheduleHandle, WorkflowNotFoundError | WorkflowValidationError | RuntimeClientError>;
|
|
265
283
|
/**
|
|
266
284
|
* Get a typed handle to an existing schedule. Does not validate that the
|
|
267
285
|
* schedule exists — handle methods (`describe`, `pause`, etc.) will
|
|
@@ -282,8 +300,8 @@ declare class TypedScheduleClient<TContract extends ContractDefinition> {
|
|
|
282
300
|
* meaning the `searchAttributes` field is effectively absent from the start
|
|
283
301
|
* options for that workflow.
|
|
284
302
|
*/
|
|
285
|
-
type TypedSearchAttributeMap<TWorkflow extends
|
|
286
|
-
type TypedWorkflowStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"]> = Omit<WorkflowStartOptions, "taskQueue" | "args" | "searchAttributes" | "typedSearchAttributes"> & {
|
|
303
|
+
type TypedSearchAttributeMap<TWorkflow extends AnyWorkflowDefinition> = TWorkflow["searchAttributes"] extends Record<string, SearchAttributeDefinition> ? { [K in keyof TWorkflow["searchAttributes"]]?: SearchAttributeKindToType<TWorkflow["searchAttributes"][K]["kind"]> } : never;
|
|
304
|
+
type TypedWorkflowStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string> = Omit<WorkflowStartOptions, "taskQueue" | "args" | "searchAttributes" | "typedSearchAttributes"> & {
|
|
287
305
|
args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
|
|
288
306
|
/**
|
|
289
307
|
* Indexed search attributes for the started workflow. Keys and value types
|
|
@@ -297,7 +315,7 @@ type TypedWorkflowStartOptions<TContract extends ContractDefinition, TWorkflowNa
|
|
|
297
315
|
* Options for {@link TypedClient.signalWithStart} — typed against both the
|
|
298
316
|
* workflow's input schema and the named signal's input schema.
|
|
299
317
|
*/
|
|
300
|
-
type TypedSignalWithStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"], TSignalName extends
|
|
318
|
+
type TypedSignalWithStartOptions<TContract extends ContractDefinition, TWorkflowName extends keyof TContract["workflows"] & string, TSignalName extends SignalNamesOf<TContract["workflows"][TWorkflowName]>> = Omit<WorkflowSignalWithStartOptions, "taskQueue" | "args" | "signal" | "signalArgs" | "searchAttributes" | "typedSearchAttributes"> & {
|
|
301
319
|
args: ClientInferInput<TContract["workflows"][TWorkflowName]>;
|
|
302
320
|
signalName: TSignalName;
|
|
303
321
|
signalArgs: TContract["workflows"][TWorkflowName]["signals"][TSignalName] extends SignalDefinition ? ClientInferInput<TContract["workflows"][TWorkflowName]["signals"][TSignalName]> : never;
|
|
@@ -314,7 +332,7 @@ type TypedSignalWithStartOptions<TContract extends ContractDefinition, TWorkflow
|
|
|
314
332
|
* to the standard handle so callers can correlate the signal with the
|
|
315
333
|
* (possibly pre-existing) workflow execution chain.
|
|
316
334
|
*/
|
|
317
|
-
type TypedWorkflowHandleWithSignaledRunId<TWorkflow extends
|
|
335
|
+
type TypedWorkflowHandleWithSignaledRunId<TWorkflow extends AnyWorkflowDefinition> = TypedWorkflowHandle<TWorkflow> & {
|
|
318
336
|
/**
|
|
319
337
|
* The Run Id of the bound Workflow at the time of `signalWithStart`. Since
|
|
320
338
|
* `signalWithStart` may have signaled an existing Workflow Chain, this is
|
|
@@ -325,7 +343,7 @@ type TypedWorkflowHandleWithSignaledRunId<TWorkflow extends WorkflowDefinition>
|
|
|
325
343
|
/**
|
|
326
344
|
* Typed workflow handle with validated results using neverthrow Result/ResultAsync
|
|
327
345
|
*/
|
|
328
|
-
type TypedWorkflowHandle<TWorkflow extends
|
|
346
|
+
type TypedWorkflowHandle<TWorkflow extends AnyWorkflowDefinition> = {
|
|
329
347
|
workflowId: string;
|
|
330
348
|
/**
|
|
331
349
|
* Type-safe queries based on workflow definition with Result pattern
|
|
@@ -440,7 +458,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
|
|
|
440
458
|
* );
|
|
441
459
|
* ```
|
|
442
460
|
*/
|
|
443
|
-
startWorkflow<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, {
|
|
461
|
+
startWorkflow<TWorkflowName extends keyof TContract["workflows"] & string>(workflowName: TWorkflowName, {
|
|
444
462
|
args,
|
|
445
463
|
searchAttributes,
|
|
446
464
|
...temporalOptions
|
|
@@ -471,7 +489,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
|
|
|
471
489
|
* );
|
|
472
490
|
* ```
|
|
473
491
|
*/
|
|
474
|
-
signalWithStart<TWorkflowName extends keyof TContract["workflows"], TSignalName extends
|
|
492
|
+
signalWithStart<TWorkflowName extends keyof TContract["workflows"] & string, TSignalName extends SignalNamesOf<TContract["workflows"][TWorkflowName]>>(workflowName: TWorkflowName, {
|
|
475
493
|
args,
|
|
476
494
|
signalName,
|
|
477
495
|
signalArgs,
|
|
@@ -496,7 +514,7 @@ declare class TypedClient<TContract extends ContractDefinition> {
|
|
|
496
514
|
* );
|
|
497
515
|
* ```
|
|
498
516
|
*/
|
|
499
|
-
executeWorkflow<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, {
|
|
517
|
+
executeWorkflow<TWorkflowName extends keyof TContract["workflows"] & string>(workflowName: TWorkflowName, {
|
|
500
518
|
args,
|
|
501
519
|
searchAttributes,
|
|
502
520
|
...temporalOptions
|
|
@@ -516,9 +534,9 @@ declare class TypedClient<TContract extends ContractDefinition> {
|
|
|
516
534
|
* );
|
|
517
535
|
* ```
|
|
518
536
|
*/
|
|
519
|
-
getHandle<TWorkflowName extends keyof TContract["workflows"]>(workflowName: TWorkflowName, workflowId: string): ResultAsync<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, WorkflowNotFoundError | RuntimeClientError>;
|
|
537
|
+
getHandle<TWorkflowName extends keyof TContract["workflows"] & string>(workflowName: TWorkflowName, workflowId: string): ResultAsync<TypedWorkflowHandle<TContract["workflows"][TWorkflowName]>, WorkflowNotFoundError | RuntimeClientError>;
|
|
520
538
|
private createTypedHandle;
|
|
521
539
|
}
|
|
522
540
|
//#endregion
|
|
523
|
-
export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError };
|
|
541
|
+
export { type ClientInferActivities, type ClientInferActivity, type ClientInferInput, type ClientInferOutput, type ClientInferQuery, type ClientInferSignal, type ClientInferUpdate, type ClientInferWorkflow, type ClientInferWorkflowActivities, type ClientInferWorkflowContextActivities, type ClientInferWorkflowQueries, type ClientInferWorkflowSignals, type ClientInferWorkflowUpdates, type ClientInferWorkflows, QueryValidationError, RuntimeClientError, SignalValidationError, type TemporalFailure, TypedClient, type TypedScheduleActionOverrides, TypedScheduleClient, type TypedScheduleCreateOptions, type TypedScheduleHandle, type TypedSignalWithStartOptions, type TypedWorkflowHandle, type TypedWorkflowHandleWithSignaledRunId, type TypedWorkflowStartOptions, UpdateValidationError, WorkflowAlreadyStartedError, WorkflowExecutionNotFoundError, WorkflowFailedError, WorkflowNotFoundError, WorkflowValidationError };
|
|
524
542
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/schedule.ts","../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/errors.ts","../src/schedule.ts","../src/client.ts"],"mappings":";;;;;;;;;;;KAgBY,gBAAA;EAA6B,KAAA,EAAO,SAAA;AAAA,KAAe,gBAAA,CAAiB,UAAA,CAC9E,CAAA;;;;;KAOU,iBAAA;EAA8B,MAAA,EAAQ,SAAA;AAAA,KAAe,gBAAA,CAAiB,WAAA,CAChF,CAAA;;;;;;;AADF;;KAaY,mBAAA,mBAAsC,qBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,mBAAA,mBAAsC,kBAAA,KAChD,IAAA,EAAM,gBAAA,CAAiB,SAAA,MACpB,OAAA,CAAQ,iBAAA,CAAkB,SAAA;;;;;KAMnB,iBAAA,iBAAkC,gBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,WAAA,OAAkB,KAAA;;;;AAlBvB;KAwBY,gBAAA,gBAAgC,eAAA,KAC1C,IAAA,EAAM,gBAAA,CAAiB,MAAA,MACpB,WAAA,CAAY,iBAAA,CAAkB,MAAA,GAAS,KAAA;;;;;KAMhC,iBAAA,iBAAkC,gBAAA,KAC5C,IAAA,EAAM,gBAAA,CAAiB,OAAA,MACpB,WAAA,CAAY,iBAAA,CAAkB,OAAA,GAAU,KAAA;;;;;;;KASjC,oBAAA,mBAAuC,kBAAA,kBACrC,SAAA,gBAAyB,mBAAA,CAAoB,SAAA,cAAuB,CAAA;;;;KAMtE,qBAAA,mBAAwC,kBAAA,IAClD,SAAA,uBAAgC,MAAA,SAAe,kBAAA,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,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,UAAA;IACA,UAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,2BAAA,CAA4B,SAAA,EAAW,aAAA,EAAe,WAAA,IACxD,WAAA,CACD,oCAAA,CAAqC,SAAA,cAAuB,aAAA,IAC1D,qBAAA,GACA,uBAAA,GACA,qBAAA,GACA,2BAAA,GACA,kBAAA;EH/YoE;;;AAO1E;;;;;;;;;;;;;;;EGsdE,eAAA,6BAA4C,SAAA,uBAAA,CAC1C,YAAA,EAAc,aAAA;IAEZ,IAAA;IACA,gBAAA;IAAA,GACG;EAAA,GACF,yBAAA,CAA0B,SAAA,EAAW,aAAA,IACvC,WAAA,CACD,iBAAA,CAAkB,SAAA,cAAuB,aAAA,IACvC,qBAAA,GACA,uBAAA,GACA,2BAAA,GACA,mBAAA,GACA,8BAAA,GACA,kBAAA;EHneiB;;;;;;;;;AASvB;;;;;;EGqjBE,SAAA,6BAAsC,SAAA,uBAAA,CACpC,YAAA,EAAc,aAAA,EACd,UAAA,WACC,WAAA,CACD,mBAAA,CAAoB,SAAA,cAAuB,aAAA,IAC3C,qBAAA,GAAwB,kBAAA;EAAA,QAoBlB,iBAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TypedSearchAttributes, WorkflowNotFoundError as WorkflowNotFoundError$1, defineSearchAttributeKey } from "@temporalio/common";
|
|
2
2
|
import { ResultAsync, err, ok } from "neverthrow";
|
|
3
|
+
import { summarizeIssues } from "@temporal-contract/contract";
|
|
3
4
|
import { WorkflowExecutionAlreadyStartedError, WorkflowFailedError as WorkflowFailedError$1 } from "@temporalio/client";
|
|
5
|
+
import { _internal_makeResultAsync } from "@temporal-contract/contract/result-async";
|
|
4
6
|
//#region src/errors.ts
|
|
5
7
|
/**
|
|
6
8
|
* Base class for all typed client errors with boxed pattern
|
|
@@ -76,11 +78,17 @@ var WorkflowExecutionNotFoundError = class extends TypedClientError {
|
|
|
76
78
|
* on a workflow's result and the workflow completes with a failure —
|
|
77
79
|
* Temporal's `WorkflowFailedError`.
|
|
78
80
|
*
|
|
79
|
-
* `cause` is the *unwrapped* underlying
|
|
81
|
+
* `cause` is the *unwrapped* underlying {@link TemporalFailure} (typically an
|
|
80
82
|
* `ApplicationFailure`, `CancelledFailure`, `TerminatedFailure`, or
|
|
81
83
|
* `TimeoutFailure`) lifted from Temporal's wrapper, so callers can branch
|
|
82
84
|
* on the failure category in one step (`err.cause instanceof
|
|
83
|
-
* ApplicationFailure`) instead of unwrapping twice via the SDK wrapper.
|
|
85
|
+
* ApplicationFailure`) instead of unwrapping twice via the SDK wrapper. The
|
|
86
|
+
* SDK declares `WorkflowFailedError.cause` as the wider `Error | undefined`
|
|
87
|
+
* (since `cause` lives on `Error`), but the runtime guarantee — driven by
|
|
88
|
+
* Temporal's wire format — is that it is always a `TemporalFailure` subclass
|
|
89
|
+
* when the wrapper is surfaced. `classifyResultError` narrows that wider
|
|
90
|
+
* static type to the public {@link TemporalFailure} union with a cast, so
|
|
91
|
+
* consumers see the precise leaf-failure typing instead of a bare `Error`.
|
|
84
92
|
*
|
|
85
93
|
* Returned from `executeWorkflow` and `handle.result()`.
|
|
86
94
|
*/
|
|
@@ -93,52 +101,6 @@ var WorkflowFailedError = class extends TypedClientError {
|
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
103
|
/**
|
|
96
|
-
* Pattern for string keys safe to render with dot notation. A "safe" key is a
|
|
97
|
-
* JavaScript identifier (letters/digits/underscore/$, not starting with a
|
|
98
|
-
* digit). Anything else — keys containing dots, spaces, leading digits, the
|
|
99
|
-
* empty string, the literal string `"0"` etc. — gets bracket-quoted so the
|
|
100
|
-
* path is unambiguous.
|
|
101
|
-
*
|
|
102
|
-
* This helper is intentionally duplicated with the worker package so each
|
|
103
|
-
* entry point is self-contained; keep the two copies in sync.
|
|
104
|
-
*/
|
|
105
|
-
const SAFE_IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
106
|
-
/**
|
|
107
|
-
* Render a Standard Schema {@link StandardSchemaV1.Issue} into a human-readable
|
|
108
|
-
* string that includes the failing field's path.
|
|
109
|
-
*
|
|
110
|
-
* Example output:
|
|
111
|
-
* - `at items[0].quantity: Expected number, received undefined`
|
|
112
|
-
* - `at customerId: Expected string, received undefined`
|
|
113
|
-
* - `at user["first name"]: Expected string, received undefined`
|
|
114
|
-
* - `Validation error` *(no path)*
|
|
115
|
-
*
|
|
116
|
-
* Path segments come either as bare `PropertyKey` values or as
|
|
117
|
-
* `{ key: PropertyKey }` objects (per the spec); both are normalized.
|
|
118
|
-
* - Numeric keys → `[N]`
|
|
119
|
-
* - String keys that are valid JS identifiers → bare (first) or `.key`
|
|
120
|
-
* - String keys that aren't valid identifiers → `["..."]` with JSON-style
|
|
121
|
-
* escaping (handles dots, spaces, leading digits, the empty string, the
|
|
122
|
-
* literal string `"0"`, embedded quotes, etc.)
|
|
123
|
-
* - Symbol / other `PropertyKey` → `[Symbol(name)]`
|
|
124
|
-
*/
|
|
125
|
-
function formatIssue(issue) {
|
|
126
|
-
if (issue.path === void 0 || issue.path.length === 0) return issue.message;
|
|
127
|
-
let path = "";
|
|
128
|
-
for (let i = 0; i < issue.path.length; i++) {
|
|
129
|
-
const segment = issue.path[i];
|
|
130
|
-
const key = segment !== null && typeof segment === "object" && "key" in segment ? segment.key : segment;
|
|
131
|
-
if (typeof key === "number") path += `[${key}]`;
|
|
132
|
-
else if (typeof key === "string" && SAFE_IDENTIFIER.test(key)) path += i === 0 ? key : `.${key}`;
|
|
133
|
-
else if (typeof key === "string") path += `[${JSON.stringify(key)}]`;
|
|
134
|
-
else path += `[${String(key)}]`;
|
|
135
|
-
}
|
|
136
|
-
return `at ${path}: ${issue.message}`;
|
|
137
|
-
}
|
|
138
|
-
function summarizeIssues(issues) {
|
|
139
|
-
return issues.map(formatIssue).join("; ");
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
104
|
* Thrown when workflow input or output validation fails
|
|
143
105
|
*/
|
|
144
106
|
var WorkflowValidationError = class extends TypedClientError {
|
|
@@ -200,10 +162,12 @@ var UpdateValidationError = class extends TypedClientError {
|
|
|
200
162
|
*
|
|
201
163
|
* Used by `client.ts` (workflow operations) and `schedule.ts` (schedule
|
|
202
164
|
* operations) so the unexpected-rejection shape is identical across the
|
|
203
|
-
* typed client surface.
|
|
165
|
+
* typed client surface. Delegates to `_internal_makeResultAsync` from
|
|
166
|
+
* `@temporal-contract/contract` so the same wrapper is shared between the
|
|
167
|
+
* client and worker packages.
|
|
204
168
|
*/
|
|
205
169
|
function makeResultAsync(work) {
|
|
206
|
-
return
|
|
170
|
+
return _internal_makeResultAsync(work, (e) => new RuntimeClientError("unexpected", e));
|
|
207
171
|
}
|
|
208
172
|
/**
|
|
209
173
|
* Map a thrown error from `client.workflow.start` / `signalWithStart` into
|
|
@@ -272,9 +236,9 @@ var TypedScheduleClient = class {
|
|
|
272
236
|
create(workflowName, options) {
|
|
273
237
|
const work = async () => {
|
|
274
238
|
const definition = this.contract.workflows[workflowName];
|
|
275
|
-
if (!definition) return err(new WorkflowNotFoundError(
|
|
239
|
+
if (!definition) return err(new WorkflowNotFoundError(workflowName, Object.keys(this.contract.workflows)));
|
|
276
240
|
const inputResult = await definition.input["~standard"].validate(options.args);
|
|
277
|
-
if (inputResult.issues) return err(new WorkflowValidationError(
|
|
241
|
+
if (inputResult.issues) return err(new WorkflowValidationError(workflowName, "input", inputResult.issues));
|
|
278
242
|
try {
|
|
279
243
|
const overrides = options.action ?? {};
|
|
280
244
|
const action = {
|
|
@@ -351,6 +315,36 @@ function toTypedSearchAttributes(workflowDef, values) {
|
|
|
351
315
|
return pairs.length > 0 ? new TypedSearchAttributes(pairs) : void 0;
|
|
352
316
|
}
|
|
353
317
|
/**
|
|
318
|
+
* Shared pre-call ritual for the three contract-driven entry points that
|
|
319
|
+
* actually start a workflow (`startWorkflow`, `signalWithStart`,
|
|
320
|
+
* `executeWorkflow`):
|
|
321
|
+
*
|
|
322
|
+
* 1. Look up the workflow definition on the contract.
|
|
323
|
+
* 2. Surface a `WorkflowNotFoundError` if absent.
|
|
324
|
+
* 3. Validate `args` against the workflow's input schema.
|
|
325
|
+
* 4. Surface a `WorkflowValidationError` if validation fails.
|
|
326
|
+
* 5. Translate any caller-supplied `searchAttributes` into Temporal's
|
|
327
|
+
* `TypedSearchAttributes` shape (or `undefined`).
|
|
328
|
+
*
|
|
329
|
+
* `getHandle` deliberately keeps its own three-line lookup — it doesn't
|
|
330
|
+
* accept `args` or `searchAttributes`, so it can't share this helper. The
|
|
331
|
+
* call-specific extras (signal validation, post-call output validation,
|
|
332
|
+
* extended error classification) stay at the call site — those are the
|
|
333
|
+
* differentiators that make each method distinct.
|
|
334
|
+
*/
|
|
335
|
+
async function resolveDefinitionAndValidateInput(contract, workflowName, args, searchAttributes) {
|
|
336
|
+
const definition = contract.workflows[workflowName];
|
|
337
|
+
if (!definition) return err(createWorkflowNotFoundError(workflowName, contract));
|
|
338
|
+
const inputResult = await definition.input["~standard"].validate(args);
|
|
339
|
+
if (inputResult.issues) return err(createWorkflowValidationError(workflowName, "input", inputResult.issues));
|
|
340
|
+
const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
|
|
341
|
+
return ok({
|
|
342
|
+
definition,
|
|
343
|
+
validatedInput: inputResult.value,
|
|
344
|
+
typedSearchAttributes
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
354
348
|
* Typed Temporal client with neverthrow Result/ResultAsync pattern based on a contract
|
|
355
349
|
*
|
|
356
350
|
* Provides type-safe methods to start and execute workflows
|
|
@@ -434,16 +428,14 @@ var TypedClient = class TypedClient {
|
|
|
434
428
|
*/
|
|
435
429
|
startWorkflow(workflowName, { args, searchAttributes, ...temporalOptions }) {
|
|
436
430
|
const work = async () => {
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
439
|
-
const
|
|
440
|
-
if (inputResult.issues) return err(createWorkflowValidationError(workflowName, "input", inputResult.issues));
|
|
441
|
-
const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
|
|
431
|
+
const resolved = await resolveDefinitionAndValidateInput(this.contract, workflowName, args, searchAttributes);
|
|
432
|
+
if (resolved.isErr()) return err(resolved.error);
|
|
433
|
+
const { definition, validatedInput, typedSearchAttributes } = resolved.value;
|
|
442
434
|
try {
|
|
443
435
|
const handle = await this.client.workflow.start(workflowName, {
|
|
444
436
|
...temporalOptions,
|
|
445
437
|
taskQueue: this.contract.taskQueue,
|
|
446
|
-
args: [
|
|
438
|
+
args: [validatedInput],
|
|
447
439
|
...typedSearchAttributes ? { typedSearchAttributes } : {}
|
|
448
440
|
});
|
|
449
441
|
return ok(this.createTypedHandle(handle, definition));
|
|
@@ -481,20 +473,18 @@ var TypedClient = class TypedClient {
|
|
|
481
473
|
*/
|
|
482
474
|
signalWithStart(workflowName, { args, signalName, signalArgs, searchAttributes, ...temporalOptions }) {
|
|
483
475
|
const work = async () => {
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
const
|
|
487
|
-
if (inputResult.issues) return err(createWorkflowValidationError(workflowName, "input", inputResult.issues));
|
|
476
|
+
const resolved = await resolveDefinitionAndValidateInput(this.contract, workflowName, args, searchAttributes);
|
|
477
|
+
if (resolved.isErr()) return err(resolved.error);
|
|
478
|
+
const { definition, validatedInput, typedSearchAttributes } = resolved.value;
|
|
488
479
|
const signalDef = definition.signals?.[signalName];
|
|
489
|
-
if (!signalDef) return err(new SignalValidationError(signalName, [{ message: `Signal "${signalName}" is not declared on workflow "${
|
|
480
|
+
if (!signalDef) return err(new SignalValidationError(signalName, [{ message: `Signal "${signalName}" is not declared on workflow "${workflowName}".` }]));
|
|
490
481
|
const signalInputResult = await signalDef.input["~standard"].validate(signalArgs);
|
|
491
482
|
if (signalInputResult.issues) return err(new SignalValidationError(signalName, signalInputResult.issues));
|
|
492
|
-
const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
|
|
493
483
|
try {
|
|
494
484
|
const handle = await this.client.workflow.signalWithStart(workflowName, {
|
|
495
485
|
...temporalOptions,
|
|
496
486
|
taskQueue: this.contract.taskQueue,
|
|
497
|
-
args: [
|
|
487
|
+
args: [validatedInput],
|
|
498
488
|
signal: signalName,
|
|
499
489
|
signalArgs: [signalInputResult.value],
|
|
500
490
|
...typedSearchAttributes ? { typedSearchAttributes } : {}
|
|
@@ -529,16 +519,14 @@ var TypedClient = class TypedClient {
|
|
|
529
519
|
*/
|
|
530
520
|
executeWorkflow(workflowName, { args, searchAttributes, ...temporalOptions }) {
|
|
531
521
|
const work = async () => {
|
|
532
|
-
const
|
|
533
|
-
if (
|
|
534
|
-
const
|
|
535
|
-
if (inputResult.issues) return err(createWorkflowValidationError(workflowName, "input", inputResult.issues));
|
|
536
|
-
const typedSearchAttributes = toTypedSearchAttributes(definition, searchAttributes);
|
|
522
|
+
const resolved = await resolveDefinitionAndValidateInput(this.contract, workflowName, args, searchAttributes);
|
|
523
|
+
if (resolved.isErr()) return err(resolved.error);
|
|
524
|
+
const { definition, validatedInput, typedSearchAttributes } = resolved.value;
|
|
537
525
|
try {
|
|
538
526
|
const result = await this.client.workflow.execute(workflowName, {
|
|
539
527
|
...temporalOptions,
|
|
540
528
|
taskQueue: this.contract.taskQueue,
|
|
541
|
-
args: [
|
|
529
|
+
args: [validatedInput],
|
|
542
530
|
...typedSearchAttributes ? { typedSearchAttributes } : {}
|
|
543
531
|
});
|
|
544
532
|
const outputResult = await definition.output["~standard"].validate(result);
|