@noy-db/hub 0.7.0 → 0.8.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -14
- package/LICENSE +202 -21
- package/NOTICE +1 -0
- package/README.md +27 -10
- package/codemods/0.8.0-pre.json +61 -0
- package/dist/api-GVYEKSJE.js +19 -0
- package/dist/as/index.js +11 -11
- package/dist/at/index.js +9 -9
- package/dist/attestation/index.js +20 -20
- package/dist/{backup-IJTB4S4M.js → backup-7TFRVFLH.js} +21 -15
- package/dist/backup-7TFRVFLH.js.map +1 -0
- package/dist/blobs/index.js +13 -13
- package/dist/broker/index.js +12 -12
- package/dist/by/index.js +2 -2
- package/dist/cargo/index.js +39 -36
- package/dist/{chunk-7O3Y4PPD.js → chunk-244VXYPG.js} +140 -16
- package/dist/chunk-244VXYPG.js.map +1 -0
- package/dist/{chunk-BUE2D7PX.js → chunk-32YV3TJT.js} +2 -2
- package/dist/{chunk-3RCJJBNR.js → chunk-3ELRMVJK.js} +12 -12
- package/dist/{chunk-6GMZ7HEE.js → chunk-3F7GLNAE.js} +6 -6
- package/dist/{chunk-2Y4IMKA6.js → chunk-3H5KLDZN.js} +4 -4
- package/dist/{chunk-VTFVLCUH.js → chunk-3JWHAR6E.js} +2 -2
- package/dist/{chunk-YMUFFJCO.js → chunk-3TDUWVWB.js} +5 -2
- package/dist/chunk-3TDUWVWB.js.map +1 -0
- package/dist/{chunk-JBDFMYKQ.js → chunk-4AF3TUMP.js} +2 -2
- package/dist/{chunk-ZORTV6NH.js → chunk-4I522ERM.js} +88 -4
- package/dist/chunk-4I522ERM.js.map +1 -0
- package/dist/{chunk-MUM7IANK.js → chunk-4MXI3ODD.js} +4 -4
- package/dist/chunk-4MXI3ODD.js.map +1 -0
- package/dist/{chunk-BLN54W3L.js → chunk-5FDLC6G7.js} +56 -3
- package/dist/chunk-5FDLC6G7.js.map +1 -0
- package/dist/chunk-5O7D6ZTW.js +53 -0
- package/dist/chunk-5O7D6ZTW.js.map +1 -0
- package/dist/{chunk-J6FXAEUG.js → chunk-6B3VNR4P.js} +12 -12
- package/dist/{chunk-TUFM4UZP.js → chunk-6K7DPM7D.js} +2 -2
- package/dist/{chunk-K6LHRFBL.js → chunk-6LMQ5R26.js} +7 -7
- package/dist/{chunk-SPXXX5E4.js → chunk-6LNL42F5.js} +94 -32
- package/dist/chunk-6LNL42F5.js.map +1 -0
- package/dist/{chunk-XLMEZIAJ.js → chunk-6OWXYZK2.js} +2 -2
- package/dist/{chunk-BOWNCWZT.js → chunk-6QSQQLSE.js} +3 -3
- package/dist/chunk-7JE7BDYJ.js +1558 -0
- package/dist/chunk-7JE7BDYJ.js.map +1 -0
- package/dist/{chunk-KG7TZKZG.js → chunk-7VCXZDA4.js} +5 -5
- package/dist/chunk-7VCXZDA4.js.map +1 -0
- package/dist/{chunk-NQKIUNW5.js → chunk-A6IJU4TK.js} +2 -2
- package/dist/{chunk-BM5TWITZ.js → chunk-ANWPSTZU.js} +38 -9
- package/dist/chunk-ANWPSTZU.js.map +1 -0
- package/dist/{chunk-QIZPZMUI.js → chunk-AOWGXU6D.js} +2 -2
- package/dist/{chunk-CUZLNGD5.js → chunk-B2YY6WDD.js} +1 -1
- package/dist/chunk-B2YY6WDD.js.map +1 -0
- package/dist/{chunk-SFAWCTEM.js → chunk-B57AFBY2.js} +2 -2
- package/dist/{chunk-GPEQUXHL.js → chunk-B6SJIBQK.js} +4 -4
- package/dist/chunk-BJ2IXQ5Q.js +100 -0
- package/dist/chunk-BJ2IXQ5Q.js.map +1 -0
- package/dist/{chunk-Q2PU57HC.js → chunk-BK2HHQGN.js} +2 -2
- package/dist/chunk-BKT776R5.js +1 -0
- package/dist/{chunk-KUX3OB6D.js → chunk-BP6DARYA.js} +33 -5
- package/dist/chunk-BP6DARYA.js.map +1 -0
- package/dist/{chunk-FXBIP2WD.js → chunk-BUDAGWL5.js} +6 -6
- package/dist/chunk-CF5UU4S7.js +757 -0
- package/dist/chunk-CF5UU4S7.js.map +1 -0
- package/dist/{chunk-BOET4NA4.js → chunk-CKNGS5MH.js} +3 -3
- package/dist/chunk-CY2CYVWZ.js +41 -0
- package/dist/chunk-CY2CYVWZ.js.map +1 -0
- package/dist/{chunk-2577DKXB.js → chunk-DC5QVPV7.js} +2 -2
- package/dist/chunk-DC5QVPV7.js.map +1 -0
- package/dist/{chunk-YSRUYAVU.js → chunk-DE4DH2RZ.js} +2 -2
- package/dist/{chunk-6I2RQCET.js → chunk-DF73H4UN.js} +4 -4
- package/dist/{chunk-4GVM6QZA.js → chunk-ENAG3IY7.js} +2 -2
- package/dist/chunk-ENAG3IY7.js.map +1 -0
- package/dist/{chunk-K7NTTA6P.js → chunk-EOVMT6TB.js} +2 -2
- package/dist/chunk-F24ZZTHQ.js +193 -0
- package/dist/chunk-F24ZZTHQ.js.map +1 -0
- package/dist/chunk-F2TDU7MQ.js +456 -0
- package/dist/chunk-F2TDU7MQ.js.map +1 -0
- package/dist/chunk-F6NCB7KT.js +13 -0
- package/dist/chunk-F6NCB7KT.js.map +1 -0
- package/dist/{chunk-SPYWXKJN.js → chunk-F7XGHL5O.js} +3 -3
- package/dist/chunk-F7XGHL5O.js.map +1 -0
- package/dist/{chunk-XTXOCYOJ.js → chunk-FCKWQE2H.js} +5 -5
- package/dist/{chunk-U4FOQDY4.js → chunk-FH2L2E34.js} +4 -4
- package/dist/chunk-FH2L2E34.js.map +1 -0
- package/dist/{chunk-4OZNXTO4.js → chunk-FN5EBVTQ.js} +2 -2
- package/dist/chunk-FQ54DWUQ.js +270 -0
- package/dist/chunk-FQ54DWUQ.js.map +1 -0
- package/dist/{chunk-NKHRDYOR.js → chunk-FQ5VRHIB.js} +4 -4
- package/dist/{chunk-FAHMLERK.js → chunk-FW22ZCXT.js} +2 -2
- package/dist/chunk-FXQBGFOX.js +524 -0
- package/dist/chunk-FXQBGFOX.js.map +1 -0
- package/dist/{chunk-AO42KJO6.js → chunk-GF5BZ7D4.js} +45 -9
- package/dist/chunk-GF5BZ7D4.js.map +1 -0
- package/dist/{chunk-TRGTKX5E.js → chunk-GHLTDZRS.js} +5 -3
- package/dist/{chunk-TRGTKX5E.js.map → chunk-GHLTDZRS.js.map} +1 -1
- package/dist/{chunk-5WDXHNSW.js → chunk-HBPPGWUM.js} +5 -5
- package/dist/chunk-HBPPGWUM.js.map +1 -0
- package/dist/{chunk-KTFRCC5C.js → chunk-HBRLNOHL.js} +82 -8
- package/dist/chunk-HBRLNOHL.js.map +1 -0
- package/dist/chunk-HLEK5VAN.js +275 -0
- package/dist/chunk-HLEK5VAN.js.map +1 -0
- package/dist/{chunk-RMS3NEA3.js → chunk-HT2AHGQI.js} +2 -2
- package/dist/{chunk-CHJBLCOG.js → chunk-HVSCEIYL.js} +7 -7
- package/dist/{chunk-UXWB3FPF.js → chunk-I3JDRCMW.js} +150 -22
- package/dist/chunk-I3JDRCMW.js.map +1 -0
- package/dist/{chunk-GY4WYNNG.js → chunk-ID6Z6E66.js} +2 -2
- package/dist/{chunk-EYBQEIUY.js → chunk-IEX7NK2K.js} +3 -3
- package/dist/{chunk-KUJDV5QH.js → chunk-ISZQJBML.js} +5 -5
- package/dist/{chunk-LWBCUYZW.js → chunk-IT22PWKV.js} +2 -2
- package/dist/{chunk-EQEYOJBM.js → chunk-IUWCVHQ7.js} +3 -3
- package/dist/chunk-IUWCVHQ7.js.map +1 -0
- package/dist/{chunk-7V4TP3AF.js → chunk-J6UOHJY5.js} +4 -4
- package/dist/{chunk-JMGDHKQF.js → chunk-JCN44NCY.js} +2 -2
- package/dist/{chunk-CARABLSQ.js → chunk-K6W7BVZ6.js} +3 -3
- package/dist/{chunk-77K4PG6P.js → chunk-KJFW62P4.js} +29 -11
- package/dist/chunk-KJFW62P4.js.map +1 -0
- package/dist/{chunk-453F654R.js → chunk-L7DOS3TE.js} +2 -2
- package/dist/chunk-LGNDFRYC.js +23 -0
- package/dist/chunk-LGNDFRYC.js.map +1 -0
- package/dist/{chunk-WEQEYLCS.js → chunk-LGRLME4M.js} +7 -7
- package/dist/{chunk-RMF67KCG.js → chunk-LQ4ZHOKP.js} +2 -2
- package/dist/{chunk-ZVO4QVPD.js → chunk-M522UYZ2.js} +5 -5
- package/dist/{chunk-G56KBWFY.js → chunk-M7NI3IWE.js} +45 -12
- package/dist/chunk-M7NI3IWE.js.map +1 -0
- package/dist/chunk-MDWKM2XC.js +293 -0
- package/dist/chunk-MDWKM2XC.js.map +1 -0
- package/dist/chunk-MKXXMNJH.js +204 -0
- package/dist/chunk-MKXXMNJH.js.map +1 -0
- package/dist/{chunk-SKGMN35F.js → chunk-MLPHLJIQ.js} +3 -3
- package/dist/chunk-MLPHLJIQ.js.map +1 -0
- package/dist/{chunk-2N4GY74U.js → chunk-MTL7MXGR.js} +6 -6
- package/dist/{chunk-TFR7DSOV.js → chunk-MVZ2TPVP.js} +2 -2
- package/dist/{chunk-CPWQB3N5.js → chunk-N5DNADLQ.js} +7 -7
- package/dist/{chunk-ELNXJMGB.js → chunk-NNARWO72.js} +6 -6
- package/dist/{chunk-PT43Y56J.js → chunk-NRT6QZQB.js} +102 -16
- package/dist/chunk-NRT6QZQB.js.map +1 -0
- package/dist/{chunk-QIBVIOXO.js → chunk-NWHBJQAL.js} +99 -8
- package/dist/chunk-NWHBJQAL.js.map +1 -0
- package/dist/chunk-NYMLINRP.js +28 -0
- package/dist/chunk-NYMLINRP.js.map +1 -0
- package/dist/{chunk-7MG7SJT7.js → chunk-ODVPTDPK.js} +1 -1
- package/dist/chunk-ODVPTDPK.js.map +1 -0
- package/dist/chunk-ORDURZBU.js +461 -0
- package/dist/chunk-ORDURZBU.js.map +1 -0
- package/dist/{chunk-6YXCPL4T.js → chunk-PDCG6PR5.js} +2 -2
- package/dist/{chunk-REDOOY2Q.js → chunk-PSIV7CJV.js} +2 -2
- package/dist/{chunk-NA2NIJZI.js → chunk-QBBUZ3I3.js} +126 -19
- package/dist/chunk-QBBUZ3I3.js.map +1 -0
- package/dist/{chunk-5VCRVKOZ.js → chunk-QOOUUR4A.js} +6 -4
- package/dist/{chunk-5VCRVKOZ.js.map → chunk-QOOUUR4A.js.map} +1 -1
- package/dist/{chunk-ANATMFIO.js → chunk-QWFHIOD2.js} +5 -5
- package/dist/{chunk-X2DLENDQ.js → chunk-QWGU66MP.js} +3 -3
- package/dist/chunk-RHVMZSUU.js +7 -0
- package/dist/chunk-RHVMZSUU.js.map +1 -0
- package/dist/{chunk-BSFNRLK2.js → chunk-S57HTZ6X.js} +5 -5
- package/dist/{chunk-SZJ3DLZA.js → chunk-SEE332EV.js} +2 -2
- package/dist/{chunk-YYP7WSEB.js → chunk-SI3V7D4G.js} +2 -2
- package/dist/{chunk-UGTBXF5U.js → chunk-SOIQ4MM4.js} +3 -3
- package/dist/chunk-SUZKW6UR.js +25 -0
- package/dist/chunk-SUZKW6UR.js.map +1 -0
- package/dist/{chunk-VXGSWL6L.js → chunk-SYVZW77S.js} +6 -6
- package/dist/{chunk-6GOE5PGN.js → chunk-T2LBQ5DV.js} +883 -227
- package/dist/chunk-T2LBQ5DV.js.map +1 -0
- package/dist/chunk-T52GX4SA.js +215 -0
- package/dist/chunk-T52GX4SA.js.map +1 -0
- package/dist/{chunk-MVMXZYXT.js → chunk-TKUOEU2F.js} +2 -2
- package/dist/chunk-TOPYQ6GA.js +31 -0
- package/dist/chunk-TOPYQ6GA.js.map +1 -0
- package/dist/{chunk-SMH6SRX7.js → chunk-TROR3ALR.js} +2 -2
- package/dist/{chunk-2C3AQB46.js → chunk-UD5EVGZ7.js} +42 -389
- package/dist/chunk-UD5EVGZ7.js.map +1 -0
- package/dist/{chunk-KJIMGIWO.js → chunk-UPD5NWI5.js} +65 -17
- package/dist/chunk-UPD5NWI5.js.map +1 -0
- package/dist/{chunk-SL3JAAKN.js → chunk-UYB234ZR.js} +30 -2
- package/dist/chunk-UYB234ZR.js.map +1 -0
- package/dist/chunk-VHM7HCKB.js +220 -0
- package/dist/chunk-VHM7HCKB.js.map +1 -0
- package/dist/{chunk-DGOZ4UZD.js → chunk-VNNRUGMM.js} +2 -2
- package/dist/{chunk-HDOU6I2Y.js → chunk-VNPEWFPD.js} +4 -4
- package/dist/{chunk-L7CIOOBW.js → chunk-WNJ4AVGE.js} +2 -2
- package/dist/{chunk-FMZY5Q6L.js → chunk-WX5ADGTZ.js} +3 -3
- package/dist/{chunk-VXANTWBJ.js → chunk-WY2XXTET.js} +92 -6
- package/dist/{chunk-VXANTWBJ.js.map → chunk-WY2XXTET.js.map} +1 -1
- package/dist/{chunk-6X6SEMEE.js → chunk-X25NWUZB.js} +33 -8
- package/dist/chunk-X25NWUZB.js.map +1 -0
- package/dist/{chunk-Q7HZX3IF.js → chunk-X4773RBR.js} +2 -2
- package/dist/chunk-XBKH4FOC.js +195 -0
- package/dist/chunk-XBKH4FOC.js.map +1 -0
- package/dist/{chunk-ANSIZYEG.js → chunk-YNIUIERI.js} +3 -3
- package/dist/chunk-YSK2CU2Q.js +936 -0
- package/dist/chunk-YSK2CU2Q.js.map +1 -0
- package/dist/{chunk-UXVWEX5L.js → chunk-Z5HTYMMQ.js} +6 -2
- package/dist/chunk-Z5HTYMMQ.js.map +1 -0
- package/dist/{chunk-RRNRNANG.js → chunk-ZE4CHIED.js} +66 -75
- package/dist/chunk-ZE4CHIED.js.map +1 -0
- package/dist/chunk-ZSX4S5XB.js +1289 -0
- package/dist/chunk-ZSX4S5XB.js.map +1 -0
- package/dist/{chunk-BZ3534YM.js → chunk-ZUVBC32X.js} +2 -2
- package/dist/{chunk-L742JPKZ.js → chunk-ZXABPVM6.js} +6 -6
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-LI2SF2E4.js → classified-marker-W3USLL5M.js} +3 -3
- package/dist/collection-facade-QU6IJBN3.js +48 -0
- package/dist/{computed-VPOKQK4N.js → computed-TPFBX7U4.js} +3 -3
- package/dist/consent/index.js +9 -9
- package/dist/cover/index.js +10 -10
- package/dist/coverage/index.js +306 -0
- package/dist/coverage/index.js.map +1 -0
- package/dist/custody/index.js +12 -12
- package/dist/{dead-filter-TSWZQRR5.js → dead-filter-U2UYKSZL.js} +2 -2
- package/dist/debug/index.js +1 -1
- package/dist/{delegation-OVIFFPG4.js → delegation-S3AEPW2T.js} +11 -11
- package/dist/derivations/index.js +25 -22
- package/dist/derive-OX7F6TGG.js +21 -0
- package/dist/directory/index.js +10 -10
- package/dist/{dispatch-WC6X2M6C.js → dispatch-3CQDJV5Q.js} +5 -5
- package/dist/{dispatch-S73TK3IY.js → dispatch-RH4LHKBH.js} +21 -21
- package/dist/{enclave-KJOTOH7X.js → enclave-27SMF6GF.js} +15 -9
- package/dist/executor-B6SRO2QS.js +36 -0
- package/dist/executor-BI5CHWRY.js +8 -0
- package/dist/executor-RBKM5W5K.js +8 -0
- package/dist/export-accessible-VMA3YM5V.js +22 -0
- package/dist/extract-partition-NF7PXGPP.js +37 -0
- package/dist/{fanout-sidecar-WUFXNYP4.js → fanout-sidecar-OT6RYLOL.js} +9 -9
- package/dist/find-LZMP26KF.js +10 -0
- package/dist/forget/index.js +9 -9
- package/dist/guards/index.js +4 -4
- package/dist/history/index.js +13 -13
- package/dist/i18n/index.js +14 -14
- package/dist/index.d.ts +29 -6
- package/dist/index.js +999 -191
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +13 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/introspection/index.js +11 -11
- package/dist/issue-IHARXWW5.js +18 -0
- package/dist/ivf-flat-UZ6DQDLS.js +314 -0
- package/dist/ivf-flat-UZ6DQDLS.js.map +1 -0
- package/dist/{json-schema-V3M5MUCM.js → json-schema-3SHX72CC.js} +2 -1
- package/dist/json-schema-3SHX72CC.js.map +1 -0
- package/dist/kernel/collection-config.d.ts +4 -20
- package/dist/kernel/collection.d.ts +29 -8
- package/dist/kernel/enclave/crypto.d.ts +16 -0
- package/dist/kernel/enclave/index.d.ts +1 -1
- package/dist/kernel/enclave/record-keys/record-codec.d.ts +25 -0
- package/dist/kernel/errors.d.ts +227 -36
- package/dist/kernel/generation-map.d.ts +48 -0
- package/dist/kernel/memory-store.d.ts +35 -7
- package/dist/kernel/noydb.d.ts +6 -1
- package/dist/kernel/present-cache.d.ts +58 -0
- package/dist/kernel/query/all.d.ts +7 -0
- package/dist/kernel/query/builder.d.ts +601 -270
- package/dist/kernel/query/civil-date.d.ts +64 -0
- package/dist/kernel/query/cursor.d.ts +40 -0
- package/dist/kernel/query/distinct-key.d.ts +98 -0
- package/dist/kernel/query/hydration.d.ts +76 -0
- package/dist/kernel/query/index.d.ts +31 -15
- package/dist/kernel/query/internal/core.d.ts +30 -0
- package/dist/kernel/query/internal/hooks.d.ts +22 -0
- package/dist/kernel/query/internal/maintenance.d.ts +43 -0
- package/dist/kernel/query/live/incremental.d.ts +314 -0
- package/dist/kernel/query/live/index.d.ts +22 -0
- package/dist/kernel/query/live/install.d.ts +2 -0
- package/dist/kernel/query/{live.d.ts → live/live.d.ts} +39 -9
- package/dist/kernel/query/live/methods.d.ts +107 -0
- package/dist/kernel/query/predicate.d.ts +119 -1
- package/dist/kernel/query/reduce/date-trunc.d.ts +75 -0
- package/dist/kernel/query/reduce/index.d.ts +36 -0
- package/dist/kernel/query/reduce/install.d.ts +2 -0
- package/dist/kernel/query/reduce/methods.d.ts +259 -0
- package/dist/kernel/query/reduce/scan-methods.d.ts +121 -0
- package/dist/kernel/query/relate/explain.d.ts +199 -0
- package/dist/kernel/query/relate/index.d.ts +48 -0
- package/dist/kernel/query/relate/install.d.ts +2 -0
- package/dist/kernel/query/relate/join-on.d.ts +126 -0
- package/dist/kernel/query/relate/join-reduce.d.ts +16 -0
- package/dist/kernel/query/relate/join.d.ts +452 -0
- package/dist/kernel/query/relate/methods.d.ts +426 -0
- package/dist/kernel/query/relate/partition.d.ts +87 -0
- package/dist/kernel/query/relate/scan-methods.d.ts +163 -0
- package/dist/kernel/query/relate/traverse.d.ts +109 -0
- package/dist/kernel/query/scan-builder.d.ts +79 -176
- package/dist/kernel/query/sort-key.d.ts +52 -0
- package/dist/kernel/tx-write-gate.d.ts +77 -0
- package/dist/kernel/types.d.ts +71 -3
- package/dist/kernel/validation.d.ts +27 -10
- package/dist/kernel/vault.d.ts +9 -4
- package/dist/kernel/via/compose.d.ts +3 -0
- package/dist/kernel/via/index.d.ts +56 -0
- package/dist/kernel/via/pipeline.d.ts +48 -0
- package/dist/{ledger-F33ZVMTK.js → ledger-KZPCMVZY.js} +11 -11
- package/dist/liberate-GRLCZMW4.js +24 -0
- package/dist/link-set-JCMJ7ULP.js +30 -0
- package/dist/{managed-secret-PQYKSR6T.js → managed-secret-S3MQ6SH6.js} +10 -10
- package/dist/materialized-views/index.js +30 -23
- package/dist/{migrate-cek-5ENH64AA.js → migrate-cek-V7GKJZ7O.js} +2 -2
- package/dist/money/index.js +5 -5
- package/dist/noydb-SWQJ3MZS.js +97 -0
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +12 -12
- package/dist/pod/index.js +75 -68
- package/dist/{pod-handle-Q736KYON.js → pod-handle-WGDFB4C2.js} +9 -9
- package/dist/policy/index.js +10 -10
- package/dist/port/with/blob-strategy.d.ts +9 -0
- package/dist/port/with/collection-options.d.ts +5 -0
- package/dist/port/with/coverage-strategy.d.ts +83 -0
- package/dist/port/with/service-bus.d.ts +46 -0
- package/dist/port/with/strategies.d.ts +2 -0
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-LNE2FE2A.js → post-register-SLSXIPBV.js} +6 -6
- package/dist/query/all/index.js +31 -0
- package/dist/query/index.js +20 -32
- package/dist/query/live/index.js +21 -0
- package/dist/query/live/index.js.map +1 -0
- package/dist/query/reduce/index.js +33 -0
- package/dist/query/reduce/index.js.map +1 -0
- package/dist/query/relate/index.js +56 -0
- package/dist/query/relate/index.js.map +1 -0
- package/dist/reduce/index.js +72 -18
- package/dist/reduce/index.js.map +1 -1
- package/dist/register-F3OYE7MJ.js +31 -0
- package/dist/registry-CILQFXFK.js +8 -0
- package/dist/registry-XNNYQVKV.js +8 -0
- package/dist/registry-YCDZV3VW.js +35 -0
- package/dist/registry-ZGYS33TE.js +24 -0
- package/dist/request-withdrawal-Z5NC6TXT.js +30 -0
- package/dist/{reveal-67RDQRIN.js → reveal-4BCKPEC2.js} +6 -6
- package/dist/revoke-ZL62WC2D.js +23 -0
- package/dist/satellites/index.js +1 -1
- package/dist/schema-update/index.js +2 -2
- package/dist/sealed-record/index.js +12 -12
- package/dist/search/index.js +11 -5
- package/dist/{seed-G42JYN56.js → seed-4JS2RJ4A.js} +12 -12
- package/dist/sequence/index.js +9 -9
- package/dist/session/index.js +9 -9
- package/dist/shadow/index.js +2 -2
- package/dist/signer-MBZZMXTC.js +24 -0
- package/dist/snapshots/index.js +10 -10
- package/dist/{stale-DDL7WQEZ.js → stale-TJ3DYZMQ.js} +10 -10
- package/dist/storage-SVMKRGCW.js +22 -0
- package/dist/{store-coordination-provider-MEQ2MJQG.js → store-coordination-provider-2O2VUHKW.js} +10 -10
- package/dist/sync/index.js +10 -10
- package/dist/team/index.js +17 -15
- package/dist/tiers/index.js +13 -11
- package/dist/to/index.js +2 -2
- package/dist/transactions/index.js +3 -3
- package/dist/util/index.js +1 -1
- package/dist/vault-head/index.js +8 -8
- package/dist/{verify-KOV2G5D6.js → verify-RVT67IMH.js} +5 -5
- package/dist/via/blob/index.d.ts +1 -0
- package/dist/via/geo/binding.d.ts +31 -0
- package/dist/via/geo/descriptor.d.ts +54 -0
- package/dist/via/geo/geohash.d.ts +95 -0
- package/dist/via/geo/index.d.ts +13 -0
- package/dist/via/geo/where.d.ts +50 -0
- package/dist/via/i18n/core.d.ts +1 -1
- package/dist/via/lookup/registry.d.ts +1 -1
- package/dist/via/lookup/snapshot.d.ts +3 -3
- package/dist/walk-HJ42EISE.js +21 -0
- package/dist/walk-HJ42EISE.js.map +1 -0
- package/dist/with-audit/coverage/accounting.d.ts +112 -0
- package/dist/with-audit/coverage/active.d.ts +29 -0
- package/dist/with-audit/coverage/index.d.ts +61 -0
- package/dist/with-audit/coverage/sketch.d.ts +75 -0
- package/dist/with-audit/periods/periods.d.ts +55 -7
- package/dist/with-audit/periods/reserved-collections.d.ts +3 -0
- package/dist/with-audit/periods/vault-facade.d.ts +17 -0
- package/dist/with-audit/tiers/index.d.ts +51 -0
- package/dist/with-audit/tiers/strategy.d.ts +8 -0
- package/dist/with-cargo/floor.d.ts +2 -2
- package/dist/with-commit/tx/invariants.d.ts +1 -1
- package/dist/with-commit/tx/transaction.d.ts +13 -3
- package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -3
- package/dist/with-formula/materialized-views/emit-memo.d.ts +40 -0
- package/dist/with-formula/materialized-views/executor.d.ts +8 -0
- package/dist/with-formula/materialized-views/index.d.ts +1 -1
- package/dist/with-formula/materialized-views/registry.d.ts +15 -0
- package/dist/with-formula/materialized-views/types.d.ts +106 -14
- package/dist/with-formula/materialized-views/window-stage.d.ts +11 -0
- package/dist/with-formula/overlay-views/types.d.ts +1 -1
- package/dist/with-formula/overlay-views/virtual-collection.d.ts +13 -4
- package/dist/with-lookup/embeddings/chunks.d.ts +79 -0
- package/dist/with-lookup/embeddings/descriptor.d.ts +21 -0
- package/dist/with-lookup/embeddings/index.d.ts +3 -0
- package/dist/with-lookup/embeddings/ivf-flat.d.ts +93 -0
- package/dist/with-lookup/embeddings/vector-index.d.ts +73 -0
- package/dist/with-lookup/embeddings/vector-set.d.ts +94 -1
- package/dist/with-lookup/embeddings/with-vector-index.d.ts +67 -0
- package/dist/with-lookup/indexing/collection-facade.d.ts +85 -2
- package/dist/with-lookup/indexing/compound-indexes.d.ts +129 -0
- package/dist/with-lookup/indexing/eager-indexes.d.ts +170 -1
- package/dist/with-lookup/indexing/index-snapshot.d.ts +62 -0
- package/dist/with-lookup/indexing/lazy-builder.d.ts +33 -0
- package/dist/with-lookup/indexing/persisted-field-indexes.d.ts +104 -0
- package/dist/with-lookup/indexing/persisted-indexes.d.ts +12 -0
- package/dist/with-lookup/indexing/sorted-indexes.d.ts +117 -0
- package/dist/with-lookup/indexing/unique-constraints.d.ts +106 -23
- package/dist/with-lookup/reduce/active.d.ts +2 -24
- package/dist/with-lookup/reduce/group-core.d.ts +43 -0
- package/dist/with-lookup/reduce/groupby.d.ts +195 -36
- package/dist/with-lookup/reduce/incremental-group.d.ts +153 -0
- package/dist/with-lookup/reduce/index.d.ts +26 -5
- package/dist/with-lookup/reduce/reducers.d.ts +255 -1
- package/dist/with-lookup/reduce/reduction.d.ts +44 -13
- package/dist/with-lookup/reduce/strategy.d.ts +43 -3
- package/dist/with-lookup/reduce/window.d.ts +262 -0
- package/dist/with-lookup/search/collection-facade.d.ts +44 -8
- package/dist/with-lookup/search/index-store.d.ts +5 -3
- package/dist/with-lookup/search/index.d.ts +4 -2
- package/dist/with-lookup/search/inverted-index.d.ts +38 -2
- package/dist/with-lookup/search/persisted-index-store.d.ts +5 -2
- package/dist/with-lookup/search/phrase.d.ts +28 -0
- package/dist/with-lookup/search/retrieve-types.d.ts +57 -1
- package/dist/with-lookup/search/serialize.d.ts +29 -3
- package/dist/with-lookup/search/strategy.d.ts +2 -6
- package/dist/with-party/directory/cover/index.d.ts +1 -1
- package/dist/with-party/directory/cover/storage.d.ts +1 -1
- package/dist/with-party/directory/cover/types.d.ts +1 -1
- package/dist/with-party/directory/index.d.ts +1 -1
- package/dist/with-party/directory/types.d.ts +1 -1
- package/dist/with-party/directory/user-envelope/api.d.ts +1 -1
- package/dist/with-party/policy/engine.d.ts +1 -1
- package/dist/with-party/policy/index.d.ts +1 -1
- package/dist/with-party/policy/presets.d.ts +1 -1
- package/dist/with-party/team/authenticators.d.ts +91 -1
- package/dist/with-party/team/index.d.ts +3 -2
- package/dist/with-party/team/keyring.d.ts +13 -6
- package/dist/with-party/team/managed-secret.d.ts +1 -1
- package/dist/with-party/team/noydb-facade.d.ts +12 -3
- package/dist/with-party/team/wrapped-deks.d.ts +4 -4
- package/dist/with-pod/format.d.ts +1 -1
- package/dist/with-pod/pod.d.ts +5 -5
- package/dist/with-shape/blobs/blob-compaction.d.ts +16 -0
- package/dist/with-shape/blobs/blob-set.d.ts +21 -2
- package/dist/with-shape/blobs/legacy-sweep.d.ts +35 -0
- package/dist/with-shape/introspection/describe.d.ts +6 -0
- package/dist/with-shape/introspection/field-meta.d.ts +18 -0
- package/dist/with-shape/introspection/types.d.ts +57 -1
- package/dist/with-shape/links/vault-facade.d.ts +1 -1
- package/dist/with-store/partitioned/index.d.ts +337 -0
- package/dist/with-sync/change-broadcast.d.ts +153 -0
- package/dist/withdraw-accessible-5NZUPAVA.js +27 -0
- package/dist/withdraw-accessible-5NZUPAVA.js.map +1 -0
- package/package.json +37 -10
- package/dist/api-TXFOVOXX.js +0 -19
- package/dist/backup-IJTB4S4M.js.map +0 -1
- package/dist/chunk-2577DKXB.js.map +0 -1
- package/dist/chunk-2C3AQB46.js.map +0 -1
- package/dist/chunk-4GVM6QZA.js.map +0 -1
- package/dist/chunk-5WDXHNSW.js.map +0 -1
- package/dist/chunk-6GOE5PGN.js.map +0 -1
- package/dist/chunk-6X6SEMEE.js.map +0 -1
- package/dist/chunk-77K4PG6P.js.map +0 -1
- package/dist/chunk-7MG2LHO5.js +0 -1616
- package/dist/chunk-7MG2LHO5.js.map +0 -1
- package/dist/chunk-7MG7SJT7.js.map +0 -1
- package/dist/chunk-7O3Y4PPD.js.map +0 -1
- package/dist/chunk-AO42KJO6.js.map +0 -1
- package/dist/chunk-ATL3ZVXT.js +0 -151
- package/dist/chunk-ATL3ZVXT.js.map +0 -1
- package/dist/chunk-BLN54W3L.js.map +0 -1
- package/dist/chunk-BM5TWITZ.js.map +0 -1
- package/dist/chunk-CUZLNGD5.js.map +0 -1
- package/dist/chunk-EQEYOJBM.js.map +0 -1
- package/dist/chunk-G56KBWFY.js.map +0 -1
- package/dist/chunk-I3ISCYT7.js +0 -159
- package/dist/chunk-I3ISCYT7.js.map +0 -1
- package/dist/chunk-KG7TZKZG.js.map +0 -1
- package/dist/chunk-KJIMGIWO.js.map +0 -1
- package/dist/chunk-KTFRCC5C.js.map +0 -1
- package/dist/chunk-KUX3OB6D.js.map +0 -1
- package/dist/chunk-MUM7IANK.js.map +0 -1
- package/dist/chunk-NA2NIJZI.js.map +0 -1
- package/dist/chunk-NSITFOCJ.js +0 -99
- package/dist/chunk-NSITFOCJ.js.map +0 -1
- package/dist/chunk-PT43Y56J.js.map +0 -1
- package/dist/chunk-QIBVIOXO.js.map +0 -1
- package/dist/chunk-RRNRNANG.js.map +0 -1
- package/dist/chunk-RTBJ5IOO.js +0 -87
- package/dist/chunk-RTBJ5IOO.js.map +0 -1
- package/dist/chunk-SKGMN35F.js.map +0 -1
- package/dist/chunk-SL3JAAKN.js.map +0 -1
- package/dist/chunk-SPXXX5E4.js.map +0 -1
- package/dist/chunk-SPYWXKJN.js.map +0 -1
- package/dist/chunk-U4FOQDY4.js.map +0 -1
- package/dist/chunk-UXVWEX5L.js.map +0 -1
- package/dist/chunk-UXWB3FPF.js.map +0 -1
- package/dist/chunk-YMUFFJCO.js.map +0 -1
- package/dist/chunk-ZN4FD4PE.js +0 -364
- package/dist/chunk-ZN4FD4PE.js.map +0 -1
- package/dist/chunk-ZORTV6NH.js.map +0 -1
- package/dist/collection-facade-4GRREZ6C.js +0 -45
- package/dist/derive-6O5SWQKN.js +0 -21
- package/dist/executor-5NIMLSKZ.js +0 -8
- package/dist/executor-AQVXV5GZ.js +0 -8
- package/dist/executor-PUAO6AKJ.js +0 -29
- package/dist/export-accessible-72EQNBMR.js +0 -22
- package/dist/extract-partition-PUYNU3UF.js +0 -37
- package/dist/find-2ABFCZX4.js +0 -10
- package/dist/issue-SIDORTSZ.js +0 -18
- package/dist/json-schema-V3M5MUCM.js.map +0 -1
- package/dist/kernel/query/join.d.ts +0 -232
- package/dist/liberate-LCDPNAG2.js +0 -24
- package/dist/link-set-FKNWAYKS.js +0 -30
- package/dist/noydb-DUXZPKSN.js +0 -90
- package/dist/register-I2DZXGAR.js +0 -31
- package/dist/registry-23WF3TGH.js +0 -8
- package/dist/registry-4AYVUNXK.js +0 -8
- package/dist/registry-VSSQPIGF.js +0 -18
- package/dist/registry-YLEWMGAC.js +0 -32
- package/dist/request-withdrawal-KFQHEZ25.js +0 -30
- package/dist/revoke-DQDZAZZM.js +0 -23
- package/dist/signer-WAMDZHEN.js +0 -24
- package/dist/storage-FLR73HHF.js +0 -22
- package/dist/walk-3UQBRMDV.js +0 -21
- package/dist/withdraw-accessible-EL5GXZBS.js +0 -27
- /package/dist/{api-TXFOVOXX.js.map → api-GVYEKSJE.js.map} +0 -0
- /package/dist/{chunk-BUE2D7PX.js.map → chunk-32YV3TJT.js.map} +0 -0
- /package/dist/{chunk-3RCJJBNR.js.map → chunk-3ELRMVJK.js.map} +0 -0
- /package/dist/{chunk-6GMZ7HEE.js.map → chunk-3F7GLNAE.js.map} +0 -0
- /package/dist/{chunk-2Y4IMKA6.js.map → chunk-3H5KLDZN.js.map} +0 -0
- /package/dist/{chunk-VTFVLCUH.js.map → chunk-3JWHAR6E.js.map} +0 -0
- /package/dist/{chunk-JBDFMYKQ.js.map → chunk-4AF3TUMP.js.map} +0 -0
- /package/dist/{chunk-J6FXAEUG.js.map → chunk-6B3VNR4P.js.map} +0 -0
- /package/dist/{chunk-TUFM4UZP.js.map → chunk-6K7DPM7D.js.map} +0 -0
- /package/dist/{chunk-K6LHRFBL.js.map → chunk-6LMQ5R26.js.map} +0 -0
- /package/dist/{chunk-XLMEZIAJ.js.map → chunk-6OWXYZK2.js.map} +0 -0
- /package/dist/{chunk-BOWNCWZT.js.map → chunk-6QSQQLSE.js.map} +0 -0
- /package/dist/{chunk-NQKIUNW5.js.map → chunk-A6IJU4TK.js.map} +0 -0
- /package/dist/{chunk-QIZPZMUI.js.map → chunk-AOWGXU6D.js.map} +0 -0
- /package/dist/{chunk-SFAWCTEM.js.map → chunk-B57AFBY2.js.map} +0 -0
- /package/dist/{chunk-GPEQUXHL.js.map → chunk-B6SJIBQK.js.map} +0 -0
- /package/dist/{chunk-Q2PU57HC.js.map → chunk-BK2HHQGN.js.map} +0 -0
- /package/dist/{collection-facade-4GRREZ6C.js.map → chunk-BKT776R5.js.map} +0 -0
- /package/dist/{chunk-FXBIP2WD.js.map → chunk-BUDAGWL5.js.map} +0 -0
- /package/dist/{chunk-BOET4NA4.js.map → chunk-CKNGS5MH.js.map} +0 -0
- /package/dist/{chunk-YSRUYAVU.js.map → chunk-DE4DH2RZ.js.map} +0 -0
- /package/dist/{chunk-6I2RQCET.js.map → chunk-DF73H4UN.js.map} +0 -0
- /package/dist/{chunk-K7NTTA6P.js.map → chunk-EOVMT6TB.js.map} +0 -0
- /package/dist/{chunk-XTXOCYOJ.js.map → chunk-FCKWQE2H.js.map} +0 -0
- /package/dist/{chunk-4OZNXTO4.js.map → chunk-FN5EBVTQ.js.map} +0 -0
- /package/dist/{chunk-NKHRDYOR.js.map → chunk-FQ5VRHIB.js.map} +0 -0
- /package/dist/{chunk-FAHMLERK.js.map → chunk-FW22ZCXT.js.map} +0 -0
- /package/dist/{chunk-RMS3NEA3.js.map → chunk-HT2AHGQI.js.map} +0 -0
- /package/dist/{chunk-CHJBLCOG.js.map → chunk-HVSCEIYL.js.map} +0 -0
- /package/dist/{chunk-GY4WYNNG.js.map → chunk-ID6Z6E66.js.map} +0 -0
- /package/dist/{chunk-EYBQEIUY.js.map → chunk-IEX7NK2K.js.map} +0 -0
- /package/dist/{chunk-KUJDV5QH.js.map → chunk-ISZQJBML.js.map} +0 -0
- /package/dist/{chunk-LWBCUYZW.js.map → chunk-IT22PWKV.js.map} +0 -0
- /package/dist/{chunk-7V4TP3AF.js.map → chunk-J6UOHJY5.js.map} +0 -0
- /package/dist/{chunk-JMGDHKQF.js.map → chunk-JCN44NCY.js.map} +0 -0
- /package/dist/{chunk-CARABLSQ.js.map → chunk-K6W7BVZ6.js.map} +0 -0
- /package/dist/{chunk-453F654R.js.map → chunk-L7DOS3TE.js.map} +0 -0
- /package/dist/{chunk-WEQEYLCS.js.map → chunk-LGRLME4M.js.map} +0 -0
- /package/dist/{chunk-RMF67KCG.js.map → chunk-LQ4ZHOKP.js.map} +0 -0
- /package/dist/{chunk-ZVO4QVPD.js.map → chunk-M522UYZ2.js.map} +0 -0
- /package/dist/{chunk-2N4GY74U.js.map → chunk-MTL7MXGR.js.map} +0 -0
- /package/dist/{chunk-TFR7DSOV.js.map → chunk-MVZ2TPVP.js.map} +0 -0
- /package/dist/{chunk-CPWQB3N5.js.map → chunk-N5DNADLQ.js.map} +0 -0
- /package/dist/{chunk-ELNXJMGB.js.map → chunk-NNARWO72.js.map} +0 -0
- /package/dist/{chunk-6YXCPL4T.js.map → chunk-PDCG6PR5.js.map} +0 -0
- /package/dist/{chunk-REDOOY2Q.js.map → chunk-PSIV7CJV.js.map} +0 -0
- /package/dist/{chunk-ANATMFIO.js.map → chunk-QWFHIOD2.js.map} +0 -0
- /package/dist/{chunk-X2DLENDQ.js.map → chunk-QWGU66MP.js.map} +0 -0
- /package/dist/{chunk-BSFNRLK2.js.map → chunk-S57HTZ6X.js.map} +0 -0
- /package/dist/{chunk-SZJ3DLZA.js.map → chunk-SEE332EV.js.map} +0 -0
- /package/dist/{chunk-YYP7WSEB.js.map → chunk-SI3V7D4G.js.map} +0 -0
- /package/dist/{chunk-UGTBXF5U.js.map → chunk-SOIQ4MM4.js.map} +0 -0
- /package/dist/{chunk-VXGSWL6L.js.map → chunk-SYVZW77S.js.map} +0 -0
- /package/dist/{chunk-MVMXZYXT.js.map → chunk-TKUOEU2F.js.map} +0 -0
- /package/dist/{chunk-SMH6SRX7.js.map → chunk-TROR3ALR.js.map} +0 -0
- /package/dist/{chunk-DGOZ4UZD.js.map → chunk-VNNRUGMM.js.map} +0 -0
- /package/dist/{chunk-HDOU6I2Y.js.map → chunk-VNPEWFPD.js.map} +0 -0
- /package/dist/{chunk-L7CIOOBW.js.map → chunk-WNJ4AVGE.js.map} +0 -0
- /package/dist/{chunk-FMZY5Q6L.js.map → chunk-WX5ADGTZ.js.map} +0 -0
- /package/dist/{chunk-Q7HZX3IF.js.map → chunk-X4773RBR.js.map} +0 -0
- /package/dist/{chunk-ANSIZYEG.js.map → chunk-YNIUIERI.js.map} +0 -0
- /package/dist/{chunk-BZ3534YM.js.map → chunk-ZUVBC32X.js.map} +0 -0
- /package/dist/{chunk-L742JPKZ.js.map → chunk-ZXABPVM6.js.map} +0 -0
- /package/dist/{classified-marker-LI2SF2E4.js.map → classified-marker-W3USLL5M.js.map} +0 -0
- /package/dist/{computed-VPOKQK4N.js.map → collection-facade-QU6IJBN3.js.map} +0 -0
- /package/dist/{derive-6O5SWQKN.js.map → computed-TPFBX7U4.js.map} +0 -0
- /package/dist/{dead-filter-TSWZQRR5.js.map → dead-filter-U2UYKSZL.js.map} +0 -0
- /package/dist/{delegation-OVIFFPG4.js.map → delegation-S3AEPW2T.js.map} +0 -0
- /package/dist/{enclave-KJOTOH7X.js.map → derive-OX7F6TGG.js.map} +0 -0
- /package/dist/{dispatch-WC6X2M6C.js.map → dispatch-3CQDJV5Q.js.map} +0 -0
- /package/dist/{dispatch-S73TK3IY.js.map → dispatch-RH4LHKBH.js.map} +0 -0
- /package/dist/{executor-5NIMLSKZ.js.map → enclave-27SMF6GF.js.map} +0 -0
- /package/dist/{executor-AQVXV5GZ.js.map → executor-B6SRO2QS.js.map} +0 -0
- /package/dist/{executor-PUAO6AKJ.js.map → executor-BI5CHWRY.js.map} +0 -0
- /package/dist/{export-accessible-72EQNBMR.js.map → executor-RBKM5W5K.js.map} +0 -0
- /package/dist/{extract-partition-PUYNU3UF.js.map → export-accessible-VMA3YM5V.js.map} +0 -0
- /package/dist/{find-2ABFCZX4.js.map → extract-partition-NF7PXGPP.js.map} +0 -0
- /package/dist/{fanout-sidecar-WUFXNYP4.js.map → fanout-sidecar-OT6RYLOL.js.map} +0 -0
- /package/dist/{issue-SIDORTSZ.js.map → find-LZMP26KF.js.map} +0 -0
- /package/dist/{ledger-F33ZVMTK.js.map → issue-IHARXWW5.js.map} +0 -0
- /package/dist/{liberate-LCDPNAG2.js.map → ledger-KZPCMVZY.js.map} +0 -0
- /package/dist/{link-set-FKNWAYKS.js.map → liberate-GRLCZMW4.js.map} +0 -0
- /package/dist/{managed-secret-PQYKSR6T.js.map → link-set-JCMJ7ULP.js.map} +0 -0
- /package/dist/{noydb-DUXZPKSN.js.map → managed-secret-S3MQ6SH6.js.map} +0 -0
- /package/dist/{migrate-cek-5ENH64AA.js.map → migrate-cek-V7GKJZ7O.js.map} +0 -0
- /package/dist/{register-I2DZXGAR.js.map → noydb-SWQJ3MZS.js.map} +0 -0
- /package/dist/{pod-handle-Q736KYON.js.map → pod-handle-WGDFB4C2.js.map} +0 -0
- /package/dist/{post-register-LNE2FE2A.js.map → post-register-SLSXIPBV.js.map} +0 -0
- /package/dist/{registry-23WF3TGH.js.map → query/all/index.js.map} +0 -0
- /package/dist/{registry-4AYVUNXK.js.map → register-F3OYE7MJ.js.map} +0 -0
- /package/dist/{registry-VSSQPIGF.js.map → registry-CILQFXFK.js.map} +0 -0
- /package/dist/{registry-YLEWMGAC.js.map → registry-XNNYQVKV.js.map} +0 -0
- /package/dist/{request-withdrawal-KFQHEZ25.js.map → registry-YCDZV3VW.js.map} +0 -0
- /package/dist/{revoke-DQDZAZZM.js.map → registry-ZGYS33TE.js.map} +0 -0
- /package/dist/{signer-WAMDZHEN.js.map → request-withdrawal-Z5NC6TXT.js.map} +0 -0
- /package/dist/{reveal-67RDQRIN.js.map → reveal-4BCKPEC2.js.map} +0 -0
- /package/dist/{stale-DDL7WQEZ.js.map → revoke-ZL62WC2D.js.map} +0 -0
- /package/dist/{seed-G42JYN56.js.map → seed-4JS2RJ4A.js.map} +0 -0
- /package/dist/{storage-FLR73HHF.js.map → signer-MBZZMXTC.js.map} +0 -0
- /package/dist/{walk-3UQBRMDV.js.map → stale-TJ3DYZMQ.js.map} +0 -0
- /package/dist/{withdraw-accessible-EL5GXZBS.js.map → storage-SVMKRGCW.js.map} +0 -0
- /package/dist/{store-coordination-provider-MEQ2MJQG.js.map → store-coordination-provider-2O2VUHKW.js.map} +0 -0
- /package/dist/{verify-KOV2G5D6.js.map → verify-RVT67IMH.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-commit/tx/atomic-eligibility.ts","../src/kernel/best-effort-revert.ts","../src/kernel/tx-write-gate.ts","../src/with-commit/tx/transaction.ts"],"sourcesContent":["/**\n * #893/#906-prep — the atomic-commit eligibility gate.\n *\n * `runTransaction` (Task 5) consults `canCommitAtomically` right after the\n * body returns, to decide whether the whole staged batch can be prepared and\n * submitted as ONE `store.tx(ops)` call instead of the per-op abortable\n * path (Phase 1 pre-flight + Phase 2 Collection-layer execute + Phase 3\n * best-effort revert — see `transaction.ts`'s module doc).\n *\n * Pure decision logic: no side effects, no store reads. Every input is\n * already sitting on `db` / `ctx`.\n *\n * ALL of the following must hold. (Commit-time changeset invariants are NOT a\n * condition: that phase lives after Phase 2 in `runTransaction` and runs\n * unchanged on either path — a failing invariant reverts the atomic batch\n * through the same `ctx._executed` plan.)\n *\n * 1. The store declares `capabilities.txAtomic === true` AND implements\n * `tx()`. Both — mirrors the pairing rule `bestEffortRevert` already\n * enforces (`kernel/best-effort-revert.ts:78`): an undeclared `tx()` is\n * never used, even if present.\n * 2. Not an amendment transaction (`ctx._amendment === false`) — amendments\n * need the guard-registry change-set + invariant machinery the atomic\n * path skips entirely.\n * 3. No `(vault, collection, id)` is touched twice in the batch. The\n * abortable path's Phase 1 snapshots each key once and Phase 2 replays\n * every op against that same snapshot in order; a single `store.tx()`\n * write set can't express \"this key changes twice in sequence.\"\n * 4. Every touched collection reports `_txAtomicSafe(op.type)` — see that\n * method's doc comment on `Collection` for what it excludes and why.\n * #931: of the wrapper-level write signals, only a live `onBeforeWrite`\n * hook still excludes — it may REFUSE a write, which only\n * `Collection.put()`/`.delete()` honors. After-hooks and the\n * `afterPut`/`afterDelete` observe bus are refusal-free observers, so\n * the atomic path fires them itself per leg post-finalize\n * (`Collection._fireAtomicAfterWrite`) instead of forfeiting the batch.\n * Delete gates on the enforcer's `_deleteCascadesPossible(name)` (#922):\n * `Vault.enforceRefsOnDelete` cascades from THREE sources (lookup-ref\n * edges, classic inbound refs, managed-link `onDelete`), and the Vault\n * predicate unions exactly those three — a `getInbound`-only check would\n * be narrower and wrongly admit unsafe atomic deletes, because\n * `_prepareDelete` runs the cascades DURING prepare (see\n * `with-shape/links/vault-facade.ts` `enforceRefsOnDelete`).\n *\n * @internal\n */\n\nimport type { Noydb } from '../../kernel/noydb.js'\nimport type { TxContext } from './transaction.js'\nimport { keyOf } from './transaction.js'\n\nexport function canCommitAtomically(db: Noydb, ctx: TxContext): boolean {\n const store = db._store\n if (store.capabilities?.txAtomic !== true || typeof store.tx !== 'function') return false\n if (ctx._amendment) return false\n\n const seen = new Set<string>()\n for (const op of ctx._ops) {\n const key = keyOf(op)\n if (seen.has(key)) return false\n seen.add(key)\n }\n\n for (const op of ctx._ops) {\n const coll = db.vault(op.vaultName).collection(op.collectionName)\n if (!coll._txAtomicSafe(op.type)) return false\n }\n\n return true\n}\n","/**\n * Best-effort reverse-revert — the shape shared by two independent rollback\n * paths that used to duplicate it: satellite fan-out\n * (`with-shape/satellites/fanout.ts`'s `revertAndCompensate`) and\n * multi-record transactions (`with-commit/tx/transaction.ts`'s\n * `revertExecuted`). Both revert a list of already-executed writes on\n * failure by walking them in REVERSE order and, per leg, restoring the\n * captured prior envelope straight through the raw adapter — `put(prior)`\n * when one existed, `delete` when the leg was a fresh insert — bypassing\n * the Collection layer so the revert itself doesn't re-fire\n * encryption/ledger/change-event machinery. Each leg's raw-adapter revert\n * is best-effort: a throw is swallowed so a revert-path failure never masks\n * the original error that triggered the rollback, and the loop moves on to\n * the next leg.\n *\n * An optional per-leg `compensate` callback runs immediately after a\n * successful raw-adapter revert (still inside the same try, so a throwing\n * callback is swallowed the same way as a throwing raw revert). What the\n * callback does is entirely caller-defined — satellites' fan-out fires\n * `_compensateRevertedWrite` only for legs whose write actually landed\n * (#596); with-commit's transaction executor invalidates the Collection\n * cache. Neither concern belongs here: this helper only knows the generic\n * reverse/best-effort/raw-revert shape.\n *\n * Lives in `kernel/` — not a `with-*` service — so both consumers (one a\n * gated service, `with-commit`; one an always-on schema feature,\n * `with-shape/satellites`) can import it without creating a\n * `with-* → with-*` edge, which would force either family to always bundle\n * the other and defeat the opt-in tree-shaking both are built around.\n *\n * @internal — implementation-sharing only, not part of the public surface.\n */\nimport type { EncryptedEnvelope, StoreCapabilities, TxOp } from './types.js'\n\n/** One already-executed write a revert pass needs to unwind. */\nexport interface BestEffortRevertLeg {\n readonly vaultName: string\n readonly collectionName: string\n readonly id: string\n /** Envelope captured before the write, or `null` if the id didn't exist yet. */\n readonly prior: EncryptedEnvelope | null\n}\n\n/** The subset of `NoydbStore` a raw-adapter revert needs. */\nexport interface BestEffortRevertAdapter {\n put(vaultName: string, collectionName: string, id: string, envelope: EncryptedEnvelope): Promise<void>\n delete(vaultName: string, collectionName: string, id: string): Promise<void>\n /**\n * Optional storage-layer transaction (#886). When the store declares\n * `txAtomic`, the whole revert is submitted as ONE operation instead of a\n * per-leg loop, so a crash mid-revert can no longer leave the vault\n * half-unwound.\n */\n tx?(ops: readonly TxOp[]): Promise<void>\n readonly capabilities?: StoreCapabilities\n}\n\n/**\n * Revert `executed` in reverse order via the raw adapter, best-effort.\n * `compensate`, when supplied, runs once per leg immediately after that\n * leg's own raw revert succeeds.\n */\nexport async function bestEffortRevert<T extends BestEffortRevertLeg>(\n executed: readonly T[],\n adapter: BestEffortRevertAdapter,\n compensate?: (leg: T) => Promise<void> | void,\n): Promise<void> {\n const legs = [...executed].reverse()\n\n // #886 — atomic revert when the store can do it. The legs already carry RAW\n // prior envelopes (captured pre-write), which is exactly the shape `tx()`\n // wants, so this needs none of the Collection-layer machinery that makes\n // delegating the FORWARD write path a much larger job.\n //\n // Failure stays best-effort: if the store rejects the batch we fall through\n // to the per-leg loop rather than surfacing a revert-path error, because a\n // revert failure must never mask the original error that triggered it.\n if (adapter.capabilities?.txAtomic === true && typeof adapter.tx === 'function') {\n const ops: TxOp[] = legs.map(leg =>\n leg.prior !== null\n ? { type: 'put', vault: leg.vaultName, collection: leg.collectionName, id: leg.id, envelope: leg.prior }\n : { type: 'delete', vault: leg.vaultName, collection: leg.collectionName, id: leg.id },\n )\n try {\n await adapter.tx(ops)\n if (compensate) for (const leg of legs) { try { await compensate(leg) } catch { /* best-effort */ } }\n return\n } catch {\n // fall through to the per-leg path below\n }\n }\n\n for (const leg of legs) {\n try {\n if (leg.prior !== null) {\n await adapter.put(leg.vaultName, leg.collectionName, leg.id, leg.prior)\n } else {\n await adapter.delete(leg.vaultName, leg.collectionName, leg.id)\n }\n if (compensate) await compensate(leg)\n } catch {\n // best-effort — a revert-path failure must not mask the original\n // error that triggered the rollback (matches both callers' prior\n // independent implementations).\n }\n }\n}\n","/**\n * #1420 — the in-flight-write gate.\n *\n * ## The defect this closes\n *\n * `runTransaction`'s commit opens with a **pre-flight**: it re-reads every\n * touched envelope and enforces the caller's `expectedVersion`. That check is\n * only as honest as the read, and the read could not see a plain\n * `Collection.put()` that had *started* but not yet reached the store. Such a\n * put is invisible to the pre-flight, so:\n *\n * - it lands after the pre-flight and the transaction overwrites it from a\n * stale snapshot (both writers report success, one write vanishes); or\n * - it lands after the transaction's own write and clobbers it from a stale\n * base (two writes, one version bump).\n *\n * Neither raised an error on either side, and the loss was **store-capability\n * dependent** — `to-memory` declares `txAtomic` and takes the atomic commit\n * path, `to-browser-idb` does not and takes the per-op replay — so an app\n * tested on a memory store could ship lossy on IndexedDB.\n *\n * ## The remedy: make the pre-flight's read honest\n *\n * Every logical `Collection.put()` / `.delete()` registers itself here for the\n * span of its read-modify-write, keyed by `(vault, collection, id)`. A commit\n * **drains** the writes already in flight on the keys it is about to touch,\n * BEFORE its pre-flight reads. The in-flight case then behaves exactly like\n * the fully-awaited one the pre-flight already handled correctly: the read\n * sees the new version and a mismatched `expectedVersion` refuses with\n * `ConflictError`. No silent loss, and no new refusal for writes that were\n * never in conflict.\n *\n * ## Why this is deadlock-free\n *\n * The wait is strictly one-directional and one-deep. A registered write never\n * waits on anything from this module — only a commit does, and only on writes\n * registered *before* it started draining ({@link drainKeyedWrites} takes a\n * snapshot and does not loop to a fixed point). So there is no cycle to close,\n * and the drain terminates as soon as the pre-existing writes settle,\n * whichever way they settle. A commit's own Phase-2 writes register *after*\n * the drain has returned, so a commit never waits on itself.\n *\n * ## Scope, deliberately\n *\n * Keyed on the STORE object, not the `Noydb` instance — two hub instances over\n * one store are the same race, and this keeps the always-on kernel files\n * (`noydb.ts`) untouched. Same-process only: it is a JS-object registry, and\n * makes no claim about a second tab or a second process. That is the same\n * boundary the reported defect has.\n *\n * ⛔ This does NOT serialize transaction against transaction. Two concurrent\n * commits touching one key can still interleave — a distinct case from the\n * reported one, and one whose fix (a commit barrier) has to solve reentrancy\n * for the commit's own replay writes first. Do not extend this module into\n * that without measuring the reentrancy path.\n *\n * @internal\n */\n\n/** store → key → the settle-promises of the writes currently in flight on it. */\nconst inFlight = new WeakMap<object, Map<string, Set<Promise<void>>>>()\n\n/** The shared `(vault, collection, id)` key shape. @internal */\nexport function writeGateKey(vault: string, collection: string, id: string): string {\n return `${vault}\\x00${collection}\\x00${id}`\n}\n\n/**\n * Run one logical write registered against `(vault, collection, id)` so a\n * concurrent commit can drain it. Returns / throws exactly what `fn` does —\n * registration is invisible to the caller.\n *\n * @internal\n */\nexport async function trackKeyedWrite<R>(\n store: object,\n vault: string,\n collection: string,\n id: string,\n fn: () => Promise<R>,\n): Promise<R> {\n let byKey = inFlight.get(store)\n if (byKey === undefined) {\n byKey = new Map()\n inFlight.set(store, byKey)\n }\n const key = writeGateKey(vault, collection, id)\n let waiters = byKey.get(key)\n if (waiters === undefined) {\n waiters = new Set()\n byKey.set(key, waiters)\n }\n const running = fn()\n // A drainer must never inherit this write's rejection: it is waiting for the\n // write to STOP being in flight, not for it to succeed. The original promise\n // is what the caller gets, unswallowed.\n const settled = running.then(() => undefined, () => undefined)\n waiters.add(settled)\n try {\n return await running\n } finally {\n waiters.delete(settled)\n if (waiters.size === 0) byKey.delete(key)\n }\n}\n\n/**\n * Wait for every write already in flight on `keys` to settle. Snapshot-based\n * and single-pass — see the deadlock note in the module doc. A no-op (and no\n * microtask) when nothing is in flight, which is the overwhelmingly common\n * case for a commit.\n *\n * @internal\n */\nexport async function drainKeyedWrites(store: object, keys: Iterable<string>): Promise<void> {\n const byKey = inFlight.get(store)\n if (byKey === undefined || byKey.size === 0) return\n let waits: Promise<void>[] | undefined\n for (const key of keys) {\n const waiters = byKey.get(key)\n if (waiters === undefined) continue\n for (const w of waiters) (waits ??= []).push(w)\n }\n if (waits !== undefined) await Promise.all(waits)\n}\n","/**\n * Multi-record atomic transactions.\n *\n * Lets an application stage writes across two or more collections (or\n * vaults) and commit them all-or-nothing.\n *\n * ```ts\n * await db.transaction(async (tx) => {\n * const inv = tx.vault('acme').collection<Invoice>('invoices')\n * const pay = tx.vault('acme').collection<Payment>('payments')\n * await inv.put(invoiceId, { ...invoice, status: 'paid' })\n * await pay.put(paymentId, { invoiceId, amount, paidAt })\n * })\n * // If the body throws before returning: nothing persisted.\n * // If the body returns: all puts committed; any CAS mismatch rolls\n * // the batch back and surfaces as ConflictError.\n * ```\n *\n * ## Atomicity semantics\n *\n * Ops are buffered during the body. On body-return the hub:\n *\n * 0. **Drain (#1420)** — waits out any plain `Collection.put()` /\n * `.delete()` already in flight on a key this commit touches, so\n * the pre-flight below reads a version that includes it. Without\n * this the pre-flight cannot see a write that has STARTED but not\n * yet reached the store, and one of the two writes vanishes with\n * both reporting success.\n * 1. **Pre-flight** — re-reads every touched envelope and enforces\n * any caller-supplied `expectedVersion`. A mismatch throws\n * `ConflictError` with *no* writes performed.\n * 2. **Execute** — re-validates each op's `expectedVersion` against\n * the CURRENT stored version (#1420 — the pre-flight's verdict is\n * otherwise unchecked all the way to the write, and this path\n * carries no store-level CAS the way the atomic one does), then\n * calls `Collection.put()` / `.delete()` for each staged op in\n * declaration order. History snapshots, ledger appends, and change\n * events fire as normal per op.\n * 3. **Unwind on failure** — if step 2 throws mid-batch, each\n * already-committed op is reverted via the raw store (restoring\n * the captured prior envelope, or deleting if none existed). The\n * ledger is NOT rewritten — audit history preserves the partial\n * commit and the revert.\n *\n * **Atomic delegation (#906).** Steps 1–3 above describe the OCC\n * fallback. When the store declares `StoreCapabilities.txAtomic` AND\n * implements `tx()`, AND the staged batch is statically safe\n * (`canCommitAtomically` — see `atomic-eligibility.ts`), the commit\n * instead: prepares every op through `Collection._preparePut` /\n * `_prepareDelete` (encrypt, resolve the prior version, mint the #589\n * marker — no observable side effect), submits the whole write set as\n * ONE `store.tx(ops)` call with a per-leg `expectedVersion`, then\n * finalizes each op in staged order. The visible difference: history\n * snapshots, ledger entries and change events all fire AFTER the bytes\n * are durable, instead of interleaving per op.\n *\n * **Crash window.** On the OCC fallback, steps 2–3 are not a\n * storage-layer transaction — if the process dies between two executed\n * ops, the on-disk state is partial. The atomic path above closes that\n * window for the write set itself (`to-memory` and the SQL stores in\n * `noy-db-to` implement `tx()`); a crash between the batch landing and\n * the finalize loop finishing still leaves per-op side effects (history,\n * ledger, cache) incomplete. Stores that cannot commit a batch\n * atomically (file, S3) omit `tx()` and keep the fallback.\n *\n * ## Not covered\n *\n * - Cross-sync-peer atomicity. Transactions commit against the\n * primary store only; the sync engine pushes on its normal\n * schedule. For cross-peer two-phase commit use `SyncTransaction`\n * via `db.transaction(vaultName)`.\n * - Read-your-writes within the body. `tx.collection().get(id)`\n * returns the most-recently-staged value for that id when one\n * exists; if no staged op has touched the id, it reads the current\n * committed state. Version numbers returned by `get` reflect the\n * pre-transaction state (staged puts have no version yet).\n *\n * @module\n */\n\nimport type { Noydb } from '../../kernel/noydb.js'\nimport type { Vault } from '../../kernel/vault.js'\nimport type { Collection } from '../../kernel/collection.js'\nimport type { EncryptedEnvelope, TxOp } from '../../kernel/types.js'\nimport type { PreparedPut, PreparedDelete } from '../../kernel/prepared-write.js'\nimport { canCommitAtomically } from './atomic-eligibility.js'\nimport {\n AmendmentForbiddenError,\n ConflictError,\n InvariantError,\n ValidationError,\n} from '../../kernel/errors.js'\nimport { generateULID } from '../../with-pod/ulid.js'\nimport type { GuardExecutor as GuardExecutorModule } from '../../with-audit/guards/executor.js'\nimport type { LedgerEntry } from '../history/ledger/entry.js'\nimport type { TransactionInvariant } from './invariants.js'\nimport type { GuardChange, GuardContext, ReadOnlyVaultFacade } from '../../with-audit/guards/types.js'\nimport { bestEffortRevert } from '../../kernel/best-effort-revert.js'\nimport { drainKeyedWrites } from '../../kernel/tx-write-gate.js'\n\n/** One op buffered inside a running `TxContext`. @internal */\nexport interface StagedOp {\n type: 'put' | 'delete'\n vaultName: string\n collectionName: string\n id: string\n record?: unknown\n expectedVersion?: number\n /**\n * Optional human-readable tag forwarded to the resulting ledger\n * entry's `reason` field. Set by callers via\n * `tx.vault(v).collection(c).put(id, record, { reason })`.\n */\n reason?: string\n}\n\n/**\n * One executed op (main staged op or recursive side-effect like a\n * derivation output) paired with the envelope captured before the write.\n * `revertExecuted` walks this array in reverse on rollback.\n * @internal\n */\nexport interface ExecutedOp {\n op: StagedOp\n priorEnvelope: EncryptedEnvelope | null\n}\n\n/**\n * Options accepted by `db.transaction({ amendment, reason }, fn)`.\n * Only the amendment variant uses these — a plain `db.transaction(fn)`\n * never sees this shape.\n */\nexport interface AmendmentTxOptions {\n /** Opt into amendment mode. Required to be `true`. */\n readonly amendment: true\n /** Human-readable rationale recorded in the ledger entry. Required. */\n readonly reason: string\n}\n\n/**\n * Transaction handle passed to the user's body. Use\n * `tx.vault(name).collection<T>(name)` to get a per-collection\n * facade; its `put`/`delete`/`get` calls stage ops against the tx.\n */\nexport class TxContext {\n /** Stable id for this transaction; shared by all writes it performs. */\n readonly txId: string = generateULID()\n /** @internal */\n readonly _ops: StagedOp[] = []\n /**\n * @internal — write log built up in Phase 2. Each entry records the\n * envelope captured BEFORE the write so a mid-batch failure can\n * restore prior state via `revertExecuted`. Side-effect writes (e.g.\n * recursive derivation outputs fired inside `Collection.put`) are\n * appended here in execution order so they roll back alongside the\n * main staged ops.\n */\n readonly _executed: ExecutedOp[] = []\n /** @internal */\n readonly _db: Noydb\n /**\n * @internal — true when this TxContext was opened in amendment\n * mode. Toggles the lazy-`beginAmendment` + role-check path on first\n * `tx.vault(name)` and unlocks the post-Phase-2 invariant + audit run.\n */\n readonly _amendment: boolean\n /** @internal — vaults that have already had `beginAmendment` called. */\n readonly _amendmentVaults = new Map<string, Vault>()\n\n /** @internal */\n constructor(db: Noydb, amendment = false) {\n this._db = db\n this._amendment = amendment\n }\n\n /** Scope subsequent `collection()` calls to the named vault. */\n vault(name: string): TxVault {\n const v = this._db.vault(name)\n if (this._amendment && !this._amendmentVaults.has(name)) {\n // Role check is per-vault. The task spec (\"only admin or owner\n // can open an amendment\") is implemented lazy-on-first-touch\n // because the role lives on the vault's keyring, and `tx.vault()`\n // is the first place we know which vault we're addressing. The\n // observable effect is identical to an eager check in the single-\n // vault case the tests exercise; multi-vault amendments check\n // each touched vault as they first appear.\n const role = v.role\n // FR-6: custodian is admin-rank for operational mutations, and an\n // amendment is an operational (data-correcting) act — not an ownership\n // meta-capability — so custodian is allowed alongside owner/admin.\n if (role !== 'admin' && role !== 'owner' && role !== 'custodian') {\n throw new AmendmentForbiddenError(v.userId, role)\n }\n // Amendments require an initialised guard registry — they\n // produce a structured invariant + change-set audit. A vault\n // opened without `guardStrategies` (or via the sync fallback\n // path) has a null registry and cannot run an amendment.\n const reg = v._getGuardRegistry()\n if (reg === null) {\n throw new ValidationError(\n `Vault \"${name}\": amendment mode requires at least one ` +\n `guardStrategy registered via createNoydb({ guardStrategies }). ` +\n `Open the vault with guardStrategies before calling ` +\n `db.transaction({ amendment: true }).`,\n )\n }\n reg.beginAmendment()\n this._amendmentVaults.set(name, v)\n }\n return new TxVault(this, v)\n }\n}\n\n/** Per-vault facade inside a running transaction. */\nexport class TxVault {\n /** @internal */\n readonly _ctx: TxContext\n /** @internal */\n readonly _vault: Vault\n\n /** @internal */\n constructor(ctx: TxContext, vault: Vault) {\n this._ctx = ctx\n this._vault = vault\n }\n\n /** Scope subsequent op calls to the named collection. */\n collection<T>(name: string): TxCollection<T> {\n const c = this._vault.collection<T>(name)\n return new TxCollection<T>(this._ctx, this._vault, c, name)\n }\n}\n\n/** Per-collection facade inside a running transaction. */\nexport class TxCollection<T> {\n /** @internal */\n readonly _ctx: TxContext\n /** @internal */\n readonly _vault: Vault\n /** @internal */\n readonly _coll: Collection<T>\n /** @internal */\n readonly _name: string\n\n /** @internal */\n constructor(ctx: TxContext, vault: Vault, coll: Collection<T>, name: string) {\n this._ctx = ctx\n this._vault = vault\n this._coll = coll\n this._name = name\n }\n\n /**\n * Read the current committed value, or the most-recently-staged\n * value from the same transaction if one exists.\n */\n async get(id: string): Promise<T | null> {\n for (let i = this._ctx._ops.length - 1; i >= 0; i--) {\n const op = this._ctx._ops[i]!\n if (\n op.vaultName === this._vault.name &&\n op.collectionName === this._name &&\n op.id === id\n ) {\n if (op.type === 'delete') return null\n return op.record as T\n }\n }\n return this._coll.get(id)\n }\n\n /**\n * Stage a put. Does not write until the transaction body returns.\n * Supply `{ expectedVersion }` to enforce optimistic concurrency\n * during the commit pre-flight.\n */\n put(id: string, record: T, options?: { expectedVersion?: number; reason?: string }): void {\n const op: StagedOp = {\n type: 'put',\n vaultName: this._vault.name,\n collectionName: this._name,\n id,\n record,\n }\n if (options?.expectedVersion !== undefined) op.expectedVersion = options.expectedVersion\n if (options?.reason !== undefined) op.reason = options.reason\n this._ctx._ops.push(op)\n }\n\n /**\n * Stage a delete. Does not write until the transaction body returns.\n * Supply `{ expectedVersion }` to enforce optimistic concurrency\n * during the commit pre-flight.\n */\n delete(id: string, options?: { expectedVersion?: number }): void {\n const op: StagedOp = {\n type: 'delete',\n vaultName: this._vault.name,\n collectionName: this._name,\n id,\n }\n if (options?.expectedVersion !== undefined) op.expectedVersion = options.expectedVersion\n this._ctx._ops.push(op)\n }\n}\n\n/**\n * Commit plan: pre-flight check + execution + revert plan.\n *\n * @internal — driven by `withTransactions()` (via `tx/active.ts`) for\n * user-facing `db.transaction(...)` calls and by the `amendment` path\n * in `noydb.ts`. `Collection.putManyAtomic` runs its own Phase 2 loop\n * but shares the `_activeTxContext` mechanism (and the `revertExecuted`\n * helper) so nested side-effect derivation writes get registered for\n * revert alongside the bulk-put source ops.\n */\nexport async function runTransaction<T>(\n db: Noydb,\n fn: (tx: TxContext) => Promise<T> | T,\n options?: AmendmentTxOptions,\n txInvariants?: ReadonlyArray<TransactionInvariant>,\n): Promise<T> {\n // ─── Amendment-mode pre-flight ───────────────────────────────\n // `reason` is the only thing we can validate before the body runs;\n // the per-vault role check happens lazily on first `tx.vault(name)`\n // because we don't know which vaults the body will touch ahead of\n // time. Throwing here keeps the failure mode close to the call site\n // so the developer doesn't have to walk an async stack to find the\n // missing-reason mistake.\n if (options?.amendment) {\n if (typeof options.reason !== 'string' || options.reason.trim().length === 0) {\n throw new ValidationError(\n 'db.transaction({ amendment: true }) requires a non-empty `reason` string.',\n )\n }\n }\n\n const ctx = new TxContext(db, options?.amendment === true)\n const bodyResult = await fn(ctx)\n\n if (ctx._ops.length === 0) {\n // Body produced no ops. If amendment mode was active we still\n // need to close any opened windows so a subsequent (unrelated)\n // write doesn't surprise-collect into a stale change-set. Each\n // `beginAmendment` is matched by exactly one `consumeChanges`.\n if (ctx._amendment) {\n for (const v of ctx._amendmentVaults.values()) {\n // Registry is guaranteed non-null here — `tx.vault(name)`\n // threw above if it was null before adding to\n // `_amendmentVaults`.\n const reg = v._getGuardRegistry()\n if (reg !== null) {\n reg.consumeChanges()\n reg.consumeMeta()\n }\n }\n }\n return bodyResult\n }\n\n // Phase 1 — pre-flight: snapshot every touched envelope and enforce\n // any caller-supplied expectedVersion. Same (vault, coll, id) touched\n // more than once in one tx snapshots only the *initial* committed\n // state; the in-order replay in Phase 2 takes care of successor ops.\n const priorEnvelopes = new Map<string, EncryptedEnvelope | null>()\n const store = db._store\n\n // #1420 — before the first pre-flight read, wait out any plain\n // `Collection.put()`/`.delete()` already in flight on a key this commit is\n // about to touch. Without it the pre-flight's re-read cannot see a write\n // that has started but not yet reached the store, so the check passes\n // against a stale snapshot and one of the two writes vanishes with both\n // reporting success. Draining makes the in-flight case behave exactly like\n // the fully-awaited one, which the pre-flight below already handled\n // correctly. Deadlock-free by construction — see `kernel/tx-write-gate.ts`.\n await drainKeyedWrites(store, ctx._ops.map(keyOf))\n\n // Commit-time changeset invariants need PLAINTEXT prior records\n // for `before`, but `priorEnvelopes` holds ENCRYPTED envelopes. So for\n // ops in a watched scope we additionally decrypt the prior record here,\n // in Phase 1, BEFORE Phase 2 overwrites it. Snapshots only the initial\n // committed state per (vault, coll, id), matching the envelope snapshot.\n const invariants = txInvariants ?? []\n const watchedScopes = new Set(invariants.map(i => i.scope))\n const plainBefore = new Map<string, unknown>()\n\n for (const op of ctx._ops) {\n const key = keyOf(op)\n if (!priorEnvelopes.has(key)) {\n const env = await store.get(op.vaultName, op.collectionName, op.id)\n priorEnvelopes.set(key, env)\n }\n if (watchedScopes.has(op.collectionName) && !plainBefore.has(key)) {\n const prior = await db\n .vault(op.vaultName)\n .collection(op.collectionName)\n .get(op.id)\n plainBefore.set(key, prior ?? null)\n }\n if (op.expectedVersion !== undefined) {\n const env = priorEnvelopes.get(key) ?? null\n const actual = env?._v ?? 0\n if (actual !== op.expectedVersion) {\n throw new ConflictError(\n actual,\n `Transaction pre-flight: ${op.vaultName}/${op.collectionName}/${op.id} ` +\n `expected v${op.expectedVersion}, found v${actual}`,\n )\n }\n }\n }\n\n // Phase 2 — execute via the Collection layer so history snapshots,\n // ledger entries, and change events fire normally. We capture each\n // successful op so a mid-batch throw can revert in Phase 3.\n //\n // `_activeTxContext` is published on the Noydb instance for the\n // duration of Phase 2 so recursive writes triggered inside\n // `Collection.put` (today: eager derivation outputs) can register\n // their own envelopes onto `ctx._executed` and roll back alongside\n // the main staged ops. The `finally` clears it before the\n // amendment commit phase runs.\n db._setActiveTxContext(ctx)\n try {\n if (canCommitAtomically(db, ctx)) {\n // #906 — the whole batch goes to the store as ONE `tx()` write set.\n // Tracked here because the atomic path bypasses `Collection.put()`,\n // which is where an ordinary write enters the queue: without this,\n // `hub.writeQueue.pending` would read false for the entire commit.\n // One tracked unit, not one per op — the batch IS one logical write.\n await db._writeQueueTracker.track(() => commitAtomicBatch(db, ctx, priorEnvelopes))\n } else {\n const writtenKeys = new Set<string>()\n try {\n for (const op of ctx._ops) {\n const coll = db.vault(op.vaultName).collection(op.collectionName)\n const key = keyOf(op)\n const prior = priorEnvelopes.get(key) ?? null\n // #1420 — the per-op path replays through `Collection.put()`, which\n // carries no CAS: whatever the pre-flight decided stands unchecked\n // until the write lands. The atomic path re-validates by handing\n // every leg an `expectedVersion` to `store.tx()`; this is that check\n // for the path that has no store-level batch. Once THIS transaction\n // has written the key its version has legitimately moved, so a\n // second op on the same key is exempt — matching Phase 1, which\n // snapshots (and checks) only the first occurrence per key.\n if (op.expectedVersion !== undefined && !writtenKeys.has(key)) {\n const current = await store.get(op.vaultName, op.collectionName, op.id)\n const actual = current?._v ?? 0\n if (actual !== op.expectedVersion) {\n throw new ConflictError(\n actual,\n `Transaction execute: ${op.vaultName}/${op.collectionName}/${op.id} ` +\n `expected v${op.expectedVersion}, found v${actual}`,\n )\n }\n }\n // Record the revert plan BEFORE the call so a mid-`coll.put` throw\n // (e.g. strict-mode derivation failure firing after `store.put`\n // has already committed the envelope) still has its source write\n // reverted. `revertExecuted` is best-effort: putting prior back is\n // idempotent when the failing op never actually wrote, and\n // `_invalidateCacheEntry` is a no-op when the collection isn't\n // hydrated.\n ctx._executed.push({ op, priorEnvelope: prior })\n if (op.type === 'put') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await coll.put(op.id, op.record as any, op.reason !== undefined ? { reason: op.reason } : undefined)\n } else {\n await coll.delete(op.id)\n }\n writtenKeys.add(key)\n }\n } catch (err) {\n // Phase 3 — best-effort revert. See helper docstring.\n await revertExecuted(ctx._executed, store, db)\n // Drain amendment windows so the next transaction starts clean.\n if (ctx._amendment) {\n for (const v of ctx._amendmentVaults.values()) {\n const reg = v._getGuardRegistry()\n if (reg !== null) {\n reg.consumeChanges()\n reg.consumeMeta()\n }\n }\n }\n throw err\n }\n }\n } finally {\n db._clearActiveTxContext(ctx)\n }\n\n // ─── Amendment commit phase (only if amendment === true) ────\n // Body succeeded — now run each touched vault's invariants over the\n // collected change-set, then append a structured ledger entry. If\n // any invariant throws, treat it exactly like a mid-Phase-2 failure:\n // revert every executed op and re-throw the InvariantError.\n if (ctx._amendment) {\n // Lazy-load GuardExecutor at the dispatch site — keeps the floor\n // bundle free of the guards service when amendments aren't used.\n // Mirrors the deferred-load pattern from elsewhere in this module.\n const { GuardExecutor } = (await import('../../with-audit/guards/executor.js')) as {\n GuardExecutor: typeof GuardExecutorModule\n }\n try {\n for (const [vaultName, v] of ctx._amendmentVaults) {\n const registry = v._getGuardRegistry()\n // Registry is guaranteed non-null at this point — the\n // `tx.vault(name)` path that populates `_amendmentVaults`\n // throws if the registry is null. The defensive check here\n // is for TypeScript's narrowing.\n if (registry === null) continue\n const changesByCollection = registry.consumeChanges()\n const meta = registry.consumeMeta()\n if (changesByCollection.size === 0) continue\n\n const readOnlyVault = v._getReadOnlyFacade()\n if (readOnlyVault === null) continue\n\n // Build the invariant ctx once per vault — it's the same shape\n // every guard sees on the normal `check` path, just with a\n // synthetic `existing: null` (invariants get the full change\n // set in their first parameter; `existing` is a per-record\n // concept that doesn't apply here).\n const invariantsPassed: string[] = []\n for (const [collection, changes] of changesByCollection) {\n const guards = registry.guardsFor(collection).filter(g => g.amendment !== undefined)\n for (const guard of guards) {\n await GuardExecutor.runInvariant(guard, changes, {\n existing: null,\n vault: readOnlyVault,\n userId: v.userId,\n role: v.role,\n })\n }\n if (guards.length > 0) invariantsPassed.push(collection)\n }\n\n // Append the audit ledger entry. Silent no-op when the\n // history strategy isn't configured — the records still\n // committed, only the multi-record summary is unavailable.\n const ledger = v._getLedgerOrNull()\n if (ledger) {\n const role = v.role as 'admin' | 'owner'\n const amendment: NonNullable<LedgerEntry['amendment']> = {\n reason: options!.reason,\n role,\n changes: meta,\n invariantsPassed,\n }\n await ledger.append({\n op: 'amendment',\n collection: '',\n id: '',\n version: 0,\n actor: v.userId,\n // No payload to hash — the per-record entries already\n // captured `payloadHash` at their own append time. We use\n // a sha256 of the canonical reason string so the field is\n // populated with something deterministic and non-empty.\n payloadHash: '',\n amendment,\n })\n }\n void vaultName\n }\n } catch (err) {\n await revertExecuted(ctx._executed, store, db)\n throw err instanceof InvariantError ? err : new InvariantError(\n err instanceof Error ? err.message : `invariant violated: ${String(err)}`,\n )\n }\n }\n\n // ─── Commit-time changeset invariant phase ───────────\n // Runs for BOTH ordinary and amendment transactions (placed after the\n // amendment phase so an amendment commit is still subject to these\n // set-level constraints). Assemble the changeset from the executed\n // staged ops, deduped to the LAST write per (vault, coll, id) while\n // preserving write order, then group `GuardChange` by collection\n // (scope) and run each matching invariant. A throw mirrors the\n // amendment-phase failure mode exactly: revert every executed op and\n // re-throw as `InvariantError`.\n if (invariants.length > 0) {\n // Dedup ctx._ops to the last write per key, preserving first-seen\n // (write) order so the changeset is stable and order-meaningful.\n const lastOp = new Map<string, StagedOp>()\n const order: string[] = []\n for (const op of ctx._ops) {\n const key = keyOf(op)\n if (!lastOp.has(key)) order.push(key)\n lastOp.set(key, op)\n }\n\n // Group {before, after} pairs by collection name (the invariant\n // scope). `before` is the plaintext prior captured in Phase 1 (null\n // for inserts / unwatched — only watched scopes were captured, and\n // every grouped key belongs to a watched scope). `after` is the\n // written record, null for a delete.\n const changesByScope = new Map<string, GuardChange<unknown>[]>()\n // Parallel map: scope → the vault name of its (last-seen) op, used to\n // build the per-invariant read-only ctx (facade + userId + role).\n const scopeVault = new Map<string, string>()\n for (const key of order) {\n const op = lastOp.get(key)!\n if (!watchedScopes.has(op.collectionName)) continue\n const before = plainBefore.get(key) ?? null\n const after = op.type === 'delete' ? null : (op.record ?? null)\n const change = { before, after } as GuardChange<unknown>\n const arr = changesByScope.get(op.collectionName)\n if (arr) arr.push(change)\n else changesByScope.set(op.collectionName, [change])\n\n // Stash the vault name alongside so we can build a per-vault ctx.\n // (All ops in a scope group could span vaults; we resolve the\n // vault per change below via a parallel map keyed the same way.)\n scopeVault.set(op.collectionName, op.vaultName)\n }\n\n try {\n for (const inv of invariants) {\n const changes = changesByScope.get(inv.scope)\n if (changes === undefined || changes.length === 0) continue\n const vaultName = scopeVault.get(inv.scope)!\n const v = db.vault(vaultName)\n // Prefer the real read-only facade so the invariant can read\n // sibling collections; fall back to a minimal read-only stub.\n const facade: ReadOnlyVaultFacade =\n v._getReadOnlyFacade() ?? {\n collection<R = unknown>(name: string) {\n const c = v.collection<R>(name)\n return {\n get: (id: string) => c.get(id),\n list: () => c.list(),\n query: () => c.query(),\n }\n },\n }\n const ctxForInv: GuardContext<unknown> = {\n existing: null,\n vault: facade,\n userId: v.userId,\n role: v.role,\n }\n await inv.check(changes, ctxForInv)\n }\n } catch (err) {\n await revertExecuted(ctx._executed, store, db)\n throw err instanceof InvariantError ? err : new InvariantError(\n err instanceof Error ? err.message : `invariant violated: ${String(err)}`,\n )\n }\n }\n\n return bodyResult\n}\n\n/**\n * One prepared leg of an atomic batch: the `store.tx()` op to submit plus the\n * carrier its finalize half needs.\n * @internal\n */\ninterface AtomicLeg {\n readonly op: StagedOp\n readonly coll: Collection<unknown>\n readonly txOp: TxOp\n readonly prepared: PreparedPut<unknown> | PreparedDelete<unknown>\n}\n\n/**\n * #906 — the atomic commit path: prepare every staged op, submit the whole\n * write set as ONE `store.tx()` call, then finalize each op in staged order.\n *\n * Only ever reached through `canCommitAtomically` (`atomic-eligibility.ts`),\n * whose exclusions are what make this safe — no CRDT, no refs, no\n * derivation/MV source, no unique constraints, no amendment, no id touched\n * twice. Do not call it without that blessing.\n *\n * @internal\n */\nasync function commitAtomicBatch(\n db: Noydb,\n ctx: TxContext,\n priorEnvelopes: ReadonlyMap<string, EncryptedEnvelope | null>,\n): Promise<void> {\n const store = db._store\n const legs: AtomicLeg[] = []\n\n // ─── Prepare ───────────────────────────────────────────────────\n // Encrypt, resolve the prior version, mint the #589 marker — with zero\n // observable side effects on the collections the gate admits. A throw here\n // therefore needs no unwind: nothing has been written yet, and the caller\n // sees the refusal exactly as it would from `Collection.put()`. The revert\n // plan is recorded all the same, because a FINALIZE failure below does need\n // it (same record-before-the-call convention as the OCC loop).\n for (const op of ctx._ops) {\n const coll = db.vault(op.vaultName).collection(op.collectionName)\n // The two refusals `Collection.put()` / `.delete()` assert before anything\n // else — schema-update gate + schema fence. They live in those wrappers,\n // not in the prepare halves this path calls, so assert them here, per op.\n await coll._assertWriteGates()\n const prior = priorEnvelopes.get(keyOf(op)) ?? null\n // Every leg carries CAS against the Phase-1 snapshot, so a writer landing\n // between the body returning and the batch reaching the store loses.\n const base = { vault: op.vaultName, collection: op.collectionName, id: op.id, expectedVersion: prior?._v ?? 0 }\n ctx._executed.push({ op, priorEnvelope: prior })\n if (op.type === 'put') {\n const prepared = await coll._preparePut(op.id, op.record, op.reason !== undefined ? { reason: op.reason } : undefined)\n legs.push({ op, coll, prepared, txOp: { type: 'put', ...base, envelope: prepared.envelope } })\n } else {\n const prepared = await coll._prepareDelete(op.id, false)\n if (prepared === null) {\n // Nothing to delete (no live record / already a marker / shredded) —\n // the case `_doDelete` answers with `false`. Drop the op and its\n // revert entry rather than sending a leg for it.\n ctx._executed.pop()\n continue\n }\n legs.push({\n op, coll, prepared,\n // Under sync the delete is a marker PUT at `live._v + 1` (#589);\n // without sync it is a physical removal.\n txOp: prepared.marker ? { type: 'put', ...base, envelope: prepared.marker } : { type: 'delete', ...base },\n })\n }\n }\n\n // Every op turned out to be a no-op delete — same as the OCC loop, which\n // would have written nothing either. Don't hand the store an empty batch.\n if (legs.length === 0) return\n\n // ─── The batch ─────────────────────────────────────────────────\n // Deliberately NOT inside a revert-guarded try: a rejection means the store\n // applied nothing (all-or-nothing is the capability we gated on), so there\n // is nothing to unwind and a revert pass would write over records this\n // transaction never touched. No ledger entry, history snapshot or change\n // event has fired either — every one of those lives in finalize below. The\n // error (a `ConflictError` when a leg lost its CAS) surfaces unwrapped.\n await store.tx!(legs.map(l => l.txOp))\n\n // ─── Finalize ──────────────────────────────────────────────────\n // History snapshot, ledger entry, cache/index update, change event — per op,\n // in staged order, all AFTER the bytes are durable (where the OCC loop\n // interleaves them per op). #931: then the after-write observers (user\n // `onAfterWrite` hooks + the `afterPut`/`afterDelete` observe bus), which\n // no longer gate eligibility — they cannot refuse a completed write.\n try {\n for (const leg of legs) {\n if (leg.op.type === 'put') await leg.coll._finalizePut(leg.prepared as PreparedPut<unknown>)\n else await leg.coll._finalizeDelete(leg.prepared as PreparedDelete<unknown>)\n await leg.coll._fireAtomicAfterWrite(leg.op.type, leg.prepared)\n }\n } catch (err) {\n // The bytes ARE durable now, so this is today's best-effort unwind over\n // the plan recorded above. No amendment window to drain — the gate\n // excludes amendment transactions.\n await revertExecuted(ctx._executed, store, db)\n throw err\n }\n}\n\n/**\n * Phase 3 helper — restore captured prior envelopes via the raw store\n * to avoid re-firing Collection-level side effects (we don't want a\n * cascade of change events undoing themselves). The ledger is left\n * as-is: each committed op appended an entry; the revert is\n * deliberately NOT recorded as a compensating entry because the\n * caller-facing contract is \"atomic or not at all,\" not \"every write\n * visible in the audit trail.\" Auditors who need the intermediate\n * state can still reconstruct it by walking the ledger through the\n * failed-tx timestamp.\n *\n * Delegates the reverse/best-effort/raw-revert shape to the shared\n * `bestEffortRevert` helper (`kernel/best-effort-revert.ts`); the cache\n * invalidation below rides along as that helper's per-leg `compensate`\n * callback, gated on `db` exactly as before.\n *\n * @internal — shared between `runTransaction` and\n * `Collection.putManyAtomic`. Both register source ops + nested\n * derivation side-effect ops onto `_executed`; this helper unwinds the\n * combined list in reverse on rollback.\n */\nexport async function revertExecuted(\n executed: ReadonlyArray<ExecutedOp>,\n store: Noydb['_store'],\n db?: Noydb,\n): Promise<void> {\n const legs = executed.map(({ op, priorEnvelope }) => ({\n vaultName: op.vaultName,\n collectionName: op.collectionName,\n id: op.id,\n prior: priorEnvelope,\n }))\n await bestEffortRevert(\n legs,\n store,\n db\n ? async (leg) => {\n // Sync the Collection-layer cache with what we just wrote at\n // the raw store. Without this, eager-mode `get` would still\n // return the rolled-back record from its in-memory map. The\n // Collection's `_invalidateCacheEntry` is a no-op when the\n // collection hasn't yet been hydrated.\n const coll = db.vault(leg.vaultName).collection(leg.collectionName)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await (coll as any)._invalidateCacheEntry(leg.id)\n }\n : undefined,\n )\n}\n\n/** @internal — shared (vault, collection, id) key shape; also used by `atomic-eligibility.ts`'s duplicate-key scan. */\nexport function keyOf(op: StagedOp): string {\n return `${op.vaultName}\\x00${op.collectionName}\\x00${op.id}`\n}\n"],"mappings":";;;;;;;;;;;AAmDO,SAAS,oBAAoB,IAAW,KAAyB;AACtE,QAAM,QAAQ,GAAG;AACjB,MAAI,MAAM,cAAc,aAAa,QAAQ,OAAO,MAAM,OAAO,WAAY,QAAO;AACpF,MAAI,IAAI,WAAY,QAAO;AAE3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,MAAM,IAAI,MAAM;AACzB,UAAM,MAAM,MAAM,EAAE;AACpB,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO;AAC1B,SAAK,IAAI,GAAG;AAAA,EACd;AAEA,aAAW,MAAM,IAAI,MAAM;AACzB,UAAM,OAAO,GAAG,MAAM,GAAG,SAAS,EAAE,WAAW,GAAG,cAAc;AAChE,QAAI,CAAC,KAAK,cAAc,GAAG,IAAI,EAAG,QAAO;AAAA,EAC3C;AAEA,SAAO;AACT;;;ACPA,eAAsB,iBACpB,UACA,SACA,YACe;AACf,QAAM,OAAO,CAAC,GAAG,QAAQ,EAAE,QAAQ;AAUnC,MAAI,QAAQ,cAAc,aAAa,QAAQ,OAAO,QAAQ,OAAO,YAAY;AAC/E,UAAM,MAAc,KAAK;AAAA,MAAI,SAC3B,IAAI,UAAU,OACV,EAAE,MAAM,OAAO,OAAO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H;AAAA,EACF;AAIA,MAAI,KAAK,WAAW,EAAG;AASvB,QAAM,MAAM,GAAI,KAAK,IAAI,OAAK,EAAE,IAAI,CAAC;AAQrC,MAAI;AACF,eAAW,OAAO,MAAM;AACtB,UAAI,IAAI,GAAG,SAAS,MAAO,OAAM,IAAI,KAAK,aAAa,IAAI,QAAgC;AAAA,UACtF,OAAM,IAAI,KAAK,gBAAgB,IAAI,QAAmC;AAC3E,YAAM,IAAI,KAAK,sBAAsB,IAAI,GAAG,MAAM,IAAI,QAAQ;AAAA,IAChE;AAAA,EACF,SAAS,KAAK;AAIZ,UAAM,eAAe,IAAI,WAAW,OAAO,EAAE;AAC7C,UAAM;AAAA,EACR;AACF;AAuBA,eAAsB,eACpB,UACA,OACA,IACe;AACf,QAAM,OAAO,SAAS,IAAI,CAAC,EAAE,IAAI,cAAc,OAAO;AAAA,IACpD,WAAW,GAAG;AAAA,IACd,gBAAgB,GAAG;AAAA,IACnB,IAAI,GAAG;AAAA,IACP,OAAO;AAAA,EACT,EAAE;AACF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,KACI,OAAO,QAAQ;AAMb,YAAM,OAAO,GAAG,MAAM,IAAI,SAAS,EAAE,WAAW,IAAI,cAAc;AAElE,YAAO,KAAa,sBAAsB,IAAI,EAAE;AAAA,IAClD,IACA;AAAA,EACN;AACF;AAGO,SAAS,MAAM,IAAsB;AAC1C,SAAO,GAAG,GAAG,SAAS,KAAO,GAAG,cAAc,KAAO,GAAG,EAAE;AAC5D;","names":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CollectionNotHydratedError
|
|
3
|
+
} from "./chunk-244VXYPG.js";
|
|
4
|
+
|
|
5
|
+
// src/kernel/query/hydration.ts
|
|
6
|
+
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
7
|
+
function pendingResult(gate, terminal, compute) {
|
|
8
|
+
let settled;
|
|
9
|
+
const settle = () => settled ??= gate.hydrate().then(() => compute());
|
|
10
|
+
const refuse = () => {
|
|
11
|
+
throw new CollectionNotHydratedError(gate.collection, terminal, gate.label);
|
|
12
|
+
};
|
|
13
|
+
const proxy = new Proxy(
|
|
14
|
+
// #1462 — the target is `[]`, NOT `{}`, and it is load-bearing: `IsArray`
|
|
15
|
+
// unwraps a proxy to its target, so this is what makes
|
|
16
|
+
// `Array.isArray(rows)` answer `true` and send the idiomatic guard into
|
|
17
|
+
// the throwing path below instead of into a silent `[]`. Every trap still
|
|
18
|
+
// fires — the target is never read, only classified.
|
|
19
|
+
[],
|
|
20
|
+
{
|
|
21
|
+
get(_target, prop) {
|
|
22
|
+
if (prop === "then") {
|
|
23
|
+
return (onOk, onErr) => settle().then(onOk, onErr);
|
|
24
|
+
}
|
|
25
|
+
if (prop === "catch") {
|
|
26
|
+
return (onErr) => settle().catch(onErr);
|
|
27
|
+
}
|
|
28
|
+
if (prop === "finally") {
|
|
29
|
+
return (fn) => settle().finally(fn);
|
|
30
|
+
}
|
|
31
|
+
if (prop === Symbol.toStringTag) return "NoydbPendingResult";
|
|
32
|
+
if (prop === INSPECT) {
|
|
33
|
+
return () => `[noydb: ${terminal}() on unhydrated collection "${gate.label}" \u2014 await it, or await list()/get() first]`;
|
|
34
|
+
}
|
|
35
|
+
return refuse();
|
|
36
|
+
},
|
|
37
|
+
has: refuse,
|
|
38
|
+
ownKeys: refuse,
|
|
39
|
+
set: refuse,
|
|
40
|
+
getOwnPropertyDescriptor: refuse
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
return proxy;
|
|
44
|
+
}
|
|
45
|
+
function gateTerminal(gate, terminal, compute) {
|
|
46
|
+
if (gate === void 0 || gate.isHydrated()) return compute();
|
|
47
|
+
return pendingResult(gate, terminal, compute);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
gateTerminal
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=chunk-5O7D6ZTW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/kernel/query/hydration.ts"],"sourcesContent":["import { CollectionNotHydratedError } from '../errors.js'\n\n/**\n * #1414 — the cold-collection gate.\n *\n * An eager collection that has never been read asynchronously holds an EMPTY\n * cache. Before this module every synchronous query terminal answered out of\n * that cache, so a cold collection reported `[]` / `0` / `false` with total\n * confidence, forever, until some `list()`/`get()` hydrated it. Guards inherit\n * the same source through `ReadOnlyVaultFacade`, and both failure directions\n * were measured on shipped stable: a valid write refused because the guard's\n * lookup came back empty, and — worse — a write that a warm instance REFUSES\n * committing on a cold one, because the guard's `await …toArray()` saw nothing.\n *\n * **Empty and unable-to-answer are different facts.** Same posture as #1402\n * (\"an index that cannot answer must say so, not return nothing\") and #1410.\n *\n * The fix has to serve two callers at once, and that is what shapes this\n * module:\n *\n * - the AWAITED caller (`await q.toArray()`, and therefore every guard, since\n * `GuardSpec.check` is async) must transparently hydrate and get the rows.\n * This is the half that closes the bypass.\n * - the SYNCHRONOUS caller must be told, loudly, that the answer it is about\n * to trust is not an answer.\n *\n * A terminal cannot both throw and be awaitable, so a cold terminal returns a\n * **pending result**: a thenable that hydrates and re-runs the terminal when\n * awaited, and throws {@link CollectionNotHydratedError} on every use that\n * READS it — indexing, `.length`, iteration, spread, `.map()`, `JSON.stringify`,\n * `String()`, `in`, `Object.keys`, arithmetic, any property read.\n *\n * ⛔ **THE EXACT BOUNDARY, enumerated — because \"any other use\" is what this\n * doc used to say, and it was not true (#1462).** Two operations answer\n * without reaching a proxy trap, and NEITHER CAN BE MADE TO THROW:\n *\n * | use | result | why it cannot throw |\n * |---|---|---|\n * | `typeof rows` | `'object'` | answered from the value's type, no trap |\n * | `if (rows)` / `Boolean(rows)` — truthiness | `true` | `ToBoolean` never calls a trap |\n *\n * Do not try to close either with a `valueOf` returning `false` — that would\n * resurrect the confident-wrong-answer this whole module exists to abolish, in\n * the one shape nobody would ever check.\n *\n * ⭐ **`Array.isArray` used to be a third row, and it was the dangerous one.**\n * `toArray()` is declared `T[]`, so `Array.isArray(rows) ? rows : []` is the\n * ORDINARY defensive shape for the declared type — and it returned `[]` on a\n * cold collection, restoring the silent empty read this module abolishes,\n * behind code that looks like it handles the edge case. It is closed: the\n * proxy's target is `[]`, and `IsArray` unwraps a proxy to its target, so the\n * check answers `true` and the guard falls through to the throwing path. That\n * cost one character of target and no change to the design — the report that\n * found it assumed it needed a real array exotic object.\n *\n * ⚠️ **So the rule for anyone extending this: a use that reaches a trap must\n * throw, and a use that cannot reach one must be IN THE TABLE ABOVE.** The\n * table is pinned by `__tests__/1462-pending-result-surface.test.ts`, which\n * also asserts this comment no longer claims a total guarantee — a probe\n * written against \"any other use\" passes vacuously, because the phrase names\n * no specific use for anything to contradict.\n */\nexport interface HydrationGate {\n /** `<vault>/<collection>` — names the collection in the error. */\n readonly label: string\n /** Collection name alone, for the error's structured field. */\n readonly collection: string\n /** False only while the eager cache has never been bulk-loaded. */\n isHydrated(): boolean\n /** Bulk-load the collection. Idempotent. */\n hydrate(): Promise<void>\n}\n\nconst INSPECT = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * Wrap a terminal's result for an unhydrated collection. `compute` is re-run\n * AFTER hydration — it must be the terminal itself, not a captured value, or\n * the awaited caller would receive the cold answer it came here to avoid.\n */\nfunction pendingResult<V>(gate: HydrationGate, terminal: string, compute: () => V): V {\n let settled: Promise<V> | undefined\n const settle = (): Promise<V> => (settled ??= gate.hydrate().then(() => compute()))\n const refuse = (): never => {\n throw new CollectionNotHydratedError(gate.collection, terminal, gate.label)\n }\n const proxy = new Proxy(\n // #1462 — the target is `[]`, NOT `{}`, and it is load-bearing: `IsArray`\n // unwraps a proxy to its target, so this is what makes\n // `Array.isArray(rows)` answer `true` and send the idiomatic guard into\n // the throwing path below instead of into a silent `[]`. Every trap still\n // fires — the target is never read, only classified.\n [],\n {\n get(_target, prop) {\n if (prop === 'then') {\n return (onOk?: (v: V) => unknown, onErr?: (e: unknown) => unknown): Promise<unknown> =>\n settle().then(onOk, onErr)\n }\n if (prop === 'catch') {\n return (onErr?: (e: unknown) => unknown): Promise<unknown> => settle().catch(onErr)\n }\n if (prop === 'finally') {\n return (fn?: () => void): Promise<V> => settle().finally(fn)\n }\n if (prop === Symbol.toStringTag) return 'NoydbPendingResult'\n if (prop === INSPECT) {\n return () => `[noydb: ${terminal}() on unhydrated collection \"${gate.label}\" — await it, or await list()/get() first]`\n }\n return refuse()\n },\n has: refuse,\n ownKeys: refuse,\n set: refuse,\n getOwnPropertyDescriptor: refuse,\n },\n )\n return proxy as V\n}\n\n/**\n * Terminal wrapper. Returns `compute()` unchanged whenever the source is\n * hydrated (or carries no gate at all — a plain-object source, a join source,\n * a lazy collection), so the hot path is one property read and a boolean.\n */\nexport function gateTerminal<V>(\n gate: HydrationGate | undefined,\n terminal: string,\n compute: () => V,\n): V {\n if (gate === undefined || gate.isHydrated()) return compute()\n return pendingResult(gate, terminal, compute)\n}\n"],"mappings":";;;;;AAyEA,IAAM,UAAU,uBAAO,IAAI,4BAA4B;AAOvD,SAAS,cAAiB,MAAqB,UAAkB,SAAqB;AACpF,MAAI;AACJ,QAAM,SAAS,MAAmB,YAAY,KAAK,QAAQ,EAAE,KAAK,MAAM,QAAQ,CAAC;AACjF,QAAM,SAAS,MAAa;AAC1B,UAAM,IAAI,2BAA2B,KAAK,YAAY,UAAU,KAAK,KAAK;AAAA,EAC5E;AACA,QAAM,QAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMhB,CAAC;AAAA,IACD;AAAA,MACE,IAAI,SAAS,MAAM;AACjB,YAAI,SAAS,QAAQ;AACnB,iBAAO,CAAC,MAA0B,UAChC,OAAO,EAAE,KAAK,MAAM,KAAK;AAAA,QAC7B;AACA,YAAI,SAAS,SAAS;AACpB,iBAAO,CAAC,UAAsD,OAAO,EAAE,MAAM,KAAK;AAAA,QACpF;AACA,YAAI,SAAS,WAAW;AACtB,iBAAO,CAAC,OAAgC,OAAO,EAAE,QAAQ,EAAE;AAAA,QAC7D;AACA,YAAI,SAAS,OAAO,YAAa,QAAO;AACxC,YAAI,SAAS,SAAS;AACpB,iBAAO,MAAM,WAAW,QAAQ,gCAAgC,KAAK,KAAK;AAAA,QAC5E;AACA,eAAO,OAAO;AAAA,MAChB;AAAA,MACA,KAAK;AAAA,MACL,SAAS;AAAA,MACT,KAAK;AAAA,MACL,0BAA0B;AAAA,IAC5B;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,aACd,MACA,UACA,SACG;AACH,MAAI,SAAS,UAAa,KAAK,WAAW,EAAG,QAAO,QAAQ;AAC5D,SAAO,cAAc,MAAM,UAAU,OAAO;AAC9C;","names":[]}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
walkClosure
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3ELRMVJK.js";
|
|
4
4
|
import {
|
|
5
5
|
resolveManagedSecret
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ENAG3IY7.js";
|
|
7
7
|
import {
|
|
8
8
|
parseExtractedPartitionBody,
|
|
9
9
|
readPod,
|
|
10
10
|
readPodHeader
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HBPPGWUM.js";
|
|
12
12
|
import {
|
|
13
13
|
createOwnerKeyring,
|
|
14
14
|
mintRosterTag,
|
|
15
15
|
nextRosterEpoch,
|
|
16
16
|
requireRosterKey
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-M7NI3IWE.js";
|
|
18
18
|
import {
|
|
19
19
|
LedgerStore
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ZXABPVM6.js";
|
|
21
21
|
import {
|
|
22
22
|
LEDGER_COLLECTION
|
|
23
23
|
} from "./chunk-I7FD46FF.js";
|
|
24
24
|
import {
|
|
25
25
|
openEnvelopeJson
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KJFW62P4.js";
|
|
27
27
|
import {
|
|
28
28
|
buildRecordEnvelope
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-SEE332EV.js";
|
|
30
30
|
import {
|
|
31
31
|
base64ToBuffer,
|
|
32
32
|
wrapKey
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-UYB234ZR.js";
|
|
34
34
|
import {
|
|
35
35
|
AdoptionStateError,
|
|
36
36
|
TransferSealError,
|
|
37
37
|
ValidationError
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-244VXYPG.js";
|
|
39
39
|
|
|
40
40
|
// src/with-cargo/active.ts
|
|
41
41
|
function withCargo() {
|
|
42
42
|
return {
|
|
43
43
|
async extractPartition(vault, opts) {
|
|
44
|
-
const { extractPartitionCore } = await import("./extract-partition-
|
|
44
|
+
const { extractPartitionCore } = await import("./extract-partition-NF7PXGPP.js");
|
|
45
45
|
return extractPartitionCore(vault, opts);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -252,7 +252,7 @@ async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
if (isManaged(opts)) {
|
|
255
|
-
const { createNoydb } = await import("./noydb-
|
|
255
|
+
const { createNoydb } = await import("./noydb-SWQJ3MZS.js");
|
|
256
256
|
const db = await createNoydb({
|
|
257
257
|
store,
|
|
258
258
|
user: userId,
|
|
@@ -307,4 +307,4 @@ export {
|
|
|
307
307
|
withCargo,
|
|
308
308
|
describeExtraction
|
|
309
309
|
};
|
|
310
|
-
//# sourceMappingURL=chunk-
|
|
310
|
+
//# sourceMappingURL=chunk-6B3VNR4P.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SatelliteConfigError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-244VXYPG.js";
|
|
4
4
|
|
|
5
5
|
// src/with-shape/satellites/validate.ts
|
|
6
6
|
function validateSatelliteDeclaration(input) {
|
|
@@ -47,4 +47,4 @@ export {
|
|
|
47
47
|
validateSatelliteDeclaration,
|
|
48
48
|
hashFields
|
|
49
49
|
};
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
50
|
+
//# sourceMappingURL=chunk-6K7DPM7D.js.map
|
|
@@ -7,28 +7,28 @@ import {
|
|
|
7
7
|
deriveSchemaManifest,
|
|
8
8
|
loadSchemaManifestEntry,
|
|
9
9
|
saveSchemaManifest
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SYVZW77S.js";
|
|
11
11
|
import {
|
|
12
12
|
MANIFEST_COLLECTION
|
|
13
13
|
} from "./chunk-EPFF7LOX.js";
|
|
14
14
|
import {
|
|
15
15
|
loadFence,
|
|
16
16
|
saveFence
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-L7DOS3TE.js";
|
|
18
18
|
import {
|
|
19
19
|
derivePersistedSchema
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-PSIV7CJV.js";
|
|
21
21
|
import {
|
|
22
22
|
loadPersistedSchemaEntry,
|
|
23
23
|
savePersistedSchema
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-3H5KLDZN.js";
|
|
25
25
|
import {
|
|
26
26
|
envelopePayloadHash
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-CKNGS5MH.js";
|
|
28
28
|
import {
|
|
29
29
|
ManifestConflictError,
|
|
30
30
|
isConflictError
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-244VXYPG.js";
|
|
32
32
|
|
|
33
33
|
// src/with-shape/persisted-schemas/field-ids.ts
|
|
34
34
|
var BASE32URL_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
@@ -257,4 +257,4 @@ export {
|
|
|
257
257
|
persistClassifiedMarker,
|
|
258
258
|
persistSatelliteMarker
|
|
259
259
|
};
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
260
|
+
//# sourceMappingURL=chunk-6LMQ5R26.js.map
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeVecId,
|
|
3
|
-
embeddingSourceText,
|
|
4
|
-
encodeVecId,
|
|
5
|
-
isVecIdFor
|
|
6
|
-
} from "./chunk-RTBJ5IOO.js";
|
|
7
1
|
import {
|
|
8
2
|
buildBlobFieldEntries,
|
|
9
3
|
buildDictKeyFieldEntries,
|
|
10
4
|
buildI18nFieldEntries,
|
|
11
5
|
buildStringFieldEntries,
|
|
12
6
|
extractSnippet,
|
|
13
|
-
searchScan
|
|
14
|
-
|
|
7
|
+
searchScan,
|
|
8
|
+
segmentTokenizer
|
|
9
|
+
} from "./chunk-I3JDRCMW.js";
|
|
15
10
|
import {
|
|
16
11
|
fuseRetrieval
|
|
17
12
|
} from "./chunk-AURFOK3D.js";
|
|
13
|
+
import {
|
|
14
|
+
decodeVecId,
|
|
15
|
+
deriveChunkVectors,
|
|
16
|
+
embeddingSourceText,
|
|
17
|
+
encodeVecId,
|
|
18
|
+
isVecIdFor
|
|
19
|
+
} from "./chunk-MDWKM2XC.js";
|
|
18
20
|
import {
|
|
19
21
|
isStaticDictDescriptor,
|
|
20
22
|
stripI18nFilled
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-GHLTDZRS.js";
|
|
22
24
|
import {
|
|
23
25
|
liveRecordIsElevated
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JCN44NCY.js";
|
|
25
27
|
import {
|
|
26
28
|
EmbeddingDimMismatchError
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-244VXYPG.js";
|
|
28
30
|
|
|
29
31
|
// src/with-lookup/search/collection-facade.ts
|
|
30
32
|
async function search(ctx, field, query, opts = {}) {
|
|
@@ -51,6 +53,10 @@ function buildRetrievalDocs(ctx, labelMaps, blobFilenames, only) {
|
|
|
51
53
|
}
|
|
52
54
|
return docs;
|
|
53
55
|
}
|
|
56
|
+
function positionBuildOptions(ctx) {
|
|
57
|
+
const fields = ctx.textIndexPositions;
|
|
58
|
+
return fields && fields.length > 0 ? { positions: fields } : void 0;
|
|
59
|
+
}
|
|
54
60
|
function hasIndexedBlobFields(ctx, only) {
|
|
55
61
|
if (!ctx.blobFields || !ctx.textIndexes) return false;
|
|
56
62
|
const fields = only ? ctx.textIndexes.filter((f) => only.includes(f)) : ctx.textIndexes;
|
|
@@ -106,7 +112,7 @@ async function flushIndex(ctx) {
|
|
|
106
112
|
await ctx.ensureHydrated();
|
|
107
113
|
const labelMaps = await resolveDictLabelMaps(ctx);
|
|
108
114
|
const blobFilenames = await resolveBlobFilenames(ctx);
|
|
109
|
-
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
115
|
+
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames), positionBuildOptions(ctx));
|
|
110
116
|
await ctx.searchIndexStore.flush?.();
|
|
111
117
|
}
|
|
112
118
|
function buildVectorLoad(ctx) {
|
|
@@ -127,7 +133,12 @@ function buildVectorLoad(ctx) {
|
|
|
127
133
|
}
|
|
128
134
|
if (body === null) continue;
|
|
129
135
|
const parsed = JSON.parse(body);
|
|
130
|
-
|
|
136
|
+
if (parsed.chunks && parsed.chunks.length > 0) {
|
|
137
|
+
const chunks = parsed.chunks.map((c) => ({ id: c.id, start: c.start, end: c.end, vec: new Float32Array(c.vec) }));
|
|
138
|
+
out.push({ id, model: parsed.model, chunks });
|
|
139
|
+
} else if (parsed.vec) {
|
|
140
|
+
out.push({ id, vec: new Float32Array(parsed.vec), model: parsed.model });
|
|
141
|
+
}
|
|
131
142
|
}
|
|
132
143
|
return out;
|
|
133
144
|
};
|
|
@@ -178,15 +189,39 @@ async function warmIndex(ctx) {
|
|
|
178
189
|
const built = ctx.searchIndexStore.built;
|
|
179
190
|
const labelMaps = built ? /* @__PURE__ */ new Map() : await resolveDictLabelMaps(ctx);
|
|
180
191
|
const blobFilenames = built ? /* @__PURE__ */ new Map() : await resolveBlobFilenames(ctx);
|
|
181
|
-
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
192
|
+
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames), positionBuildOptions(ctx));
|
|
182
193
|
}
|
|
194
|
+
var NO_LIMIT = Number.POSITIVE_INFINITY;
|
|
183
195
|
async function retrieve(ctx, query, opts = {}) {
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
if (opts.within === void 0) {
|
|
197
|
+
return opts.mode === "semantic" ? retrieveSemantic(ctx, query, opts) : opts.mode === "hybrid" ? retrieveHybrid(ctx, query, opts) : retrieveLexical(ctx, query, opts);
|
|
198
|
+
}
|
|
199
|
+
if (segmentTokenizer(query).length === 0) return retrieveWithinOnly(ctx, opts, opts.within);
|
|
200
|
+
const unlimited = { ...opts, limit: NO_LIMIT };
|
|
201
|
+
const hits = opts.mode === "semantic" ? await retrieveSemantic(ctx, query, unlimited) : opts.mode === "hybrid" ? await retrieveHybrid(ctx, query, unlimited) : await retrieveLexical(ctx, query, unlimited);
|
|
202
|
+
return applyWithin(hits, opts.within, opts.limit);
|
|
186
203
|
}
|
|
187
|
-
function applyWithin(hits, within) {
|
|
204
|
+
function applyWithin(hits, within, limit) {
|
|
188
205
|
const ids = new Set(within._idArray());
|
|
189
|
-
|
|
206
|
+
const kept = hits.filter((h) => ids.has(h.id));
|
|
207
|
+
const limited = limit !== void 0 ? kept.slice(0, limit) : kept;
|
|
208
|
+
return limited.map((h, i) => ({ ...h, rank: i + 1 }));
|
|
209
|
+
}
|
|
210
|
+
async function retrieveWithinOnly(ctx, opts, within) {
|
|
211
|
+
if (ctx.lazy) {
|
|
212
|
+
throw new Error(`Collection "${ctx.name}": retrieve() requires eager mode (prefetch: true).`);
|
|
213
|
+
}
|
|
214
|
+
await ctx.ensureHydrated();
|
|
215
|
+
const ids = within._idArray();
|
|
216
|
+
const limited = opts.limit !== void 0 ? ids.slice(0, opts.limit) : ids;
|
|
217
|
+
return limited.map((id, i) => {
|
|
218
|
+
const base = { id, score: 0, rank: i + 1, field: "(within)", snippet: "" };
|
|
219
|
+
if (opts.includeRecord) {
|
|
220
|
+
const e = ctx.cache.get(id);
|
|
221
|
+
if (e) base.record = stripI18nFilled(e.record);
|
|
222
|
+
}
|
|
223
|
+
return base;
|
|
224
|
+
});
|
|
190
225
|
}
|
|
191
226
|
async function retrieveLexical(ctx, query, opts) {
|
|
192
227
|
if (!ctx.searchIndexStore) {
|
|
@@ -201,12 +236,13 @@ async function retrieveLexical(ctx, query, opts) {
|
|
|
201
236
|
const built = ctx.searchIndexStore.built;
|
|
202
237
|
const labelMaps = built ? /* @__PURE__ */ new Map() : await resolveDictLabelMaps(ctx);
|
|
203
238
|
const blobFilenames = built ? /* @__PURE__ */ new Map() : await resolveBlobFilenames(ctx);
|
|
204
|
-
const index = await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
239
|
+
const index = await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames), positionBuildOptions(ctx));
|
|
205
240
|
const hits = index.query(query, {
|
|
206
241
|
...opts.limit !== void 0 ? { limit: opts.limit } : {},
|
|
207
242
|
...opts.match ? { match: opts.match } : {},
|
|
208
243
|
...opts.prefix ? { prefix: opts.prefix } : {},
|
|
209
|
-
...opts.fields ? { fields: opts.fields } : {}
|
|
244
|
+
...opts.fields ? { fields: opts.fields } : {},
|
|
245
|
+
...opts.boost ? { boost: opts.boost } : {}
|
|
210
246
|
});
|
|
211
247
|
const window = opts.snippetWindow ?? 80;
|
|
212
248
|
return hits.map((h, i) => {
|
|
@@ -242,7 +278,9 @@ async function retrieveSemantic(ctx, query, opts) {
|
|
|
242
278
|
return similarTo(ctx, qVec, {
|
|
243
279
|
...opts.limit !== void 0 ? { k: opts.limit } : {},
|
|
244
280
|
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
245
|
-
...opts.includeRecord ? { includeRecord: true } : {}
|
|
281
|
+
...opts.includeRecord ? { includeRecord: true } : {},
|
|
282
|
+
...opts.exact !== void 0 ? { exact: opts.exact } : {},
|
|
283
|
+
...opts.nprobe !== void 0 ? { nprobe: opts.nprobe } : {}
|
|
246
284
|
});
|
|
247
285
|
}
|
|
248
286
|
async function similarTo(ctx, vector, opts = {}) {
|
|
@@ -250,28 +288,51 @@ async function similarTo(ctx, vector, opts = {}) {
|
|
|
250
288
|
if (ctx.lazy) throw new Error(`Collection "${ctx.name}": similarTo() requires eager mode (prefetch: true).`);
|
|
251
289
|
await ctx.ensureHydrated();
|
|
252
290
|
await ctx.vectorSet.ensureLoaded(buildVectorLoad(ctx));
|
|
253
|
-
const hits = ctx.vectorSet.
|
|
291
|
+
const hits = await ctx.vectorSet.topK(vector, opts.k ?? 10, {
|
|
254
292
|
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
293
|
+
...opts.exact !== void 0 ? { exact: opts.exact } : {},
|
|
294
|
+
...opts.nprobe !== void 0 ? { nprobe: opts.nprobe } : {},
|
|
255
295
|
expectModel: ctx.embeddings.model
|
|
256
296
|
});
|
|
257
297
|
return hits.map((h, i) => {
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
298
|
+
const e = ctx.cache.get(h.id);
|
|
299
|
+
let snippet = "";
|
|
300
|
+
if (h.chunk && e && ctx.embeddings) {
|
|
301
|
+
snippet = embeddingSourceText(e.record, ctx.embeddings.source).slice(h.chunk.start, h.chunk.end);
|
|
262
302
|
}
|
|
303
|
+
const base = { id: h.id, score: h.score, rank: i + 1, field: "(vector)", snippet, ...h.chunk ? { chunk: h.chunk } : {} };
|
|
304
|
+
if (opts.includeRecord && e) base.record = stripI18nFilled(e.record);
|
|
263
305
|
return base;
|
|
264
306
|
});
|
|
265
307
|
}
|
|
266
308
|
async function embedOnWrite(ctx, id, record, version) {
|
|
267
309
|
if (!ctx.embeddings) return;
|
|
268
310
|
const text = embeddingSourceText(record, ctx.embeddings.source);
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
311
|
+
const chunks = await deriveChunkVectors(text, ctx.embeddings);
|
|
312
|
+
let body;
|
|
313
|
+
let writtenVec;
|
|
314
|
+
if (chunks.length > 0) {
|
|
315
|
+
for (const c of chunks) {
|
|
316
|
+
if (c.vec.length !== ctx.embeddings.dim) throw new EmbeddingDimMismatchError("embeddings", ctx.embeddings.dim, c.vec.length);
|
|
317
|
+
}
|
|
318
|
+
body = JSON.stringify({
|
|
319
|
+
chunks: chunks.map((c) => ({ id: c.id, start: c.start, end: c.end, vec: Array.from(c.vec) })),
|
|
320
|
+
model: ctx.embeddings.model,
|
|
321
|
+
dim: ctx.embeddings.dim
|
|
322
|
+
});
|
|
323
|
+
} else {
|
|
324
|
+
const vec = await ctx.embeddings.encode(text);
|
|
325
|
+
if (vec.length !== ctx.embeddings.dim) throw new EmbeddingDimMismatchError("embeddings", ctx.embeddings.dim, vec.length);
|
|
326
|
+
writtenVec = vec;
|
|
327
|
+
body = JSON.stringify({ vec: Array.from(vec), model: ctx.embeddings.model, dim: ctx.embeddings.dim });
|
|
328
|
+
}
|
|
272
329
|
const vecEnv = await ctx.codec.encryptJsonString({ collection: "_vec", id: encodeVecId(ctx.name, id) }, body, version);
|
|
273
330
|
await ctx.adapter.put(ctx.vault, "_vec", encodeVecId(ctx.name, id), vecEnv);
|
|
274
|
-
|
|
331
|
+
if (chunks.length > 0) {
|
|
332
|
+
ctx.vectorSet?.upsert({ id, model: ctx.embeddings.model, chunks: chunks.map((c) => ({ id: c.id, start: c.start, end: c.end, vec: c.vec })) });
|
|
333
|
+
} else {
|
|
334
|
+
ctx.vectorSet?.upsert({ id, model: ctx.embeddings.model, vec: writtenVec });
|
|
335
|
+
}
|
|
275
336
|
}
|
|
276
337
|
async function rebuildEmbeddings(ctx) {
|
|
277
338
|
if (!ctx.embeddings) return { rebuilt: 0, skipped: 0 };
|
|
@@ -302,7 +363,7 @@ async function syncTierSearch(ctx, id, record, version) {
|
|
|
302
363
|
if (!ctx.searchIndexStore && !ctx.vectorSet) return;
|
|
303
364
|
if (record === null) {
|
|
304
365
|
await ctx.adapter.delete(ctx.vault, "_vec", encodeVecId(ctx.name, id));
|
|
305
|
-
ctx.vectorSet?.
|
|
366
|
+
ctx.vectorSet?.removeRecord(id);
|
|
306
367
|
} else {
|
|
307
368
|
await embedOnWrite(ctx, id, record, version ?? 1);
|
|
308
369
|
}
|
|
@@ -314,6 +375,7 @@ async function syncTierSearch(ctx, id, record, version) {
|
|
|
314
375
|
export {
|
|
315
376
|
search,
|
|
316
377
|
buildRetrievalDocs,
|
|
378
|
+
positionBuildOptions,
|
|
317
379
|
hasIndexedBlobFields,
|
|
318
380
|
flushIndex,
|
|
319
381
|
buildPersistedIndexCallbacks,
|
|
@@ -324,4 +386,4 @@ export {
|
|
|
324
386
|
rebuildEmbeddings,
|
|
325
387
|
syncTierSearch
|
|
326
388
|
};
|
|
327
|
-
//# sourceMappingURL=chunk-
|
|
389
|
+
//# sourceMappingURL=chunk-6LNL42F5.js.map
|