@rivetkit/workflow-engine 2.1.11-rc.1 → 2.2.1
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/tsup/{chunk-OYYWSC77.cjs → chunk-4SWXLWKL.cjs} +426 -54
- package/dist/tsup/chunk-4SWXLWKL.cjs.map +1 -0
- package/dist/tsup/{chunk-4ME2JBMC.js → chunk-UMFB2AR3.js} +426 -54
- package/dist/tsup/chunk-UMFB2AR3.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +44 -1
- package/dist/tsup/index.d.ts +44 -1
- package/dist/tsup/index.js +1 -1
- package/dist/tsup/testing.cjs +23 -23
- package/dist/tsup/testing.d.cts +1 -1
- package/dist/tsup/testing.d.ts +1 -1
- package/dist/tsup/testing.js +1 -1
- package/package.json +1 -1
- package/src/context.ts +592 -75
- package/src/index.ts +8 -0
- package/src/types.ts +53 -0
- package/dist/tsup/chunk-4ME2JBMC.js.map +0 -1
- package/dist/tsup/chunk-OYYWSC77.cjs.map +0 -1
package/src/index.ts
CHANGED
|
@@ -93,6 +93,14 @@ export type {
|
|
|
93
93
|
StepConfig,
|
|
94
94
|
StepEntry,
|
|
95
95
|
Storage,
|
|
96
|
+
TryBlockCatchKind,
|
|
97
|
+
TryBlockConfig,
|
|
98
|
+
TryBlockFailure,
|
|
99
|
+
TryBlockResult,
|
|
100
|
+
TryStepCatchKind,
|
|
101
|
+
TryStepConfig,
|
|
102
|
+
TryStepFailure,
|
|
103
|
+
TryStepResult,
|
|
96
104
|
WorkflowContextInterface,
|
|
97
105
|
WorkflowError,
|
|
98
106
|
WorkflowErrorEvent,
|
package/src/types.ts
CHANGED
|
@@ -401,6 +401,50 @@ export interface StepConfig<T> {
|
|
|
401
401
|
timeout?: number;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
+
export type TryStepCatchKind =
|
|
405
|
+
| "critical"
|
|
406
|
+
| "timeout"
|
|
407
|
+
| "exhausted"
|
|
408
|
+
| "rollback";
|
|
409
|
+
|
|
410
|
+
export interface TryStepFailure {
|
|
411
|
+
kind: TryStepCatchKind;
|
|
412
|
+
stepName: string;
|
|
413
|
+
attempts: number;
|
|
414
|
+
error: WorkflowError;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export type TryStepResult<T> =
|
|
418
|
+
| { ok: true; value: T }
|
|
419
|
+
| { ok: false; failure: TryStepFailure };
|
|
420
|
+
|
|
421
|
+
export interface TryStepConfig<T> extends StepConfig<T> {
|
|
422
|
+
catch?: readonly TryStepCatchKind[];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export type TryBlockCatchKind =
|
|
426
|
+
| "step"
|
|
427
|
+
| "join"
|
|
428
|
+
| "race"
|
|
429
|
+
| "rollback";
|
|
430
|
+
|
|
431
|
+
export interface TryBlockFailure {
|
|
432
|
+
source: "step" | "join" | "race" | "block";
|
|
433
|
+
name: string;
|
|
434
|
+
error: WorkflowError;
|
|
435
|
+
step?: TryStepFailure;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export type TryBlockResult<T> =
|
|
439
|
+
| { ok: true; value: T }
|
|
440
|
+
| { ok: false; failure: TryBlockFailure };
|
|
441
|
+
|
|
442
|
+
export interface TryBlockConfig<T> {
|
|
443
|
+
name: string;
|
|
444
|
+
run: (ctx: WorkflowContextInterface) => Promise<T>;
|
|
445
|
+
catch?: readonly TryBlockCatchKind[];
|
|
446
|
+
}
|
|
447
|
+
|
|
404
448
|
/**
|
|
405
449
|
* Result from a loop iteration.
|
|
406
450
|
*/
|
|
@@ -454,6 +498,15 @@ export interface WorkflowContextInterface {
|
|
|
454
498
|
step<T>(name: string, run: () => Promise<T>): Promise<T>;
|
|
455
499
|
step<T>(config: StepConfig<T>): Promise<T>;
|
|
456
500
|
|
|
501
|
+
tryStep<T>(name: string, run: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
502
|
+
tryStep<T>(config: TryStepConfig<T>): Promise<TryStepResult<T>>;
|
|
503
|
+
|
|
504
|
+
try<T>(
|
|
505
|
+
name: string,
|
|
506
|
+
run: (ctx: WorkflowContextInterface) => Promise<T>,
|
|
507
|
+
): Promise<TryBlockResult<T>>;
|
|
508
|
+
try<T>(config: TryBlockConfig<T>): Promise<TryBlockResult<T>>;
|
|
509
|
+
|
|
457
510
|
loop<T>(
|
|
458
511
|
name: string,
|
|
459
512
|
run: (
|