@rivetkit/workflow-engine 2.3.4 → 2.3.5
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-Z3WC5MXC.js → chunk-DTS4S7RT.js} +7 -3
- package/dist/tsup/chunk-DTS4S7RT.js.map +1 -0
- package/dist/tsup/{chunk-OCUQRGRS.cjs → chunk-KLHCG2KY.cjs} +7 -3
- package/dist/tsup/chunk-KLHCG2KY.cjs.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +5 -0
- package/dist/tsup/index.d.ts +5 -0
- 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/src/driver.ts +6 -0
- package/src/storage.ts +6 -2
- package/dist/tsup/chunk-OCUQRGRS.cjs.map +0 -1
- package/dist/tsup/chunk-Z3WC5MXC.js.map +0 -1
package/dist/tsup/index.d.cts
CHANGED
|
@@ -571,6 +571,11 @@ interface KVWrite {
|
|
|
571
571
|
* See architecture.md "Isolation Model" for details.
|
|
572
572
|
*/
|
|
573
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;
|
|
574
579
|
/**
|
|
575
580
|
* Get a value by key.
|
|
576
581
|
* Returns null if the key doesn't exist.
|
package/dist/tsup/index.d.ts
CHANGED
|
@@ -571,6 +571,11 @@ interface KVWrite {
|
|
|
571
571
|
* See architecture.md "Isolation Model" for details.
|
|
572
572
|
*/
|
|
573
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;
|
|
574
579
|
/**
|
|
575
580
|
* Get a value by key.
|
|
576
581
|
* Returns null if the key doesn't exist.
|
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/src/driver.ts
CHANGED
|
@@ -30,6 +30,12 @@ export interface KVWrite {
|
|
|
30
30
|
* See architecture.md "Isolation Model" for details.
|
|
31
31
|
*/
|
|
32
32
|
export interface EngineDriver {
|
|
33
|
+
/**
|
|
34
|
+
* Requires each logical storage flush to reach `batch` as one indivisible
|
|
35
|
+
* unit. The driver must reject an oversized unit instead of splitting it.
|
|
36
|
+
*/
|
|
37
|
+
readonly atomicBatch?: boolean;
|
|
38
|
+
|
|
33
39
|
// === KV Operations ===
|
|
34
40
|
|
|
35
41
|
/**
|
package/src/storage.ts
CHANGED
|
@@ -318,8 +318,12 @@ export async function flush(
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
if (writes.length > 0) {
|
|
321
|
-
|
|
322
|
-
await driver.batch(
|
|
321
|
+
if (driver.atomicBatch) {
|
|
322
|
+
await driver.batch(writes);
|
|
323
|
+
} else {
|
|
324
|
+
for (const chunk of splitBatchWrites(writes)) {
|
|
325
|
+
await driver.batch(chunk);
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
329
|
|