@noy-db/hub 0.3.0-pre.11 → 0.3.0-pre.12
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/aggregate/index.js +4 -4
- package/dist/api-3TH2GOFQ.js +20 -0
- package/dist/as/index.js +11 -11
- package/dist/attestation/index.js +18 -18
- package/dist/{backup-XA5STIYQ.js → backup-2WVBIVXW.js} +11 -11
- package/dist/blobs/index.js +10 -10
- package/dist/broker/index.js +12 -12
- package/dist/bundle/index.js +20 -20
- package/dist/by/index.js +2 -2
- package/dist/cargo/index.js +22 -22
- package/dist/{chunk-C3YH34IL.js → chunk-2MTRJCBI.js} +3 -3
- package/dist/{chunk-HUS3J5WM.js → chunk-37WOJQWY.js} +2 -2
- package/dist/{chunk-IP2QBAGS.js → chunk-3QSOFZQB.js} +8 -8
- package/dist/{chunk-IDIV5NVH.js → chunk-44IL5G3W.js} +5 -5
- package/dist/{chunk-X6CMGUAG.js → chunk-45QPICLE.js} +2 -2
- package/dist/{chunk-BEIRE5K4.js → chunk-4BQXMCE5.js} +4 -4
- package/dist/{chunk-ODJWBC5I.js → chunk-5HNX4OD4.js} +2 -2
- package/dist/{chunk-TPH5EO6L.js → chunk-65VLRG3I.js} +2 -2
- package/dist/{chunk-RKRGDAS7.js → chunk-6MA575R5.js} +5 -5
- package/dist/{chunk-3CNQ7FQ3.js → chunk-6S7ENMRE.js} +119 -25
- package/dist/chunk-6S7ENMRE.js.map +1 -0
- package/dist/{chunk-VA4ZWLFY.js → chunk-7GAXFU2O.js} +2 -2
- package/dist/{chunk-5JB73NMC.js → chunk-7QLY64AD.js} +5 -5
- package/dist/{chunk-GA2QHD6P.js → chunk-7ZOSHEVS.js} +9 -9
- package/dist/{chunk-H44ZE4IE.js → chunk-AAIIDAUC.js} +33 -17
- package/dist/chunk-AAIIDAUC.js.map +1 -0
- package/dist/{chunk-H6HM6CVR.js → chunk-AKEOHKMT.js} +10 -7
- package/dist/{chunk-H6HM6CVR.js.map → chunk-AKEOHKMT.js.map} +1 -1
- package/dist/{chunk-YSXEFGND.js → chunk-APHLCXVC.js} +2 -2
- package/dist/{chunk-CB25ONKC.js → chunk-BDEMZD4F.js} +2 -2
- package/dist/{chunk-P5RY4ZWD.js → chunk-BDPAVYGJ.js} +9 -9
- package/dist/{chunk-DIRRS7WP.js → chunk-BLUT46UP.js} +2 -2
- package/dist/{chunk-5ZOSG3RJ.js → chunk-CCIR2OJH.js} +5 -5
- package/dist/{chunk-7E67FJ33.js → chunk-CXC3JLAQ.js} +2 -2
- package/dist/{chunk-AOVDSIL3.js → chunk-CZMCOFEA.js} +6 -6
- package/dist/{chunk-SRVQHVNX.js → chunk-DIB2BOIH.js} +5 -5
- package/dist/{chunk-7QIXUSDQ.js → chunk-DJ7MRXNA.js} +15 -12
- package/dist/chunk-DJ7MRXNA.js.map +1 -0
- package/dist/{chunk-DJ3VKYFA.js → chunk-EHW5KTTA.js} +4 -4
- package/dist/{chunk-25NDNMQ7.js → chunk-EIZ4YOG2.js} +3 -3
- package/dist/{chunk-IGJHJYM6.js → chunk-EVHBK7BN.js} +4 -4
- package/dist/{chunk-7VSGW5KJ.js → chunk-EXGDL2UQ.js} +2 -2
- package/dist/{chunk-L2SNBIV7.js → chunk-F3LGBRSV.js} +9 -9
- package/dist/{chunk-ELNBMFOS.js → chunk-F44XWXOA.js} +4 -4
- package/dist/{chunk-KPGX66PM.js → chunk-FF7S3XDW.js} +2 -2
- package/dist/{chunk-5XIPOCQC.js → chunk-FJTWLQV3.js} +3 -3
- package/dist/{chunk-YXOUQ2H7.js → chunk-FYNE4WLC.js} +2 -2
- package/dist/{chunk-FH542DDY.js → chunk-FZCGIJEJ.js} +1 -1
- package/dist/{chunk-FH542DDY.js.map → chunk-FZCGIJEJ.js.map} +1 -1
- package/dist/{chunk-57V5S7PW.js → chunk-GL3JV5EV.js} +6 -6
- package/dist/{chunk-ARSAMO24.js → chunk-GXLZXD2W.js} +2 -2
- package/dist/{chunk-QQJXBZCO.js → chunk-HA6ZQWA2.js} +8 -8
- package/dist/{chunk-OEAATWH5.js → chunk-HBBZWEC5.js} +6 -6
- package/dist/{chunk-2JMMY7HZ.js → chunk-HG76BZ6G.js} +6 -6
- package/dist/{chunk-45ZZLTFH.js → chunk-HGAB325C.js} +2 -2
- package/dist/{chunk-WTUNZACT.js → chunk-HIOLCOK3.js} +2 -2
- package/dist/{chunk-C7NTK5I3.js → chunk-HK4XTXO4.js} +4 -4
- package/dist/{chunk-UFILRICG.js → chunk-HYG32HCM.js} +2 -2
- package/dist/{chunk-PXWVF7MC.js → chunk-ILF5GARW.js} +7 -7
- package/dist/{chunk-HFJIGWJC.js → chunk-INBQ43DI.js} +3 -3
- package/dist/{chunk-DMFNPHCX.js → chunk-IQIVD7TP.js} +6 -6
- package/dist/{chunk-FQQF23MC.js → chunk-J3JIYFYL.js} +2 -2
- package/dist/{chunk-CKZW6P5V.js → chunk-JC75UBMT.js} +1 -1
- package/dist/chunk-JC75UBMT.js.map +1 -0
- package/dist/{chunk-4N5QFSNQ.js → chunk-JGUZMC3I.js} +5 -5
- package/dist/{chunk-ZP5PL65C.js → chunk-JRKE5MAZ.js} +2 -2
- package/dist/{chunk-JOQ53DMI.js → chunk-K2DLLK34.js} +3 -3
- package/dist/{chunk-4R4Q64W5.js → chunk-KKYEZCQG.js} +2 -2
- package/dist/{chunk-D26JB3LZ.js → chunk-NAR6IDKH.js} +2 -2
- package/dist/{chunk-7NS43EXZ.js → chunk-NEYKOESM.js} +5 -5
- package/dist/{chunk-SYMS4546.js → chunk-NM3IFKBL.js} +2 -2
- package/dist/{chunk-OOLO4LQG.js → chunk-NRYNRSGV.js} +6 -6
- package/dist/{chunk-D3EFFFOL.js → chunk-NT2ZO4KI.js} +5 -5
- package/dist/{chunk-QLLKLFE2.js → chunk-P2LJI6JE.js} +2 -2
- package/dist/{chunk-K62IUKOD.js → chunk-PH7G7ZI7.js} +5 -5
- package/dist/{chunk-A2Y6YFVN.js → chunk-PN5332SU.js} +2 -2
- package/dist/{chunk-BCYQA5BK.js → chunk-QF5LGMSV.js} +2 -2
- package/dist/{chunk-VR24ILCR.js → chunk-QG5RQQBO.js} +3 -3
- package/dist/{chunk-O2DYPAZY.js → chunk-QYPDYN23.js} +2 -2
- package/dist/{chunk-DGH65E7Q.js → chunk-R3NHNVS5.js} +16 -4
- package/dist/chunk-R3NHNVS5.js.map +1 -0
- package/dist/{chunk-MELR46EF.js → chunk-RNXJ2VO6.js} +5 -5
- package/dist/{chunk-UTLEAJXC.js → chunk-RXTMLYJS.js} +2 -2
- package/dist/{chunk-XHV25KBM.js → chunk-S2OWPVSO.js} +2 -2
- package/dist/{chunk-6QILBDZU.js → chunk-S7TAPIRS.js} +3 -3
- package/dist/{chunk-Q3XSMOZM.js → chunk-SAL5X5OK.js} +2 -2
- package/dist/{chunk-XFXUTFWQ.js → chunk-SGJGWBSC.js} +6 -6
- package/dist/{chunk-7ITPJFGC.js → chunk-SIAIYP6G.js} +2 -2
- package/dist/{chunk-H6CZSDWK.js → chunk-SXPCZ6LL.js} +3 -3
- package/dist/{chunk-H6CZSDWK.js.map → chunk-SXPCZ6LL.js.map} +1 -1
- package/dist/{chunk-QYPKGVT4.js → chunk-TBNF5DV5.js} +3 -3
- package/dist/{chunk-CIKY6I4W.js → chunk-TVOHSPVK.js} +2 -2
- package/dist/{chunk-AWB5JZW6.js → chunk-TVS6BUUR.js} +2 -2
- package/dist/{chunk-BZO4WCJI.js → chunk-UMC5QZTX.js} +4 -4
- package/dist/{chunk-MCEKIAO4.js → chunk-US34HTOI.js} +3 -3
- package/dist/{chunk-BE7N3AXA.js → chunk-VCUQR6ZL.js} +3 -3
- package/dist/{chunk-W5D62AQD.js → chunk-VXZNSPJM.js} +20 -7
- package/dist/chunk-VXZNSPJM.js.map +1 -0
- package/dist/{chunk-OFJ5GPNA.js → chunk-WEHIQYQH.js} +2 -2
- package/dist/{chunk-PR5LC5YX.js → chunk-WHQHTNT7.js} +4 -4
- package/dist/{chunk-3MSQLQNZ.js → chunk-X6Y5MXTH.js} +2 -2
- package/dist/{chunk-3G4KMVUN.js → chunk-XJ47GS53.js} +3 -3
- package/dist/{chunk-MSPNM2OM.js → chunk-XS6DLN67.js} +3 -3
- package/dist/{chunk-FXK4X4BL.js → chunk-Y5TWPBNW.js} +4 -4
- package/dist/{chunk-A2QF4JUE.js → chunk-YCXKFB7J.js} +208 -100
- package/dist/chunk-YCXKFB7J.js.map +1 -0
- package/dist/{chunk-67TNU77I.js → chunk-ZHOJOT6S.js} +2 -2
- package/dist/{chunk-WGV4CUZT.js → chunk-ZL6PRULX.js} +4 -4
- package/dist/{chunk-WGV4CUZT.js.map → chunk-ZL6PRULX.js.map} +1 -1
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-LQWWQNIJ.js → classified-marker-M7K3OJPM.js} +8 -4
- package/dist/classified-marker-M7K3OJPM.js.map +1 -0
- package/dist/collection-facade-DWA735G2.js +39 -0
- package/dist/{computed-W6MVAMWZ.js → computed-ORCGM5JE.js} +3 -3
- package/dist/consent/index.js +9 -9
- package/dist/{dead-filter-4KXZEB3X.js → dead-filter-OV5FGKOG.js} +2 -2
- package/dist/delegation-YVSHMIZZ.js +25 -0
- package/dist/derivations/index.js +12 -12
- package/dist/derive-BUO555L5.js +21 -0
- package/dist/{enclave-VXAQD4XJ.js → enclave-XXFUKJC6.js} +9 -9
- package/dist/executor-6OCCE5VM.js +25 -0
- package/dist/executor-JFVAJY42.js +9 -0
- package/dist/executor-UPSH5O3F.js +9 -0
- package/dist/export-accessible-L4A2QZA5.js +23 -0
- package/dist/extract-partition-ZHQ4RGGM.js +36 -0
- package/dist/{fanout-sidecar-CKYFH33E.js → fanout-sidecar-IO2KDUWV.js} +9 -9
- package/dist/find-ZFZDZQ2U.js +11 -0
- package/dist/forget/index.js +9 -9
- package/dist/guards/index.js +3 -3
- package/dist/history/index.js +11 -11
- package/dist/i18n/index.js +14 -14
- package/dist/index.js +84 -84
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +5 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-OG4V23SQ.js +19 -0
- package/dist/kernel/best-effort-revert.d.ts +52 -0
- package/dist/kernel/collection-config.d.ts +8 -0
- package/dist/kernel/collection.d.ts +18 -4
- package/dist/kernel/errors.d.ts +1 -1
- package/dist/kernel/noydb.d.ts +8 -0
- package/dist/kernel/types.d.ts +19 -0
- package/dist/kernel/vault.d.ts +15 -1
- package/dist/kernel/via/graph.d.ts +2 -1
- package/dist/{ledger-FU6GH5EH.js → ledger-UAQKPWNM.js} +11 -11
- package/dist/liberate-GFUQJRK5.js +24 -0
- package/dist/{link-set-MNADSH5M.js → link-set-DGYUOFVD.js} +11 -11
- package/dist/materialized-views/index.js +18 -18
- package/dist/noydb-AKH4AMCR.js +67 -0
- package/dist/on/index.js +9 -9
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +12 -12
- package/dist/pod/index.js +11 -11
- package/dist/{policy-JTFOPPUU.js → policy-5POYLI26.js} +5 -5
- package/dist/port/with/lookup-strategy.d.ts +2 -1
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-HAWO3O7O.js → post-register-LB3P4XQU.js} +12 -7
- package/dist/post-register-LB3P4XQU.js.map +1 -0
- package/dist/{public-envelope-NJVB7LPA.js → public-envelope-GOG4LUM7.js} +4 -4
- package/dist/query/index.js +5 -5
- package/dist/register-ZI7YI7US.js +23 -0
- package/dist/registry-DZ2T4LL7.js +9 -0
- package/dist/registry-NVWEQ2GU.js +18 -0
- package/dist/registry-SEKL74ET.js +19 -0
- package/dist/request-withdrawal-ZP3JIRVS.js +31 -0
- package/dist/{reveal-BOY7XYFH.js → reveal-NPVROV4D.js} +6 -6
- package/dist/revoke-VF6TAJK2.js +24 -0
- package/dist/satellites/index.js +1 -1
- package/dist/sealed-record/index.js +12 -12
- package/dist/{seed-4RRXT42N.js → seed-VI4FU7UH.js} +11 -11
- package/dist/session/index.js +9 -9
- package/dist/shadow/index.js +2 -2
- package/dist/signer-DRDDCCHW.js +25 -0
- package/dist/snapshots/index.js +10 -10
- package/dist/{stale-NXPT56JA.js → stale-TJXFQKOJ.js} +2 -2
- package/dist/storage-GR7KZRH4.js +23 -0
- package/dist/{store-coordination-provider-HPYVFJCV.js → store-coordination-provider-5KDS2RRP.js} +3 -3
- package/dist/sync/index.js +9 -9
- package/dist/team/index.js +15 -15
- package/dist/tiers/index.js +10 -10
- package/dist/to/index.js +1 -1
- package/dist/tx/index.js +3 -3
- package/dist/util/index.js +1 -1
- package/dist/{verify-66RHOW7N.js → verify-QK76NJ4G.js} +5 -5
- package/dist/via/lookup/registry.d.ts +9 -0
- package/dist/via/money/where.d.ts +27 -6
- package/dist/{walk-2RWEOCAS.js → walk-XQCBKSBW.js} +11 -11
- package/dist/with/index.js +11 -11
- package/dist/with-commit/tx/transaction.d.ts +5 -0
- package/dist/with-lookup/indexing/lazy-builder.d.ts +35 -2
- package/dist/with-lookup/indexing/persisted-indexes.d.ts +44 -1
- package/dist/with-party/team/sync.d.ts +9 -0
- package/dist/with-shape/satellites/fanout.d.ts +5 -4
- package/dist/with-shape/satellites/migrate-cek.d.ts +26 -0
- package/dist/with-shape/satellites/types.d.ts +11 -0
- package/dist/withdraw-accessible-FMN4LPJZ.js +28 -0
- package/package.json +3 -3
- package/dist/api-YGMINAET.js +0 -20
- package/dist/chunk-3CNQ7FQ3.js.map +0 -1
- package/dist/chunk-7QIXUSDQ.js.map +0 -1
- package/dist/chunk-A2QF4JUE.js.map +0 -1
- package/dist/chunk-CKZW6P5V.js.map +0 -1
- package/dist/chunk-DGH65E7Q.js.map +0 -1
- package/dist/chunk-H44ZE4IE.js.map +0 -1
- package/dist/chunk-W5D62AQD.js.map +0 -1
- package/dist/classified-marker-LQWWQNIJ.js.map +0 -1
- package/dist/collection-facade-YE2O4J4O.js +0 -39
- package/dist/delegation-OPUU3R2E.js +0 -25
- package/dist/derive-BGUHU663.js +0 -21
- package/dist/executor-GTVSUUBX.js +0 -25
- package/dist/executor-GZWMTOXB.js +0 -9
- package/dist/executor-XXGS4S3K.js +0 -9
- package/dist/export-accessible-BMULIOYB.js +0 -23
- package/dist/extract-partition-JUQTWDXR.js +0 -36
- package/dist/find-XRGCNGNN.js +0 -11
- package/dist/issue-UB6AA5M6.js +0 -19
- package/dist/liberate-YUN7W5QG.js +0 -24
- package/dist/noydb-6JLBZU4U.js +0 -67
- package/dist/post-register-HAWO3O7O.js.map +0 -1
- package/dist/register-VCKOBWKT.js +0 -23
- package/dist/registry-72UKJ2L4.js +0 -9
- package/dist/registry-BZFLJNEH.js +0 -18
- package/dist/registry-YJEYSYI5.js +0 -19
- package/dist/request-withdrawal-6MJRMFHF.js +0 -31
- package/dist/revoke-4KUNSVJC.js +0 -24
- package/dist/signer-DDDXP5JD.js +0 -25
- package/dist/storage-IR6EEAV2.js +0 -23
- package/dist/withdraw-accessible-CLMZEHQT.js +0 -28
- /package/dist/{api-YGMINAET.js.map → api-3TH2GOFQ.js.map} +0 -0
- /package/dist/{backup-XA5STIYQ.js.map → backup-2WVBIVXW.js.map} +0 -0
- /package/dist/{chunk-C3YH34IL.js.map → chunk-2MTRJCBI.js.map} +0 -0
- /package/dist/{chunk-HUS3J5WM.js.map → chunk-37WOJQWY.js.map} +0 -0
- /package/dist/{chunk-IP2QBAGS.js.map → chunk-3QSOFZQB.js.map} +0 -0
- /package/dist/{chunk-IDIV5NVH.js.map → chunk-44IL5G3W.js.map} +0 -0
- /package/dist/{chunk-X6CMGUAG.js.map → chunk-45QPICLE.js.map} +0 -0
- /package/dist/{chunk-BEIRE5K4.js.map → chunk-4BQXMCE5.js.map} +0 -0
- /package/dist/{chunk-ODJWBC5I.js.map → chunk-5HNX4OD4.js.map} +0 -0
- /package/dist/{chunk-TPH5EO6L.js.map → chunk-65VLRG3I.js.map} +0 -0
- /package/dist/{chunk-RKRGDAS7.js.map → chunk-6MA575R5.js.map} +0 -0
- /package/dist/{chunk-VA4ZWLFY.js.map → chunk-7GAXFU2O.js.map} +0 -0
- /package/dist/{chunk-5JB73NMC.js.map → chunk-7QLY64AD.js.map} +0 -0
- /package/dist/{chunk-GA2QHD6P.js.map → chunk-7ZOSHEVS.js.map} +0 -0
- /package/dist/{chunk-YSXEFGND.js.map → chunk-APHLCXVC.js.map} +0 -0
- /package/dist/{chunk-CB25ONKC.js.map → chunk-BDEMZD4F.js.map} +0 -0
- /package/dist/{chunk-P5RY4ZWD.js.map → chunk-BDPAVYGJ.js.map} +0 -0
- /package/dist/{chunk-DIRRS7WP.js.map → chunk-BLUT46UP.js.map} +0 -0
- /package/dist/{chunk-5ZOSG3RJ.js.map → chunk-CCIR2OJH.js.map} +0 -0
- /package/dist/{chunk-7E67FJ33.js.map → chunk-CXC3JLAQ.js.map} +0 -0
- /package/dist/{chunk-AOVDSIL3.js.map → chunk-CZMCOFEA.js.map} +0 -0
- /package/dist/{chunk-SRVQHVNX.js.map → chunk-DIB2BOIH.js.map} +0 -0
- /package/dist/{chunk-DJ3VKYFA.js.map → chunk-EHW5KTTA.js.map} +0 -0
- /package/dist/{chunk-25NDNMQ7.js.map → chunk-EIZ4YOG2.js.map} +0 -0
- /package/dist/{chunk-IGJHJYM6.js.map → chunk-EVHBK7BN.js.map} +0 -0
- /package/dist/{chunk-7VSGW5KJ.js.map → chunk-EXGDL2UQ.js.map} +0 -0
- /package/dist/{chunk-L2SNBIV7.js.map → chunk-F3LGBRSV.js.map} +0 -0
- /package/dist/{chunk-ELNBMFOS.js.map → chunk-F44XWXOA.js.map} +0 -0
- /package/dist/{chunk-KPGX66PM.js.map → chunk-FF7S3XDW.js.map} +0 -0
- /package/dist/{chunk-5XIPOCQC.js.map → chunk-FJTWLQV3.js.map} +0 -0
- /package/dist/{chunk-YXOUQ2H7.js.map → chunk-FYNE4WLC.js.map} +0 -0
- /package/dist/{chunk-57V5S7PW.js.map → chunk-GL3JV5EV.js.map} +0 -0
- /package/dist/{chunk-ARSAMO24.js.map → chunk-GXLZXD2W.js.map} +0 -0
- /package/dist/{chunk-QQJXBZCO.js.map → chunk-HA6ZQWA2.js.map} +0 -0
- /package/dist/{chunk-OEAATWH5.js.map → chunk-HBBZWEC5.js.map} +0 -0
- /package/dist/{chunk-2JMMY7HZ.js.map → chunk-HG76BZ6G.js.map} +0 -0
- /package/dist/{chunk-45ZZLTFH.js.map → chunk-HGAB325C.js.map} +0 -0
- /package/dist/{chunk-WTUNZACT.js.map → chunk-HIOLCOK3.js.map} +0 -0
- /package/dist/{chunk-C7NTK5I3.js.map → chunk-HK4XTXO4.js.map} +0 -0
- /package/dist/{chunk-UFILRICG.js.map → chunk-HYG32HCM.js.map} +0 -0
- /package/dist/{chunk-PXWVF7MC.js.map → chunk-ILF5GARW.js.map} +0 -0
- /package/dist/{chunk-HFJIGWJC.js.map → chunk-INBQ43DI.js.map} +0 -0
- /package/dist/{chunk-DMFNPHCX.js.map → chunk-IQIVD7TP.js.map} +0 -0
- /package/dist/{chunk-FQQF23MC.js.map → chunk-J3JIYFYL.js.map} +0 -0
- /package/dist/{chunk-4N5QFSNQ.js.map → chunk-JGUZMC3I.js.map} +0 -0
- /package/dist/{chunk-ZP5PL65C.js.map → chunk-JRKE5MAZ.js.map} +0 -0
- /package/dist/{chunk-JOQ53DMI.js.map → chunk-K2DLLK34.js.map} +0 -0
- /package/dist/{chunk-4R4Q64W5.js.map → chunk-KKYEZCQG.js.map} +0 -0
- /package/dist/{chunk-D26JB3LZ.js.map → chunk-NAR6IDKH.js.map} +0 -0
- /package/dist/{chunk-7NS43EXZ.js.map → chunk-NEYKOESM.js.map} +0 -0
- /package/dist/{chunk-SYMS4546.js.map → chunk-NM3IFKBL.js.map} +0 -0
- /package/dist/{chunk-OOLO4LQG.js.map → chunk-NRYNRSGV.js.map} +0 -0
- /package/dist/{chunk-D3EFFFOL.js.map → chunk-NT2ZO4KI.js.map} +0 -0
- /package/dist/{chunk-QLLKLFE2.js.map → chunk-P2LJI6JE.js.map} +0 -0
- /package/dist/{chunk-K62IUKOD.js.map → chunk-PH7G7ZI7.js.map} +0 -0
- /package/dist/{chunk-A2Y6YFVN.js.map → chunk-PN5332SU.js.map} +0 -0
- /package/dist/{chunk-BCYQA5BK.js.map → chunk-QF5LGMSV.js.map} +0 -0
- /package/dist/{chunk-VR24ILCR.js.map → chunk-QG5RQQBO.js.map} +0 -0
- /package/dist/{chunk-O2DYPAZY.js.map → chunk-QYPDYN23.js.map} +0 -0
- /package/dist/{chunk-MELR46EF.js.map → chunk-RNXJ2VO6.js.map} +0 -0
- /package/dist/{chunk-UTLEAJXC.js.map → chunk-RXTMLYJS.js.map} +0 -0
- /package/dist/{chunk-XHV25KBM.js.map → chunk-S2OWPVSO.js.map} +0 -0
- /package/dist/{chunk-6QILBDZU.js.map → chunk-S7TAPIRS.js.map} +0 -0
- /package/dist/{chunk-Q3XSMOZM.js.map → chunk-SAL5X5OK.js.map} +0 -0
- /package/dist/{chunk-XFXUTFWQ.js.map → chunk-SGJGWBSC.js.map} +0 -0
- /package/dist/{chunk-7ITPJFGC.js.map → chunk-SIAIYP6G.js.map} +0 -0
- /package/dist/{chunk-QYPKGVT4.js.map → chunk-TBNF5DV5.js.map} +0 -0
- /package/dist/{chunk-CIKY6I4W.js.map → chunk-TVOHSPVK.js.map} +0 -0
- /package/dist/{chunk-AWB5JZW6.js.map → chunk-TVS6BUUR.js.map} +0 -0
- /package/dist/{chunk-BZO4WCJI.js.map → chunk-UMC5QZTX.js.map} +0 -0
- /package/dist/{chunk-MCEKIAO4.js.map → chunk-US34HTOI.js.map} +0 -0
- /package/dist/{chunk-BE7N3AXA.js.map → chunk-VCUQR6ZL.js.map} +0 -0
- /package/dist/{chunk-OFJ5GPNA.js.map → chunk-WEHIQYQH.js.map} +0 -0
- /package/dist/{chunk-PR5LC5YX.js.map → chunk-WHQHTNT7.js.map} +0 -0
- /package/dist/{chunk-3MSQLQNZ.js.map → chunk-X6Y5MXTH.js.map} +0 -0
- /package/dist/{chunk-3G4KMVUN.js.map → chunk-XJ47GS53.js.map} +0 -0
- /package/dist/{chunk-MSPNM2OM.js.map → chunk-XS6DLN67.js.map} +0 -0
- /package/dist/{chunk-FXK4X4BL.js.map → chunk-Y5TWPBNW.js.map} +0 -0
- /package/dist/{chunk-67TNU77I.js.map → chunk-ZHOJOT6S.js.map} +0 -0
- /package/dist/{collection-facade-YE2O4J4O.js.map → collection-facade-DWA735G2.js.map} +0 -0
- /package/dist/{computed-W6MVAMWZ.js.map → computed-ORCGM5JE.js.map} +0 -0
- /package/dist/{dead-filter-4KXZEB3X.js.map → dead-filter-OV5FGKOG.js.map} +0 -0
- /package/dist/{delegation-OPUU3R2E.js.map → delegation-YVSHMIZZ.js.map} +0 -0
- /package/dist/{derive-BGUHU663.js.map → derive-BUO555L5.js.map} +0 -0
- /package/dist/{enclave-VXAQD4XJ.js.map → enclave-XXFUKJC6.js.map} +0 -0
- /package/dist/{executor-GTVSUUBX.js.map → executor-6OCCE5VM.js.map} +0 -0
- /package/dist/{executor-GZWMTOXB.js.map → executor-JFVAJY42.js.map} +0 -0
- /package/dist/{executor-XXGS4S3K.js.map → executor-UPSH5O3F.js.map} +0 -0
- /package/dist/{export-accessible-BMULIOYB.js.map → export-accessible-L4A2QZA5.js.map} +0 -0
- /package/dist/{extract-partition-JUQTWDXR.js.map → extract-partition-ZHQ4RGGM.js.map} +0 -0
- /package/dist/{fanout-sidecar-CKYFH33E.js.map → fanout-sidecar-IO2KDUWV.js.map} +0 -0
- /package/dist/{find-XRGCNGNN.js.map → find-ZFZDZQ2U.js.map} +0 -0
- /package/dist/{issue-UB6AA5M6.js.map → issue-OG4V23SQ.js.map} +0 -0
- /package/dist/{ledger-FU6GH5EH.js.map → ledger-UAQKPWNM.js.map} +0 -0
- /package/dist/{liberate-YUN7W5QG.js.map → liberate-GFUQJRK5.js.map} +0 -0
- /package/dist/{link-set-MNADSH5M.js.map → link-set-DGYUOFVD.js.map} +0 -0
- /package/dist/{noydb-6JLBZU4U.js.map → noydb-AKH4AMCR.js.map} +0 -0
- /package/dist/{policy-JTFOPPUU.js.map → policy-5POYLI26.js.map} +0 -0
- /package/dist/{public-envelope-NJVB7LPA.js.map → public-envelope-GOG4LUM7.js.map} +0 -0
- /package/dist/{register-VCKOBWKT.js.map → register-ZI7YI7US.js.map} +0 -0
- /package/dist/{registry-72UKJ2L4.js.map → registry-DZ2T4LL7.js.map} +0 -0
- /package/dist/{registry-BZFLJNEH.js.map → registry-NVWEQ2GU.js.map} +0 -0
- /package/dist/{registry-YJEYSYI5.js.map → registry-SEKL74ET.js.map} +0 -0
- /package/dist/{request-withdrawal-6MJRMFHF.js.map → request-withdrawal-ZP3JIRVS.js.map} +0 -0
- /package/dist/{reveal-BOY7XYFH.js.map → reveal-NPVROV4D.js.map} +0 -0
- /package/dist/{revoke-4KUNSVJC.js.map → revoke-VF6TAJK2.js.map} +0 -0
- /package/dist/{seed-4RRXT42N.js.map → seed-VI4FU7UH.js.map} +0 -0
- /package/dist/{signer-DDDXP5JD.js.map → signer-DRDDCCHW.js.map} +0 -0
- /package/dist/{stale-NXPT56JA.js.map → stale-TJXFQKOJ.js.map} +0 -0
- /package/dist/{storage-IR6EEAV2.js.map → storage-GR7KZRH4.js.map} +0 -0
- /package/dist/{store-coordination-provider-HPYVFJCV.js.map → store-coordination-provider-5KDS2RRP.js.map} +0 -0
- /package/dist/{verify-66RHOW7N.js.map → verify-QK76NJ4G.js.map} +0 -0
- /package/dist/{walk-2RWEOCAS.js.map → walk-XQCBKSBW.js.map} +0 -0
- /package/dist/{withdraw-accessible-CLMZEHQT.js.map → withdraw-accessible-FMN4LPJZ.js.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ATTESTATIONS_COLLECTION,
|
|
3
3
|
loadOrCreateSigner
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NT2ZO4KI.js";
|
|
5
5
|
import {
|
|
6
6
|
generateULID
|
|
7
7
|
} from "./chunk-ZJADGNYF.js";
|
|
8
8
|
import {
|
|
9
9
|
encrypt
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-37WOJQWY.js";
|
|
11
11
|
import {
|
|
12
12
|
NOYDB_FORMAT_VERSION
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JC75UBMT.js";
|
|
14
14
|
import {
|
|
15
15
|
AttestationError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
17
17
|
|
|
18
18
|
// src/with-audit/attestation/issue.ts
|
|
19
19
|
import {
|
|
@@ -56,4 +56,4 @@ async function issueAttestationCore(ctx, args) {
|
|
|
56
56
|
export {
|
|
57
57
|
issueAttestationCore
|
|
58
58
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-6MA575R5.js.map
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
readPath
|
|
4
4
|
} from "./chunk-IGJCYUT5.js";
|
|
5
5
|
import {
|
|
6
|
+
FieldNotQueryableError,
|
|
6
7
|
IndexRequiredError
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
8
9
|
|
|
9
10
|
// src/with-lookup/indexing/persisted-indexes.ts
|
|
10
11
|
var IDX_PREFIX = "_idx/";
|
|
@@ -31,6 +32,25 @@ function compositeKey(fields) {
|
|
|
31
32
|
var PersistedCollectionIndex = class {
|
|
32
33
|
indexes = /* @__PURE__ */ new Map();
|
|
33
34
|
defs = /* @__PURE__ */ new Map();
|
|
35
|
+
/**
|
|
36
|
+
* Per-field bucket-key canonicalizer (#677 — lazy twin of #672's
|
|
37
|
+
* `CollectionIndexes.setCanonicalizer`), registered ONCE via
|
|
38
|
+
* {@link setCanonicalizer} when the collection wires indexing up
|
|
39
|
+
* (money-aware via `ViaPipeline.canonicalizeIndexKey`). Consulted by
|
|
40
|
+
* EVERY bucket-mutation site — `ingest`/`upsert`/`remove` — so bucket
|
|
41
|
+
* membership is symmetric: a legacy non-canonical stored value (e.g.
|
|
42
|
+
* `'0100'`) and a canonical one (`'100'`) land in the SAME bucket,
|
|
43
|
+
* mirroring `eager-indexes.ts`'s `addToIndex`/`removeFromIndex`.
|
|
44
|
+
*/
|
|
45
|
+
canonicalize;
|
|
46
|
+
/**
|
|
47
|
+
* Register the bucket-key canonicalizer. Called once, where the
|
|
48
|
+
* collection constructs its indexing state — safe to call again (the
|
|
49
|
+
* closure is simply replaced) but there is normally only one caller.
|
|
50
|
+
*/
|
|
51
|
+
setCanonicalizer(fn) {
|
|
52
|
+
this.canonicalize = fn;
|
|
53
|
+
}
|
|
34
54
|
/**
|
|
35
55
|
* Declare a single-field index. Subsequent `upsert` / `ingest` calls
|
|
36
56
|
* populate the in-memory mirror; calls before `declare` are no-ops
|
|
@@ -91,7 +111,7 @@ var PersistedCollectionIndex = class {
|
|
|
91
111
|
const state = this.indexes.get(field);
|
|
92
112
|
if (!state) return;
|
|
93
113
|
for (const row of rows) {
|
|
94
|
-
addToState(state, row.recordId, row.value);
|
|
114
|
+
addToState(state, row.recordId, row.value, field, this.canonicalize);
|
|
95
115
|
}
|
|
96
116
|
}
|
|
97
117
|
/**
|
|
@@ -105,9 +125,9 @@ var PersistedCollectionIndex = class {
|
|
|
105
125
|
const state = this.indexes.get(field);
|
|
106
126
|
if (!state) return;
|
|
107
127
|
if (previousValue !== null && previousValue !== void 0) {
|
|
108
|
-
removeFromState(state, recordId, previousValue);
|
|
128
|
+
removeFromState(state, recordId, previousValue, field, this.canonicalize);
|
|
109
129
|
}
|
|
110
|
-
addToState(state, recordId, newValue);
|
|
130
|
+
addToState(state, recordId, newValue, field, this.canonicalize);
|
|
111
131
|
}
|
|
112
132
|
/**
|
|
113
133
|
* Remove a record from the index for one field. Called by
|
|
@@ -118,7 +138,7 @@ var PersistedCollectionIndex = class {
|
|
|
118
138
|
remove(recordId, field, value) {
|
|
119
139
|
const state = this.indexes.get(field);
|
|
120
140
|
if (!state) return;
|
|
121
|
-
removeFromState(state, recordId, value);
|
|
141
|
+
removeFromState(state, recordId, value, field, this.canonicalize);
|
|
122
142
|
}
|
|
123
143
|
/**
|
|
124
144
|
* Drop all bucket data while preserving field declarations. Called on
|
|
@@ -137,6 +157,14 @@ var PersistedCollectionIndex = class {
|
|
|
137
157
|
* back to scan or throws `IndexRequiredError`). Returns a shared empty
|
|
138
158
|
* set if the field is declared but no record matches — that set MUST
|
|
139
159
|
* NOT be mutated by the caller.
|
|
160
|
+
*
|
|
161
|
+
* `value` is bucketed via the plain {@link stringifyKey} — it is NOT
|
|
162
|
+
* canonicalized here. Callers on a Via-covered field (money) canonicalize
|
|
163
|
+
* `value` themselves BEFORE calling (see `lazy-builder.ts`'s
|
|
164
|
+
* `resolveCandidateIds()`, #677) — the SAME caller-canonicalizes split
|
|
165
|
+
* `eager-indexes.ts`'s `lookupEqual`/`lookupIn` use (see `kernel/query/
|
|
166
|
+
* builder.ts`'s `candidateRecords()`), so probing here twice never
|
|
167
|
+
* double-canonicalizes.
|
|
140
168
|
*/
|
|
141
169
|
lookupEqual(field, value) {
|
|
142
170
|
const state = this.indexes.get(field);
|
|
@@ -147,7 +175,8 @@ var PersistedCollectionIndex = class {
|
|
|
147
175
|
/**
|
|
148
176
|
* Set lookup — return the union of record ids whose `field` matches any
|
|
149
177
|
* of `values`. Returns `null` if the field is not declared. Returns a
|
|
150
|
-
* fresh (non-shared) Set — safe for the caller to mutate.
|
|
178
|
+
* fresh (non-shared) Set — safe for the caller to mutate. Same
|
|
179
|
+
* caller-canonicalizes contract as {@link lookupEqual} (#677).
|
|
151
180
|
*/
|
|
152
181
|
lookupIn(field, values) {
|
|
153
182
|
const state = this.indexes.get(field);
|
|
@@ -169,6 +198,23 @@ var PersistedCollectionIndex = class {
|
|
|
169
198
|
* Supported ops: `'<'`, `'<='`, `'>'`, `'>='`, `'between'`. For
|
|
170
199
|
* `'between'`, `value` is `[lo, hi]` and both bounds are inclusive
|
|
171
200
|
* (matches the eager-mode operator contract in `predicate.ts`).
|
|
201
|
+
*
|
|
202
|
+
* NOT canonicalized (#677): this method compares `value` against the
|
|
203
|
+
* ORIGINAL TYPED `state.values`, not a stringified bucket key, so a
|
|
204
|
+
* `canonicalizeIndexKey`-shaped (`string | undefined`) result would not
|
|
205
|
+
* even type-check as a bound here. This does NOT mirror eager mode the
|
|
206
|
+
* way `lookupEqual`/`lookupIn` do: `moneyIndexProbe` (`via/money/
|
|
207
|
+
* where.ts`) never emits a range probe, so EAGER mode's `candidateRecords`
|
|
208
|
+
* never calls an index for a range clause and always scans.
|
|
209
|
+
*
|
|
210
|
+
* LAZY mode's `resolveCandidateIds()` (`lazy-builder.ts`) no longer
|
|
211
|
+
* dispatches a Via-covered (e.g. money) range clause through THIS method
|
|
212
|
+
* at all (#684) — it enumerates the field's indexed ids via `orderedBy()`
|
|
213
|
+
* instead and leaves the raw/typed comparison here for the (now
|
|
214
|
+
* Via-aware) post-filter to redo correctly in scaled-int space. A
|
|
215
|
+
* NON-via range clause still dispatches through this method exactly as
|
|
216
|
+
* before — the raw/typed comparison here is correct and sufficient for
|
|
217
|
+
* fields with no decode-transforming Via binding.
|
|
172
218
|
*/
|
|
173
219
|
lookupRange(field, op, value) {
|
|
174
220
|
const state = this.indexes.get(field);
|
|
@@ -211,9 +257,9 @@ function stringifyKey(value) {
|
|
|
211
257
|
}
|
|
212
258
|
return "\0OBJECT\0";
|
|
213
259
|
}
|
|
214
|
-
function addToState(state, recordId, value) {
|
|
260
|
+
function addToState(state, recordId, value, field, canonicalize) {
|
|
215
261
|
if (value === null || value === void 0) return;
|
|
216
|
-
const key = stringifyKey(value);
|
|
262
|
+
const key = canonicalize?.(field, value) ?? stringifyKey(value);
|
|
217
263
|
let bucket = state.buckets.get(key);
|
|
218
264
|
if (!bucket) {
|
|
219
265
|
bucket = /* @__PURE__ */ new Set();
|
|
@@ -222,9 +268,9 @@ function addToState(state, recordId, value) {
|
|
|
222
268
|
bucket.add(recordId);
|
|
223
269
|
state.values.set(recordId, value);
|
|
224
270
|
}
|
|
225
|
-
function removeFromState(state, recordId, value) {
|
|
271
|
+
function removeFromState(state, recordId, value, field, canonicalize) {
|
|
226
272
|
if (value === null || value === void 0) return;
|
|
227
|
-
const key = stringifyKey(value);
|
|
273
|
+
const key = canonicalize?.(field, value) ?? stringifyKey(value);
|
|
228
274
|
const bucket = state.buckets.get(key);
|
|
229
275
|
if (bucket) {
|
|
230
276
|
bucket.delete(recordId);
|
|
@@ -276,7 +322,21 @@ var LazyQuery = class _LazyQuery {
|
|
|
276
322
|
this.plan = plan;
|
|
277
323
|
}
|
|
278
324
|
where(field, op, value) {
|
|
279
|
-
const
|
|
325
|
+
const via = this.source.via();
|
|
326
|
+
if (via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
|
|
327
|
+
const viaClause = via?.buildClause(field, op, value);
|
|
328
|
+
const clause = viaClause ? {
|
|
329
|
+
type: "field",
|
|
330
|
+
field,
|
|
331
|
+
op,
|
|
332
|
+
value,
|
|
333
|
+
via: {
|
|
334
|
+
brand: viaClause.brand,
|
|
335
|
+
payload: viaClause.payload,
|
|
336
|
+
evaluate: (actual, evalOp) => via.evaluateClause(viaClause, actual, evalOp),
|
|
337
|
+
indexValue: via.indexProbe(viaClause, op)
|
|
338
|
+
}
|
|
339
|
+
} : { type: "field", field, op, value };
|
|
280
340
|
return new _LazyQuery(this.source, {
|
|
281
341
|
...this.plan,
|
|
282
342
|
clauses: [...this.plan.clauses, clause]
|
|
@@ -313,17 +373,17 @@ var LazyQuery = class _LazyQuery {
|
|
|
313
373
|
missingFields: touchedFields
|
|
314
374
|
});
|
|
315
375
|
}
|
|
316
|
-
const
|
|
376
|
+
const survivors = [];
|
|
317
377
|
for (const id of candidateIds) {
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
if (!matchesAll(
|
|
321
|
-
|
|
378
|
+
const raw = await this.source.getRawRecord(id);
|
|
379
|
+
if (raw === null) continue;
|
|
380
|
+
if (!matchesAll(raw, this.plan.clauses)) continue;
|
|
381
|
+
survivors.push(raw);
|
|
322
382
|
}
|
|
323
|
-
const sorted = this.plan.orderBy.length > 0 ? sortRecords(
|
|
383
|
+
const sorted = this.plan.orderBy.length > 0 ? sortRecords(survivors, this.plan.orderBy, this.source.via()) : survivors;
|
|
324
384
|
const offset = this.plan.offset > 0 ? this.plan.offset : 0;
|
|
325
|
-
const
|
|
326
|
-
return
|
|
385
|
+
const page = this.plan.limit === void 0 ? sorted.slice(offset) : sorted.slice(offset, offset + this.plan.limit);
|
|
386
|
+
return Promise.all(page.map((r) => this.source.decodeRecord(r)));
|
|
327
387
|
}
|
|
328
388
|
async first() {
|
|
329
389
|
const out = await this.limit(1).toArray();
|
|
@@ -342,12 +402,17 @@ var LazyQuery = class _LazyQuery {
|
|
|
342
402
|
resolveCandidateIds() {
|
|
343
403
|
const idx = this.source.persistedIndexes;
|
|
344
404
|
const eqMap = /* @__PURE__ */ new Map();
|
|
405
|
+
const viaFields = /* @__PURE__ */ new Set();
|
|
345
406
|
for (const clause of this.plan.clauses) {
|
|
346
|
-
if (clause.op === "==")
|
|
407
|
+
if (clause.op === "==") {
|
|
408
|
+
eqMap.set(clause.field, clause.value);
|
|
409
|
+
if (clause.via) viaFields.add(clause.field);
|
|
410
|
+
}
|
|
347
411
|
}
|
|
348
412
|
if (eqMap.size >= 2) {
|
|
349
413
|
for (const def of idx.definitions()) {
|
|
350
414
|
if (def.kind !== "composite") continue;
|
|
415
|
+
if (def.fields.some((f) => viaFields.has(f))) continue;
|
|
351
416
|
if (def.fields.every((f) => eqMap.has(f))) {
|
|
352
417
|
const tuple = def.fields.map((f) => eqMap.get(f));
|
|
353
418
|
const ids = idx.lookupEqual(def.key, tuple);
|
|
@@ -357,12 +422,40 @@ var LazyQuery = class _LazyQuery {
|
|
|
357
422
|
}
|
|
358
423
|
for (const clause of this.plan.clauses) {
|
|
359
424
|
if (clause.op === "==") {
|
|
360
|
-
|
|
425
|
+
if (clause.via) {
|
|
426
|
+
if (clause.via.indexValue === void 0) {
|
|
427
|
+
const entries = idx.orderedBy(clause.field, "asc");
|
|
428
|
+
if (entries) return entries.map((e) => e.recordId);
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const ids2 = idx.lookupEqual(clause.field, clause.via.indexValue);
|
|
432
|
+
if (ids2) return [...ids2];
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
const probe = this.source.canonicalizeIndexKey?.(clause.field, clause.value) ?? clause.value;
|
|
436
|
+
const ids = idx.lookupEqual(clause.field, probe);
|
|
361
437
|
if (ids) return [...ids];
|
|
362
438
|
} else if (clause.op === "in" && Array.isArray(clause.value)) {
|
|
363
|
-
|
|
439
|
+
if (clause.via) {
|
|
440
|
+
if (clause.via.indexValue === void 0) {
|
|
441
|
+
const entries = idx.orderedBy(clause.field, "asc");
|
|
442
|
+
if (entries) return entries.map((e) => e.recordId);
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (!Array.isArray(clause.via.indexValue)) continue;
|
|
446
|
+
const ids2 = idx.lookupIn(clause.field, clause.via.indexValue);
|
|
447
|
+
if (ids2) return [...ids2];
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
const probes = clause.value.map((v) => this.source.canonicalizeIndexKey?.(clause.field, v) ?? v);
|
|
451
|
+
const ids = idx.lookupIn(clause.field, probes);
|
|
364
452
|
if (ids) return [...ids];
|
|
365
453
|
} else if (isRangeOp(clause.op)) {
|
|
454
|
+
if (clause.via) {
|
|
455
|
+
const entries = idx.orderedBy(clause.field, "asc");
|
|
456
|
+
if (entries) return entries.map((e) => e.recordId);
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
366
459
|
const ids = idx.lookupRange(clause.field, clause.op, clause.value);
|
|
367
460
|
if (ids) return [...ids];
|
|
368
461
|
}
|
|
@@ -397,12 +490,13 @@ function matchesAll(record, clauses) {
|
|
|
397
490
|
}
|
|
398
491
|
return true;
|
|
399
492
|
}
|
|
400
|
-
function sortRecords(records, orderBy) {
|
|
493
|
+
function sortRecords(records, orderBy, via) {
|
|
401
494
|
return [...records].sort((a, b) => {
|
|
402
495
|
for (const { field, direction } of orderBy) {
|
|
403
496
|
const av = readPath(a, field);
|
|
404
497
|
const bv = readPath(b, field);
|
|
405
|
-
const
|
|
498
|
+
const viaCmp = via?.compareForOrder(field, av, bv);
|
|
499
|
+
const cmp = viaCmp !== void 0 ? viaCmp : compareValues(av, bv);
|
|
406
500
|
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
407
501
|
}
|
|
408
502
|
return 0;
|
|
@@ -427,4 +521,4 @@ export {
|
|
|
427
521
|
PersistedCollectionIndex,
|
|
428
522
|
LazyQuery
|
|
429
523
|
};
|
|
430
|
-
//# sourceMappingURL=chunk-
|
|
524
|
+
//# sourceMappingURL=chunk-6S7ENMRE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-lookup/indexing/persisted-indexes.ts","../src/with-lookup/indexing/lazy-builder.ts"],"sourcesContent":["/**\n * Persistent, encrypted secondary indexes for lazy-mode collections.\n *\n * Parallel to the in-memory `CollectionIndexes` used by eager mode (see\n * `packages/hub/src/query/indexes.ts`): same logical surface, but entries\n * are materialised as encrypted side-car records (`_idx/<field>/<recordId>`)\n * and bulk-loaded into an in-memory mirror on first query.\n *\n * This module only owns the id-namespace convention, the in-memory mirror,\n * and the typed errors. Write-path integration (PR 2 / ), query-planner\n * dispatch (PR 3 / , PR 4 / ), and the rebuild/reconcile utilities\n * (PR 5 / ) live in other files.\n *\n * See the design spec for the full architecture + threat model.\n */\n\n/**\n * Reserved id prefix for encrypted index side-car records.\n * Matches the existing `_keyring`, `_ledger_deltas/…`, `_meta/handle`\n * conventions inside a collection's id namespace.\n */\nexport const IDX_PREFIX = '_idx/' as const\n\n/**\n * Encode the side-car record id for a (field, recordId) pair.\n *\n * Format: `_idx/<field>/<recordId>` — no escaping. Field names may contain\n * dots (for dotted-path access consistent with eager-mode `readPath`);\n * record ids may contain slashes. The first two slash-separated segments\n * are `_idx` and the field; everything after the *second* slash is the\n * record id verbatim.\n */\nexport function encodeIdxId(field: string, recordId: string): string {\n return `${IDX_PREFIX}${field}/${recordId}`\n}\n\n/**\n * Decode a side-car id back into `{ field, recordId }`, or `null` if the\n * input is not a well-formed idx id. A well-formed id is:\n * - prefixed with `_idx/`\n * - contains a field segment (non-empty, no slashes)\n * - contains a record-id segment (non-empty, may contain slashes)\n */\nexport function decodeIdxId(id: string): { field: string; recordId: string } | null {\n if (!id.startsWith(IDX_PREFIX)) return null\n const rest = id.slice(IDX_PREFIX.length)\n const firstSlash = rest.indexOf('/')\n if (firstSlash <= 0) return null\n const field = rest.slice(0, firstSlash)\n const recordId = rest.slice(firstSlash + 1)\n if (recordId.length === 0) return null\n return { field, recordId }\n}\n\n/**\n * Fast-path predicate for discriminating side-car ids from regular record\n * ids and other reserved namespaces. Used by the hub to filter `list()`\n * results during bulk-load of the in-memory mirror.\n */\nexport function isIdxId(id: string): boolean {\n return decodeIdxId(id) !== null\n}\n\n/**\n * Sorted-value entry returned by `orderedBy()`. Mirrors the body shape\n * used by the write path — but `orderedBy` emits them already sorted by\n * `value` in the requested direction. Consumers (PR 4 / ) treat the\n * array as immutable and paginate via a numeric offset.\n *\n * **Note on `value`:** as of, this is the ORIGINAL TYPED\n * value (number, Date, boolean, etc.), not the stringified bucket key.\n * That's what lets range predicates and `orderedBy` compare numerically\n * instead of stumbling into `'10' < '2'` on `String(n)`.\n */\nexport interface OrderedEntry {\n readonly recordId: string\n readonly value: unknown\n}\n\n/**\n * Bulk-load row shape accepted by `ingest()`. The `value` field is the\n * decrypted index body's `value` field verbatim.\n */\nexport interface IngestRow {\n readonly recordId: string\n readonly value: unknown\n}\n\n/**\n * In-memory mirror of the persisted index side-car records for a single\n * collection. Populated by bulk-loading `_idx/<field>/*` ids on first\n * query and maintained incrementally by `Collection.put()` / `.delete()`\n * via `upsert()` / `remove()`.\n *\n * API surface is deliberately parallel to `CollectionIndexes` (eager mode)\n * so the query planner in PR 3/4 can dispatch to either polymorphically.\n *\n * Lifecycle:\n * - `declare(field)` — accept the field as indexable (idempotent)\n * - `ingest(field, rows[])` — bulk-load from decrypted index bodies\n * - `upsert(recordId, field, newValue, previousValue)` — incremental update\n * - `remove(recordId, field, value)` — incremental remove\n * - `lookupEqual(field, value)` / `lookupIn(field, values)` — equality reads\n * - `orderedBy(field, dir)` — sorted iteration for orderBy\n * - `clear()` — drop all buckets (invalidation / rotation)\n */\n/**\n * Per-field storage: the equality bucket map AND a parallel table of typed\n * values keyed by recordId. The typed table exists so range predicates\n * and `orderedBy` can compare on the original typed value rather\n * than the stringified bucket key — String(10) < String(2) is the classic\n * landmine `stringifyKey` introduces for numeric fields.\n */\ninterface PersistedFieldState {\n readonly buckets: Map<string, Set<string>>\n readonly values: Map<string, unknown>\n}\n\n/**\n * Structured index definition. Single-field indexes carry just a field\n * name; composite indexes carry the ordered list of fields and\n * the synthetic `key` (= fields joined by `COMPOSITE_DELIMITER`) used\n * as the bucket-map key and side-car envelope id segment.\n */\nexport type PersistedIndexDef =\n | { readonly kind: 'single'; readonly field: string; readonly key: string }\n | { readonly kind: 'composite'; readonly fields: readonly string[]; readonly key: string }\n\n/**\n * Delimiter used to synthesize a composite-index key from an ordered\n * field list. Intentionally a character that is extremely unusual in\n * JavaScript object keys (`|`) so collision with a literal field name\n * is vanishingly rare in practice. Composite declarations whose field\n * names contain `|` are rejected at declare-time with an explicit\n * error.\n */\nexport const COMPOSITE_DELIMITER = '|'\n\nexport function compositeKey(fields: readonly string[]): string {\n return fields.join(COMPOSITE_DELIMITER)\n}\n\nexport class PersistedCollectionIndex {\n private readonly indexes = new Map<string, PersistedFieldState>()\n private readonly defs = new Map<string, PersistedIndexDef>()\n\n /**\n * Per-field bucket-key canonicalizer (#677 — lazy twin of #672's\n * `CollectionIndexes.setCanonicalizer`), registered ONCE via\n * {@link setCanonicalizer} when the collection wires indexing up\n * (money-aware via `ViaPipeline.canonicalizeIndexKey`). Consulted by\n * EVERY bucket-mutation site — `ingest`/`upsert`/`remove` — so bucket\n * membership is symmetric: a legacy non-canonical stored value (e.g.\n * `'0100'`) and a canonical one (`'100'`) land in the SAME bucket,\n * mirroring `eager-indexes.ts`'s `addToIndex`/`removeFromIndex`.\n */\n private canonicalize?: (field: string, value: unknown) => string | undefined\n\n /**\n * Register the bucket-key canonicalizer. Called once, where the\n * collection constructs its indexing state — safe to call again (the\n * closure is simply replaced) but there is normally only one caller.\n */\n setCanonicalizer(fn: (field: string, value: unknown) => string | undefined): void {\n this.canonicalize = fn\n }\n\n /**\n * Declare a single-field index. Subsequent `upsert` / `ingest` calls\n * populate the in-memory mirror; calls before `declare` are no-ops\n * (tolerant bulk-load ordering). Idempotent.\n */\n declare(field: string): void {\n if (this.indexes.has(field)) return\n this.indexes.set(field, { buckets: new Map(), values: new Map() })\n this.defs.set(field, { kind: 'single', field, key: field })\n }\n\n /**\n * Declare a composite (multi-field) index. The synthetic\n * key is `fields.join('|')`; it doubles as the in-memory map key and\n * the `_idx/<key>/<recordId>` side-car field segment. Callers upsert\n * and lookup via the same `key` as single-field indexes, just with a\n * tuple value (JSON-stringified for bucketing).\n */\n declareComposite(fields: readonly string[]): void {\n if (fields.length === 0) {\n throw new Error('declareComposite: fields array must be non-empty')\n }\n for (const f of fields) {\n if (f.includes(COMPOSITE_DELIMITER)) {\n throw new Error(\n `declareComposite: field \"${f}\" contains the composite delimiter ` +\n `\"${COMPOSITE_DELIMITER}\" — pick a different field name or open an ` +\n `issue to add hash-based composite keys.`,\n )\n }\n }\n const key = compositeKey(fields)\n if (this.indexes.has(key)) return\n this.indexes.set(key, { buckets: new Map(), values: new Map() })\n this.defs.set(key, { kind: 'composite', fields: [...fields], key })\n }\n\n /**\n * Every declared index's structured definition. Collection walks this\n * when materialising side-cars on put/delete so it can extract a\n * single-field value or a composite tuple appropriately.\n */\n definitions(): PersistedIndexDef[] {\n return [...this.defs.values()]\n }\n\n /** True if `field` has been declared as indexable on this mirror. */\n has(field: string): boolean {\n return this.indexes.has(field)\n }\n\n /** All declared field names, in declaration order. */\n fields(): string[] {\n return [...this.indexes.keys()]\n }\n\n /**\n * Bulk-load the mirror from decrypted index bodies. Intended to be\n * called once per field after reading the collection's `_idx/<field>/*`\n * side-cars. Safe to call twice with the same rows — bucket Sets\n * deduplicate recordIds. If `field` is not declared, this is a no-op\n * (tolerates the case where bulk-load runs before `declare()` lands).\n */\n ingest(field: string, rows: readonly IngestRow[]): void {\n const state = this.indexes.get(field)\n if (!state) return\n for (const row of rows) {\n addToState(state, row.recordId, row.value, field, this.canonicalize)\n }\n }\n\n /**\n * Incrementally update a record's index entry for one field. Called by\n * `Collection.put()` after the main write succeeds. If\n * `previousValue` is non-null, the record is removed from the old\n * bucket first — this is the update path. Pass `null` for fresh adds.\n * No-op if the field is not declared.\n */\n upsert(recordId: string, field: string, newValue: unknown, previousValue: unknown): void {\n const state = this.indexes.get(field)\n if (!state) return\n if (previousValue !== null && previousValue !== undefined) {\n removeFromState(state, recordId, previousValue, field, this.canonicalize)\n }\n addToState(state, recordId, newValue, field, this.canonicalize)\n }\n\n /**\n * Remove a record from the index for one field. Called by\n * `Collection.delete()`. No-op if the field is not declared or\n * the record isn't in the bucket. Empty buckets are dropped to keep\n * the Map clean.\n */\n remove(recordId: string, field: string, value: unknown): void {\n const state = this.indexes.get(field)\n if (!state) return\n removeFromState(state, recordId, value, field, this.canonicalize)\n }\n\n /**\n * Drop all bucket data while preserving field declarations. Called on\n * invalidation (incoming sync changes, keyring rotation) — the next\n * query re-populates via `ingest`.\n */\n clear(): void {\n for (const state of this.indexes.values()) {\n state.buckets.clear()\n state.values.clear()\n }\n }\n\n /**\n * Equality lookup — return the set of record ids whose `field` matches\n * `value`. Returns `null` if the field is not declared (caller falls\n * back to scan or throws `IndexRequiredError`). Returns a shared empty\n * set if the field is declared but no record matches — that set MUST\n * NOT be mutated by the caller.\n *\n * `value` is bucketed via the plain {@link stringifyKey} — it is NOT\n * canonicalized here. Callers on a Via-covered field (money) canonicalize\n * `value` themselves BEFORE calling (see `lazy-builder.ts`'s\n * `resolveCandidateIds()`, #677) — the SAME caller-canonicalizes split\n * `eager-indexes.ts`'s `lookupEqual`/`lookupIn` use (see `kernel/query/\n * builder.ts`'s `candidateRecords()`), so probing here twice never\n * double-canonicalizes.\n */\n lookupEqual(field: string, value: unknown): ReadonlySet<string> | null {\n const state = this.indexes.get(field)\n if (!state) return null\n const key = stringifyKey(value)\n return state.buckets.get(key) ?? EMPTY_SET\n }\n\n /**\n * Set lookup — return the union of record ids whose `field` matches any\n * of `values`. Returns `null` if the field is not declared. Returns a\n * fresh (non-shared) Set — safe for the caller to mutate. Same\n * caller-canonicalizes contract as {@link lookupEqual} (#677).\n */\n lookupIn(field: string, values: readonly unknown[]): ReadonlySet<string> | null {\n const state = this.indexes.get(field)\n if (!state) return null\n const out = new Set<string>()\n for (const value of values) {\n const bucket = state.buckets.get(stringifyKey(value))\n if (bucket) for (const id of bucket) out.add(id)\n }\n return out\n }\n\n /**\n * Range lookup. Return record ids whose indexed value\n * satisfies the predicate. Comparison happens on the ORIGINAL TYPED\n * value carried in `state.values` — so numeric `<` sorts numerically,\n * not lexicographically on `String(n)`. Returns `null` if the field\n * is not declared.\n *\n * Supported ops: `'<'`, `'<='`, `'>'`, `'>='`, `'between'`. For\n * `'between'`, `value` is `[lo, hi]` and both bounds are inclusive\n * (matches the eager-mode operator contract in `predicate.ts`).\n *\n * NOT canonicalized (#677): this method compares `value` against the\n * ORIGINAL TYPED `state.values`, not a stringified bucket key, so a\n * `canonicalizeIndexKey`-shaped (`string | undefined`) result would not\n * even type-check as a bound here. This does NOT mirror eager mode the\n * way `lookupEqual`/`lookupIn` do: `moneyIndexProbe` (`via/money/\n * where.ts`) never emits a range probe, so EAGER mode's `candidateRecords`\n * never calls an index for a range clause and always scans.\n *\n * LAZY mode's `resolveCandidateIds()` (`lazy-builder.ts`) no longer\n * dispatches a Via-covered (e.g. money) range clause through THIS method\n * at all (#684) — it enumerates the field's indexed ids via `orderedBy()`\n * instead and leaves the raw/typed comparison here for the (now\n * Via-aware) post-filter to redo correctly in scaled-int space. A\n * NON-via range clause still dispatches through this method exactly as\n * before — the raw/typed comparison here is correct and sufficient for\n * fields with no decode-transforming Via binding.\n */\n lookupRange(\n field: string,\n op: '<' | '<=' | '>' | '>=' | 'between',\n value: unknown,\n ): ReadonlySet<string> | null {\n const state = this.indexes.get(field)\n if (!state) return null\n const out = new Set<string>()\n for (const [recordId, live] of state.values) {\n if (live === undefined || live === null) continue\n if (matchesRange(live, op, value)) out.add(recordId)\n }\n return out\n }\n\n /**\n * Sorted iteration — return every entry on `field` as an\n * `OrderedEntry[]`, sorted by the ORIGINAL TYPED value (no more\n * `'10' < '2'` surprises on numeric fields). Consumers paginate with\n * a numeric offset. `OrderedEntry.value` is the typed value.\n */\n orderedBy(field: string, dir: 'asc' | 'desc'): readonly OrderedEntry[] | null {\n const state = this.indexes.get(field)\n if (!state) return null\n const entries: OrderedEntry[] = []\n for (const [recordId, value] of state.values) {\n entries.push({ recordId, value })\n }\n entries.sort((a, b) => compareTyped(a.value, b.value))\n if (dir === 'desc') entries.reverse()\n return entries\n }\n}\n\nconst EMPTY_SET: ReadonlySet<string> = new Set()\n\n/**\n * Canonicalize a value into a bucket key. Deliberately identical to the\n * eager-mode `stringifyKey` in `query/indexes.ts` so semantics match. When\n * `query/indexes.ts` changes its coercion rules, update this in lockstep.\n *\n * null / undefined values are NOT indexed — callers who pass them to\n * `upsert` / `remove` short-circuit before reaching this function; the\n * sentinel here exists only to make `lookupEqual(field, null)` return\n * an empty bucket (rather than matching some arbitrary record).\n */\nfunction stringifyKey(value: unknown): string {\n if (value === null || value === undefined) return '\\0NULL\\0'\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n if (value instanceof Date) return value.toISOString()\n // composite index values are tuple arrays. JSON.stringify\n // gives a delimiter-safe, order-preserving canonical form so buckets\n // for `['c-A', '2026-Q1']` and `['c-A', '2026-Q2']` never collide.\n if (Array.isArray(value)) {\n const parts: string[] = []\n for (const el of value) parts.push(stringifyKey(el))\n return JSON.stringify(parts)\n }\n return '\\0OBJECT\\0'\n}\n\nfunction addToState(\n state: PersistedFieldState,\n recordId: string,\n value: unknown,\n field: string,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n if (value === null || value === undefined) return\n const key = canonicalize?.(field, value) ?? stringifyKey(value)\n let bucket = state.buckets.get(key)\n if (!bucket) {\n bucket = new Set()\n state.buckets.set(key, bucket)\n }\n bucket.add(recordId)\n state.values.set(recordId, value)\n}\n\nfunction removeFromState(\n state: PersistedFieldState,\n recordId: string,\n value: unknown,\n field: string,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n if (value === null || value === undefined) return\n const key = canonicalize?.(field, value) ?? stringifyKey(value)\n const bucket = state.buckets.get(key)\n if (bucket) {\n bucket.delete(recordId)\n if (bucket.size === 0) state.buckets.delete(key)\n }\n state.values.delete(recordId)\n}\n\n/**\n * Range-predicate comparator. Runs on the ORIGINAL TYPED value so numeric\n * fields sort numerically (not lexicographically on `String(n)`). ISO-8601\n * date strings already sort correctly lexicographically; Date instances\n * compare via `getTime()` before the string branch to keep the contract\n * honest regardless of which form survived serialization.\n */\nfunction matchesRange(\n live: unknown,\n op: '<' | '<=' | '>' | '>=' | 'between',\n bound: unknown,\n): boolean {\n if (op === 'between') {\n if (!Array.isArray(bound) || bound.length !== 2) return false\n return compareTyped(live, bound[0]) >= 0 && compareTyped(live, bound[1]) <= 0\n }\n const cmp = compareTyped(live, bound)\n switch (op) {\n case '<': return cmp < 0\n case '<=': return cmp <= 0\n case '>': return cmp > 0\n case '>=': return cmp >= 0\n }\n}\n\nfunction compareTyped(a: unknown, b: unknown): number {\n if (a === undefined || a === null) return b === undefined || b === null ? 0 : 1\n if (b === undefined || b === null) return -1\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime()\n if (typeof a === 'string' && typeof b === 'string') return a < b ? -1 : a > b ? 1 : 0\n if (typeof a === 'boolean' && typeof b === 'boolean') {\n return a === b ? 0 : a ? 1 : -1\n }\n // Mixed/unsupported types: deliberately treat as equal so sort stays\n // stable. Matches the eager-mode `compareValues` contract in\n // builder.ts — we don't silently coerce arbitrary objects to strings\n // (which would be meaningless) nor throw (which would be hostile).\n return 0\n}\n","/**\n * Lazy-mode query builder.\n *\n * Companion to `Query<T>` in `builder.ts`, but built for collections in lazy\n * mode where `snapshot()` is unavailable — records live in the adapter and\n * are pulled on demand. Dispatches through `PersistedCollectionIndex` to\n * resolve a candidate record-id set, then decrypts only those records.\n *\n * Scope:\n * - `.where(field, '==' | 'in', value)` — dispatched through the index\n * - `.where(field, other-op, value)` — evaluated against the decrypted\n * candidate set (non-indexed ops still require the field to be indexed\n * — we need SOMETHING to scope the candidate set)\n * - `.orderBy(field, dir?)` — dispatched through `orderedBy` when no\n * `==`/`in` clause is present; otherwise applied as an in-memory sort\n * over the candidate set\n * - `.limit(n)` / `.offset(n)` — page slice after filtering\n * - `.toArray()` / `.first()` / `.count()` — terminals\n *\n * Every field referenced by a where or orderBy clause MUST be indexed;\n * otherwise `toArray()` throws `IndexRequiredError`. This is deliberate:\n * silent scan-fallback would hide the very performance cliff that lazy-mode\n * indexes exist to prevent (see `docs/architecture.md` §indexes).\n */\n\nimport type { Clause, FieldClause, Operator } from '../../kernel/query/predicate.js'\nimport { evaluateClause, readPath } from '../../kernel/query/predicate.js'\nimport type { PersistedCollectionIndex } from './persisted-indexes.js'\nimport { IndexRequiredError, FieldNotQueryableError } from '../../kernel/errors.js'\nimport type { QueryField } from '../../kernel/types.js'\nimport type { ViaPipeline } from '../../kernel/via/pipeline.js'\n\nexport interface LazyOrderBy {\n readonly field: string\n readonly direction: 'asc' | 'desc'\n}\n\n/**\n * Source abstraction the LazyQuery runs against. Collection implements it.\n * Kept minimal so the builder stays test-friendly.\n */\nexport interface LazyQuerySource<T> {\n readonly collectionName: string\n readonly persistedIndexes: PersistedCollectionIndex\n /**\n * Per-field bucket-key canonicalizer (#677 — lazy twin of the eager\n * `candidateRecords()` probe-resolution in `kernel/query/builder.ts`).\n * Consulted in `resolveCandidateIds()` for `==`/`in` clause values\n * BEFORE calling `lookupEqual`/`lookupIn`, so a mixed-era stored value\n * (money) probes the SAME canonical bucket the write path now\n * populates. A narrow closure — not the whole `ViaPipeline` — keeps\n * the with-lookup/kernel seam thin. `undefined` (no via, or no binding\n * covers the field) is the common case: falls back to the raw value,\n * unchanged from today.\n */\n canonicalizeIndexKey?(field: string, value: unknown): string | undefined\n /** Ensure `_idx/<field>/*` side-cars have been bulk-loaded into the mirror. */\n ensurePersistedIndexesLoaded(): Promise<void>\n /**\n * Decrypt one record by id in RAW (pre-`present()`, stored-form) shape,\n * or return null if it's gone (#684 — the raw-fetch seam). Used by the\n * post-filter (`toArray()`) so a `clause.via.evaluate` (e.g. money) sees\n * the same operand/actual-value space as eager's `filterRecords` — the\n * DECODED form (e.g. money's canonical decimal) is only materialized\n * for survivors, via {@link decodeRecord}.\n */\n getRawRecord(id: string): Promise<unknown>\n /**\n * Apply this collection's locale/virtual-field decode (`present()`) to a\n * RAW record already known to match — the output-side twin of\n * {@link getRawRecord}. Mirrors eager's `Query.decodeVia`.\n */\n decodeRecord(record: unknown): Promise<T>\n /**\n * This collection's compiled Via pipeline (money, i18n, …), read lazily\n * (a method, not a captured value) so a late `_setVia` (#666) is honored\n * — same closure discipline as {@link canonicalizeIndexKey}. `undefined`\n * when the collection has no Via-covered fields.\n */\n via(): ViaPipeline | undefined\n}\n\ninterface LazyPlan {\n readonly clauses: readonly FieldClause[]\n readonly orderBy: readonly LazyOrderBy[]\n readonly limit: number | undefined\n readonly offset: number\n}\n\nconst EMPTY_PLAN: LazyPlan = {\n clauses: [],\n orderBy: [],\n limit: undefined,\n offset: 0,\n}\n\nexport class LazyQuery<T, S extends keyof T = never, Q extends keyof T & string = never> {\n private readonly source: LazyQuerySource<T>\n private readonly plan: LazyPlan\n\n constructor(source: LazyQuerySource<T>, plan: LazyPlan = EMPTY_PLAN) {\n this.source = source\n this.plan = plan\n }\n\n where<V>(field: QueryField<T, S, Q>, op: Operator, value: V): LazyQuery<T, S, Q> {\n // A Via-covered field (e.g. money) compares in major units, BigInt-exact\n // in scaled space — same build-time operand rewrite + `clause.via`\n // attachment as `Query.where()` (`kernel/query/builder.ts`) and\n // `ScanBuilder.where()` (`kernel/query/scan-builder.ts`). Before #684\n // this method built a bare clause with no `clause.via` at all, so the\n // post-filter fell through to the generic (non-Via-aware) comparison —\n // see `toArray()` below for the raw-record post-filter this feeds.\n const via = this.source.via()\n // Consults the Via pipeline's posture BEFORE building a clause — same\n // gate as `Query.where()` (builder.ts) / `ScanBuilder.where()`\n // (scan-builder.ts): a field whose posture is `queryable: 'none'`\n // (e.g. a `blobFields` slot) throws `FieldNotQueryableError` here, at\n // the call site, instead of building a bare clause that later surfaces\n // as a deferred `IndexRequiredError` from `toArray()`.\n if (via?.postureFor(field)?.queryable === 'none') throw new FieldNotQueryableError(field)\n const viaClause = via?.buildClause(field, op, value)\n const clause: FieldClause = viaClause\n ? {\n type: 'field',\n field,\n op,\n value,\n via: {\n brand: viaClause.brand,\n payload: viaClause.payload,\n evaluate: (actual: unknown, evalOp: string) => via!.evaluateClause(viaClause, actual, evalOp),\n indexValue: via!.indexProbe(viaClause, op),\n },\n }\n : { type: 'field', field, op, value }\n return new LazyQuery<T, S, Q>(this.source, {\n ...this.plan,\n clauses: [...this.plan.clauses, clause],\n })\n }\n\n orderBy(field: QueryField<T, S>, direction: 'asc' | 'desc' = 'asc'): LazyQuery<T, S, Q> {\n return new LazyQuery<T, S, Q>(this.source, {\n ...this.plan,\n orderBy: [...this.plan.orderBy, { field, direction }],\n })\n }\n\n limit(n: number): LazyQuery<T, S, Q> {\n return new LazyQuery<T, S, Q>(this.source, { ...this.plan, limit: n })\n }\n\n offset(n: number): LazyQuery<T, S, Q> {\n return new LazyQuery<T, S, Q>(this.source, { ...this.plan, offset: n })\n }\n\n async toArray(): Promise<T[]> {\n await this.source.ensurePersistedIndexesLoaded()\n\n const touchedFields = collectTouchedFields(this.plan)\n const missingFields = touchedFields.filter(f => !isFieldIndexed(f, this.source.persistedIndexes))\n if (missingFields.length > 0) {\n throw new IndexRequiredError({\n collection: this.source.collectionName,\n touchedFields,\n missingFields,\n })\n }\n\n const candidateIds = this.resolveCandidateIds()\n if (candidateIds === null) {\n // No usable driver — every touched field is indexed but no clause\n // pins the candidate set. This happens when a query only uses\n // operators other than `==`/`in` and no `orderBy` clause is\n // present — we refuse to enumerate the whole index, because that\n // defeats the purpose of lazy mode.\n throw new IndexRequiredError({\n collection: this.source.collectionName,\n touchedFields,\n missingFields: touchedFields,\n })\n }\n\n // #684: post-filter the RAW record (mirrors eager's filterRecords on the\n // raw snapshot) so `clause.via.evaluate` sees the same stored-form\n // operand/actual-value space `buildClause` quantized into at where()\n // time. Survivors stay RAW here — #695 sorts them via-aware in that\n // same stored-form space (mirroring eager's `sortRecords(result, ...,\n // source.via, ...)` in `kernel/query/builder.ts`) before anything is\n // decoded (`present()`).\n const survivors: T[] = []\n for (const id of candidateIds) {\n const raw = await this.source.getRawRecord(id)\n if (raw === null) continue\n if (!matchesAll(raw, this.plan.clauses)) continue\n survivors.push(raw as T)\n }\n\n // #695: sort the RAW survivors via-aware — a money field's stored form\n // (scaled-integer string) sorts lexicographically wrong under the\n // generic comparator ('10.00' < '2.00' once decoded); `via.compareForOrder`\n // compares in the correct (BigInt-exact scaled) space, same as eager.\n const sorted = this.plan.orderBy.length > 0\n ? sortRecords(survivors, this.plan.orderBy, this.source.via())\n : survivors\n\n const offset = this.plan.offset > 0 ? this.plan.offset : 0\n const page = this.plan.limit === undefined\n ? sorted.slice(offset)\n : sorted.slice(offset, offset + this.plan.limit)\n\n // Decode only the final page — fewer decodes than the pre-#695 code,\n // which decoded every survivor before sorting/slicing.\n return Promise.all(page.map(r => this.source.decodeRecord(r)))\n }\n\n async first(): Promise<T | null> {\n const out = await this.limit(1).toArray()\n return out.length > 0 ? out[0]! : null\n }\n\n async count(): Promise<number> {\n const out = await this.toArray()\n return out.length\n }\n\n /**\n * Resolve the candidate record-id set to decrypt. Returns null when the\n * query has no usable driver — no `==`/`in` clause and no `orderBy`\n * clause that can scope the scan. Callers interpret null as\n * IndexRequiredError (see `toArray`).\n */\n private resolveCandidateIds(): readonly string[] | null {\n const idx = this.source.persistedIndexes\n\n // prefer a composite index when the query's `==`\n // clauses cover every field of one declared composite. The\n // composite mirror lookup is O(matches) vs single-field +\n // post-filter on the decrypted candidate set.\n const eqMap = new Map<string, unknown>()\n const viaFields = new Set<string>()\n for (const clause of this.plan.clauses) {\n if (clause.op === '==') {\n eqMap.set(clause.field, clause.value)\n // #696: the composite mirror buckets on `stringifyKey(tuple)` built\n // from the RAW clause values — the per-field money canonicalizer\n // (`canonicalizeIndexKey`) only ever keys off a single field name,\n // never the joined composite key, so a Via-covered field's tuple\n // slot never lands in the same bucket a canonical write produced.\n // Track which `==` fields are Via-covered so the composite branch\n // below can skip them and fall through to the single-field\n // Via-aware path (already correct for money) instead.\n if (clause.via) viaFields.add(clause.field)\n }\n }\n if (eqMap.size >= 2) {\n for (const def of idx.definitions()) {\n if (def.kind !== 'composite') continue\n if (def.fields.some(f => viaFields.has(f))) continue\n if (def.fields.every(f => eqMap.has(f))) {\n const tuple = def.fields.map(f => eqMap.get(f))\n const ids = idx.lookupEqual(def.key, tuple)\n if (ids) return [...ids]\n }\n }\n }\n\n for (const clause of this.plan.clauses) {\n if (clause.op === '==') {\n if (clause.via) {\n // #684: prefer `clause.via.indexValue` — the same STORED-form\n // probe operand eager's `candidateRecords()` resolves first\n // (`kernel/query/builder.ts`). `undefined` means the binding\n // declined to probe this op/payload (e.g. money multi-mode) — no\n // sound equality bucket exists. Eager's `candidateRecords()`\n // handles this by skipping the index-eligibility check for the\n // clause and falling back to a full scan (`builder.ts:1176`); the\n // lazy equivalent (#684 review-fix 2) is the same move the RANGE branch\n // below already makes — enumerate the field's full indexed id\n // set via `orderedBy` and let the (now via-aware) post-filter in\n // `toArray()` decide, instead of throwing `IndexRequiredError`.\n if (clause.via.indexValue === undefined) {\n const entries = idx.orderedBy(clause.field, 'asc')\n if (entries) return entries.map(e => e.recordId)\n continue\n }\n const ids = idx.lookupEqual(clause.field, clause.via.indexValue)\n if (ids) return [...ids]\n continue\n }\n // #677: canonicalize the probe value BEFORE the lookup — same\n // \"resolve before lookupEqual\" shape as eager's `candidateRecords()`,\n // but through the narrower `canonicalizeIndexKey` seam, used only on\n // this NON-via path. `undefined` (no via coverage) falls back to the\n // raw clause value, unchanged from today.\n const probe = this.source.canonicalizeIndexKey?.(clause.field, clause.value) ?? clause.value\n const ids = idx.lookupEqual(clause.field, probe)\n if (ids) return [...ids]\n } else if (clause.op === 'in' && Array.isArray(clause.value)) {\n if (clause.via) {\n // Same #684 review-fix 2 fallback as the `==` branch above — a via\n // payload that declines to probe (e.g. money multi-mode) still\n // has a sound candidate superset via `orderedBy`.\n if (clause.via.indexValue === undefined) {\n const entries = idx.orderedBy(clause.field, 'asc')\n if (entries) return entries.map(e => e.recordId)\n continue\n }\n if (!Array.isArray(clause.via.indexValue)) continue\n const ids = idx.lookupIn(clause.field, clause.via.indexValue)\n if (ids) return [...ids]\n continue\n }\n const probes = clause.value.map(v => this.source.canonicalizeIndexKey?.(clause.field, v) ?? v)\n const ids = idx.lookupIn(clause.field, probes)\n if (ids) return [...ids]\n } else if (isRangeOp(clause.op)) {\n if (clause.via) {\n // #684: a Via-covered range clause (e.g. money) cannot trust\n // `lookupRange` — it compares the ORIGINAL TYPED stored value,\n // wrong space for a binding whose stored form isn't directly\n // orderable that way (money: BigInt-exact scaled-int compare).\n // No binding emits a range `indexProbe` either (see\n // `moneyIndexProbe`), so there's no sound bucket lookup at all.\n // Enumerate the field's full indexed id set via `orderedBy` — the\n // same superset a scan would consider, just scoped to indexed ids\n // — and let the (now via-aware) post-filter in `toArray()` apply\n // the correct scaled-space comparison. Replaces the old\n // \"always trust lookupRange, no scan fallback\" gap.\n const entries = idx.orderedBy(clause.field, 'asc')\n if (entries) return entries.map(e => e.recordId)\n continue\n }\n // range predicates on a NON-via indexed field dispatch through\n // `lookupRange`, which compares on the original typed value (no\n // numeric-lexicographic landmines).\n const ids = idx.lookupRange(clause.field, clause.op, clause.value)\n if (ids) return [...ids]\n }\n }\n\n // No equality/range driver — try to scope via orderBy.\n if (this.plan.orderBy.length > 0) {\n const primary = this.plan.orderBy[0]!\n const entries = idx.orderedBy(primary.field, primary.direction)\n if (entries) return entries.map(e => e.recordId)\n }\n\n return null\n }\n}\n\n/**\n * True if the given field name is covered by either a single-field\n * index or appears as a component of a declared composite index.\n * Composite coverage is sufficient for the missing-field check because\n * composite writes also maintain the in-memory mirror — the range /\n * orderBy / single-equality lookup paths fall through to decrypted\n * candidates that still get post-filtered by the composite clause.\n */\nfunction isFieldIndexed(field: string, idx: PersistedCollectionIndex): boolean {\n if (idx.has(field)) return true\n for (const def of idx.definitions()) {\n if (def.kind === 'composite' && def.fields.includes(field)) return true\n }\n return false\n}\n\nfunction isRangeOp(op: Operator): op is '<' | '<=' | '>' | '>=' | 'between' {\n return op === '<' || op === '<=' || op === '>' || op === '>=' || op === 'between'\n}\n\nfunction collectTouchedFields(plan: LazyPlan): string[] {\n const seen = new Set<string>()\n for (const c of plan.clauses) seen.add(c.field)\n for (const o of plan.orderBy) seen.add(o.field)\n return [...seen]\n}\n\nfunction matchesAll(record: unknown, clauses: readonly Clause[]): boolean {\n for (const c of clauses) {\n if (!evaluateClause(record, c)) return false\n }\n return true\n}\n\nfunction sortRecords<T>(records: T[], orderBy: readonly LazyOrderBy[], via?: ViaPipeline): T[] {\n return [...records].sort((a, b) => {\n for (const { field, direction } of orderBy) {\n const av = readPath(a, field)\n const bv = readPath(b, field)\n // #695: a Via-covered field (e.g. money) may store a representation\n // the generic comparator would order wrong — ask the pipeline for an\n // exact ordering first, same as eager's `sortRecords` in\n // `kernel/query/builder.ts`. `undefined` (no via, or the field isn't\n // covered) falls back to the generic comparator, unchanged from today.\n const viaCmp = via?.compareForOrder(field, av, bv)\n const cmp = viaCmp !== undefined ? viaCmp : compareValues(av, bv)\n if (cmp !== 0) return direction === 'asc' ? cmp : -cmp\n }\n return 0\n })\n}\n\nfunction compareValues(a: unknown, b: unknown): number {\n if (a === undefined || a === null) return b === undefined || b === null ? 0 : 1\n if (b === undefined || b === null) return -1\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (typeof a === 'string' && typeof b === 'string') return a < b ? -1 : a > b ? 1 : 0\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime()\n return 0\n}\n"],"mappings":";;;;;;;;;;AAqBO,IAAM,aAAa;AAWnB,SAAS,YAAY,OAAe,UAA0B;AACnE,SAAO,GAAG,UAAU,GAAG,KAAK,IAAI,QAAQ;AAC1C;AASO,SAAS,YAAY,IAAwD;AAClF,MAAI,CAAC,GAAG,WAAW,UAAU,EAAG,QAAO;AACvC,QAAM,OAAO,GAAG,MAAM,WAAW,MAAM;AACvC,QAAM,aAAa,KAAK,QAAQ,GAAG;AACnC,MAAI,cAAc,EAAG,QAAO;AAC5B,QAAM,QAAQ,KAAK,MAAM,GAAG,UAAU;AACtC,QAAM,WAAW,KAAK,MAAM,aAAa,CAAC;AAC1C,MAAI,SAAS,WAAW,EAAG,QAAO;AAClC,SAAO,EAAE,OAAO,SAAS;AAC3B;AAOO,SAAS,QAAQ,IAAqB;AAC3C,SAAO,YAAY,EAAE,MAAM;AAC7B;AA2EO,IAAM,sBAAsB;AAE5B,SAAS,aAAa,QAAmC;AAC9D,SAAO,OAAO,KAAK,mBAAmB;AACxC;AAEO,IAAM,2BAAN,MAA+B;AAAA,EACnB,UAAU,oBAAI,IAAiC;AAAA,EAC/C,OAAO,oBAAI,IAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,iBAAiB,IAAiE;AACh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}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
IllegalTransitionError,
|
|
3
3
|
RecordLockedError,
|
|
4
4
|
ValidationError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
6
6
|
|
|
7
7
|
// src/with-audit/guards/with-guard.ts
|
|
8
8
|
function withGuard(strategy) {
|
|
@@ -120,4 +120,4 @@ export {
|
|
|
120
120
|
immutableGuard,
|
|
121
121
|
transitionGuard
|
|
122
122
|
};
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-7GAXFU2O.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openEnvelopeJson
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HA6ZQWA2.js";
|
|
4
4
|
import {
|
|
5
5
|
encrypt
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-37WOJQWY.js";
|
|
7
7
|
import {
|
|
8
8
|
NOYDB_FORMAT_VERSION
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JC75UBMT.js";
|
|
10
10
|
import {
|
|
11
11
|
ConflictError,
|
|
12
12
|
SequenceContentionError,
|
|
13
13
|
SequenceNotEnabledError,
|
|
14
14
|
SequenceOfflineError,
|
|
15
15
|
ValidationError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
17
17
|
|
|
18
18
|
// src/with-commit/sequence/strategy.ts
|
|
19
19
|
var NO_SEQUENCE = {
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
resolveSequenceKey,
|
|
200
200
|
SequenceStore
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-7QLY64AD.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveManagedSecret
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FF7S3XDW.js";
|
|
4
4
|
import {
|
|
5
5
|
parseExtractedPartitionBody,
|
|
6
6
|
readPod,
|
|
7
7
|
readPodHeader
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PH7G7ZI7.js";
|
|
9
9
|
import {
|
|
10
10
|
createOwnerKeyring
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CCIR2OJH.js";
|
|
12
12
|
import {
|
|
13
13
|
LedgerStore
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HBBZWEC5.js";
|
|
15
15
|
import {
|
|
16
16
|
LEDGER_COLLECTION
|
|
17
17
|
} from "./chunk-I7FD46FF.js";
|
|
18
18
|
import {
|
|
19
19
|
openEnvelopeJson
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HA6ZQWA2.js";
|
|
21
21
|
import {
|
|
22
22
|
base64ToBuffer,
|
|
23
23
|
wrapKey
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-37WOJQWY.js";
|
|
25
25
|
import {
|
|
26
26
|
AdoptionStateError,
|
|
27
27
|
TransferSealError,
|
|
28
28
|
ValidationError
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
30
30
|
|
|
31
31
|
// src/with-cargo/adopt-partition.ts
|
|
32
32
|
async function unsealDeks(seal, transferKey) {
|
|
@@ -179,7 +179,7 @@ async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
if (isManaged(opts)) {
|
|
182
|
-
const { createNoydb } = await import("./noydb-
|
|
182
|
+
const { createNoydb } = await import("./noydb-AKH4AMCR.js");
|
|
183
183
|
const db = await createNoydb({
|
|
184
184
|
store,
|
|
185
185
|
user: userId,
|
|
@@ -232,4 +232,4 @@ export {
|
|
|
232
232
|
createOwnerOnAdoptedPartition,
|
|
233
233
|
decryptExtractedPartition
|
|
234
234
|
};
|
|
235
|
-
//# sourceMappingURL=chunk-
|
|
235
|
+
//# sourceMappingURL=chunk-7ZOSHEVS.js.map
|
|
@@ -6,7 +6,22 @@ import {
|
|
|
6
6
|
ConflictError,
|
|
7
7
|
InvariantError,
|
|
8
8
|
ValidationError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FZCGIJEJ.js";
|
|
10
|
+
|
|
11
|
+
// src/kernel/best-effort-revert.ts
|
|
12
|
+
async function bestEffortRevert(executed, adapter, compensate) {
|
|
13
|
+
for (const leg of [...executed].reverse()) {
|
|
14
|
+
try {
|
|
15
|
+
if (leg.prior !== null) {
|
|
16
|
+
await adapter.put(leg.vaultName, leg.collectionName, leg.id, leg.prior);
|
|
17
|
+
} else {
|
|
18
|
+
await adapter.delete(leg.vaultName, leg.collectionName, leg.id);
|
|
19
|
+
}
|
|
20
|
+
if (compensate) await compensate(leg);
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
|
|
11
26
|
// src/with-commit/tx/transaction.ts
|
|
12
27
|
var TxContext = class {
|
|
@@ -216,7 +231,7 @@ async function runTransaction(db, fn, options, txInvariants) {
|
|
|
216
231
|
db._clearActiveTxContext(ctx);
|
|
217
232
|
}
|
|
218
233
|
if (ctx._amendment) {
|
|
219
|
-
const { GuardExecutor } = await import("./executor-
|
|
234
|
+
const { GuardExecutor } = await import("./executor-UPSH5O3F.js");
|
|
220
235
|
try {
|
|
221
236
|
for (const [vaultName, v] of ctx._amendmentVaults) {
|
|
222
237
|
const registry = v._getGuardRegistry();
|
|
@@ -326,30 +341,31 @@ async function runTransaction(db, fn, options, txInvariants) {
|
|
|
326
341
|
return bodyResult;
|
|
327
342
|
}
|
|
328
343
|
async function revertExecuted(executed, store, db) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
344
|
+
const legs = executed.map(({ op, priorEnvelope }) => ({
|
|
345
|
+
vaultName: op.vaultName,
|
|
346
|
+
collectionName: op.collectionName,
|
|
347
|
+
id: op.id,
|
|
348
|
+
prior: priorEnvelope
|
|
349
|
+
}));
|
|
350
|
+
await bestEffortRevert(
|
|
351
|
+
legs,
|
|
352
|
+
store,
|
|
353
|
+
db ? async (leg) => {
|
|
354
|
+
const coll = db.vault(leg.vaultName).collection(leg.collectionName);
|
|
355
|
+
await coll._invalidateCacheEntry(leg.id);
|
|
356
|
+
} : void 0
|
|
357
|
+
);
|
|
343
358
|
}
|
|
344
359
|
function keyOf(op) {
|
|
345
360
|
return `${op.vaultName}\0${op.collectionName}\0${op.id}`;
|
|
346
361
|
}
|
|
347
362
|
|
|
348
363
|
export {
|
|
364
|
+
bestEffortRevert,
|
|
349
365
|
TxContext,
|
|
350
366
|
TxVault,
|
|
351
367
|
TxCollection,
|
|
352
368
|
runTransaction,
|
|
353
369
|
revertExecuted
|
|
354
370
|
};
|
|
355
|
-
//# sourceMappingURL=chunk-
|
|
371
|
+
//# sourceMappingURL=chunk-AAIIDAUC.js.map
|