@noy-db/hub 0.4.0-pre.5 → 0.4.0-pre.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-22ES33N3.js → api-5QVQX4HG.js} +6 -6
- package/dist/attestation/index.js +14 -14
- package/dist/{backup-YCHAC575.js → backup-USYSNCYM.js} +6 -6
- package/dist/blobs/index.js +8 -5
- package/dist/blobs/index.js.map +1 -1
- package/dist/broker/index.js +6 -6
- package/dist/cargo/index.js +26 -28
- package/dist/{chunk-RWW3I3PO.js → chunk-2BVW754E.js} +2 -2
- package/dist/{chunk-VEGQYPCP.js → chunk-2ZSC454H.js} +3 -3
- package/dist/{chunk-S4YERMGJ.js → chunk-32467U5J.js} +3 -3
- package/dist/{chunk-UVBHM7AK.js → chunk-3GXDB3NQ.js} +4 -4
- package/dist/{chunk-L2CAWCQL.js → chunk-3S2YNMUS.js} +53 -5
- package/dist/chunk-3S2YNMUS.js.map +1 -0
- package/dist/{chunk-HAPY7WFP.js → chunk-3TZUC4WS.js} +9 -9
- package/dist/{chunk-M6QA2KK2.js → chunk-44Y3P5U6.js} +2 -2
- package/dist/{chunk-WQN5SM7P.js → chunk-4B3DL75F.js} +2 -2
- package/dist/{chunk-XUFAFHQM.js → chunk-5ABOFAHN.js} +7 -4
- package/dist/chunk-5ABOFAHN.js.map +1 -0
- package/dist/chunk-5D2ALSM5.js +19 -0
- package/dist/chunk-5D2ALSM5.js.map +1 -0
- package/dist/{chunk-OHV6T5JB.js → chunk-6SSWOUUS.js} +2 -2
- package/dist/{chunk-6RPWILRH.js → chunk-7IQWHYL2.js} +3 -3
- package/dist/chunk-AFHQATY4.js +47 -0
- package/dist/chunk-AFHQATY4.js.map +1 -0
- package/dist/{chunk-I2XEBEEF.js → chunk-AZXEOEQK.js} +3 -3
- package/dist/{chunk-K7BADAOS.js → chunk-C2V7AJO2.js} +3 -3
- package/dist/chunk-CADUYBQD.js +151 -0
- package/dist/chunk-CADUYBQD.js.map +1 -0
- package/dist/{chunk-YTW6ZIPD.js → chunk-DOZFU7OZ.js} +1 -1
- package/dist/chunk-DOZFU7OZ.js.map +1 -0
- package/dist/{chunk-YCAJDK4O.js → chunk-E7FSBI6I.js} +3 -3
- package/dist/chunk-EP5L47XV.js +22 -0
- package/dist/chunk-EP5L47XV.js.map +1 -0
- package/dist/{chunk-YWZEDG7F.js → chunk-EPME33Y4.js} +4 -4
- package/dist/{chunk-EEZCB74X.js → chunk-EWPS35AR.js} +465 -393
- package/dist/chunk-EWPS35AR.js.map +1 -0
- package/dist/{chunk-BY5YBSXA.js → chunk-GQT6J4FJ.js} +14 -1
- package/dist/chunk-GQT6J4FJ.js.map +1 -0
- package/dist/{chunk-YXZNGHID.js → chunk-H5GMROCB.js} +2 -2
- package/dist/{chunk-QMMOMBH6.js → chunk-HA7P3BTB.js} +24 -175
- package/dist/chunk-HA7P3BTB.js.map +1 -0
- package/dist/{chunk-FTCGEUOY.js → chunk-HDF5R2K6.js} +4 -4
- package/dist/{chunk-R2N37AA6.js → chunk-HVPW6PCX.js} +2 -2
- package/dist/{chunk-YXIVUWDU.js → chunk-HXVRRJBD.js} +3 -3
- package/dist/{chunk-5ATANZSW.js → chunk-ICYC5YNI.js} +4 -4
- package/dist/{chunk-7ICV4ASA.js → chunk-IUATR5UE.js} +25 -3
- package/dist/chunk-IUATR5UE.js.map +1 -0
- package/dist/{chunk-QZJEYZ4I.js → chunk-JGOKAZNB.js} +3 -3
- package/dist/{chunk-JN3SGXJE.js → chunk-JOCMXSR2.js} +1 -1
- package/dist/{chunk-JN3SGXJE.js.map → chunk-JOCMXSR2.js.map} +1 -1
- package/dist/{chunk-7BIJS6II.js → chunk-JTIPVW4J.js} +3 -3
- package/dist/{chunk-SC4JLMZI.js → chunk-KCZAFDP5.js} +2 -2
- package/dist/{chunk-GP54LU5N.js → chunk-LG2GUYRX.js} +7 -7
- package/dist/{chunk-J5TEU77Q.js → chunk-LN3MQFUE.js} +54 -2
- package/dist/chunk-LN3MQFUE.js.map +1 -0
- package/dist/{chunk-FIP7KI2P.js → chunk-M4GO4ZJK.js} +205 -15
- package/dist/chunk-M4GO4ZJK.js.map +1 -0
- package/dist/{chunk-QMZ5A6FQ.js → chunk-M7W2KYTL.js} +2 -2
- package/dist/{chunk-K4BWPNJO.js → chunk-MLCTPWSO.js} +3 -3
- package/dist/{chunk-GEEJPID6.js → chunk-MMVQ3SUO.js} +3 -3
- package/dist/{chunk-HQKRZIX6.js → chunk-MPPWL64H.js} +24 -41
- package/dist/chunk-MPPWL64H.js.map +1 -0
- package/dist/{chunk-YZN6NRTR.js → chunk-MQBFT2OT.js} +11 -9
- package/dist/chunk-MQBFT2OT.js.map +1 -0
- package/dist/{chunk-TNJVDG2B.js → chunk-NA374QG7.js} +2 -2
- package/dist/chunk-NIKO2BBZ.js +23 -0
- package/dist/chunk-NIKO2BBZ.js.map +1 -0
- package/dist/chunk-PEOZ34EM.js +13 -0
- package/dist/chunk-PEOZ34EM.js.map +1 -0
- package/dist/chunk-PVEWA2DU.js +23 -0
- package/dist/chunk-PVEWA2DU.js.map +1 -0
- package/dist/{chunk-V5JUAW4M.js → chunk-QVIZDLAR.js} +5 -5
- package/dist/{chunk-DYZ5CCVM.js → chunk-RM5EXCFF.js} +1 -1
- package/dist/{chunk-DYZ5CCVM.js.map → chunk-RM5EXCFF.js.map} +1 -1
- package/dist/chunk-SMY5X46Z.js +14 -0
- package/dist/chunk-SMY5X46Z.js.map +1 -0
- package/dist/{chunk-2CRZOVDI.js → chunk-UNREYBZO.js} +2 -2
- package/dist/{chunk-KJTIAECI.js → chunk-V2R2VWER.js} +168 -9
- package/dist/chunk-V2R2VWER.js.map +1 -0
- package/dist/{chunk-CKUYQO2P.js → chunk-VDTWFN2P.js} +7 -5
- package/dist/chunk-VDTWFN2P.js.map +1 -0
- package/dist/chunk-VKQCVU2Z.js +21 -0
- package/dist/chunk-VKQCVU2Z.js.map +1 -0
- package/dist/{chunk-UTEATWHO.js → chunk-VNJMLOQS.js} +4 -4
- package/dist/{chunk-JAMDDLIM.js → chunk-WCJJQV2D.js} +2 -2
- package/dist/{chunk-OMSKGLYA.js → chunk-WWBC4KLB.js} +2 -2
- package/dist/{chunk-JIHH26WQ.js → chunk-XG7OZDOS.js} +3 -3
- package/dist/{chunk-QBOQI6PG.js → chunk-XONZGK6J.js} +2 -2
- package/dist/{chunk-YQQPNXNO.js → chunk-XSOGLHGY.js} +2 -2
- package/dist/{chunk-3OWYOECI.js → chunk-XY6MNSAF.js} +4 -4
- package/dist/chunk-XZHEOSQ2.js +16 -0
- package/dist/chunk-XZHEOSQ2.js.map +1 -0
- package/dist/{chunk-X3MWEFPT.js → chunk-YGMREQAK.js} +3 -3
- package/dist/chunk-YMUFFJCO.js +23 -0
- package/dist/chunk-YMUFFJCO.js.map +1 -0
- package/dist/{chunk-3LJYHE7S.js → chunk-ZDFU34XY.js} +9 -6
- package/dist/{chunk-3LJYHE7S.js.map → chunk-ZDFU34XY.js.map} +1 -1
- package/dist/{chunk-ILM6X6CP.js → chunk-ZF572E2M.js} +2 -2
- package/dist/{chunk-TNATF3HB.js → chunk-ZGEFBDPR.js} +2 -2
- package/dist/chunk-ZGEFBDPR.js.map +1 -0
- package/dist/{chunk-OGVE4IJW.js → chunk-ZHMUFYZF.js} +4 -4
- package/dist/{chunk-YFFEF6HR.js → chunk-ZHZ4PET5.js} +2 -2
- package/dist/{chunk-YZNKFYDC.js → chunk-ZM72UO3Y.js} +2 -2
- package/dist/classified/index.js +3 -3
- package/dist/{classified-marker-52P3D72W.js → classified-marker-SVDRXLD3.js} +3 -3
- package/dist/{collection-facade-XKCFHSLR.js → collection-facade-S5PPKZD5.js} +9 -9
- package/dist/consent/index.js +8 -4
- package/dist/consent/index.js.map +1 -1
- package/dist/{cover-5BSNJREH.js → cover-ADBCTIKN.js} +3 -3
- package/dist/crdt/index.js +4 -0
- package/dist/crdt/index.js.map +1 -1
- package/dist/{dead-filter-JXVCKS6W.js → dead-filter-HKDMTMVY.js} +2 -2
- package/dist/{delegation-WWZPEDK2.js → delegation-EV7LKJPH.js} +5 -5
- package/dist/derivations/index.js +3 -3
- package/dist/{derive-CWWFEQ4N.js → derive-5LDJW76F.js} +4 -4
- package/dist/{dispatch-PKQQFDBT.js → dispatch-SPMYNXNW.js} +12 -11
- package/dist/{dispatch-PKQQFDBT.js.map → dispatch-SPMYNXNW.js.map} +1 -1
- package/dist/{dispatch-SMXUO7W5.js → dispatch-V5MSMQYX.js} +5 -5
- package/dist/{enclave-I5H3GINP.js → enclave-ZA7C3H2L.js} +4 -4
- package/dist/executor-SVHAJZ4A.js +28 -0
- package/dist/{export-accessible-FBL6TDSK.js → export-accessible-S35YKIBL.js} +7 -7
- package/dist/{extract-partition-ZYIRYMTI.js → extract-partition-UVHAM5WZ.js} +10 -10
- package/dist/{fanout-sidecar-WWXVHHUH.js → fanout-sidecar-HRMHC34B.js} +4 -4
- package/dist/forget/index.js +4 -4
- package/dist/history/index.js +10 -6
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +10 -8
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +4 -7
- package/dist/index.js +94 -151
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +3 -1
- package/dist/indexing/index.js.map +1 -1
- package/dist/{issue-F76PAGIR.js → issue-5X3SMCF4.js} +6 -6
- package/dist/kernel/lazy.d.ts +30 -0
- package/dist/kernel/noydb.d.ts +21 -10
- package/dist/kernel/query/builder.d.ts +10 -10
- package/dist/kernel/query/index.d.ts +0 -6
- package/dist/kernel/query/scan-builder.d.ts +4 -4
- package/dist/kernel/types.d.ts +5 -5
- package/dist/{ledger-M2BKCNVS.js → ledger-K6JBFL3Z.js} +6 -6
- package/dist/liberate-NHTCKBU4.js +24 -0
- package/dist/{link-set-ZU4E5J5S.js → link-set-XVZY2ODC.js} +5 -5
- package/dist/materialized-views/index.js +15 -12
- package/dist/noydb-TI3RFU6M.js +78 -0
- package/dist/periods/index.js +9 -7
- package/dist/pod/index.js +5 -6
- package/dist/{policy-IY2YEA3A.js → policy-QWGJB7P7.js} +4 -4
- package/dist/port/with/collection-registries.d.ts +62 -0
- package/dist/port/with/strategies.d.ts +2 -2
- package/dist/port/with/team-strategy.d.ts +2 -1
- package/dist/portability/index.js +6 -6
- package/dist/{post-register-XIAHB6KF.js → post-register-5VHHVFJY.js} +4 -4
- package/dist/query/index.js +4 -44
- package/dist/{aggregate → reduce}/index.js +22 -15
- package/dist/reduce/index.js.map +1 -0
- package/dist/{register-HB4TQZSV.js → register-CEX7R7NE.js} +6 -6
- package/dist/{registry-6BMBFEXT.js → registry-DIKMRXUC.js} +5 -5
- package/dist/{registry-JOFO7RAH.js → registry-EWIB5NTI.js} +4 -4
- package/dist/{request-withdrawal-UN3TRHWI.js → request-withdrawal-AAG57QO4.js} +9 -9
- package/dist/{reveal-VWXRV2XU.js → reveal-7OOT5XPD.js} +3 -3
- package/dist/{revoke-OLO2OVR7.js → revoke-U5LCIJMF.js} +6 -6
- package/dist/sealed-record/index.js +6 -6
- package/dist/{seed-CDBFOTIK.js → seed-GVOI6QP6.js} +6 -6
- package/dist/session/index.js +7 -3
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.js +4 -0
- package/dist/shadow/index.js.map +1 -1
- package/dist/{signer-MGGKPYAN.js → signer-NAA2OX7H.js} +5 -5
- package/dist/snapshots/index.js +9 -5
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-NBROTA66.js → stale-BJO2WIN7.js} +6 -5
- package/dist/{storage-3R37QZLA.js → storage-FL7XXZTN.js} +5 -5
- package/dist/{store-coordination-provider-P3IU5JHD.js → store-coordination-provider-DX5HECK3.js} +3 -3
- package/dist/sync/index.js +8 -4
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.js +15 -17
- package/dist/tiers/index.js +4 -4
- package/dist/tx/index.js +5 -1
- package/dist/tx/index.js.map +1 -1
- package/dist/via/blob/index.d.ts +2 -0
- package/dist/via/i18n/core.d.ts +1 -1
- package/dist/via/i18n/index.d.ts +2 -0
- package/dist/via/money/money-reducer.d.ts +2 -2
- package/dist/{walk-E3OVLBFR.js → walk-JXMWKKQW.js} +5 -5
- package/dist/with-audit/consent/index.d.ts +2 -0
- package/dist/with-audit/periods/index.d.ts +2 -0
- package/dist/with-cargo/floor.d.ts +3 -3
- package/dist/with-commit/crdt/index.d.ts +2 -0
- package/dist/with-commit/history/index.d.ts +2 -0
- package/dist/with-fork/shadow/index.d.ts +2 -0
- package/dist/with-fork/snapshots/index.d.ts +2 -0
- package/dist/with-formula/materialized-views/types.d.ts +7 -7
- package/dist/with-lookup/indexing/index.d.ts +2 -0
- package/dist/with-lookup/{aggregate → reduce}/active.d.ts +8 -8
- package/dist/with-lookup/{aggregate → reduce}/groupby.d.ts +21 -21
- package/dist/with-lookup/reduce/index.d.ts +34 -0
- package/dist/with-lookup/{aggregate → reduce}/reducers.d.ts +10 -10
- package/dist/with-lookup/{aggregate/aggregation.d.ts → reduce/reduction.d.ts} +21 -21
- package/dist/with-lookup/{aggregate → reduce}/strategy.d.ts +15 -15
- package/dist/with-party/session/index.d.ts +2 -0
- package/dist/with-party/sync/index.d.ts +2 -0
- package/dist/with-party/team/keyring.d.ts +20 -1
- package/dist/with-party/team/noydb-facade.d.ts +2 -1
- package/dist/{withdraw-accessible-Q2EMATCU.js → withdraw-accessible-GO6KQJVM.js} +8 -8
- package/package.json +6 -34
- package/dist/aggregate/index.js.map +0 -1
- package/dist/as/index.js +0 -30
- package/dist/at/index.js +0 -1
- package/dist/by/index.js +0 -11
- package/dist/chunk-2YELV6TV.js +0 -1
- package/dist/chunk-7ICV4ASA.js.map +0 -1
- package/dist/chunk-AFAPBZAA.js +0 -54
- package/dist/chunk-AFAPBZAA.js.map +0 -1
- package/dist/chunk-BY5YBSXA.js.map +0 -1
- package/dist/chunk-CJVEAVYH.js +0 -205
- package/dist/chunk-CJVEAVYH.js.map +0 -1
- package/dist/chunk-CKUYQO2P.js.map +0 -1
- package/dist/chunk-EEZCB74X.js.map +0 -1
- package/dist/chunk-FIP7KI2P.js.map +0 -1
- package/dist/chunk-HQKRZIX6.js.map +0 -1
- package/dist/chunk-IGLU4ME7.js +0 -255
- package/dist/chunk-IGLU4ME7.js.map +0 -1
- package/dist/chunk-J5TEU77Q.js.map +0 -1
- package/dist/chunk-KJTIAECI.js.map +0 -1
- package/dist/chunk-L2CAWCQL.js.map +0 -1
- package/dist/chunk-LB7FD65R.js +0 -163
- package/dist/chunk-LB7FD65R.js.map +0 -1
- package/dist/chunk-QMMOMBH6.js.map +0 -1
- package/dist/chunk-TNATF3HB.js.map +0 -1
- package/dist/chunk-XUFAFHQM.js.map +0 -1
- package/dist/chunk-YTW6ZIPD.js.map +0 -1
- package/dist/chunk-YZN6NRTR.js.map +0 -1
- package/dist/executor-SHYLIBOM.js +0 -26
- package/dist/in/index.js +0 -1
- package/dist/liberate-ZP7UB57K.js +0 -24
- package/dist/noydb-BNDGEK5X.js +0 -71
- package/dist/on/index.js +0 -17
- package/dist/port/as/index.d.ts +0 -26
- package/dist/port/at/index.d.ts +0 -18
- package/dist/port/in/index.d.ts +0 -21
- package/dist/port/on/index.d.ts +0 -27
- package/dist/port/ui/index.d.ts +0 -21
- package/dist/port/with/index.d.ts +0 -18
- package/dist/request-withdrawal-UN3TRHWI.js.map +0 -1
- package/dist/revoke-OLO2OVR7.js.map +0 -1
- package/dist/signer-MGGKPYAN.js.map +0 -1
- package/dist/stale-NBROTA66.js.map +0 -1
- package/dist/storage-3R37QZLA.js.map +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/with/index.js +0 -31
- package/dist/with/index.js.map +0 -1
- package/dist/with-lookup/aggregate/index.d.ts +0 -23
- package/dist/withdraw-accessible-Q2EMATCU.js.map +0 -1
- /package/dist/{api-22ES33N3.js.map → api-5QVQX4HG.js.map} +0 -0
- /package/dist/{backup-YCHAC575.js.map → backup-USYSNCYM.js.map} +0 -0
- /package/dist/{chunk-RWW3I3PO.js.map → chunk-2BVW754E.js.map} +0 -0
- /package/dist/{chunk-VEGQYPCP.js.map → chunk-2ZSC454H.js.map} +0 -0
- /package/dist/{chunk-S4YERMGJ.js.map → chunk-32467U5J.js.map} +0 -0
- /package/dist/{chunk-UVBHM7AK.js.map → chunk-3GXDB3NQ.js.map} +0 -0
- /package/dist/{chunk-HAPY7WFP.js.map → chunk-3TZUC4WS.js.map} +0 -0
- /package/dist/{chunk-M6QA2KK2.js.map → chunk-44Y3P5U6.js.map} +0 -0
- /package/dist/{chunk-WQN5SM7P.js.map → chunk-4B3DL75F.js.map} +0 -0
- /package/dist/{chunk-OHV6T5JB.js.map → chunk-6SSWOUUS.js.map} +0 -0
- /package/dist/{chunk-6RPWILRH.js.map → chunk-7IQWHYL2.js.map} +0 -0
- /package/dist/{chunk-I2XEBEEF.js.map → chunk-AZXEOEQK.js.map} +0 -0
- /package/dist/{chunk-K7BADAOS.js.map → chunk-C2V7AJO2.js.map} +0 -0
- /package/dist/{chunk-YCAJDK4O.js.map → chunk-E7FSBI6I.js.map} +0 -0
- /package/dist/{chunk-YWZEDG7F.js.map → chunk-EPME33Y4.js.map} +0 -0
- /package/dist/{chunk-YXZNGHID.js.map → chunk-H5GMROCB.js.map} +0 -0
- /package/dist/{chunk-FTCGEUOY.js.map → chunk-HDF5R2K6.js.map} +0 -0
- /package/dist/{chunk-R2N37AA6.js.map → chunk-HVPW6PCX.js.map} +0 -0
- /package/dist/{chunk-YXIVUWDU.js.map → chunk-HXVRRJBD.js.map} +0 -0
- /package/dist/{chunk-5ATANZSW.js.map → chunk-ICYC5YNI.js.map} +0 -0
- /package/dist/{chunk-QZJEYZ4I.js.map → chunk-JGOKAZNB.js.map} +0 -0
- /package/dist/{chunk-7BIJS6II.js.map → chunk-JTIPVW4J.js.map} +0 -0
- /package/dist/{chunk-SC4JLMZI.js.map → chunk-KCZAFDP5.js.map} +0 -0
- /package/dist/{chunk-GP54LU5N.js.map → chunk-LG2GUYRX.js.map} +0 -0
- /package/dist/{chunk-QMZ5A6FQ.js.map → chunk-M7W2KYTL.js.map} +0 -0
- /package/dist/{chunk-K4BWPNJO.js.map → chunk-MLCTPWSO.js.map} +0 -0
- /package/dist/{chunk-GEEJPID6.js.map → chunk-MMVQ3SUO.js.map} +0 -0
- /package/dist/{chunk-TNJVDG2B.js.map → chunk-NA374QG7.js.map} +0 -0
- /package/dist/{chunk-V5JUAW4M.js.map → chunk-QVIZDLAR.js.map} +0 -0
- /package/dist/{chunk-2CRZOVDI.js.map → chunk-UNREYBZO.js.map} +0 -0
- /package/dist/{chunk-UTEATWHO.js.map → chunk-VNJMLOQS.js.map} +0 -0
- /package/dist/{chunk-JAMDDLIM.js.map → chunk-WCJJQV2D.js.map} +0 -0
- /package/dist/{chunk-OMSKGLYA.js.map → chunk-WWBC4KLB.js.map} +0 -0
- /package/dist/{chunk-JIHH26WQ.js.map → chunk-XG7OZDOS.js.map} +0 -0
- /package/dist/{chunk-QBOQI6PG.js.map → chunk-XONZGK6J.js.map} +0 -0
- /package/dist/{chunk-YQQPNXNO.js.map → chunk-XSOGLHGY.js.map} +0 -0
- /package/dist/{chunk-3OWYOECI.js.map → chunk-XY6MNSAF.js.map} +0 -0
- /package/dist/{chunk-X3MWEFPT.js.map → chunk-YGMREQAK.js.map} +0 -0
- /package/dist/{chunk-ILM6X6CP.js.map → chunk-ZF572E2M.js.map} +0 -0
- /package/dist/{chunk-OGVE4IJW.js.map → chunk-ZHMUFYZF.js.map} +0 -0
- /package/dist/{chunk-YFFEF6HR.js.map → chunk-ZHZ4PET5.js.map} +0 -0
- /package/dist/{chunk-YZNKFYDC.js.map → chunk-ZM72UO3Y.js.map} +0 -0
- /package/dist/{classified-marker-52P3D72W.js.map → classified-marker-SVDRXLD3.js.map} +0 -0
- /package/dist/{as/index.js.map → collection-facade-S5PPKZD5.js.map} +0 -0
- /package/dist/{at/index.js.map → cover-ADBCTIKN.js.map} +0 -0
- /package/dist/{dead-filter-JXVCKS6W.js.map → dead-filter-HKDMTMVY.js.map} +0 -0
- /package/dist/{by/index.js.map → delegation-EV7LKJPH.js.map} +0 -0
- /package/dist/{chunk-2YELV6TV.js.map → derive-5LDJW76F.js.map} +0 -0
- /package/dist/{dispatch-SMXUO7W5.js.map → dispatch-V5MSMQYX.js.map} +0 -0
- /package/dist/{collection-facade-XKCFHSLR.js.map → enclave-ZA7C3H2L.js.map} +0 -0
- /package/dist/{cover-5BSNJREH.js.map → executor-SVHAJZ4A.js.map} +0 -0
- /package/dist/{delegation-WWZPEDK2.js.map → export-accessible-S35YKIBL.js.map} +0 -0
- /package/dist/{derive-CWWFEQ4N.js.map → extract-partition-UVHAM5WZ.js.map} +0 -0
- /package/dist/{fanout-sidecar-WWXVHHUH.js.map → fanout-sidecar-HRMHC34B.js.map} +0 -0
- /package/dist/{enclave-I5H3GINP.js.map → issue-5X3SMCF4.js.map} +0 -0
- /package/dist/{executor-SHYLIBOM.js.map → ledger-K6JBFL3Z.js.map} +0 -0
- /package/dist/{export-accessible-FBL6TDSK.js.map → liberate-NHTCKBU4.js.map} +0 -0
- /package/dist/{extract-partition-ZYIRYMTI.js.map → link-set-XVZY2ODC.js.map} +0 -0
- /package/dist/{in/index.js.map → noydb-TI3RFU6M.js.map} +0 -0
- /package/dist/{issue-F76PAGIR.js.map → policy-QWGJB7P7.js.map} +0 -0
- /package/dist/{post-register-XIAHB6KF.js.map → post-register-5VHHVFJY.js.map} +0 -0
- /package/dist/{ledger-M2BKCNVS.js.map → register-CEX7R7NE.js.map} +0 -0
- /package/dist/{liberate-ZP7UB57K.js.map → registry-DIKMRXUC.js.map} +0 -0
- /package/dist/{link-set-ZU4E5J5S.js.map → registry-EWIB5NTI.js.map} +0 -0
- /package/dist/{noydb-BNDGEK5X.js.map → request-withdrawal-AAG57QO4.js.map} +0 -0
- /package/dist/{reveal-VWXRV2XU.js.map → reveal-7OOT5XPD.js.map} +0 -0
- /package/dist/{on/index.js.map → revoke-U5LCIJMF.js.map} +0 -0
- /package/dist/{seed-CDBFOTIK.js.map → seed-GVOI6QP6.js.map} +0 -0
- /package/dist/{policy-IY2YEA3A.js.map → signer-NAA2OX7H.js.map} +0 -0
- /package/dist/{register-HB4TQZSV.js.map → stale-BJO2WIN7.js.map} +0 -0
- /package/dist/{registry-6BMBFEXT.js.map → storage-FL7XXZTN.js.map} +0 -0
- /package/dist/{store-coordination-provider-P3IU5JHD.js.map → store-coordination-provider-DX5HECK3.js.map} +0 -0
- /package/dist/{walk-E3OVLBFR.js.map → walk-JXMWKKQW.js.map} +0 -0
- /package/dist/with-lookup/{aggregate → reduce}/canonical-key.d.ts +0 -0
- /package/dist/{registry-JOFO7RAH.js.map → withdraw-accessible-GO6KQJVM.js.map} +0 -0
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazy
|
|
3
|
+
} from "./chunk-5D2ALSM5.js";
|
|
4
|
+
|
|
1
5
|
// src/with-formula/derivations/stale.ts
|
|
6
|
+
var loadDerivationExecutor = lazy(() => import("./executor-FCJEH3FU.js"));
|
|
2
7
|
var _staleByRegistry = /* @__PURE__ */ new WeakMap();
|
|
3
8
|
var keyFor = (source, sourceId) => `${source}/${sourceId}`;
|
|
4
9
|
async function markStale(registry, strategy, sourceId) {
|
|
@@ -33,9 +38,7 @@ async function resolveStaleOnRead(accessor, outputCollection, id) {
|
|
|
33
38
|
continue;
|
|
34
39
|
}
|
|
35
40
|
const sourceWithId = { ...source, id };
|
|
36
|
-
|
|
37
|
-
({ DerivationExecutor } = await import("./executor-FCJEH3FU.js"));
|
|
38
|
-
}
|
|
41
|
+
DerivationExecutor ??= (await loadDerivationExecutor()).DerivationExecutor;
|
|
39
42
|
const ctx = { vault: accessor.getReadOnlyFacade() };
|
|
40
43
|
const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx);
|
|
41
44
|
for (const key of Object.keys(spec.outputs)) {
|
|
@@ -75,4 +78,4 @@ export {
|
|
|
75
78
|
markStale,
|
|
76
79
|
resolveStaleOnRead
|
|
77
80
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-5ABOFAHN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-formula/derivations/stale.ts"],"sourcesContent":["import type { Collection } from '../../kernel/collection.js'\nimport type { DerivationExecutor as DerivationExecutorType } from './executor.js'\nimport type { ReadOnlyVaultFacade } from '../../with-audit/guards/types.js'\nimport type { TxContext } from '../../with-commit/tx/transaction.js'\nimport type { DerivationRegistry } from './registry.js'\n// Type-only — runtime class loaded via dynamic import in\n// `resolveStaleOnRead` only when a stale flag actually fires. Keeps\n// the executor chunk out of the floor bundle.\nimport type { DerivationStrategy } from './types.js'\n\nimport { lazy } from '../../kernel/lazy.js'\n\n/** #846c — one memoized binding instead of a cast at the call site. */\nconst loadDerivationExecutor = lazy(() => import('./executor.js'))\n\n/**\n * Accessor shape passed through from the owning Vault. Provides the\n * registry (used to look up strategies and as the WeakMap key) and a\n * resolver from collection name to the live `Collection` instance.\n * Same shape as `Collection.derivationSource` so callers can pass it\n * through directly.\n */\nexport interface DerivationStaleAccessor {\n registry(): DerivationRegistry\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getCollection(name: string): Collection<any>\n /**\n * Read-only vault facade handed to `derive(source, ctx)` on the lazy\n * resolve-on-read path. Same instance/shape as the eager path uses.\n */\n getReadOnlyFacade(): ReadOnlyVaultFacade\n /**\n * Active multi-record TxContext or `null`. The lazy resolve-on-read\n * path uses this to register tombstone deletes on `_executed` so a\n * later rollback restores the prior emission. Mirrors the eager\n * path's rollback tracking; the lazy `put` was historically\n * unregistered but the tombstone delete (a NEW write path)\n * matches the eager registration for symmetry.\n */\n getActiveTxContext(): TxContext | null\n}\n\n/**\n * In-memory stale map keyed by `DerivationRegistry` instance (stable\n * per vault). Maps `${source}/${sourceId}` → set of pending strategies.\n *\n * Persistence across vault close is NOT implemented in v1 (concern\n * flagged in the dim14 spec). On vault re-open, derived records'\n * `_derivedFrom.strategyHash` will still match the registered\n * strategies' hash, so an unset stale flag is interpreted as \"fresh.\"\n * `vault.deriveAll()` (Task D13) is the explicit recompute escape\n * hatch.\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst _staleByRegistry = new WeakMap<DerivationRegistry, Map<string, Set<DerivationStrategy<any, any>>>>()\n\nconst keyFor = (source: string, sourceId: string): string => `${source}/${sourceId}`\n\n/** Mark every output of (strategy, sourceId) as stale. */\nexport async function markStale(\n registry: DerivationRegistry,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n strategy: DerivationStrategy<any, any>,\n sourceId: string,\n): Promise<void> {\n let map = _staleByRegistry.get(registry)\n if (!map) {\n map = new Map()\n _staleByRegistry.set(registry, map)\n }\n const k = keyFor(strategy.source, sourceId)\n let set = map.get(k)\n if (!set) {\n set = new Set()\n map.set(k, set)\n }\n set.add(strategy)\n}\n\n/**\n * Called from `Collection.get` on lazy-mode output collections. If the\n * id has a pending stale flag for any strategy producing this output\n * collection, re-derive before returning the record. No-op when there\n * is no pending work — keeps the read fast path negligible.\n */\nexport async function resolveStaleOnRead(\n accessor: DerivationStaleAccessor,\n outputCollection: string,\n id: string,\n): Promise<void> {\n const registry = accessor.registry()\n const producers = registry.strategiesProducingOutput(outputCollection)\n if (producers.length === 0) return\n\n const map = _staleByRegistry.get(registry)\n if (!map) return\n\n // Dynamic-import the executor only when at least one stale flag\n // actually fires. Vaults with no derivation strategies never call\n // this function (gated on `derivationSource` in `Collection.get`);\n // vaults with strategies but no pending stale ids reach the\n // `pending.has(spec)` short-circuit below without ever touching\n // the executor chunk.\n let DerivationExecutor: typeof DerivationExecutorType | null = null\n\n for (const { spec, strategyHash } of producers) {\n const k = keyFor(spec.source, id)\n const pending = map.get(k)\n if (!pending || !pending.has(spec)) continue\n\n // Read the source record from the source collection and re-derive.\n // We use the same getCollection accessor that eager dispatch uses\n // — it returns the live `Collection<any>` instance with full\n // crypto / keyring wiring.\n const sourceColl = accessor.getCollection(spec.source)\n const source = await sourceColl.get(id)\n if (!source) {\n pending.delete(spec)\n continue\n }\n const sourceWithId = { ...(source as Record<string, unknown>), id } as Record<string, unknown> & { id: string }\n // sourceVersion: not tracked in v1 stale map; pass 0 — matches the\n // forthcoming v0 semantics, `_derivedFrom.sourceVersion` is\n // informational, not load-bearing for correctness.\n DerivationExecutor ??= (await loadDerivationExecutor()).DerivationExecutor\n const ctx = { vault: accessor.getReadOnlyFacade() }\n const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx)\n for (const key of Object.keys(spec.outputs)) {\n const out = result.outputs[key]\n if (!out) continue\n if (out.kind === 'failed') {\n const err = out.error\n if (spec.strict) {\n // Leave the stale flag set so a future read retries.\n throw err\n }\n console.warn(\n `[derivation] lazy output \"${key}\" for source \"${spec.source}\" id=\"${id}\" failed:`,\n err,\n )\n continue\n }\n if (out.kind === 'array') {\n // Defensive — array-shape requires `lifecycle: 'eager'`\n // (validated at withDerivation registration).\n // Reaching the lazy-resolve path for array-shape would mean\n // a registration check was bypassed. Log and skip.\n console.warn(\n `[derivation] unexpected array-shape output \"${key}\" in lazy resolve path; `\n + 'array-shape derivations require lifecycle: \"eager\".',\n )\n continue\n }\n const outSpec = spec.outputs[key]\n if (!outSpec) continue\n const outputColl = accessor.getCollection(outSpec.collection)\n if (out.skipped === true) {\n // Optional output skipped on lazy resolve — delete any\n // prior emission so the read returns null (matches eager-path\n // tombstone semantics). Routed through `_internalDelete` so a\n // user-registered `onDelete` on the output collection\n // does NOT fire. The active TxContext (if any) is forwarded:\n // `resolveStaleOnRead` is reachable from `Collection.get()`\n // which can be called from inside a transaction, so the\n // tombstone must be observable to `revertExecuted` on\n // rollback.\n await outputColl._internalDelete(id, accessor.getActiveTxContext())\n continue\n }\n await outputColl.put(id, out.value)\n }\n pending.delete(spec)\n }\n}\n"],"mappings":";;;;;AAaA,IAAM,yBAAyB,KAAK,MAAM,OAAO,wBAAe,CAAC;AA2CjE,IAAM,mBAAmB,oBAAI,QAA4E;AAEzG,IAAM,SAAS,CAAC,QAAgB,aAA6B,GAAG,MAAM,IAAI,QAAQ;AAGlF,eAAsB,UACpB,UAEA,UACA,UACe;AACf,MAAI,MAAM,iBAAiB,IAAI,QAAQ;AACvC,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,qBAAiB,IAAI,UAAU,GAAG;AAAA,EACpC;AACA,QAAM,IAAI,OAAO,SAAS,QAAQ,QAAQ;AAC1C,MAAI,MAAM,IAAI,IAAI,CAAC;AACnB,MAAI,CAAC,KAAK;AACR,UAAM,oBAAI,IAAI;AACd,QAAI,IAAI,GAAG,GAAG;AAAA,EAChB;AACA,MAAI,IAAI,QAAQ;AAClB;AAQA,eAAsB,mBACpB,UACA,kBACA,IACe;AACf,QAAM,WAAW,SAAS,SAAS;AACnC,QAAM,YAAY,SAAS,0BAA0B,gBAAgB;AACrE,MAAI,UAAU,WAAW,EAAG;AAE5B,QAAM,MAAM,iBAAiB,IAAI,QAAQ;AACzC,MAAI,CAAC,IAAK;AAQV,MAAI,qBAA2D;AAE/D,aAAW,EAAE,MAAM,aAAa,KAAK,WAAW;AAC9C,UAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;AAChC,UAAM,UAAU,IAAI,IAAI,CAAC;AACzB,QAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,IAAI,EAAG;AAMpC,UAAM,aAAa,SAAS,cAAc,KAAK,MAAM;AACrD,UAAM,SAAS,MAAM,WAAW,IAAI,EAAE;AACtC,QAAI,CAAC,QAAQ;AACX,cAAQ,OAAO,IAAI;AACnB;AAAA,IACF;AACA,UAAM,eAAe,EAAE,GAAI,QAAoC,GAAG;AAIlE,4BAAwB,MAAM,uBAAuB,GAAG;AACxD,UAAM,MAAM,EAAE,OAAO,SAAS,kBAAkB,EAAE;AAClD,UAAM,SAAS,MAAM,mBAAmB,IAAI,MAAM,cAAc,GAAG,cAAc,GAAG;AACpF,eAAW,OAAO,OAAO,KAAK,KAAK,OAAO,GAAG;AAC3C,YAAM,MAAM,OAAO,QAAQ,GAAG;AAC9B,UAAI,CAAC,IAAK;AACV,UAAI,IAAI,SAAS,UAAU;AACzB,cAAM,MAAM,IAAI;AAChB,YAAI,KAAK,QAAQ;AAEf,gBAAM;AAAA,QACR;AACA,gBAAQ;AAAA,UACN,6BAA6B,GAAG,iBAAiB,KAAK,MAAM,SAAS,EAAE;AAAA,UACvE;AAAA,QACF;AACA;AAAA,MACF;AACA,UAAI,IAAI,SAAS,SAAS;AAKxB,gBAAQ;AAAA,UACN,+CAA+C,GAAG;AAAA,QAEpD;AACA;AAAA,MACF;AACA,YAAM,UAAU,KAAK,QAAQ,GAAG;AAChC,UAAI,CAAC,QAAS;AACd,YAAM,aAAa,SAAS,cAAc,QAAQ,UAAU;AAC5D,UAAI,IAAI,YAAY,MAAM;AAUxB,cAAM,WAAW,gBAAgB,IAAI,SAAS,mBAAmB,CAAC;AAClE;AAAA,MACF;AACA,YAAM,WAAW,IAAI,IAAI,IAAI,KAAK;AAAA,IACpC;AACA,YAAQ,OAAO,IAAI;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/kernel/lazy.ts
|
|
2
|
+
function lazy(load) {
|
|
3
|
+
let cached;
|
|
4
|
+
let inflight;
|
|
5
|
+
return async () => {
|
|
6
|
+
if (cached !== void 0) return cached;
|
|
7
|
+
inflight ??= load().then((mod) => {
|
|
8
|
+
cached = mod;
|
|
9
|
+
inflight = void 0;
|
|
10
|
+
return mod;
|
|
11
|
+
});
|
|
12
|
+
return inflight;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
lazy
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-5D2ALSM5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/kernel/lazy.ts"],"sourcesContent":["/**\n * Memoized module loader for the S4 lazy-import seam (#846c).\n *\n * The spine and the services reach optional machinery through a dynamic\n * `import()` — that is what keeps a service out of the floor bundle for\n * consumers who never opt into it, and `check-architecture`'s `port-layering`\n * rule requires it for any spine→service edge. The pattern stays; this only\n * removes the ceremony that grew around it.\n *\n * Call sites had each re-invented the same shape: a `let mod = null` cache\n * declared *inside* the function (so it cached for one invocation and no\n * longer), plus in several places an `as { … }` cast, because destructuring a\n * dynamic import inline gave up the module's type.\n *\n * ```ts\n * const loadExecutor = lazy(() => import('./executor.js'))\n * // …\n * const { DerivationExecutor } = await loadExecutor()\n * ```\n *\n * Note this is about clarity, not speed: the ES module system already caches a\n * resolved module, so the win is one named binding per module instead of a\n * hand-rolled cache and a cast at every call site.\n *\n * Concurrent first calls share a single in-flight promise rather than each\n * starting their own `import()`.\n *\n * @internal\n */\nexport function lazy<T>(load: () => Promise<T>): () => Promise<T> {\n let cached: T | undefined\n let inflight: Promise<T> | undefined\n\n return async (): Promise<T> => {\n if (cached !== undefined) return cached\n inflight ??= load().then((mod) => {\n cached = mod\n inflight = undefined\n return mod\n })\n return inflight\n }\n}\n"],"mappings":";AA6BO,SAAS,KAAQ,MAA0C;AAChE,MAAI;AACJ,MAAI;AAEJ,SAAO,YAAwB;AAC7B,QAAI,WAAW,OAAW,QAAO;AACjC,iBAAa,KAAK,EAAE,KAAK,CAAC,QAAQ;AAChC,eAAS;AACT,iBAAW;AACX,aAAO;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NOYDB_FORMAT_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
4
4
|
|
|
5
5
|
// src/with-party/team/managed-secret.ts
|
|
6
6
|
var MemorySealingKeyProvider = class {
|
|
@@ -227,4 +227,4 @@ export {
|
|
|
227
227
|
loadSealedSecret,
|
|
228
228
|
resolveManagedSecret
|
|
229
229
|
};
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-6SSWOUUS.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openEnvelopeJson
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MMVQ3SUO.js";
|
|
4
4
|
import {
|
|
5
5
|
encrypt
|
|
6
6
|
} from "./chunk-7U6AB7DZ.js";
|
|
7
7
|
import {
|
|
8
8
|
NOYDB_FORMAT_VERSION
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
10
10
|
import {
|
|
11
11
|
ConflictError,
|
|
12
12
|
USER_ENVELOPE_COLLECTION,
|
|
@@ -147,4 +147,4 @@ export {
|
|
|
147
147
|
deleteUserEnvelope,
|
|
148
148
|
listUserEnvelopeIds
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
150
|
+
//# sourceMappingURL=chunk-7IQWHYL2.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/with-commit/history/strategy.ts
|
|
2
|
+
function notEnabled(op) {
|
|
3
|
+
return new Error(
|
|
4
|
+
`${op} requires the history strategy. Import \`{ withHistory }\` from "@noy-db/hub/history" and pass it to \`createNoydb({ historyStrategy: withHistory() })\`.`
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
var NO_HISTORY = {
|
|
8
|
+
async saveHistory() {
|
|
9
|
+
},
|
|
10
|
+
async getHistoryEntries() {
|
|
11
|
+
throw notEnabled("collection.history()");
|
|
12
|
+
},
|
|
13
|
+
async getVersionEnvelope() {
|
|
14
|
+
throw notEnabled("collection.getVersion()");
|
|
15
|
+
},
|
|
16
|
+
async pruneHistory() {
|
|
17
|
+
return 0;
|
|
18
|
+
},
|
|
19
|
+
async clearHistory() {
|
|
20
|
+
return 0;
|
|
21
|
+
},
|
|
22
|
+
async tombstoneHistory() {
|
|
23
|
+
return 0;
|
|
24
|
+
},
|
|
25
|
+
async rewrapHistory() {
|
|
26
|
+
},
|
|
27
|
+
async envelopePayloadHash() {
|
|
28
|
+
return "";
|
|
29
|
+
},
|
|
30
|
+
computePatch() {
|
|
31
|
+
return [];
|
|
32
|
+
},
|
|
33
|
+
diff() {
|
|
34
|
+
throw notEnabled("collection.diff()");
|
|
35
|
+
},
|
|
36
|
+
buildLedger() {
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
buildVaultInstant() {
|
|
40
|
+
throw notEnabled("vault.at() / vault.timeMachine()");
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
NO_HISTORY
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=chunk-AFHQATY4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-commit/history/strategy.ts"],"sourcesContent":["/**\n * Strategy seam for the optional history + ledger + time-machine\n * service. Core imports `HistoryStrategy` type-only + `NO_HISTORY`\n * stub; real implementations of `saveHistory`, `LedgerStore`,\n * `VaultInstant`, `computePatch`, `diff` etc. are only reachable via\n * `withHistory()` in `./active.ts`.\n *\n * Applications that don't track per-record versioning, don't need the\n * hash-chained audit ledger, and don't restore to past instants ship\n * none of the ~1,880 LOC behind this seam.\n *\n * Strategy contract:\n *\n * - **saveHistory / pruneHistory / clearHistory** — no-ops under\n * NO_HISTORY. Writes still succeed; no snapshot is captured.\n * - **getHistoryEntries / getVersionEnvelope / diff** — throw under\n * NO_HISTORY. These are read APIs the consumer would only call\n * after explicitly asking for history; the throw guides them to\n * `@noy-db/hub/history`.\n * - **envelopePayloadHash / computePatch** — return empty / `[]`\n * under NO_HISTORY. These are only used inside the\n * `if (this.ledger)` branch, which is itself gated by\n * `buildLedger()` returning null.\n * - **buildLedger** — returns `null` under NO_HISTORY. The Vault's\n * public `vault.ledger()` accessor throws when null.\n * - **buildVaultInstant** — throws under NO_HISTORY. `vault.at()`\n * propagates the throw.\n *\n * @internal\n */\n\nimport type {\n EncryptedEnvelope,\n NoydbStore,\n HistoryOptions,\n PruneOptions,\n} from '../../kernel/types.js'\nimport type { LedgerStore } from './ledger/store.js'\nimport type { JsonPatch } from './ledger/patch.js'\nimport type { DiffEntry } from './diff.js'\nimport type { VaultInstant, VaultEngine } from './time-machine.js'\nimport type { EnclaveKey } from '../../kernel/enclave/index.js'\n\n/**\n * Options accepted by `HistoryStrategy.buildLedger`. Mirrors the\n * `LedgerStore` constructor verbatim — kept in this file so `core`\n * code never imports the LedgerStore module at runtime.\n *\n * @internal\n */\nexport interface BuildLedgerOptions {\n adapter: NoydbStore\n vault: string\n encrypted: boolean\n getDEK: (collectionName: string) => Promise<EnclaveKey>\n actor: string\n}\n\n/**\n * @internal\n */\nexport interface HistoryStrategy {\n /**\n * Persist a full encrypted envelope snapshot of the prior version\n * under `_history/{collection}:{id}:{paddedVersion}`. No-op under\n * `NO_HISTORY`.\n */\n saveHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n envelope: EncryptedEnvelope,\n ): Promise<void>\n\n /**\n * List history envelopes for a record, newest first. Throws under\n * `NO_HISTORY` — callers reach this via `collection.history()` /\n * `collection.getVersion()` / `collection.diff()`, which only work\n * with the strategy enabled.\n */\n getHistoryEntries(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n options?: HistoryOptions,\n ): Promise<EncryptedEnvelope[]>\n\n /**\n * Fetch a specific version's envelope. Throws under `NO_HISTORY`.\n */\n getVersionEnvelope(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n version: number,\n ): Promise<EncryptedEnvelope | null>\n\n /**\n * Prune history entries by retention rule. Returns `0` under\n * `NO_HISTORY`.\n */\n pruneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string | undefined,\n options: PruneOptions,\n ): Promise<number>\n\n /**\n * Clear all history for vault/collection/record. Returns `0` under\n * `NO_HISTORY`.\n */\n clearHistory(\n adapter: NoydbStore,\n vault: string,\n collection?: string,\n recordId?: string,\n ): Promise<number>\n\n /**\n * Crypto-shred (overwrite-to-tombstone) every `_history` version of a\n * record for GDPR erasure. Returns the number of versions newly\n * tombstoned, or `0` under `NO_HISTORY` (no history = nothing to shred).\n */\n tombstoneHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n actor: string,\n encrypted: boolean,\n ): Promise<number>\n\n /**\n * Re-key every `_history` snapshot of a record from `fromDek` to `toDek`\n * on a tier move (elevate/demote/putAtTier), mirroring the live-body\n * rewrap so prior versions are not left decryptable at rest under a tier\n * the record has moved away from. Optional `tier0Dek` enables the legacy\n * fallback for snapshots written before this rewrap existed (see\n * `history.ts` for the full contract). No-op under `NO_HISTORY` (no\n * history = nothing to rewrap).\n */\n rewrapHistory(\n adapter: NoydbStore,\n vault: string,\n collection: string,\n recordId: string,\n fromDek: EnclaveKey,\n toDek: EnclaveKey,\n tier0Dek?: EnclaveKey,\n ): Promise<void>\n\n /**\n * Compute the SHA-256 hash of an envelope's encrypted payload, used\n * by `LedgerStore.append` to track tamper-evidence. Returns the\n * empty string under `NO_HISTORY` (the call site is gated by\n * `if (this.ledger)`, so the value is never observed).\n */\n envelopePayloadHash(envelope: EncryptedEnvelope | null): Promise<string>\n\n /**\n * Compute the JSON patch from `from` → `to`. Returns `[]` under\n * `NO_HISTORY`.\n */\n computePatch(from: unknown, to: unknown): JsonPatch\n\n /**\n * Compute the typed diff between two records. Throws under\n * `NO_HISTORY` — `collection.diff()` is a history-read API.\n */\n diff(recordA: unknown, recordB: unknown): DiffEntry[]\n\n /**\n * Construct (or return null) a `LedgerStore` for the vault. Returns\n * `null` under `NO_HISTORY`; the Vault treats null as \"no ledger\n * attached\" — collection write paths skip the append branch and the\n * public `vault.ledger()` accessor throws.\n */\n buildLedger(opts: BuildLedgerOptions): LedgerStore | null\n\n /**\n * Construct a `VaultInstant` for time-machine reads. Throws under\n * `NO_HISTORY`.\n */\n buildVaultInstant(engine: VaultEngine, timestamp: string): VaultInstant\n}\n\n/**\n * Error thrown when the consumer reaches a history-gated surface\n * without opting into the strategy. The message names the offending\n * operation and points to the subpath import.\n *\n * @internal\n */\nfunction notEnabled(op: string): Error {\n return new Error(\n `${op} requires the history strategy. Import ` +\n '`{ withHistory }` from \"@noy-db/hub/history\" and pass it to ' +\n '`createNoydb({ historyStrategy: withHistory() })`.',\n )\n}\n\n/**\n * No-history stub. Snapshots and prune/clear are no-ops; reads and\n * time-machine throw with an actionable message; ledger construction\n * returns null so the write-path's `if (this.ledger)` branch is dead\n * code in the bundle.\n *\n * @internal\n */\nexport const NO_HISTORY: HistoryStrategy = {\n async saveHistory() {},\n async getHistoryEntries() { throw notEnabled('collection.history()') },\n async getVersionEnvelope() { throw notEnabled('collection.getVersion()') },\n async pruneHistory() { return 0 },\n async clearHistory() { return 0 },\n async tombstoneHistory() { return 0 },\n async rewrapHistory() {},\n async envelopePayloadHash() { return '' },\n computePatch() { return [] },\n diff() { throw notEnabled('collection.diff()') },\n buildLedger() { return null },\n buildVaultInstant() { throw notEnabled('vault.at() / vault.timeMachine()') },\n}\n"],"mappings":";AAsMA,SAAS,WAAW,IAAmB;AACrC,SAAO,IAAI;AAAA,IACT,GAAG,EAAE;AAAA,EAGP;AACF;AAUO,IAAM,aAA8B;AAAA,EACzC,MAAM,cAAc;AAAA,EAAC;AAAA,EACrB,MAAM,oBAAoB;AAAE,UAAM,WAAW,sBAAsB;AAAA,EAAE;AAAA,EACrE,MAAM,qBAAqB;AAAE,UAAM,WAAW,yBAAyB;AAAA,EAAE;AAAA,EACzE,MAAM,eAAe;AAAE,WAAO;AAAA,EAAE;AAAA,EAChC,MAAM,eAAe;AAAE,WAAO;AAAA,EAAE;AAAA,EAChC,MAAM,mBAAmB;AAAE,WAAO;AAAA,EAAE;AAAA,EACpC,MAAM,gBAAgB;AAAA,EAAC;AAAA,EACvB,MAAM,sBAAsB;AAAE,WAAO;AAAA,EAAG;AAAA,EACxC,eAAe;AAAE,WAAO,CAAC;AAAA,EAAE;AAAA,EAC3B,OAAO;AAAE,UAAM,WAAW,mBAAmB;AAAA,EAAE;AAAA,EAC/C,cAAc;AAAE,WAAO;AAAA,EAAK;AAAA,EAC5B,oBAAoB;AAAE,UAAM,WAAW,kCAAkC;AAAA,EAAE;AAC7E;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openEnvelopeJson
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MMVQ3SUO.js";
|
|
4
4
|
import {
|
|
5
5
|
encrypt,
|
|
6
6
|
hmacSha256Hex,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-7U6AB7DZ.js";
|
|
9
9
|
import {
|
|
10
10
|
NOYDB_FORMAT_VERSION
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
12
12
|
|
|
13
13
|
// src/with-audit/forget/strategy.ts
|
|
14
14
|
var NO_FORGET = { subjects: {} };
|
|
@@ -147,4 +147,4 @@ export {
|
|
|
147
147
|
coerceSubjectId,
|
|
148
148
|
readDottedPath
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
150
|
+
//# sourceMappingURL=chunk-AZXEOEQK.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
envelopePayloadHash
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2BVW754E.js";
|
|
4
4
|
import {
|
|
5
5
|
NOYDB_FORMAT_VERSION
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DOZFU7OZ.js";
|
|
7
7
|
import {
|
|
8
8
|
DictKeyMissingError,
|
|
9
9
|
PermissionDeniedError
|
|
@@ -389,4 +389,4 @@ export {
|
|
|
389
389
|
dictCollectionName,
|
|
390
390
|
LookupHandle
|
|
391
391
|
};
|
|
392
|
-
//# sourceMappingURL=chunk-
|
|
392
|
+
//# sourceMappingURL=chunk-C2V7AJO2.js.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readPath
|
|
3
|
+
} from "./chunk-IGJCYUT5.js";
|
|
4
|
+
|
|
5
|
+
// src/with-lookup/reduce/reducers.ts
|
|
6
|
+
function count(opts) {
|
|
7
|
+
const _seed = opts?.seed;
|
|
8
|
+
void _seed;
|
|
9
|
+
return {
|
|
10
|
+
op: "count",
|
|
11
|
+
init: () => 0,
|
|
12
|
+
step: (state) => state + 1,
|
|
13
|
+
remove: (state) => state - 1,
|
|
14
|
+
finalize: (state) => state,
|
|
15
|
+
merge: (a, b) => a + b
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function sum(field, opts) {
|
|
19
|
+
const _seed = opts?.seed;
|
|
20
|
+
void _seed;
|
|
21
|
+
return {
|
|
22
|
+
op: "sum",
|
|
23
|
+
field,
|
|
24
|
+
// Money-only metadata, read by `wrapMoneyReducers`. No effect on a
|
|
25
|
+
// generic numeric sum.
|
|
26
|
+
...opts?.convertTo !== void 0 ? { convertTo: opts.convertTo } : {},
|
|
27
|
+
...opts?.fx !== void 0 ? { fx: opts.fx } : {},
|
|
28
|
+
init: () => 0,
|
|
29
|
+
step: (state, record) => state + readNumber(record, field),
|
|
30
|
+
remove: (state, record) => state - readNumber(record, field),
|
|
31
|
+
finalize: (state) => state,
|
|
32
|
+
merge: (a, b) => a + b
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function avg(field, opts) {
|
|
36
|
+
const _seed = opts?.seed;
|
|
37
|
+
void _seed;
|
|
38
|
+
return {
|
|
39
|
+
op: "avg",
|
|
40
|
+
field,
|
|
41
|
+
init: () => ({ sum: 0, count: 0 }),
|
|
42
|
+
step: (state, record) => ({
|
|
43
|
+
sum: state.sum + readNumber(record, field),
|
|
44
|
+
count: state.count + 1
|
|
45
|
+
}),
|
|
46
|
+
remove: (state, record) => ({
|
|
47
|
+
sum: state.sum - readNumber(record, field),
|
|
48
|
+
count: state.count - 1
|
|
49
|
+
}),
|
|
50
|
+
finalize: (state) => state.count === 0 ? null : state.sum / state.count,
|
|
51
|
+
merge: (a, b) => ({ sum: a.sum + b.sum, count: a.count + b.count })
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function pushValue(state, value) {
|
|
55
|
+
return { values: [...state.values, value] };
|
|
56
|
+
}
|
|
57
|
+
function removeValue(state, value) {
|
|
58
|
+
const idx = state.values.indexOf(value);
|
|
59
|
+
if (idx < 0) return state;
|
|
60
|
+
const next = state.values.slice();
|
|
61
|
+
next.splice(idx, 1);
|
|
62
|
+
return { values: next };
|
|
63
|
+
}
|
|
64
|
+
function min(field, opts) {
|
|
65
|
+
const _seed = opts?.seed;
|
|
66
|
+
void _seed;
|
|
67
|
+
return {
|
|
68
|
+
op: "min",
|
|
69
|
+
field,
|
|
70
|
+
init: () => ({ values: [] }),
|
|
71
|
+
step: (state, record) => pushValue(state, readNumber(record, field)),
|
|
72
|
+
remove: (state, record) => removeValue(state, readNumber(record, field)),
|
|
73
|
+
finalize: (state) => {
|
|
74
|
+
if (state.values.length === 0) return null;
|
|
75
|
+
let out = state.values[0];
|
|
76
|
+
for (let i = 1; i < state.values.length; i++) {
|
|
77
|
+
const v = state.values[i];
|
|
78
|
+
if (v < out) out = v;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
},
|
|
82
|
+
merge: (a, b) => ({ values: [...a.values, ...b.values] })
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function max(field, opts) {
|
|
86
|
+
const _seed = opts?.seed;
|
|
87
|
+
void _seed;
|
|
88
|
+
return {
|
|
89
|
+
op: "max",
|
|
90
|
+
field,
|
|
91
|
+
init: () => ({ values: [] }),
|
|
92
|
+
step: (state, record) => pushValue(state, readNumber(record, field)),
|
|
93
|
+
remove: (state, record) => removeValue(state, readNumber(record, field)),
|
|
94
|
+
finalize: (state) => {
|
|
95
|
+
if (state.values.length === 0) return null;
|
|
96
|
+
let out = state.values[0];
|
|
97
|
+
for (let i = 1; i < state.values.length; i++) {
|
|
98
|
+
const v = state.values[i];
|
|
99
|
+
if (v > out) out = v;
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
},
|
|
103
|
+
merge: (a, b) => ({ values: [...a.values, ...b.values] })
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function moneySum(field, opts) {
|
|
107
|
+
return sum(field, opts);
|
|
108
|
+
}
|
|
109
|
+
function moneyMin(field, opts) {
|
|
110
|
+
return min(field, opts);
|
|
111
|
+
}
|
|
112
|
+
function moneyMax(field, opts) {
|
|
113
|
+
return max(field, opts);
|
|
114
|
+
}
|
|
115
|
+
var reducerBuilder = {
|
|
116
|
+
count,
|
|
117
|
+
// The generic F parameter on sum/min/max in the interface is type-only; the
|
|
118
|
+
// standalone factories are plain `(field: string)` functions. With M=never the
|
|
119
|
+
// conditional return collapses to the numeric branch, matching the factories'
|
|
120
|
+
// return type, but TypeScript cannot verify that collapse for a generic method
|
|
121
|
+
// signature — so each factory is cast directly to the method's type.
|
|
122
|
+
sum,
|
|
123
|
+
avg,
|
|
124
|
+
min,
|
|
125
|
+
max,
|
|
126
|
+
moneySum,
|
|
127
|
+
moneyMin,
|
|
128
|
+
moneyMax
|
|
129
|
+
};
|
|
130
|
+
function readNumber(record, field) {
|
|
131
|
+
const value = readPath(record, field);
|
|
132
|
+
if (typeof value === "object" && value !== null && "amount" in value && "currency" in value) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`aggregate: field "${field}" holds a money value but was not money-aware \u2014 declare it in the collection's moneyFields so sum/min/max stay exact`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
count,
|
|
142
|
+
sum,
|
|
143
|
+
avg,
|
|
144
|
+
min,
|
|
145
|
+
max,
|
|
146
|
+
moneySum,
|
|
147
|
+
moneyMin,
|
|
148
|
+
moneyMax,
|
|
149
|
+
reducerBuilder
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=chunk-CADUYBQD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-lookup/reduce/reducers.ts"],"sourcesContent":["/**\n * Reduction reducers for the query DSL.\n *\n * the reducer protocol plus five built-in factories\n * (`count`, `sum`, `avg`, `min`, `max`) consumed by `Query.aggregate()`\n * and, in the future, `Scan.aggregate()`. Every factory accepts\n * an optional `{ seed }` parameter that is plumbed through the\n * protocol but unused by the executor — that's the load-bearing\n * half of constraint #2. When partition-aware reduction\n * lands, the seed carries the previous partition's running total into\n * the next partition without requiring a protocol change.\n *\n * Reducers are intentionally generic over their internal state type\n * `S` so compound reducers (avg keeps `{sum, count}`, min/max keep a\n * value bag) can model internal bookkeeping without leaking the\n * implementation through the accumulator's public shape. `finalize`\n * collapses `S` back into the user-visible `R`.\n *\n * Reducers are pure data — `init` / `step` / `finalize` / optional\n * `remove` are stateless functions that receive and return `S`. This\n * is the shape that admits O(1) incremental maintenance in a future\n * optimization (delta-aware `LiveReduction` applies `step` or\n * `remove` per delta), without blocking the simpler \"full re-run on\n * source change\" that ships.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport type { MoneyString } from '../../via/money/branded.js'\nimport type { QueryField } from '../../kernel/types.js'\n\n/**\n * A single reducer: factory-produced, ready to plug into an\n * `.aggregate()` spec.\n *\n * Type parameters:\n * - `R` — user-visible result type (what the reduction returns\n * for this slot, e.g. `number` for `sum()`)\n * - `S` — internal state type, defaults to `R` for simple reducers\n * that don't need compound bookkeeping\n *\n * A reducer is stateless: every method is pure over `S`. `init()` is\n * called once per reduction run to build the initial state; `step()`\n * folds a record into the state; `remove()` (optional) un-folds a\n * record, enabling incremental live maintenance; `finalize()` reads\n * the final answer out of the state at the end of the run.\n */\nexport interface Reducer<R, S = R> {\n /** Build the initial state for a fresh reduction run. */\n init(): S\n /** Fold a record into the state. Returns the new state. */\n step(state: S, record: unknown): S\n /**\n * Un-fold a record from the state. Returns the new state.\n *\n * Optional — reducers without `remove` cannot be maintained\n * incrementally and must be re-run from scratch when the underlying\n * record set changes. `sum`, `count`, `avg` implement `remove` in\n * O(1); `min` and `max` implement it in O(N) worst case (when the\n * extremum itself is removed and the next extremum must be\n * recomputed from the remaining contributing values).\n */\n remove?(state: S, record: unknown): S\n /** Collapse the internal state into the user-visible result. */\n finalize(state: S): R\n /**\n * Combine two independent partial states into one (then `finalize` once).\n * Optional. MUST be associative + commutative with `init()` as identity.\n * Never merge finalized results — only states. Enables parallel /\n * hierarchical reduction (e.g. cross-shard or advisor→firm rollup).\n */\n merge?(a: S, b: S): S\n /**\n * Identifying operation tag stamped by each built-in factory.\n * Used by `summariseAggregateOp` in the introspection walker to\n * render human-readable aggregate descriptors in `dumpSchema()`.\n * Optional so third-party custom reducers are unaffected.\n */\n readonly op?: 'count' | 'sum' | 'avg' | 'min' | 'max'\n /**\n * Field name for field-based reducers (`sum`, `avg`, `min`, `max`).\n * Absent on `count` which aggregates over record count, not a field.\n */\n readonly field?: string\n /**\n * Money-only: target currency for `sum` over a multi-currency money\n * field. Consumed by `wrapMoneyReducers` to convert per-currency\n * subtotals to one figure. Ignored for non-money fields.\n */\n readonly convertTo?: string\n /**\n * Money-only: FX rate map (`'USD->EUR' → rate`) used with `convertTo`.\n */\n readonly fx?: Record<string, number | string>\n}\n\n/**\n * Common options accepted by every reducer factory.\n *\n * `seed` — optional initial value for the internal state. **Unused by\n * the executor**, plumbed through the protocol for constraint\n * #2 (partition-aware reduction seam). In, partitioned\n * reductions will pass the previous partition's carry as `seed` so\n * a long time series can be rolled forward one partition at a time\n * without re-reducing closed partitions.\n *\n * always uses `init()` with the factory's zero value, regardless\n * of whether `seed` was passed. Do not remove the parameter — that's\n * the whole point of having it exist now.\n */\nexport interface ReducerOptions<TSeed = unknown> {\n /** constraint #2 — seed is plumbed through but unused in. */\n readonly seed?: TSeed\n /**\n * Money-only (honored by `sum` over a multi-currency money field):\n * convert per-currency subtotals to this currency for a single figure.\n */\n readonly convertTo?: string\n /** Money-only: FX rate map (`'USD->EUR' → rate`) used with `convertTo`. */\n readonly fx?: Record<string, number | string>\n}\n\n// ---------------------------------------------------------------------------\n// Factories\n// ---------------------------------------------------------------------------\n\n/**\n * Count the number of records that match the query. Ignores field\n * values entirely — the count is over the number of records, not over\n * the number of non-null field values in any column.\n */\nexport function count(opts?: ReducerOptions<number>): Reducer<number> {\n // Seed captured on the closure but unused at execution time in\n //. The reference in _seed keeps lint happy.\n const _seed = opts?.seed\n void _seed\n return {\n op: 'count',\n init: () => 0,\n step: (state) => state + 1,\n remove: (state) => state - 1,\n finalize: (state) => state,\n merge: (a, b) => a + b,\n }\n}\n\n/**\n * Sum a numeric field across all matching records. Non-number values\n * at the field path are coerced to 0 — consumers who want a different\n * behavior (throw, skip, treat as NaN) should filter upstream via\n * `.where()` or write a custom reducer.\n *\n * KNOWN LIMITATION (type imprecision): the declared result type is `number`,\n * but when `field` is a **money** field the runtime returns a decimal *string*\n * (e.g. `'0.30'`, or `{ EUR: '0.30' }` in multi-currency mode) — money sums are\n * BigInt-exact in scaled space and never collapse to a float. The `number` type\n * is therefore a lie for money fields; narrow the result yourself at the call\n * site. A precise fix requires threading money-field declarations into the type\n * system (tracked separately).\n */\nexport function sum(\n field: string,\n opts?: ReducerOptions<number>,\n): Reducer<number> {\n const _seed = opts?.seed\n void _seed\n return {\n op: 'sum',\n field,\n // Money-only metadata, read by `wrapMoneyReducers`. No effect on a\n // generic numeric sum.\n ...(opts?.convertTo !== undefined ? { convertTo: opts.convertTo } : {}),\n ...(opts?.fx !== undefined ? { fx: opts.fx } : {}),\n init: () => 0,\n step: (state, record) => state + readNumber(record, field),\n remove: (state, record) => state - readNumber(record, field),\n finalize: (state) => state,\n merge: (a, b) => a + b,\n }\n}\n\n/**\n * Arithmetic mean of a numeric field across all matching records.\n *\n * Returns `null` for an empty result set (zero records is not a\n * well-defined denominator — returning NaN would poison downstream\n * arithmetic, and throwing would force every consumer to wrap in\n * try/catch just to handle \"no matches\"). Consumers who want an\n * explicit zero should coalesce with `?? 0`.\n *\n * Internal state is `{sum, count}` so the running average can be\n * maintained incrementally — on each delta, both fields update in\n * O(1) and `finalize` divides. Directly storing `avg` as state would\n * not admit incremental removal without also tracking count.\n */\nexport function avg(\n field: string,\n opts?: ReducerOptions<{ sum: number; count: number }>,\n): Reducer<number | null, { sum: number; count: number }> {\n const _seed = opts?.seed\n void _seed\n return {\n op: 'avg',\n field,\n init: () => ({ sum: 0, count: 0 }),\n step: (state, record) => ({\n sum: state.sum + readNumber(record, field),\n count: state.count + 1,\n }),\n remove: (state, record) => ({\n sum: state.sum - readNumber(record, field),\n count: state.count - 1,\n }),\n finalize: (state) => (state.count === 0 ? null : state.sum / state.count),\n merge: (a, b) => ({ sum: a.sum + b.sum, count: a.count + b.count }),\n }\n}\n\nexport interface MinMaxState {\n /**\n * Multiset of contributing field values. Stored as a plain array\n * because we need to support `remove` and a plain array gives us\n * O(1) push + O(N) worst-case removal — which matches the\n * documented min/max removal complexity. A sorted structure would\n * let us drop the O(N) rescan but adds complexity that doesn't\n * need; consumers hitting the O(N) ceiling should file an issue.\n */\n readonly values: number[]\n}\n\nfunction pushValue(state: MinMaxState, value: number): MinMaxState {\n return { values: [...state.values, value] }\n}\n\nfunction removeValue(state: MinMaxState, value: number): MinMaxState {\n // Remove the first matching value — duplicates are fine, we only\n // need to drop one instance per `remove()` call so the multiset\n // count stays consistent with the record count.\n const idx = state.values.indexOf(value)\n if (idx < 0) return state\n const next = state.values.slice()\n next.splice(idx, 1)\n return { values: next }\n}\n\n/**\n * Smallest numeric value of a field across all matching records.\n * Returns `null` for an empty result set. See `avg()` for the\n * reasoning on `null` vs NaN vs throwing.\n *\n * Incremental complexity: O(1) for `step`, O(N) worst case for\n * `remove` when the current minimum is removed (the state holds the\n * full multiset of contributing values and `finalize` scans for the\n * new minimum). Consumers with very large result sets and frequent\n * removals of the current extremum should either accept the cost or\n * wait for a future optimization.\n */\nexport function min(\n field: string,\n opts?: ReducerOptions<number>,\n): Reducer<number | null, MinMaxState> {\n const _seed = opts?.seed\n void _seed\n return {\n op: 'min',\n field,\n init: () => ({ values: [] }),\n step: (state, record) => pushValue(state, readNumber(record, field)),\n remove: (state, record) => removeValue(state, readNumber(record, field)),\n finalize: (state) => {\n if (state.values.length === 0) return null\n let out = state.values[0]!\n for (let i = 1; i < state.values.length; i++) {\n const v = state.values[i]!\n if (v < out) out = v\n }\n return out\n },\n merge: (a, b) => ({ values: [...a.values, ...b.values] }),\n }\n}\n\n/**\n * Largest numeric value of a field across all matching records.\n * Mirror of `min()` — see that doc for semantics, null-on-empty\n * behavior, and the O(N) removal caveat.\n */\nexport function max(\n field: string,\n opts?: ReducerOptions<number>,\n): Reducer<number | null, MinMaxState> {\n const _seed = opts?.seed\n void _seed\n return {\n op: 'max',\n field,\n init: () => ({ values: [] }),\n step: (state, record) => pushValue(state, readNumber(record, field)),\n remove: (state, record) => removeValue(state, readNumber(record, field)),\n finalize: (state) => {\n if (state.values.length === 0) return null\n let out = state.values[0]!\n for (let i = 1; i < state.values.length; i++) {\n const v = state.values[i]!\n if (v > out) out = v\n }\n return out\n },\n merge: (a, b) => ({ values: [...a.values, ...b.values] }),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Money-typed reducer constructors\n// ---------------------------------------------------------------------------\n\n/**\n * `sum()` for a **declared money field**, typed to match the runtime.\n *\n * `sum()` returns `Reducer<number>`, but `wrapMoneyReducers` (applied at\n * `query.aggregate()` time, once `moneyFields` is known) rewrites any\n * `sum`/`min`/`max` over a money field to a money reducer that finalizes to a\n * `MoneyString` decimal — so the `number` type is a lie for money fields and\n * consumers need a cast at every read site. `moneySum` is the same reducer with\n * the correct `Reducer<MoneyString>` return type, so no read-site cast is\n * needed. It is the caller's assertion that `field` is a money field; use plain\n * `sum()` for non-money fields. (For a multi-currency money field WITHOUT\n * `convertTo`, the runtime returns a per-currency `Record<string, MoneyString>`\n * rather than a single `MoneyString` — pass `convertTo` to collapse to one\n * currency, or read the map at the boundary.)\n */\nexport function moneySum(field: string, opts?: ReducerOptions<number>): Reducer<MoneyString> {\n // The constructed reducer is the plain numeric `sum`; `wrapMoneyReducers`\n // swaps in the MoneyString-producing money reducer at aggregate() time.\n return sum(field, opts) as unknown as Reducer<MoneyString>\n}\n\n/**\n * `min()` for a declared money field, typed `Reducer<MoneyString | null>`\n * (null on an empty result set in fixed-currency mode, mirroring `min()`). See\n * {@link moneySum} for the late-binding rewrite. Note: `convertTo`/`fx` on\n * `opts` have no effect on min/max (cross-currency min/max is unsupported — use\n * {@link moneySum} for currency conversion). In multi-currency mode the runtime\n * returns a per-currency map and an empty result is `{}` rather than `null`.\n */\nexport function moneyMin(field: string, opts?: ReducerOptions<number>): Reducer<MoneyString | null> {\n return min(field, opts) as unknown as Reducer<MoneyString | null>\n}\n\n/**\n * `max()` for a declared money field, typed `Reducer<MoneyString | null>`\n * (null on an empty result set in fixed-currency mode, mirroring `max()`). See\n * {@link moneyMin} for the `convertTo`/`fx` and multi-currency caveats.\n */\nexport function moneyMax(field: string, opts?: ReducerOptions<number>): Reducer<MoneyString | null> {\n return max(field, opts) as unknown as Reducer<MoneyString | null>\n}\n\n// ---------------------------------------------------------------------------\n// Builder (typed spec-builder for aggregate())\n// ---------------------------------------------------------------------------\n\n/**\n * Typed builder passed to the `aggregate(b => spec)` overload.\n *\n * Each field-taking method narrows `field` to `QueryField<T, S>`, which\n * excludes any field listed in the collection's `sensitive` option at\n * compile time. `count()` carries no field argument and is always allowed.\n *\n * The type parameters match the `Query<T, S>` they come from:\n * - `T` — the record type of the collection\n * - `S` — the union of sensitive field keys (defaults to `never`)\n *\n * ONE shared runtime instance (`reducerBuilder`) serves all `T`/`S`\n * combinations — the field narrowing is type-only; the methods delegate\n * directly to the standalone factories.\n */\nexport interface ReducerBuilder<T, S extends keyof T = never, M extends keyof T & string = never> {\n count(opts?: ReducerOptions<number>): Reducer<number>\n sum<F extends QueryField<T, S>>(field: F, opts?: ReducerOptions<number>): [F] extends [M] ? Reducer<MoneyString> : Reducer<number>\n avg(field: QueryField<T, S>, opts?: ReducerOptions<{ sum: number; count: number }>): ReturnType<typeof avg>\n min<F extends QueryField<T, S>>(field: F, opts?: ReducerOptions<number>): [F] extends [M] ? Reducer<MoneyString | null> : ReturnType<typeof min>\n max<F extends QueryField<T, S>>(field: F, opts?: ReducerOptions<number>): [F] extends [M] ? Reducer<MoneyString | null> : ReturnType<typeof max>\n moneySum(field: QueryField<T, S>, opts?: ReducerOptions<number>): Reducer<MoneyString>\n moneyMin(field: QueryField<T, S>, opts?: ReducerOptions<number>): Reducer<MoneyString | null>\n moneyMax(field: QueryField<T, S>, opts?: ReducerOptions<number>): Reducer<MoneyString | null>\n}\n\n/**\n * Shared runtime instance for the `aggregate(b => spec)` builder form.\n *\n * The field-narrowing to `QueryField<T, S>` is type-only — each method\n * delegates directly to its standalone factory. A `(field: string) => R`\n * factory is assignable to a `(field: QueryField<T,S>) => R` method by\n * parameter-contravariance, so this single instance works for all `T`/`S`.\n */\nexport const reducerBuilder: ReducerBuilder<Record<string, unknown>> = {\n count,\n // The generic F parameter on sum/min/max in the interface is type-only; the\n // standalone factories are plain `(field: string)` functions. With M=never the\n // conditional return collapses to the numeric branch, matching the factories'\n // return type, but TypeScript cannot verify that collapse for a generic method\n // signature — so each factory is cast directly to the method's type.\n sum: sum as ReducerBuilder<Record<string, unknown>>['sum'],\n avg,\n min: min as ReducerBuilder<Record<string, unknown>>['min'],\n max: max as ReducerBuilder<Record<string, unknown>>['max'],\n moneySum, moneyMin, moneyMax,\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Read a numeric field from a record. Non-number values (null,\n * undefined, strings, objects) coerce to 0 so sum/avg/min/max don't\n * produce NaN on one bad row. Consumers who want strict typing should\n * validate upstream with Standard Schema, which NOYDB already runs on\n * every `put()`.\n */\nfunction readNumber(record: unknown, field: string): number {\n const value = readPath(record, field)\n // Defensive: a `{ amount, currency }` value means a multi-currency\n // money field reached a generic numeric reducer instead of being\n // rewritten by `wrapMoneyReducers` — that would silently produce a\n // wrong total. Surface it loudly rather than coercing to 0.\n if (\n typeof value === 'object' &&\n value !== null &&\n 'amount' in value &&\n 'currency' in value\n ) {\n throw new Error(\n `aggregate: field \"${field}\" holds a money value but was not money-aware — ` +\n `declare it in the collection's moneyFields so sum/min/max stay exact`,\n )\n }\n return typeof value === 'number' && Number.isFinite(value) ? value : 0\n}\n"],"mappings":"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","names":[]}
|