@rivetkit/workflow-engine 0.0.0-main.72cbc7c → 0.0.0-main.79e97f1
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/schemas/v1.ts +25 -0
- package/dist/tsup/{chunk-CIDHCIH7.js → chunk-DTS4S7RT.js} +190 -79
- package/dist/tsup/chunk-DTS4S7RT.js.map +1 -0
- package/dist/tsup/{chunk-SFJQFMCW.cjs → chunk-KLHCG2KY.cjs} +190 -79
- package/dist/tsup/chunk-KLHCG2KY.cjs.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +45 -13
- package/dist/tsup/index.d.ts +45 -13
- package/dist/tsup/index.js +1 -1
- package/dist/tsup/testing.cjs +23 -23
- package/dist/tsup/testing.js +1 -1
- package/package.json +1 -1
- package/schemas/serde.ts +17 -3
- package/schemas/v1.bare +10 -1
- package/schemas/versioned.ts +1 -0
- package/src/context.ts +140 -49
- package/src/driver.ts +6 -0
- package/src/index.ts +41 -21
- package/src/location.ts +1 -1
- package/src/storage.ts +6 -2
- package/src/types.ts +20 -3
- package/dist/tsup/chunk-CIDHCIH7.js.map +0 -1
- package/dist/tsup/chunk-SFJQFMCW.cjs.map +0 -1
package/dist/tsup/index.d.cts
CHANGED
|
@@ -101,10 +101,20 @@ interface RemovedEntry {
|
|
|
101
101
|
originalType: EntryKindType;
|
|
102
102
|
originalName?: string;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Version check entry data - records which version of a code path this
|
|
106
|
+
* workflow instance is pinned to at a given location.
|
|
107
|
+
*/
|
|
108
|
+
interface VersionCheckEntry {
|
|
109
|
+
/** The version this instance resolved to at this location. */
|
|
110
|
+
resolved: number;
|
|
111
|
+
/** The `latest` value seen when this entry was first resolved (diagnostics). */
|
|
112
|
+
latest: number;
|
|
113
|
+
}
|
|
104
114
|
/**
|
|
105
115
|
* All possible entry kind types.
|
|
106
116
|
*/
|
|
107
|
-
type EntryKindType = "step" | "loop" | "sleep" | "message" | "rollback_checkpoint" | "join" | "race" | "removed";
|
|
117
|
+
type EntryKindType = "step" | "loop" | "sleep" | "message" | "rollback_checkpoint" | "join" | "race" | "removed" | "version_check";
|
|
108
118
|
/**
|
|
109
119
|
* Type-specific entry data.
|
|
110
120
|
*/
|
|
@@ -132,6 +142,9 @@ type EntryKind = {
|
|
|
132
142
|
} | {
|
|
133
143
|
type: "removed";
|
|
134
144
|
data: RemovedEntry;
|
|
145
|
+
} | {
|
|
146
|
+
type: "version_check";
|
|
147
|
+
data: VersionCheckEntry;
|
|
135
148
|
};
|
|
136
149
|
/**
|
|
137
150
|
* An entry in the workflow history.
|
|
@@ -345,6 +358,8 @@ interface StepConfig<T> {
|
|
|
345
358
|
retryBackoffMax?: number;
|
|
346
359
|
/** Timeout in ms for step execution (default: 30000). Set to 0 to disable. */
|
|
347
360
|
timeout?: number;
|
|
361
|
+
/** If true, step timeouts retry like any other error instead of failing immediately as critical. Default: false. */
|
|
362
|
+
retryOnTimeout?: boolean;
|
|
348
363
|
}
|
|
349
364
|
type TryStepCatchKind = "critical" | "timeout" | "exhausted" | "rollback";
|
|
350
365
|
interface TryStepFailure {
|
|
@@ -398,7 +413,7 @@ type LoopResult<S, T> = {
|
|
|
398
413
|
* Stateless loops (state = undefined) may return void/undefined, which is treated as
|
|
399
414
|
* `Loop.continue(undefined)`.
|
|
400
415
|
*/
|
|
401
|
-
type LoopIterationResult<S, T> = Promise<LoopResult<S, T> | (S extends undefined ?
|
|
416
|
+
type LoopIterationResult<S, T> = Promise<LoopResult<S, T> | (S extends undefined ? undefined : never)>;
|
|
402
417
|
/**
|
|
403
418
|
* Configuration for a loop.
|
|
404
419
|
*/
|
|
@@ -456,6 +471,7 @@ interface WorkflowContextInterface {
|
|
|
456
471
|
value: T;
|
|
457
472
|
}>;
|
|
458
473
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
474
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
459
475
|
isEvicted(): boolean;
|
|
460
476
|
}
|
|
461
477
|
/**
|
|
@@ -555,6 +571,11 @@ interface KVWrite {
|
|
|
555
571
|
* See architecture.md "Isolation Model" for details.
|
|
556
572
|
*/
|
|
557
573
|
interface EngineDriver {
|
|
574
|
+
/**
|
|
575
|
+
* Requires each logical storage flush to reach `batch` as one indivisible
|
|
576
|
+
* unit. The driver must reject an oversized unit instead of splitting it.
|
|
577
|
+
*/
|
|
578
|
+
readonly atomicBatch?: boolean;
|
|
558
579
|
/**
|
|
559
580
|
* Get a value by key.
|
|
560
581
|
* Returns null if the key doesn't exist.
|
|
@@ -697,12 +718,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
697
718
|
*/
|
|
698
719
|
evict(): void;
|
|
699
720
|
/**
|
|
700
|
-
* Wait for
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
721
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
722
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
723
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
724
|
+
* long-lived run abort signal.
|
|
704
725
|
*/
|
|
705
|
-
|
|
726
|
+
private sleepOrEvict;
|
|
706
727
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
707
728
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
708
729
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
|
@@ -713,7 +734,9 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
713
734
|
*
|
|
714
735
|
* Note: This does NOT cancel the underlying operation. JavaScript Promises
|
|
715
736
|
* cannot be cancelled once started. When a timeout occurs:
|
|
716
|
-
* - The step is
|
|
737
|
+
* - The step is rejected with StepTimeoutError. By default this is treated
|
|
738
|
+
* as a critical failure with no retry. Set retryOnTimeout: true on the
|
|
739
|
+
* step config to retry timeouts like any other error.
|
|
717
740
|
* - The underlying async operation continues running in the background
|
|
718
741
|
* - Any side effects from the operation may still occur
|
|
719
742
|
*
|
|
@@ -777,8 +800,22 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
777
800
|
private executeRace;
|
|
778
801
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
779
802
|
private executeRemoved;
|
|
803
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
804
|
+
private executeGetVersion;
|
|
805
|
+
/**
|
|
806
|
+
* Returns true if any history entry under the current location scope
|
|
807
|
+
* (other than `excludeKey`) has not yet been visited this run. Used by
|
|
808
|
+
* getVersion to detect an old in-flight instance whose scope was already
|
|
809
|
+
* executed by code that predates a version gate.
|
|
810
|
+
*/
|
|
811
|
+
private hasUnvisitedUnderCurrentScope;
|
|
780
812
|
}
|
|
781
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Extract structured error information from an error.
|
|
816
|
+
*/
|
|
817
|
+
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
818
|
+
|
|
782
819
|
/**
|
|
783
820
|
* Thrown from steps to prevent retry.
|
|
784
821
|
* Use this when an error is unrecoverable and retrying would be pointless.
|
|
@@ -883,11 +920,6 @@ declare class EntryInProgressError extends Error {
|
|
|
883
920
|
constructor();
|
|
884
921
|
}
|
|
885
922
|
|
|
886
|
-
/**
|
|
887
|
-
* Extract structured error information from an error.
|
|
888
|
-
*/
|
|
889
|
-
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
890
|
-
|
|
891
923
|
/**
|
|
892
924
|
* Check if a path segment is a loop iteration marker.
|
|
893
925
|
*/
|
package/dist/tsup/index.d.ts
CHANGED
|
@@ -101,10 +101,20 @@ interface RemovedEntry {
|
|
|
101
101
|
originalType: EntryKindType;
|
|
102
102
|
originalName?: string;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Version check entry data - records which version of a code path this
|
|
106
|
+
* workflow instance is pinned to at a given location.
|
|
107
|
+
*/
|
|
108
|
+
interface VersionCheckEntry {
|
|
109
|
+
/** The version this instance resolved to at this location. */
|
|
110
|
+
resolved: number;
|
|
111
|
+
/** The `latest` value seen when this entry was first resolved (diagnostics). */
|
|
112
|
+
latest: number;
|
|
113
|
+
}
|
|
104
114
|
/**
|
|
105
115
|
* All possible entry kind types.
|
|
106
116
|
*/
|
|
107
|
-
type EntryKindType = "step" | "loop" | "sleep" | "message" | "rollback_checkpoint" | "join" | "race" | "removed";
|
|
117
|
+
type EntryKindType = "step" | "loop" | "sleep" | "message" | "rollback_checkpoint" | "join" | "race" | "removed" | "version_check";
|
|
108
118
|
/**
|
|
109
119
|
* Type-specific entry data.
|
|
110
120
|
*/
|
|
@@ -132,6 +142,9 @@ type EntryKind = {
|
|
|
132
142
|
} | {
|
|
133
143
|
type: "removed";
|
|
134
144
|
data: RemovedEntry;
|
|
145
|
+
} | {
|
|
146
|
+
type: "version_check";
|
|
147
|
+
data: VersionCheckEntry;
|
|
135
148
|
};
|
|
136
149
|
/**
|
|
137
150
|
* An entry in the workflow history.
|
|
@@ -345,6 +358,8 @@ interface StepConfig<T> {
|
|
|
345
358
|
retryBackoffMax?: number;
|
|
346
359
|
/** Timeout in ms for step execution (default: 30000). Set to 0 to disable. */
|
|
347
360
|
timeout?: number;
|
|
361
|
+
/** If true, step timeouts retry like any other error instead of failing immediately as critical. Default: false. */
|
|
362
|
+
retryOnTimeout?: boolean;
|
|
348
363
|
}
|
|
349
364
|
type TryStepCatchKind = "critical" | "timeout" | "exhausted" | "rollback";
|
|
350
365
|
interface TryStepFailure {
|
|
@@ -398,7 +413,7 @@ type LoopResult<S, T> = {
|
|
|
398
413
|
* Stateless loops (state = undefined) may return void/undefined, which is treated as
|
|
399
414
|
* `Loop.continue(undefined)`.
|
|
400
415
|
*/
|
|
401
|
-
type LoopIterationResult<S, T> = Promise<LoopResult<S, T> | (S extends undefined ?
|
|
416
|
+
type LoopIterationResult<S, T> = Promise<LoopResult<S, T> | (S extends undefined ? undefined : never)>;
|
|
402
417
|
/**
|
|
403
418
|
* Configuration for a loop.
|
|
404
419
|
*/
|
|
@@ -456,6 +471,7 @@ interface WorkflowContextInterface {
|
|
|
456
471
|
value: T;
|
|
457
472
|
}>;
|
|
458
473
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
474
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
459
475
|
isEvicted(): boolean;
|
|
460
476
|
}
|
|
461
477
|
/**
|
|
@@ -555,6 +571,11 @@ interface KVWrite {
|
|
|
555
571
|
* See architecture.md "Isolation Model" for details.
|
|
556
572
|
*/
|
|
557
573
|
interface EngineDriver {
|
|
574
|
+
/**
|
|
575
|
+
* Requires each logical storage flush to reach `batch` as one indivisible
|
|
576
|
+
* unit. The driver must reject an oversized unit instead of splitting it.
|
|
577
|
+
*/
|
|
578
|
+
readonly atomicBatch?: boolean;
|
|
558
579
|
/**
|
|
559
580
|
* Get a value by key.
|
|
560
581
|
* Returns null if the key doesn't exist.
|
|
@@ -697,12 +718,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
697
718
|
*/
|
|
698
719
|
evict(): void;
|
|
699
720
|
/**
|
|
700
|
-
* Wait for
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
721
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
722
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
723
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
724
|
+
* long-lived run abort signal.
|
|
704
725
|
*/
|
|
705
|
-
|
|
726
|
+
private sleepOrEvict;
|
|
706
727
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
707
728
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
708
729
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
|
@@ -713,7 +734,9 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
713
734
|
*
|
|
714
735
|
* Note: This does NOT cancel the underlying operation. JavaScript Promises
|
|
715
736
|
* cannot be cancelled once started. When a timeout occurs:
|
|
716
|
-
* - The step is
|
|
737
|
+
* - The step is rejected with StepTimeoutError. By default this is treated
|
|
738
|
+
* as a critical failure with no retry. Set retryOnTimeout: true on the
|
|
739
|
+
* step config to retry timeouts like any other error.
|
|
717
740
|
* - The underlying async operation continues running in the background
|
|
718
741
|
* - Any side effects from the operation may still occur
|
|
719
742
|
*
|
|
@@ -777,8 +800,22 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
777
800
|
private executeRace;
|
|
778
801
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
779
802
|
private executeRemoved;
|
|
803
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
804
|
+
private executeGetVersion;
|
|
805
|
+
/**
|
|
806
|
+
* Returns true if any history entry under the current location scope
|
|
807
|
+
* (other than `excludeKey`) has not yet been visited this run. Used by
|
|
808
|
+
* getVersion to detect an old in-flight instance whose scope was already
|
|
809
|
+
* executed by code that predates a version gate.
|
|
810
|
+
*/
|
|
811
|
+
private hasUnvisitedUnderCurrentScope;
|
|
780
812
|
}
|
|
781
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Extract structured error information from an error.
|
|
816
|
+
*/
|
|
817
|
+
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
818
|
+
|
|
782
819
|
/**
|
|
783
820
|
* Thrown from steps to prevent retry.
|
|
784
821
|
* Use this when an error is unrecoverable and retrying would be pointless.
|
|
@@ -883,11 +920,6 @@ declare class EntryInProgressError extends Error {
|
|
|
883
920
|
constructor();
|
|
884
921
|
}
|
|
885
922
|
|
|
886
|
-
/**
|
|
887
|
-
* Extract structured error information from an error.
|
|
888
|
-
*/
|
|
889
|
-
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
890
|
-
|
|
891
923
|
/**
|
|
892
924
|
* Check if a path segment is a loop iteration marker.
|
|
893
925
|
*/
|
package/dist/tsup/index.js
CHANGED
package/dist/tsup/testing.cjs
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkKLHCG2KYcjs = require('./chunk-KLHCG2KY.cjs');
|
|
51
51
|
|
|
52
52
|
// src/testing.ts
|
|
53
53
|
var InMemoryWorkflowMessageDriver = class {
|
|
@@ -97,7 +97,7 @@ var InMemoryWorkflowMessageDriver = class {
|
|
|
97
97
|
}
|
|
98
98
|
async waitForMessages(messageNames, abortSignal) {
|
|
99
99
|
if (abortSignal.aborted) {
|
|
100
|
-
throw new (0,
|
|
100
|
+
throw new (0, _chunkKLHCG2KYcjs.EvictedError)();
|
|
101
101
|
}
|
|
102
102
|
const nameSet = messageNames.length > 0 ? new Set(messageNames) : void 0;
|
|
103
103
|
if (this.#messages.some(
|
|
@@ -118,7 +118,7 @@ var InMemoryWorkflowMessageDriver = class {
|
|
|
118
118
|
},
|
|
119
119
|
abortSignal,
|
|
120
120
|
onAbort: () => {
|
|
121
|
-
waiter.reject(new (0,
|
|
121
|
+
waiter.reject(new (0, _chunkKLHCG2KYcjs.EvictedError)());
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
abortSignal.addEventListener("abort", waiter.onAbort, {
|
|
@@ -158,56 +158,56 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
158
158
|
__init4() {this.workerPollInterval = 100}
|
|
159
159
|
__init5() {this.messageDriver = this.#inMemoryMessageDriver}
|
|
160
160
|
async get(key) {
|
|
161
|
-
await
|
|
162
|
-
const entry = this.kv.get(
|
|
161
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
162
|
+
const entry = this.kv.get(_chunkKLHCG2KYcjs.keyToHex.call(void 0, key));
|
|
163
163
|
return _nullishCoalesce((entry == null ? void 0 : entry.value), () => ( null));
|
|
164
164
|
}
|
|
165
165
|
async set(key, value) {
|
|
166
|
-
await
|
|
167
|
-
this.kv.set(
|
|
166
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
167
|
+
this.kv.set(_chunkKLHCG2KYcjs.keyToHex.call(void 0, key), { key, value });
|
|
168
168
|
}
|
|
169
169
|
async delete(key) {
|
|
170
|
-
await
|
|
171
|
-
this.kv.delete(
|
|
170
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
171
|
+
this.kv.delete(_chunkKLHCG2KYcjs.keyToHex.call(void 0, key));
|
|
172
172
|
}
|
|
173
173
|
async deletePrefix(prefix) {
|
|
174
|
-
await
|
|
174
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
175
175
|
for (const [hexKey, entry] of this.kv) {
|
|
176
|
-
if (
|
|
176
|
+
if (_chunkKLHCG2KYcjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
177
177
|
this.kv.delete(hexKey);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async deleteRange(start, end) {
|
|
182
|
-
await
|
|
182
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
183
183
|
for (const [hexKey, entry] of this.kv) {
|
|
184
|
-
if (
|
|
184
|
+
if (_chunkKLHCG2KYcjs.compareKeys.call(void 0, entry.key, start) >= 0 && _chunkKLHCG2KYcjs.compareKeys.call(void 0, entry.key, end) < 0) {
|
|
185
185
|
this.kv.delete(hexKey);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
async list(prefix) {
|
|
190
|
-
await
|
|
190
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
191
191
|
const results = [];
|
|
192
192
|
for (const entry of this.kv.values()) {
|
|
193
|
-
if (
|
|
193
|
+
if (_chunkKLHCG2KYcjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
194
194
|
results.push({ key: entry.key, value: entry.value });
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
return results.sort((a, b) =>
|
|
197
|
+
return results.sort((a, b) => _chunkKLHCG2KYcjs.compareKeys.call(void 0, a.key, b.key));
|
|
198
198
|
}
|
|
199
199
|
async batch(writes) {
|
|
200
|
-
await
|
|
200
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
201
201
|
for (const { key, value } of writes) {
|
|
202
|
-
this.kv.set(
|
|
202
|
+
this.kv.set(_chunkKLHCG2KYcjs.keyToHex.call(void 0, key), { key, value });
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
async setAlarm(workflowId, wakeAt) {
|
|
206
|
-
await
|
|
206
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
207
207
|
this.alarms.set(workflowId, wakeAt);
|
|
208
208
|
}
|
|
209
209
|
async clearAlarm(workflowId) {
|
|
210
|
-
await
|
|
210
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, this.latency);
|
|
211
211
|
this.alarms.delete(workflowId);
|
|
212
212
|
}
|
|
213
213
|
async waitForMessages(messageNames, abortSignal) {
|
|
@@ -218,7 +218,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
218
218
|
}
|
|
219
219
|
while (true) {
|
|
220
220
|
if (abortSignal.aborted) {
|
|
221
|
-
throw new (0,
|
|
221
|
+
throw new (0, _chunkKLHCG2KYcjs.EvictedError)();
|
|
222
222
|
}
|
|
223
223
|
const messages = await this.messageDriver.receiveMessages({
|
|
224
224
|
names: messageNames.length > 0 ? messageNames : void 0,
|
|
@@ -228,7 +228,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
228
228
|
if (messages.length > 0) {
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
-
await
|
|
231
|
+
await _chunkKLHCG2KYcjs.sleep.call(void 0, Math.max(1, this.latency));
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
@@ -324,5 +324,5 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
|
|
327
|
-
exports.CancelledError =
|
|
327
|
+
exports.CancelledError = _chunkKLHCG2KYcjs.CancelledError; exports.CriticalError = _chunkKLHCG2KYcjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkKLHCG2KYcjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkKLHCG2KYcjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkKLHCG2KYcjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkKLHCG2KYcjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkKLHCG2KYcjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkKLHCG2KYcjs.EntryInProgressError; exports.EvictedError = _chunkKLHCG2KYcjs.EvictedError; exports.HistoryDivergedError = _chunkKLHCG2KYcjs.HistoryDivergedError; exports.InMemoryDriver = InMemoryDriver; exports.JoinError = _chunkKLHCG2KYcjs.JoinError; exports.Loop = _chunkKLHCG2KYcjs.Loop; exports.MessageWaitError = _chunkKLHCG2KYcjs.MessageWaitError; exports.RaceError = _chunkKLHCG2KYcjs.RaceError; exports.RollbackCheckpointError = _chunkKLHCG2KYcjs.RollbackCheckpointError; exports.RollbackError = _chunkKLHCG2KYcjs.RollbackError; exports.SleepError = _chunkKLHCG2KYcjs.SleepError; exports.StepExhaustedError = _chunkKLHCG2KYcjs.StepExhaustedError; exports.StepFailedError = _chunkKLHCG2KYcjs.StepFailedError; exports.WorkflowContextImpl = _chunkKLHCG2KYcjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkKLHCG2KYcjs.appendLoopIteration; exports.appendName = _chunkKLHCG2KYcjs.appendName; exports.createEntry = _chunkKLHCG2KYcjs.createEntry; exports.createHistorySnapshot = _chunkKLHCG2KYcjs.createHistorySnapshot; exports.createStorage = _chunkKLHCG2KYcjs.createStorage; exports.deleteEntriesWithPrefix = _chunkKLHCG2KYcjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkKLHCG2KYcjs.emptyLocation; exports.extractErrorInfo = _chunkKLHCG2KYcjs.extractErrorInfo; exports.flush = _chunkKLHCG2KYcjs.flush; exports.generateId = _chunkKLHCG2KYcjs.generateId; exports.getEntry = _chunkKLHCG2KYcjs.getEntry; exports.getOrCreateMetadata = _chunkKLHCG2KYcjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkKLHCG2KYcjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkKLHCG2KYcjs.isLoopIterationMarker; exports.loadMetadata = _chunkKLHCG2KYcjs.loadMetadata; exports.loadStorage = _chunkKLHCG2KYcjs.loadStorage; exports.locationToKey = _chunkKLHCG2KYcjs.locationToKey; exports.locationsEqual = _chunkKLHCG2KYcjs.locationsEqual; exports.parentLocation = _chunkKLHCG2KYcjs.parentLocation; exports.registerName = _chunkKLHCG2KYcjs.registerName; exports.replayWorkflowFromStep = _chunkKLHCG2KYcjs.replayWorkflowFromStep; exports.resolveName = _chunkKLHCG2KYcjs.resolveName; exports.runWorkflow = _chunkKLHCG2KYcjs.runWorkflow; exports.setEntry = _chunkKLHCG2KYcjs.setEntry;
|
|
328
328
|
//# sourceMappingURL=testing.cjs.map
|
package/dist/tsup/testing.js
CHANGED
package/package.json
CHANGED
package/schemas/serde.ts
CHANGED
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
EntryMetadata as InternalEntryMetadata,
|
|
19
19
|
EntryStatus as InternalEntryStatus,
|
|
20
20
|
Location as InternalLocation,
|
|
21
|
-
LoopIterationMarker as InternalLoopIterationMarker,
|
|
22
21
|
PathSegment as InternalPathSegment,
|
|
23
22
|
SleepState as InternalSleepState,
|
|
24
23
|
WorkflowState as InternalWorkflowState,
|
|
@@ -27,7 +26,6 @@ import {
|
|
|
27
26
|
CURRENT_VERSION,
|
|
28
27
|
ENTRY_METADATA_VERSIONED,
|
|
29
28
|
ENTRY_VERSIONED,
|
|
30
|
-
WORKFLOW_METADATA_VERSIONED,
|
|
31
29
|
} from "./versioned.js";
|
|
32
30
|
|
|
33
31
|
// === Helper: ArrayBuffer to/from utilities ===
|
|
@@ -74,7 +72,7 @@ function assertString(
|
|
|
74
72
|
/**
|
|
75
73
|
* Validate that a value is a number.
|
|
76
74
|
*/
|
|
77
|
-
function
|
|
75
|
+
function _assertNumber(
|
|
78
76
|
value: unknown,
|
|
79
77
|
context: string,
|
|
80
78
|
): asserts value is number {
|
|
@@ -309,6 +307,14 @@ function entryKindToBare(kind: InternalEntryKind): v1.EntryKind {
|
|
|
309
307
|
originalName: kind.data.originalName ?? null,
|
|
310
308
|
},
|
|
311
309
|
};
|
|
310
|
+
case "version_check":
|
|
311
|
+
return {
|
|
312
|
+
tag: "VersionCheckEntry",
|
|
313
|
+
val: {
|
|
314
|
+
resolved: kind.data.resolved,
|
|
315
|
+
latest: kind.data.latest,
|
|
316
|
+
},
|
|
317
|
+
};
|
|
312
318
|
}
|
|
313
319
|
}
|
|
314
320
|
|
|
@@ -398,6 +404,14 @@ function entryKindFromBare(kind: v1.EntryKind): InternalEntryKind {
|
|
|
398
404
|
originalName: kind.val.originalName ?? undefined,
|
|
399
405
|
},
|
|
400
406
|
};
|
|
407
|
+
case "VersionCheckEntry":
|
|
408
|
+
return {
|
|
409
|
+
type: "version_check",
|
|
410
|
+
data: {
|
|
411
|
+
resolved: kind.val.resolved,
|
|
412
|
+
latest: kind.val.latest,
|
|
413
|
+
},
|
|
414
|
+
};
|
|
401
415
|
default:
|
|
402
416
|
throw new Error(
|
|
403
417
|
`Unknown entry kind: ${(kind as { tag: string }).tag}`,
|
package/schemas/v1.bare
CHANGED
|
@@ -122,6 +122,14 @@ type RemovedEntry struct {
|
|
|
122
122
|
originalName: optional<str>
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
# MARK: Version Check Entry
|
|
126
|
+
type VersionCheckEntry struct {
|
|
127
|
+
# The version this instance resolved to at this location
|
|
128
|
+
resolved: u32
|
|
129
|
+
# The `latest` value seen when first resolved (diagnostics)
|
|
130
|
+
latest: u32
|
|
131
|
+
}
|
|
132
|
+
|
|
125
133
|
# MARK: Entry Kind
|
|
126
134
|
# Type-specific entry data
|
|
127
135
|
type EntryKind union {
|
|
@@ -132,7 +140,8 @@ type EntryKind union {
|
|
|
132
140
|
RollbackCheckpointEntry |
|
|
133
141
|
JoinEntry |
|
|
134
142
|
RaceEntry |
|
|
135
|
-
RemovedEntry
|
|
143
|
+
RemovedEntry |
|
|
144
|
+
VersionCheckEntry
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
# MARK: Entry
|