@graphrefly/graphrefly 0.45.0 → 0.47.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 +1 -2
- package/dist/_internal-B23BagFd.d.cts +33 -0
- package/dist/_internal-B23BagFd.d.ts +33 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
- package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
- package/dist/agents-C0Ji9ldU.d.cts +629 -0
- package/dist/agents-C9zexT7I.d.ts +629 -0
- package/dist/audit-BAXb3VOg.d.ts +246 -0
- package/dist/audit-C_bPfkqS.d.cts +246 -0
- package/dist/backoff-7KIK3WQW.js +24 -0
- package/dist/backoff-7KIK3WQW.js.map +1 -0
- package/dist/backoff-Bnb9OoPh.d.cts +6 -0
- package/dist/backoff-Bnb9OoPh.d.ts +6 -0
- package/dist/base/composition/index.cjs +865 -0
- package/dist/base/composition/index.cjs.map +1 -0
- package/dist/base/composition/index.d.cts +468 -0
- package/dist/base/composition/index.d.ts +468 -0
- package/dist/base/composition/index.js +40 -0
- package/dist/base/composition/index.js.map +1 -0
- package/dist/base/index.cjs +6390 -0
- package/dist/base/index.cjs.map +1 -0
- package/dist/base/index.d.cts +21 -0
- package/dist/base/index.d.ts +21 -0
- package/dist/base/index.js +259 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/io/index.cjs +3270 -0
- package/dist/base/io/index.cjs.map +1 -0
- package/dist/base/io/index.d.cts +2245 -0
- package/dist/base/io/index.d.ts +2245 -0
- package/dist/base/io/index.js +117 -0
- package/dist/base/io/index.js.map +1 -0
- package/dist/base/meta/index.cjs +43 -0
- package/dist/base/meta/index.cjs.map +1 -0
- package/dist/base/meta/index.d.cts +45 -0
- package/dist/base/meta/index.d.ts +45 -0
- package/dist/base/meta/index.js +13 -0
- package/dist/base/meta/index.js.map +1 -0
- package/dist/base/mutation/index.cjs +200 -0
- package/dist/base/mutation/index.cjs.map +1 -0
- package/dist/base/mutation/index.d.cts +177 -0
- package/dist/base/mutation/index.d.ts +177 -0
- package/dist/base/mutation/index.js +22 -0
- package/dist/base/mutation/index.js.map +1 -0
- package/dist/base/render/index.cjs +1120 -0
- package/dist/base/render/index.cjs.map +1 -0
- package/dist/base/render/index.d.cts +227 -0
- package/dist/base/render/index.d.ts +227 -0
- package/dist/base/render/index.js +24 -0
- package/dist/base/render/index.js.map +1 -0
- package/dist/base/sources/browser/index.cjs +172 -0
- package/dist/base/sources/browser/index.cjs.map +1 -0
- package/dist/base/sources/browser/index.d.cts +84 -0
- package/dist/base/sources/browser/index.d.ts +84 -0
- package/dist/base/sources/browser/index.js +151 -0
- package/dist/base/sources/browser/index.js.map +1 -0
- package/dist/base/sources/event/index.cjs +98 -0
- package/dist/base/sources/event/index.cjs.map +1 -0
- package/dist/base/sources/event/index.d.cts +91 -0
- package/dist/base/sources/event/index.d.ts +91 -0
- package/dist/base/sources/event/index.js +13 -0
- package/dist/base/sources/event/index.js.map +1 -0
- package/dist/base/sources/index.cjs +755 -0
- package/dist/base/sources/index.cjs.map +1 -0
- package/dist/base/sources/index.d.cts +357 -0
- package/dist/base/sources/index.d.ts +357 -0
- package/dist/base/sources/index.js +42 -0
- package/dist/base/sources/index.js.map +1 -0
- package/dist/base/sources/node/index.cjs +320 -0
- package/dist/base/sources/node/index.cjs.map +1 -0
- package/dist/base/sources/node/index.d.cts +185 -0
- package/dist/base/sources/node/index.d.ts +185 -0
- package/dist/base/sources/node/index.js +306 -0
- package/dist/base/sources/node/index.js.map +1 -0
- package/dist/base/utils/index.cjs +37 -0
- package/dist/base/utils/index.cjs.map +1 -0
- package/dist/base/utils/index.d.cts +37 -0
- package/dist/base/utils/index.d.ts +37 -0
- package/dist/base/utils/index.js +11 -0
- package/dist/base/utils/index.js.map +1 -0
- package/dist/base/worker/index.cjs +548 -0
- package/dist/base/worker/index.cjs.map +1 -0
- package/dist/base/worker/index.d.cts +207 -0
- package/dist/base/worker/index.d.ts +207 -0
- package/dist/base/worker/index.js +20 -0
- package/dist/base/worker/index.js.map +1 -0
- package/dist/breaker-C9skL3d8.d.ts +175 -0
- package/dist/breaker-ugSdq54q.d.cts +175 -0
- package/dist/cascading-CSSbKGrJ.d.ts +199 -0
- package/dist/cascading-baGkiihI.d.cts +199 -0
- package/dist/chunk-22SG74BD.js +207 -0
- package/dist/chunk-22SG74BD.js.map +1 -0
- package/dist/chunk-255UCBG4.js +58 -0
- package/dist/chunk-255UCBG4.js.map +1 -0
- package/dist/chunk-2LO3EL4W.js +1 -0
- package/dist/chunk-2LO3EL4W.js.map +1 -0
- package/dist/chunk-2OB3CEJS.js +1065 -0
- package/dist/chunk-2OB3CEJS.js.map +1 -0
- package/dist/chunk-36NMM65U.js +144 -0
- package/dist/chunk-36NMM65U.js.map +1 -0
- package/dist/chunk-3CEXCBN6.js +1 -0
- package/dist/chunk-3CEXCBN6.js.map +1 -0
- package/dist/chunk-3MUSLI6E.js +105 -0
- package/dist/chunk-3MUSLI6E.js.map +1 -0
- package/dist/chunk-3PSLNJDU.js +884 -0
- package/dist/chunk-3PSLNJDU.js.map +1 -0
- package/dist/chunk-42FQ27MQ.js +594 -0
- package/dist/chunk-42FQ27MQ.js.map +1 -0
- package/dist/chunk-4GYMCUDZ.js +1085 -0
- package/dist/chunk-4GYMCUDZ.js.map +1 -0
- package/dist/chunk-4S53H2KR.js +382 -0
- package/dist/chunk-4S53H2KR.js.map +1 -0
- package/dist/chunk-4XCHZRUJ.js +128 -0
- package/dist/chunk-4XCHZRUJ.js.map +1 -0
- package/dist/chunk-5IMMNARC.js +1153 -0
- package/dist/chunk-5IMMNARC.js.map +1 -0
- package/dist/chunk-6XZYT4SW.js +256 -0
- package/dist/chunk-6XZYT4SW.js.map +1 -0
- package/dist/chunk-7EGRP2VX.js +76 -0
- package/dist/chunk-7EGRP2VX.js.map +1 -0
- package/dist/chunk-A7KV5UK4.js +150 -0
- package/dist/chunk-A7KV5UK4.js.map +1 -0
- package/dist/chunk-APY2SS5X.js +156 -0
- package/dist/chunk-APY2SS5X.js.map +1 -0
- package/dist/chunk-AZDQPQ3V.js +66 -0
- package/dist/chunk-AZDQPQ3V.js.map +1 -0
- package/dist/chunk-BU3SEFA5.js +90 -0
- package/dist/chunk-BU3SEFA5.js.map +1 -0
- package/dist/chunk-BXGZFGZ4.js +189 -0
- package/dist/chunk-BXGZFGZ4.js.map +1 -0
- package/dist/chunk-CGHORL6G.js +579 -0
- package/dist/chunk-CGHORL6G.js.map +1 -0
- package/dist/chunk-CXANAIZU.js +530 -0
- package/dist/chunk-CXANAIZU.js.map +1 -0
- package/dist/chunk-CZQHCKKG.js +1 -0
- package/dist/chunk-CZQHCKKG.js.map +1 -0
- package/dist/chunk-DKNHAICT.js +133 -0
- package/dist/chunk-DKNHAICT.js.map +1 -0
- package/dist/chunk-DM4OMPWK.js +584 -0
- package/dist/chunk-DM4OMPWK.js.map +1 -0
- package/dist/chunk-DMSNO6ZB.js +452 -0
- package/dist/chunk-DMSNO6ZB.js.map +1 -0
- package/dist/chunk-E5OZPDIW.js +229 -0
- package/dist/chunk-E5OZPDIW.js.map +1 -0
- package/dist/chunk-EHRRQ4IC.js +211 -0
- package/dist/chunk-EHRRQ4IC.js.map +1 -0
- package/dist/chunk-EVYY4X5A.js +509 -0
- package/dist/chunk-EVYY4X5A.js.map +1 -0
- package/dist/chunk-FDFD67UO.js +1 -0
- package/dist/chunk-FDFD67UO.js.map +1 -0
- package/dist/chunk-FMPF42Q4.js +13 -0
- package/dist/chunk-FMPF42Q4.js.map +1 -0
- package/dist/chunk-FW23JYNQ.js +454 -0
- package/dist/chunk-FW23JYNQ.js.map +1 -0
- package/dist/chunk-GWRNLJNW.js +2508 -0
- package/dist/chunk-GWRNLJNW.js.map +1 -0
- package/dist/chunk-HL7HUJIX.js +1 -0
- package/dist/chunk-HL7HUJIX.js.map +1 -0
- package/dist/chunk-IHTWQEDR.js +169 -0
- package/dist/chunk-IHTWQEDR.js.map +1 -0
- package/dist/chunk-IJRR6YAI.js +128 -0
- package/dist/chunk-IJRR6YAI.js.map +1 -0
- package/dist/chunk-JGFRAFDL.js +221 -0
- package/dist/chunk-JGFRAFDL.js.map +1 -0
- package/dist/chunk-JKTC747G.js +725 -0
- package/dist/chunk-JKTC747G.js.map +1 -0
- package/dist/chunk-KN3H5CNT.js +11 -0
- package/dist/chunk-KN3H5CNT.js.map +1 -0
- package/dist/chunk-KPG3DGLA.js +1 -0
- package/dist/chunk-KPG3DGLA.js.map +1 -0
- package/dist/chunk-KRNQ6RGQ.js +1 -0
- package/dist/chunk-KRNQ6RGQ.js.map +1 -0
- package/dist/chunk-MLTPJMH6.js +417 -0
- package/dist/chunk-MLTPJMH6.js.map +1 -0
- package/dist/chunk-N3SZ7BMH.js +95 -0
- package/dist/chunk-N3SZ7BMH.js.map +1 -0
- package/dist/chunk-NDUD3IMO.js +540 -0
- package/dist/chunk-NDUD3IMO.js.map +1 -0
- package/dist/chunk-NY2PYHNC.js +873 -0
- package/dist/chunk-NY2PYHNC.js.map +1 -0
- package/dist/chunk-O3MT7DYI.js +225 -0
- package/dist/chunk-O3MT7DYI.js.map +1 -0
- package/dist/chunk-OCUDSN63.js +2386 -0
- package/dist/chunk-OCUDSN63.js.map +1 -0
- package/dist/chunk-OIWU3NYV.js +199 -0
- package/dist/chunk-OIWU3NYV.js.map +1 -0
- package/dist/chunk-OQUIJT7A.js +1 -0
- package/dist/chunk-OQUIJT7A.js.map +1 -0
- package/dist/chunk-P5LBT622.js +105 -0
- package/dist/chunk-P5LBT622.js.map +1 -0
- package/dist/chunk-PKGQG5QQ.js +519 -0
- package/dist/chunk-PKGQG5QQ.js.map +1 -0
- package/dist/chunk-PKPO3JTZ.js +561 -0
- package/dist/chunk-PKPO3JTZ.js.map +1 -0
- package/dist/chunk-PL5UDIQ5.js +118 -0
- package/dist/chunk-PL5UDIQ5.js.map +1 -0
- package/dist/chunk-PZWISPIQ.js +432 -0
- package/dist/chunk-PZWISPIQ.js.map +1 -0
- package/dist/chunk-Q3EYOCZB.js +510 -0
- package/dist/chunk-Q3EYOCZB.js.map +1 -0
- package/dist/chunk-QMBYUVRL.js +15 -0
- package/dist/chunk-QMBYUVRL.js.map +1 -0
- package/dist/chunk-RAGGHLCV.js +200 -0
- package/dist/chunk-RAGGHLCV.js.map +1 -0
- package/dist/chunk-RJOG4IJU.js +1039 -0
- package/dist/chunk-RJOG4IJU.js.map +1 -0
- package/dist/chunk-SOOKUYVM.js +403 -0
- package/dist/chunk-SOOKUYVM.js.map +1 -0
- package/dist/chunk-T5BN5KG7.js +1 -0
- package/dist/chunk-T5BN5KG7.js.map +1 -0
- package/dist/chunk-TNX5ZGDJ.js +574 -0
- package/dist/chunk-TNX5ZGDJ.js.map +1 -0
- package/dist/chunk-TP7244Y6.js +207 -0
- package/dist/chunk-TP7244Y6.js.map +1 -0
- package/dist/chunk-TSBFTJKM.js +57 -0
- package/dist/chunk-TSBFTJKM.js.map +1 -0
- package/dist/chunk-URQ2CBBF.js +143 -0
- package/dist/chunk-URQ2CBBF.js.map +1 -0
- package/dist/chunk-VLAGJZSL.js +1079 -0
- package/dist/chunk-VLAGJZSL.js.map +1 -0
- package/dist/chunk-W2BOPXTI.js +1 -0
- package/dist/chunk-W2BOPXTI.js.map +1 -0
- package/dist/chunk-Y52CS6YA.js +88 -0
- package/dist/chunk-Y52CS6YA.js.map +1 -0
- package/dist/chunk-YCBUWK77.js +92 -0
- package/dist/chunk-YCBUWK77.js.map +1 -0
- package/dist/chunk-YJ4U2D2C.js +314 -0
- package/dist/chunk-YJ4U2D2C.js.map +1 -0
- package/dist/chunk-Z4YXAUDN.js +239 -0
- package/dist/chunk-Z4YXAUDN.js.map +1 -0
- package/dist/chunk-Z65DVDEQ.js +146 -0
- package/dist/chunk-Z65DVDEQ.js.map +1 -0
- package/dist/chunk-Z6EGP5D7.js +92 -0
- package/dist/chunk-Z6EGP5D7.js.map +1 -0
- package/dist/chunk-ZT4WMQW4.js +1575 -0
- package/dist/chunk-ZT4WMQW4.js.map +1 -0
- package/dist/chunk-ZVXXDWIB.js +1282 -0
- package/dist/chunk-ZVXXDWIB.js.map +1 -0
- package/dist/compat/index.cjs +3150 -6
- package/dist/compat/index.cjs.map +1 -1
- package/dist/compat/index.d.cts +116 -1
- package/dist/compat/index.d.ts +116 -1
- package/dist/compat/index.js +175 -2
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/jotai/index.cjs +130 -2
- package/dist/compat/jotai/index.cjs.map +1 -1
- package/dist/compat/jotai/index.d.cts +2 -1
- package/dist/compat/jotai/index.d.ts +2 -1
- package/dist/compat/jotai/index.js +7 -2
- package/dist/compat/jotai/index.js.map +1 -1
- package/dist/compat/nanostores/index.cjs +186 -2
- package/dist/compat/nanostores/index.cjs.map +1 -1
- package/dist/compat/nanostores/index.d.cts +2 -1
- package/dist/compat/nanostores/index.d.ts +2 -1
- package/dist/compat/nanostores/index.js +21 -2
- package/dist/compat/nanostores/index.js.map +1 -1
- package/dist/compat/nestjs/index.cjs +2291 -6
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.d.cts +10 -1
- package/dist/compat/nestjs/index.d.ts +10 -1
- package/dist/compat/nestjs/index.js +76 -2
- package/dist/compat/nestjs/index.js.map +1 -1
- package/dist/compat/react/index.cjs +95 -2
- package/dist/compat/react/index.cjs.map +1 -1
- package/dist/compat/react/index.d.cts +2 -1
- package/dist/compat/react/index.d.ts +2 -1
- package/dist/compat/react/index.js +11 -2
- package/dist/compat/react/index.js.map +1 -1
- package/dist/compat/solid/index.cjs +82 -2
- package/dist/compat/solid/index.cjs.map +1 -1
- package/dist/compat/solid/index.d.cts +2 -1
- package/dist/compat/solid/index.d.ts +2 -1
- package/dist/compat/solid/index.js +11 -2
- package/dist/compat/solid/index.js.map +1 -1
- package/dist/compat/svelte/index.cjs +85 -2
- package/dist/compat/svelte/index.cjs.map +1 -1
- package/dist/compat/svelte/index.d.cts +2 -1
- package/dist/compat/svelte/index.d.ts +2 -1
- package/dist/compat/svelte/index.js +11 -2
- package/dist/compat/svelte/index.js.map +1 -1
- package/dist/compat/vue/index.cjs +100 -2
- package/dist/compat/vue/index.cjs.map +1 -1
- package/dist/compat/vue/index.d.cts +3 -1
- package/dist/compat/vue/index.d.ts +3 -1
- package/dist/compat/vue/index.js +11 -2
- package/dist/compat/vue/index.js.map +1 -1
- package/dist/compat/zustand/index.cjs +50 -2
- package/dist/compat/zustand/index.cjs.map +1 -1
- package/dist/compat/zustand/index.d.cts +2 -1
- package/dist/compat/zustand/index.d.ts +2 -1
- package/dist/compat/zustand/index.js +7 -2
- package/dist/compat/zustand/index.js.map +1 -1
- package/dist/distill-De6Rnn15.d.cts +48 -0
- package/dist/distill-De6Rnn15.d.ts +48 -0
- package/dist/external-register-CWyroXb_.d.cts +138 -0
- package/dist/external-register-CWyroXb_.d.ts +138 -0
- package/dist/fallback-Bx46zqky.d.cts +243 -0
- package/dist/fallback-pIWW8A2d.d.ts +243 -0
- package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
- package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
- package/dist/index-B6pxYJzO.d.cts +36 -0
- package/dist/index-B6pxYJzO.d.ts +36 -0
- package/dist/index-BFsng6v1.d.cts +44 -0
- package/dist/index-BFsng6v1.d.ts +44 -0
- package/dist/index-B_p8tnvf.d.cts +770 -0
- package/dist/index-Bg-LwEt-.d.cts +45 -0
- package/dist/index-Bg-LwEt-.d.ts +45 -0
- package/dist/index-Brp888t0.d.cts +127 -0
- package/dist/index-Brp888t0.d.ts +127 -0
- package/dist/index-CDfk6jHN.d.cts +37 -0
- package/dist/index-CDfk6jHN.d.ts +37 -0
- package/dist/index-DLAxYaN5.d.cts +169 -0
- package/dist/index-DLAxYaN5.d.ts +169 -0
- package/dist/index-DeWbQzMe.d.cts +34 -0
- package/dist/index-DeWbQzMe.d.ts +34 -0
- package/dist/index-_HDSmPyp.d.ts +770 -0
- package/dist/index-dX9IzPqj.d.cts +86 -0
- package/dist/index-dX9IzPqj.d.ts +86 -0
- package/dist/index.cjs +26009 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -42
- package/dist/index.d.ts +55 -42
- package/dist/index.js +849 -0
- package/dist/index.js.map +1 -1
- package/dist/layout-types-B5aiHYgk.d.cts +72 -0
- package/dist/layout-types-B5aiHYgk.d.ts +72 -0
- package/dist/memory-composers-BryDrRBX.d.cts +529 -0
- package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
- package/dist/observable-B25XqCbZ.d.cts +59 -0
- package/dist/observable-B25XqCbZ.d.ts +59 -0
- package/dist/pipeline-graph-Ce47CB6Y.d.cts +145 -0
- package/dist/pipeline-graph-DXCwY9vG.d.ts +145 -0
- package/dist/presets/ai/index.cjs +4377 -0
- package/dist/presets/ai/index.cjs.map +1 -0
- package/dist/presets/ai/index.d.cts +98 -0
- package/dist/presets/ai/index.d.ts +98 -0
- package/dist/presets/ai/index.js +54 -0
- package/dist/presets/ai/index.js.map +1 -0
- package/dist/presets/harness/index.cjs +5929 -0
- package/dist/presets/harness/index.cjs.map +1 -0
- package/dist/presets/harness/index.d.cts +566 -0
- package/dist/presets/harness/index.d.ts +566 -0
- package/dist/presets/harness/index.js +71 -0
- package/dist/presets/harness/index.js.map +1 -0
- package/dist/presets/index.cjs +9782 -0
- package/dist/presets/index.cjs.map +1 -0
- package/dist/presets/index.d.cts +28 -0
- package/dist/presets/index.d.ts +28 -0
- package/dist/presets/index.js +129 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/inspect/index.cjs +1087 -0
- package/dist/presets/inspect/index.cjs.map +1 -0
- package/dist/presets/inspect/index.d.cts +172 -0
- package/dist/presets/inspect/index.d.ts +172 -0
- package/dist/presets/inspect/index.js +21 -0
- package/dist/presets/inspect/index.js.map +1 -0
- package/dist/presets/resilience/index.cjs +1593 -0
- package/dist/presets/resilience/index.cjs.map +1 -0
- package/dist/presets/resilience/index.d.cts +205 -0
- package/dist/presets/resilience/index.d.ts +205 -0
- package/dist/presets/resilience/index.js +18 -0
- package/dist/presets/resilience/index.js.map +1 -0
- package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
- package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
- package/dist/reactive-layout-fswlBUvX.d.cts +195 -0
- package/dist/reactive-layout-fswlBUvX.d.ts +195 -0
- package/dist/retry-BDbRZ_gx.d.ts +125 -0
- package/dist/retry-DWuhjvsA.d.cts +125 -0
- package/dist/solutions/index.cjs +8200 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +23 -0
- package/dist/solutions/index.d.ts +23 -0
- package/dist/solutions/index.js +55 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/spawnable-5mDY501F.d.cts +746 -0
- package/dist/spawnable-D3lR0oQu.d.ts +746 -0
- package/dist/status-U-rUI79b.d.cts +84 -0
- package/dist/status-U-rUI79b.d.ts +84 -0
- package/dist/timeout-U5O4ESK3.js +12 -0
- package/dist/timeout-U5O4ESK3.js.map +1 -0
- package/dist/types-BB5Lw-pB.d.cts +442 -0
- package/dist/types-BB5Lw-pB.d.ts +442 -0
- package/dist/types-CJWIMJiZ.d.ts +548 -0
- package/dist/types-vCq7ShIm.d.cts +548 -0
- package/dist/utils/ai/browser.cjs +2169 -0
- package/dist/utils/ai/browser.cjs.map +1 -0
- package/dist/utils/ai/browser.d.cts +129 -0
- package/dist/utils/ai/browser.d.ts +129 -0
- package/dist/utils/ai/browser.js +255 -0
- package/dist/utils/ai/browser.js.map +1 -0
- package/dist/utils/ai/index.cjs +8468 -0
- package/dist/utils/ai/index.cjs.map +1 -0
- package/dist/utils/ai/index.d.cts +1777 -0
- package/dist/utils/ai/index.d.ts +1777 -0
- package/dist/utils/ai/index.js +173 -0
- package/dist/utils/ai/index.js.map +1 -0
- package/dist/utils/ai/node.cjs +648 -0
- package/dist/utils/ai/node.cjs.map +1 -0
- package/dist/utils/ai/node.d.cts +57 -0
- package/dist/utils/ai/node.d.ts +57 -0
- package/dist/utils/ai/node.js +84 -0
- package/dist/utils/ai/node.js.map +1 -0
- package/dist/utils/cqrs/index.cjs +1036 -0
- package/dist/utils/cqrs/index.cjs.map +1 -0
- package/dist/utils/cqrs/index.d.cts +438 -0
- package/dist/utils/cqrs/index.d.ts +438 -0
- package/dist/utils/cqrs/index.js +18 -0
- package/dist/utils/cqrs/index.js.map +1 -0
- package/dist/utils/demo-shell/index.cjs +865 -0
- package/dist/utils/demo-shell/index.cjs.map +1 -0
- package/dist/utils/demo-shell/index.d.cts +90 -0
- package/dist/utils/demo-shell/index.d.ts +90 -0
- package/dist/utils/demo-shell/index.js +13 -0
- package/dist/utils/demo-shell/index.js.map +1 -0
- package/dist/utils/domain-templates/index.cjs +732 -0
- package/dist/utils/domain-templates/index.cjs.map +1 -0
- package/dist/utils/domain-templates/index.d.cts +214 -0
- package/dist/utils/domain-templates/index.d.ts +214 -0
- package/dist/utils/domain-templates/index.js +17 -0
- package/dist/utils/domain-templates/index.js.map +1 -0
- package/dist/utils/graphspec/index.cjs +1174 -0
- package/dist/utils/graphspec/index.cjs.map +1 -0
- package/dist/utils/graphspec/index.d.cts +449 -0
- package/dist/utils/graphspec/index.d.ts +449 -0
- package/dist/utils/graphspec/index.js +35 -0
- package/dist/utils/graphspec/index.js.map +1 -0
- package/dist/utils/harness/index.cjs +656 -0
- package/dist/utils/harness/index.cjs.map +1 -0
- package/dist/utils/harness/index.d.cts +542 -0
- package/dist/utils/harness/index.d.ts +542 -0
- package/dist/utils/harness/index.js +56 -0
- package/dist/utils/harness/index.js.map +1 -0
- package/dist/utils/index.cjs +17614 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +96 -0
- package/dist/utils/index.d.ts +96 -0
- package/dist/utils/index.js +514 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inspect/index.cjs +807 -0
- package/dist/utils/inspect/index.cjs.map +1 -0
- package/dist/utils/inspect/index.d.cts +123 -0
- package/dist/utils/inspect/index.d.ts +123 -0
- package/dist/utils/inspect/index.js +30 -0
- package/dist/utils/inspect/index.js.map +1 -0
- package/dist/utils/job-queue/index.cjs +717 -0
- package/dist/utils/job-queue/index.cjs.map +1 -0
- package/dist/utils/job-queue/index.d.cts +200 -0
- package/dist/utils/job-queue/index.d.ts +200 -0
- package/dist/utils/job-queue/index.js +18 -0
- package/dist/utils/job-queue/index.js.map +1 -0
- package/dist/utils/memory/index.cjs +1456 -0
- package/dist/utils/memory/index.cjs.map +1 -0
- package/dist/utils/memory/index.d.cts +660 -0
- package/dist/utils/memory/index.d.ts +660 -0
- package/dist/utils/memory/index.js +19 -0
- package/dist/utils/memory/index.js.map +1 -0
- package/dist/utils/messaging/index.cjs +666 -0
- package/dist/utils/messaging/index.cjs.map +1 -0
- package/dist/utils/messaging/index.d.cts +562 -0
- package/dist/utils/messaging/index.d.ts +562 -0
- package/dist/utils/messaging/index.js +50 -0
- package/dist/utils/messaging/index.js.map +1 -0
- package/dist/utils/orchestration/index.cjs +876 -0
- package/dist/utils/orchestration/index.cjs.map +1 -0
- package/dist/utils/orchestration/index.d.cts +233 -0
- package/dist/utils/orchestration/index.d.ts +233 -0
- package/dist/utils/orchestration/index.js +19 -0
- package/dist/utils/orchestration/index.js.map +1 -0
- package/dist/utils/process/index.cjs +743 -0
- package/dist/utils/process/index.cjs.map +1 -0
- package/dist/utils/process/index.d.cts +411 -0
- package/dist/utils/process/index.d.ts +411 -0
- package/dist/utils/process/index.js +14 -0
- package/dist/utils/process/index.js.map +1 -0
- package/dist/utils/reactive-layout/index.cjs +1607 -0
- package/dist/utils/reactive-layout/index.cjs.map +1 -0
- package/dist/utils/reactive-layout/index.d.cts +492 -0
- package/dist/utils/reactive-layout/index.d.ts +492 -0
- package/dist/utils/reactive-layout/index.js +52 -0
- package/dist/utils/reactive-layout/index.js.map +1 -0
- package/dist/utils/reduction/index.cjs +203 -0
- package/dist/utils/reduction/index.cjs.map +1 -0
- package/dist/utils/reduction/index.d.cts +102 -0
- package/dist/utils/reduction/index.d.ts +102 -0
- package/dist/utils/reduction/index.js +14 -0
- package/dist/utils/reduction/index.js.map +1 -0
- package/dist/utils/resilience/index.cjs +1617 -0
- package/dist/utils/resilience/index.cjs.map +1 -0
- package/dist/utils/resilience/index.d.cts +9 -0
- package/dist/utils/resilience/index.d.ts +9 -0
- package/dist/utils/resilience/index.js +44 -0
- package/dist/utils/resilience/index.js.map +1 -0
- package/dist/utils/surface/index.cjs +1070 -0
- package/dist/utils/surface/index.cjs.map +1 -0
- package/dist/utils/surface/index.d.cts +240 -0
- package/dist/utils/surface/index.d.ts +240 -0
- package/dist/utils/surface/index.js +30 -0
- package/dist/utils/surface/index.js.map +1 -0
- package/dist/utils/topology-view/index.cjs +620 -0
- package/dist/utils/topology-view/index.cjs.map +1 -0
- package/dist/utils/topology-view/index.d.cts +68 -0
- package/dist/utils/topology-view/index.d.ts +68 -0
- package/dist/utils/topology-view/index.js +11 -0
- package/dist/utils/topology-view/index.js.map +1 -0
- package/package.json +293 -241
- package/dist/core/index.cjs +0 -21
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/index.js.map +0 -1
- package/dist/extra/browser.cjs +0 -21
- package/dist/extra/browser.cjs.map +0 -1
- package/dist/extra/browser.d.cts +0 -1
- package/dist/extra/browser.d.ts +0 -1
- package/dist/extra/browser.js +0 -3
- package/dist/extra/browser.js.map +0 -1
- package/dist/extra/index.cjs +0 -21
- package/dist/extra/index.cjs.map +0 -1
- package/dist/extra/index.d.cts +0 -1
- package/dist/extra/index.d.ts +0 -1
- package/dist/extra/index.js +0 -3
- package/dist/extra/index.js.map +0 -1
- package/dist/extra/node.cjs +0 -21
- package/dist/extra/node.cjs.map +0 -1
- package/dist/extra/node.d.cts +0 -1
- package/dist/extra/node.d.ts +0 -1
- package/dist/extra/node.js +0 -3
- package/dist/extra/node.js.map +0 -1
- package/dist/extra/operators.cjs +0 -21
- package/dist/extra/operators.cjs.map +0 -1
- package/dist/extra/operators.d.cts +0 -1
- package/dist/extra/operators.d.ts +0 -1
- package/dist/extra/operators.js +0 -3
- package/dist/extra/operators.js.map +0 -1
- package/dist/extra/reactive.cjs +0 -21
- package/dist/extra/reactive.cjs.map +0 -1
- package/dist/extra/reactive.d.cts +0 -1
- package/dist/extra/reactive.d.ts +0 -1
- package/dist/extra/reactive.js +0 -3
- package/dist/extra/reactive.js.map +0 -1
- package/dist/extra/render/index.cjs +0 -21
- package/dist/extra/render/index.cjs.map +0 -1
- package/dist/extra/render/index.d.cts +0 -1
- package/dist/extra/render/index.d.ts +0 -1
- package/dist/extra/render/index.js +0 -3
- package/dist/extra/render/index.js.map +0 -1
- package/dist/extra/sources.cjs +0 -21
- package/dist/extra/sources.cjs.map +0 -1
- package/dist/extra/sources.d.cts +0 -1
- package/dist/extra/sources.d.ts +0 -1
- package/dist/extra/sources.js +0 -3
- package/dist/extra/sources.js.map +0 -1
- package/dist/extra/storage-browser.cjs +0 -21
- package/dist/extra/storage-browser.cjs.map +0 -1
- package/dist/extra/storage-browser.d.cts +0 -1
- package/dist/extra/storage-browser.d.ts +0 -1
- package/dist/extra/storage-browser.js +0 -3
- package/dist/extra/storage-browser.js.map +0 -1
- package/dist/extra/storage-core.cjs +0 -21
- package/dist/extra/storage-core.cjs.map +0 -1
- package/dist/extra/storage-core.d.cts +0 -1
- package/dist/extra/storage-core.d.ts +0 -1
- package/dist/extra/storage-core.js +0 -3
- package/dist/extra/storage-core.js.map +0 -1
- package/dist/extra/storage-node.cjs +0 -21
- package/dist/extra/storage-node.cjs.map +0 -1
- package/dist/extra/storage-node.d.cts +0 -1
- package/dist/extra/storage-node.d.ts +0 -1
- package/dist/extra/storage-node.js +0 -3
- package/dist/extra/storage-node.js.map +0 -1
- package/dist/extra/storage-tiers-browser.cjs +0 -21
- package/dist/extra/storage-tiers-browser.cjs.map +0 -1
- package/dist/extra/storage-tiers-browser.d.cts +0 -1
- package/dist/extra/storage-tiers-browser.d.ts +0 -1
- package/dist/extra/storage-tiers-browser.js +0 -3
- package/dist/extra/storage-tiers-browser.js.map +0 -1
- package/dist/extra/storage-tiers-node.cjs +0 -21
- package/dist/extra/storage-tiers-node.cjs.map +0 -1
- package/dist/extra/storage-tiers-node.d.cts +0 -1
- package/dist/extra/storage-tiers-node.d.ts +0 -1
- package/dist/extra/storage-tiers-node.js +0 -3
- package/dist/extra/storage-tiers-node.js.map +0 -1
- package/dist/extra/storage-tiers.cjs +0 -21
- package/dist/extra/storage-tiers.cjs.map +0 -1
- package/dist/extra/storage-tiers.d.cts +0 -1
- package/dist/extra/storage-tiers.d.ts +0 -1
- package/dist/extra/storage-tiers.js +0 -3
- package/dist/extra/storage-tiers.js.map +0 -1
- package/dist/extra/storage-wal.cjs +0 -21
- package/dist/extra/storage-wal.cjs.map +0 -1
- package/dist/extra/storage-wal.d.cts +0 -1
- package/dist/extra/storage-wal.d.ts +0 -1
- package/dist/extra/storage-wal.js +0 -3
- package/dist/extra/storage-wal.js.map +0 -1
- package/dist/graph/index.cjs +0 -21
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.d.cts +0 -1
- package/dist/graph/index.d.ts +0 -1
- package/dist/graph/index.js +0 -3
- package/dist/graph/index.js.map +0 -1
- package/dist/patterns/ai/browser.cjs +0 -21
- package/dist/patterns/ai/browser.cjs.map +0 -1
- package/dist/patterns/ai/browser.d.cts +0 -1
- package/dist/patterns/ai/browser.d.ts +0 -1
- package/dist/patterns/ai/browser.js +0 -3
- package/dist/patterns/ai/browser.js.map +0 -1
- package/dist/patterns/ai/index.cjs +0 -21
- package/dist/patterns/ai/index.cjs.map +0 -1
- package/dist/patterns/ai/index.d.cts +0 -1
- package/dist/patterns/ai/index.d.ts +0 -1
- package/dist/patterns/ai/index.js +0 -3
- package/dist/patterns/ai/index.js.map +0 -1
- package/dist/patterns/ai/node.cjs +0 -21
- package/dist/patterns/ai/node.cjs.map +0 -1
- package/dist/patterns/ai/node.d.cts +0 -1
- package/dist/patterns/ai/node.d.ts +0 -1
- package/dist/patterns/ai/node.js +0 -3
- package/dist/patterns/ai/node.js.map +0 -1
- package/dist/patterns/cqrs/index.cjs +0 -21
- package/dist/patterns/cqrs/index.cjs.map +0 -1
- package/dist/patterns/cqrs/index.d.cts +0 -1
- package/dist/patterns/cqrs/index.d.ts +0 -1
- package/dist/patterns/cqrs/index.js +0 -3
- package/dist/patterns/cqrs/index.js.map +0 -1
- package/dist/patterns/demo-shell/index.cjs +0 -21
- package/dist/patterns/demo-shell/index.cjs.map +0 -1
- package/dist/patterns/demo-shell/index.d.cts +0 -1
- package/dist/patterns/demo-shell/index.d.ts +0 -1
- package/dist/patterns/demo-shell/index.js +0 -3
- package/dist/patterns/demo-shell/index.js.map +0 -1
- package/dist/patterns/domain-templates/index.cjs +0 -21
- package/dist/patterns/domain-templates/index.cjs.map +0 -1
- package/dist/patterns/domain-templates/index.d.cts +0 -1
- package/dist/patterns/domain-templates/index.d.ts +0 -1
- package/dist/patterns/domain-templates/index.js +0 -3
- package/dist/patterns/domain-templates/index.js.map +0 -1
- package/dist/patterns/graphspec/index.cjs +0 -21
- package/dist/patterns/graphspec/index.cjs.map +0 -1
- package/dist/patterns/graphspec/index.d.cts +0 -1
- package/dist/patterns/graphspec/index.d.ts +0 -1
- package/dist/patterns/graphspec/index.js +0 -3
- package/dist/patterns/graphspec/index.js.map +0 -1
- package/dist/patterns/harness/index.cjs +0 -21
- package/dist/patterns/harness/index.cjs.map +0 -1
- package/dist/patterns/harness/index.d.cts +0 -1
- package/dist/patterns/harness/index.d.ts +0 -1
- package/dist/patterns/harness/index.js +0 -3
- package/dist/patterns/harness/index.js.map +0 -1
- package/dist/patterns/inspect/index.cjs +0 -21
- package/dist/patterns/inspect/index.cjs.map +0 -1
- package/dist/patterns/inspect/index.d.cts +0 -1
- package/dist/patterns/inspect/index.d.ts +0 -1
- package/dist/patterns/inspect/index.js +0 -3
- package/dist/patterns/inspect/index.js.map +0 -1
- package/dist/patterns/job-queue/index.cjs +0 -21
- package/dist/patterns/job-queue/index.cjs.map +0 -1
- package/dist/patterns/job-queue/index.d.cts +0 -1
- package/dist/patterns/job-queue/index.d.ts +0 -1
- package/dist/patterns/job-queue/index.js +0 -3
- package/dist/patterns/job-queue/index.js.map +0 -1
- package/dist/patterns/memory/index.cjs +0 -21
- package/dist/patterns/memory/index.cjs.map +0 -1
- package/dist/patterns/memory/index.d.cts +0 -1
- package/dist/patterns/memory/index.d.ts +0 -1
- package/dist/patterns/memory/index.js +0 -3
- package/dist/patterns/memory/index.js.map +0 -1
- package/dist/patterns/messaging/index.cjs +0 -21
- package/dist/patterns/messaging/index.cjs.map +0 -1
- package/dist/patterns/messaging/index.d.cts +0 -1
- package/dist/patterns/messaging/index.d.ts +0 -1
- package/dist/patterns/messaging/index.js +0 -3
- package/dist/patterns/messaging/index.js.map +0 -1
- package/dist/patterns/orchestration/index.cjs +0 -21
- package/dist/patterns/orchestration/index.cjs.map +0 -1
- package/dist/patterns/orchestration/index.d.cts +0 -1
- package/dist/patterns/orchestration/index.d.ts +0 -1
- package/dist/patterns/orchestration/index.js +0 -3
- package/dist/patterns/orchestration/index.js.map +0 -1
- package/dist/patterns/process/index.cjs +0 -21
- package/dist/patterns/process/index.cjs.map +0 -1
- package/dist/patterns/process/index.d.cts +0 -1
- package/dist/patterns/process/index.d.ts +0 -1
- package/dist/patterns/process/index.js +0 -3
- package/dist/patterns/process/index.js.map +0 -1
- package/dist/patterns/reactive-layout/index.cjs +0 -21
- package/dist/patterns/reactive-layout/index.cjs.map +0 -1
- package/dist/patterns/reactive-layout/index.d.cts +0 -1
- package/dist/patterns/reactive-layout/index.d.ts +0 -1
- package/dist/patterns/reactive-layout/index.js +0 -3
- package/dist/patterns/reactive-layout/index.js.map +0 -1
- package/dist/patterns/reduction/index.cjs +0 -21
- package/dist/patterns/reduction/index.cjs.map +0 -1
- package/dist/patterns/reduction/index.d.cts +0 -1
- package/dist/patterns/reduction/index.d.ts +0 -1
- package/dist/patterns/reduction/index.js +0 -3
- package/dist/patterns/reduction/index.js.map +0 -1
- package/dist/patterns/surface/index.cjs +0 -21
- package/dist/patterns/surface/index.cjs.map +0 -1
- package/dist/patterns/surface/index.d.cts +0 -1
- package/dist/patterns/surface/index.d.ts +0 -1
- package/dist/patterns/surface/index.js +0 -3
- package/dist/patterns/surface/index.js.map +0 -1
- package/dist/patterns/topology-view/index.cjs +0 -21
- package/dist/patterns/topology-view/index.cjs.map +0 -1
- package/dist/patterns/topology-view/index.d.cts +0 -1
- package/dist/patterns/topology-view/index.d.ts +0 -1
- package/dist/patterns/topology-view/index.js +0 -3
- package/dist/patterns/topology-view/index.js.map +0 -1
- package/dist/testing/index.cjs +0 -21
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -1
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +0 -3
- package/dist/testing/index.js.map +0 -1
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { Node, NodeOptions } from '@graphrefly/pure-ts/core';
|
|
2
|
+
import { G as GateState } from './breaker-ugSdq54q.cjs';
|
|
3
|
+
import { N as NodeOrValue } from './_internal-B23BagFd.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Timeout — emits `ERROR` with `TimeoutError` if no `DATA` arrives within the deadline.
|
|
7
|
+
*
|
|
8
|
+
* §3.1c — caching, fallback & composition sugar. Uses
|
|
9
|
+
* `core/clock.js`-style nanoseconds and a `ResettableTimer` so the deadline
|
|
10
|
+
* resets on each DATA. Distinct from the `operators/control.ts` timeout
|
|
11
|
+
* (which forwards a caller-supplied error/value) — this one is the
|
|
12
|
+
* resilience family's "deadline → ERROR" primitive.
|
|
13
|
+
*
|
|
14
|
+
* **DS-13.5.B (locked 2026-05-01).** Pre-1.0 break: returns
|
|
15
|
+
* {@link TimeoutBundle} with `node` + `timeoutState` companion. Opts
|
|
16
|
+
* accept `Partial<TimeoutOptions>` or `Node<Partial<TimeoutOptions>>`
|
|
17
|
+
* (object-shape, replacing the old `NodeOrValue<number>` flat shape).
|
|
18
|
+
* State preservation across rebind: `ns` change does NOT reset the
|
|
19
|
+
* in-flight deadline — new `ns` applies to next attempt only.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Thrown by {@link withTimeout} when no `DATA` arrives within the deadline.
|
|
24
|
+
*
|
|
25
|
+
* @category extra
|
|
26
|
+
*/
|
|
27
|
+
declare class TimeoutError extends Error {
|
|
28
|
+
name: string;
|
|
29
|
+
constructor(ns: number);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options accepted by {@link withTimeout}.
|
|
33
|
+
*
|
|
34
|
+
* - `ns` — deadline in nanoseconds (must be `> 0`). Required at the
|
|
35
|
+
* first opts settle; missing / non-positive values throw at
|
|
36
|
+
* construction.
|
|
37
|
+
* - `meta` — optional metadata merged onto the result node's `meta`
|
|
38
|
+
* for describe()/explain() introspection. Reactive `meta` updates
|
|
39
|
+
* are picked up on the next attempt's emission.
|
|
40
|
+
*
|
|
41
|
+
* @category extra/resilience
|
|
42
|
+
*/
|
|
43
|
+
interface TimeoutOptions {
|
|
44
|
+
ns: number;
|
|
45
|
+
meta?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Lifecycle-shaped state companion emitted by {@link withTimeout}.
|
|
49
|
+
*
|
|
50
|
+
* Default `equals` dedups on the `status` field — subscribers don't
|
|
51
|
+
* re-fire on identical-shape transitions, but DO fire on every state
|
|
52
|
+
* transition AND on payload changes within the same status (e.g. when
|
|
53
|
+
* `running.startedAt_ns` advances on a fresh attempt).
|
|
54
|
+
*
|
|
55
|
+
* @category extra/resilience
|
|
56
|
+
*/
|
|
57
|
+
type TimeoutState = {
|
|
58
|
+
status: "pending";
|
|
59
|
+
} | {
|
|
60
|
+
status: "running";
|
|
61
|
+
startedAt_ns: number;
|
|
62
|
+
deadline_ns: number;
|
|
63
|
+
} | {
|
|
64
|
+
status: "completed";
|
|
65
|
+
settledAt_ns: number;
|
|
66
|
+
} | {
|
|
67
|
+
status: "errored";
|
|
68
|
+
firedAt_ns: number;
|
|
69
|
+
deadline_ns: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Bundle returned by {@link withTimeout}: the timeout-wrapped output node and
|
|
73
|
+
* its lifecycle-shaped state companion.
|
|
74
|
+
*
|
|
75
|
+
* **Single-subscriber / pipeline-only contract (DS-13.5.B QA, N1, 2026-05-03).**
|
|
76
|
+
* The `timeoutState` companion is allocated once at factory time and shared
|
|
77
|
+
* across all subscribers to `node`. With one subscriber (the typical use
|
|
78
|
+
* case — wire `node` into your downstream chain, optionally observe
|
|
79
|
+
* `timeoutState` separately) the companion reflects a coherent timeline.
|
|
80
|
+
* With **two or more subscribers** to `node`, each subscriber re-runs the
|
|
81
|
+
* producer body and writes into the same `timeoutState`, which can flip
|
|
82
|
+
* between states from different in-flight machines. Don't fan out
|
|
83
|
+
* `node` to multiple subscribers and rely on `timeoutState` accuracy
|
|
84
|
+
* unless you use {@link keepalive} / {@link share}-style consolidation.
|
|
85
|
+
*
|
|
86
|
+
* @category extra/resilience
|
|
87
|
+
*/
|
|
88
|
+
interface TimeoutBundle<T> {
|
|
89
|
+
node: Node<T>;
|
|
90
|
+
timeoutState: Node<TimeoutState>;
|
|
91
|
+
}
|
|
92
|
+
interface TimeoutExtraOpts {
|
|
93
|
+
meta?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap `source` with a deadline. If no `DATA` arrives within `opts.ns`
|
|
97
|
+
* nanoseconds, the result node emits `[[ERROR, TimeoutError]]` and
|
|
98
|
+
* transitions `timeoutState` to `"errored"`.
|
|
99
|
+
*
|
|
100
|
+
* The timer starts on subscription and resets on each `DATA`. `DIRTY`
|
|
101
|
+
* does NOT reset the timer. Terminal messages (`COMPLETE` / `ERROR`)
|
|
102
|
+
* cancel the timer.
|
|
103
|
+
*
|
|
104
|
+
* **Reactive opts (DS-13.5.B, locked 2026-05-01).**
|
|
105
|
+
*
|
|
106
|
+
* - Static-form callers pass `Partial<TimeoutOptions>` (today's path).
|
|
107
|
+
* `ns` is validated at construction; missing / non-positive throws
|
|
108
|
+
* `RangeError`.
|
|
109
|
+
* - Reactive-form callers pass `Node<Partial<TimeoutOptions>>` — each
|
|
110
|
+
* emission shallow-merges over the prior opts. Empty `{}` emissions
|
|
111
|
+
* are no-ops (no rebind, no companion fire). Mid-flight opts swap
|
|
112
|
+
* does NOT reset the in-flight deadline; new `ns` applies to the
|
|
113
|
+
* next `startTimer()` call.
|
|
114
|
+
* - When the opts Node has `cache === undefined` (SENTINEL: no opts
|
|
115
|
+
* emitted yet), the source is paused until the first valid opts
|
|
116
|
+
* settle. The first valid settle must carry `ns > 0` or the timer
|
|
117
|
+
* layer emits an ERROR (downstream observable) — distinct from the
|
|
118
|
+
* construction-time `RangeError` thrown for static / cache-defined
|
|
119
|
+
* invalid values.
|
|
120
|
+
*
|
|
121
|
+
* @param source - Upstream node.
|
|
122
|
+
* @param opts - `Partial<TimeoutOptions>` (static) or
|
|
123
|
+
* `Node<Partial<TimeoutOptions>>` (reactive).
|
|
124
|
+
* @param extraOpts - Forwarded factory metadata (meta field merged
|
|
125
|
+
* onto the result node).
|
|
126
|
+
* @returns {@link TimeoutBundle} with `node` and `timeoutState`.
|
|
127
|
+
*
|
|
128
|
+
* @throws {RangeError} when the first opts settle is missing or has
|
|
129
|
+
* non-positive `ns`.
|
|
130
|
+
*
|
|
131
|
+
* @category extra
|
|
132
|
+
*/
|
|
133
|
+
declare function withTimeout<T>(source: Node<T>, opts: Partial<TimeoutOptions> | Node<Partial<TimeoutOptions>>, extraOpts?: TimeoutExtraOpts): TimeoutBundle<T>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* `budgetGate` — numeric-constraint flow gate (Tier 2.2 promotion from
|
|
137
|
+
* `patterns/reduction/`).
|
|
138
|
+
*
|
|
139
|
+
* Lives alongside the other `extra/resilience/` flow controls (`retry`,
|
|
140
|
+
* `circuitBreaker`, `rateLimiter`, `tokenBucket`, `fallback`, `withStatus`).
|
|
141
|
+
*
|
|
142
|
+
* @module
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/** A reactive constraint for {@link budgetGate}. */
|
|
146
|
+
type BudgetConstraint<T = unknown> = {
|
|
147
|
+
/** Constraint node whose value is checked. */
|
|
148
|
+
node: Node<T>;
|
|
149
|
+
/** Returns `true` when the constraint is satisfied (budget available). */
|
|
150
|
+
check: (value: T) => boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Optional human-readable name for `BudgetGateState.constraintsSnapshot`.
|
|
153
|
+
* Defaults to the constraint Node's `.name` (or `""` when unset).
|
|
154
|
+
*/
|
|
155
|
+
name?: string;
|
|
156
|
+
};
|
|
157
|
+
/** Options for {@link budgetGate}. */
|
|
158
|
+
type BudgetGateOptions = Omit<NodeOptions<unknown>, "describeKind" | "name" | "meta"> & {
|
|
159
|
+
meta?: Record<string, unknown>;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Per-constraint snapshot inside {@link BudgetGateState}. The `value` field is
|
|
163
|
+
* typed as `unknown` because constraint values are generic — most callers
|
|
164
|
+
* carry numeric budgets but the gate doesn't enforce that. Cast at the
|
|
165
|
+
* subscriber site if you need a narrower type.
|
|
166
|
+
*
|
|
167
|
+
* @category extra/resilience
|
|
168
|
+
*/
|
|
169
|
+
interface BudgetConstraintSnapshot {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
readonly satisfied: boolean;
|
|
172
|
+
readonly value: unknown;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Lifecycle-shaped state companion emitted by {@link budgetGate} (DS-13.5.B,
|
|
176
|
+
* locked 2026-05-01). `status` is `"open"` when every constraint's `check`
|
|
177
|
+
* returns true; `"closed"` otherwise. The `constraintsSnapshot` array
|
|
178
|
+
* preserves constraint ordering and reflects the most recent values seen
|
|
179
|
+
* via per-constraint reactive updates.
|
|
180
|
+
*
|
|
181
|
+
* @category extra/resilience
|
|
182
|
+
*/
|
|
183
|
+
interface BudgetGateState {
|
|
184
|
+
readonly status: GateState;
|
|
185
|
+
readonly constraintsSnapshot: ReadonlyArray<BudgetConstraintSnapshot>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Bundle returned by {@link budgetGate}: the gated output node and its
|
|
189
|
+
* gate-state companion. Pre-1.0 break vs. the prior `Node<T>` return —
|
|
190
|
+
* unwrap via `.node` for downstream wiring.
|
|
191
|
+
*
|
|
192
|
+
* @category extra/resilience
|
|
193
|
+
*/
|
|
194
|
+
interface BudgetGateBundle<T> {
|
|
195
|
+
node: Node<T>;
|
|
196
|
+
budgetGateState: Node<BudgetGateState>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Pass-through that respects reactive constraint nodes.
|
|
200
|
+
*
|
|
201
|
+
* DATA flows through when all constraints are satisfied. When any constraint
|
|
202
|
+
* is exceeded, `PAUSE` is sent upstream and DATA is buffered in a FIFO queue.
|
|
203
|
+
* When constraints relax, the queue drains in arrival order and `RESUME` is
|
|
204
|
+
* sent upstream.
|
|
205
|
+
*
|
|
206
|
+
* ## Invariants (do not refactor without preserving)
|
|
207
|
+
*
|
|
208
|
+
* 1. **Terminal force-flush.** On `COMPLETE` / `ERROR` arriving from `source`,
|
|
209
|
+
* every buffered item is emitted downstream BEFORE the terminal message is
|
|
210
|
+
* forwarded. The constraint is intentionally bypassed for the flush — once
|
|
211
|
+
* upstream is done, the caller must see the buffered work, not lose it.
|
|
212
|
+
* See COMPOSITION-GUIDE §19 (terminal-emission operators).
|
|
213
|
+
*
|
|
214
|
+
* 2. **PAUSE-release ordering.** When a constraint flips from saturated →
|
|
215
|
+
* released, the queue drains in FIFO order downstream BEFORE `RESUME` is
|
|
216
|
+
* sent upstream. Reversing the order (RESUME-then-drain) would let new
|
|
217
|
+
* upstream DATA interleave with the queue tail, breaking arrival-order
|
|
218
|
+
* delivery. See COMPOSITION-GUIDE §9, §9a (diamond + batch coalescing).
|
|
219
|
+
*
|
|
220
|
+
* 3. **Deferred RESOLVED.** A `RESOLVED` from `source` while the queue is
|
|
221
|
+
* non-empty is held until the queue drains, then forwarded — so downstream
|
|
222
|
+
* sees `[buffered DATA…, RESOLVED]` in causal order rather than
|
|
223
|
+
* `[RESOLVED, buffered DATA…]`.
|
|
224
|
+
*
|
|
225
|
+
* **Stall risk (qa D4):** if the constraint never relaxes AND no terminal
|
|
226
|
+
* arrives from `source`, the deferred RESOLVED is held forever. Downstream
|
|
227
|
+
* consumers that depend on `RESOLVED` for an `awaitSettled`-style
|
|
228
|
+
* coordination wait stall in this case. PAUSE is sent upstream so source
|
|
229
|
+
* backpressure stops further DATA, but the gate itself has no escape
|
|
230
|
+
* hatch — by design (the producer-pattern is fire-and-forget; recovery
|
|
231
|
+
* happens at the compositor level via timeout, retry, or cancellation).
|
|
232
|
+
*
|
|
233
|
+
* 4. **Constraint DIRTY suppression.** Constraint-node DIRTY does NOT
|
|
234
|
+
* propagate downstream — only `source`-DIRTY does. The gate's downstream
|
|
235
|
+
* semantics track `source`'s wave, not constraint waves.
|
|
236
|
+
*
|
|
237
|
+
* 5. **Lazy PAUSE (qa D3).** PAUSE is sent upstream ONLY when a `source` DATA
|
|
238
|
+
* arrives that fails the constraint check (the first blocked item). A
|
|
239
|
+
* constraint flipping closed BEFORE any source DATA arrives does NOT emit
|
|
240
|
+
* a preemptive PAUSE — upstream may push DATA freely until the first
|
|
241
|
+
* item is buffered. This matches the producer-pattern lazy-activation
|
|
242
|
+
* philosophy (don't impose backpressure for hypothetical future blocks).
|
|
243
|
+
* For eager-PAUSE semantics, wrap the gate in a compositor that watches
|
|
244
|
+
* constraints + source independently.
|
|
245
|
+
*
|
|
246
|
+
* ## Queue
|
|
247
|
+
*
|
|
248
|
+
* The internal buffer is an unbounded {@link HeadIndexQueue} (O(1) push,
|
|
249
|
+
* O(1) shift, opportunistic compaction). It does NOT use {@link RingBuffer}
|
|
250
|
+
* because RingBuffer's drop-oldest eviction would silently lose buffered
|
|
251
|
+
* items between PAUSE and RESUME. Backpressure (PAUSE) is the upstream
|
|
252
|
+
* contract for bounding the queue, not capacity-driven eviction here.
|
|
253
|
+
*
|
|
254
|
+
* ## Producer-pattern: source edge is invisible to `describe()`
|
|
255
|
+
*
|
|
256
|
+
* `budgetGate` is constructed via `node([], fn)` and subscribes to `source`
|
|
257
|
+
* and the constraint nodes manually inside its activation fn. Because no
|
|
258
|
+
* dep is declared at construction, **`describe()` shows no edge from
|
|
259
|
+
* `source` (or any constraint) into the returned node** — the gate looks
|
|
260
|
+
* like a standalone leaf source. This is intentional (see COMPOSITION-GUIDE
|
|
261
|
+
* §24 "Edges are derived, not declared"): if you want the constraint /
|
|
262
|
+
* source dependency to appear in describe output, surface it at the
|
|
263
|
+
* compositor level (e.g. annotate via `meta.ai.upstream`, or wrap the gate
|
|
264
|
+
* in a parent factory that exposes the deps as constructor args).
|
|
265
|
+
*
|
|
266
|
+
* ## Reference equality + Tier 6.5 3.2.5 locked semantics
|
|
267
|
+
*
|
|
268
|
+
* **Constraint VALUES are reactive.** Each `BudgetConstraint.node` is
|
|
269
|
+
* subscribed at activation; per-value changes flip the gate (re-evaluate
|
|
270
|
+
* in the same wave) and trigger PAUSE/RESUME upstream. Per the locked
|
|
271
|
+
* semantic rule for the reactive-options-widening batch (Tier 6.5 3.2.5,
|
|
272
|
+
* 2026-04-29): "constraints array re-evaluated immediately against
|
|
273
|
+
* current source; adding/removing constraints triggers gate
|
|
274
|
+
* re-evaluation in the same wave" — the per-value half is shipped via
|
|
275
|
+
* the existing constraint-Node subscription model.
|
|
276
|
+
*
|
|
277
|
+
* **The constraints ARRAY shape is static.** The factory captures the
|
|
278
|
+
* `constraints` array reference and each `check` function at
|
|
279
|
+
* construction; it does NOT diff subsequent arrays. To add or remove
|
|
280
|
+
* constraints reactively, build the swap at the compositor level (a
|
|
281
|
+
* `switchMap` rebuild over a constraint-shape Node), or construct a new
|
|
282
|
+
* gate. Dynamic constraint-array reactivity is intentionally deferred —
|
|
283
|
+
* the subscription churn (resub on every constraint add/remove) and
|
|
284
|
+
* `latestValues` shape mutation overshoot the budget-gate's
|
|
285
|
+
* fire-and-forget ergonomics.
|
|
286
|
+
*
|
|
287
|
+
* @param source - Input node.
|
|
288
|
+
* @param constraints - Reactive constraint checks. MUST be non-empty.
|
|
289
|
+
* @param opts - Optional node options.
|
|
290
|
+
* @returns Gated node.
|
|
291
|
+
*
|
|
292
|
+
* @throws {RangeError} when `constraints.length === 0`. The gate has no
|
|
293
|
+
* meaningful identity without at least one check — degenerate to plain
|
|
294
|
+
* pass-through (e.g. via `derived([source], ([v]) => v)`) instead.
|
|
295
|
+
*
|
|
296
|
+
* @category resilience
|
|
297
|
+
*/
|
|
298
|
+
declare function budgetGate<T>(source: Node<T>, constraints: ReadonlyArray<BudgetConstraint>, opts?: BudgetGateOptions): BudgetGateBundle<T>;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Fallback — replace upstream ERROR with a static or computed source.
|
|
302
|
+
*
|
|
303
|
+
* Accepts scalar / `Node` / `PromiseLike` / `AsyncIterable` fallbacks; non-Node
|
|
304
|
+
* inputs are routed through `fromAny` so the fallback participates in the
|
|
305
|
+
* reactive protocol uniformly.
|
|
306
|
+
*/
|
|
307
|
+
|
|
308
|
+
/** Inputs accepted by {@link fallback}. */
|
|
309
|
+
type FallbackInput<T> = T | Node<T> | PromiseLike<T> | AsyncIterable<T>;
|
|
310
|
+
/**
|
|
311
|
+
* On upstream terminal `ERROR`, switch to a fallback source instead of propagating the error.
|
|
312
|
+
*
|
|
313
|
+
* Accepts any of:
|
|
314
|
+
* - **scalar value** — emits `[[DATA, fb], [COMPLETE]]`
|
|
315
|
+
* - **`Node<T>`** — subscribes and forwards all messages (push-on-subscribe delivers current cache)
|
|
316
|
+
* - **`Promise<T>` / thenable** — resolves into a one-shot `DATA` then `COMPLETE` (via {@link fromAny})
|
|
317
|
+
* - **`AsyncIterable<T>`** — streams each yielded value as `DATA`, then `COMPLETE` (via {@link fromAny})
|
|
318
|
+
*
|
|
319
|
+
* Non-`Node` inputs are routed through {@link fromAny} so the fallback participates in the
|
|
320
|
+
* reactive protocol uniformly. Bare strings, arrays, and other synchronous scalars are treated
|
|
321
|
+
* as single values (NOT split into characters / elements) to avoid the `fromAny`-on-string
|
|
322
|
+
* iteration gotcha.
|
|
323
|
+
*
|
|
324
|
+
* Composes naturally with {@link retry}:
|
|
325
|
+
* `pipe(source, retry({count:3}), fallback("default"))`.
|
|
326
|
+
*
|
|
327
|
+
* @param source - Upstream node.
|
|
328
|
+
* @param fb - Fallback value, node, promise, or async iterable.
|
|
329
|
+
* @returns Node that replaces errors with the fallback.
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```ts
|
|
333
|
+
* import { fallback, throwError } from "@graphrefly/graphrefly-ts";
|
|
334
|
+
*
|
|
335
|
+
* const safe = fallback(throwError(new Error("boom")), "default");
|
|
336
|
+
* safe.cache; // "default" after subscribe
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @category extra
|
|
340
|
+
*/
|
|
341
|
+
declare function fallback<T>(source: Node<T>, fb: FallbackInput<T>, options?: {
|
|
342
|
+
meta?: Record<string, unknown>;
|
|
343
|
+
}): Node<T>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Rate limiters — `tokenBucket` (raw meter), `rateLimiter` (operator with
|
|
347
|
+
* bounded queue + reactive backpressure companions), and the re-export of
|
|
348
|
+
* `adaptiveRateLimiter` from its standalone module.
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
interface TokenBucket {
|
|
352
|
+
/**
|
|
353
|
+
* Number of tokens currently available (after refill).
|
|
354
|
+
*
|
|
355
|
+
* **Float-valued.** When `refillPerSecond` is fractional (or `capacity` × elapsed-fraction
|
|
356
|
+
* yields a non-integer), the bucket accumulates fractional refill credit between
|
|
357
|
+
* `tryConsume`s. Consumers should not assume integer tokens — e.g. with
|
|
358
|
+
* `tokenBucket(10, 2.5)` after 100ms of elapsed time `available()` may report `0.25`.
|
|
359
|
+
*/
|
|
360
|
+
available(): number;
|
|
361
|
+
/** Try to consume `cost` tokens. Returns `true` if successful. */
|
|
362
|
+
tryConsume(cost?: number): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Return `cost` tokens to the bucket (capped at capacity). Used when a
|
|
365
|
+
* multi-bucket admission fails partway — e.g., `adaptiveRateLimiter`
|
|
366
|
+
* consumes from an rpm bucket, then a tpm bucket; if tpm fails, call
|
|
367
|
+
* `rpmBucket.putBack(requestCost)` so the rpm slot isn't wasted.
|
|
368
|
+
* No-op for non-positive `cost`.
|
|
369
|
+
*/
|
|
370
|
+
putBack(cost?: number): void;
|
|
371
|
+
}
|
|
372
|
+
/** Optional configuration for {@link tokenBucket}. */
|
|
373
|
+
interface TokenBucketOptions {
|
|
374
|
+
/**
|
|
375
|
+
* Clock function returning **nanoseconds** with `monotonicNs()` semantics
|
|
376
|
+
* (monotonically non-decreasing). Default: `monotonicNs` from `core/clock`.
|
|
377
|
+
* Override for deterministic tests — eliminates the need for `vi.useFakeTimers`
|
|
378
|
+
* to drive token-refill scheduling.
|
|
379
|
+
*/
|
|
380
|
+
clock?: () => number;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Token-bucket meter (capacity + refill rate per second). Use with {@link rateLimiter} or custom gates.
|
|
384
|
+
*
|
|
385
|
+
* @param capacity - Maximum tokens (must be positive).
|
|
386
|
+
* @param refillPerSecond - Tokens added per elapsed second (non-negative; may be fractional).
|
|
387
|
+
* @param opts - Optional `clock` override for deterministic testing.
|
|
388
|
+
* @returns {@link TokenBucket} instance.
|
|
389
|
+
*
|
|
390
|
+
* @remarks
|
|
391
|
+
* **Float behavior:** the internal token counter is float-valued — fractional refill
|
|
392
|
+
* accumulates between `tryConsume` calls. See {@link TokenBucket.available} for caveats.
|
|
393
|
+
*
|
|
394
|
+
* **Clock injection:** pass `opts.clock` to drive refill scheduling deterministically
|
|
395
|
+
* in tests. The contract matches {@link circuitBreaker}'s `now` option: must return
|
|
396
|
+
* `monotonicNs()`-style nanoseconds, never `Date.now()` (wall-clock skew breaks
|
|
397
|
+
* elapsed math).
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* import { tokenBucket } from "@graphrefly/graphrefly-ts";
|
|
402
|
+
*
|
|
403
|
+
* const bucket = tokenBucket(10, 2); // capacity 10, refill 2 tokens/sec
|
|
404
|
+
* bucket.tryConsume(3); // true — 7 tokens remaining
|
|
405
|
+
* bucket.available(); // ~7 (plus any elapsed refill — float-valued)
|
|
406
|
+
*
|
|
407
|
+
* // Deterministic test:
|
|
408
|
+
* let t = 0;
|
|
409
|
+
* const tb = tokenBucket(5, 1, { clock: () => t });
|
|
410
|
+
* tb.tryConsume(5); // exhausts
|
|
411
|
+
* t = 1_000_000_000; // advance 1s → +1 refill
|
|
412
|
+
* tb.tryConsume(1); // true
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* @category extra
|
|
416
|
+
*/
|
|
417
|
+
declare function tokenBucket(capacity: number, refillPerSecond: number, opts?: TokenBucketOptions): TokenBucket;
|
|
418
|
+
type RateLimiterOverflowPolicy = "drop-oldest" | "drop-newest" | "error";
|
|
419
|
+
type RateLimiterOptions = {
|
|
420
|
+
/** Maximum `DATA` emissions per window (must be > 0). */
|
|
421
|
+
maxEvents: number;
|
|
422
|
+
/** Window length in nanoseconds (must be > 0). */
|
|
423
|
+
windowNs: number;
|
|
424
|
+
/**
|
|
425
|
+
* Cap on items queued while waiting for token refill.
|
|
426
|
+
*
|
|
427
|
+
* **Required.** Pass a finite positive integer (>= 1) for a bounded queue, OR
|
|
428
|
+
* the literal `Infinity` to opt in to an unbounded queue (caller acknowledges
|
|
429
|
+
* the unbounded-memory-growth risk on a high-rate source). Omitting this
|
|
430
|
+
* throws at construction time — the silent-unbounded-buffer footgun is the
|
|
431
|
+
* most common rateLimiter mis-configuration.
|
|
432
|
+
*/
|
|
433
|
+
maxBuffer: number;
|
|
434
|
+
/** Overflow policy when `maxBuffer` is exceeded. Default: `"drop-newest"`. */
|
|
435
|
+
onOverflow?: RateLimiterOverflowPolicy;
|
|
436
|
+
/**
|
|
437
|
+
* Caller-supplied metadata merged into the produced node's `meta` (Tier 5.2
|
|
438
|
+
* D8 widening). Use {@link domainMeta} to tag the layer for `describe()` /
|
|
439
|
+
* mermaid grouping (e.g. `domainMeta("resilient", "rate-limit")`). The
|
|
440
|
+
* primitive's own `factoryTag("rateLimiter", opts)` and the `droppedCount`
|
|
441
|
+
* / `rateLimitState` companion seeds always win against caller-supplied
|
|
442
|
+
* keys so the audit trail can't be silently overwritten.
|
|
443
|
+
*/
|
|
444
|
+
meta?: Record<string, unknown>;
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* Thrown by {@link rateLimiter} when `onOverflow: "error"` and the pending buffer is full.
|
|
448
|
+
*
|
|
449
|
+
* @category extra
|
|
450
|
+
*/
|
|
451
|
+
declare class RateLimiterOverflowError extends Error {
|
|
452
|
+
name: string;
|
|
453
|
+
constructor(maxBuffer: number);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Combined runtime state surfaced by {@link rateLimiter} alongside `droppedCount`.
|
|
457
|
+
* Tier 5.2 D7 widening — exposes pending-buffer occupancy and a `paused`
|
|
458
|
+
* flag so consumers can render backpressure (UI), feed `lens.health`, or
|
|
459
|
+
* gate downstream effects.
|
|
460
|
+
*/
|
|
461
|
+
/**
|
|
462
|
+
* Lifecycle-shaped state companion emitted by {@link rateLimiter}.
|
|
463
|
+
*
|
|
464
|
+
* **DS-13.5.B widening (2026-05-01).** `status` extends {@link GateState}
|
|
465
|
+
* with `"throttled"` (= `paused === true`). Pre-1.0 break vs the prior
|
|
466
|
+
* shape (which omitted `status`).
|
|
467
|
+
*
|
|
468
|
+
* - `"open"` — passing through (no buffering, no recent overflow drops).
|
|
469
|
+
* - `"throttled"` — at least one item queued awaiting a token refill.
|
|
470
|
+
* - `"closed"` — reserved for future terminal lifecycle reporting.
|
|
471
|
+
*/
|
|
472
|
+
type RateLimiterState = {
|
|
473
|
+
/** DS-13.5.B status field — `"open" | "closed" | "throttled"`. */
|
|
474
|
+
status: GateState | "throttled";
|
|
475
|
+
/** Cumulative `DATA` items dropped due to overflow since this subscription cycle started. */
|
|
476
|
+
droppedCount: number;
|
|
477
|
+
/** Items currently buffered awaiting a token refill. `0` when the limiter is passing through. */
|
|
478
|
+
pendingCount: number;
|
|
479
|
+
/** `true` when at least one item is queued (the limiter is actively throttling). */
|
|
480
|
+
paused: boolean;
|
|
481
|
+
};
|
|
482
|
+
/** Bundle returned by {@link rateLimiter}. */
|
|
483
|
+
type RateLimiterBundle<T> = {
|
|
484
|
+
/** The throttled stream — at most `maxEvents` `DATA` per `windowNs`. */
|
|
485
|
+
node: Node<T>;
|
|
486
|
+
/**
|
|
487
|
+
* Reactive companion: count of `DATA` items dropped since the producer
|
|
488
|
+
* activated.
|
|
489
|
+
*
|
|
490
|
+
* - Increments on every drop under any overflow policy (`drop-newest`,
|
|
491
|
+
* `drop-oldest`). The `error` policy terminates the stream after a single
|
|
492
|
+
* overflow, so `droppedCount` increments at most once in that path.
|
|
493
|
+
* - **Lifecycle scoping (qa A1 + EC7):** the counter retains its final
|
|
494
|
+
* value through terminal (`COMPLETE` / `ERROR` / `TEARDOWN`) so consumers
|
|
495
|
+
* see the final drop count, not zero. The closure-held counter resets to
|
|
496
|
+
* `0` only when the producer fn re-runs — which only happens on a new
|
|
497
|
+
* subscription cycle, and only if the producer was constructed with
|
|
498
|
+
* `resubscribable: true`. The default `rateLimiter` producer is NOT
|
|
499
|
+
* resubscribable, so a single producer-fn run is the typical lifetime.
|
|
500
|
+
* - Producer-pattern note: this companion is invisible to `describe()`
|
|
501
|
+
* traversal from `node` (effect-mirror limitation; same shape as
|
|
502
|
+
* `withBreaker.breakerState` and `withStatus.status`). Surface it via
|
|
503
|
+
* `node.meta.droppedCount` if you need it in topology snapshots.
|
|
504
|
+
*/
|
|
505
|
+
droppedCount: Node<number>;
|
|
506
|
+
/**
|
|
507
|
+
* Reactive companion: combined `{droppedCount, pendingCount, paused}` view.
|
|
508
|
+
*
|
|
509
|
+
* - `pendingCount` reflects the live buffer occupancy and updates on every
|
|
510
|
+
* push / shift / overflow drop; `paused` is shorthand for
|
|
511
|
+
* `pendingCount > 0`.
|
|
512
|
+
* - Equality-deduped — re-emits only when one of the three fields actually
|
|
513
|
+
* changes (so a busy steady-state where every DATA passes immediately
|
|
514
|
+
* produces one `paused: false` emission, not one per DATA).
|
|
515
|
+
* - **Lifecycle scoping (qa EC7):** same contract as `droppedCount` —
|
|
516
|
+
* retains its final value through terminal; resets to the initial
|
|
517
|
+
* `{droppedCount: 0, pendingCount: 0, paused: false}` only on a new
|
|
518
|
+
* producer-fn run (resubscribable upstream required).
|
|
519
|
+
* - Same producer-pattern caveat as `droppedCount` re: `describe()` visibility.
|
|
520
|
+
*/
|
|
521
|
+
rateLimitState: Node<RateLimiterState>;
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* Token-bucket rate limiter: at most `maxEvents` `DATA` values per `windowNs`.
|
|
525
|
+
*
|
|
526
|
+
* Uses {@link tokenBucket} internally (capacity = `maxEvents`, refill = `maxEvents / windowSeconds`).
|
|
527
|
+
* Excess items are queued FIFO (in a fixed-capacity {@link RingBuffer} for O(1) push/shift)
|
|
528
|
+
* until a token is available. The queue is bounded by the **required** `maxBuffer` option
|
|
529
|
+
* with a configurable overflow policy.
|
|
530
|
+
*
|
|
531
|
+
* @param source - Upstream node.
|
|
532
|
+
* @param opts - Rate + bounded-buffer configuration. `maxBuffer` is required (use `Infinity` to opt in to unbounded).
|
|
533
|
+
* @returns `{ node, droppedCount }` bundle. Subscribe to `node` for the throttled stream and to `droppedCount` for backpressure pressure.
|
|
534
|
+
*
|
|
535
|
+
* @throws {RangeError} when `maxEvents` / `windowNs` is non-positive, when `maxBuffer` is omitted, or when `maxBuffer` is a finite value < 1.
|
|
536
|
+
*
|
|
537
|
+
* @remarks
|
|
538
|
+
* **Terminal:** `COMPLETE` / `ERROR` cancel the refill timer, drop the pending queue,
|
|
539
|
+
* reset `droppedCount` to `0`, and propagate.
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```ts
|
|
543
|
+
* import { rateLimiter, state, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
|
|
544
|
+
*
|
|
545
|
+
* const src = state(0);
|
|
546
|
+
* // Allow at most 5 DATA values per second; queue up to 100 excess items, drop newest beyond.
|
|
547
|
+
* const { node: limited, droppedCount } = rateLimiter(src, {
|
|
548
|
+
* maxEvents: 5,
|
|
549
|
+
* windowNs: NS_PER_SEC,
|
|
550
|
+
* maxBuffer: 100,
|
|
551
|
+
* });
|
|
552
|
+
* droppedCount.subscribe(([m]) => console.log("dropped so far:", m[1]));
|
|
553
|
+
* ```
|
|
554
|
+
*
|
|
555
|
+
* @category extra
|
|
556
|
+
*/
|
|
557
|
+
declare function rateLimiter<T>(source: Node<T>, opts: NodeOrValue<RateLimiterOptions>): RateLimiterBundle<T>;
|
|
558
|
+
|
|
559
|
+
export { type BudgetConstraint as B, type FallbackInput as F, type RateLimiterBundle as R, type TimeoutBundle as T, type BudgetConstraintSnapshot as a, type BudgetGateBundle as b, type BudgetGateOptions as c, type BudgetGateState as d, type RateLimiterOptions as e, RateLimiterOverflowError as f, type RateLimiterOverflowPolicy as g, type RateLimiterState as h, TimeoutError as i, type TimeoutOptions as j, type TimeoutState as k, type TokenBucket as l, type TokenBucketOptions as m, budgetGate as n, fallback as o, rateLimiter as r, tokenBucket as t, withTimeout as w };
|