@demlik/tea 0.13.0 → 0.15.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 +11 -9
- package/dist/agent/index.d.ts +638 -45
- package/dist/agent/index.js +9 -19
- package/dist/{chunk-RH5EFRVJ.js → chunk-22POWGFA.js} +31 -5
- package/dist/chunk-22POWGFA.js.map +1 -0
- package/dist/{chunk-DMYGQB4O.js → chunk-3B5X7SBB.js} +23 -6
- package/dist/chunk-3B5X7SBB.js.map +1 -0
- package/dist/chunk-66PY5WYF.js +1816 -0
- package/dist/chunk-66PY5WYF.js.map +1 -0
- package/dist/{chunk-25LBDCBC.js → chunk-6IQPODUF.js} +2 -2
- package/dist/{chunk-25LBDCBC.js.map → chunk-6IQPODUF.js.map} +1 -1
- package/dist/chunk-AYS5N6WY.js +505 -0
- package/dist/chunk-AYS5N6WY.js.map +1 -0
- package/dist/{chunk-EWJP3YYP.js → chunk-HWVW4AXC.js} +3 -3
- package/dist/chunk-HWVW4AXC.js.map +1 -0
- package/dist/{chunk-O4MVQTEJ.js → chunk-L3TND7LA.js} +20 -16
- package/dist/chunk-L3TND7LA.js.map +1 -0
- package/dist/{chunk-J6527VRQ.js → chunk-LFZUK6J2.js} +3 -3
- package/dist/chunk-LFZUK6J2.js.map +1 -0
- package/dist/{chunk-D736QUGF.js → chunk-MYXFNWAJ.js} +4 -5
- package/dist/chunk-MYXFNWAJ.js.map +1 -0
- package/dist/{chunk-K575PT4S.js → chunk-PR6TB3BL.js} +15 -4
- package/dist/chunk-PR6TB3BL.js.map +1 -0
- package/dist/{chunk-YUXP55T2.js → chunk-Q5CQTBFA.js} +57 -7
- package/dist/chunk-Q5CQTBFA.js.map +1 -0
- package/dist/{batch-window/index.js → chunk-QPEVCJ5Q.js} +4 -8
- package/dist/chunk-QPEVCJ5Q.js.map +1 -0
- package/dist/chunk-TCLBCERH.js +1480 -0
- package/dist/chunk-TCLBCERH.js.map +1 -0
- package/dist/{chunk-FV3Z5MBE.js → chunk-TXN2KFHF.js} +14 -4
- package/dist/chunk-TXN2KFHF.js.map +1 -0
- package/dist/{chunk-MUUROGIH.js → chunk-V46HSVCK.js} +62 -12
- package/dist/chunk-V46HSVCK.js.map +1 -0
- package/dist/{chunk-Q2UM7BXU.js → chunk-VBDU4JL6.js} +2 -2
- package/dist/chunk-VBDU4JL6.js.map +1 -0
- package/dist/{chunk-ZVJZ72HY.js → chunk-VTQI2NHP.js} +25 -11
- package/dist/chunk-VTQI2NHP.js.map +1 -0
- package/dist/{core-Co0LWkIA.d.ts → core-DnzqWy6u.d.ts} +72 -23
- package/dist/devtools/index.d.ts +2 -2
- package/dist/devtools/index.js +207 -2
- package/dist/devtools/index.js.map +1 -1
- package/dist/do/index.d.ts +43 -29
- package/dist/do/index.js +36 -25
- package/dist/do/index.js.map +1 -1
- package/dist/{durable-effects-C6uwzjb5.d.ts → durable-effects-CWzA-o2B.d.ts} +2 -2
- package/dist/extension/index.d.ts +300 -3
- package/dist/extension/index.js +596 -5
- package/dist/extension/index.js.map +1 -1
- package/dist/flow/index.d.ts +1284 -0
- package/dist/flow/index.js +732 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/idempotency/index.d.ts +90 -116
- package/dist/idempotency/index.js +4 -1
- package/dist/index-Bc40JWVl.d.ts +131 -0
- package/dist/{batch-window/index.d.ts → index-C2DwkjlP.d.ts} +7 -12
- package/dist/index-CA_7I5g9.d.ts +806 -0
- package/dist/index-CSyMYDAB.d.ts +69 -0
- package/dist/{fan-out/index.d.ts → index-CuNO9m8i.d.ts} +7 -9
- package/dist/{debounce/index.d.ts → index-DHSUmQTR.d.ts} +7 -7
- package/dist/{recorder/index.d.ts → index-DrIRb_Ch.d.ts} +4 -7
- package/dist/index-HSYgG2Yt.d.ts +380 -0
- package/dist/{monitored-run/index.d.ts → index-KXqTRJyb.d.ts} +37 -13
- package/dist/{snapshot/index.d.ts → index-ZCMhnVKN.d.ts} +15 -78
- package/dist/index.d.ts +771 -6
- package/dist/index.js +1 -2
- package/dist/jev/index.d.ts +646 -0
- package/dist/jev/index.js +485 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/machine-DGlPWCWI.d.ts +1781 -0
- package/dist/machine-viz/index.d.ts +1 -1
- package/dist/machine-viz/index.js +12 -5
- package/dist/machine-viz/index.js.map +1 -1
- package/dist/mem/index.d.ts +18 -3
- package/dist/mem/index.js +22 -2
- package/dist/mem/index.js.map +1 -1
- package/dist/node/index.d.ts +104 -6
- package/dist/node/index.js +132 -9
- package/dist/node/index.js.map +1 -1
- package/dist/{paginator → paginate}/index.d.ts +140 -6
- package/dist/paginate/index.js +7 -0
- package/dist/parity/index.d.ts +4 -10
- package/dist/parity/index.js +4 -7
- package/dist/parity/index.js.map +1 -1
- package/dist/pbt/index.d.ts +247 -5
- package/dist/pbt/index.js +124 -5
- package/dist/pbt/index.js.map +1 -1
- package/dist/{trace-replay → persistence}/index.d.ts +7 -5
- package/dist/persistence/index.js +6 -0
- package/dist/{protocol-B5YmJr0d.d.ts → protocol-D8VbH-VH.d.ts} +10 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -2
- package/dist/react/index.js.map +1 -1
- package/dist/resilience/index.d.ts +744 -0
- package/dist/resilience/index.js +657 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/retry-backoff/index.d.ts +3 -2
- package/dist/retry-backoff/index.js +1 -1
- package/dist/runtime-types-CMF13BBh.d.ts +998 -0
- package/dist/testing/index.d.ts +147 -3
- package/dist/testing/index.js +95 -3
- package/dist/testing/index.js.map +1 -1
- package/dist/{throttled-input → timing}/index.d.ts +143 -12
- package/dist/{throttled-input → timing}/index.js +57 -12
- package/dist/timing/index.js.map +1 -0
- package/dist/{types-XS_miRnB.d.ts → types-BseNPIhr.d.ts} +1 -1
- package/dist/work-queue/index.d.ts +130 -54
- package/dist/work-queue/index.js +3 -2
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +45 -218
- package/dist/authed-call/index.d.ts +0 -120
- package/dist/authed-call/index.js +0 -134
- package/dist/authed-call/index.js.map +0 -1
- package/dist/await-terminal/index.d.ts +0 -101
- package/dist/await-terminal/index.js +0 -76
- package/dist/await-terminal/index.js.map +0 -1
- package/dist/batch-window/index.js.map +0 -1
- package/dist/cache/index.d.ts +0 -152
- package/dist/cache/index.js +0 -8
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -16
- package/dist/chart/index.js.map +0 -1
- package/dist/chart/inspect/index.d.ts +0 -86
- package/dist/chart/inspect/index.js +0 -5
- package/dist/chart/inspect/react.d.ts +0 -113
- package/dist/chart/inspect/react.js +0 -11
- package/dist/chart/inspect/react.js.map +0 -1
- package/dist/chart/inspect/styles.css +0 -286
- package/dist/chart/lane/index.d.ts +0 -362
- package/dist/chart/lane/index.js +0 -9
- package/dist/chart/lane/index.js.map +0 -1
- package/dist/chart/lane/react.d.ts +0 -84
- package/dist/chart/lane/react.js +0 -559
- package/dist/chart/lane/react.js.map +0 -1
- package/dist/chart/lane/server.d.ts +0 -148
- package/dist/chart/lane/server.js +0 -209
- package/dist/chart/lane/server.js.map +0 -1
- package/dist/chart/lane/styles.css +0 -498
- package/dist/chart/lane/viewer/assets/abnfDiagram-N423BO3Z-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/architectureDiagram-T3A2C74G-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/blockDiagram-VBNYF7ZC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/c4Diagram-5PPSVZJV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-2GRJ4B5K-HdDf8SI3.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-5RXB4S5H-CcNtpUd7.js +0 -231
- package/dist/chart/lane/viewer/assets/chunk-5VM5RSS4-BP4fRS_5.js +0 -15
- package/dist/chart/lane/viewer/assets/chunk-KBJHAD2P-DZOw7xU6.js +0 -1
- package/dist/chart/lane/viewer/assets/chunk-NSK5VX7P-CBCyTZMs.js +0 -128
- package/dist/chart/lane/viewer/assets/classDiagram-JCYQIIEL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/classDiagram-v2-OCEON4UE-D4uAiFr8.js +0 -206
- package/dist/chart/lane/viewer/assets/cose-bilkent-JH36ORCC-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/cynefinDiagram-MW4NZA55-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-K_PewWfS.js +0 -1
- package/dist/chart/lane/viewer/assets/dagre-VZM6K2ZE-831qZcA8.js +0 -4
- package/dist/chart/lane/viewer/assets/diagram-7IWD3JNH-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-B4RE2ZJO-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-LBJQPF4R-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-Q27KOJAE-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/diagram-UB23O5K3-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ebnfDiagram-BXEA7PRR-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/erDiagram-JOGREHBK-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/flowDiagram-UKHOOZJN-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ganttDiagram-PKOTCBZU-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/gitGraphDiagram-DS77QQ5N-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/index-9SkH5NA3.css +0 -1
- package/dist/chart/lane/viewer/assets/index-Bgt4sXpW.js +0 -195
- package/dist/chart/lane/viewer/assets/infoDiagram-6WML65LV-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/ishikawaDiagram-WSZJBQD7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/journeyDiagram-NVQOT4AX-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/kanban-definition-27J2QSJJ-G7PaPzy-.js +0 -89
- package/dist/chart/lane/viewer/assets/katex-DOwCrGXH.js +0 -1
- package/dist/chart/lane/viewer/assets/mindmap-definition-FAOFIHXS-CGj9nrVk.js +0 -96
- package/dist/chart/lane/viewer/assets/path-fybaL0A-.js +0 -1
- package/dist/chart/lane/viewer/assets/pegDiagram-VL7TDLO6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/pieDiagram-7S7Q4E2Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/quadrantDiagram-CIZ2JOQS-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/railroadDiagram-AXF67PYL-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/requirementDiagram-LRYGKXZP-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sankeyDiagram-W5VNT64P-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/sequenceDiagram-SI44F4Z6-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-OKZ733FA-B_88AzBS.js +0 -1
- package/dist/chart/lane/viewer/assets/stateDiagram-v2-UEYNNEHI-CR5gcgq6.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanes-SLNWSIFB-B4xK-rwg.js +0 -1
- package/dist/chart/lane/viewer/assets/swimlanesDiagram-ULZ7WXOC-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/timeline-definition-Z64GVDOM-CCv52MfY.js +0 -120
- package/dist/chart/lane/viewer/assets/vennDiagram-T6HMQDX7-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/wardleyDiagram-T6FBY63Y-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/assets/xychartDiagram-ELKLHX3M-C729LI31.js +0 -1
- package/dist/chart/lane/viewer/index.html +0 -15
- package/dist/chart/report/index.d.ts +0 -117
- package/dist/chart/report/index.js +0 -32
- package/dist/chart/report/index.js.map +0 -1
- package/dist/chunk-2YFLOCWX.js +0 -15
- package/dist/chunk-2YFLOCWX.js.map +0 -1
- package/dist/chunk-3I52QZZ5.js +0 -519
- package/dist/chunk-3I52QZZ5.js.map +0 -1
- package/dist/chunk-3ZAFFRRB.js +0 -457
- package/dist/chunk-3ZAFFRRB.js.map +0 -1
- package/dist/chunk-4EQZ76JC.js +0 -33
- package/dist/chunk-4EQZ76JC.js.map +0 -1
- package/dist/chunk-4KLG43GY.js +0 -223
- package/dist/chunk-4KLG43GY.js.map +0 -1
- package/dist/chunk-7FRZ2CT2.js +0 -424
- package/dist/chunk-7FRZ2CT2.js.map +0 -1
- package/dist/chunk-AZZLE7XR.js +0 -62
- package/dist/chunk-AZZLE7XR.js.map +0 -1
- package/dist/chunk-BYQUGDD3.js +0 -16
- package/dist/chunk-BYQUGDD3.js.map +0 -1
- package/dist/chunk-CIQG5L42.js +0 -685
- package/dist/chunk-CIQG5L42.js.map +0 -1
- package/dist/chunk-CLM6ERNO.js +0 -61
- package/dist/chunk-CLM6ERNO.js.map +0 -1
- package/dist/chunk-COS5MSTO.js +0 -88
- package/dist/chunk-COS5MSTO.js.map +0 -1
- package/dist/chunk-CRPZJVD2.js +0 -71
- package/dist/chunk-CRPZJVD2.js.map +0 -1
- package/dist/chunk-D62FDQKE.js +0 -53
- package/dist/chunk-D62FDQKE.js.map +0 -1
- package/dist/chunk-D736QUGF.js.map +0 -1
- package/dist/chunk-DGE4PV4A.js +0 -26
- package/dist/chunk-DGE4PV4A.js.map +0 -1
- package/dist/chunk-DMYGQB4O.js.map +0 -1
- package/dist/chunk-EWJP3YYP.js.map +0 -1
- package/dist/chunk-FV3Z5MBE.js.map +0 -1
- package/dist/chunk-HCEVHFJ7.js +0 -54
- package/dist/chunk-HCEVHFJ7.js.map +0 -1
- package/dist/chunk-J6527VRQ.js.map +0 -1
- package/dist/chunk-JELSZN25.js +0 -47
- package/dist/chunk-JELSZN25.js.map +0 -1
- package/dist/chunk-K575PT4S.js.map +0 -1
- package/dist/chunk-L57ZOT5K.js +0 -184
- package/dist/chunk-L57ZOT5K.js.map +0 -1
- package/dist/chunk-MU6MCIAC.js +0 -15
- package/dist/chunk-MU6MCIAC.js.map +0 -1
- package/dist/chunk-MUUROGIH.js.map +0 -1
- package/dist/chunk-NR7BU22N.js +0 -758
- package/dist/chunk-NR7BU22N.js.map +0 -1
- package/dist/chunk-O4MVQTEJ.js.map +0 -1
- package/dist/chunk-OOYD44JI.js +0 -317
- package/dist/chunk-OOYD44JI.js.map +0 -1
- package/dist/chunk-Q2UM7BXU.js.map +0 -1
- package/dist/chunk-RH5EFRVJ.js.map +0 -1
- package/dist/chunk-S2EGRPCM.js +0 -47
- package/dist/chunk-S2EGRPCM.js.map +0 -1
- package/dist/chunk-SINXE47Y.js +0 -55
- package/dist/chunk-SINXE47Y.js.map +0 -1
- package/dist/chunk-UF4MZSLT.js +0 -53
- package/dist/chunk-UF4MZSLT.js.map +0 -1
- package/dist/chunk-UOC2PL46.js +0 -13
- package/dist/chunk-UOC2PL46.js.map +0 -1
- package/dist/chunk-VYFAZN3F.js +0 -372
- package/dist/chunk-VYFAZN3F.js.map +0 -1
- package/dist/chunk-WRAA7GVZ.js +0 -209
- package/dist/chunk-WRAA7GVZ.js.map +0 -1
- package/dist/chunk-XGELA764.js +0 -163
- package/dist/chunk-XGELA764.js.map +0 -1
- package/dist/chunk-YUXP55T2.js.map +0 -1
- package/dist/chunk-YWIKDKHY.js +0 -307
- package/dist/chunk-YWIKDKHY.js.map +0 -1
- package/dist/chunk-ZJ5AOYBH.js +0 -8
- package/dist/chunk-ZJ5AOYBH.js.map +0 -1
- package/dist/chunk-ZSUUOEPL.js +0 -731
- package/dist/chunk-ZSUUOEPL.js.map +0 -1
- package/dist/chunk-ZVJZ72HY.js.map +0 -1
- package/dist/circuit-breaker/index.d.ts +0 -197
- package/dist/circuit-breaker/index.js +0 -3
- package/dist/circuit-breaker/index.js.map +0 -1
- package/dist/deadline/index.d.ts +0 -199
- package/dist/deadline/index.js +0 -6
- package/dist/deadline/index.js.map +0 -1
- package/dist/debounce/index.js +0 -3
- package/dist/debounce/index.js.map +0 -1
- package/dist/extension/react.d.ts +0 -121
- package/dist/extension/react.js +0 -75
- package/dist/extension/react.js.map +0 -1
- package/dist/extension/subs/index.d.ts +0 -45
- package/dist/extension/subs/index.js +0 -80
- package/dist/extension/subs/index.js.map +0 -1
- package/dist/extension/test-utils.d.ts +0 -128
- package/dist/extension/test-utils.js +0 -277
- package/dist/extension/test-utils.js.map +0 -1
- package/dist/fan-out/index.js +0 -5
- package/dist/fan-out/index.js.map +0 -1
- package/dist/fold-BJPdjc9w.d.ts +0 -435
- package/dist/graph-B3L5e0N1.d.ts +0 -923
- package/dist/idempotency/adapter.d.ts +0 -62
- package/dist/idempotency/adapter.js +0 -4
- package/dist/idempotency/adapter.js.map +0 -1
- package/dist/idempotent-intake/index.d.ts +0 -188
- package/dist/idempotent-intake/index.js +0 -7
- package/dist/idempotent-intake/index.js.map +0 -1
- package/dist/journal/index.d.ts +0 -373
- package/dist/journal/index.js +0 -3
- package/dist/journal/index.js.map +0 -1
- package/dist/llm-call/index.d.ts +0 -311
- package/dist/llm-call/index.js +0 -16
- package/dist/llm-call/index.js.map +0 -1
- package/dist/machine-BtFWQmmq.d.ts +0 -804
- package/dist/monitored-run/index.js +0 -10
- package/dist/monitored-run/index.js.map +0 -1
- package/dist/paginated-walk/index.d.ts +0 -235
- package/dist/paginated-walk/index.js +0 -16
- package/dist/paginated-walk/index.js.map +0 -1
- package/dist/paginator/index.js +0 -3
- package/dist/paginator/index.js.map +0 -1
- package/dist/pbt/arbitraries/index.d.ts +0 -136
- package/dist/pbt/arbitraries/index.js +0 -3
- package/dist/pbt/arbitraries/index.js.map +0 -1
- package/dist/pbt/runners/index.d.ts +0 -118
- package/dist/pbt/runners/index.js +0 -5
- package/dist/pbt/runners/index.js.map +0 -1
- package/dist/poller/index.d.ts +0 -352
- package/dist/poller/index.js +0 -115
- package/dist/poller/index.js.map +0 -1
- package/dist/prediction/index.d.ts +0 -131
- package/dist/prediction/index.js +0 -4
- package/dist/prediction/index.js.map +0 -1
- package/dist/pure/index.d.ts +0 -3
- package/dist/pure/index.js +0 -4
- package/dist/pure/index.js.map +0 -1
- package/dist/rate-limit/index.d.ts +0 -115
- package/dist/rate-limit/index.js +0 -3
- package/dist/rate-limit/index.js.map +0 -1
- package/dist/reconciler/index.d.ts +0 -193
- package/dist/reconciler/index.js +0 -164
- package/dist/reconciler/index.js.map +0 -1
- package/dist/recorder/index.js +0 -3
- package/dist/recorder/index.js.map +0 -1
- package/dist/reducer-4GNR6b8B.d.ts +0 -447
- package/dist/resilient-call/index.d.ts +0 -320
- package/dist/resilient-call/index.js +0 -14
- package/dist/resilient-call/index.js.map +0 -1
- package/dist/retry-to-success/index.d.ts +0 -109
- package/dist/retry-to-success/index.js +0 -37
- package/dist/retry-to-success/index.js.map +0 -1
- package/dist/run-pAcmBpah.d.ts +0 -713
- package/dist/runtime-types-CNLmhWif.d.ts +0 -517
- package/dist/saga/index.d.ts +0 -241
- package/dist/saga/index.js +0 -150
- package/dist/saga/index.js.map +0 -1
- package/dist/samples-B3My5oh2.d.ts +0 -59
- package/dist/snapshot/index.js +0 -5
- package/dist/snapshot/index.js.map +0 -1
- package/dist/subs/index.d.ts +0 -472
- package/dist/subs/index.js +0 -7
- package/dist/subs/index.js.map +0 -1
- package/dist/throttle/index.d.ts +0 -134
- package/dist/throttle/index.js +0 -3
- package/dist/throttle/index.js.map +0 -1
- package/dist/throttled-input/index.js.map +0 -1
- package/dist/token-refresh/index.d.ts +0 -216
- package/dist/token-refresh/index.js +0 -6
- package/dist/token-refresh/index.js.map +0 -1
- package/dist/trace-replay/index.js +0 -6
- package/dist/trace-replay/index.js.map +0 -1
- package/dist/with-deadline/index.d.ts +0 -197
- package/dist/with-deadline/index.js +0 -111
- package/dist/with-deadline/index.js.map +0 -1
- package/dist/with-resilience/index.d.ts +0 -225
- package/dist/with-resilience/index.js +0 -240
- package/dist/with-resilience/index.js.map +0 -1
- package/dist/with-telemetry/index.d.ts +0 -150
- package/dist/with-telemetry/index.js +0 -70
- package/dist/with-telemetry/index.js.map +0 -1
- package/dist/work-queue/adapter.d.ts +0 -84
- package/dist/work-queue/adapter.js +0 -4
- package/dist/work-queue/adapter.js.map +0 -1
- package/dist/work-queue/ops.d.ts +0 -71
- package/dist/work-queue/ops.js +0 -3
- package/dist/work-queue/ops.js.map +0 -1
- package/dist/workflow/index.d.ts +0 -485
- package/dist/workflow/index.js +0 -244
- package/dist/workflow/index.js.map +0 -1
- /package/dist/{cache → paginate}/index.js.map +0 -0
- /package/dist/{chart/inspect → persistence}/index.js.map +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/work-queue/index.ts"],"names":[],"mappings":";;;AAsCA,SAAS,KAAA,GAAgB;AACvB,EAAA,OACE,WAAW,MAAA,EAAQ,UAAA,IAAa,IAChC,CAAA,EAAA,EAAK,KAAK,GAAA,EAAK,CAAA,CAAA,EAAI,IAAA,CAAK,QAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAE1D;AA2CO,SAAS,YAAe,KAAA,EAA8B;AAM3D,EAAA,eAAe,UAAA,GAA6C;AAC1D,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,IAAA,EAAK;AAC7B,IAAA,OAAO,KAAA,CAAM,QAAQ,GAAG,CAAA;AAAA,EAC1B;AAEA,EAAA,eAAe,IAAA,GAAgC;AAC7C,IAAA,OAAQ,MAAM,UAAA,EAAW,IAAM,EAAC;AAAA,EAClC;AAEA,EAAA,eAAe,QAAQ,KAAA,EAA+C;AACpE,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,EAAK;AACzB,IAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,SAAA,CAAa,KAAA,EAAO,KAAA,EAAO,IAAA,CAAK,GAAA,EAAI,EAAG,KAAA,EAAO,CAAA;AACrE,IAAA,MAAM,KAAA,CAAM,KAAK,IAAI,CAAA;AACr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MAAM,EAAE,MAAM,OAAA,EAAQ,GAAI,YAAe,KAAA,EAAO,EAAA,EAAI,CAAC,IAAA,MAAU;AAAA,MAC7D,GAAG,IAAA;AAAA,MACH,MAAA,EAAQ;AAAA,KACV,CAAE,CAAA;AACF,IAAA,IAAI,OAAA,EAAS,MAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AAAA,EACpC;AAEA,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,qBAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * @packageDocumentation\n * @demlik/tea/work-queue — substrate-agnostic work-queue lifecycle on `Store<S>`.\n *\n * Two public surfaces, one shape:\n * - `createQueue(store)` (this file) is the in-process adapter — it binds the\n * pure ops to an injected `Store` and runs `load → mutate → save`.\n * - `@demlik/tea/work-queue/ops` (`./ops`) is the BLESSED, importable surface\n * of those same pure ops. L2 compositions that own their own Model slice\n * (`monitored-run`, `idempotent-intake`, …) import the ops directly and\n * delegate status flips to them instead of re-rolling the transitions.\n * Both routes call the identical ops, so the lifecycle rules live in exactly\n * one place. This mirrors `@demlik/tea/do`'s one-shape-per-package rule.\n *\n * The package is generic in the input payload `I` (audit-specific fields go\n * here in the extension host). `output` is a free-form side-channel correlation\n * token (a backend id, URL, trace id) — typed as `string` because that's its\n * only honest type. Consumers that need structured per-item data persist it in\n * their own store and put the foreign-key string in `output`.\n */\n\nimport type { Store } from \"../index\";\nimport {\n claimNextOp,\n enqueueOp,\n markDoneOp,\n patchItemOp,\n removeOp,\n resetRunningOp,\n} from \"./ops\";\n\n/**\n * Generate a queue-item id at the adapter boundary. Reads `Date.now()` and\n * `Math.random()` — impure helpers belong in the adapter (`index.ts`),\n * never in `ops.ts` (which is purely-functional by contract). Uses native\n * UUID when available, falls back to timestamp + random for environments\n * without `crypto.randomUUID`.\n */\nfunction genId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `q_${Date.now()}_${Math.random().toString(36).slice(2)}`\n );\n}\n\nexport type QueueItemStatus =\n | \"pending\"\n | \"running\"\n | \"done\"\n | \"failed\"\n | \"cancelled\";\n\n/**\n * A single queue entry. Every field is `readonly`: a persisted slice is\n * immutable, so a transition returns a NEW item (the ops always spread —\n * `{ ...item, status: … }`) rather than mutating in place. This type-enforces\n * the durability invariant the consumers already honor by convention, and\n * keeps a slice round-trippable through JSON unchanged across a reload.\n */\nexport interface QueueItem<I> {\n readonly id: string;\n readonly status: QueueItemStatus;\n readonly input: I;\n readonly enqueuedAt: number;\n readonly startedAt?: number;\n readonly finishedAt?: number;\n readonly output?: string;\n readonly error?: string;\n}\n\n/**\n * Caller-facing enqueue payload. Just `I` today — kept named so future\n * variants (priority, deferUntil, …) can grow without breaking callers.\n */\nexport type EnqueueInput<I> = I;\n\n/**\n * Adapter that binds the pure ops to an injected `Store<QueueItem<I>[]>`.\n *\n * `load → mutate → save` is the only durability discipline this package\n * imposes. The store decides what \"save\" means (chrome.storage, KV, DO\n * storage, in-memory) — that decision belongs at the caller.\n *\n * Ops that don't change the queue (e.g. `markDone` on an unknown id) skip the\n * save call so the underlying store doesn't observe a write churn.\n */\nexport function createQueue<I>(store: Store<QueueItem<I>[]>) {\n // `Store<S>.load()` returns `unknown` (invariant 8 boundary). Route\n // through `store.migrate(raw)` to get the typed value before any\n // queue operation reads it — same wiring the substrate's `run()` uses at\n // boot. The work queue is a substrate-agnostic primitive on top of\n // `Store<S>`, so it honors the same contract.\n async function loadParsed(): Promise<QueueItem<I>[] | null> {\n const raw = await store.load();\n return store.migrate(raw);\n }\n\n async function list(): Promise<QueueItem<I>[]> {\n return (await loadParsed()) ?? [];\n }\n\n async function enqueue(input: EnqueueInput<I>): Promise<QueueItem<I>> {\n const queue = await list();\n const { next, item } = enqueueOp<I>(queue, input, Date.now(), genId());\n await store.save(next);\n return item;\n }\n\n async function claimNext(): Promise<QueueItem<I> | null> {\n const queue = await list();\n const result = claimNextOp<I>(queue, Date.now());\n if (!result) return null;\n await store.save(result.next);\n return result.claimed;\n }\n\n // `markDone` ignores the optional second arg by design: completed runs leave\n // the queue, and the consumer is expected to persist any output (auditId,\n // etc.) wherever those completed records belong. Kept in the signature for\n // call-site readability and forward-compat with `bindOutput`.\n async function markDone(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = markDoneOp<I>(queue, id);\n if (changed) await store.save(next);\n }\n\n async function markFailed(id: string, error: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"failed\",\n finishedAt: Date.now(),\n error,\n }));\n if (changed) await store.save(next);\n }\n\n async function markCancelled(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"cancelled\",\n finishedAt: Date.now(),\n }));\n if (changed) await store.save(next);\n }\n\n async function resetRunningToPending(): Promise<void> {\n const queue = await list();\n const { next, changed } = resetRunningOp<I>(queue);\n if (changed) await store.save(next);\n }\n\n async function removeItem(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = removeOp<I>(queue, id);\n if (changed) await store.save(next);\n }\n\n async function retryItem(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"pending\",\n startedAt: undefined,\n finishedAt: undefined,\n error: undefined,\n output: undefined,\n }));\n if (changed) await store.save(next);\n }\n\n // `bindOutput` attaches a side-channel correlation token (string) to a\n // running item without changing its status. The queue can't reach into\n // `I` to mutate it (the substrate is domain-agnostic), so callers that\n // need to thread a backend id / URL / trace id through the lifecycle\n // route it here. Consumers needing structured payloads should persist\n // them in their own store and put the foreign-key string in `output`.\n async function bindOutput(id: string, value: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n output: value,\n }));\n if (changed) await store.save(next);\n }\n\n return {\n enqueue,\n claimNext,\n markDone,\n markFailed,\n markCancelled,\n resetRunningToPending,\n removeItem,\n retryItem,\n bindOutput,\n list,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/internal/work-queue/index.ts"],"names":[],"mappings":";;;;AAqCA,SAAS,KAAA,GAAgB;AACvB,EAAA,OACE,WAAW,MAAA,EAAQ,UAAA,IAAa,IAChC,CAAA,EAAA,EAAK,KAAK,GAAA,EAAK,CAAA,CAAA,EAAI,IAAA,CAAK,QAAO,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAE1D;AA2CO,SAAS,YAAe,KAAA,EAA8B;AAM3D,EAAA,eAAe,UAAA,GAA6C;AAC1D,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,IAAA,EAAK;AAC7B,IAAA,OAAO,KAAA,CAAM,QAAQ,GAAG,CAAA;AAAA,EAC1B;AAEA,EAAA,eAAe,IAAA,GAAgC;AAC7C,IAAA,OAAQ,MAAM,UAAA,EAAW,IAAM,EAAC;AAAA,EAClC;AAEA,EAAA,eAAe,QAAQ,KAAA,EAA+C;AACpE,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,EAAK;AACzB,IAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,SAAA,CAAa,KAAA,EAAO,KAAA,EAAO,IAAA,CAAK,GAAA,EAAI,EAAG,KAAA,EAAO,CAAA;AACrE,IAAA,MAAM,KAAA,CAAM,KAAK,IAAI,CAAA;AACrB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,eAAe,SAAA,GAA0C;AACvD,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,EAAK;AACzB,IAAA,MAAM,MAAA,GAAS,WAAA,CAAe,KAAA,EAAO,IAAA,CAAK,KAAK,CAAA;AAC/C,IAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AACpB,IAAA,MAAM,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OAAO;AAAA,IACL,OAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,qBAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * internal/work-queue — substrate-agnostic work-queue lifecycle on `Store<S>`.\n *\n * Two public surfaces, one shape:\n * - `createQueue(store)` (this file) is the in-process adapter — it binds the\n * pure ops to an injected `Store` and runs `load → mutate → save`.\n * - `internal/work-queue/ops` (`./ops`) is the BLESSED, importable surface\n * of those same pure ops. L2 compositions that own their own Model slice\n * (`monitored-run`, `idempotent-intake`, …) import the ops directly and\n * delegate status flips to them instead of re-rolling the transitions.\n * Both routes call the identical ops, so the lifecycle rules live in exactly\n * one place. This mirrors `@demlik/tea/do`'s one-shape-per-package rule.\n *\n * The package is generic in the input payload `I` (audit-specific fields go\n * here in the extension host). `output` is a free-form side-channel correlation\n * token (a backend id, URL, trace id) — typed as `string` because that's its\n * only honest type. Consumers that need structured per-item data persist it in\n * their own store and put the foreign-key string in `output`.\n */\n\nimport type { Store } from \"../../index\";\nimport {\n claimNextOp,\n enqueueOp,\n markDoneOp,\n patchItemOp,\n removeOp,\n resetRunningOp,\n} from \"./ops\";\n\n/**\n * Generate a queue-item id at the adapter boundary. Reads `Date.now()` and\n * `Math.random()` — impure helpers belong in the adapter (`index.ts`),\n * never in `ops.ts` (which is purely-functional by contract). Uses native\n * UUID when available, falls back to timestamp + random for environments\n * without `crypto.randomUUID`.\n */\nfunction genId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `q_${Date.now()}_${Math.random().toString(36).slice(2)}`\n );\n}\n\nexport type QueueItemStatus =\n | \"pending\"\n | \"running\"\n | \"done\"\n | \"failed\"\n | \"cancelled\";\n\n/**\n * A single queue entry. Every field is `readonly`: a persisted slice is\n * immutable, so a transition returns a NEW item (the ops always spread —\n * `{ ...item, status: … }`) rather than mutating in place. This type-enforces\n * the durability invariant the consumers already honor by convention, and\n * keeps a slice round-trippable through JSON unchanged across a reload.\n */\nexport interface QueueItem<I> {\n readonly id: string;\n readonly status: QueueItemStatus;\n readonly input: I;\n readonly enqueuedAt: number;\n readonly startedAt?: number;\n readonly finishedAt?: number;\n readonly output?: string;\n readonly error?: string;\n}\n\n/**\n * Caller-facing enqueue payload. Just `I` today — kept named so future\n * variants (priority, deferUntil, …) can grow without breaking callers.\n */\nexport type EnqueueInput<I> = I;\n\n/**\n * Adapter that binds the pure ops to an injected `Store<QueueItem<I>[]>`.\n *\n * `load → mutate → save` is the only durability discipline this package\n * imposes. The store decides what \"save\" means (chrome.storage, KV, DO\n * storage, in-memory) — that decision belongs at the caller.\n *\n * Ops that don't change the queue (e.g. `markDone` on an unknown id) skip the\n * save call so the underlying store doesn't observe a write churn.\n */\nexport function createQueue<I>(store: Store<QueueItem<I>[]>) {\n // `Store<S>.load()` returns `unknown` (invariant 8 boundary). Route\n // through `store.migrate(raw)` to get the typed value before any\n // queue operation reads it — same wiring the substrate's `run()` uses at\n // boot. The work queue is a substrate-agnostic primitive on top of\n // `Store<S>`, so it honors the same contract.\n async function loadParsed(): Promise<QueueItem<I>[] | null> {\n const raw = await store.load();\n return store.migrate(raw);\n }\n\n async function list(): Promise<QueueItem<I>[]> {\n return (await loadParsed()) ?? [];\n }\n\n async function enqueue(input: EnqueueInput<I>): Promise<QueueItem<I>> {\n const queue = await list();\n const { next, item } = enqueueOp<I>(queue, input, Date.now(), genId());\n await store.save(next);\n return item;\n }\n\n async function claimNext(): Promise<QueueItem<I> | null> {\n const queue = await list();\n const result = claimNextOp<I>(queue, Date.now());\n if (!result) return null;\n await store.save(result.next);\n return result.claimed;\n }\n\n // `markDone` ignores the optional second arg by design: completed runs leave\n // the queue, and the consumer is expected to persist any output (auditId,\n // etc.) wherever those completed records belong. Kept in the signature for\n // call-site readability and forward-compat with `bindOutput`.\n async function markDone(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = markDoneOp<I>(queue, id);\n if (changed) await store.save(next);\n }\n\n async function markFailed(id: string, error: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"failed\",\n finishedAt: Date.now(),\n error,\n }));\n if (changed) await store.save(next);\n }\n\n async function markCancelled(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"cancelled\",\n finishedAt: Date.now(),\n }));\n if (changed) await store.save(next);\n }\n\n async function resetRunningToPending(): Promise<void> {\n const queue = await list();\n const { next, changed } = resetRunningOp<I>(queue);\n if (changed) await store.save(next);\n }\n\n async function removeItem(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = removeOp<I>(queue, id);\n if (changed) await store.save(next);\n }\n\n async function retryItem(id: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n status: \"pending\",\n startedAt: undefined,\n finishedAt: undefined,\n error: undefined,\n output: undefined,\n }));\n if (changed) await store.save(next);\n }\n\n // `bindOutput` attaches a side-channel correlation token (string) to a\n // running item without changing its status. The queue can't reach into\n // `I` to mutate it (the substrate is domain-agnostic), so callers that\n // need to thread a backend id / URL / trace id through the lifecycle\n // route it here. Consumers needing structured payloads should persist\n // them in their own store and put the foreign-key string in `output`.\n async function bindOutput(id: string, value: string): Promise<void> {\n const queue = await list();\n const { next, changed } = patchItemOp<I>(queue, id, (item) => ({\n ...item,\n output: value,\n }));\n if (changed) await store.save(next);\n }\n\n return {\n enqueue,\n claimNext,\n markDone,\n markFailed,\n markCancelled,\n resetRunningToPending,\n removeItem,\n retryItem,\n bindOutput,\n list,\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@demlik/tea",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TEA-faithful state machine substrate — one package, every host adapter. Core + subs + testing, plus React, Durable Object, Chrome extension, Node, in-memory,
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "TEA-faithful state machine substrate — one package, every host adapter. Core + subs + testing, plus React, Durable Object, Chrome extension, Node, in-memory, devtools, and property-testing modules as subpaths.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tea",
|
|
7
7
|
"elm-architecture",
|
|
@@ -31,257 +31,87 @@
|
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"import": "./dist/index.js"
|
|
33
33
|
},
|
|
34
|
-
"./subs": {
|
|
35
|
-
"types": "./dist/subs/index.d.ts",
|
|
36
|
-
"import": "./dist/subs/index.js"
|
|
37
|
-
},
|
|
38
|
-
"./testing": {
|
|
39
|
-
"types": "./dist/testing/index.d.ts",
|
|
40
|
-
"import": "./dist/testing/index.js"
|
|
41
|
-
},
|
|
42
34
|
"./do": {
|
|
43
35
|
"types": "./dist/do/index.d.ts",
|
|
44
36
|
"import": "./dist/do/index.js"
|
|
45
37
|
},
|
|
38
|
+
"./node": {
|
|
39
|
+
"types": "./dist/node/index.d.ts",
|
|
40
|
+
"import": "./dist/node/index.js"
|
|
41
|
+
},
|
|
46
42
|
"./mem": {
|
|
47
43
|
"types": "./dist/mem/index.d.ts",
|
|
48
44
|
"import": "./dist/mem/index.js"
|
|
49
45
|
},
|
|
50
|
-
"./journal": {
|
|
51
|
-
"types": "./dist/journal/index.d.ts",
|
|
52
|
-
"import": "./dist/journal/index.js"
|
|
53
|
-
},
|
|
54
46
|
"./react": {
|
|
55
47
|
"types": "./dist/react/index.d.ts",
|
|
56
48
|
"import": "./dist/react/index.js"
|
|
57
49
|
},
|
|
58
|
-
"./devtools": {
|
|
59
|
-
"types": "./dist/devtools/index.d.ts",
|
|
60
|
-
"import": "./dist/devtools/index.js"
|
|
61
|
-
},
|
|
62
|
-
"./devtools/styles.css": "./dist/devtools/styles.css",
|
|
63
50
|
"./extension": {
|
|
64
51
|
"types": "./dist/extension/index.d.ts",
|
|
65
52
|
"import": "./dist/extension/index.js"
|
|
66
53
|
},
|
|
67
|
-
"./
|
|
68
|
-
"types": "./dist/
|
|
69
|
-
"import": "./dist/
|
|
70
|
-
},
|
|
71
|
-
"./extension/subs": {
|
|
72
|
-
"types": "./dist/extension/subs/index.d.ts",
|
|
73
|
-
"import": "./dist/extension/subs/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./extension/test-utils": {
|
|
76
|
-
"types": "./dist/extension/test-utils.d.ts",
|
|
77
|
-
"import": "./dist/extension/test-utils.js"
|
|
78
|
-
},
|
|
79
|
-
"./work-queue": {
|
|
80
|
-
"types": "./dist/work-queue/index.d.ts",
|
|
81
|
-
"import": "./dist/work-queue/index.js"
|
|
82
|
-
},
|
|
83
|
-
"./work-queue/ops": {
|
|
84
|
-
"types": "./dist/work-queue/ops.d.ts",
|
|
85
|
-
"import": "./dist/work-queue/ops.js"
|
|
86
|
-
},
|
|
87
|
-
"./work-queue/adapter": {
|
|
88
|
-
"types": "./dist/work-queue/adapter.d.ts",
|
|
89
|
-
"import": "./dist/work-queue/adapter.js"
|
|
90
|
-
},
|
|
91
|
-
"./node": {
|
|
92
|
-
"types": "./dist/node/index.d.ts",
|
|
93
|
-
"import": "./dist/node/index.js"
|
|
54
|
+
"./testing": {
|
|
55
|
+
"types": "./dist/testing/index.d.ts",
|
|
56
|
+
"import": "./dist/testing/index.js"
|
|
94
57
|
},
|
|
95
58
|
"./pbt": {
|
|
96
59
|
"types": "./dist/pbt/index.d.ts",
|
|
97
60
|
"import": "./dist/pbt/index.js"
|
|
98
61
|
},
|
|
99
|
-
"./
|
|
100
|
-
"types": "./dist/
|
|
101
|
-
"import": "./dist/
|
|
102
|
-
},
|
|
103
|
-
"./pbt/runners": {
|
|
104
|
-
"types": "./dist/pbt/runners/index.d.ts",
|
|
105
|
-
"import": "./dist/pbt/runners/index.js"
|
|
62
|
+
"./agent": {
|
|
63
|
+
"types": "./dist/agent/index.d.ts",
|
|
64
|
+
"import": "./dist/agent/index.js"
|
|
106
65
|
},
|
|
107
66
|
"./retry-backoff": {
|
|
108
67
|
"types": "./dist/retry-backoff/index.d.ts",
|
|
109
68
|
"import": "./dist/retry-backoff/index.js"
|
|
110
69
|
},
|
|
111
|
-
"./rate-limit": {
|
|
112
|
-
"types": "./dist/rate-limit/index.d.ts",
|
|
113
|
-
"import": "./dist/rate-limit/index.js"
|
|
114
|
-
},
|
|
115
70
|
"./idempotency": {
|
|
116
71
|
"types": "./dist/idempotency/index.d.ts",
|
|
117
72
|
"import": "./dist/idempotency/index.js"
|
|
118
73
|
},
|
|
119
|
-
"./
|
|
120
|
-
"types": "./dist/
|
|
121
|
-
"import": "./dist/
|
|
74
|
+
"./flow": {
|
|
75
|
+
"types": "./dist/flow/index.d.ts",
|
|
76
|
+
"import": "./dist/flow/index.js"
|
|
122
77
|
},
|
|
123
|
-
"./
|
|
124
|
-
"types": "./dist/
|
|
125
|
-
"import": "./dist/
|
|
78
|
+
"./resilience": {
|
|
79
|
+
"types": "./dist/resilience/index.d.ts",
|
|
80
|
+
"import": "./dist/resilience/index.js"
|
|
126
81
|
},
|
|
127
|
-
"./
|
|
128
|
-
"types": "./dist/
|
|
129
|
-
"import": "./dist/
|
|
82
|
+
"./timing": {
|
|
83
|
+
"types": "./dist/timing/index.d.ts",
|
|
84
|
+
"import": "./dist/timing/index.js"
|
|
130
85
|
},
|
|
131
|
-
"./
|
|
132
|
-
"types": "./dist/
|
|
133
|
-
"import": "./dist/
|
|
86
|
+
"./persistence": {
|
|
87
|
+
"types": "./dist/persistence/index.d.ts",
|
|
88
|
+
"import": "./dist/persistence/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./paginate": {
|
|
91
|
+
"types": "./dist/paginate/index.d.ts",
|
|
92
|
+
"import": "./dist/paginate/index.js"
|
|
93
|
+
},
|
|
94
|
+
"./work-queue": {
|
|
95
|
+
"types": "./dist/work-queue/index.d.ts",
|
|
96
|
+
"import": "./dist/work-queue/index.js"
|
|
134
97
|
},
|
|
135
|
-
"./
|
|
136
|
-
"types": "./dist/
|
|
137
|
-
"import": "./dist/
|
|
98
|
+
"./jev": {
|
|
99
|
+
"types": "./dist/jev/index.d.ts",
|
|
100
|
+
"import": "./dist/jev/index.js"
|
|
138
101
|
},
|
|
139
|
-
"./
|
|
140
|
-
"types": "./dist/
|
|
141
|
-
"import": "./dist/
|
|
102
|
+
"./devtools": {
|
|
103
|
+
"types": "./dist/devtools/index.d.ts",
|
|
104
|
+
"import": "./dist/devtools/index.js"
|
|
142
105
|
},
|
|
143
106
|
"./machine-viz": {
|
|
144
107
|
"types": "./dist/machine-viz/index.d.ts",
|
|
145
108
|
"import": "./dist/machine-viz/index.js"
|
|
146
109
|
},
|
|
147
|
-
"./debounce": {
|
|
148
|
-
"types": "./dist/debounce/index.d.ts",
|
|
149
|
-
"import": "./dist/debounce/index.js"
|
|
150
|
-
},
|
|
151
|
-
"./throttle": {
|
|
152
|
-
"types": "./dist/throttle/index.d.ts",
|
|
153
|
-
"import": "./dist/throttle/index.js"
|
|
154
|
-
},
|
|
155
|
-
"./recorder": {
|
|
156
|
-
"types": "./dist/recorder/index.d.ts",
|
|
157
|
-
"import": "./dist/recorder/index.js"
|
|
158
|
-
},
|
|
159
|
-
"./trace-replay": {
|
|
160
|
-
"types": "./dist/trace-replay/index.d.ts",
|
|
161
|
-
"import": "./dist/trace-replay/index.js"
|
|
162
|
-
},
|
|
163
|
-
"./paginator": {
|
|
164
|
-
"types": "./dist/paginator/index.d.ts",
|
|
165
|
-
"import": "./dist/paginator/index.js"
|
|
166
|
-
},
|
|
167
|
-
"./snapshot": {
|
|
168
|
-
"types": "./dist/snapshot/index.d.ts",
|
|
169
|
-
"import": "./dist/snapshot/index.js"
|
|
170
|
-
},
|
|
171
|
-
"./token-refresh": {
|
|
172
|
-
"types": "./dist/token-refresh/index.d.ts",
|
|
173
|
-
"import": "./dist/token-refresh/index.js"
|
|
174
|
-
},
|
|
175
|
-
"./resilient-call": {
|
|
176
|
-
"types": "./dist/resilient-call/index.d.ts",
|
|
177
|
-
"import": "./dist/resilient-call/index.js"
|
|
178
|
-
},
|
|
179
|
-
"./with-telemetry": {
|
|
180
|
-
"types": "./dist/with-telemetry/index.d.ts",
|
|
181
|
-
"import": "./dist/with-telemetry/index.js"
|
|
182
|
-
},
|
|
183
|
-
"./fan-out": {
|
|
184
|
-
"types": "./dist/fan-out/index.d.ts",
|
|
185
|
-
"import": "./dist/fan-out/index.js"
|
|
186
|
-
},
|
|
187
|
-
"./idempotent-intake": {
|
|
188
|
-
"types": "./dist/idempotent-intake/index.d.ts",
|
|
189
|
-
"import": "./dist/idempotent-intake/index.js"
|
|
190
|
-
},
|
|
191
|
-
"./poller": {
|
|
192
|
-
"types": "./dist/poller/index.d.ts",
|
|
193
|
-
"import": "./dist/poller/index.js"
|
|
194
|
-
},
|
|
195
|
-
"./workflow": {
|
|
196
|
-
"types": "./dist/workflow/index.d.ts",
|
|
197
|
-
"import": "./dist/workflow/index.js"
|
|
198
|
-
},
|
|
199
|
-
"./batch-window": {
|
|
200
|
-
"types": "./dist/batch-window/index.d.ts",
|
|
201
|
-
"import": "./dist/batch-window/index.js"
|
|
202
|
-
},
|
|
203
|
-
"./saga": {
|
|
204
|
-
"types": "./dist/saga/index.d.ts",
|
|
205
|
-
"import": "./dist/saga/index.js"
|
|
206
|
-
},
|
|
207
|
-
"./throttled-input": {
|
|
208
|
-
"types": "./dist/throttled-input/index.d.ts",
|
|
209
|
-
"import": "./dist/throttled-input/index.js"
|
|
210
|
-
},
|
|
211
|
-
"./monitored-run": {
|
|
212
|
-
"types": "./dist/monitored-run/index.d.ts",
|
|
213
|
-
"import": "./dist/monitored-run/index.js"
|
|
214
|
-
},
|
|
215
|
-
"./llm-call": {
|
|
216
|
-
"types": "./dist/llm-call/index.d.ts",
|
|
217
|
-
"import": "./dist/llm-call/index.js"
|
|
218
|
-
},
|
|
219
|
-
"./paginated-walk": {
|
|
220
|
-
"types": "./dist/paginated-walk/index.d.ts",
|
|
221
|
-
"import": "./dist/paginated-walk/index.js"
|
|
222
|
-
},
|
|
223
|
-
"./authed-call": {
|
|
224
|
-
"types": "./dist/authed-call/index.d.ts",
|
|
225
|
-
"import": "./dist/authed-call/index.js"
|
|
226
|
-
},
|
|
227
|
-
"./reconciler": {
|
|
228
|
-
"types": "./dist/reconciler/index.d.ts",
|
|
229
|
-
"import": "./dist/reconciler/index.js"
|
|
230
|
-
},
|
|
231
|
-
"./agent": {
|
|
232
|
-
"types": "./dist/agent/index.d.ts",
|
|
233
|
-
"import": "./dist/agent/index.js"
|
|
234
|
-
},
|
|
235
|
-
"./with-deadline": {
|
|
236
|
-
"types": "./dist/with-deadline/index.d.ts",
|
|
237
|
-
"import": "./dist/with-deadline/index.js"
|
|
238
|
-
},
|
|
239
|
-
"./with-resilience": {
|
|
240
|
-
"types": "./dist/with-resilience/index.d.ts",
|
|
241
|
-
"import": "./dist/with-resilience/index.js"
|
|
242
|
-
},
|
|
243
|
-
"./prediction": {
|
|
244
|
-
"types": "./dist/prediction/index.d.ts",
|
|
245
|
-
"import": "./dist/prediction/index.js"
|
|
246
|
-
},
|
|
247
|
-
"./pure": {
|
|
248
|
-
"types": "./dist/pure/index.d.ts",
|
|
249
|
-
"import": "./dist/pure/index.js"
|
|
250
|
-
},
|
|
251
110
|
"./parity": {
|
|
252
111
|
"types": "./dist/parity/index.d.ts",
|
|
253
112
|
"import": "./dist/parity/index.js"
|
|
254
113
|
},
|
|
255
|
-
"./
|
|
256
|
-
"types": "./dist/chart/index.d.ts",
|
|
257
|
-
"import": "./dist/chart/index.js"
|
|
258
|
-
},
|
|
259
|
-
"./chart/inspect": {
|
|
260
|
-
"types": "./dist/chart/inspect/index.d.ts",
|
|
261
|
-
"import": "./dist/chart/inspect/index.js"
|
|
262
|
-
},
|
|
263
|
-
"./chart/inspect/react": {
|
|
264
|
-
"types": "./dist/chart/inspect/react.d.ts",
|
|
265
|
-
"import": "./dist/chart/inspect/react.js"
|
|
266
|
-
},
|
|
267
|
-
"./chart/inspect/styles.css": "./dist/chart/inspect/styles.css",
|
|
268
|
-
"./chart/report": {
|
|
269
|
-
"types": "./dist/chart/report/index.d.ts",
|
|
270
|
-
"import": "./dist/chart/report/index.js"
|
|
271
|
-
},
|
|
272
|
-
"./chart/lane": {
|
|
273
|
-
"types": "./dist/chart/lane/index.d.ts",
|
|
274
|
-
"import": "./dist/chart/lane/index.js"
|
|
275
|
-
},
|
|
276
|
-
"./chart/lane/react": {
|
|
277
|
-
"types": "./dist/chart/lane/react.d.ts",
|
|
278
|
-
"import": "./dist/chart/lane/react.js"
|
|
279
|
-
},
|
|
280
|
-
"./chart/lane/server": {
|
|
281
|
-
"types": "./dist/chart/lane/server.d.ts",
|
|
282
|
-
"import": "./dist/chart/lane/server.js"
|
|
283
|
-
},
|
|
284
|
-
"./chart/lane/styles.css": "./dist/chart/lane/styles.css",
|
|
114
|
+
"./devtools/styles.css": "./dist/devtools/styles.css",
|
|
285
115
|
"./package.json": "./package.json"
|
|
286
116
|
},
|
|
287
117
|
"dependencies": {
|
|
@@ -313,6 +143,7 @@
|
|
|
313
143
|
}
|
|
314
144
|
},
|
|
315
145
|
"devDependencies": {
|
|
146
|
+
"@anthropic-ai/sdk": "0.124.0",
|
|
316
147
|
"@biomejs/biome": "2.3.14",
|
|
317
148
|
"@changesets/cli": "^2.27.11",
|
|
318
149
|
"@cloudflare/workers-types": "4.20260312.1",
|
|
@@ -322,10 +153,9 @@
|
|
|
322
153
|
"@types/react": "19.0.8",
|
|
323
154
|
"@types/react-dom": "19.0.3",
|
|
324
155
|
"@types/ws": "8.5.14",
|
|
325
|
-
"
|
|
156
|
+
"ai": "^7.0.93",
|
|
326
157
|
"fast-check": "^3.23.0",
|
|
327
158
|
"happy-dom": "^20.9.0",
|
|
328
|
-
"mermaid": "^11.16.1",
|
|
329
159
|
"react": "19.0.0",
|
|
330
160
|
"react-dom": "19.0.0",
|
|
331
161
|
"tsup": "^8.3.5",
|
|
@@ -345,22 +175,19 @@
|
|
|
345
175
|
"node": "23.7.0"
|
|
346
176
|
},
|
|
347
177
|
"scripts": {
|
|
348
|
-
"build": "NODE_OPTIONS=--max-old-space-size=8192 tsup
|
|
178
|
+
"build": "NODE_OPTIONS=--max-old-space-size=8192 tsup",
|
|
349
179
|
"lint": "biome check src package.json",
|
|
350
180
|
"lint:worktree": "biome check src package.json",
|
|
351
181
|
"test": "vitest run",
|
|
352
|
-
"demo:saga": "vitest run src/workflow/demo.test.ts",
|
|
353
|
-
"lane:view": "vite --config demo/lane-view/vite.config.ts",
|
|
354
|
-
"lane:watch": "node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/lane-watch.ts",
|
|
182
|
+
"demo:saga": "vitest run src/internal/flow/workflow/demo.test.ts",
|
|
355
183
|
"typecheck": "tsc --noEmit",
|
|
356
184
|
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
357
185
|
"typecheck:consumers": "tsc -p tsconfig.consumers.json",
|
|
358
186
|
"docs:reference": "TEA_DOCS_WRITE=1 vitest run src/docs/reference/generate-reference.test.ts",
|
|
359
187
|
"docs:reference:check": "pnpm run docs:reference && git diff --exit-code -- docs/reference",
|
|
360
188
|
"verify-exports": "node scripts/verify-exports.mjs",
|
|
361
|
-
"
|
|
189
|
+
"verify-optional-peer-install": "node scripts/verify-optional-peer-install.mjs",
|
|
362
190
|
"check:merge-markers": "node scripts/check-merge-markers.mjs",
|
|
363
|
-
"release": "changeset"
|
|
364
|
-
"build:viewer": "node build-viewer.mjs"
|
|
191
|
+
"release": "changeset"
|
|
365
192
|
}
|
|
366
193
|
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { P as PortEmitter, C as Cmd } from '../core-Co0LWkIA.js';
|
|
2
|
-
import { M as MsgType } from '../protocol-B5YmJr0d.js';
|
|
3
|
-
import { ResilientConfig, ResilientState, RunCmd, SucceedMsg, FailMsg, ResilientTimerMsg, ResilientPorts } from '../resilient-call/index.js';
|
|
4
|
-
import { TokenRefreshConfig, Token, TokenState, RefreshTokenCmd, TokenRefreshMsg } from '../token-refresh/index.js';
|
|
5
|
-
import { DeadlineSub } from '../deadline/index.js';
|
|
6
|
-
export { DeadlineExceeded, deadlineSub, subscribeDeadline } from '../deadline/index.js';
|
|
7
|
-
import 'zod';
|
|
8
|
-
import '../cache/index.js';
|
|
9
|
-
import '../types-XS_miRnB.js';
|
|
10
|
-
import '../circuit-breaker/index.js';
|
|
11
|
-
import '../rate-limit/index.js';
|
|
12
|
-
import '../retry-backoff/index.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The authed-call knob. It is `ResilientConfig` widened by the token dimension:
|
|
16
|
-
*
|
|
17
|
-
* - `refresh` — the ONLY required field: the port that mints a fresh `Token`.
|
|
18
|
-
* Identical to token-refresh's `TokenRefreshPorts.refresh`; it is hoisted
|
|
19
|
-
* onto the config (not the ports) so the consumer spells the credential
|
|
20
|
-
* source once, the same way `rng` is curried onto the factory.
|
|
21
|
-
* - `skewMs` — token-refresh's refresh-ahead skew (optional, defaults to 0).
|
|
22
|
-
* - every `ResilientConfig` field (`retry` / `circuit` / `rateLimit` /
|
|
23
|
-
* `cache` / `deadline`) — passed straight through to the resilient-call
|
|
24
|
-
* knob, each still optional, each still "omit a brick → omit its gate".
|
|
25
|
-
*/
|
|
26
|
-
interface AuthedConfig extends ResilientConfig, TokenRefreshConfig {
|
|
27
|
-
/** Mint a fresh credential. The single DI seam the auth dimension adds. */
|
|
28
|
-
readonly refresh: () => Promise<Token>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The composed slice. Three plain-data fields, no closures:
|
|
32
|
-
*
|
|
33
|
-
* - `resilience` — resilient-call's entire slice (circuit, bucket, retry,
|
|
34
|
-
* cache, calls). Owned and mutated only via resilient-call's verbs.
|
|
35
|
-
* - `auth` — token-refresh's `{ token, stale }` slice. Owned and mutated only
|
|
36
|
-
* via token-refresh's verbs.
|
|
37
|
-
* - `authRetry` — per-key count of auth-retries (401 → refresh → retry) spent
|
|
38
|
-
* on a call. Caps the dance at one retry per call so a credential the server
|
|
39
|
-
* keeps rejecting cannot spin forever. A key absent from the record has
|
|
40
|
-
* spent zero. Cleared when a call settles or a fresh `attempt` starts.
|
|
41
|
-
*
|
|
42
|
-
* `pendingAuthRetry` carries the inputs of calls parked waiting for the refresh
|
|
43
|
-
* to land, keyed so `onRefreshed` can re-issue exactly those calls. Plain data —
|
|
44
|
-
* `input` is the same payload the call was issued with.
|
|
45
|
-
*/
|
|
46
|
-
interface AuthedState<I, R> {
|
|
47
|
-
readonly resilience: ResilientState<I, R>;
|
|
48
|
-
readonly auth: TokenState;
|
|
49
|
-
readonly authRetry: Readonly<Record<string, number>>;
|
|
50
|
-
readonly pendingAuthRetry: Readonly<Record<string, I>>;
|
|
51
|
-
}
|
|
52
|
-
/** The two effects this knob emits: resilient-call's run, token-refresh's mint. */
|
|
53
|
-
type AuthedCmd<I> = RunCmd<I> | RefreshTokenCmd;
|
|
54
|
-
/**
|
|
55
|
-
* Every Msg the knob's verbs fold. Resilient-call's settle + timer Msgs, token-
|
|
56
|
-
* refresh's refresh-result Msgs, and the 401 trigger the consumer dispatches
|
|
57
|
-
* when a guarded call comes back unauthorized.
|
|
58
|
-
*/
|
|
59
|
-
type Unauthorized = {
|
|
60
|
-
readonly type: typeof MsgType.Unauthorized;
|
|
61
|
-
readonly key: string;
|
|
62
|
-
readonly at: number;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* The plain-data error a 401 we cannot fix settles with. A `{_tag, ...}`
|
|
66
|
-
* sentinel — NEVER a `new Error(...)` — so the slice stays JSON-serializable
|
|
67
|
-
* (an Error object round-trips to `{}` under JSON and carries a stack trace,
|
|
68
|
-
* both of which break the slice's durability invariant once it is persisted
|
|
69
|
-
* into a `Store<S>` and reloaded). Mirrors resilient-call's `DeadlineExceededError`
|
|
70
|
-
* sentinel discipline. `key` echoes the call that was rejected so a consumer can
|
|
71
|
-
* attribute the failure.
|
|
72
|
-
*/
|
|
73
|
-
type UnauthorizedError = {
|
|
74
|
-
readonly _tag: "unauthorized";
|
|
75
|
-
readonly key: string;
|
|
76
|
-
};
|
|
77
|
-
/** Ports `handlers` needs — resilient-call's run port AND token-refresh's refresh port. */
|
|
78
|
-
interface AuthedPorts<I, R> extends ResilientPorts<I, R> {
|
|
79
|
-
/** Mint a fresh credential. Mirrors `AuthedConfig.refresh` for symmetry at the splice site. */
|
|
80
|
-
readonly refresh: () => Promise<Token>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Build an authed-call knob from `config`. `rng` is injected for retry jitter
|
|
84
|
-
* and threaded straight into the underlying resilient-call knob — pass a fixed
|
|
85
|
-
* `() => 0.5` in tests to pin backoff; defaults to `Math.random` (read only at
|
|
86
|
-
* the verb boundary inside resilient-call, never in a brick op).
|
|
87
|
-
*
|
|
88
|
-
* Returns the uniform L2 knob contract, widened by the auth verbs (`on401`,
|
|
89
|
-
* `onRefreshed`, `installToken`). `I` is the port input type, `R` the result.
|
|
90
|
-
*/
|
|
91
|
-
declare function createAuthedCall<I, R>(config: AuthedConfig, rng?: () => number): {
|
|
92
|
-
init: () => AuthedState<I, R>;
|
|
93
|
-
attempt: (s: AuthedState<I, R>, key: string, input: I, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
94
|
-
succeed: (s: AuthedState<I, R>, key: string, msg: SucceedMsg<R>) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
95
|
-
fail: (s: AuthedState<I, R>, key: string, msg: FailMsg) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
96
|
-
on401: (s: AuthedState<I, R>, key: string, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
97
|
-
installToken: (s: AuthedState<I, R>, token: Token) => AuthedState<I, R>;
|
|
98
|
-
onRefreshed: (s: AuthedState<I, R>, at: number) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
99
|
-
onTimer: (s: AuthedState<I, R>, msg: ResilientTimerMsg) => readonly [AuthedState<I, R>, readonly AuthedCmd<I>[]];
|
|
100
|
-
/** token-refresh's call-boundary verb, re-exposed for proactive expiry refresh. */
|
|
101
|
-
needsRefresh: (s: AuthedState<I, R>, at: number) => boolean;
|
|
102
|
-
subs: (s: AuthedState<I, R>) => readonly DeadlineSub[];
|
|
103
|
-
handlers: (ports: AuthedPorts<I, R>) => {
|
|
104
|
-
refresh_token: (cmd: RefreshTokenCmd, ctx: PortEmitter, dispatch?: ((msg: TokenRefreshMsg) => void) | undefined) => Promise<void | TokenRefreshMsg>;
|
|
105
|
-
resilient_run: (cmd: RunCmd<I>, ctx: Readonly<Record<never, never>>) => Promise<FailMsg | SucceedMsg<R>>;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
/** The shape `createAuthedCall` returns — useful for typing a held knob. */
|
|
109
|
-
type AuthedCall<I, R> = ReturnType<typeof createAuthedCall<I, R>>;
|
|
110
|
-
/**
|
|
111
|
-
* Lift a knob result `[slice, cmds]` into a host `[State, cmds]` where the slice
|
|
112
|
-
* lives at `state.authed`. A convenience for the common single-slice host;
|
|
113
|
-
* consumers with a differently-named field spread by hand. Pure — a thin record
|
|
114
|
-
* rebuild, no clock / RNG.
|
|
115
|
-
*/
|
|
116
|
-
declare function liftAuthed<S extends {
|
|
117
|
-
authed: AuthedState<I, R>;
|
|
118
|
-
}, I, R, C extends Cmd>(state: S, [slice, cmds]: readonly [AuthedState<I, R>, readonly C[]]): readonly [S, readonly C[]];
|
|
119
|
-
|
|
120
|
-
export { type AuthedCall, type AuthedCmd, type AuthedConfig, type AuthedPorts, type AuthedState, DeadlineSub, FailMsg, ResilientState, ResilientTimerMsg, RunCmd, SucceedMsg, Token, TokenRefreshMsg, TokenState, type Unauthorized, type UnauthorizedError, createAuthedCall, liftAuthed };
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { createTokenRefresh, refreshTokenCmd } from '../chunk-CLM6ERNO.js';
|
|
2
|
-
import { createResilientCall } from '../chunk-4KLG43GY.js';
|
|
3
|
-
import '../chunk-JELSZN25.js';
|
|
4
|
-
import '../chunk-RH5EFRVJ.js';
|
|
5
|
-
export { deadlineSub, subscribeDeadline } from '../chunk-DGE4PV4A.js';
|
|
6
|
-
import '../chunk-Q2UM7BXU.js';
|
|
7
|
-
import '../chunk-S2EGRPCM.js';
|
|
8
|
-
import '../chunk-UF4MZSLT.js';
|
|
9
|
-
import '../chunk-VYFAZN3F.js';
|
|
10
|
-
import '../chunk-2YFLOCWX.js';
|
|
11
|
-
import '../chunk-ZJ5AOYBH.js';
|
|
12
|
-
import '../chunk-ZSUUOEPL.js';
|
|
13
|
-
import { without } from '../chunk-OOYD44JI.js';
|
|
14
|
-
|
|
15
|
-
// src/authed-call/index.ts
|
|
16
|
-
function createAuthedCall(config, rng = Math.random) {
|
|
17
|
-
const rc = createResilientCall(config, rng);
|
|
18
|
-
const tr = createTokenRefresh({ skewMs: config.skewMs });
|
|
19
|
-
function init() {
|
|
20
|
-
return {
|
|
21
|
-
resilience: rc.init(),
|
|
22
|
-
auth: tr.init(),
|
|
23
|
-
authRetry: {},
|
|
24
|
-
pendingAuthRetry: {}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function liftResilient(s, [resilience, cmds]) {
|
|
28
|
-
return [{ ...s, resilience }, cmds];
|
|
29
|
-
}
|
|
30
|
-
function clearAuthKey(s, key) {
|
|
31
|
-
return {
|
|
32
|
-
...s,
|
|
33
|
-
authRetry: without(s.authRetry, key),
|
|
34
|
-
pendingAuthRetry: without(s.pendingAuthRetry, key)
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function attempt(s, key, input, at) {
|
|
38
|
-
const cleared = clearAuthKey(s, key);
|
|
39
|
-
return liftResilient(
|
|
40
|
-
cleared,
|
|
41
|
-
rc.attempt(cleared.resilience, key, input, at)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
function succeed(s, key, msg) {
|
|
45
|
-
const settled = clearAuthKey(s, key);
|
|
46
|
-
return liftResilient(settled, rc.succeed(settled.resilience, key, msg));
|
|
47
|
-
}
|
|
48
|
-
function fail(s, key, msg) {
|
|
49
|
-
const [resilience, cmds] = rc.fail(s.resilience, key, msg);
|
|
50
|
-
const next = settleAuthIfDone({ ...s, resilience }, key, resilience);
|
|
51
|
-
return [next, cmds];
|
|
52
|
-
}
|
|
53
|
-
function on401(s, key, at) {
|
|
54
|
-
const spent = s.authRetry[key] ?? 0;
|
|
55
|
-
const call = s.resilience.calls[key];
|
|
56
|
-
const input = call?.phase === "running" || call?.phase === "waiting_retry" ? call.input : void 0;
|
|
57
|
-
if (spent >= 1 || input === void 0) {
|
|
58
|
-
const error = { _tag: "unauthorized", key };
|
|
59
|
-
const [settled] = rc.settleFailed(s.resilience, key, error);
|
|
60
|
-
return [{ ...clearAuthKey(s, key), resilience: settled }, []];
|
|
61
|
-
}
|
|
62
|
-
return [
|
|
63
|
-
{
|
|
64
|
-
...s,
|
|
65
|
-
auth: tr.on401(s.auth),
|
|
66
|
-
authRetry: { ...s.authRetry, [key]: spent + 1 },
|
|
67
|
-
pendingAuthRetry: { ...s.pendingAuthRetry, [key]: input }
|
|
68
|
-
},
|
|
69
|
-
[refreshTokenCmd()]
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
function installToken(s, token) {
|
|
73
|
-
return { ...s, auth: tr.refreshed(s.auth, token) };
|
|
74
|
-
}
|
|
75
|
-
function onRefreshed(s, at) {
|
|
76
|
-
const parked = Object.entries(s.pendingAuthRetry);
|
|
77
|
-
if (parked.length === 0) return [s, []];
|
|
78
|
-
let resilience = s.resilience;
|
|
79
|
-
const cmds = [];
|
|
80
|
-
for (const [key, input] of parked) {
|
|
81
|
-
const [next, runCmds] = rc.attempt(resilience, key, input, at);
|
|
82
|
-
resilience = next;
|
|
83
|
-
cmds.push(...runCmds);
|
|
84
|
-
}
|
|
85
|
-
return [{ ...s, resilience, pendingAuthRetry: {} }, cmds];
|
|
86
|
-
}
|
|
87
|
-
function onTimer(s, msg) {
|
|
88
|
-
const [resilience, cmds] = rc.onTimer(s.resilience, msg);
|
|
89
|
-
const next = settleAuthIfDone({ ...s, resilience }, void 0, resilience);
|
|
90
|
-
return [next, cmds];
|
|
91
|
-
}
|
|
92
|
-
function settleAuthIfDone(s, onlyKey, resilience) {
|
|
93
|
-
const keys = onlyKey !== void 0 ? [onlyKey] : Object.keys(s.authRetry);
|
|
94
|
-
let next = s;
|
|
95
|
-
for (const key of keys) {
|
|
96
|
-
const phase = resilience.calls[key]?.phase;
|
|
97
|
-
if (phase === "succeeded" || phase === "failed") {
|
|
98
|
-
next = clearAuthKey(next, key);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return next;
|
|
102
|
-
}
|
|
103
|
-
function subs(s) {
|
|
104
|
-
return rc.subs(s.resilience);
|
|
105
|
-
}
|
|
106
|
-
function handlers(ports) {
|
|
107
|
-
const trPorts = { refresh: ports.refresh };
|
|
108
|
-
return {
|
|
109
|
-
...rc.handlers({ run: ports.run }),
|
|
110
|
-
...tr.handlers(trPorts)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
init,
|
|
115
|
-
attempt,
|
|
116
|
-
succeed,
|
|
117
|
-
fail,
|
|
118
|
-
on401,
|
|
119
|
-
installToken,
|
|
120
|
-
onRefreshed,
|
|
121
|
-
onTimer,
|
|
122
|
-
/** token-refresh's call-boundary verb, re-exposed for proactive expiry refresh. */
|
|
123
|
-
needsRefresh: (s, at) => tr.needsRefresh(s.auth, at),
|
|
124
|
-
subs,
|
|
125
|
-
handlers
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function liftAuthed(state, [slice, cmds]) {
|
|
129
|
-
return [{ ...state, authed: slice }, cmds];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export { createAuthedCall, liftAuthed };
|
|
133
|
-
//# sourceMappingURL=index.js.map
|
|
134
|
-
//# sourceMappingURL=index.js.map
|