@dudousxd/nestjs-durable-core 0.28.2 → 0.29.1
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 +245 -207
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -17
- package/dist/index.d.ts +13 -17
- package/dist/index.js +245 -207
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -472,8 +472,9 @@ type WorkflowCommand =
|
|
|
472
472
|
interface WorkflowDecision {
|
|
473
473
|
taskId: string;
|
|
474
474
|
runId: string;
|
|
475
|
-
/** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
|
|
476
|
-
|
|
475
|
+
/** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
|
|
476
|
+
* `cancelled` = the worker bailed at an op boundary because the run was cancelled mid-turn. */
|
|
477
|
+
status: 'continue' | 'completed' | 'failed' | 'cancelled';
|
|
477
478
|
/** New durable ops the replay produced this turn (status === 'continue'), ordered by seq. */
|
|
478
479
|
commands: WorkflowCommand[];
|
|
479
480
|
/** Final workflow output (status === 'completed'). */
|
|
@@ -1231,6 +1232,8 @@ declare class WorkflowEngine {
|
|
|
1231
1232
|
private readonly trackStepStart;
|
|
1232
1233
|
/** Where a freshly-started run executes — in-process by default (see {@link RunDispatcher}). */
|
|
1233
1234
|
private readonly runDispatcher;
|
|
1235
|
+
/** Per-key serialization for singleton workflows (admission, back-pressure, notify-on-release). */
|
|
1236
|
+
private readonly singletons;
|
|
1234
1237
|
/** Every registered workflow, keyed by `name@version` — so old versions stay runnable. */
|
|
1235
1238
|
private readonly workflows;
|
|
1236
1239
|
/** The newest registered version per workflow name — used to `start` new runs. */
|
|
@@ -1551,21 +1554,6 @@ declare class WorkflowEngine {
|
|
|
1551
1554
|
private completeStep;
|
|
1552
1555
|
/** Checkpoint a step that failed terminally, so the failure point is visible (not just the run). */
|
|
1553
1556
|
private failStep;
|
|
1554
|
-
/**
|
|
1555
|
-
* Whether `run` may run now under its singleton key: it's among the `limit` oldest in-flight runs
|
|
1556
|
-
* (running or suspended) sharing the key, by `(createdAt, id)` order. A consistent store gives every
|
|
1557
|
-
* instance the same ordering, so admission is race-free + FIFO.
|
|
1558
|
-
*/
|
|
1559
|
-
private admitSingleton;
|
|
1560
|
-
/**
|
|
1561
|
-
* Notify-on-release: a singleton run just settled (freeing a slot), so wake the gated waiters that
|
|
1562
|
-
* can now be admitted — immediately, instead of letting them sleep until their ~1s retry timer.
|
|
1563
|
-
* Dispatches up to `limit` of the oldest gated (`suspended` + same singleton tag) waiters by
|
|
1564
|
-
* `(createdAt, id)`; each re-checks admission in `runExecution` and runs only if it actually wins a
|
|
1565
|
-
* slot, so this never breaks the FIFO + race-free guarantees (the durable timer remains the
|
|
1566
|
-
* cross-instance / crash fallback — this just removes the poll latency on the happy path).
|
|
1567
|
-
*/
|
|
1568
|
-
private wakeNextSingletons;
|
|
1569
1557
|
private execute;
|
|
1570
1558
|
/**
|
|
1571
1559
|
* Advance a remote (cross-SDK) workflow one turn: hand its history to the executor (which dispatches
|
|
@@ -1573,6 +1561,14 @@ declare class WorkflowEngine {
|
|
|
1573
1561
|
* {@link runExecution}'s settle/suspend; the lease is held by {@link execute}. The result that lands
|
|
1574
1562
|
* us back here (a remote step finished, a timer fired) goes through `resume` like any TS workflow.
|
|
1575
1563
|
*/
|
|
1564
|
+
/**
|
|
1565
|
+
* Apply a terminal/suspended transition once: persist the new run status, emit the matching
|
|
1566
|
+
* lifecycle event, and (on completion/failure) wake a waiting parent. Both the TS and remote
|
|
1567
|
+
* executors funnel their completed/failed/suspended outcomes through here so a status update can
|
|
1568
|
+
* never drift from its event or `notifyParent` call. Does NOT touch the run lock — each executor
|
|
1569
|
+
* keeps its own lease handling (the TS executor's `finally`, the remote path's caller).
|
|
1570
|
+
*/
|
|
1571
|
+
private settleRun;
|
|
1576
1572
|
private runRemoteExecution;
|
|
1577
1573
|
/** The run's resolved durable ops as replay inputs: completed/failed steps + elapsed timers. */
|
|
1578
1574
|
private remoteHistory;
|
package/dist/index.d.ts
CHANGED
|
@@ -472,8 +472,9 @@ type WorkflowCommand =
|
|
|
472
472
|
interface WorkflowDecision {
|
|
473
473
|
taskId: string;
|
|
474
474
|
runId: string;
|
|
475
|
-
/** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
|
|
476
|
-
|
|
475
|
+
/** `continue` = produced `commands` and is blocked on an await; otherwise the run settles.
|
|
476
|
+
* `cancelled` = the worker bailed at an op boundary because the run was cancelled mid-turn. */
|
|
477
|
+
status: 'continue' | 'completed' | 'failed' | 'cancelled';
|
|
477
478
|
/** New durable ops the replay produced this turn (status === 'continue'), ordered by seq. */
|
|
478
479
|
commands: WorkflowCommand[];
|
|
479
480
|
/** Final workflow output (status === 'completed'). */
|
|
@@ -1231,6 +1232,8 @@ declare class WorkflowEngine {
|
|
|
1231
1232
|
private readonly trackStepStart;
|
|
1232
1233
|
/** Where a freshly-started run executes — in-process by default (see {@link RunDispatcher}). */
|
|
1233
1234
|
private readonly runDispatcher;
|
|
1235
|
+
/** Per-key serialization for singleton workflows (admission, back-pressure, notify-on-release). */
|
|
1236
|
+
private readonly singletons;
|
|
1234
1237
|
/** Every registered workflow, keyed by `name@version` — so old versions stay runnable. */
|
|
1235
1238
|
private readonly workflows;
|
|
1236
1239
|
/** The newest registered version per workflow name — used to `start` new runs. */
|
|
@@ -1551,21 +1554,6 @@ declare class WorkflowEngine {
|
|
|
1551
1554
|
private completeStep;
|
|
1552
1555
|
/** Checkpoint a step that failed terminally, so the failure point is visible (not just the run). */
|
|
1553
1556
|
private failStep;
|
|
1554
|
-
/**
|
|
1555
|
-
* Whether `run` may run now under its singleton key: it's among the `limit` oldest in-flight runs
|
|
1556
|
-
* (running or suspended) sharing the key, by `(createdAt, id)` order. A consistent store gives every
|
|
1557
|
-
* instance the same ordering, so admission is race-free + FIFO.
|
|
1558
|
-
*/
|
|
1559
|
-
private admitSingleton;
|
|
1560
|
-
/**
|
|
1561
|
-
* Notify-on-release: a singleton run just settled (freeing a slot), so wake the gated waiters that
|
|
1562
|
-
* can now be admitted — immediately, instead of letting them sleep until their ~1s retry timer.
|
|
1563
|
-
* Dispatches up to `limit` of the oldest gated (`suspended` + same singleton tag) waiters by
|
|
1564
|
-
* `(createdAt, id)`; each re-checks admission in `runExecution` and runs only if it actually wins a
|
|
1565
|
-
* slot, so this never breaks the FIFO + race-free guarantees (the durable timer remains the
|
|
1566
|
-
* cross-instance / crash fallback — this just removes the poll latency on the happy path).
|
|
1567
|
-
*/
|
|
1568
|
-
private wakeNextSingletons;
|
|
1569
1557
|
private execute;
|
|
1570
1558
|
/**
|
|
1571
1559
|
* Advance a remote (cross-SDK) workflow one turn: hand its history to the executor (which dispatches
|
|
@@ -1573,6 +1561,14 @@ declare class WorkflowEngine {
|
|
|
1573
1561
|
* {@link runExecution}'s settle/suspend; the lease is held by {@link execute}. The result that lands
|
|
1574
1562
|
* us back here (a remote step finished, a timer fired) goes through `resume` like any TS workflow.
|
|
1575
1563
|
*/
|
|
1564
|
+
/**
|
|
1565
|
+
* Apply a terminal/suspended transition once: persist the new run status, emit the matching
|
|
1566
|
+
* lifecycle event, and (on completion/failure) wake a waiting parent. Both the TS and remote
|
|
1567
|
+
* executors funnel their completed/failed/suspended outcomes through here so a status update can
|
|
1568
|
+
* never drift from its event or `notifyParent` call. Does NOT touch the run lock — each executor
|
|
1569
|
+
* keeps its own lease handling (the TS executor's `finally`, the remote path's caller).
|
|
1570
|
+
*/
|
|
1571
|
+
private settleRun;
|
|
1576
1572
|
private runRemoteExecution;
|
|
1577
1573
|
/** The run's resolved durable ops as replay inputs: completed/failed steps + elapsed timers. */
|
|
1578
1574
|
private remoteHistory;
|