@dudousxd/nestjs-durable-core 0.29.1 → 0.30.0
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/index.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -226,6 +226,14 @@ interface StateStore {
|
|
|
226
226
|
createRun(run: WorkflowRun): Promise<void>;
|
|
227
227
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
228
228
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Hard-delete a run and all of its rows — the run plus its checkpoints, signal waiters, and
|
|
231
|
+
* normalized search-attribute rows. Unlike a cancelled run (which stays as terminal history), a
|
|
232
|
+
* deleted run is GONE: it no longer appears in {@link getRun} or {@link listRuns}. This removes
|
|
233
|
+
* exactly the one run — the engine's {@link WorkflowEngine.deleteRun} handles the child cascade.
|
|
234
|
+
* No-op if the run doesn't exist. (Token-keyed buffered signals are transient and left alone.)
|
|
235
|
+
*/
|
|
236
|
+
deleteRun(runId: string): Promise<void>;
|
|
229
237
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
230
238
|
/**
|
|
231
239
|
* Persist a checkpoint and advance the run atomically. Durable semantics depend on this
|
|
@@ -1501,6 +1509,17 @@ declare class WorkflowEngine {
|
|
|
1501
1509
|
cancelWhere(filter: Omit<RunQuery, 'limit' | 'offset'>, opts?: {
|
|
1502
1510
|
compensate?: boolean;
|
|
1503
1511
|
}): Promise<RunResult[]>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Hard-delete a run and its entire subtree. Unlike {@link cancel} (which marks a run `cancelled`
|
|
1514
|
+
* but keeps it as history), delete REMOVES the run and all its rows (checkpoints, signal waiters,
|
|
1515
|
+
* search-attribute rows) — it vanishes from {@link getRun} and {@link listRuns}. Use it to purge a
|
|
1516
|
+
* finished run whose data is being deleted (e.g. a pipeline run whose result rows are cleared).
|
|
1517
|
+
*
|
|
1518
|
+
* Cascades depth-first via {@link getRunChildren} so children are gone before the parent (no
|
|
1519
|
+
* orphaned child runs). Prefer {@link cancel} first for a live run — deleting one mid-flight orphans
|
|
1520
|
+
* its worker (its next checkpoint write fails). Returns the number of runs deleted (0 if absent).
|
|
1521
|
+
*/
|
|
1522
|
+
deleteRun(runId: string): Promise<number>;
|
|
1504
1523
|
/**
|
|
1505
1524
|
* Cascade cancellation to a run's children — both awaited (`ctx.child`, found via its live
|
|
1506
1525
|
* `child:<id>` waiter) and fire-and-forget (`ctx.startChild`, found via its `spawn:<id>`
|
|
@@ -1789,6 +1808,7 @@ declare class CodecStateStore implements StateStore {
|
|
|
1789
1808
|
createRun(run: WorkflowRun): Promise<void>;
|
|
1790
1809
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
1791
1810
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
1811
|
+
deleteRun(runId: string): Promise<void>;
|
|
1792
1812
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
1793
1813
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
1794
1814
|
transaction<T>(work: (tx: {
|
|
@@ -2025,6 +2045,7 @@ declare class InMemoryStateStore implements StateStore {
|
|
|
2025
2045
|
createRun(run: WorkflowRun): Promise<void>;
|
|
2026
2046
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
2027
2047
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
2048
|
+
deleteRun(runId: string): Promise<void>;
|
|
2028
2049
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
2029
2050
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
2030
2051
|
listIncompleteRuns(): Promise<WorkflowRun[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -226,6 +226,14 @@ interface StateStore {
|
|
|
226
226
|
createRun(run: WorkflowRun): Promise<void>;
|
|
227
227
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
228
228
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Hard-delete a run and all of its rows — the run plus its checkpoints, signal waiters, and
|
|
231
|
+
* normalized search-attribute rows. Unlike a cancelled run (which stays as terminal history), a
|
|
232
|
+
* deleted run is GONE: it no longer appears in {@link getRun} or {@link listRuns}. This removes
|
|
233
|
+
* exactly the one run — the engine's {@link WorkflowEngine.deleteRun} handles the child cascade.
|
|
234
|
+
* No-op if the run doesn't exist. (Token-keyed buffered signals are transient and left alone.)
|
|
235
|
+
*/
|
|
236
|
+
deleteRun(runId: string): Promise<void>;
|
|
229
237
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
230
238
|
/**
|
|
231
239
|
* Persist a checkpoint and advance the run atomically. Durable semantics depend on this
|
|
@@ -1501,6 +1509,17 @@ declare class WorkflowEngine {
|
|
|
1501
1509
|
cancelWhere(filter: Omit<RunQuery, 'limit' | 'offset'>, opts?: {
|
|
1502
1510
|
compensate?: boolean;
|
|
1503
1511
|
}): Promise<RunResult[]>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Hard-delete a run and its entire subtree. Unlike {@link cancel} (which marks a run `cancelled`
|
|
1514
|
+
* but keeps it as history), delete REMOVES the run and all its rows (checkpoints, signal waiters,
|
|
1515
|
+
* search-attribute rows) — it vanishes from {@link getRun} and {@link listRuns}. Use it to purge a
|
|
1516
|
+
* finished run whose data is being deleted (e.g. a pipeline run whose result rows are cleared).
|
|
1517
|
+
*
|
|
1518
|
+
* Cascades depth-first via {@link getRunChildren} so children are gone before the parent (no
|
|
1519
|
+
* orphaned child runs). Prefer {@link cancel} first for a live run — deleting one mid-flight orphans
|
|
1520
|
+
* its worker (its next checkpoint write fails). Returns the number of runs deleted (0 if absent).
|
|
1521
|
+
*/
|
|
1522
|
+
deleteRun(runId: string): Promise<number>;
|
|
1504
1523
|
/**
|
|
1505
1524
|
* Cascade cancellation to a run's children — both awaited (`ctx.child`, found via its live
|
|
1506
1525
|
* `child:<id>` waiter) and fire-and-forget (`ctx.startChild`, found via its `spawn:<id>`
|
|
@@ -1789,6 +1808,7 @@ declare class CodecStateStore implements StateStore {
|
|
|
1789
1808
|
createRun(run: WorkflowRun): Promise<void>;
|
|
1790
1809
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
1791
1810
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
1811
|
+
deleteRun(runId: string): Promise<void>;
|
|
1792
1812
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
1793
1813
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
1794
1814
|
transaction<T>(work: (tx: {
|
|
@@ -2025,6 +2045,7 @@ declare class InMemoryStateStore implements StateStore {
|
|
|
2025
2045
|
createRun(run: WorkflowRun): Promise<void>;
|
|
2026
2046
|
updateRun(runId: string, patch: Partial<WorkflowRun>): Promise<void>;
|
|
2027
2047
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
2048
|
+
deleteRun(runId: string): Promise<void>;
|
|
2028
2049
|
getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
|
|
2029
2050
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
2030
2051
|
listIncompleteRuns(): Promise<WorkflowRun[]>;
|
package/dist/index.js
CHANGED
|
@@ -2115,6 +2115,26 @@ var WorkflowEngine = class {
|
|
|
2115
2115
|
return results;
|
|
2116
2116
|
}
|
|
2117
2117
|
/**
|
|
2118
|
+
* Hard-delete a run and its entire subtree. Unlike {@link cancel} (which marks a run `cancelled`
|
|
2119
|
+
* but keeps it as history), delete REMOVES the run and all its rows (checkpoints, signal waiters,
|
|
2120
|
+
* search-attribute rows) — it vanishes from {@link getRun} and {@link listRuns}. Use it to purge a
|
|
2121
|
+
* finished run whose data is being deleted (e.g. a pipeline run whose result rows are cleared).
|
|
2122
|
+
*
|
|
2123
|
+
* Cascades depth-first via {@link getRunChildren} so children are gone before the parent (no
|
|
2124
|
+
* orphaned child runs). Prefer {@link cancel} first for a live run — deleting one mid-flight orphans
|
|
2125
|
+
* its worker (its next checkpoint write fails). Returns the number of runs deleted (0 if absent).
|
|
2126
|
+
*/
|
|
2127
|
+
async deleteRun(runId) {
|
|
2128
|
+
const run = await this.store.getRun(runId);
|
|
2129
|
+
if (!run) return 0;
|
|
2130
|
+
let deleted = 0;
|
|
2131
|
+
for (const childId of await this.getRunChildren(runId)) {
|
|
2132
|
+
deleted += await this.deleteRun(childId);
|
|
2133
|
+
}
|
|
2134
|
+
await this.store.deleteRun(runId);
|
|
2135
|
+
return deleted + 1;
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2118
2138
|
* Cascade cancellation to a run's children — both awaited (`ctx.child`, found via its live
|
|
2119
2139
|
* `child:<id>` waiter) and fire-and-forget (`ctx.startChild`, found via its `spawn:<id>`
|
|
2120
2140
|
* checkpoint). Recursive, so a whole subtree is cancelled; the terminal guard in `cancel` stops it
|
|
@@ -3274,6 +3294,9 @@ var CodecStateStore = class {
|
|
|
3274
3294
|
async getRun(runId) {
|
|
3275
3295
|
return this.decRun(await this.inner.getRun(runId));
|
|
3276
3296
|
}
|
|
3297
|
+
deleteRun(runId) {
|
|
3298
|
+
return this.inner.deleteRun(runId);
|
|
3299
|
+
}
|
|
3277
3300
|
async getCheckpoint(runId, seq) {
|
|
3278
3301
|
return this.decCp(await this.inner.getCheckpoint(runId, seq));
|
|
3279
3302
|
}
|
|
@@ -3668,6 +3691,16 @@ var InMemoryStateStore = class {
|
|
|
3668
3691
|
...run
|
|
3669
3692
|
} : null;
|
|
3670
3693
|
}
|
|
3694
|
+
async deleteRun(runId) {
|
|
3695
|
+
this.runs.delete(runId);
|
|
3696
|
+
for (const [key, cp] of this.checkpoints) {
|
|
3697
|
+
if (cp.runId === runId) this.checkpoints.delete(key);
|
|
3698
|
+
}
|
|
3699
|
+
for (const [token, waiter] of this.signalWaiters) {
|
|
3700
|
+
if (waiter.runId === runId) this.signalWaiters.delete(token);
|
|
3701
|
+
}
|
|
3702
|
+
this.reindexAttributes(runId, void 0);
|
|
3703
|
+
}
|
|
3671
3704
|
async getCheckpoint(runId, seq) {
|
|
3672
3705
|
const cp = this.checkpoints.get(this.key(runId, seq));
|
|
3673
3706
|
return cp ? {
|