@demlik/tea 0.14.0 → 0.16.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/README.md +30 -7
- package/dist/agent/index.d.ts +49 -36
- package/dist/agent/index.js +12 -8
- package/dist/chunk-4LPY67E4.js +18 -0
- package/dist/chunk-4LPY67E4.js.map +1 -0
- package/dist/chunk-5XU6ZJO2.js +533 -0
- package/dist/chunk-5XU6ZJO2.js.map +1 -0
- package/dist/{chunk-AQ6ZIMEA.js → chunk-6NG4V5SB.js} +89 -115
- package/dist/chunk-6NG4V5SB.js.map +1 -0
- package/dist/{chunk-HYDWG35Q.js → chunk-7MGXQZPW.js} +11 -9
- package/dist/chunk-7MGXQZPW.js.map +1 -0
- package/dist/{chunk-BLJ2JQSH.js → chunk-BCTEOVOU.js} +3 -3
- package/dist/{chunk-BLJ2JQSH.js.map → chunk-BCTEOVOU.js.map} +1 -1
- package/dist/chunk-CH5KTOEZ.js +710 -0
- package/dist/chunk-CH5KTOEZ.js.map +1 -0
- package/dist/chunk-CIHSHLQX.js +64 -0
- package/dist/chunk-CIHSHLQX.js.map +1 -0
- package/dist/{chunk-Z2L3LSNV.js → chunk-EHUDXAKC.js} +246 -210
- package/dist/chunk-EHUDXAKC.js.map +1 -0
- package/dist/chunk-GOX2CYIM.js +380 -0
- package/dist/chunk-GOX2CYIM.js.map +1 -0
- package/dist/chunk-IVJP3GKJ.js +104 -0
- package/dist/chunk-IVJP3GKJ.js.map +1 -0
- package/dist/{chunk-F7FMAWLA.js → chunk-MVZS5FDM.js} +13 -6
- package/dist/chunk-MVZS5FDM.js.map +1 -0
- package/dist/{chunk-LYLTKJWM.js → chunk-MYNLY3HP.js} +9 -8
- package/dist/chunk-MYNLY3HP.js.map +1 -0
- package/dist/{chunk-I5MQMJDW.js → chunk-NSIAORRY.js} +20 -30
- package/dist/chunk-NSIAORRY.js.map +1 -0
- package/dist/{chunk-MYXFNWAJ.js → chunk-QNGYQMZB.js} +4 -4
- package/dist/chunk-QNGYQMZB.js.map +1 -0
- package/dist/chunk-WT5PBPLB.js +98 -0
- package/dist/chunk-WT5PBPLB.js.map +1 -0
- package/dist/{core-CTzMJ82M.d.ts → core-BbgtiXdg.d.ts} +231 -139
- package/dist/do/index.d.ts +37 -32
- package/dist/do/index.js +21 -14
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-B0-qGQDy.d.ts → durable-effects-7MTK_jnj.d.ts} +1 -1
- package/dist/effect/index.d.ts +151 -0
- package/dist/effect/index.js +98 -0
- package/dist/effect/index.js.map +1 -0
- package/dist/extension/index.d.ts +6 -7
- package/dist/extension/index.js +3 -2
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +68 -70
- package/dist/flow/index.js +32 -27
- package/dist/flow/index.js.map +1 -1
- package/dist/idempotency/index.d.ts +6 -7
- package/dist/idempotency/index.js +4 -2
- package/dist/{index-DJWIER_3.d.ts → index-7vV8xmsD.d.ts} +1 -1
- package/dist/{index-NjrT3fL2.d.ts → index-Bz5Rh9Ga.d.ts} +19 -96
- package/dist/index-CjFDUBeq.d.ts +207 -0
- package/dist/{index-6A7dB8f6.d.ts → index-CkFYA9Y6.d.ts} +14 -16
- package/dist/{index-B5BZ-_cT.d.ts → index-Cou86-GX.d.ts} +189 -108
- package/dist/{index-TvRb1KVf.d.ts → index-DU6JpQ8G.d.ts} +1 -1
- package/dist/{index-q0hXFeZ0.d.ts → index-Xufl55W8.d.ts} +286 -215
- package/dist/{index-4vZzljCD.d.ts → index-_dOR3xqA.d.ts} +57 -45
- package/dist/index.d.ts +181 -385
- package/dist/index.js +2 -1
- package/dist/jev/index.d.ts +147 -99
- package/dist/jev/index.js +329 -233
- package/dist/jev/index.js.map +1 -1
- package/dist/{machine-CdIcN2Xm.d.ts → machine-BQzTV8On.d.ts} +171 -280
- package/dist/machine-viz/index.d.ts +5 -5
- package/dist/machine-viz/index.js +8 -4
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +3 -4
- package/dist/mem/index.js +2 -1
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +119 -78
- package/dist/node/index.js +52 -38
- package/dist/node/index.js.map +1 -1
- package/dist/paginate/index.d.ts +27 -33
- package/dist/paginate/index.js +6 -4
- package/dist/parity/index.d.ts +4 -5
- package/dist/parity/index.js +3 -2
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +2 -2
- package/dist/pbt/index.js +2 -1
- package/dist/pbt/index.js.map +1 -1
- package/dist/persistence/index.d.ts +6 -7
- package/dist/persistence/index.js +5 -3
- package/dist/promise/index.d.ts +186 -0
- package/dist/promise/index.js +5 -0
- package/dist/promise/index.js.map +1 -0
- package/dist/protocol-ClRZBhHQ.d.ts +53 -0
- package/dist/react/index.d.ts +36 -17
- package/dist/react/index.js +27 -4
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +63 -455
- package/dist/resilience/index.js +37 -483
- package/dist/resilience/index.js.map +1 -1
- package/dist/{runtime-types-LWDoi943.d.ts → runtime-types-CiVpC0HN.d.ts} +131 -388
- package/dist/testing/index.d.ts +165 -15
- package/dist/testing/index.js +104 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/timing/index.d.ts +25 -22
- package/dist/timing/index.js +4 -3
- package/dist/timing/index.js.map +1 -1
- package/dist/{types-DP3f5NIl.d.ts → types-LxZxGYda.d.ts} +2 -2
- package/dist/work-queue/index.d.ts +5 -6
- package/package.json +18 -5
- package/dist/chunk-AQ6ZIMEA.js.map +0 -1
- package/dist/chunk-F2US5BW6.js +0 -72
- package/dist/chunk-F2US5BW6.js.map +0 -1
- package/dist/chunk-F7FMAWLA.js.map +0 -1
- package/dist/chunk-HUKZQX6U.js +0 -97
- package/dist/chunk-HUKZQX6U.js.map +0 -1
- package/dist/chunk-HYDWG35Q.js.map +0 -1
- package/dist/chunk-I5MQMJDW.js.map +0 -1
- package/dist/chunk-LYLTKJWM.js.map +0 -1
- package/dist/chunk-MYXFNWAJ.js.map +0 -1
- package/dist/chunk-RQULHGYH.js +0 -1804
- package/dist/chunk-RQULHGYH.js.map +0 -1
- package/dist/chunk-Z2L3LSNV.js.map +0 -1
- package/dist/index-DMCeMPMJ.d.ts +0 -272
package/dist/flow/index.d.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { R as Runtime, C as CtxArg } from '../runtime-types-
|
|
2
|
-
import { C as Cmd, S as Sub, M as Machine,
|
|
3
|
-
export { B as BatchWindow,
|
|
4
|
-
export { a as FanOutConfig, b as FanOutDone, c as FanOutFailed, d as FanOutPorts, F as FanOutState, e as createFanOut, i as initFanOut, f as isComplete } from '../index-
|
|
5
|
-
export { E as EndedRun, M as MonitoredRunCmd, b as MonitoredRunConfig,
|
|
1
|
+
import { R as Runtime, C as CtxArg } from '../runtime-types-CiVpC0HN.js';
|
|
2
|
+
import { C as Cmd, S as Sub, M as Machine, R as RunHandlers, b as CmdDef, T as TimerDeps, c as CmdOf } from '../core-BbgtiXdg.js';
|
|
3
|
+
export { B as BatchWindow, c as BatchWindowConfig, b as BatchWindowExpired, d as BatchWindowKnob, a as BatchWindowSub, e as addItem, f as batchWindowExpired, g as createBatchWindow, i as initBatchWindow, o as onWindow, s as subsFor, h as subscribeBatchWindow, t as timerFor } from '../index-_dOR3xqA.js';
|
|
4
|
+
export { a as FanOutConfig, b as FanOutDone, c as FanOutFailed, d as FanOutPorts, F as FanOutState, e as createFanOut, i as initFanOut, f as isComplete } from '../index-CkFYA9Y6.js';
|
|
5
|
+
export { E as EndedRun, M as MonitoredRunCmd, b as MonitoredRunConfig, a as MonitoredRunState, c as MonitoredRunTimerMsg, R as RunFailure, S as StageResult, d as createMonitoredRun, l as liftRun } from '../index-Bz5Rh9Ga.js';
|
|
6
6
|
import { RetryState, AnyRetryPolicy, RetryPolicy } from '../retry-backoff/index.js';
|
|
7
7
|
import { I as IdempotencyStore } from '../index-Bc40JWVl.js';
|
|
8
|
-
import { a as DeadlineSub, T as TtlCache } from '../index-
|
|
9
|
-
|
|
10
|
-
import { C as CircuitConfig, c as RateLimitConfig, D as DeadlineConfig, d as ResilientPorts, F as FailMsg, S as SucceedMsg } from '../index-B5BZ-_cT.js';
|
|
8
|
+
import { a as DeadlineSub, T as TtlCache } from '../index-Xufl55W8.js';
|
|
9
|
+
import { f as CircuitConfig, l as RateLimitConfig, m as DeadlineConfig, b as ResilientTimerMsg } from '../index-Cou86-GX.js';
|
|
11
10
|
import { PaginatedWalkState, PaginatedWalkTimerMsg, FetchPageCmd, PageErrMsg, PageOkMsg } from '../paginate/index.js';
|
|
12
|
-
import { Q as QueueItem } from '../index-
|
|
13
|
-
export { E as EnqueueInput } from '../index-
|
|
14
|
-
import { D as DeliveryId, E as EffectLedgerEvent } from '../durable-effects-
|
|
15
|
-
export { a as EffectConfirmed, b as EffectOwed, e as emptyLedger } from '../durable-effects-
|
|
11
|
+
import { Q as QueueItem } from '../index-7vV8xmsD.js';
|
|
12
|
+
export { E as EnqueueInput } from '../index-7vV8xmsD.js';
|
|
13
|
+
import { D as DeliveryId, E as EffectLedgerEvent } from '../durable-effects-7MTK_jnj.js';
|
|
14
|
+
export { a as EffectConfirmed, b as EffectOwed, e as emptyLedger } from '../durable-effects-7MTK_jnj.js';
|
|
16
15
|
export { D as Debounced, d as debounce } from '../index-DHSUmQTR.js';
|
|
17
|
-
export {
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
20
|
-
import '../types-DP3f5NIl.js';
|
|
16
|
+
export { b as SnapshotSavedMsg, S as SnapshotWriteCmd } from '../index-CjFDUBeq.js';
|
|
17
|
+
import '@standard-schema/spec';
|
|
18
|
+
import '../types-LxZxGYda.js';
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* internal/flow/await-terminal — run a ONE-SHOT / decision-procedure machine to a
|
|
@@ -45,7 +43,7 @@ import '../types-DP3f5NIl.js';
|
|
|
45
43
|
* this helper does NOT invent one; the caller names their own terminal states.
|
|
46
44
|
*
|
|
47
45
|
* The optional `timeoutMs` is a plain caller-boundary timer (not an in-loop
|
|
48
|
-
* progress deadline — see `../deadline`
|
|
46
|
+
* progress deadline — see `../deadline` for that shape): it
|
|
49
47
|
* clears on resolve and REJECTS with the `instanceof`-checkable
|
|
50
48
|
* {@link TerminalTimeoutError} if the deadline elapses first, never silently
|
|
51
49
|
* resolving.
|
|
@@ -100,17 +98,21 @@ declare function awaitTerminal<S, M extends {
|
|
|
100
98
|
* on BOTH the resolve and reject paths. Wraps {@link awaitTerminal}.
|
|
101
99
|
*
|
|
102
100
|
* The seed carries the machine's `ctx` (conditionally optional, exactly as
|
|
103
|
-
* `run`'s `ctx` — a pure machine omits it)
|
|
104
|
-
*
|
|
101
|
+
* `run`'s `ctx` — a pure machine omits it), the handlers `run` takes beside the
|
|
102
|
+
* machine (`interpret`, and `subscribe` when its Subs need runners), and the
|
|
103
|
+
* `msgs` to dispatch once
|
|
104
|
+
* booted. A `timeoutMs` in `opts` bounds the await identically to
|
|
105
|
+
* `awaitTerminal`.
|
|
105
106
|
*
|
|
106
107
|
* @param machine the machine to boot.
|
|
107
|
-
* @param seed `{ ctx?, msgs }` — the boot context
|
|
108
|
+
* @param seed `{ ctx?, interpret, subscribe?, msgs }` — the boot context, the
|
|
109
|
+
* handlers, and the seed messages.
|
|
108
110
|
* @param isTerminal caller-supplied terminal predicate over the machine's state.
|
|
109
111
|
* @param opts optional bounded `timeoutMs` deadline (see {@link AwaitTerminalOptions}).
|
|
110
112
|
*/
|
|
111
113
|
declare function runToTerminal<S, M extends {
|
|
112
114
|
type: string;
|
|
113
|
-
}, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, seed: CtxArg<Ctx> & {
|
|
115
|
+
}, C extends Cmd, U extends Sub, Ctx>(machine: Machine<S, M, C, U, Ctx>, seed: CtxArg<Ctx> & NoInfer<RunHandlers<M, C, U, Ctx>> & {
|
|
114
116
|
readonly msgs: readonly M[];
|
|
115
117
|
}, isTerminal: (state: S) => boolean, opts?: AwaitTerminalOptions): Promise<S>;
|
|
116
118
|
|
|
@@ -176,7 +178,9 @@ declare function runToTerminal<S, M extends {
|
|
|
176
178
|
* },
|
|
177
179
|
*
|
|
178
180
|
* // Subs — the knob owns the interval/backoff deadline:
|
|
179
|
-
*
|
|
181
|
+
* types: { ..., sub: {} as DeadlinesSub },
|
|
182
|
+
* subs: [deadlinesSub((s) => poll.subs(s.poll))],
|
|
183
|
+
* // at run: run(machine, { interpret, subscribe: { deadline: subscribeDeadline } })
|
|
180
184
|
*
|
|
181
185
|
* The cadence has exactly ONE source: the `everyMs` deadline Sub. `start`,
|
|
182
186
|
* `tickResult`, and `tickErr` only RE-ARM the deadline (they emit no cadence
|
|
@@ -194,8 +198,8 @@ declare function runToTerminal<S, M extends {
|
|
|
194
198
|
* verb body names the global RNG). `replay` reconstructs a poll run exactly.
|
|
195
199
|
*
|
|
196
200
|
* NOT a substrate primitive: it depends only on sibling subpaths
|
|
197
|
-
* (`../deadline`, `../retry-backoff`, `../idempotency`) and the core `Cmd`
|
|
198
|
-
*
|
|
201
|
+
* (`../deadline`, `../retry-backoff`, `../idempotency`) and the core `Cmd`
|
|
202
|
+
* type. Internal since #48 — not published on any subpath; reached from
|
|
199
203
|
* inside the package as `internal/flow/poller`. The L1 escape hatch is those
|
|
200
204
|
* three siblings threaded by hand.
|
|
201
205
|
*/
|
|
@@ -218,7 +222,7 @@ interface PollerConfig<State, R> {
|
|
|
218
222
|
* The stop predicate, read against the consumer's whole Model. When it
|
|
219
223
|
* returns `true`, the poller is DONE: `subs` returns `[]` (the timer
|
|
220
224
|
* disarms) and no further tick is scheduled. Pure — it must not read the
|
|
221
|
-
* clock or mutate; the
|
|
225
|
+
* clock or mutate; the consumer's reducer cell calls it (`untilHeld`).
|
|
222
226
|
*/
|
|
223
227
|
readonly until: (state: State) => boolean;
|
|
224
228
|
/**
|
|
@@ -335,22 +339,20 @@ type PollerGaveUp<R> = Extract<PollerState<R>, {
|
|
|
335
339
|
phase: "gave_up";
|
|
336
340
|
}>;
|
|
337
341
|
/**
|
|
338
|
-
* The poller
|
|
339
|
-
*
|
|
340
|
-
* across transitions means "same armed deadline", even as `nextAtMs` advances.
|
|
342
|
+
* The deadline the poller lists — a `../deadline` entry under the
|
|
343
|
+
* `poller:tick:` id family (see `pollerSubId`).
|
|
341
344
|
*/
|
|
342
345
|
type PollerSub = DeadlineSub;
|
|
343
346
|
/**
|
|
344
347
|
* The knob handle returned by `createPoller`. Spread its hooks into your
|
|
345
348
|
* machine: `init()` seeds the slice, `start(...)` arms the first tick,
|
|
346
349
|
* `tickResult` / `tickErr` are the two update verbs, and `subs(...)` returns the
|
|
347
|
-
*
|
|
350
|
+
* tick deadline while the poller is live.
|
|
348
351
|
*
|
|
349
352
|
* Pure-ops + subs module: there is no `handlers(ports)` cell. The poller's I/O
|
|
350
353
|
* is the consumer's own `onTick` Cmd run by the consumer's `interpret` — the
|
|
351
|
-
* knob never owns a port. (Compare `../deadline`, which ships a `
|
|
352
|
-
*
|
|
353
|
-
* splice into `interpret`.)
|
|
354
|
+
* knob never owns a port. (Compare `../deadline`, which ships a `deadline`
|
|
355
|
+
* runner; the poller reuses it, so it has nothing of its own to hand `run`.)
|
|
354
356
|
*/
|
|
355
357
|
interface Poller<State, R> {
|
|
356
358
|
/** Seed the Model slice. Idle until `start(...)` arms the first tick. */
|
|
@@ -433,16 +435,16 @@ interface Poller<State, R> {
|
|
|
433
435
|
*/
|
|
434
436
|
tickErr(state: PollerState<R>, error: unknown, at: number): readonly [PollerPolling<R> | PollerGaveUp<R>, readonly Cmd[]];
|
|
435
437
|
/**
|
|
436
|
-
* The
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
438
|
+
* The tick deadline, listed while the poller is `"polling"` with an armed
|
|
439
|
+
* `nextAtMs`; `[]` once `"done"` / `"gave_up"` (the timer disarms) or before
|
|
440
|
+
* `start`. Declare it on the machine:
|
|
441
|
+
* `subs: [deadlinesSub((s) => poll.subs(s.poll))]`.
|
|
440
442
|
*
|
|
441
|
-
* The
|
|
442
|
-
*
|
|
443
|
-
*
|
|
443
|
+
* The list is armed by `../deadline`'s `subscribeDeadline` runner, which the
|
|
444
|
+
* consumer passes to `run` as `subscribe.deadline` — the poller does not
|
|
445
|
+
* redraw the timer lifecycle.
|
|
444
446
|
*/
|
|
445
|
-
subs(state: PollerState<R>): readonly
|
|
447
|
+
subs(state: PollerState<R>): readonly PollerSub[];
|
|
446
448
|
}
|
|
447
449
|
/**
|
|
448
450
|
* Build a poller knob from `config`. Returns the hook bag to spread into a
|
|
@@ -583,54 +585,50 @@ interface ReconcilerState<Actual, Change, Page, Cursor = number> {
|
|
|
583
585
|
/**
|
|
584
586
|
* The actual-list page-fetch effect: the inherited `resilient_run` Cmd from
|
|
585
587
|
* paginated-walk, whose `input` is the `Cursor` to fetch and whose `key` is the
|
|
586
|
-
* fixed `PAGE_KEY`.
|
|
588
|
+
* fixed `PAGE_KEY`. It is `Cmd.define`d; the handler you write fetches ONE page
|
|
589
|
+
* of the ACTUAL listing and returns `ok(page)` or
|
|
590
|
+
* `err({ _tag: "port_rejected", … })`.
|
|
587
591
|
*/
|
|
588
592
|
type ScanPageCmd<Cursor> = FetchPageCmd<Cursor>;
|
|
589
|
-
/**
|
|
593
|
+
/** The page-settled Msgs the engine mints from that handler's outcome. */
|
|
590
594
|
type ScanPageOkMsg<Page> = PageOkMsg<Page>;
|
|
591
595
|
type ScanPageErrMsg = PageErrMsg;
|
|
592
596
|
/** The scan retry / deadline timer Msg — inherited from paginated-walk. */
|
|
593
597
|
type ReconcilerTimerMsg = PaginatedWalkTimerMsg;
|
|
594
|
-
/**
|
|
595
|
-
* Ports the consumer supplies to `handlers`. `run(cursor)` fetches ONE page of
|
|
596
|
-
* the ACTUAL listing for the given cursor; throwing routes to `pageErr` (and
|
|
597
|
-
* thus the scan backoff). Same shape as paginated-walk's port.
|
|
598
|
-
*/
|
|
599
|
-
interface ReconcilerPorts<Cursor, Page> extends ResilientPorts<Cursor, Page> {
|
|
600
|
-
}
|
|
601
598
|
/**
|
|
602
599
|
* Build a reconciler knob from `config`. `rng` is injected for the underlying
|
|
603
600
|
* scan-retry jitter — pass a fixed `() => 0` in tests to pin backoff; defaults
|
|
604
601
|
* to `Math.random` (read at the verb boundary inside resilient-call, never in a
|
|
605
602
|
* reconciler verb). Inherited straight from paginated-walk.
|
|
606
603
|
*
|
|
607
|
-
* Returns
|
|
608
|
-
* `
|
|
609
|
-
* `
|
|
604
|
+
* Returns plain functions: `init()`, the verbs `scan` / `pageOk` / `pageErr` /
|
|
605
|
+
* `planned` / `applyNext` / `applied` / `onTimer`, the derived `isComplete`,
|
|
606
|
+
* `deadlines(state)` / `timer(state)`, and the scan's page-fetch Cmd def
|
|
607
|
+
* (`scanPage`) to list in the machine's `cmds`.
|
|
610
608
|
*/
|
|
611
609
|
declare function createReconciler<Actual, Desired, Page, Change, ApplyCmd extends Cmd = Cmd, Cursor = number>(config: ReconcilerConfig<Actual, Desired, Page, Change, ApplyCmd, Cursor>, rng?: () => number): {
|
|
610
|
+
/** The scan's page-fetch Cmd def — list it in the machine's `cmds`. */
|
|
611
|
+
scanPage: CmdDef<"resilient_run", {
|
|
612
|
+
readonly key: string;
|
|
613
|
+
readonly input: Cursor;
|
|
614
|
+
}, Page, {
|
|
615
|
+
readonly [detail: string]: unknown;
|
|
616
|
+
readonly _tag: "deadline_exceeded";
|
|
617
|
+
} | {
|
|
618
|
+
readonly [detail: string]: unknown;
|
|
619
|
+
readonly _tag: "port_rejected";
|
|
620
|
+
}>;
|
|
612
621
|
init: () => ReconcilerState<Actual, Change, Page, Cursor>;
|
|
613
622
|
scan: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
614
|
-
pageOk: (s: ReconcilerState<Actual, Change, Page, Cursor>,
|
|
615
|
-
pageErr: (s: ReconcilerState<Actual, Change, Page, Cursor>,
|
|
623
|
+
pageOk: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ScanPageOkMsg<Page>) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
624
|
+
pageErr: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ScanPageErrMsg) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
616
625
|
planned: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number, changes?: readonly Change[]) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
617
626
|
applyNext: (s: ReconcilerState<Actual, Change, Page, Cursor>, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
618
627
|
applied: (s: ReconcilerState<Actual, Change, Page, Cursor>, change: Change, at: number) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
619
628
|
onTimer: (s: ReconcilerState<Actual, Change, Page, Cursor>, msg: ReconcilerTimerMsg) => readonly [ReconcilerState<Actual, Change, Page, Cursor>, readonly (ApplyCmd | ScanPageCmd<Cursor>)[]];
|
|
620
629
|
isComplete: (s: ReconcilerState<Actual, Change, Page, Cursor>) => boolean;
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
resilient_run: (cmd: CmdValue<"resilient_run", {
|
|
624
|
-
readonly key: string;
|
|
625
|
-
readonly input: Cursor;
|
|
626
|
-
}, {
|
|
627
|
-
readonly [detail: string]: unknown;
|
|
628
|
-
readonly _tag: "deadline_exceeded";
|
|
629
|
-
} | {
|
|
630
|
-
readonly [detail: string]: unknown;
|
|
631
|
-
readonly _tag: "port_rejected";
|
|
632
|
-
}, unknown>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<Page>>;
|
|
633
|
-
};
|
|
630
|
+
deadlines: (s: ReconcilerState<Actual, Change, Page, Cursor>) => readonly DeadlineSub[];
|
|
631
|
+
timer: (s: ReconcilerState<Actual, Change, Page, Cursor>) => TimerDeps<ResilientTimerMsg<"resilient">> | null;
|
|
634
632
|
};
|
|
635
633
|
/**
|
|
636
634
|
* Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the slice
|
|
@@ -1107,7 +1105,7 @@ declare function workflowActivityDef<A>(): CmdDef<"workflow_activity", {
|
|
|
1107
1105
|
readonly id: DeliveryId;
|
|
1108
1106
|
/** The opaque activity to perform. */
|
|
1109
1107
|
readonly activity: A;
|
|
1110
|
-
},
|
|
1108
|
+
}, undefined, never>;
|
|
1111
1109
|
type ActivityCmd<A> = CmdOf<ReturnType<typeof workflowActivityDef<A>>>;
|
|
1112
1110
|
/**
|
|
1113
1111
|
* Dispatch a compensation (#125). Same shape + ledger discipline as
|
|
@@ -1125,7 +1123,7 @@ declare function workflowCompensationDef<A>(): CmdDef<"workflow_compensation", {
|
|
|
1125
1123
|
readonly id: DeliveryId;
|
|
1126
1124
|
/** The opaque compensating (inverse) activity to perform. */
|
|
1127
1125
|
readonly compensation: A;
|
|
1128
|
-
},
|
|
1126
|
+
}, undefined, never>;
|
|
1129
1127
|
type CompensationCmd<A> = CmdOf<ReturnType<typeof workflowCompensationDef<A>>>;
|
|
1130
1128
|
/** The Cmd union this module emits: forward activity dispatches AND (#125)
|
|
1131
1129
|
* reverse compensation dispatches. The owed/confirmed ledger events are not
|
|
@@ -1292,4 +1290,4 @@ declare function createWorkflow<A, R, F>(restore?: {
|
|
|
1292
1290
|
*/
|
|
1293
1291
|
declare function foldWorkflow<A, R, F>(steps: WorkflowSteps<A>, msgs: Iterable<WorkflowMsg<R, F>>): WorkflowState<A, R, F>;
|
|
1294
1292
|
|
|
1295
|
-
export { type ActivityCmd, type ActivityErr, type ActivityOk, type AwaitTerminalOptions, type CompensatingWorkflow, type CompensationCmd, type CompensationErr, type CompensationFailedWorkflow, type CompensationOk, type CompletedStep, type CompletedWorkflow,
|
|
1293
|
+
export { type ActivityCmd, type ActivityErr, type ActivityOk, type AwaitTerminalOptions, type CompensatingWorkflow, type CompensationCmd, type CompensationErr, type CompensationFailedWorkflow, type CompensationOk, type CompletedStep, type CompletedWorkflow, DeliveryId, EffectLedgerEvent, type FailedCompensatedWorkflow, type FailedWorkflow, type InFlightActivity, type InFlightCompensation, type Poller, type PollerConfig, type PollerDone, type PollerGaveUp, type PollerPolling, type PollerState, type PollerSub, type ReconcilePhase, type ReconcilerConfig, type ReconcilerState, type ReconcilerTimerMsg, type RunningWorkflow, type SagaConfig, type SagaPhase, type SagaState, type SagaStep, type ScanPageCmd, type ScanPageErrMsg, type ScanPageOkMsg, type StepId, TerminalTimeoutError, WORKFLOW_MSG_TYPES, WORKFLOW_STATUSES, type Workflow, type WorkflowCmd, type WorkflowMsg, type WorkflowMsgType, type WorkflowReducerStep, type WorkflowState, type WorkflowStatus, type WorkflowStep, type WorkflowSteps, awaitTerminal, createPoller, createReconciler, createSaga, createWorkflow, foldWorkflow, initSaga, isAborted, isCommitted, isCompensationFailed, isSettled, liftReconciler, routeWorkflowMsg, runToTerminal, workflowActivityDef, workflowCompensationDef };
|
package/dist/flow/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { createPaginatedWalk, PAGE_KEY } from '../chunk-NSIAORRY.js';
|
|
2
|
+
export { addItem, batchWindowExpired, createBatchWindow, initBatchWindow, onWindow, subsFor, subscribeBatchWindow, timerFor } from '../chunk-MVZS5FDM.js';
|
|
2
3
|
export { debounce } from '../chunk-LFZUK6J2.js';
|
|
3
|
-
import { createPaginatedWalk, PAGE_KEY } from '../chunk-I5MQMJDW.js';
|
|
4
4
|
import { pendingEffectsLedger, foldLedger, survivingEffects } from '../chunk-6IQPODUF.js';
|
|
5
5
|
export { emptyLedger } from '../chunk-6IQPODUF.js';
|
|
6
|
-
export { createMonitoredRun, liftRun } from '../chunk-
|
|
7
|
-
|
|
6
|
+
export { createMonitoredRun, liftRun } from '../chunk-7MGXQZPW.js';
|
|
7
|
+
import '../chunk-CIHSHLQX.js';
|
|
8
|
+
export { createFanOut, initFanOut, isComplete } from '../chunk-QNGYQMZB.js';
|
|
8
9
|
import { idempotencyMemory } from '../chunk-PR6TB3BL.js';
|
|
9
10
|
import { queueAdapter } from '../chunk-TXN2KFHF.js';
|
|
10
|
-
import '../chunk-
|
|
11
|
-
import '../chunk-AQ6ZIMEA.js';
|
|
11
|
+
import '../chunk-6NG4V5SB.js';
|
|
12
12
|
import { asRng, defaultRetryPolicy, initRetry, recordFailure, shouldRetry, nextDelayMs } from '../chunk-VBDU4JL6.js';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import { run
|
|
16
|
-
import
|
|
13
|
+
import { undefinedOnly, unchecked } from '../chunk-4LPY67E4.js';
|
|
14
|
+
import { deadlineSub, initCache, get, set } from '../chunk-IVJP3GKJ.js';
|
|
15
|
+
import { run } from '../chunk-WT5PBPLB.js';
|
|
16
|
+
import '../chunk-5XU6ZJO2.js';
|
|
17
|
+
import '../chunk-GOX2CYIM.js';
|
|
18
|
+
import { Cmd } from '../chunk-CH5KTOEZ.js';
|
|
17
19
|
|
|
18
20
|
// src/internal/flow/await-terminal/index.ts
|
|
19
21
|
var TerminalTimeoutError = class extends Error {
|
|
@@ -67,10 +69,10 @@ function awaitTerminal(runtime, isTerminal, opts = {}) {
|
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
async function runToTerminal(machine, seed, isTerminal, opts = {}) {
|
|
70
|
-
const { msgs, ...
|
|
72
|
+
const { msgs, ...runOpts } = seed;
|
|
71
73
|
const runtime = await run(
|
|
72
74
|
machine,
|
|
73
|
-
|
|
75
|
+
runOpts
|
|
74
76
|
).ready;
|
|
75
77
|
try {
|
|
76
78
|
const terminal = awaitTerminal(runtime, isTerminal, opts);
|
|
@@ -228,12 +230,13 @@ function createReconciler(config, rng = Math.random) {
|
|
|
228
230
|
const next = { ...s, phase: "scanning", walk: w };
|
|
229
231
|
return [next, cmds];
|
|
230
232
|
}
|
|
231
|
-
function pageOk(s,
|
|
233
|
+
function pageOk(s, msg) {
|
|
234
|
+
const { value: page, at } = msg;
|
|
232
235
|
if (s.phase !== "scanning") {
|
|
233
|
-
const [w2] = walk.pageOk(s.walk,
|
|
236
|
+
const [w2] = walk.pageOk(s.walk, msg);
|
|
234
237
|
return [withWalk(s, w2), []];
|
|
235
238
|
}
|
|
236
|
-
const [w, walkCmds] = walk.pageOk(s.walk,
|
|
239
|
+
const [w, walkCmds] = walk.pageOk(s.walk, msg);
|
|
237
240
|
const actual = [...s.actual, ...config.itemsOf(page)];
|
|
238
241
|
const scanned = { ...s, walk: w, actual };
|
|
239
242
|
const cmds = walkCmds;
|
|
@@ -243,8 +246,8 @@ function createReconciler(config, rng = Math.random) {
|
|
|
243
246
|
}
|
|
244
247
|
return [scanned, cmds];
|
|
245
248
|
}
|
|
246
|
-
function pageErr(s,
|
|
247
|
-
const [w, cmds] = walk.pageErr(s.walk,
|
|
249
|
+
function pageErr(s, msg) {
|
|
250
|
+
const [w, cmds] = walk.pageErr(s.walk, msg);
|
|
248
251
|
let next = withWalk(s, w);
|
|
249
252
|
if (s.phase === "scanning" && w.resilience.calls[PAGE_KEY]?.phase === "failed") {
|
|
250
253
|
next = { ...next, phase: "failed" };
|
|
@@ -311,13 +314,15 @@ function createReconciler(config, rng = Math.random) {
|
|
|
311
314
|
function isComplete2(s) {
|
|
312
315
|
return s.phase === "done";
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
return walk.
|
|
317
|
+
function deadlines(s) {
|
|
318
|
+
return walk.deadlines(s.walk);
|
|
316
319
|
}
|
|
317
|
-
function
|
|
318
|
-
return walk.
|
|
320
|
+
function timer(s) {
|
|
321
|
+
return walk.timer(s.walk);
|
|
319
322
|
}
|
|
320
323
|
return {
|
|
324
|
+
/** The scan's page-fetch Cmd def — list it in the machine's `cmds`. */
|
|
325
|
+
scanPage: walk.fetch,
|
|
321
326
|
init,
|
|
322
327
|
scan,
|
|
323
328
|
pageOk,
|
|
@@ -327,8 +332,8 @@ function createReconciler(config, rng = Math.random) {
|
|
|
327
332
|
applied,
|
|
328
333
|
onTimer,
|
|
329
334
|
isComplete: isComplete2,
|
|
330
|
-
|
|
331
|
-
|
|
335
|
+
deadlines,
|
|
336
|
+
timer
|
|
332
337
|
};
|
|
333
338
|
}
|
|
334
339
|
function liftReconciler(state, [slice, cmds]) {
|
|
@@ -506,15 +511,15 @@ var WORKFLOW_STATUSES = new Set(
|
|
|
506
511
|
);
|
|
507
512
|
function workflowActivityDef() {
|
|
508
513
|
return Cmd.define("workflow_activity", {
|
|
509
|
-
input:
|
|
510
|
-
ok:
|
|
514
|
+
input: unchecked(),
|
|
515
|
+
ok: undefinedOnly,
|
|
511
516
|
err: []
|
|
512
517
|
});
|
|
513
518
|
}
|
|
514
519
|
function workflowCompensationDef() {
|
|
515
520
|
return Cmd.define("workflow_compensation", {
|
|
516
|
-
input:
|
|
517
|
-
ok:
|
|
521
|
+
input: unchecked(),
|
|
522
|
+
ok: undefinedOnly,
|
|
518
523
|
err: []
|
|
519
524
|
});
|
|
520
525
|
}
|