@noy-db/hub 0.2.0-pre.9 → 0.3.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dist/adapter/index.d.ts +5 -0
- package/dist/adapter/index.js +15 -0
- package/dist/aggregate/index.d.ts +6 -2
- package/dist/aggregate/index.js +24 -16
- package/dist/aggregate/index.js.map +1 -1
- package/dist/api-RW3KP7WU.js +14 -0
- package/dist/as/index.d.ts +7 -0
- package/dist/as/index.js +24 -0
- package/dist/at/index.d.ts +5 -0
- package/dist/at/index.js +1 -0
- package/dist/attestation/index.d.ts +15 -47
- package/dist/attestation/index.js +54 -10
- package/dist/attestation/index.js.map +1 -1
- package/dist/backup-XV3IOEGB.js +217 -0
- package/dist/backup-XV3IOEGB.js.map +1 -0
- package/dist/blobs/index.d.ts +6 -8
- package/dist/blobs/index.js +19 -12
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.d.ts +16 -70
- package/dist/bundle/index.js +39 -476
- package/dist/bundle/index.js.map +1 -1
- package/dist/{ulid-CJ8RzRrm.d.ts → bundle-CH-H06dp.d.ts} +31 -86
- package/dist/by/index.d.ts +1 -0
- package/dist/by/index.js +11 -0
- package/dist/cargo/index.d.ts +9 -0
- package/dist/cargo/index.js +89 -0
- package/dist/chunk-26LGBE4T.js +42 -0
- package/dist/chunk-26LGBE4T.js.map +1 -0
- package/dist/chunk-2P2HZEXU.js +233 -0
- package/dist/chunk-2P2HZEXU.js.map +1 -0
- package/dist/{chunk-K3DK3NU5.js → chunk-3YFXJ3ZP.js} +20 -5
- package/dist/chunk-3YFXJ3ZP.js.map +1 -0
- package/dist/chunk-4Q6HSHHL.js +90 -0
- package/dist/chunk-4Q6HSHHL.js.map +1 -0
- package/dist/chunk-5LUY7UTV.js +380 -0
- package/dist/chunk-5LUY7UTV.js.map +1 -0
- package/dist/chunk-5N6CZTCY.js +367 -0
- package/dist/chunk-5N6CZTCY.js.map +1 -0
- package/dist/chunk-5O3AOPDT.js +992 -0
- package/dist/chunk-5O3AOPDT.js.map +1 -0
- package/dist/chunk-5R3ERCDH.js +239 -0
- package/dist/chunk-5R3ERCDH.js.map +1 -0
- package/dist/{chunk-6CME4UEK.js → chunk-5R5JW2JT.js} +7000 -4827
- package/dist/chunk-5R5JW2JT.js.map +1 -0
- package/dist/chunk-5TDJ56JE.js +32 -0
- package/dist/chunk-5TDJ56JE.js.map +1 -0
- package/dist/{chunk-T7JEBOGN.js → chunk-62QYRORB.js} +18 -11
- package/dist/chunk-62QYRORB.js.map +1 -0
- package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
- package/dist/chunk-6S7T6WC4.js.map +1 -0
- package/dist/chunk-76722EBH.js +451 -0
- package/dist/chunk-76722EBH.js.map +1 -0
- package/dist/{chunk-Z6FNBOTC.js → chunk-AIWULCUO.js} +13 -17
- package/dist/chunk-AIWULCUO.js.map +1 -0
- package/dist/{chunk-O3VZPBZG.js → chunk-AQTBSL7R.js} +47 -11
- package/dist/chunk-AQTBSL7R.js.map +1 -0
- package/dist/chunk-AURFOK3D.js +35 -0
- package/dist/chunk-AURFOK3D.js.map +1 -0
- package/dist/{chunk-53XBRIRT.js → chunk-AXRXJTE2.js} +9 -9
- package/dist/chunk-AXRXJTE2.js.map +1 -0
- package/dist/chunk-AZAOEIKW.js +155 -0
- package/dist/chunk-AZAOEIKW.js.map +1 -0
- package/dist/{chunk-HNRHLRDC.js → chunk-BG3SPSR4.js} +3 -3
- package/dist/chunk-BG3SPSR4.js.map +1 -0
- package/dist/chunk-BGIZAFY7.js +1 -0
- package/dist/chunk-CHFZDSE4.js +1 -0
- package/dist/{chunk-DJHHA6XH.js → chunk-CMGR4ZEW.js} +50 -20
- package/dist/chunk-CMGR4ZEW.js.map +1 -0
- package/dist/chunk-CWPPNPOH.js +23 -0
- package/dist/chunk-CWPPNPOH.js.map +1 -0
- package/dist/{chunk-QODLLGQ7.js → chunk-DFEMTNPJ.js} +371 -38
- package/dist/chunk-DFEMTNPJ.js.map +1 -0
- package/dist/{chunk-ZYWZWG6G.js → chunk-DGDI2D4M.js} +10 -10
- package/dist/chunk-DGDI2D4M.js.map +1 -0
- package/dist/{chunk-SYMWGEET.js → chunk-EIZUR2XW.js} +3 -3
- package/dist/chunk-EIZUR2XW.js.map +1 -0
- package/dist/{chunk-BVRYKATC.js → chunk-FISN7WE4.js} +36 -33
- package/dist/chunk-FISN7WE4.js.map +1 -0
- package/dist/chunk-GHVIKOHT.js +1 -0
- package/dist/chunk-GYGWYIOZ.js +200 -0
- package/dist/chunk-GYGWYIOZ.js.map +1 -0
- package/dist/chunk-HCIPRAGS.js +45 -0
- package/dist/chunk-HCIPRAGS.js.map +1 -0
- package/dist/{chunk-PX35GA7L.js → chunk-I2NOIW44.js} +10 -10
- package/dist/chunk-I2NOIW44.js.map +1 -0
- package/dist/{chunk-OIF6LZUR.js → chunk-I3TIKTJO.js} +3 -3
- package/dist/chunk-I3TIKTJO.js.map +1 -0
- package/dist/chunk-I7FD46FF.js +9 -0
- package/dist/chunk-I7FD46FF.js.map +1 -0
- package/dist/chunk-IAGBDSCS.js +40 -0
- package/dist/chunk-IAGBDSCS.js.map +1 -0
- package/dist/{chunk-JWRVQKRZ.js → chunk-IELYAOGG.js} +6 -18
- package/dist/chunk-IELYAOGG.js.map +1 -0
- package/dist/chunk-IGUYVGGI.js +205 -0
- package/dist/chunk-IGUYVGGI.js.map +1 -0
- package/dist/{chunk-U26HQ6KJ.js → chunk-IO6GRPT6.js} +4 -4
- package/dist/chunk-IO6GRPT6.js.map +1 -0
- package/dist/chunk-IPB7FTQX.js +273 -0
- package/dist/chunk-IPB7FTQX.js.map +1 -0
- package/dist/chunk-ITNUCOXM.js +148 -0
- package/dist/chunk-ITNUCOXM.js.map +1 -0
- package/dist/{chunk-WPLVTJ5D.js → chunk-IUEN57TV.js} +10 -10
- package/dist/chunk-IUEN57TV.js.map +1 -0
- package/dist/{chunk-DL3HWOQ5.js → chunk-JNUWZ6D3.js} +9 -9
- package/dist/chunk-JNUWZ6D3.js.map +1 -0
- package/dist/chunk-K2WCO3NX.js +1 -0
- package/dist/chunk-KVOXU4T5.js +30 -0
- package/dist/chunk-KVOXU4T5.js.map +1 -0
- package/dist/chunk-KXGNJJXB.js +135 -0
- package/dist/chunk-KXGNJJXB.js.map +1 -0
- package/dist/chunk-LB7FD65R.js +163 -0
- package/dist/chunk-LB7FD65R.js.map +1 -0
- package/dist/{chunk-22DWZL57.js → chunk-LFLXAY2W.js} +43 -218
- package/dist/chunk-LFLXAY2W.js.map +1 -0
- package/dist/chunk-LMTH2RM6.js +129 -0
- package/dist/chunk-LMTH2RM6.js.map +1 -0
- package/dist/{aggregate/index.cjs → chunk-LV7M27WM.js} +390 -219
- package/dist/chunk-LV7M27WM.js.map +1 -0
- package/dist/{chunk-PE2FR4J3.js → chunk-LXQT4WMP.js} +16 -18
- package/dist/chunk-LXQT4WMP.js.map +1 -0
- package/dist/chunk-M2YKN37S.js +524 -0
- package/dist/chunk-M2YKN37S.js.map +1 -0
- package/dist/chunk-M6OST55S.js +14 -0
- package/dist/chunk-M6OST55S.js.map +1 -0
- package/dist/{chunk-F3GDRNUT.js → chunk-MD3Y6J3L.js} +35 -69
- package/dist/chunk-MD3Y6J3L.js.map +1 -0
- package/dist/{chunk-XJFLDA7A.js → chunk-MTMJVJ5W.js} +8 -7
- package/dist/chunk-MTMJVJ5W.js.map +1 -0
- package/dist/{chunk-DFMLEQZB.js → chunk-NF5JWERG.js} +5 -10
- package/dist/chunk-NF5JWERG.js.map +1 -0
- package/dist/{chunk-DO7C2TOG.js → chunk-PKHL44ER.js} +3 -3
- package/dist/{chunk-DO7C2TOG.js.map → chunk-PKHL44ER.js.map} +1 -1
- package/dist/chunk-PSMV73A5.js +117 -0
- package/dist/chunk-PSMV73A5.js.map +1 -0
- package/dist/chunk-PY4KJPYU.js +9 -0
- package/dist/chunk-PY4KJPYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/{chunk-DE6GKS6G.js → chunk-Q7SS3IME.js} +50 -9
- package/dist/chunk-Q7SS3IME.js.map +1 -0
- package/dist/chunk-QHJW5EXU.js +54 -0
- package/dist/chunk-QHJW5EXU.js.map +1 -0
- package/dist/{chunk-NONAAENK.js → chunk-RUEKROOS.js} +11 -4
- package/dist/chunk-RUEKROOS.js.map +1 -0
- package/dist/chunk-RUIMKQTA.js +23 -0
- package/dist/chunk-RUIMKQTA.js.map +1 -0
- package/dist/{chunk-TFBP23BX.js → chunk-SKF73JOP.js} +66 -7
- package/dist/chunk-SKF73JOP.js.map +1 -0
- package/dist/chunk-SM3AVUHC.js +42 -0
- package/dist/chunk-SM3AVUHC.js.map +1 -0
- package/dist/{chunk-ML236QKC.js → chunk-SMXWYP24.js} +5 -5
- package/dist/chunk-SMXWYP24.js.map +1 -0
- package/dist/chunk-SRB2XEWB.js +148 -0
- package/dist/chunk-SRB2XEWB.js.map +1 -0
- package/dist/chunk-SVLR4POP.js +64 -0
- package/dist/chunk-SVLR4POP.js.map +1 -0
- package/dist/chunk-TA66UMI4.js +123 -0
- package/dist/chunk-TA66UMI4.js.map +1 -0
- package/dist/chunk-TEILUWOI.js +664 -0
- package/dist/chunk-TEILUWOI.js.map +1 -0
- package/dist/chunk-TJYQIGAP.js +82 -0
- package/dist/chunk-TJYQIGAP.js.map +1 -0
- package/dist/{chunk-H2X3ISXG.js → chunk-UAG5KWVA.js} +7 -7
- package/dist/chunk-UAG5KWVA.js.map +1 -0
- package/dist/chunk-UDRIWL7A.js +382 -0
- package/dist/chunk-UDRIWL7A.js.map +1 -0
- package/dist/{chunk-2GLDA55J.js → chunk-UIU2THRG.js} +498 -133
- package/dist/chunk-UIU2THRG.js.map +1 -0
- package/dist/{chunk-3YPCK6JX.js → chunk-UPJNJGGA.js} +165 -423
- package/dist/chunk-UPJNJGGA.js.map +1 -0
- package/dist/chunk-UV5MFVO3.js +21 -0
- package/dist/chunk-UV5MFVO3.js.map +1 -0
- package/dist/{chunk-2WUSG3IT.js → chunk-V7RWQRG7.js} +5 -5
- package/dist/chunk-V7RWQRG7.js.map +1 -0
- package/dist/{chunk-VTKGMEPP.js → chunk-VCTFO5CO.js} +13 -3
- package/dist/chunk-VCTFO5CO.js.map +1 -0
- package/dist/{chunk-5T22KDPN.js → chunk-VFQGRQIH.js} +8 -8
- package/dist/chunk-VFQGRQIH.js.map +1 -0
- package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
- package/dist/chunk-VQNJ7UZL.js.map +1 -0
- package/dist/{chunk-DONMZAD2.js → chunk-WWGT2MDV.js} +43 -165
- package/dist/chunk-WWGT2MDV.js.map +1 -0
- package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
- package/dist/chunk-WXSYDNBT.js.map +1 -0
- package/dist/chunk-WYSO2NIH.js +30 -0
- package/dist/chunk-WYSO2NIH.js.map +1 -0
- package/dist/chunk-XXYIOFUB.js +164 -0
- package/dist/chunk-XXYIOFUB.js.map +1 -0
- package/dist/{chunk-3BFJOWSU.js → chunk-Y22T3KQE.js} +35 -7
- package/dist/chunk-Y22T3KQE.js.map +1 -0
- package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
- package/dist/chunk-YMUGBZN2.js.map +1 -0
- package/dist/{chunk-I5FOWO4J.js → chunk-ZCGAHGUS.js} +52 -73
- package/dist/chunk-ZCGAHGUS.js.map +1 -0
- package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
- package/dist/chunk-ZJADGNYF.js.map +1 -0
- package/dist/{chunk-B6PB7JLN.js → chunk-ZYUC53LT.js} +427 -6
- package/dist/chunk-ZYUC53LT.js.map +1 -0
- package/dist/collection-facade-GQAOGJP2.js +33 -0
- package/dist/consent/index.d.ts +5 -7
- package/dist/consent/index.js +7 -5
- package/dist/consent/index.js.map +1 -1
- package/dist/crdt/index.d.ts +6 -2
- package/dist/crdt/index.js +3 -2
- package/dist/crdt/index.js.map +1 -1
- package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
- package/dist/delegation-UL5HKLER.js +19 -0
- package/dist/derivations/index.d.ts +7 -9
- package/dist/derivations/index.js +11 -6
- package/dist/describe/index.d.ts +1 -0
- package/dist/describe/index.js +1 -0
- package/dist/describe-aBkJR2sd.d.ts +131 -0
- package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-C9Ro3v_O.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/enclave-UL5LW66V.js +88 -0
- package/dist/executor-2FWQRLMG.js +15 -0
- package/dist/executor-QZ7BXICW.js +9 -0
- package/dist/executor-Z5ZLJVTV.js +9 -0
- package/dist/export-accessible-KRV5W4GH.js +17 -0
- package/dist/extract-partition-GLKBOXFQ.js +30 -0
- package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-GF3DJ6KR.js} +34 -14
- package/dist/fanout-sidecar-GF3DJ6KR.js.map +1 -0
- package/dist/forget/index.d.ts +36 -0
- package/dist/forget/index.js +19 -0
- package/dist/forget/index.js.map +1 -0
- package/dist/guards/index.d.ts +13 -9
- package/dist/guards/index.js +12 -5
- package/dist/{hash-DdpVypUp.d.cts → hash-Cp5uwiox.d.ts} +5 -1
- package/dist/history/index.d.ts +6 -8
- package/dist/history/index.js +19 -12
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.d.ts +5 -7
- package/dist/i18n/index.js +104 -15
- package/dist/i18n/index.js.map +1 -1
- package/dist/in/index.d.ts +5 -0
- package/dist/in/index.js +1 -0
- package/dist/in/index.js.map +1 -0
- package/dist/index-B9QdHytu.d.ts +123 -0
- package/dist/index-BF9_96A5.d.ts +123 -0
- package/dist/{types-Df28QFKb.d.ts → index-BzUo1B6n.d.ts} +16270 -8358
- package/dist/index.d.ts +1088 -450
- package/dist/index.js +1165 -293
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.d.ts +6 -3
- package/dist/indexing/index.js +6 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-Y6UVIR43.js +13 -0
- package/dist/issue-Y6UVIR43.js.map +1 -0
- package/dist/kernel/index.d.ts +32 -0
- package/dist/kernel/index.js +53 -0
- package/dist/kernel/index.js.map +1 -0
- package/dist/{ledger-TMRZYNVJ.js → ledger-RYI35CDS.js} +12 -9
- package/dist/ledger-RYI35CDS.js.map +1 -0
- package/dist/liberate-CRPZEV7O.js +18 -0
- package/dist/liberate-CRPZEV7O.js.map +1 -0
- package/dist/materialized-views/index.d.ts +6 -19
- package/dist/materialized-views/index.js +16 -12
- package/dist/mime-magic-CGhw37_E.d.ts +103 -0
- package/dist/noydb-367AM4HT.js +50 -0
- package/dist/noydb-367AM4HT.js.map +1 -0
- package/dist/on/index.d.ts +5 -0
- package/dist/on/index.js +11 -0
- package/dist/on/index.js.map +1 -0
- package/dist/overlay-views/index.d.ts +27 -11
- package/dist/overlay-views/index.js +7 -6
- package/dist/periods/index.d.ts +5 -7
- package/dist/periods/index.js +13 -9
- package/dist/pod/index.d.ts +63 -0
- package/dist/pod/index.js +61 -0
- package/dist/pod/index.js.map +1 -0
- package/dist/policy-IXK4FVXP.js +41 -0
- package/dist/policy-IXK4FVXP.js.map +1 -0
- package/dist/portability/index.d.ts +20 -0
- package/dist/portability/index.js +43 -0
- package/dist/portability/index.js.map +1 -0
- package/dist/{public-envelope-BW6OXORV.js → public-envelope-JHDQCPSX.js} +6 -5
- package/dist/public-envelope-JHDQCPSX.js.map +1 -0
- package/dist/query/index.d.ts +5 -3
- package/dist/query/index.js +21 -13
- package/dist/read-only-facade-5ADRJVTM.js +8 -0
- package/dist/read-only-facade-5ADRJVTM.js.map +1 -0
- package/dist/registry-45RJNWGU.js +9 -0
- package/dist/registry-45RJNWGU.js.map +1 -0
- package/dist/registry-5GRV5VXI.js +13 -0
- package/dist/registry-5GRV5VXI.js.map +1 -0
- package/dist/registry-VW6P6A3J.js +8 -0
- package/dist/registry-VW6P6A3J.js.map +1 -0
- package/dist/registry-WEUCHBO4.js +11 -0
- package/dist/registry-WEUCHBO4.js.map +1 -0
- package/dist/request-withdrawal-GBPH2FDY.js +25 -0
- package/dist/request-withdrawal-GBPH2FDY.js.map +1 -0
- package/dist/revoke-TUFRGI6S.js +18 -0
- package/dist/revoke-TUFRGI6S.js.map +1 -0
- package/dist/sealed-record/index.d.ts +69 -0
- package/dist/sealed-record/index.js +65 -0
- package/dist/sealed-record/index.js.map +1 -0
- package/dist/session/index.d.ts +6 -8
- package/dist/session/index.js +7 -5
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.d.ts +5 -7
- package/dist/shadow/index.js +4 -3
- package/dist/shadow/index.js.map +1 -1
- package/dist/{signer-72QAUSVW.js → signer-PNKTBVF7.js} +6 -5
- package/dist/signer-PNKTBVF7.js.map +1 -0
- package/dist/snapshots/index.d.ts +6 -8
- package/dist/snapshots/index.js +13 -11
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-6ZDBTQT7.js → stale-3JWHNDIY.js} +3 -2
- package/dist/stale-3JWHNDIY.js.map +1 -0
- package/dist/store-coordination-provider-3I7XWZZK.js +142 -0
- package/dist/store-coordination-provider-3I7XWZZK.js.map +1 -0
- package/dist/subject-index-O75wKshW.d.ts +362 -0
- package/dist/sync/index.d.ts +4 -6
- package/dist/sync/index.js +7 -6
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.d.ts +5 -7
- package/dist/team/index.js +20 -16
- package/dist/tiers/index.d.ts +5 -0
- package/dist/tiers/index.js +33 -0
- package/dist/tiers/index.js.map +1 -0
- package/dist/to/index.d.ts +5 -0
- package/dist/to/index.js +17 -0
- package/dist/to/index.js.map +1 -0
- package/dist/transition-guard-C7ol6oPw.d.ts +165 -0
- package/dist/tx/index.d.ts +23 -9
- package/dist/tx/index.js +13 -8
- package/dist/tx/index.js.map +1 -1
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ulid-DRH25k3y.d.ts +66 -0
- package/dist/ulid-PTAIMDG4.js +10 -0
- package/dist/ulid-PTAIMDG4.js.map +1 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +7 -2
- package/dist/util/index.js.map +1 -1
- package/dist/vault-diff-B5fYNBL7.d.ts +147 -0
- package/dist/with/index.d.ts +38 -0
- package/dist/with/index.js +25 -0
- package/dist/with/index.js.map +1 -0
- package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-6p0Fk8bL.d.ts} +1 -1
- package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-BJ6mXGMd.d.ts} +2 -3
- package/dist/with-rollup-BvQo3ROo.d.ts +47 -0
- package/dist/withdraw-accessible-FFS46EOD.js +22 -0
- package/dist/withdraw-accessible-FFS46EOD.js.map +1 -0
- package/dist/zod-HAJM7LMS.js +14763 -0
- package/dist/zod-HAJM7LMS.js.map +1 -0
- package/package.json +121 -201
- package/dist/aggregate/index.cjs.map +0 -1
- package/dist/aggregate/index.d.cts +0 -38
- package/dist/attestation/index.cjs +0 -305
- package/dist/attestation/index.cjs.map +0 -1
- package/dist/attestation/index.d.cts +0 -52
- package/dist/blobs/index.cjs +0 -1480
- package/dist/blobs/index.cjs.map +0 -1
- package/dist/blobs/index.d.cts +0 -46
- package/dist/bundle/index.cjs +0 -19264
- package/dist/bundle/index.cjs.map +0 -1
- package/dist/bundle/index.d.cts +0 -176
- package/dist/chunk-22DWZL57.js.map +0 -1
- package/dist/chunk-2GLDA55J.js.map +0 -1
- package/dist/chunk-2QR2PQTT.js.map +0 -1
- package/dist/chunk-2WUSG3IT.js.map +0 -1
- package/dist/chunk-3BFJOWSU.js.map +0 -1
- package/dist/chunk-3YPCK6JX.js.map +0 -1
- package/dist/chunk-53XBRIRT.js.map +0 -1
- package/dist/chunk-5T22KDPN.js.map +0 -1
- package/dist/chunk-5XHKQ56N.js +0 -340
- package/dist/chunk-5XHKQ56N.js.map +0 -1
- package/dist/chunk-6CME4UEK.js.map +0 -1
- package/dist/chunk-6STK5TQP.js +0 -139
- package/dist/chunk-6STK5TQP.js.map +0 -1
- package/dist/chunk-A3JMGXPG.js.map +0 -1
- package/dist/chunk-B6PB7JLN.js.map +0 -1
- package/dist/chunk-BVRYKATC.js.map +0 -1
- package/dist/chunk-DE6GKS6G.js.map +0 -1
- package/dist/chunk-DFMLEQZB.js.map +0 -1
- package/dist/chunk-DJHHA6XH.js.map +0 -1
- package/dist/chunk-DL3HWOQ5.js.map +0 -1
- package/dist/chunk-DONMZAD2.js.map +0 -1
- package/dist/chunk-EMIGCR7X.js.map +0 -1
- package/dist/chunk-F3GDRNUT.js.map +0 -1
- package/dist/chunk-FZU343FL.js.map +0 -1
- package/dist/chunk-H2X3ISXG.js.map +0 -1
- package/dist/chunk-HNRHLRDC.js.map +0 -1
- package/dist/chunk-I5FOWO4J.js.map +0 -1
- package/dist/chunk-J66GRPNH.js.map +0 -1
- package/dist/chunk-JWRVQKRZ.js.map +0 -1
- package/dist/chunk-K3DK3NU5.js.map +0 -1
- package/dist/chunk-ML236QKC.js.map +0 -1
- package/dist/chunk-NONAAENK.js.map +0 -1
- package/dist/chunk-O3VZPBZG.js.map +0 -1
- package/dist/chunk-OIF6LZUR.js.map +0 -1
- package/dist/chunk-OQ6PIGHA.js +0 -19
- package/dist/chunk-OQ6PIGHA.js.map +0 -1
- package/dist/chunk-PE2FR4J3.js.map +0 -1
- package/dist/chunk-PP6W64Y3.js +0 -275
- package/dist/chunk-PP6W64Y3.js.map +0 -1
- package/dist/chunk-PX35GA7L.js.map +0 -1
- package/dist/chunk-QEILDE6R.js +0 -793
- package/dist/chunk-QEILDE6R.js.map +0 -1
- package/dist/chunk-QODLLGQ7.js.map +0 -1
- package/dist/chunk-RAZ4OVLL.js +0 -51
- package/dist/chunk-RAZ4OVLL.js.map +0 -1
- package/dist/chunk-SYMWGEET.js.map +0 -1
- package/dist/chunk-T7JEBOGN.js.map +0 -1
- package/dist/chunk-TFBP23BX.js.map +0 -1
- package/dist/chunk-TV3YZ35S.js +0 -90
- package/dist/chunk-TV3YZ35S.js.map +0 -1
- package/dist/chunk-U26HQ6KJ.js.map +0 -1
- package/dist/chunk-UF3BUNQZ.js +0 -1
- package/dist/chunk-UMLVJTYV.js +0 -20
- package/dist/chunk-UMLVJTYV.js.map +0 -1
- package/dist/chunk-VTKGMEPP.js.map +0 -1
- package/dist/chunk-W6EQLGMB.js +0 -100
- package/dist/chunk-W6EQLGMB.js.map +0 -1
- package/dist/chunk-WIRRPTFH.js +0 -17
- package/dist/chunk-WIRRPTFH.js.map +0 -1
- package/dist/chunk-WPLVTJ5D.js.map +0 -1
- package/dist/chunk-XJFLDA7A.js.map +0 -1
- package/dist/chunk-Z6FNBOTC.js.map +0 -1
- package/dist/chunk-ZYWZWG6G.js.map +0 -1
- package/dist/consent/index.cjs +0 -204
- package/dist/consent/index.cjs.map +0 -1
- package/dist/consent/index.d.cts +0 -25
- package/dist/crdt/index.cjs +0 -152
- package/dist/crdt/index.cjs.map +0 -1
- package/dist/crdt/index.d.cts +0 -30
- package/dist/crypto-HTZ4FJOP.js +0 -44
- package/dist/delegation-RI54P6I5.js +0 -17
- package/dist/derivations/index.cjs +0 -351
- package/dist/derivations/index.cjs.map +0 -1
- package/dist/derivations/index.d.cts +0 -72
- package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
- package/dist/executor-5PNY7LGW.js +0 -8
- package/dist/executor-B4QIYGZX.js +0 -8
- package/dist/executor-BWXXDQ7K.js +0 -11
- package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
- package/dist/guards/index.cjs +0 -322
- package/dist/guards/index.cjs.map +0 -1
- package/dist/guards/index.d.cts +0 -31
- package/dist/hash-HJqD14vS.d.ts +0 -63
- package/dist/history/index.cjs +0 -1222
- package/dist/history/index.cjs.map +0 -1
- package/dist/history/index.d.cts +0 -63
- package/dist/i18n/index.cjs +0 -1100
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -39
- package/dist/index-4fBVt8j9.d.cts +0 -2387
- package/dist/index-D8I_pyJD.d.ts +0 -2387
- package/dist/index.cjs +0 -24487
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -776
- package/dist/indexing/index.cjs +0 -742
- package/dist/indexing/index.cjs.map +0 -1
- package/dist/indexing/index.d.cts +0 -36
- package/dist/issue-VGDPP4B5.js +0 -12
- package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
- package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
- package/dist/materialized-views/index.cjs +0 -854
- package/dist/materialized-views/index.cjs.map +0 -1
- package/dist/materialized-views/index.d.cts +0 -186
- package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
- package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
- package/dist/noydb-G725ZSZG.js +0 -34
- package/dist/overlay-views/index.cjs +0 -359
- package/dist/overlay-views/index.cjs.map +0 -1
- package/dist/overlay-views/index.d.cts +0 -82
- package/dist/periods/index.cjs +0 -1041
- package/dist/periods/index.cjs.map +0 -1
- package/dist/periods/index.d.cts +0 -22
- package/dist/predicate-BSAGEyu5.d.cts +0 -209
- package/dist/predicate-BSAGEyu5.d.ts +0 -209
- package/dist/query/index.cjs +0 -2375
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -3
- package/dist/read-only-facade-ITU6L7BL.js +0 -7
- package/dist/registry-3QP3YKQS.js +0 -8
- package/dist/registry-DKEXOJVO.js +0 -7
- package/dist/registry-OJIOSBV6.js +0 -10
- package/dist/registry-USRVT6YF.js +0 -8
- package/dist/revoke-JCC7N56X.js +0 -17
- package/dist/session/index.cjs +0 -495
- package/dist/session/index.cjs.map +0 -1
- package/dist/session/index.d.cts +0 -46
- package/dist/shadow/index.cjs +0 -133
- package/dist/shadow/index.cjs.map +0 -1
- package/dist/shadow/index.d.cts +0 -17
- package/dist/snapshots/index.cjs +0 -937
- package/dist/snapshots/index.cjs.map +0 -1
- package/dist/snapshots/index.d.cts +0 -28
- package/dist/store/index.cjs +0 -1083
- package/dist/store/index.cjs.map +0 -1
- package/dist/store/index.d.cts +0 -492
- package/dist/store/index.d.ts +0 -492
- package/dist/store/index.js +0 -37
- package/dist/strategy-BSxFXGzb.d.cts +0 -110
- package/dist/strategy-BSxFXGzb.d.ts +0 -110
- package/dist/strategy-DSTrsZ8t.d.cts +0 -601
- package/dist/strategy-DSTrsZ8t.d.ts +0 -601
- package/dist/sync/index.cjs +0 -1062
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.d.cts +0 -43
- package/dist/team/index.cjs +0 -2798
- package/dist/team/index.cjs.map +0 -1
- package/dist/team/index.d.cts +0 -118
- package/dist/tx/index.cjs +0 -544
- package/dist/tx/index.cjs.map +0 -1
- package/dist/tx/index.d.cts +0 -21
- package/dist/types-DyXYr8rE.d.cts +0 -12818
- package/dist/ulid-COREQ2RQ.js +0 -9
- package/dist/ulid-Drr7ykr6.d.cts +0 -603
- package/dist/util/index.cjs +0 -230
- package/dist/util/index.cjs.map +0 -1
- package/dist/util/index.d.cts +0 -77
- package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
- package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
- package/dist/with-guard-ByyxmEe7.d.cts +0 -18
- package/dist/with-guard-qube6BMI.d.ts +0 -18
- package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
- package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
- /package/dist/{store → adapter}/index.js.map +0 -0
- /package/dist/{chunk-UF3BUNQZ.js.map → api-RW3KP7WU.js.map} +0 -0
- /package/dist/{crypto-HTZ4FJOP.js.map → as/index.js.map} +0 -0
- /package/dist/{delegation-RI54P6I5.js.map → at/index.js.map} +0 -0
- /package/dist/{executor-5PNY7LGW.js.map → by/index.js.map} +0 -0
- /package/dist/{executor-B4QIYGZX.js.map → cargo/index.js.map} +0 -0
- /package/dist/{executor-BWXXDQ7K.js.map → chunk-BGIZAFY7.js.map} +0 -0
- /package/dist/{issue-VGDPP4B5.js.map → chunk-CHFZDSE4.js.map} +0 -0
- /package/dist/{ledger-TMRZYNVJ.js.map → chunk-GHVIKOHT.js.map} +0 -0
- /package/dist/{noydb-G725ZSZG.js.map → chunk-K2WCO3NX.js.map} +0 -0
- /package/dist/{public-envelope-BW6OXORV.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/dist/{read-only-facade-ITU6L7BL.js.map → collection-facade-GQAOGJP2.js.map} +0 -0
- /package/dist/{registry-3QP3YKQS.js.map → delegation-UL5HKLER.js.map} +0 -0
- /package/dist/{registry-DKEXOJVO.js.map → describe/index.js.map} +0 -0
- /package/dist/{registry-OJIOSBV6.js.map → enclave-UL5LW66V.js.map} +0 -0
- /package/dist/{registry-USRVT6YF.js.map → executor-2FWQRLMG.js.map} +0 -0
- /package/dist/{revoke-JCC7N56X.js.map → executor-QZ7BXICW.js.map} +0 -0
- /package/dist/{signer-72QAUSVW.js.map → executor-Z5ZLJVTV.js.map} +0 -0
- /package/dist/{stale-6ZDBTQT7.js.map → export-accessible-KRV5W4GH.js.map} +0 -0
- /package/dist/{ulid-COREQ2RQ.js.map → extract-partition-GLKBOXFQ.js.map} +0 -0
package/dist/chunk-QEILDE6R.js
DELETED
|
@@ -1,793 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BundleVersionConflictError,
|
|
3
|
-
ConflictError
|
|
4
|
-
} from "./chunk-B6PB7JLN.js";
|
|
5
|
-
|
|
6
|
-
// src/store/bundle-store.ts
|
|
7
|
-
var BUNDLE_STORE_VERSION = 1;
|
|
8
|
-
var MAX_CONFLICT_RETRIES = 3;
|
|
9
|
-
function wrapBundleStore(bundle, options) {
|
|
10
|
-
const autoFlush = options?.autoFlush !== false;
|
|
11
|
-
const snapshots = /* @__PURE__ */ new Map();
|
|
12
|
-
const versions = /* @__PURE__ */ new Map();
|
|
13
|
-
const loaded = /* @__PURE__ */ new Set();
|
|
14
|
-
let batchDepth = 0;
|
|
15
|
-
async function load(vault) {
|
|
16
|
-
if (loaded.has(vault)) return snapshots.get(vault);
|
|
17
|
-
const result = await bundle.readBundle(vault);
|
|
18
|
-
if (result) {
|
|
19
|
-
const text = new TextDecoder().decode(result.bytes);
|
|
20
|
-
const format = JSON.parse(text);
|
|
21
|
-
snapshots.set(vault, format.data);
|
|
22
|
-
versions.set(vault, result.version);
|
|
23
|
-
} else {
|
|
24
|
-
snapshots.set(vault, {});
|
|
25
|
-
versions.set(vault, null);
|
|
26
|
-
}
|
|
27
|
-
loaded.add(vault);
|
|
28
|
-
return snapshots.get(vault);
|
|
29
|
-
}
|
|
30
|
-
async function flush(vault) {
|
|
31
|
-
const snapshot = snapshots.get(vault) ?? {};
|
|
32
|
-
const format = {
|
|
33
|
-
_noydb_bundle_store: BUNDLE_STORE_VERSION,
|
|
34
|
-
vault,
|
|
35
|
-
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36
|
-
data: snapshot
|
|
37
|
-
};
|
|
38
|
-
const bytes = new TextEncoder().encode(JSON.stringify(format));
|
|
39
|
-
const expectedVersion = versions.get(vault) ?? null;
|
|
40
|
-
for (let attempt = 0; attempt < MAX_CONFLICT_RETRIES; attempt++) {
|
|
41
|
-
try {
|
|
42
|
-
const { version: newVersion } = await bundle.writeBundle(vault, bytes, expectedVersion);
|
|
43
|
-
versions.set(vault, newVersion);
|
|
44
|
-
return;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
if (err instanceof BundleVersionConflictError && attempt < MAX_CONFLICT_RETRIES - 1) {
|
|
47
|
-
const remote = await bundle.readBundle(vault);
|
|
48
|
-
if (remote) {
|
|
49
|
-
const remoteText = new TextDecoder().decode(remote.bytes);
|
|
50
|
-
const remoteFormat = JSON.parse(remoteText);
|
|
51
|
-
const localSnap = snapshots.get(vault) ?? {};
|
|
52
|
-
const mergedSnap = mergeSnapshots(remoteFormat.data, localSnap);
|
|
53
|
-
snapshots.set(vault, mergedSnap);
|
|
54
|
-
versions.set(vault, remote.version);
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
throw err;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async function maybeFlush(vault) {
|
|
63
|
-
if (autoFlush && batchDepth === 0) {
|
|
64
|
-
await flush(vault);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const store = {
|
|
68
|
-
name: bundle.name ?? "bundle",
|
|
69
|
-
async flush(vaultId) {
|
|
70
|
-
await flush(vaultId);
|
|
71
|
-
},
|
|
72
|
-
async batch(vaultId, fn) {
|
|
73
|
-
await load(vaultId);
|
|
74
|
-
batchDepth++;
|
|
75
|
-
try {
|
|
76
|
-
await fn();
|
|
77
|
-
} finally {
|
|
78
|
-
batchDepth--;
|
|
79
|
-
}
|
|
80
|
-
await flush(vaultId);
|
|
81
|
-
},
|
|
82
|
-
async get(vault, collection, id) {
|
|
83
|
-
const snap = await load(vault);
|
|
84
|
-
return snap[collection]?.[id] ?? null;
|
|
85
|
-
},
|
|
86
|
-
async put(vault, collection, id, envelope, expectedVersion) {
|
|
87
|
-
const snap = await load(vault);
|
|
88
|
-
if (expectedVersion !== void 0) {
|
|
89
|
-
const current = snap[collection]?.[id];
|
|
90
|
-
const currentVersion = current?._v ?? 0;
|
|
91
|
-
if (currentVersion !== expectedVersion) {
|
|
92
|
-
throw new ConflictError(
|
|
93
|
-
currentVersion,
|
|
94
|
-
`Expected version ${expectedVersion} but found ${currentVersion} on ${collection}/${id}`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
snap[collection] ??= {};
|
|
99
|
-
snap[collection][id] = envelope;
|
|
100
|
-
await maybeFlush(vault);
|
|
101
|
-
},
|
|
102
|
-
async delete(vault, collection, id) {
|
|
103
|
-
const snap = await load(vault);
|
|
104
|
-
if (snap[collection]) {
|
|
105
|
-
delete snap[collection][id];
|
|
106
|
-
await maybeFlush(vault);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
async list(vault, collection) {
|
|
110
|
-
const snap = await load(vault);
|
|
111
|
-
return Object.keys(snap[collection] ?? {});
|
|
112
|
-
},
|
|
113
|
-
async loadAll(vault) {
|
|
114
|
-
return await load(vault);
|
|
115
|
-
},
|
|
116
|
-
async saveAll(vault, data) {
|
|
117
|
-
snapshots.set(vault, data);
|
|
118
|
-
loaded.add(vault);
|
|
119
|
-
await flush(vault);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return store;
|
|
123
|
-
}
|
|
124
|
-
function mergeSnapshots(remote, local) {
|
|
125
|
-
const merged = {};
|
|
126
|
-
for (const [coll, records] of Object.entries(remote)) {
|
|
127
|
-
merged[coll] = { ...records };
|
|
128
|
-
}
|
|
129
|
-
for (const [coll, records] of Object.entries(local)) {
|
|
130
|
-
if (!merged[coll]) {
|
|
131
|
-
merged[coll] = { ...records };
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
for (const [id, envelope] of Object.entries(records)) {
|
|
135
|
-
const existing = merged[coll][id];
|
|
136
|
-
if (!existing || envelope._ts >= existing._ts) {
|
|
137
|
-
merged[coll][id] = envelope;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return merged;
|
|
142
|
-
}
|
|
143
|
-
function createBundleStore(factory) {
|
|
144
|
-
return factory;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// src/store/route-store.ts
|
|
148
|
-
var BLOB_CHUNKS = "_blob_chunks";
|
|
149
|
-
var BLOB_INDEX = "_blob_index";
|
|
150
|
-
var BLOB_SLOTS = "_blob_slots_";
|
|
151
|
-
var BLOB_VERSIONS = "_blob_versions_";
|
|
152
|
-
function routeStore(opts) {
|
|
153
|
-
const primary = opts.default;
|
|
154
|
-
const blobsIsSimple = opts.blobs && "get" in opts.blobs;
|
|
155
|
-
const simpleBlobStore = blobsIsSimple ? opts.blobs : void 0;
|
|
156
|
-
const tieredBlobs = !blobsIsSimple ? opts.blobs : void 0;
|
|
157
|
-
const blobThreshold = tieredBlobs?.threshold ?? 400 * 1024;
|
|
158
|
-
const allStores = /* @__PURE__ */ new Set([primary]);
|
|
159
|
-
if (simpleBlobStore) allStores.add(simpleBlobStore);
|
|
160
|
-
if (tieredBlobs?.large) allStores.add(tieredBlobs.large);
|
|
161
|
-
if (tieredBlobs?.small) allStores.add(tieredBlobs.small);
|
|
162
|
-
if (opts.age?.cold) allStores.add(opts.age.cold);
|
|
163
|
-
if (opts.routes) for (const s of Object.values(opts.routes)) allStores.add(s);
|
|
164
|
-
if (opts.vaultRoutes) for (const s of Object.values(opts.vaultRoutes)) allStores.add(s);
|
|
165
|
-
if (opts.blobRoutes) for (const s of Object.values(opts.blobRoutes)) allStores.add(s);
|
|
166
|
-
if (opts.overflow) allStores.add(opts.overflow);
|
|
167
|
-
if (opts.blobLifecycle?.archiveStore) allStores.add(opts.blobLifecycle.archiveStore);
|
|
168
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
169
|
-
const suspended = /* @__PURE__ */ new Set();
|
|
170
|
-
const writeQueues = /* @__PURE__ */ new Map();
|
|
171
|
-
const NULL_STORE = {
|
|
172
|
-
name: "suspended",
|
|
173
|
-
async get() {
|
|
174
|
-
return null;
|
|
175
|
-
},
|
|
176
|
-
async put() {
|
|
177
|
-
},
|
|
178
|
-
async delete() {
|
|
179
|
-
},
|
|
180
|
-
async list() {
|
|
181
|
-
return [];
|
|
182
|
-
},
|
|
183
|
-
async loadAll() {
|
|
184
|
-
return {};
|
|
185
|
-
},
|
|
186
|
-
async saveAll() {
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
function routeNameFor(vault, collection) {
|
|
190
|
-
if (opts.vaultRoutes) {
|
|
191
|
-
for (const prefix of Object.keys(opts.vaultRoutes)) {
|
|
192
|
-
if (vault.startsWith(prefix)) return prefix;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (opts.routes && !collection.startsWith("_") && opts.routes[collection]) {
|
|
196
|
-
return collection;
|
|
197
|
-
}
|
|
198
|
-
if (isBlobChunks(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
|
|
199
|
-
if (opts.routeBlobMeta && isBlobMeta(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
|
|
200
|
-
if (opts.age && !collection.startsWith("_")) {
|
|
201
|
-
}
|
|
202
|
-
return "default";
|
|
203
|
-
}
|
|
204
|
-
const quotaExceeded = false;
|
|
205
|
-
function resolveOriginalStore(route) {
|
|
206
|
-
if (route === "blobs") return simpleBlobStore ?? tieredBlobs?.large ?? primary;
|
|
207
|
-
if (route === "cold") return opts.age?.cold ?? primary;
|
|
208
|
-
if (opts.routes?.[route]) return opts.routes[route];
|
|
209
|
-
if (opts.vaultRoutes?.[route]) return opts.vaultRoutes[route];
|
|
210
|
-
return primary;
|
|
211
|
-
}
|
|
212
|
-
function maybeQueueWrite(routeName, method, vault, collection, id, envelope, expectedVersion) {
|
|
213
|
-
if (!suspended.has(routeName)) return false;
|
|
214
|
-
const queue = writeQueues.get(routeName);
|
|
215
|
-
if (!queue) return false;
|
|
216
|
-
if (queue.writes.length >= queue.maxSize) {
|
|
217
|
-
queue.writes.shift();
|
|
218
|
-
}
|
|
219
|
-
queue.writes.push({
|
|
220
|
-
method,
|
|
221
|
-
vault,
|
|
222
|
-
collection,
|
|
223
|
-
id,
|
|
224
|
-
...envelope !== void 0 ? { envelope } : {},
|
|
225
|
-
...expectedVersion !== void 0 ? { expectedVersion } : {}
|
|
226
|
-
});
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
function isBlobChunks(collection) {
|
|
230
|
-
return collection === BLOB_CHUNKS;
|
|
231
|
-
}
|
|
232
|
-
function isBlobMeta(collection) {
|
|
233
|
-
return collection === BLOB_INDEX || collection.startsWith(BLOB_SLOTS) || collection.startsWith(BLOB_VERSIONS);
|
|
234
|
-
}
|
|
235
|
-
function isInternal(collection) {
|
|
236
|
-
return collection.startsWith("_");
|
|
237
|
-
}
|
|
238
|
-
function storeFor(vault, collection) {
|
|
239
|
-
const rName = routeNameFor(vault, collection);
|
|
240
|
-
if (suspended.has(rName)) return NULL_STORE;
|
|
241
|
-
if (overrides.has(rName)) return overrides.get(rName);
|
|
242
|
-
if (opts.vaultRoutes) {
|
|
243
|
-
for (const [prefix, store2] of Object.entries(opts.vaultRoutes)) {
|
|
244
|
-
if (vault.startsWith(prefix)) return store2;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (opts.routes && !isInternal(collection) && opts.routes[collection]) {
|
|
248
|
-
return opts.routes[collection];
|
|
249
|
-
}
|
|
250
|
-
if (isBlobChunks(collection)) {
|
|
251
|
-
if (simpleBlobStore) return simpleBlobStore;
|
|
252
|
-
if (tieredBlobs) return tieredBlobs.large;
|
|
253
|
-
}
|
|
254
|
-
if (opts.routeBlobMeta && isBlobMeta(collection)) {
|
|
255
|
-
if (simpleBlobStore) return simpleBlobStore;
|
|
256
|
-
if (tieredBlobs) return tieredBlobs.large;
|
|
257
|
-
}
|
|
258
|
-
if (quotaExceeded && opts.overflow) return opts.overflow;
|
|
259
|
-
return primary;
|
|
260
|
-
}
|
|
261
|
-
function blobStoreForSize(dataSize) {
|
|
262
|
-
if (!tieredBlobs) return simpleBlobStore ?? primary;
|
|
263
|
-
if (dataSize <= blobThreshold) {
|
|
264
|
-
return tieredBlobs.small ?? primary;
|
|
265
|
-
}
|
|
266
|
-
return tieredBlobs.large;
|
|
267
|
-
}
|
|
268
|
-
function isCold(collection, envelope) {
|
|
269
|
-
if (!opts.age) return false;
|
|
270
|
-
if (isInternal(collection)) return false;
|
|
271
|
-
if (opts.age.collections && opts.age.collections.length > 0) {
|
|
272
|
-
if (!opts.age.collections.includes(collection)) return false;
|
|
273
|
-
}
|
|
274
|
-
const cutoff = Date.now() - opts.age.coldAfterDays * 24 * 60 * 60 * 1e3;
|
|
275
|
-
const ts = new Date(envelope._ts).getTime();
|
|
276
|
-
return ts < cutoff;
|
|
277
|
-
}
|
|
278
|
-
const store = {
|
|
279
|
-
name: buildName(),
|
|
280
|
-
async get(vault, collection, id) {
|
|
281
|
-
const s = storeFor(vault, collection);
|
|
282
|
-
const result = await s.get(vault, collection, id);
|
|
283
|
-
if (result === null && opts.age && !isInternal(collection)) {
|
|
284
|
-
if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
|
|
285
|
-
return opts.age.cold.get(vault, collection, id);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return result;
|
|
289
|
-
},
|
|
290
|
-
async put(vault, collection, id, envelope, expectedVersion) {
|
|
291
|
-
const rn = routeNameFor(vault, collection);
|
|
292
|
-
if (maybeQueueWrite(rn, "put", vault, collection, id, envelope, expectedVersion)) return;
|
|
293
|
-
if (isBlobChunks(collection) && tieredBlobs) {
|
|
294
|
-
const dataSize = envelope._data.length;
|
|
295
|
-
const s2 = blobStoreForSize(dataSize);
|
|
296
|
-
return s2.put(vault, collection, id, envelope, expectedVersion);
|
|
297
|
-
}
|
|
298
|
-
const s = storeFor(vault, collection);
|
|
299
|
-
if (opts.age && !isInternal(collection)) {
|
|
300
|
-
opts.age.cold.delete(vault, collection, id).catch(() => {
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
return s.put(vault, collection, id, envelope, expectedVersion);
|
|
304
|
-
},
|
|
305
|
-
async delete(vault, collection, id) {
|
|
306
|
-
const rn = routeNameFor(vault, collection);
|
|
307
|
-
if (maybeQueueWrite(rn, "delete", vault, collection, id)) return;
|
|
308
|
-
const s = storeFor(vault, collection);
|
|
309
|
-
await s.delete(vault, collection, id);
|
|
310
|
-
if (opts.age && !isInternal(collection)) {
|
|
311
|
-
await opts.age.cold.delete(vault, collection, id).catch(() => {
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
async list(vault, collection) {
|
|
316
|
-
const s = storeFor(vault, collection);
|
|
317
|
-
const ids = await s.list(vault, collection);
|
|
318
|
-
if (opts.age && !isInternal(collection)) {
|
|
319
|
-
if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
|
|
320
|
-
const coldIds = await opts.age.cold.list(vault, collection).catch(() => []);
|
|
321
|
-
if (coldIds.length > 0) {
|
|
322
|
-
const merged = new Set(ids);
|
|
323
|
-
for (const id of coldIds) merged.add(id);
|
|
324
|
-
return [...merged];
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return ids;
|
|
329
|
-
},
|
|
330
|
-
async loadAll(vault) {
|
|
331
|
-
const stores = getStoresForVault(vault);
|
|
332
|
-
const snapshots = await Promise.all(
|
|
333
|
-
stores.map((s) => s.loadAll(vault).catch(() => ({})))
|
|
334
|
-
);
|
|
335
|
-
return mergeSnapshots2(snapshots);
|
|
336
|
-
},
|
|
337
|
-
async saveAll(vault, data) {
|
|
338
|
-
const partitioned = /* @__PURE__ */ new Map();
|
|
339
|
-
for (const [collection, records] of Object.entries(data)) {
|
|
340
|
-
const s = storeFor(vault, collection);
|
|
341
|
-
if (!partitioned.has(s)) partitioned.set(s, {});
|
|
342
|
-
partitioned.get(s)[collection] = records;
|
|
343
|
-
}
|
|
344
|
-
await Promise.all(
|
|
345
|
-
[...partitioned.entries()].map(([s, snap]) => s.saveAll(vault, snap))
|
|
346
|
-
);
|
|
347
|
-
},
|
|
348
|
-
async compact(vault) {
|
|
349
|
-
if (!opts.age) return 0;
|
|
350
|
-
let migrated = 0;
|
|
351
|
-
const collections = opts.age.collections?.length ? opts.age.collections : await primary.list(vault, "").catch(() => []);
|
|
352
|
-
for (const collection of collections) {
|
|
353
|
-
const ids = await primary.list(vault, collection).catch(() => []);
|
|
354
|
-
for (const id of ids) {
|
|
355
|
-
const envelope = await primary.get(vault, collection, id);
|
|
356
|
-
if (!envelope) continue;
|
|
357
|
-
if (isCold(collection, envelope)) {
|
|
358
|
-
await opts.age.cold.put(vault, collection, id, envelope);
|
|
359
|
-
await primary.delete(vault, collection, id);
|
|
360
|
-
migrated++;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return migrated;
|
|
365
|
-
},
|
|
366
|
-
// ── Runtime override / suspend ──────────────────────
|
|
367
|
-
override(route, overrideStore, overrideOpts) {
|
|
368
|
-
if (overrideOpts?.hydrate) {
|
|
369
|
-
return (async () => {
|
|
370
|
-
overrides.set(route, overrideStore);
|
|
371
|
-
})();
|
|
372
|
-
}
|
|
373
|
-
overrides.set(route, overrideStore);
|
|
374
|
-
},
|
|
375
|
-
clearOverride(route) {
|
|
376
|
-
overrides.delete(route);
|
|
377
|
-
},
|
|
378
|
-
suspend(route, suspendOpts) {
|
|
379
|
-
suspended.add(route);
|
|
380
|
-
if (suspendOpts?.queue) {
|
|
381
|
-
writeQueues.set(route, {
|
|
382
|
-
writes: [],
|
|
383
|
-
maxSize: suspendOpts.maxQueueSize ?? 1e4
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
async resume(route) {
|
|
388
|
-
suspended.delete(route);
|
|
389
|
-
const queue = writeQueues.get(route);
|
|
390
|
-
if (!queue || queue.writes.length === 0) {
|
|
391
|
-
writeQueues.delete(route);
|
|
392
|
-
return 0;
|
|
393
|
-
}
|
|
394
|
-
let replayed = 0;
|
|
395
|
-
const target = overrides.get(route) ?? resolveOriginalStore(route);
|
|
396
|
-
for (const write of queue.writes) {
|
|
397
|
-
try {
|
|
398
|
-
if (write.method === "put" && write.envelope) {
|
|
399
|
-
await target.put(write.vault, write.collection, write.id, write.envelope, write.expectedVersion);
|
|
400
|
-
} else if (write.method === "delete") {
|
|
401
|
-
await target.delete(write.vault, write.collection, write.id);
|
|
402
|
-
}
|
|
403
|
-
replayed++;
|
|
404
|
-
} catch {
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
writeQueues.delete(route);
|
|
408
|
-
return replayed;
|
|
409
|
-
},
|
|
410
|
-
routeStatus() {
|
|
411
|
-
const ov = {};
|
|
412
|
-
for (const [k, v] of overrides) ov[k] = v.name ?? "unnamed";
|
|
413
|
-
const q = {};
|
|
414
|
-
for (const [k, v] of writeQueues) q[k] = v.writes.length;
|
|
415
|
-
return { overrides: ov, suspended: [...suspended], queued: q };
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
if (anyHas("listVaults")) {
|
|
419
|
-
store.listVaults = async () => {
|
|
420
|
-
const results = await Promise.all(
|
|
421
|
-
[...allStores].filter((s) => s.listVaults !== void 0).map((s) => s.listVaults().catch(() => []))
|
|
422
|
-
);
|
|
423
|
-
return [...new Set(results.flat())];
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
if (anyHas("ping")) {
|
|
427
|
-
store.ping = async () => {
|
|
428
|
-
const results = await Promise.all(
|
|
429
|
-
[...allStores].filter((s) => s.ping !== void 0).map((s) => s.ping().catch(() => false))
|
|
430
|
-
);
|
|
431
|
-
return results.some(Boolean);
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
return store;
|
|
435
|
-
function buildName() {
|
|
436
|
-
const names = [...allStores].map((s) => s.name ?? "?").join("+");
|
|
437
|
-
return `route(${names})`;
|
|
438
|
-
}
|
|
439
|
-
function anyHas(method) {
|
|
440
|
-
return [...allStores].some((s) => s[method]);
|
|
441
|
-
}
|
|
442
|
-
function getStoresForVault(vault) {
|
|
443
|
-
const stores = /* @__PURE__ */ new Set();
|
|
444
|
-
if (opts.vaultRoutes) {
|
|
445
|
-
for (const [prefix, s] of Object.entries(opts.vaultRoutes)) {
|
|
446
|
-
if (vault.startsWith(prefix)) {
|
|
447
|
-
stores.add(s);
|
|
448
|
-
return [...stores];
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
stores.add(primary);
|
|
453
|
-
if (simpleBlobStore) stores.add(simpleBlobStore);
|
|
454
|
-
if (tieredBlobs?.large) stores.add(tieredBlobs.large);
|
|
455
|
-
if (tieredBlobs?.small && tieredBlobs.small !== primary) stores.add(tieredBlobs.small);
|
|
456
|
-
if (opts.age?.cold) stores.add(opts.age.cold);
|
|
457
|
-
if (opts.routes) {
|
|
458
|
-
for (const s of Object.values(opts.routes)) stores.add(s);
|
|
459
|
-
}
|
|
460
|
-
return [...stores];
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
function mergeSnapshots2(snapshots) {
|
|
464
|
-
const merged = {};
|
|
465
|
-
for (const snap of snapshots) {
|
|
466
|
-
for (const [collection, records] of Object.entries(snap)) {
|
|
467
|
-
if (!merged[collection]) {
|
|
468
|
-
merged[collection] = { ...records };
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
for (const [id, envelope] of Object.entries(records)) {
|
|
472
|
-
const existing = merged[collection][id];
|
|
473
|
-
if (!existing || envelope._ts >= existing._ts) {
|
|
474
|
-
merged[collection][id] = envelope;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
return merged;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// src/store/store-middleware.ts
|
|
483
|
-
function wrapStore(store, ...middlewares) {
|
|
484
|
-
let result = store;
|
|
485
|
-
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
486
|
-
result = middlewares[i](result);
|
|
487
|
-
}
|
|
488
|
-
return result;
|
|
489
|
-
}
|
|
490
|
-
function withRetry(opts = {}) {
|
|
491
|
-
const maxRetries = opts.maxRetries ?? 3;
|
|
492
|
-
const backoffMs = opts.backoffMs ?? 500;
|
|
493
|
-
const jitter = opts.jitter ?? 0.3;
|
|
494
|
-
const retryOn = opts.retryOn ? new Set(opts.retryOn) : null;
|
|
495
|
-
function shouldRetry(err) {
|
|
496
|
-
if (!retryOn) return true;
|
|
497
|
-
if (err && typeof err === "object" && "code" in err) {
|
|
498
|
-
return retryOn.has(err.code);
|
|
499
|
-
}
|
|
500
|
-
return true;
|
|
501
|
-
}
|
|
502
|
-
async function retryable(fn) {
|
|
503
|
-
let lastError;
|
|
504
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
505
|
-
try {
|
|
506
|
-
return await fn();
|
|
507
|
-
} catch (err) {
|
|
508
|
-
lastError = err;
|
|
509
|
-
if (attempt >= maxRetries || !shouldRetry(err)) throw err;
|
|
510
|
-
const delay = backoffMs * Math.pow(2, attempt) * (1 + Math.random() * jitter);
|
|
511
|
-
await new Promise((r) => setTimeout(r, delay));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
throw lastError;
|
|
515
|
-
}
|
|
516
|
-
return (next) => ({
|
|
517
|
-
...next,
|
|
518
|
-
name: next.name ? `retry(${next.name})` : "retry",
|
|
519
|
-
get: (v, c, id) => retryable(() => next.get(v, c, id)),
|
|
520
|
-
put: (v, c, id, env, ev) => retryable(() => next.put(v, c, id, env, ev)),
|
|
521
|
-
delete: (v, c, id) => retryable(() => next.delete(v, c, id)),
|
|
522
|
-
list: (v, c) => retryable(() => next.list(v, c)),
|
|
523
|
-
loadAll: (v) => retryable(() => next.loadAll(v)),
|
|
524
|
-
saveAll: (v, d) => retryable(() => next.saveAll(v, d))
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
528
|
-
function withLogging(opts = {}) {
|
|
529
|
-
const minLevel = LOG_LEVELS[opts.level ?? "info"];
|
|
530
|
-
const logger = opts.logger ?? console;
|
|
531
|
-
const logData = opts.logData ?? false;
|
|
532
|
-
function log(level, method, args, durationMs) {
|
|
533
|
-
if (LOG_LEVELS[level] < minLevel) return;
|
|
534
|
-
const parts = [`[noydb:${method}]`, ...Object.entries(args).map(([k, v]) => `${k}=${String(v)}`)];
|
|
535
|
-
if (durationMs !== void 0) parts.push(`${durationMs}ms`);
|
|
536
|
-
logger[level](parts.join(" "));
|
|
537
|
-
}
|
|
538
|
-
function timed(method, args, fn) {
|
|
539
|
-
const start = Date.now();
|
|
540
|
-
return fn().then(
|
|
541
|
-
(result) => {
|
|
542
|
-
log("debug", method, args, Date.now() - start);
|
|
543
|
-
return result;
|
|
544
|
-
},
|
|
545
|
-
(err) => {
|
|
546
|
-
log("error", method, { ...args, error: err.message }, Date.now() - start);
|
|
547
|
-
throw err;
|
|
548
|
-
}
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
return (next) => ({
|
|
552
|
-
...next,
|
|
553
|
-
name: next.name ? `log(${next.name})` : "log",
|
|
554
|
-
get: (v, c, id) => timed("get", { vault: v, collection: c, id }, () => next.get(v, c, id)),
|
|
555
|
-
put: (v, c, id, env, ev) => timed("put", {
|
|
556
|
-
vault: v,
|
|
557
|
-
collection: c,
|
|
558
|
-
id,
|
|
559
|
-
version: env._v,
|
|
560
|
-
...logData ? { data: env._data.slice(0, 40) + "..." } : {}
|
|
561
|
-
}, () => next.put(v, c, id, env, ev)),
|
|
562
|
-
delete: (v, c, id) => timed("delete", { vault: v, collection: c, id }, () => next.delete(v, c, id)),
|
|
563
|
-
list: (v, c) => timed("list", { vault: v, collection: c }, () => next.list(v, c)),
|
|
564
|
-
loadAll: (v) => timed("loadAll", { vault: v }, () => next.loadAll(v)),
|
|
565
|
-
saveAll: (v, d) => timed("saveAll", { vault: v }, () => next.saveAll(v, d))
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
function withMetrics(opts) {
|
|
569
|
-
function tracked(method, vault, fn, collection, id) {
|
|
570
|
-
const start = Date.now();
|
|
571
|
-
return fn().then(
|
|
572
|
-
(result) => {
|
|
573
|
-
opts.onOperation({
|
|
574
|
-
method,
|
|
575
|
-
vault,
|
|
576
|
-
...collection !== void 0 ? { collection } : {},
|
|
577
|
-
...id !== void 0 ? { id } : {},
|
|
578
|
-
durationMs: Date.now() - start,
|
|
579
|
-
success: true
|
|
580
|
-
});
|
|
581
|
-
return result;
|
|
582
|
-
},
|
|
583
|
-
(err) => {
|
|
584
|
-
opts.onOperation({
|
|
585
|
-
method,
|
|
586
|
-
vault,
|
|
587
|
-
...collection !== void 0 ? { collection } : {},
|
|
588
|
-
...id !== void 0 ? { id } : {},
|
|
589
|
-
durationMs: Date.now() - start,
|
|
590
|
-
success: false,
|
|
591
|
-
error: err
|
|
592
|
-
});
|
|
593
|
-
throw err;
|
|
594
|
-
}
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
return (next) => ({
|
|
598
|
-
...next,
|
|
599
|
-
name: next.name ? `metrics(${next.name})` : "metrics",
|
|
600
|
-
get: (v, c, id) => tracked("get", v, () => next.get(v, c, id), c, id),
|
|
601
|
-
put: (v, c, id, env, ev) => tracked("put", v, () => next.put(v, c, id, env, ev), c, id),
|
|
602
|
-
delete: (v, c, id) => tracked("delete", v, () => next.delete(v, c, id), c, id),
|
|
603
|
-
list: (v, c) => tracked("list", v, () => next.list(v, c), c),
|
|
604
|
-
loadAll: (v) => tracked("loadAll", v, () => next.loadAll(v)),
|
|
605
|
-
saveAll: (v, d) => tracked("saveAll", v, () => next.saveAll(v, d))
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
function withCircuitBreaker(opts = {}) {
|
|
609
|
-
const threshold = opts.failureThreshold ?? 5;
|
|
610
|
-
const resetMs = opts.resetTimeoutMs ?? 3e4;
|
|
611
|
-
let state = "closed";
|
|
612
|
-
let failures = 0;
|
|
613
|
-
let lastFailureTime = 0;
|
|
614
|
-
function recordSuccess() {
|
|
615
|
-
if (state === "half-open") {
|
|
616
|
-
state = "closed";
|
|
617
|
-
failures = 0;
|
|
618
|
-
opts.onClose?.();
|
|
619
|
-
}
|
|
620
|
-
failures = 0;
|
|
621
|
-
}
|
|
622
|
-
function recordFailure() {
|
|
623
|
-
failures++;
|
|
624
|
-
lastFailureTime = Date.now();
|
|
625
|
-
if (failures >= threshold && state === "closed") {
|
|
626
|
-
state = "open";
|
|
627
|
-
opts.onOpen?.();
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function canAttempt() {
|
|
631
|
-
if (state === "closed") return true;
|
|
632
|
-
if (state === "open") {
|
|
633
|
-
if (Date.now() - lastFailureTime >= resetMs) {
|
|
634
|
-
state = "half-open";
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
639
|
-
return true;
|
|
640
|
-
}
|
|
641
|
-
async function guarded(fn, fallback) {
|
|
642
|
-
if (!canAttempt()) return fallback;
|
|
643
|
-
try {
|
|
644
|
-
const result = await fn();
|
|
645
|
-
recordSuccess();
|
|
646
|
-
return result;
|
|
647
|
-
} catch (err) {
|
|
648
|
-
recordFailure();
|
|
649
|
-
throw err;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return (next) => ({
|
|
653
|
-
...next,
|
|
654
|
-
name: next.name ? `cb(${next.name})` : "cb",
|
|
655
|
-
get: (v, c, id) => guarded(() => next.get(v, c, id), null),
|
|
656
|
-
put: (v, c, id, env, ev) => guarded(() => next.put(v, c, id, env, ev), void 0),
|
|
657
|
-
delete: (v, c, id) => guarded(() => next.delete(v, c, id), void 0),
|
|
658
|
-
list: (v, c) => guarded(() => next.list(v, c), []),
|
|
659
|
-
loadAll: (v) => guarded(() => next.loadAll(v), {}),
|
|
660
|
-
saveAll: (v, d) => guarded(() => next.saveAll(v, d), void 0)
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
function withCache(opts = {}) {
|
|
664
|
-
const maxEntries = opts.maxEntries ?? 500;
|
|
665
|
-
const ttlMs = opts.ttlMs ?? 6e4;
|
|
666
|
-
const cache = /* @__PURE__ */ new Map();
|
|
667
|
-
function cacheKey(vault, collection, id) {
|
|
668
|
-
return `${vault}\0${collection}\0${id}`;
|
|
669
|
-
}
|
|
670
|
-
function getFromCache(key) {
|
|
671
|
-
const entry = cache.get(key);
|
|
672
|
-
if (!entry) return void 0;
|
|
673
|
-
if (ttlMs > 0 && Date.now() - entry.cachedAt > ttlMs) {
|
|
674
|
-
cache.delete(key);
|
|
675
|
-
return void 0;
|
|
676
|
-
}
|
|
677
|
-
cache.delete(key);
|
|
678
|
-
cache.set(key, entry);
|
|
679
|
-
return entry.envelope;
|
|
680
|
-
}
|
|
681
|
-
function setInCache(key, envelope) {
|
|
682
|
-
if (cache.size >= maxEntries) {
|
|
683
|
-
const oldest = cache.keys().next().value;
|
|
684
|
-
if (oldest !== void 0) cache.delete(oldest);
|
|
685
|
-
}
|
|
686
|
-
cache.set(key, { envelope, cachedAt: Date.now() });
|
|
687
|
-
}
|
|
688
|
-
function invalidate(key) {
|
|
689
|
-
cache.delete(key);
|
|
690
|
-
}
|
|
691
|
-
return (next) => ({
|
|
692
|
-
...next,
|
|
693
|
-
name: next.name ? `cache(${next.name})` : "cache",
|
|
694
|
-
async get(vault, collection, id) {
|
|
695
|
-
const key = cacheKey(vault, collection, id);
|
|
696
|
-
const cached = getFromCache(key);
|
|
697
|
-
if (cached !== void 0) return cached;
|
|
698
|
-
const result = await next.get(vault, collection, id);
|
|
699
|
-
setInCache(key, result);
|
|
700
|
-
return result;
|
|
701
|
-
},
|
|
702
|
-
async put(vault, collection, id, env, ev) {
|
|
703
|
-
invalidate(cacheKey(vault, collection, id));
|
|
704
|
-
await next.put(vault, collection, id, env, ev);
|
|
705
|
-
setInCache(cacheKey(vault, collection, id), env);
|
|
706
|
-
},
|
|
707
|
-
async delete(vault, collection, id) {
|
|
708
|
-
invalidate(cacheKey(vault, collection, id));
|
|
709
|
-
await next.delete(vault, collection, id);
|
|
710
|
-
},
|
|
711
|
-
list: (v, c) => next.list(v, c),
|
|
712
|
-
loadAll: (v) => next.loadAll(v),
|
|
713
|
-
saveAll: (v, d) => next.saveAll(v, d)
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
function withHealthCheck(opts = {}) {
|
|
717
|
-
const intervalMs = opts.checkIntervalMs ?? 3e4;
|
|
718
|
-
const failThreshold = opts.suspendAfterFailures ?? 3;
|
|
719
|
-
const successThreshold = opts.resumeAfterSuccess ?? 1;
|
|
720
|
-
let isSuspended = false;
|
|
721
|
-
let consecutiveFailures = 0;
|
|
722
|
-
let consecutiveSuccesses = 0;
|
|
723
|
-
return (next) => {
|
|
724
|
-
const checkFn = opts.check ?? (next.ping ? () => next.ping() : async () => {
|
|
725
|
-
await next.list("__health__", "__ping__");
|
|
726
|
-
return true;
|
|
727
|
-
});
|
|
728
|
-
async function doCheck() {
|
|
729
|
-
try {
|
|
730
|
-
const ok = await checkFn();
|
|
731
|
-
if (ok) {
|
|
732
|
-
consecutiveFailures = 0;
|
|
733
|
-
consecutiveSuccesses++;
|
|
734
|
-
if (isSuspended && consecutiveSuccesses >= successThreshold) {
|
|
735
|
-
isSuspended = false;
|
|
736
|
-
consecutiveSuccesses = 0;
|
|
737
|
-
opts.onResume?.();
|
|
738
|
-
}
|
|
739
|
-
} else {
|
|
740
|
-
throw new Error("Health check returned false");
|
|
741
|
-
}
|
|
742
|
-
} catch {
|
|
743
|
-
consecutiveSuccesses = 0;
|
|
744
|
-
consecutiveFailures++;
|
|
745
|
-
if (!isSuspended && consecutiveFailures >= failThreshold) {
|
|
746
|
-
isSuspended = true;
|
|
747
|
-
consecutiveFailures = 0;
|
|
748
|
-
opts.onSuspend?.();
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
setInterval(() => {
|
|
753
|
-
void doCheck();
|
|
754
|
-
}, intervalMs);
|
|
755
|
-
const wrapped = {
|
|
756
|
-
...next,
|
|
757
|
-
name: next.name ? `health(${next.name})` : "health",
|
|
758
|
-
async get(v, c, id) {
|
|
759
|
-
return isSuspended ? null : next.get(v, c, id);
|
|
760
|
-
},
|
|
761
|
-
async put(v, c, id, env, ev) {
|
|
762
|
-
if (!isSuspended) await next.put(v, c, id, env, ev);
|
|
763
|
-
},
|
|
764
|
-
async delete(v, c, id) {
|
|
765
|
-
if (!isSuspended) await next.delete(v, c, id);
|
|
766
|
-
},
|
|
767
|
-
async list(v, c) {
|
|
768
|
-
return isSuspended ? [] : next.list(v, c);
|
|
769
|
-
},
|
|
770
|
-
async loadAll(v) {
|
|
771
|
-
return isSuspended ? {} : next.loadAll(v);
|
|
772
|
-
},
|
|
773
|
-
async saveAll(v, d) {
|
|
774
|
-
if (!isSuspended) await next.saveAll(v, d);
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
return wrapped;
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
export {
|
|
782
|
-
wrapBundleStore,
|
|
783
|
-
createBundleStore,
|
|
784
|
-
routeStore,
|
|
785
|
-
wrapStore,
|
|
786
|
-
withRetry,
|
|
787
|
-
withLogging,
|
|
788
|
-
withMetrics,
|
|
789
|
-
withCircuitBreaker,
|
|
790
|
-
withCache,
|
|
791
|
-
withHealthCheck
|
|
792
|
-
};
|
|
793
|
-
//# sourceMappingURL=chunk-QEILDE6R.js.map
|