@rivetkit/workflow-engine 0.0.0-sqlite-query-metrics-v2.f5d3605 → 0.0.0-sqlite-sync-3-0-1-release.95f6e2d
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-XRITRTKT.cjs → chunk-AO3IZAQ4.cjs} +56 -11
- package/dist/tsup/chunk-AO3IZAQ4.cjs.map +1 -0
- package/dist/tsup/{chunk-AAAPEYGX.js → chunk-OQDLVTH2.js} +56 -11
- package/dist/tsup/chunk-OQDLVTH2.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +14 -0
- package/dist/tsup/index.d.ts +14 -0
- package/dist/tsup/index.js +1 -1
- package/dist/tsup/testing.cjs +25 -25
- package/dist/tsup/testing.js +1 -1
- package/package.json +1 -1
- package/src/context.ts +77 -13
- package/dist/tsup/chunk-AAAPEYGX.js.map +0 -1
- package/dist/tsup/chunk-XRITRTKT.cjs.map +0 -1
|
@@ -1994,6 +1994,37 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
1994
1994
|
markVisited(key) {
|
|
1995
1995
|
this.visitedKeys.add(key);
|
|
1996
1996
|
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Mark all retained history under `location` as visited.
|
|
1999
|
+
*
|
|
2000
|
+
* Replay does not re-enter a settled scope, but its entries stay in history.
|
|
2001
|
+
* Without this, an enclosing validateComplete or getVersion treats them as
|
|
2002
|
+
* leftovers from changed workflow code.
|
|
2003
|
+
*/
|
|
2004
|
+
markSettledHistoryVisited(location) {
|
|
2005
|
+
for (const [key, entry] of this.storage.history.entries) {
|
|
2006
|
+
if (isLocationPrefix(location, entry.location)) {
|
|
2007
|
+
this.markVisited(key);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Mark the retained history of a resumed loop's finished iterations as
|
|
2013
|
+
* visited, because the loop continues from `resumeIteration` without
|
|
2014
|
+
* replaying them.
|
|
2015
|
+
*/
|
|
2016
|
+
markFinishedIterationsVisited(loopLocation, resumeIteration) {
|
|
2017
|
+
const loopSegment = loopLocation[loopLocation.length - 1];
|
|
2018
|
+
for (const [key, entry] of this.storage.history.entries) {
|
|
2019
|
+
if (!isLocationPrefix(loopLocation, entry.location)) {
|
|
2020
|
+
continue;
|
|
2021
|
+
}
|
|
2022
|
+
const iterationSegment = entry.location[loopLocation.length];
|
|
2023
|
+
if (iterationSegment && typeof iterationSegment !== "number" && iterationSegment.loop === loopSegment && iterationSegment.iteration < resumeIteration) {
|
|
2024
|
+
this.markVisited(key);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
1997
2028
|
/**
|
|
1998
2029
|
* Check if a name has already been used at the current location in this execution.
|
|
1999
2030
|
* Throws HistoryDivergedError if duplicate detected.
|
|
@@ -2521,6 +2552,9 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
2521
2552
|
this.driver,
|
|
2522
2553
|
existing.id
|
|
2523
2554
|
);
|
|
2555
|
+
if (metadata.status === "completed" || loopData.output !== void 0) {
|
|
2556
|
+
this.markSettledHistoryVisited(location);
|
|
2557
|
+
}
|
|
2524
2558
|
if (rollbackMode) {
|
|
2525
2559
|
if (loopData.output !== void 0) {
|
|
2526
2560
|
return loopData.output;
|
|
@@ -2538,6 +2572,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
2538
2572
|
entry = existing;
|
|
2539
2573
|
state = loopData.state;
|
|
2540
2574
|
iteration = loopData.iteration;
|
|
2575
|
+
this.markFinishedIterationsVisited(location, iteration);
|
|
2541
2576
|
if (rollbackMode) {
|
|
2542
2577
|
rollbackOutput = loopData.output;
|
|
2543
2578
|
rollbackIterationRan = rollbackOutput !== void 0;
|
|
@@ -3208,19 +3243,21 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3208
3243
|
`Expected join branch "${branchName}" in "${name}"`
|
|
3209
3244
|
);
|
|
3210
3245
|
}
|
|
3246
|
+
const branchLocation = appendName(
|
|
3247
|
+
this.storage,
|
|
3248
|
+
location,
|
|
3249
|
+
branchName
|
|
3250
|
+
);
|
|
3211
3251
|
if (branchStatus.status === "completed") {
|
|
3252
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
3212
3253
|
results[branchName] = branchStatus.output;
|
|
3213
3254
|
return;
|
|
3214
3255
|
}
|
|
3215
3256
|
if (branchStatus.status === "failed") {
|
|
3257
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
3216
3258
|
errors[branchName] = new Error(branchStatus.error);
|
|
3217
3259
|
return;
|
|
3218
3260
|
}
|
|
3219
|
-
const branchLocation = appendName(
|
|
3220
|
-
this.storage,
|
|
3221
|
-
location,
|
|
3222
|
-
branchName
|
|
3223
|
-
);
|
|
3224
3261
|
const branchCtx = this.createBranch(branchLocation);
|
|
3225
3262
|
branchStatus.status = "running";
|
|
3226
3263
|
branchStatus.error = void 0;
|
|
@@ -3312,6 +3349,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3312
3349
|
entry = existing;
|
|
3313
3350
|
const raceKind = existing.kind;
|
|
3314
3351
|
if (raceKind.data.winner !== null) {
|
|
3352
|
+
this.markSettledHistoryVisited(location);
|
|
3315
3353
|
const winnerStatus = raceKind.data.branches[raceKind.data.winner];
|
|
3316
3354
|
return {
|
|
3317
3355
|
winner: raceKind.data.winner,
|
|
@@ -3370,6 +3408,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3370
3408
|
}
|
|
3371
3409
|
}
|
|
3372
3410
|
if (hasWinner && winnerName !== null) {
|
|
3411
|
+
this.markSettledHistoryVisited(location);
|
|
3373
3412
|
return { winner: winnerName, value: winnerValue };
|
|
3374
3413
|
}
|
|
3375
3414
|
for (const branch of branches) {
|
|
@@ -3379,14 +3418,15 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3379
3418
|
`Expected race branch "${branch.name}" in "${name}"`
|
|
3380
3419
|
);
|
|
3381
3420
|
}
|
|
3382
|
-
if (branchStatus.status !== "pending" && branchStatus.status !== "running") {
|
|
3383
|
-
continue;
|
|
3384
|
-
}
|
|
3385
3421
|
const branchLocation = appendName(
|
|
3386
3422
|
this.storage,
|
|
3387
3423
|
location,
|
|
3388
3424
|
branch.name
|
|
3389
3425
|
);
|
|
3426
|
+
if (branchStatus.status !== "pending" && branchStatus.status !== "running") {
|
|
3427
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
3428
|
+
continue;
|
|
3429
|
+
}
|
|
3390
3430
|
const branchCtx = this.createBranch(
|
|
3391
3431
|
branchLocation,
|
|
3392
3432
|
raceAbortController
|
|
@@ -3394,7 +3434,12 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3394
3434
|
branchStatus.status = "running";
|
|
3395
3435
|
branchStatus.error = void 0;
|
|
3396
3436
|
entry.dirty = true;
|
|
3397
|
-
const
|
|
3437
|
+
const runBranch = async () => {
|
|
3438
|
+
const output = await branch.run(branchCtx);
|
|
3439
|
+
branchCtx.validateComplete();
|
|
3440
|
+
return output;
|
|
3441
|
+
};
|
|
3442
|
+
const branchPromise = runBranch().then(
|
|
3398
3443
|
async (output) => {
|
|
3399
3444
|
if (hasWinner) {
|
|
3400
3445
|
branchStatus.status = "completed";
|
|
@@ -3413,7 +3458,6 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3413
3458
|
hasWinner = true;
|
|
3414
3459
|
winnerName = branch.name;
|
|
3415
3460
|
winnerValue = output;
|
|
3416
|
-
branchCtx.validateComplete();
|
|
3417
3461
|
branchStatus.status = "completed";
|
|
3418
3462
|
branchStatus.output = output;
|
|
3419
3463
|
branchStatus.error = void 0;
|
|
@@ -3548,6 +3592,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
|
|
|
3548
3592
|
`Expected ${originalType} or removed at ${key}, found ${existing.kind.type}`
|
|
3549
3593
|
);
|
|
3550
3594
|
}
|
|
3595
|
+
this.markSettledHistoryVisited(location);
|
|
3551
3596
|
return;
|
|
3552
3597
|
}
|
|
3553
3598
|
const entry = createEntry(location, {
|
|
@@ -4402,4 +4447,4 @@ export {
|
|
|
4402
4447
|
runWorkflow,
|
|
4403
4448
|
replayWorkflowFromStep
|
|
4404
4449
|
};
|
|
4405
|
-
//# sourceMappingURL=chunk-
|
|
4450
|
+
//# sourceMappingURL=chunk-OQDLVTH2.js.map
|