@rivetkit/workflow-engine 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.4e59a38
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-SFJQFMCW.cjs → chunk-OCUQRGRS.cjs} +184 -77
- package/dist/tsup/chunk-OCUQRGRS.cjs.map +1 -0
- package/dist/tsup/{chunk-CIDHCIH7.js → chunk-Z3WC5MXC.js} +184 -77
- package/dist/tsup/chunk-Z3WC5MXC.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +40 -13
- package/dist/tsup/index.d.ts +40 -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/index.ts +41 -21
- package/src/location.ts +1 -1
- 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.cjs
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkOCUQRGRScjs = require('./chunk-OCUQRGRS.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
@@ -89,5 +89,5 @@ var _chunkSFJQFMCWcjs = require('./chunk-SFJQFMCW.cjs');
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
exports.CancelledError =
|
|
92
|
+
exports.CancelledError = _chunkOCUQRGRScjs.CancelledError; exports.CriticalError = _chunkOCUQRGRScjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkOCUQRGRScjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkOCUQRGRScjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkOCUQRGRScjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkOCUQRGRScjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkOCUQRGRScjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkOCUQRGRScjs.EntryInProgressError; exports.EvictedError = _chunkOCUQRGRScjs.EvictedError; exports.HistoryDivergedError = _chunkOCUQRGRScjs.HistoryDivergedError; exports.JoinError = _chunkOCUQRGRScjs.JoinError; exports.Loop = _chunkOCUQRGRScjs.Loop; exports.MessageWaitError = _chunkOCUQRGRScjs.MessageWaitError; exports.RaceError = _chunkOCUQRGRScjs.RaceError; exports.RollbackCheckpointError = _chunkOCUQRGRScjs.RollbackCheckpointError; exports.RollbackError = _chunkOCUQRGRScjs.RollbackError; exports.SleepError = _chunkOCUQRGRScjs.SleepError; exports.StepExhaustedError = _chunkOCUQRGRScjs.StepExhaustedError; exports.StepFailedError = _chunkOCUQRGRScjs.StepFailedError; exports.WorkflowContextImpl = _chunkOCUQRGRScjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkOCUQRGRScjs.appendLoopIteration; exports.appendName = _chunkOCUQRGRScjs.appendName; exports.createEntry = _chunkOCUQRGRScjs.createEntry; exports.createHistorySnapshot = _chunkOCUQRGRScjs.createHistorySnapshot; exports.createStorage = _chunkOCUQRGRScjs.createStorage; exports.deleteEntriesWithPrefix = _chunkOCUQRGRScjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkOCUQRGRScjs.emptyLocation; exports.extractErrorInfo = _chunkOCUQRGRScjs.extractErrorInfo; exports.flush = _chunkOCUQRGRScjs.flush; exports.generateId = _chunkOCUQRGRScjs.generateId; exports.getEntry = _chunkOCUQRGRScjs.getEntry; exports.getOrCreateMetadata = _chunkOCUQRGRScjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkOCUQRGRScjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkOCUQRGRScjs.isLoopIterationMarker; exports.loadMetadata = _chunkOCUQRGRScjs.loadMetadata; exports.loadStorage = _chunkOCUQRGRScjs.loadStorage; exports.locationToKey = _chunkOCUQRGRScjs.locationToKey; exports.locationsEqual = _chunkOCUQRGRScjs.locationsEqual; exports.parentLocation = _chunkOCUQRGRScjs.parentLocation; exports.registerName = _chunkOCUQRGRScjs.registerName; exports.replayWorkflowFromStep = _chunkOCUQRGRScjs.replayWorkflowFromStep; exports.resolveName = _chunkOCUQRGRScjs.resolveName; exports.runWorkflow = _chunkOCUQRGRScjs.runWorkflow; exports.setEntry = _chunkOCUQRGRScjs.setEntry;
|
|
93
93
|
//# sourceMappingURL=index.cjs.map
|
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
|
/**
|
|
@@ -697,12 +713,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
697
713
|
*/
|
|
698
714
|
evict(): void;
|
|
699
715
|
/**
|
|
700
|
-
* Wait for
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
716
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
717
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
718
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
719
|
+
* long-lived run abort signal.
|
|
704
720
|
*/
|
|
705
|
-
|
|
721
|
+
private sleepOrEvict;
|
|
706
722
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
707
723
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
708
724
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
|
@@ -713,7 +729,9 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
713
729
|
*
|
|
714
730
|
* Note: This does NOT cancel the underlying operation. JavaScript Promises
|
|
715
731
|
* cannot be cancelled once started. When a timeout occurs:
|
|
716
|
-
* - The step is
|
|
732
|
+
* - The step is rejected with StepTimeoutError. By default this is treated
|
|
733
|
+
* as a critical failure with no retry. Set retryOnTimeout: true on the
|
|
734
|
+
* step config to retry timeouts like any other error.
|
|
717
735
|
* - The underlying async operation continues running in the background
|
|
718
736
|
* - Any side effects from the operation may still occur
|
|
719
737
|
*
|
|
@@ -777,8 +795,22 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
777
795
|
private executeRace;
|
|
778
796
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
779
797
|
private executeRemoved;
|
|
798
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
799
|
+
private executeGetVersion;
|
|
800
|
+
/**
|
|
801
|
+
* Returns true if any history entry under the current location scope
|
|
802
|
+
* (other than `excludeKey`) has not yet been visited this run. Used by
|
|
803
|
+
* getVersion to detect an old in-flight instance whose scope was already
|
|
804
|
+
* executed by code that predates a version gate.
|
|
805
|
+
*/
|
|
806
|
+
private hasUnvisitedUnderCurrentScope;
|
|
780
807
|
}
|
|
781
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Extract structured error information from an error.
|
|
811
|
+
*/
|
|
812
|
+
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
813
|
+
|
|
782
814
|
/**
|
|
783
815
|
* Thrown from steps to prevent retry.
|
|
784
816
|
* Use this when an error is unrecoverable and retrying would be pointless.
|
|
@@ -883,11 +915,6 @@ declare class EntryInProgressError extends Error {
|
|
|
883
915
|
constructor();
|
|
884
916
|
}
|
|
885
917
|
|
|
886
|
-
/**
|
|
887
|
-
* Extract structured error information from an error.
|
|
888
|
-
*/
|
|
889
|
-
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
890
|
-
|
|
891
918
|
/**
|
|
892
919
|
* Check if a path segment is a loop iteration marker.
|
|
893
920
|
*/
|
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
|
/**
|
|
@@ -697,12 +713,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
697
713
|
*/
|
|
698
714
|
evict(): void;
|
|
699
715
|
/**
|
|
700
|
-
* Wait for
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
716
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
717
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
718
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
719
|
+
* long-lived run abort signal.
|
|
704
720
|
*/
|
|
705
|
-
|
|
721
|
+
private sleepOrEvict;
|
|
706
722
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
707
723
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
708
724
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
|
@@ -713,7 +729,9 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
713
729
|
*
|
|
714
730
|
* Note: This does NOT cancel the underlying operation. JavaScript Promises
|
|
715
731
|
* cannot be cancelled once started. When a timeout occurs:
|
|
716
|
-
* - The step is
|
|
732
|
+
* - The step is rejected with StepTimeoutError. By default this is treated
|
|
733
|
+
* as a critical failure with no retry. Set retryOnTimeout: true on the
|
|
734
|
+
* step config to retry timeouts like any other error.
|
|
717
735
|
* - The underlying async operation continues running in the background
|
|
718
736
|
* - Any side effects from the operation may still occur
|
|
719
737
|
*
|
|
@@ -777,8 +795,22 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
777
795
|
private executeRace;
|
|
778
796
|
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
779
797
|
private executeRemoved;
|
|
798
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
799
|
+
private executeGetVersion;
|
|
800
|
+
/**
|
|
801
|
+
* Returns true if any history entry under the current location scope
|
|
802
|
+
* (other than `excludeKey`) has not yet been visited this run. Used by
|
|
803
|
+
* getVersion to detect an old in-flight instance whose scope was already
|
|
804
|
+
* executed by code that predates a version gate.
|
|
805
|
+
*/
|
|
806
|
+
private hasUnvisitedUnderCurrentScope;
|
|
780
807
|
}
|
|
781
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Extract structured error information from an error.
|
|
811
|
+
*/
|
|
812
|
+
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
813
|
+
|
|
782
814
|
/**
|
|
783
815
|
* Thrown from steps to prevent retry.
|
|
784
816
|
* Use this when an error is unrecoverable and retrying would be pointless.
|
|
@@ -883,11 +915,6 @@ declare class EntryInProgressError extends Error {
|
|
|
883
915
|
constructor();
|
|
884
916
|
}
|
|
885
917
|
|
|
886
|
-
/**
|
|
887
|
-
* Extract structured error information from an error.
|
|
888
|
-
*/
|
|
889
|
-
declare function extractErrorInfo(error: unknown): WorkflowError;
|
|
890
|
-
|
|
891
918
|
/**
|
|
892
919
|
* Check if a path segment is a loop iteration marker.
|
|
893
920
|
*/
|
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 _chunkOCUQRGRScjs = require('./chunk-OCUQRGRS.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, _chunkOCUQRGRScjs.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, _chunkOCUQRGRScjs.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 _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
162
|
+
const entry = this.kv.get(_chunkOCUQRGRScjs.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 _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
167
|
+
this.kv.set(_chunkOCUQRGRScjs.keyToHex.call(void 0, key), { key, value });
|
|
168
168
|
}
|
|
169
169
|
async delete(key) {
|
|
170
|
-
await
|
|
171
|
-
this.kv.delete(
|
|
170
|
+
await _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
171
|
+
this.kv.delete(_chunkOCUQRGRScjs.keyToHex.call(void 0, key));
|
|
172
172
|
}
|
|
173
173
|
async deletePrefix(prefix) {
|
|
174
|
-
await
|
|
174
|
+
await _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
175
175
|
for (const [hexKey, entry] of this.kv) {
|
|
176
|
-
if (
|
|
176
|
+
if (_chunkOCUQRGRScjs.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 _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
183
183
|
for (const [hexKey, entry] of this.kv) {
|
|
184
|
-
if (
|
|
184
|
+
if (_chunkOCUQRGRScjs.compareKeys.call(void 0, entry.key, start) >= 0 && _chunkOCUQRGRScjs.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 _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
191
191
|
const results = [];
|
|
192
192
|
for (const entry of this.kv.values()) {
|
|
193
|
-
if (
|
|
193
|
+
if (_chunkOCUQRGRScjs.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) => _chunkOCUQRGRScjs.compareKeys.call(void 0, a.key, b.key));
|
|
198
198
|
}
|
|
199
199
|
async batch(writes) {
|
|
200
|
-
await
|
|
200
|
+
await _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
201
201
|
for (const { key, value } of writes) {
|
|
202
|
-
this.kv.set(
|
|
202
|
+
this.kv.set(_chunkOCUQRGRScjs.keyToHex.call(void 0, key), { key, value });
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
async setAlarm(workflowId, wakeAt) {
|
|
206
|
-
await
|
|
206
|
+
await _chunkOCUQRGRScjs.sleep.call(void 0, this.latency);
|
|
207
207
|
this.alarms.set(workflowId, wakeAt);
|
|
208
208
|
}
|
|
209
209
|
async clearAlarm(workflowId) {
|
|
210
|
-
await
|
|
210
|
+
await _chunkOCUQRGRScjs.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, _chunkOCUQRGRScjs.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 _chunkOCUQRGRScjs.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 = _chunkOCUQRGRScjs.CancelledError; exports.CriticalError = _chunkOCUQRGRScjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkOCUQRGRScjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkOCUQRGRScjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkOCUQRGRScjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkOCUQRGRScjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkOCUQRGRScjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkOCUQRGRScjs.EntryInProgressError; exports.EvictedError = _chunkOCUQRGRScjs.EvictedError; exports.HistoryDivergedError = _chunkOCUQRGRScjs.HistoryDivergedError; exports.InMemoryDriver = InMemoryDriver; exports.JoinError = _chunkOCUQRGRScjs.JoinError; exports.Loop = _chunkOCUQRGRScjs.Loop; exports.MessageWaitError = _chunkOCUQRGRScjs.MessageWaitError; exports.RaceError = _chunkOCUQRGRScjs.RaceError; exports.RollbackCheckpointError = _chunkOCUQRGRScjs.RollbackCheckpointError; exports.RollbackError = _chunkOCUQRGRScjs.RollbackError; exports.SleepError = _chunkOCUQRGRScjs.SleepError; exports.StepExhaustedError = _chunkOCUQRGRScjs.StepExhaustedError; exports.StepFailedError = _chunkOCUQRGRScjs.StepFailedError; exports.WorkflowContextImpl = _chunkOCUQRGRScjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkOCUQRGRScjs.appendLoopIteration; exports.appendName = _chunkOCUQRGRScjs.appendName; exports.createEntry = _chunkOCUQRGRScjs.createEntry; exports.createHistorySnapshot = _chunkOCUQRGRScjs.createHistorySnapshot; exports.createStorage = _chunkOCUQRGRScjs.createStorage; exports.deleteEntriesWithPrefix = _chunkOCUQRGRScjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkOCUQRGRScjs.emptyLocation; exports.extractErrorInfo = _chunkOCUQRGRScjs.extractErrorInfo; exports.flush = _chunkOCUQRGRScjs.flush; exports.generateId = _chunkOCUQRGRScjs.generateId; exports.getEntry = _chunkOCUQRGRScjs.getEntry; exports.getOrCreateMetadata = _chunkOCUQRGRScjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkOCUQRGRScjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkOCUQRGRScjs.isLoopIterationMarker; exports.loadMetadata = _chunkOCUQRGRScjs.loadMetadata; exports.loadStorage = _chunkOCUQRGRScjs.loadStorage; exports.locationToKey = _chunkOCUQRGRScjs.locationToKey; exports.locationsEqual = _chunkOCUQRGRScjs.locationsEqual; exports.parentLocation = _chunkOCUQRGRScjs.parentLocation; exports.registerName = _chunkOCUQRGRScjs.registerName; exports.replayWorkflowFromStep = _chunkOCUQRGRScjs.replayWorkflowFromStep; exports.resolveName = _chunkOCUQRGRScjs.resolveName; exports.runWorkflow = _chunkOCUQRGRScjs.runWorkflow; exports.setEntry = _chunkOCUQRGRScjs.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
|