@dudousxd/nestjs-durable-core 0.73.0 → 0.75.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 +473 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +155 -12
- package/dist/index.d.ts +155 -12
- package/dist/index.js +471 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -995,6 +995,45 @@ interface StateStore {
|
|
|
995
995
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
|
996
996
|
/** List waiters whose `token` starts with `prefix` — used to fan out an event to its subscribers. */
|
|
997
997
|
listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
|
|
998
|
+
/**
|
|
999
|
+
* Whether run `runId` still has at least one waiter whose `token` starts with `tokenPrefix` (an
|
|
1000
|
+
* exact prefix: `%`/`_` in the prefix are literal characters, not wildcards). The `ctx.all` join
|
|
1001
|
+
* barrier asks this after each child settles, so it must stay O(1)-ish however many siblings are
|
|
1002
|
+
* still waiting — answer it with a bounded lookup, never by listing the whole group.
|
|
1003
|
+
*
|
|
1004
|
+
* Optional: a store without it keeps `ctx.all` correct, but the parent replays once per settled
|
|
1005
|
+
* child instead of once per fan.
|
|
1006
|
+
*/
|
|
1007
|
+
hasSignalWaiter?(runId: string, tokenPrefix: string): Promise<boolean>;
|
|
1008
|
+
/**
|
|
1009
|
+
* The waiters of the given runs. Lets the engine and the dashboard read what a page of runs (or
|
|
1010
|
+
* one run's children) is waiting on without scanning every waiter in the store, which a wide fan
|
|
1011
|
+
* fills with one row per running child. Callers pass ids in bounded batches.
|
|
1012
|
+
*
|
|
1013
|
+
* Optional: without it those reads fall back to {@link listSignalWaiters} over every waiter.
|
|
1014
|
+
*/
|
|
1015
|
+
listSignalWaitersByRun?(runIds: string[]): Promise<SignalWaiter[]>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Register a batch of awaited children: for each entry, put `waiter` and upsert `checkpoint` (the
|
|
1018
|
+
* parent's `running` placeholder for that child). `ctx.all` calls it once per chunk of a fan, so a
|
|
1019
|
+
* wide fan costs a handful of round trips instead of two per child.
|
|
1020
|
+
*
|
|
1021
|
+
* Every entry's waiter must be durable no later than its checkpoint: the engine reads an existing
|
|
1022
|
+
* placeholder as proof the waiter was put, and never re-puts it. Writing both in one transaction
|
|
1023
|
+
* satisfies that.
|
|
1024
|
+
*
|
|
1025
|
+
* Optional: without it the engine puts each waiter, then saves each checkpoint.
|
|
1026
|
+
*/
|
|
1027
|
+
registerChildWaits?(entries: ChildWait[]): Promise<void>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Atomically replace run `runId`'s checkpoints with `seq` in `[fromSeq, toSeq]` by the single
|
|
1030
|
+
* checkpoint `into`, whose `seq` lies in that range. `ctx.all` folds a settled group of children
|
|
1031
|
+
* into one checkpoint this way, so every later turn of the parent loads one row instead of one per
|
|
1032
|
+
* child. A delete over a contiguous seq range, served by the `(runId, seq)` primary key.
|
|
1033
|
+
*
|
|
1034
|
+
* Optional: without it a settled fan keeps one checkpoint per child.
|
|
1035
|
+
*/
|
|
1036
|
+
compactCheckpoints?(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
|
|
998
1037
|
/**
|
|
999
1038
|
* Delete the EXACT waiter row — `token` AND `runId` AND `seq` must all match — no-op if absent.
|
|
1000
1039
|
* Unlike {@link takeSignalWaiter}, which deletes ANY row for `token` (fine when the caller just won
|
|
@@ -1421,6 +1460,26 @@ interface StoreTransaction {
|
|
|
1421
1460
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
1422
1461
|
}
|
|
1423
1462
|
/** Binds an external signal `token` to the suspended run/step position waiting for it. */
|
|
1463
|
+
/** Options for {@link WorkflowCtx.all}. */
|
|
1464
|
+
interface AllOptions {
|
|
1465
|
+
/** `waitAll` (default) or `failFast` — see {@link WorkflowCtx.all}. */
|
|
1466
|
+
mode?: 'waitAll' | 'failFast';
|
|
1467
|
+
/**
|
|
1468
|
+
* The most children running at once. Unset sends the whole fan immediately. When set, children go
|
|
1469
|
+
* out in waves of `floor(concurrency / 2)`, two at a time (an odd limit runs one child under it):
|
|
1470
|
+
* a new wave starts as soon as an earlier one settles, so one slow child does not idle the rest of
|
|
1471
|
+
* the window. Each settled wave costs the parent one turn.
|
|
1472
|
+
*
|
|
1473
|
+
* Part of the fan's identity: child ids carry the wave, so changing it for an in-flight run is a
|
|
1474
|
+
* non-deterministic change like changing `inputs`.
|
|
1475
|
+
*/
|
|
1476
|
+
concurrency?: number;
|
|
1477
|
+
}
|
|
1478
|
+
/** One child of a fan as {@link StateStore.registerChildWaits} writes it. */
|
|
1479
|
+
interface ChildWait {
|
|
1480
|
+
waiter: SignalWaiter;
|
|
1481
|
+
checkpoint: StepCheckpoint;
|
|
1482
|
+
}
|
|
1424
1483
|
interface SignalWaiter {
|
|
1425
1484
|
token: string;
|
|
1426
1485
|
runId: string;
|
|
@@ -2287,13 +2346,11 @@ interface WorkflowCtx<A extends SearchAttributes = SearchAttributes> {
|
|
|
2287
2346
|
* so a fast sibling can still slip through and complete). Empty `inputs` returns `[]` with no side
|
|
2288
2347
|
* effects. The wait-all / fan-out counterpart to {@link child}; parity with the Python SDK's
|
|
2289
2348
|
* `gather_children`.
|
|
2349
|
+
*
|
|
2350
|
+
* `concurrency` caps how many children run at once (see {@link AllOptions.concurrency}).
|
|
2290
2351
|
*/
|
|
2291
|
-
all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?:
|
|
2292
|
-
|
|
2293
|
-
}): Promise<WorkflowOutputOf<C>[]>;
|
|
2294
|
-
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: {
|
|
2295
|
-
mode?: 'waitAll' | 'failFast';
|
|
2296
|
-
}): Promise<TOutput[]>;
|
|
2352
|
+
all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?: AllOptions): Promise<WorkflowOutputOf<C>[]>;
|
|
2353
|
+
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
|
|
2297
2354
|
/**
|
|
2298
2355
|
* Pause the run at this point until a human resumes it from the dashboard (or
|
|
2299
2356
|
* `engine.continue(runId)`). Records a visible `pending` checkpoint so the breakpoint shows up
|
|
@@ -2416,9 +2473,7 @@ interface DynamicWorkflowCtx<A extends SearchAttributes = SearchAttributes> exte
|
|
|
2416
2473
|
/** {@link WorkflowCtx.startChild} by workflow name. */
|
|
2417
2474
|
startChild(workflow: string, input: unknown, options?: string | ChildCallOptions): Promise<string>;
|
|
2418
2475
|
/** {@link WorkflowCtx.all} by workflow name. */
|
|
2419
|
-
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?:
|
|
2420
|
-
mode?: 'waitAll' | 'failFast';
|
|
2421
|
-
}): Promise<TOutput[]>;
|
|
2476
|
+
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
|
|
2422
2477
|
}
|
|
2423
2478
|
/** Result of executing or resuming a workflow run. */
|
|
2424
2479
|
interface RunResult {
|
|
@@ -3330,6 +3385,8 @@ declare class ScheduleNotFoundError extends Error {
|
|
|
3330
3385
|
interface ScheduleHost {
|
|
3331
3386
|
start(workflow: string, input: unknown, runId: string, opts?: StartOptions): Promise<RunResult>;
|
|
3332
3387
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
3388
|
+
/** True once the engine has begun shutting down; `tick` fires nothing more after that. */
|
|
3389
|
+
isDraining?(): boolean;
|
|
3333
3390
|
}
|
|
3334
3391
|
/** Engine-level knobs for the client. */
|
|
3335
3392
|
interface ScheduleClientOptions {
|
|
@@ -3742,6 +3799,8 @@ declare class WorkflowEngine {
|
|
|
3742
3799
|
/** Executions currently in flight, so a graceful shutdown can wait for them to settle. */
|
|
3743
3800
|
private readonly inflight;
|
|
3744
3801
|
private draining;
|
|
3802
|
+
/** Wait already spent on this shutdown before `drain()` (see `beginDrain`). */
|
|
3803
|
+
private drainSpentMs;
|
|
3745
3804
|
constructor(deps: WorkflowEngineDeps);
|
|
3746
3805
|
/**
|
|
3747
3806
|
* Register a **durable entity** (a virtual object): a keyed actor whose `handlers` run **serialized
|
|
@@ -3995,10 +4054,25 @@ declare class WorkflowEngine {
|
|
|
3995
4054
|
private findParentRunId;
|
|
3996
4055
|
/** Track an in-flight execution so {@link drain} can wait for it. */
|
|
3997
4056
|
private track;
|
|
4057
|
+
/**
|
|
4058
|
+
* Stop picking up new work without waiting: recovery, timer, schedule and timeout sweeps (and
|
|
4059
|
+
* their per-run lock loops) start nothing once this is called, and {@link runOne} returns null. A
|
|
4060
|
+
* poller calls it on its own shutdown so an in-flight sweep stops locking runs before it is awaited.
|
|
4061
|
+
*
|
|
4062
|
+
* `spentMs` is wait time ALREADY spent on this shutdown (the poller awaiting its in-flight sweep).
|
|
4063
|
+
* It is deducted from the budget of a later {@link drain}, so that wait plus the drain stay within
|
|
4064
|
+
* one `shutdownTimeoutMs`. Only time actually spent waiting is charged: time that merely passes
|
|
4065
|
+
* between this call and `drain()` (other hooks, the HTTP server closing) never is. Calls add up.
|
|
4066
|
+
*/
|
|
4067
|
+
beginDrain(spentMs?: number): void;
|
|
3998
4068
|
/**
|
|
3999
4069
|
* Graceful shutdown: stop picking up new runs (recovery/timer become no-ops) and wait for
|
|
4000
4070
|
* in-flight executions to settle, up to `timeoutMs`. Call from your app's shutdown hook so a
|
|
4001
4071
|
* deploy hands off cleanly instead of leaving runs to the lease timeout.
|
|
4072
|
+
*
|
|
4073
|
+
* `timeoutMs` is the total budget for waiting on in-flight runs; any wait already reported through
|
|
4074
|
+
* {@link beginDrain} (`spentMs`) is deducted, so a shutdown that already waited on the timer poll
|
|
4075
|
+
* for part of it waits only for the remainder. With nothing reported, the full `timeoutMs` applies.
|
|
4002
4076
|
*/
|
|
4003
4077
|
drain(timeoutMs?: number): Promise<void>;
|
|
4004
4078
|
/**
|
|
@@ -4199,6 +4273,32 @@ declare class WorkflowEngine {
|
|
|
4199
4273
|
* same way.
|
|
4200
4274
|
*/
|
|
4201
4275
|
private deliverSignal;
|
|
4276
|
+
/**
|
|
4277
|
+
* The `ctx.all` join barrier: true when `waiter` was one child of a fan (or of one wave of it)
|
|
4278
|
+
* whose siblings are still out, so waking the parent now would only replay the fan and re-suspend.
|
|
4279
|
+
* Skipping that wake is what keeps a fan of N children at O(N) work instead of N replays of N items.
|
|
4280
|
+
*
|
|
4281
|
+
* Safe because the LAST sibling to settle always wakes the parent: each child consumes its own
|
|
4282
|
+
* waiter before it asks, so whichever asks last sees none left. A failed child of a failFast fan
|
|
4283
|
+
* always wakes it. Anything that is not a `ctx.all` waiter, or a store that cannot answer the
|
|
4284
|
+
* question cheaply, wakes the parent as before.
|
|
4285
|
+
*/
|
|
4286
|
+
private fanStillWaiting;
|
|
4287
|
+
/**
|
|
4288
|
+
* Re-drive a run that just suspended on awaited children (a `ctx.all` fan or wave, a `ctx.child`)
|
|
4289
|
+
* which, by now, have settled.
|
|
4290
|
+
*
|
|
4291
|
+
* {@link execute} drops a wake that finds the run's lease held. So if a child settles while the
|
|
4292
|
+
* parent is still executing (the turn that dispatched it, or one woken by an earlier child), that
|
|
4293
|
+
* wake is spent, and the turn suspends on a snapshot that predates the child. With the `ctx.all`
|
|
4294
|
+
* barrier that wake was the only one the fan would get. Nothing would wake the run until the
|
|
4295
|
+
* `reconcileMs` sweep, minutes later.
|
|
4296
|
+
*
|
|
4297
|
+
* Called after the turn released its lease, so any child that settles from here on wakes the run
|
|
4298
|
+
* itself. Only re-drives for a group with no waiter left whose checkpoints are all settled, which
|
|
4299
|
+
* the next turn is then guaranteed to see — so it cannot loop.
|
|
4300
|
+
*/
|
|
4301
|
+
private redriveSettledChildren;
|
|
4202
4302
|
/**
|
|
4203
4303
|
* Deliver an external signal to the run waiting on `token`, resume it with `payload`, and return
|
|
4204
4304
|
* the run result — or null if no run is (or ends up) waiting for it.
|
|
@@ -4355,8 +4455,11 @@ declare class WorkflowEngine {
|
|
|
4355
4455
|
* so a completed parent (or a completed awaited child) would otherwise drop out of the tree. The
|
|
4356
4456
|
* `signal:child:<id>` checkpoint (the placeholder written when the parent first awaits the child,
|
|
4357
4457
|
* overwritten as completed/failed when it settles) persists across completion, so we read both and
|
|
4358
|
-
* dedupe — the edge stays stable for a finished run, not just a live one.
|
|
4458
|
+
* dedupe — the edge stays stable for a finished run, not just a live one. A settled `ctx.all`
|
|
4459
|
+
* group folded into one `fan:` checkpoint stands for every child in it.
|
|
4359
4460
|
*/
|
|
4461
|
+
/** The children `parentRunId` is awaiting right now, read off its own live `child:` waiters. */
|
|
4462
|
+
private awaitedChildIds;
|
|
4360
4463
|
getRunChildren(parentRunId: string): Promise<string[]>;
|
|
4361
4464
|
/** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
|
|
4362
4465
|
* `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
|
|
@@ -4979,9 +5082,24 @@ declare class GatherError extends Error {
|
|
|
4979
5082
|
declare class WorkflowSuspended extends Error {
|
|
4980
5083
|
/** Epoch ms to auto-resume (durable sleep), or undefined when waiting on an external signal. */
|
|
4981
5084
|
readonly wakeAt?: number | undefined;
|
|
5085
|
+
/** Set when awaited children are what the run is waiting on — see {@link FanJoin}. */
|
|
5086
|
+
readonly fan?: FanJoin | undefined;
|
|
4982
5087
|
/** Marks this as a control-flow signal — see {@link isWorkflowControlFlowSignal}. */
|
|
4983
5088
|
readonly [CONTROL_FLOW_SIGNAL] = true;
|
|
4984
|
-
constructor(wakeAt?: number);
|
|
5089
|
+
constructor(wakeAt?: number, fan?: FanJoin);
|
|
5090
|
+
}
|
|
5091
|
+
/**
|
|
5092
|
+
* What a run suspended on when it awaits children (`ctx.all`, `ctx.child`). For each group of
|
|
5093
|
+
* children, every waiter token starts with `waiterPrefix` and every `signal:child:` checkpoint name
|
|
5094
|
+
* with `checkpointPrefix`, so the engine can tell whether the group has settled without knowing the
|
|
5095
|
+
* children's ids.
|
|
5096
|
+
*/
|
|
5097
|
+
interface FanJoin {
|
|
5098
|
+
waits: FanWait[];
|
|
5099
|
+
}
|
|
5100
|
+
interface FanWait {
|
|
5101
|
+
waiterPrefix: string;
|
|
5102
|
+
checkpointPrefix: string;
|
|
4985
5103
|
}
|
|
4986
5104
|
/**
|
|
4987
5105
|
* Thrown by `ctx.continueAsNew(input)` to end the current run and hand off to a fresh execution of
|
|
@@ -5315,10 +5433,23 @@ declare function classifyWaiterToken(token: string): RunWaiting;
|
|
|
5315
5433
|
* state (no-worker, singleton, running) on top — none of which can be told apart from `wakeAt` alone.
|
|
5316
5434
|
*/
|
|
5317
5435
|
declare function resolveRunWaiting(run: WorkflowRun, waiterByRun: ReadonlyMap<string, SignalWaiter>): RunWaiting | undefined;
|
|
5436
|
+
/**
|
|
5437
|
+
* The signal waiters of `runIds`: through the store's {@link StateStore.listSignalWaitersByRun} in
|
|
5438
|
+
* bounded batches, or, for a store without it, one scan of every waiter filtered to those runs.
|
|
5439
|
+
*/
|
|
5440
|
+
declare function listSignalWaitersOfRuns(store: StateStore, runIds: readonly string[]): Promise<SignalWaiter[]>;
|
|
5318
5441
|
/** Index signal waiters by `runId`, keeping the first seen per run (a run parks on one waiter at a
|
|
5319
5442
|
* time in the sequential case; the earliest is the one it's blocked on). */
|
|
5320
5443
|
declare function indexWaitersByRun(waiters: readonly SignalWaiter[]): Map<string, SignalWaiter>;
|
|
5321
5444
|
|
|
5445
|
+
/**
|
|
5446
|
+
* The parent of a child run whose id the engine minted: a `ctx.all` child
|
|
5447
|
+
* (`<parent>.all.<seq>.<i>`, or `.w<k>.<i>` under a `concurrency` limit) or a `ctx.child` /
|
|
5448
|
+
* `ctx.startChild` child without an explicit id (`<parent>.child.<seq>`). Undefined for any other
|
|
5449
|
+
* run, including a child started with a caller-chosen id.
|
|
5450
|
+
*/
|
|
5451
|
+
declare function parentRunIdOf(runId: string): string | undefined;
|
|
5452
|
+
|
|
5322
5453
|
/**
|
|
5323
5454
|
* Transforms a payload value as it crosses the store boundary — e.g. encrypt-at-rest, compress, or
|
|
5324
5455
|
* redact PII. `decode` must be the exact inverse of `encode`. Both are synchronous (use a local
|
|
@@ -5365,6 +5496,14 @@ declare class CodecStateStore implements StateStore {
|
|
|
5365
5496
|
/** Forwarded verbatim — a count reads no payload. Bound only when the inner store counts, so the
|
|
5366
5497
|
* engine's facet/listing fallback still applies through the wrapper. */
|
|
5367
5498
|
readonly countRuns?: (query: Omit<RunQuery, 'limit' | 'offset'>) => Promise<number>;
|
|
5499
|
+
/** The placeholder checkpoints are encoded like any other checkpoint. */
|
|
5500
|
+
readonly registerChildWaits?: (entries: ChildWait[]) => Promise<void>;
|
|
5501
|
+
/** The folded checkpoint carries the children's outputs, so it is encoded. */
|
|
5502
|
+
readonly compactCheckpoints?: (runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint) => Promise<void>;
|
|
5503
|
+
/** Forwarded verbatim — a waiter carries no payload. */
|
|
5504
|
+
readonly listSignalWaitersByRun?: (runIds: string[]) => Promise<SignalWaiter[]>;
|
|
5505
|
+
/** Forwarded verbatim — a waiter carries no payload. */
|
|
5506
|
+
readonly hasSignalWaiter?: (runId: string, tokenPrefix: string) => Promise<boolean>;
|
|
5368
5507
|
/** Schedules persist their run `input` inside `spec` — encoded like any other payload. Bound only
|
|
5369
5508
|
* when the inner store persists schedules, so `engine.schedules` reports absence faithfully. */
|
|
5370
5509
|
readonly saveSchedule?: (record: ScheduleRecord) => Promise<void>;
|
|
@@ -5829,6 +5968,10 @@ declare class InMemoryStateStore implements StateStore {
|
|
|
5829
5968
|
putSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
5830
5969
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
|
5831
5970
|
listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
|
|
5971
|
+
registerChildWaits(entries: ChildWait[]): Promise<void>;
|
|
5972
|
+
compactCheckpoints(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
|
|
5973
|
+
listSignalWaitersByRun(runIds: string[]): Promise<SignalWaiter[]>;
|
|
5974
|
+
hasSignalWaiter(runId: string, tokenPrefix: string): Promise<boolean>;
|
|
5832
5975
|
removeSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
5833
5976
|
transaction<T>(work: (tx: {
|
|
5834
5977
|
raw: unknown;
|
|
@@ -5921,4 +6064,4 @@ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: strin
|
|
|
5921
6064
|
updatedAt: Date;
|
|
5922
6065
|
} | undefined;
|
|
5923
6066
|
|
|
5924
|
-
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
|
|
6067
|
+
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, type FanJoin, type FanWait, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
|
package/dist/index.d.ts
CHANGED
|
@@ -995,6 +995,45 @@ interface StateStore {
|
|
|
995
995
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
|
996
996
|
/** List waiters whose `token` starts with `prefix` — used to fan out an event to its subscribers. */
|
|
997
997
|
listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
|
|
998
|
+
/**
|
|
999
|
+
* Whether run `runId` still has at least one waiter whose `token` starts with `tokenPrefix` (an
|
|
1000
|
+
* exact prefix: `%`/`_` in the prefix are literal characters, not wildcards). The `ctx.all` join
|
|
1001
|
+
* barrier asks this after each child settles, so it must stay O(1)-ish however many siblings are
|
|
1002
|
+
* still waiting — answer it with a bounded lookup, never by listing the whole group.
|
|
1003
|
+
*
|
|
1004
|
+
* Optional: a store without it keeps `ctx.all` correct, but the parent replays once per settled
|
|
1005
|
+
* child instead of once per fan.
|
|
1006
|
+
*/
|
|
1007
|
+
hasSignalWaiter?(runId: string, tokenPrefix: string): Promise<boolean>;
|
|
1008
|
+
/**
|
|
1009
|
+
* The waiters of the given runs. Lets the engine and the dashboard read what a page of runs (or
|
|
1010
|
+
* one run's children) is waiting on without scanning every waiter in the store, which a wide fan
|
|
1011
|
+
* fills with one row per running child. Callers pass ids in bounded batches.
|
|
1012
|
+
*
|
|
1013
|
+
* Optional: without it those reads fall back to {@link listSignalWaiters} over every waiter.
|
|
1014
|
+
*/
|
|
1015
|
+
listSignalWaitersByRun?(runIds: string[]): Promise<SignalWaiter[]>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Register a batch of awaited children: for each entry, put `waiter` and upsert `checkpoint` (the
|
|
1018
|
+
* parent's `running` placeholder for that child). `ctx.all` calls it once per chunk of a fan, so a
|
|
1019
|
+
* wide fan costs a handful of round trips instead of two per child.
|
|
1020
|
+
*
|
|
1021
|
+
* Every entry's waiter must be durable no later than its checkpoint: the engine reads an existing
|
|
1022
|
+
* placeholder as proof the waiter was put, and never re-puts it. Writing both in one transaction
|
|
1023
|
+
* satisfies that.
|
|
1024
|
+
*
|
|
1025
|
+
* Optional: without it the engine puts each waiter, then saves each checkpoint.
|
|
1026
|
+
*/
|
|
1027
|
+
registerChildWaits?(entries: ChildWait[]): Promise<void>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Atomically replace run `runId`'s checkpoints with `seq` in `[fromSeq, toSeq]` by the single
|
|
1030
|
+
* checkpoint `into`, whose `seq` lies in that range. `ctx.all` folds a settled group of children
|
|
1031
|
+
* into one checkpoint this way, so every later turn of the parent loads one row instead of one per
|
|
1032
|
+
* child. A delete over a contiguous seq range, served by the `(runId, seq)` primary key.
|
|
1033
|
+
*
|
|
1034
|
+
* Optional: without it a settled fan keeps one checkpoint per child.
|
|
1035
|
+
*/
|
|
1036
|
+
compactCheckpoints?(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
|
|
998
1037
|
/**
|
|
999
1038
|
* Delete the EXACT waiter row — `token` AND `runId` AND `seq` must all match — no-op if absent.
|
|
1000
1039
|
* Unlike {@link takeSignalWaiter}, which deletes ANY row for `token` (fine when the caller just won
|
|
@@ -1421,6 +1460,26 @@ interface StoreTransaction {
|
|
|
1421
1460
|
saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
|
|
1422
1461
|
}
|
|
1423
1462
|
/** Binds an external signal `token` to the suspended run/step position waiting for it. */
|
|
1463
|
+
/** Options for {@link WorkflowCtx.all}. */
|
|
1464
|
+
interface AllOptions {
|
|
1465
|
+
/** `waitAll` (default) or `failFast` — see {@link WorkflowCtx.all}. */
|
|
1466
|
+
mode?: 'waitAll' | 'failFast';
|
|
1467
|
+
/**
|
|
1468
|
+
* The most children running at once. Unset sends the whole fan immediately. When set, children go
|
|
1469
|
+
* out in waves of `floor(concurrency / 2)`, two at a time (an odd limit runs one child under it):
|
|
1470
|
+
* a new wave starts as soon as an earlier one settles, so one slow child does not idle the rest of
|
|
1471
|
+
* the window. Each settled wave costs the parent one turn.
|
|
1472
|
+
*
|
|
1473
|
+
* Part of the fan's identity: child ids carry the wave, so changing it for an in-flight run is a
|
|
1474
|
+
* non-deterministic change like changing `inputs`.
|
|
1475
|
+
*/
|
|
1476
|
+
concurrency?: number;
|
|
1477
|
+
}
|
|
1478
|
+
/** One child of a fan as {@link StateStore.registerChildWaits} writes it. */
|
|
1479
|
+
interface ChildWait {
|
|
1480
|
+
waiter: SignalWaiter;
|
|
1481
|
+
checkpoint: StepCheckpoint;
|
|
1482
|
+
}
|
|
1424
1483
|
interface SignalWaiter {
|
|
1425
1484
|
token: string;
|
|
1426
1485
|
runId: string;
|
|
@@ -2287,13 +2346,11 @@ interface WorkflowCtx<A extends SearchAttributes = SearchAttributes> {
|
|
|
2287
2346
|
* so a fast sibling can still slip through and complete). Empty `inputs` returns `[]` with no side
|
|
2288
2347
|
* effects. The wait-all / fan-out counterpart to {@link child}; parity with the Python SDK's
|
|
2289
2348
|
* `gather_children`.
|
|
2349
|
+
*
|
|
2350
|
+
* `concurrency` caps how many children run at once (see {@link AllOptions.concurrency}).
|
|
2290
2351
|
*/
|
|
2291
|
-
all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?:
|
|
2292
|
-
|
|
2293
|
-
}): Promise<WorkflowOutputOf<C>[]>;
|
|
2294
|
-
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: {
|
|
2295
|
-
mode?: 'waitAll' | 'failFast';
|
|
2296
|
-
}): Promise<TOutput[]>;
|
|
2352
|
+
all<C extends WorkflowClass>(workflow: C, inputs: WorkflowInputOf<C>[], opts?: AllOptions): Promise<WorkflowOutputOf<C>[]>;
|
|
2353
|
+
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
|
|
2297
2354
|
/**
|
|
2298
2355
|
* Pause the run at this point until a human resumes it from the dashboard (or
|
|
2299
2356
|
* `engine.continue(runId)`). Records a visible `pending` checkpoint so the breakpoint shows up
|
|
@@ -2416,9 +2473,7 @@ interface DynamicWorkflowCtx<A extends SearchAttributes = SearchAttributes> exte
|
|
|
2416
2473
|
/** {@link WorkflowCtx.startChild} by workflow name. */
|
|
2417
2474
|
startChild(workflow: string, input: unknown, options?: string | ChildCallOptions): Promise<string>;
|
|
2418
2475
|
/** {@link WorkflowCtx.all} by workflow name. */
|
|
2419
|
-
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?:
|
|
2420
|
-
mode?: 'waitAll' | 'failFast';
|
|
2421
|
-
}): Promise<TOutput[]>;
|
|
2476
|
+
all<TOutput = unknown>(workflow: string, inputs: unknown[], opts?: AllOptions): Promise<TOutput[]>;
|
|
2422
2477
|
}
|
|
2423
2478
|
/** Result of executing or resuming a workflow run. */
|
|
2424
2479
|
interface RunResult {
|
|
@@ -3330,6 +3385,8 @@ declare class ScheduleNotFoundError extends Error {
|
|
|
3330
3385
|
interface ScheduleHost {
|
|
3331
3386
|
start(workflow: string, input: unknown, runId: string, opts?: StartOptions): Promise<RunResult>;
|
|
3332
3387
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
3388
|
+
/** True once the engine has begun shutting down; `tick` fires nothing more after that. */
|
|
3389
|
+
isDraining?(): boolean;
|
|
3333
3390
|
}
|
|
3334
3391
|
/** Engine-level knobs for the client. */
|
|
3335
3392
|
interface ScheduleClientOptions {
|
|
@@ -3742,6 +3799,8 @@ declare class WorkflowEngine {
|
|
|
3742
3799
|
/** Executions currently in flight, so a graceful shutdown can wait for them to settle. */
|
|
3743
3800
|
private readonly inflight;
|
|
3744
3801
|
private draining;
|
|
3802
|
+
/** Wait already spent on this shutdown before `drain()` (see `beginDrain`). */
|
|
3803
|
+
private drainSpentMs;
|
|
3745
3804
|
constructor(deps: WorkflowEngineDeps);
|
|
3746
3805
|
/**
|
|
3747
3806
|
* Register a **durable entity** (a virtual object): a keyed actor whose `handlers` run **serialized
|
|
@@ -3995,10 +4054,25 @@ declare class WorkflowEngine {
|
|
|
3995
4054
|
private findParentRunId;
|
|
3996
4055
|
/** Track an in-flight execution so {@link drain} can wait for it. */
|
|
3997
4056
|
private track;
|
|
4057
|
+
/**
|
|
4058
|
+
* Stop picking up new work without waiting: recovery, timer, schedule and timeout sweeps (and
|
|
4059
|
+
* their per-run lock loops) start nothing once this is called, and {@link runOne} returns null. A
|
|
4060
|
+
* poller calls it on its own shutdown so an in-flight sweep stops locking runs before it is awaited.
|
|
4061
|
+
*
|
|
4062
|
+
* `spentMs` is wait time ALREADY spent on this shutdown (the poller awaiting its in-flight sweep).
|
|
4063
|
+
* It is deducted from the budget of a later {@link drain}, so that wait plus the drain stay within
|
|
4064
|
+
* one `shutdownTimeoutMs`. Only time actually spent waiting is charged: time that merely passes
|
|
4065
|
+
* between this call and `drain()` (other hooks, the HTTP server closing) never is. Calls add up.
|
|
4066
|
+
*/
|
|
4067
|
+
beginDrain(spentMs?: number): void;
|
|
3998
4068
|
/**
|
|
3999
4069
|
* Graceful shutdown: stop picking up new runs (recovery/timer become no-ops) and wait for
|
|
4000
4070
|
* in-flight executions to settle, up to `timeoutMs`. Call from your app's shutdown hook so a
|
|
4001
4071
|
* deploy hands off cleanly instead of leaving runs to the lease timeout.
|
|
4072
|
+
*
|
|
4073
|
+
* `timeoutMs` is the total budget for waiting on in-flight runs; any wait already reported through
|
|
4074
|
+
* {@link beginDrain} (`spentMs`) is deducted, so a shutdown that already waited on the timer poll
|
|
4075
|
+
* for part of it waits only for the remainder. With nothing reported, the full `timeoutMs` applies.
|
|
4002
4076
|
*/
|
|
4003
4077
|
drain(timeoutMs?: number): Promise<void>;
|
|
4004
4078
|
/**
|
|
@@ -4199,6 +4273,32 @@ declare class WorkflowEngine {
|
|
|
4199
4273
|
* same way.
|
|
4200
4274
|
*/
|
|
4201
4275
|
private deliverSignal;
|
|
4276
|
+
/**
|
|
4277
|
+
* The `ctx.all` join barrier: true when `waiter` was one child of a fan (or of one wave of it)
|
|
4278
|
+
* whose siblings are still out, so waking the parent now would only replay the fan and re-suspend.
|
|
4279
|
+
* Skipping that wake is what keeps a fan of N children at O(N) work instead of N replays of N items.
|
|
4280
|
+
*
|
|
4281
|
+
* Safe because the LAST sibling to settle always wakes the parent: each child consumes its own
|
|
4282
|
+
* waiter before it asks, so whichever asks last sees none left. A failed child of a failFast fan
|
|
4283
|
+
* always wakes it. Anything that is not a `ctx.all` waiter, or a store that cannot answer the
|
|
4284
|
+
* question cheaply, wakes the parent as before.
|
|
4285
|
+
*/
|
|
4286
|
+
private fanStillWaiting;
|
|
4287
|
+
/**
|
|
4288
|
+
* Re-drive a run that just suspended on awaited children (a `ctx.all` fan or wave, a `ctx.child`)
|
|
4289
|
+
* which, by now, have settled.
|
|
4290
|
+
*
|
|
4291
|
+
* {@link execute} drops a wake that finds the run's lease held. So if a child settles while the
|
|
4292
|
+
* parent is still executing (the turn that dispatched it, or one woken by an earlier child), that
|
|
4293
|
+
* wake is spent, and the turn suspends on a snapshot that predates the child. With the `ctx.all`
|
|
4294
|
+
* barrier that wake was the only one the fan would get. Nothing would wake the run until the
|
|
4295
|
+
* `reconcileMs` sweep, minutes later.
|
|
4296
|
+
*
|
|
4297
|
+
* Called after the turn released its lease, so any child that settles from here on wakes the run
|
|
4298
|
+
* itself. Only re-drives for a group with no waiter left whose checkpoints are all settled, which
|
|
4299
|
+
* the next turn is then guaranteed to see — so it cannot loop.
|
|
4300
|
+
*/
|
|
4301
|
+
private redriveSettledChildren;
|
|
4202
4302
|
/**
|
|
4203
4303
|
* Deliver an external signal to the run waiting on `token`, resume it with `payload`, and return
|
|
4204
4304
|
* the run result — or null if no run is (or ends up) waiting for it.
|
|
@@ -4355,8 +4455,11 @@ declare class WorkflowEngine {
|
|
|
4355
4455
|
* so a completed parent (or a completed awaited child) would otherwise drop out of the tree. The
|
|
4356
4456
|
* `signal:child:<id>` checkpoint (the placeholder written when the parent first awaits the child,
|
|
4357
4457
|
* overwritten as completed/failed when it settles) persists across completion, so we read both and
|
|
4358
|
-
* dedupe — the edge stays stable for a finished run, not just a live one.
|
|
4458
|
+
* dedupe — the edge stays stable for a finished run, not just a live one. A settled `ctx.all`
|
|
4459
|
+
* group folded into one `fan:` checkpoint stands for every child in it.
|
|
4359
4460
|
*/
|
|
4461
|
+
/** The children `parentRunId` is awaiting right now, read off its own live `child:` waiters. */
|
|
4462
|
+
private awaitedChildIds;
|
|
4360
4463
|
getRunChildren(parentRunId: string): Promise<string[]>;
|
|
4361
4464
|
/** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
|
|
4362
4465
|
* `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
|
|
@@ -4979,9 +5082,24 @@ declare class GatherError extends Error {
|
|
|
4979
5082
|
declare class WorkflowSuspended extends Error {
|
|
4980
5083
|
/** Epoch ms to auto-resume (durable sleep), or undefined when waiting on an external signal. */
|
|
4981
5084
|
readonly wakeAt?: number | undefined;
|
|
5085
|
+
/** Set when awaited children are what the run is waiting on — see {@link FanJoin}. */
|
|
5086
|
+
readonly fan?: FanJoin | undefined;
|
|
4982
5087
|
/** Marks this as a control-flow signal — see {@link isWorkflowControlFlowSignal}. */
|
|
4983
5088
|
readonly [CONTROL_FLOW_SIGNAL] = true;
|
|
4984
|
-
constructor(wakeAt?: number);
|
|
5089
|
+
constructor(wakeAt?: number, fan?: FanJoin);
|
|
5090
|
+
}
|
|
5091
|
+
/**
|
|
5092
|
+
* What a run suspended on when it awaits children (`ctx.all`, `ctx.child`). For each group of
|
|
5093
|
+
* children, every waiter token starts with `waiterPrefix` and every `signal:child:` checkpoint name
|
|
5094
|
+
* with `checkpointPrefix`, so the engine can tell whether the group has settled without knowing the
|
|
5095
|
+
* children's ids.
|
|
5096
|
+
*/
|
|
5097
|
+
interface FanJoin {
|
|
5098
|
+
waits: FanWait[];
|
|
5099
|
+
}
|
|
5100
|
+
interface FanWait {
|
|
5101
|
+
waiterPrefix: string;
|
|
5102
|
+
checkpointPrefix: string;
|
|
4985
5103
|
}
|
|
4986
5104
|
/**
|
|
4987
5105
|
* Thrown by `ctx.continueAsNew(input)` to end the current run and hand off to a fresh execution of
|
|
@@ -5315,10 +5433,23 @@ declare function classifyWaiterToken(token: string): RunWaiting;
|
|
|
5315
5433
|
* state (no-worker, singleton, running) on top — none of which can be told apart from `wakeAt` alone.
|
|
5316
5434
|
*/
|
|
5317
5435
|
declare function resolveRunWaiting(run: WorkflowRun, waiterByRun: ReadonlyMap<string, SignalWaiter>): RunWaiting | undefined;
|
|
5436
|
+
/**
|
|
5437
|
+
* The signal waiters of `runIds`: through the store's {@link StateStore.listSignalWaitersByRun} in
|
|
5438
|
+
* bounded batches, or, for a store without it, one scan of every waiter filtered to those runs.
|
|
5439
|
+
*/
|
|
5440
|
+
declare function listSignalWaitersOfRuns(store: StateStore, runIds: readonly string[]): Promise<SignalWaiter[]>;
|
|
5318
5441
|
/** Index signal waiters by `runId`, keeping the first seen per run (a run parks on one waiter at a
|
|
5319
5442
|
* time in the sequential case; the earliest is the one it's blocked on). */
|
|
5320
5443
|
declare function indexWaitersByRun(waiters: readonly SignalWaiter[]): Map<string, SignalWaiter>;
|
|
5321
5444
|
|
|
5445
|
+
/**
|
|
5446
|
+
* The parent of a child run whose id the engine minted: a `ctx.all` child
|
|
5447
|
+
* (`<parent>.all.<seq>.<i>`, or `.w<k>.<i>` under a `concurrency` limit) or a `ctx.child` /
|
|
5448
|
+
* `ctx.startChild` child without an explicit id (`<parent>.child.<seq>`). Undefined for any other
|
|
5449
|
+
* run, including a child started with a caller-chosen id.
|
|
5450
|
+
*/
|
|
5451
|
+
declare function parentRunIdOf(runId: string): string | undefined;
|
|
5452
|
+
|
|
5322
5453
|
/**
|
|
5323
5454
|
* Transforms a payload value as it crosses the store boundary — e.g. encrypt-at-rest, compress, or
|
|
5324
5455
|
* redact PII. `decode` must be the exact inverse of `encode`. Both are synchronous (use a local
|
|
@@ -5365,6 +5496,14 @@ declare class CodecStateStore implements StateStore {
|
|
|
5365
5496
|
/** Forwarded verbatim — a count reads no payload. Bound only when the inner store counts, so the
|
|
5366
5497
|
* engine's facet/listing fallback still applies through the wrapper. */
|
|
5367
5498
|
readonly countRuns?: (query: Omit<RunQuery, 'limit' | 'offset'>) => Promise<number>;
|
|
5499
|
+
/** The placeholder checkpoints are encoded like any other checkpoint. */
|
|
5500
|
+
readonly registerChildWaits?: (entries: ChildWait[]) => Promise<void>;
|
|
5501
|
+
/** The folded checkpoint carries the children's outputs, so it is encoded. */
|
|
5502
|
+
readonly compactCheckpoints?: (runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint) => Promise<void>;
|
|
5503
|
+
/** Forwarded verbatim — a waiter carries no payload. */
|
|
5504
|
+
readonly listSignalWaitersByRun?: (runIds: string[]) => Promise<SignalWaiter[]>;
|
|
5505
|
+
/** Forwarded verbatim — a waiter carries no payload. */
|
|
5506
|
+
readonly hasSignalWaiter?: (runId: string, tokenPrefix: string) => Promise<boolean>;
|
|
5368
5507
|
/** Schedules persist their run `input` inside `spec` — encoded like any other payload. Bound only
|
|
5369
5508
|
* when the inner store persists schedules, so `engine.schedules` reports absence faithfully. */
|
|
5370
5509
|
readonly saveSchedule?: (record: ScheduleRecord) => Promise<void>;
|
|
@@ -5829,6 +5968,10 @@ declare class InMemoryStateStore implements StateStore {
|
|
|
5829
5968
|
putSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
5830
5969
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
|
5831
5970
|
listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
|
|
5971
|
+
registerChildWaits(entries: ChildWait[]): Promise<void>;
|
|
5972
|
+
compactCheckpoints(runId: string, fromSeq: number, toSeq: number, into: StepCheckpoint): Promise<void>;
|
|
5973
|
+
listSignalWaitersByRun(runIds: string[]): Promise<SignalWaiter[]>;
|
|
5974
|
+
hasSignalWaiter(runId: string, tokenPrefix: string): Promise<boolean>;
|
|
5832
5975
|
removeSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
5833
5976
|
transaction<T>(work: (tx: {
|
|
5834
5977
|
raw: unknown;
|
|
@@ -5921,4 +6064,4 @@ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: strin
|
|
|
5921
6064
|
updatedAt: Date;
|
|
5922
6065
|
} | undefined;
|
|
5923
6066
|
|
|
5924
|
-
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
|
|
6067
|
+
export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, type FanJoin, type FanWait, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
|