@noy-db/hub 0.2.0-pre.9 → 0.3.0-pre.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dist/aggregate/index.d.ts +5 -2
- package/dist/aggregate/index.js +25 -16
- package/dist/aggregate/index.js.map +1 -1
- package/dist/api-TX2EX2FX.js +20 -0
- package/dist/as/index.d.ts +6 -0
- package/dist/as/index.js +30 -0
- package/dist/at/index.d.ts +4 -0
- package/dist/at/index.js +1 -0
- package/dist/attestation/index.d.ts +14 -47
- package/dist/attestation/index.js +60 -10
- package/dist/attestation/index.js.map +1 -1
- package/dist/backup-R7NTDFKY.js +225 -0
- package/dist/backup-R7NTDFKY.js.map +1 -0
- package/dist/blobs/index.d.ts +5 -8
- package/dist/blobs/index.js +25 -12
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.d.ts +15 -70
- package/dist/bundle/index.js +45 -476
- package/dist/bundle/index.js.map +1 -1
- package/dist/{ulid-CJ8RzRrm.d.ts → bundle-D6GxiUfq.d.ts} +31 -86
- package/dist/by/index.d.ts +1 -0
- package/dist/by/index.js +11 -0
- package/dist/cargo/index.d.ts +7 -0
- package/dist/cargo/index.js +95 -0
- package/dist/chunk-2OV5NVE7.js +95 -0
- package/dist/chunk-2OV5NVE7.js.map +1 -0
- package/dist/chunk-2OZXVKVP.js +367 -0
- package/dist/chunk-2OZXVKVP.js.map +1 -0
- package/dist/{chunk-HNRHLRDC.js → chunk-2REPHKET.js} +6 -5
- package/dist/chunk-2REPHKET.js.map +1 -0
- package/dist/{chunk-PE2FR4J3.js → chunk-3JXPAHOZ.js} +17 -17
- package/dist/chunk-3JXPAHOZ.js.map +1 -0
- package/dist/{chunk-H2X3ISXG.js → chunk-3MATJ6O4.js} +7 -7
- package/dist/chunk-3MATJ6O4.js.map +1 -0
- package/dist/{chunk-PP6W64Y3.js → chunk-3OPY6MK2.js} +132 -3
- package/dist/chunk-3OPY6MK2.js.map +1 -0
- package/dist/{chunk-T7JEBOGN.js → chunk-3QSIU3UT.js} +49 -71
- package/dist/chunk-3QSIU3UT.js.map +1 -0
- package/dist/{chunk-ZYWZWG6G.js → chunk-4OMCIY6F.js} +32 -12
- package/dist/chunk-4OMCIY6F.js.map +1 -0
- package/dist/chunk-4Q6HSHHL.js +90 -0
- package/dist/chunk-4Q6HSHHL.js.map +1 -0
- package/dist/chunk-5I35DOHK.js +94 -0
- package/dist/chunk-5I35DOHK.js.map +1 -0
- package/dist/chunk-5VG4IJR7.js +235 -0
- package/dist/chunk-5VG4IJR7.js.map +1 -0
- package/dist/chunk-5YESYH2C.js +155 -0
- package/dist/chunk-5YESYH2C.js.map +1 -0
- package/dist/chunk-6G5ORS5D.js +202 -0
- package/dist/chunk-6G5ORS5D.js.map +1 -0
- package/dist/{chunk-VTKGMEPP.js → chunk-6P5XCKSD.js} +13 -3
- package/dist/chunk-6P5XCKSD.js.map +1 -0
- package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
- package/dist/chunk-6S7T6WC4.js.map +1 -0
- package/dist/{chunk-U26HQ6KJ.js → chunk-7BWJHO2A.js} +4 -4
- package/dist/chunk-7BWJHO2A.js.map +1 -0
- package/dist/chunk-7P2SDJG3.js +279 -0
- package/dist/chunk-7P2SDJG3.js.map +1 -0
- package/dist/chunk-ANB77BVV.js +150 -0
- package/dist/chunk-ANB77BVV.js.map +1 -0
- package/dist/chunk-AURFOK3D.js +35 -0
- package/dist/chunk-AURFOK3D.js.map +1 -0
- package/dist/chunk-BKARNZJN.js +382 -0
- package/dist/chunk-BKARNZJN.js.map +1 -0
- package/dist/{chunk-3BFJOWSU.js → chunk-BQISD5ZV.js} +35 -7
- package/dist/chunk-BQISD5ZV.js.map +1 -0
- package/dist/{chunk-2GLDA55J.js → chunk-BUAQ7YI3.js} +260 -135
- package/dist/chunk-BUAQ7YI3.js.map +1 -0
- package/dist/{chunk-2WUSG3IT.js → chunk-CB7CWSKW.js} +5 -5
- package/dist/chunk-CB7CWSKW.js.map +1 -0
- package/dist/chunk-CHFZDSE4.js +1 -0
- package/dist/{aggregate/index.cjs → chunk-DFVUTGT2.js} +206 -222
- package/dist/chunk-DFVUTGT2.js.map +1 -0
- package/dist/chunk-DJ7KIPLV.js +23 -0
- package/dist/chunk-DJ7KIPLV.js.map +1 -0
- package/dist/chunk-DSKDQP3G.js +14066 -0
- package/dist/chunk-DSKDQP3G.js.map +1 -0
- package/dist/{chunk-5T22KDPN.js → chunk-DV4HUP5G.js} +10 -8
- package/dist/chunk-DV4HUP5G.js.map +1 -0
- package/dist/chunk-EOXAAJTY.js +621 -0
- package/dist/chunk-EOXAAJTY.js.map +1 -0
- package/dist/chunk-ET67AY6B.js +74 -0
- package/dist/chunk-ET67AY6B.js.map +1 -0
- package/dist/chunk-F4CEK5YM.js +123 -0
- package/dist/chunk-F4CEK5YM.js.map +1 -0
- package/dist/chunk-FORYWFN6.js +130 -0
- package/dist/chunk-FORYWFN6.js.map +1 -0
- package/dist/{chunk-JWRVQKRZ.js → chunk-FRP6D2DM.js} +21 -20
- package/dist/chunk-FRP6D2DM.js.map +1 -0
- package/dist/chunk-FUOE7UUV.js +341 -0
- package/dist/chunk-FUOE7UUV.js.map +1 -0
- package/dist/chunk-G4JYND6L.js +42 -0
- package/dist/chunk-G4JYND6L.js.map +1 -0
- package/dist/{chunk-53XBRIRT.js → chunk-G6XV4H65.js} +9 -9
- package/dist/chunk-G6XV4H65.js.map +1 -0
- package/dist/chunk-GHVIKOHT.js +1 -0
- package/dist/{chunk-PX35GA7L.js → chunk-GNMXXTMN.js} +11 -9
- package/dist/chunk-GNMXXTMN.js.map +1 -0
- package/dist/chunk-GYGLAVCX.js +19 -0
- package/dist/chunk-GYGLAVCX.js.map +1 -0
- package/dist/chunk-HPWKV3YB.js +21 -0
- package/dist/chunk-HPWKV3YB.js.map +1 -0
- package/dist/chunk-HY3AUMFI.js +41 -0
- package/dist/chunk-HY3AUMFI.js.map +1 -0
- package/dist/chunk-HYR4WZZ3.js +69 -0
- package/dist/chunk-HYR4WZZ3.js.map +1 -0
- package/dist/chunk-I7FD46FF.js +9 -0
- package/dist/chunk-I7FD46FF.js.map +1 -0
- package/dist/{chunk-TFBP23BX.js → chunk-ICXIFFYZ.js} +66 -7
- package/dist/chunk-ICXIFFYZ.js.map +1 -0
- package/dist/{chunk-TV3YZ35S.js → chunk-IGJCYUT5.js} +17 -8
- package/dist/chunk-IGJCYUT5.js.map +1 -0
- package/dist/{chunk-F3GDRNUT.js → chunk-IVLTXX4W.js} +36 -68
- package/dist/chunk-IVLTXX4W.js.map +1 -0
- package/dist/{chunk-DONMZAD2.js → chunk-J4LPNIGK.js} +62 -169
- package/dist/chunk-J4LPNIGK.js.map +1 -0
- package/dist/chunk-JJZ2LW6T.js +36 -0
- package/dist/chunk-JJZ2LW6T.js.map +1 -0
- package/dist/chunk-JK733I5V.js +23 -0
- package/dist/chunk-JK733I5V.js.map +1 -0
- package/dist/{chunk-3YPCK6JX.js → chunk-KJ2BCBTL.js} +181 -422
- package/dist/chunk-KJ2BCBTL.js.map +1 -0
- package/dist/chunk-KNZB6JMR.js +129 -0
- package/dist/chunk-KNZB6JMR.js.map +1 -0
- package/dist/{chunk-OIF6LZUR.js → chunk-KPZS5QAQ.js} +30 -11
- package/dist/chunk-KPZS5QAQ.js.map +1 -0
- package/dist/chunk-LB7FD65R.js +163 -0
- package/dist/chunk-LB7FD65R.js.map +1 -0
- package/dist/{chunk-DO7C2TOG.js → chunk-LEJIKBBB.js} +3 -3
- package/dist/{chunk-DO7C2TOG.js.map → chunk-LEJIKBBB.js.map} +1 -1
- package/dist/{chunk-O3VZPBZG.js → chunk-LL2NIVUR.js} +56 -13
- package/dist/chunk-LL2NIVUR.js.map +1 -0
- package/dist/chunk-LP7BEXCT.js +32 -0
- package/dist/chunk-LP7BEXCT.js.map +1 -0
- package/dist/chunk-MCHVVJIA.js +968 -0
- package/dist/chunk-MCHVVJIA.js.map +1 -0
- package/dist/chunk-NO272T7Q.js +194 -0
- package/dist/chunk-NO272T7Q.js.map +1 -0
- package/dist/{chunk-22DWZL57.js → chunk-NUEQU36L.js} +70 -267
- package/dist/chunk-NUEQU36L.js.map +1 -0
- package/dist/chunk-O45M6LDB.js +38 -0
- package/dist/chunk-O45M6LDB.js.map +1 -0
- package/dist/chunk-OBKWYKYC.js +117 -0
- package/dist/chunk-OBKWYKYC.js.map +1 -0
- package/dist/{chunk-DJHHA6XH.js → chunk-OHHKHSJP.js} +50 -20
- package/dist/chunk-OHHKHSJP.js.map +1 -0
- package/dist/chunk-OT76OZL6.js +45 -0
- package/dist/chunk-OT76OZL6.js.map +1 -0
- package/dist/chunk-OVYRLHPE.js +150 -0
- package/dist/chunk-OVYRLHPE.js.map +1 -0
- package/dist/{chunk-ML236QKC.js → chunk-OXCSVM3B.js} +5 -5
- package/dist/chunk-OXCSVM3B.js.map +1 -0
- package/dist/chunk-P33LUIML.js +205 -0
- package/dist/chunk-P33LUIML.js.map +1 -0
- package/dist/{chunk-DL3HWOQ5.js → chunk-PLS64NCS.js} +10 -8
- package/dist/chunk-PLS64NCS.js.map +1 -0
- package/dist/{chunk-SYMWGEET.js → chunk-PS2NEWEX.js} +3 -3
- package/dist/chunk-PS2NEWEX.js.map +1 -0
- package/dist/chunk-PY4KJPYU.js +9 -0
- package/dist/chunk-PY4KJPYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-QA2KUPCP.js +45 -0
- package/dist/chunk-QA2KUPCP.js.map +1 -0
- package/dist/chunk-QOC3VYL2.js +30 -0
- package/dist/chunk-QOC3VYL2.js.map +1 -0
- package/dist/{chunk-BVRYKATC.js → chunk-QSFOZUYL.js} +62 -34
- package/dist/chunk-QSFOZUYL.js.map +1 -0
- package/dist/chunk-RHK32N73.js +30 -0
- package/dist/chunk-RHK32N73.js.map +1 -0
- package/dist/{chunk-K3DK3NU5.js → chunk-RW3Y22MW.js} +20 -5
- package/dist/chunk-RW3Y22MW.js.map +1 -0
- package/dist/{chunk-B6PB7JLN.js → chunk-S7VFUQM2.js} +541 -6
- package/dist/chunk-S7VFUQM2.js.map +1 -0
- package/dist/chunk-SVLR4POP.js +64 -0
- package/dist/chunk-SVLR4POP.js.map +1 -0
- package/dist/chunk-T7WSLRAU.js +49 -0
- package/dist/chunk-T7WSLRAU.js.map +1 -0
- package/dist/{chunk-WPLVTJ5D.js → chunk-TAKWLZZX.js} +285 -63
- package/dist/chunk-TAKWLZZX.js.map +1 -0
- package/dist/chunk-THNJ3IKU.js +17 -0
- package/dist/chunk-THNJ3IKU.js.map +1 -0
- package/dist/{chunk-XJFLDA7A.js → chunk-TMBXVJKT.js} +9 -6
- package/dist/chunk-TMBXVJKT.js.map +1 -0
- package/dist/chunk-TWKKOM55.js +54 -0
- package/dist/chunk-TWKKOM55.js.map +1 -0
- package/dist/chunk-U3WZCU7E.js +14 -0
- package/dist/chunk-U3WZCU7E.js.map +1 -0
- package/dist/{chunk-Z6FNBOTC.js → chunk-UF362QVH.js} +15 -17
- package/dist/chunk-UF362QVH.js.map +1 -0
- package/dist/chunk-UN4FVIBH.js +135 -0
- package/dist/chunk-UN4FVIBH.js.map +1 -0
- package/dist/chunk-VEAVKDDB.js +29 -0
- package/dist/chunk-VEAVKDDB.js.map +1 -0
- package/dist/chunk-VEPTFUJY.js +29 -0
- package/dist/chunk-VEPTFUJY.js.map +1 -0
- package/dist/chunk-VJV7GKQK.js +662 -0
- package/dist/chunk-VJV7GKQK.js.map +1 -0
- package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
- package/dist/chunk-VQNJ7UZL.js.map +1 -0
- package/dist/chunk-VQRAIPYF.js +50 -0
- package/dist/chunk-VQRAIPYF.js.map +1 -0
- package/dist/{chunk-DFMLEQZB.js → chunk-VRIYFLBA.js} +5 -10
- package/dist/chunk-VRIYFLBA.js.map +1 -0
- package/dist/chunk-VWM3DAVB.js +265 -0
- package/dist/chunk-VWM3DAVB.js.map +1 -0
- package/dist/{chunk-NONAAENK.js → chunk-VWRRVE6D.js} +11 -4
- package/dist/chunk-VWRRVE6D.js.map +1 -0
- package/dist/chunk-VYYM3MEN.js +98 -0
- package/dist/chunk-VYYM3MEN.js.map +1 -0
- package/dist/chunk-WBJIQSLL.js +167 -0
- package/dist/chunk-WBJIQSLL.js.map +1 -0
- package/dist/chunk-WIGQB62E.js +164 -0
- package/dist/chunk-WIGQB62E.js.map +1 -0
- package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
- package/dist/chunk-WXSYDNBT.js.map +1 -0
- package/dist/chunk-WZSCE6RM.js +466 -0
- package/dist/chunk-WZSCE6RM.js.map +1 -0
- package/dist/chunk-XGDAPN6M.js +255 -0
- package/dist/chunk-XGDAPN6M.js.map +1 -0
- package/dist/{chunk-QODLLGQ7.js → chunk-XH7XP3OL.js} +372 -37
- package/dist/chunk-XH7XP3OL.js.map +1 -0
- package/dist/chunk-XREOISSI.js +40 -0
- package/dist/chunk-XREOISSI.js.map +1 -0
- package/dist/chunk-XUBPSPKD.js +164 -0
- package/dist/chunk-XUBPSPKD.js.map +1 -0
- package/dist/chunk-Y3A5CB5G.js +247 -0
- package/dist/chunk-Y3A5CB5G.js.map +1 -0
- package/dist/{chunk-I5FOWO4J.js → chunk-YCXCR7VG.js} +52 -73
- package/dist/chunk-YCXCR7VG.js.map +1 -0
- package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
- package/dist/chunk-YMUGBZN2.js.map +1 -0
- package/dist/chunk-YMVQD5Q5.js +453 -0
- package/dist/chunk-YMVQD5Q5.js.map +1 -0
- package/dist/chunk-YN5IAHN6.js +32 -0
- package/dist/chunk-YN5IAHN6.js.map +1 -0
- package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
- package/dist/chunk-ZJADGNYF.js.map +1 -0
- package/dist/chunk-ZYJ55N7N.js +86 -0
- package/dist/chunk-ZYJ55N7N.js.map +1 -0
- package/dist/classified/index.d.ts +16 -0
- package/dist/classified/index.js +40 -0
- package/dist/classified-marker-H6YSHYNK.js +24 -0
- package/dist/classified-marker-H6YSHYNK.js.map +1 -0
- package/dist/collection-facade-LVD22JLM.js +39 -0
- package/dist/computed-EXDMQODG.js +11 -0
- package/dist/consent/index.d.ts +4 -7
- package/dist/consent/index.js +13 -5
- package/dist/consent/index.js.map +1 -1
- package/dist/crdt/index.d.ts +5 -2
- package/dist/crdt/index.js +3 -2
- package/dist/crdt/index.js.map +1 -1
- package/dist/dead-filter-HQIE2YG7.js +28 -0
- package/dist/dead-filter-HQIE2YG7.js.map +1 -0
- package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
- package/dist/delegation-BJP73GAP.js +25 -0
- package/dist/derivations/index.d.ts +6 -9
- package/dist/derivations/index.js +18 -6
- package/dist/derive-BME7HDWO.js +21 -0
- package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-Bmm2pgJ0.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/enclave-NHORSWSF.js +125 -0
- package/dist/executor-FE6X4LFX.js +9 -0
- package/dist/executor-KSHKRJXP.js +25 -0
- package/dist/executor-ZHTJJICG.js +9 -0
- package/dist/export-accessible-DACHM5VT.js +23 -0
- package/dist/extract-partition-RNENZZ4T.js +36 -0
- package/dist/fanout-sidecar-OFWN3NM7.js +74 -0
- package/dist/fanout-sidecar-OFWN3NM7.js.map +1 -0
- package/dist/fence-watcher-DHQ775JB.js +69 -0
- package/dist/fence-watcher-DHQ775JB.js.map +1 -0
- package/dist/find-BNGBJNKP.js +11 -0
- package/dist/forget/index.d.ts +36 -0
- package/dist/forget/index.js +25 -0
- package/dist/forget/index.js.map +1 -0
- package/dist/guards/index.d.ts +12 -9
- package/dist/guards/index.js +12 -5
- package/dist/{hash-DdpVypUp.d.cts → hash-DAJjMsCE.d.ts} +10 -1
- package/dist/history/index.d.ts +5 -8
- package/dist/history/index.js +25 -12
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.d.ts +25 -8
- package/dist/i18n/index.js +137 -29
- package/dist/i18n/index.js.map +1 -1
- package/dist/in/index.d.ts +4 -0
- package/dist/in/index.js +1 -0
- package/dist/in/index.js.map +1 -0
- package/dist/index-B9QdHytu.d.ts +123 -0
- package/dist/index-DjWbxsjb.d.ts +23579 -0
- package/dist/index-qwuNvO2B.d.ts +144 -0
- package/dist/index.d.ts +1179 -449
- package/dist/index.js +2524 -312
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.d.ts +5 -3
- package/dist/indexing/index.js +6 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-NDI4CVZU.js +19 -0
- package/dist/issue-NDI4CVZU.js.map +1 -0
- package/dist/json-schema-I22JCYCG.js +44 -0
- package/dist/json-schema-I22JCYCG.js.map +1 -0
- package/dist/lazy/index.d.ts +20 -0
- package/dist/lazy/index.js +12 -0
- package/dist/lazy/index.js.map +1 -0
- package/dist/ledger-6NDS2EO4.js +42 -0
- package/dist/ledger-6NDS2EO4.js.map +1 -0
- package/dist/liberate-HN3RIGIP.js +24 -0
- package/dist/liberate-HN3RIGIP.js.map +1 -0
- package/dist/link-set-SJB2MVJV.js +31 -0
- package/dist/link-set-SJB2MVJV.js.map +1 -0
- package/dist/materialized-views/index.d.ts +23 -20
- package/dist/materialized-views/index.js +26 -12
- package/dist/mime-magic-bBj5OgUC.d.ts +103 -0
- package/dist/noydb-BWF6EPIR.js +66 -0
- package/dist/noydb-BWF6EPIR.js.map +1 -0
- package/dist/on/index.d.ts +4 -0
- package/dist/on/index.js +17 -0
- package/dist/on/index.js.map +1 -0
- package/dist/overlay-views/index.d.ts +26 -11
- package/dist/overlay-views/index.js +7 -6
- package/dist/periods/index.d.ts +4 -7
- package/dist/periods/index.js +27 -9
- package/dist/pod/index.d.ts +62 -0
- package/dist/pod/index.js +67 -0
- package/dist/pod/index.js.map +1 -0
- package/dist/policy-WGNAG5H6.js +41 -0
- package/dist/policy-WGNAG5H6.js.map +1 -0
- package/dist/portability/index.d.ts +19 -0
- package/dist/portability/index.js +43 -0
- package/dist/portability/index.js.map +1 -0
- package/dist/post-register-CWKBQRC7.js +55 -0
- package/dist/post-register-CWKBQRC7.js.map +1 -0
- package/dist/{public-envelope-BW6OXORV.js → public-envelope-EJLVIFX7.js} +6 -5
- package/dist/public-envelope-EJLVIFX7.js.map +1 -0
- package/dist/query/index.d.ts +4 -3
- package/dist/query/index.js +24 -13
- package/dist/read-only-facade-CHCKSEPD.js +8 -0
- package/dist/read-only-facade-CHCKSEPD.js.map +1 -0
- package/dist/register-SBIX7TVV.js +23 -0
- package/dist/register-SBIX7TVV.js.map +1 -0
- package/dist/registry-3EQG6OOE.js +18 -0
- package/dist/registry-3EQG6OOE.js.map +1 -0
- package/dist/registry-CA327ACV.js +9 -0
- package/dist/registry-CA327ACV.js.map +1 -0
- package/dist/registry-E7OXOTSV.js +19 -0
- package/dist/registry-E7OXOTSV.js.map +1 -0
- package/dist/registry-VW6P6A3J.js +8 -0
- package/dist/registry-VW6P6A3J.js.map +1 -0
- package/dist/request-withdrawal-KAH2AAXC.js +31 -0
- package/dist/request-withdrawal-KAH2AAXC.js.map +1 -0
- package/dist/reveal-R3JLHMUF.js +38 -0
- package/dist/reveal-R3JLHMUF.js.map +1 -0
- package/dist/revoke-IXLOJ3IH.js +24 -0
- package/dist/revoke-IXLOJ3IH.js.map +1 -0
- package/dist/satellites/index.d.ts +4 -0
- package/dist/satellites/index.js +8 -0
- package/dist/satellites/index.js.map +1 -0
- package/dist/sealed-record/index.d.ts +68 -0
- package/dist/sealed-record/index.js +71 -0
- package/dist/sealed-record/index.js.map +1 -0
- package/dist/session/index.d.ts +5 -8
- package/dist/session/index.js +13 -5
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.d.ts +4 -7
- package/dist/shadow/index.js +4 -3
- package/dist/shadow/index.js.map +1 -1
- package/dist/signer-Y46N2GJ3.js +25 -0
- package/dist/signer-Y46N2GJ3.js.map +1 -0
- package/dist/snapshots/index.d.ts +5 -8
- package/dist/snapshots/index.js +19 -11
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-6ZDBTQT7.js → stale-Z7IW6RIL.js} +3 -2
- package/dist/stale-Z7IW6RIL.js.map +1 -0
- package/dist/storage-ADNP2UWI.js +23 -0
- package/dist/storage-ADNP2UWI.js.map +1 -0
- package/dist/store-coordination-provider-DTDMI6VL.js +142 -0
- package/dist/store-coordination-provider-DTDMI6VL.js.map +1 -0
- package/dist/subject-index-CyOgGMJL.d.ts +380 -0
- package/dist/sync/index.d.ts +3 -6
- package/dist/sync/index.js +13 -6
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.d.ts +46 -10
- package/dist/team/index.js +35 -18
- package/dist/tiers/index.d.ts +4 -0
- package/dist/tiers/index.js +39 -0
- package/dist/tiers/index.js.map +1 -0
- package/dist/to/index.d.ts +4 -0
- package/dist/to/index.js +16 -0
- package/dist/to/index.js.map +1 -0
- package/dist/transition-guard-DI-krBsZ.d.ts +165 -0
- package/dist/tx/index.d.ts +22 -9
- package/dist/tx/index.js +13 -8
- package/dist/tx/index.js.map +1 -1
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ulid-DRH25k3y.d.ts +66 -0
- package/dist/ulid-PTAIMDG4.js +10 -0
- package/dist/ulid-PTAIMDG4.js.map +1 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +7 -2
- package/dist/util/index.js.map +1 -1
- package/dist/validators-BUcli5Nh.d.ts +101 -0
- package/dist/vault-diff-Z2DUayMe.d.ts +147 -0
- package/dist/verify-JPF2YR5E.js +139 -0
- package/dist/verify-JPF2YR5E.js.map +1 -0
- package/dist/walk-XYA2O3LW.js +241 -0
- package/dist/walk-XYA2O3LW.js.map +1 -0
- package/dist/with/index.d.ts +37 -0
- package/dist/with/index.js +31 -0
- package/dist/with/index.js.map +1 -0
- package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-BUmzlXue.d.ts} +1 -1
- package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-m4FaXXTO.d.ts} +2 -3
- package/dist/with-rollup-DEKGI9vb.d.ts +47 -0
- package/dist/withdraw-accessible-WLV4MTEN.js +28 -0
- package/dist/withdraw-accessible-WLV4MTEN.js.map +1 -0
- package/dist/zod-HAJM7LMS.js +14763 -0
- package/dist/zod-HAJM7LMS.js.map +1 -0
- package/package.json +122 -202
- package/dist/aggregate/index.cjs.map +0 -1
- package/dist/aggregate/index.d.cts +0 -38
- package/dist/attestation/index.cjs +0 -305
- package/dist/attestation/index.cjs.map +0 -1
- package/dist/attestation/index.d.cts +0 -52
- package/dist/blobs/index.cjs +0 -1480
- package/dist/blobs/index.cjs.map +0 -1
- package/dist/blobs/index.d.cts +0 -46
- package/dist/bundle/index.cjs +0 -19264
- package/dist/bundle/index.cjs.map +0 -1
- package/dist/bundle/index.d.cts +0 -176
- package/dist/chunk-22DWZL57.js.map +0 -1
- package/dist/chunk-2GLDA55J.js.map +0 -1
- package/dist/chunk-2QR2PQTT.js.map +0 -1
- package/dist/chunk-2WUSG3IT.js.map +0 -1
- package/dist/chunk-3BFJOWSU.js.map +0 -1
- package/dist/chunk-3YPCK6JX.js.map +0 -1
- package/dist/chunk-53XBRIRT.js.map +0 -1
- package/dist/chunk-5T22KDPN.js.map +0 -1
- package/dist/chunk-5XHKQ56N.js +0 -340
- package/dist/chunk-5XHKQ56N.js.map +0 -1
- package/dist/chunk-6CME4UEK.js +0 -10329
- package/dist/chunk-6CME4UEK.js.map +0 -1
- package/dist/chunk-6STK5TQP.js +0 -139
- package/dist/chunk-6STK5TQP.js.map +0 -1
- package/dist/chunk-A3JMGXPG.js.map +0 -1
- package/dist/chunk-B6PB7JLN.js.map +0 -1
- package/dist/chunk-BVRYKATC.js.map +0 -1
- package/dist/chunk-DE6GKS6G.js +0 -79
- package/dist/chunk-DE6GKS6G.js.map +0 -1
- package/dist/chunk-DFMLEQZB.js.map +0 -1
- package/dist/chunk-DJHHA6XH.js.map +0 -1
- package/dist/chunk-DL3HWOQ5.js.map +0 -1
- package/dist/chunk-DONMZAD2.js.map +0 -1
- package/dist/chunk-EMIGCR7X.js.map +0 -1
- package/dist/chunk-F3GDRNUT.js.map +0 -1
- package/dist/chunk-FZU343FL.js.map +0 -1
- package/dist/chunk-H2X3ISXG.js.map +0 -1
- package/dist/chunk-HNRHLRDC.js.map +0 -1
- package/dist/chunk-I5FOWO4J.js.map +0 -1
- package/dist/chunk-J66GRPNH.js.map +0 -1
- package/dist/chunk-JWRVQKRZ.js.map +0 -1
- package/dist/chunk-K3DK3NU5.js.map +0 -1
- package/dist/chunk-ML236QKC.js.map +0 -1
- package/dist/chunk-NONAAENK.js.map +0 -1
- package/dist/chunk-O3VZPBZG.js.map +0 -1
- package/dist/chunk-OIF6LZUR.js.map +0 -1
- package/dist/chunk-OQ6PIGHA.js +0 -19
- package/dist/chunk-OQ6PIGHA.js.map +0 -1
- package/dist/chunk-PE2FR4J3.js.map +0 -1
- package/dist/chunk-PP6W64Y3.js.map +0 -1
- package/dist/chunk-PX35GA7L.js.map +0 -1
- package/dist/chunk-QEILDE6R.js +0 -793
- package/dist/chunk-QEILDE6R.js.map +0 -1
- package/dist/chunk-QODLLGQ7.js.map +0 -1
- package/dist/chunk-RAZ4OVLL.js +0 -51
- package/dist/chunk-RAZ4OVLL.js.map +0 -1
- package/dist/chunk-SYMWGEET.js.map +0 -1
- package/dist/chunk-T7JEBOGN.js.map +0 -1
- package/dist/chunk-TFBP23BX.js.map +0 -1
- package/dist/chunk-TV3YZ35S.js.map +0 -1
- package/dist/chunk-U26HQ6KJ.js.map +0 -1
- package/dist/chunk-UF3BUNQZ.js +0 -1
- package/dist/chunk-UMLVJTYV.js +0 -20
- package/dist/chunk-UMLVJTYV.js.map +0 -1
- package/dist/chunk-VTKGMEPP.js.map +0 -1
- package/dist/chunk-W6EQLGMB.js +0 -100
- package/dist/chunk-W6EQLGMB.js.map +0 -1
- package/dist/chunk-WIRRPTFH.js +0 -17
- package/dist/chunk-WIRRPTFH.js.map +0 -1
- package/dist/chunk-WPLVTJ5D.js.map +0 -1
- package/dist/chunk-XJFLDA7A.js.map +0 -1
- package/dist/chunk-Z6FNBOTC.js.map +0 -1
- package/dist/chunk-ZYWZWG6G.js.map +0 -1
- package/dist/consent/index.cjs +0 -204
- package/dist/consent/index.cjs.map +0 -1
- package/dist/consent/index.d.cts +0 -25
- package/dist/crdt/index.cjs +0 -152
- package/dist/crdt/index.cjs.map +0 -1
- package/dist/crdt/index.d.cts +0 -30
- package/dist/crypto-HTZ4FJOP.js +0 -44
- package/dist/delegation-RI54P6I5.js +0 -17
- package/dist/derivations/index.cjs +0 -351
- package/dist/derivations/index.cjs.map +0 -1
- package/dist/derivations/index.d.cts +0 -72
- package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
- package/dist/executor-5PNY7LGW.js +0 -8
- package/dist/executor-B4QIYGZX.js +0 -8
- package/dist/executor-BWXXDQ7K.js +0 -11
- package/dist/fanout-sidecar-OKPMMPLG.js +0 -51
- package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
- package/dist/guards/index.cjs +0 -322
- package/dist/guards/index.cjs.map +0 -1
- package/dist/guards/index.d.cts +0 -31
- package/dist/hash-HJqD14vS.d.ts +0 -63
- package/dist/history/index.cjs +0 -1222
- package/dist/history/index.cjs.map +0 -1
- package/dist/history/index.d.cts +0 -63
- package/dist/i18n/index.cjs +0 -1100
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -39
- package/dist/index-4fBVt8j9.d.cts +0 -2387
- package/dist/index-D8I_pyJD.d.ts +0 -2387
- package/dist/index.cjs +0 -24487
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -776
- package/dist/indexing/index.cjs +0 -742
- package/dist/indexing/index.cjs.map +0 -1
- package/dist/indexing/index.d.cts +0 -36
- package/dist/issue-VGDPP4B5.js +0 -12
- package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
- package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
- package/dist/ledger-TMRZYNVJ.js +0 -33
- package/dist/materialized-views/index.cjs +0 -854
- package/dist/materialized-views/index.cjs.map +0 -1
- package/dist/materialized-views/index.d.cts +0 -186
- package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
- package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
- package/dist/noydb-G725ZSZG.js +0 -34
- package/dist/overlay-views/index.cjs +0 -359
- package/dist/overlay-views/index.cjs.map +0 -1
- package/dist/overlay-views/index.d.cts +0 -82
- package/dist/periods/index.cjs +0 -1041
- package/dist/periods/index.cjs.map +0 -1
- package/dist/periods/index.d.cts +0 -22
- package/dist/predicate-BSAGEyu5.d.cts +0 -209
- package/dist/predicate-BSAGEyu5.d.ts +0 -209
- package/dist/query/index.cjs +0 -2375
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -3
- package/dist/read-only-facade-ITU6L7BL.js +0 -7
- package/dist/registry-3QP3YKQS.js +0 -8
- package/dist/registry-DKEXOJVO.js +0 -7
- package/dist/registry-OJIOSBV6.js +0 -10
- package/dist/registry-USRVT6YF.js +0 -8
- package/dist/revoke-JCC7N56X.js +0 -17
- package/dist/session/index.cjs +0 -495
- package/dist/session/index.cjs.map +0 -1
- package/dist/session/index.d.cts +0 -46
- package/dist/shadow/index.cjs +0 -133
- package/dist/shadow/index.cjs.map +0 -1
- package/dist/shadow/index.d.cts +0 -17
- package/dist/signer-72QAUSVW.js +0 -18
- package/dist/snapshots/index.cjs +0 -937
- package/dist/snapshots/index.cjs.map +0 -1
- package/dist/snapshots/index.d.cts +0 -28
- package/dist/store/index.cjs +0 -1083
- package/dist/store/index.cjs.map +0 -1
- package/dist/store/index.d.cts +0 -492
- package/dist/store/index.d.ts +0 -492
- package/dist/store/index.js +0 -37
- package/dist/strategy-BSxFXGzb.d.cts +0 -110
- package/dist/strategy-BSxFXGzb.d.ts +0 -110
- package/dist/strategy-DSTrsZ8t.d.cts +0 -601
- package/dist/strategy-DSTrsZ8t.d.ts +0 -601
- package/dist/sync/index.cjs +0 -1062
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.d.cts +0 -43
- package/dist/team/index.cjs +0 -2798
- package/dist/team/index.cjs.map +0 -1
- package/dist/team/index.d.cts +0 -118
- package/dist/tx/index.cjs +0 -544
- package/dist/tx/index.cjs.map +0 -1
- package/dist/tx/index.d.cts +0 -21
- package/dist/types-Df28QFKb.d.ts +0 -12818
- package/dist/types-DyXYr8rE.d.cts +0 -12818
- package/dist/ulid-COREQ2RQ.js +0 -9
- package/dist/ulid-Drr7ykr6.d.cts +0 -603
- package/dist/util/index.cjs +0 -230
- package/dist/util/index.cjs.map +0 -1
- package/dist/util/index.d.cts +0 -77
- package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
- package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
- package/dist/with-guard-ByyxmEe7.d.cts +0 -18
- package/dist/with-guard-qube6BMI.d.ts +0 -18
- package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
- package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
- /package/dist/{chunk-UF3BUNQZ.js.map → api-TX2EX2FX.js.map} +0 -0
- /package/dist/{store → as}/index.js.map +0 -0
- /package/dist/{crypto-HTZ4FJOP.js.map → at/index.js.map} +0 -0
- /package/dist/{delegation-RI54P6I5.js.map → by/index.js.map} +0 -0
- /package/dist/{executor-5PNY7LGW.js.map → cargo/index.js.map} +0 -0
- /package/dist/{executor-B4QIYGZX.js.map → chunk-CHFZDSE4.js.map} +0 -0
- /package/dist/{executor-BWXXDQ7K.js.map → chunk-GHVIKOHT.js.map} +0 -0
- /package/dist/{issue-VGDPP4B5.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/dist/{ledger-TMRZYNVJ.js.map → classified/index.js.map} +0 -0
- /package/dist/{noydb-G725ZSZG.js.map → collection-facade-LVD22JLM.js.map} +0 -0
- /package/dist/{public-envelope-BW6OXORV.js.map → computed-EXDMQODG.js.map} +0 -0
- /package/dist/{read-only-facade-ITU6L7BL.js.map → delegation-BJP73GAP.js.map} +0 -0
- /package/dist/{registry-3QP3YKQS.js.map → derive-BME7HDWO.js.map} +0 -0
- /package/dist/{registry-DKEXOJVO.js.map → enclave-NHORSWSF.js.map} +0 -0
- /package/dist/{registry-OJIOSBV6.js.map → executor-FE6X4LFX.js.map} +0 -0
- /package/dist/{registry-USRVT6YF.js.map → executor-KSHKRJXP.js.map} +0 -0
- /package/dist/{revoke-JCC7N56X.js.map → executor-ZHTJJICG.js.map} +0 -0
- /package/dist/{signer-72QAUSVW.js.map → export-accessible-DACHM5VT.js.map} +0 -0
- /package/dist/{stale-6ZDBTQT7.js.map → extract-partition-RNENZZ4T.js.map} +0 -0
- /package/dist/{ulid-COREQ2RQ.js.map → find-BNGBJNKP.js.map} +0 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fuseRetrieval
|
|
3
|
+
} from "./chunk-AURFOK3D.js";
|
|
4
|
+
import {
|
|
5
|
+
getAtPath,
|
|
6
|
+
isStaticDictDescriptor,
|
|
7
|
+
stripI18nFilled
|
|
8
|
+
} from "./chunk-EOXAAJTY.js";
|
|
9
|
+
import {
|
|
10
|
+
EmbeddingDimMismatchError,
|
|
11
|
+
EmbeddingModelMismatchError,
|
|
12
|
+
SearchNotEnabledError
|
|
13
|
+
} from "./chunk-S7VFUQM2.js";
|
|
14
|
+
|
|
15
|
+
// src/with-lookup/embeddings/cosine.ts
|
|
16
|
+
function cosine(a, b) {
|
|
17
|
+
if (a.length !== b.length) return 0;
|
|
18
|
+
let dot = 0, na = 0, nb = 0;
|
|
19
|
+
for (let i = 0; i < a.length; i++) {
|
|
20
|
+
const x = a[i], y = b[i];
|
|
21
|
+
dot += x * y;
|
|
22
|
+
na += x * x;
|
|
23
|
+
nb += y * y;
|
|
24
|
+
}
|
|
25
|
+
if (na === 0 || nb === 0) return 0;
|
|
26
|
+
return dot / (Math.sqrt(na) * Math.sqrt(nb));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/with-lookup/embeddings/descriptor.ts
|
|
30
|
+
function embeddingSourceText(record, source) {
|
|
31
|
+
const fields = typeof source === "string" ? [source] : source;
|
|
32
|
+
const parts = [];
|
|
33
|
+
for (const f of fields) {
|
|
34
|
+
for (const leaf of getAtPath(record, f)) {
|
|
35
|
+
if (typeof leaf === "string" && leaf !== "") parts.push(leaf);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return parts.join(" ");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/with-lookup/embeddings/vector-set.ts
|
|
42
|
+
var VectorSet = class {
|
|
43
|
+
vectors;
|
|
44
|
+
get loaded() {
|
|
45
|
+
return this.vectors !== void 0;
|
|
46
|
+
}
|
|
47
|
+
async ensureLoaded(load) {
|
|
48
|
+
if (this.vectors === void 0) this.vectors = await load();
|
|
49
|
+
}
|
|
50
|
+
markDirty() {
|
|
51
|
+
this.vectors = void 0;
|
|
52
|
+
}
|
|
53
|
+
cosineTopK(query, k, opts = {}) {
|
|
54
|
+
const all = this.vectors ?? [];
|
|
55
|
+
const minScore = opts.minScore ?? -Infinity;
|
|
56
|
+
const hits = [];
|
|
57
|
+
for (const v of all) {
|
|
58
|
+
if (opts.expectModel !== void 0 && v.model !== opts.expectModel) {
|
|
59
|
+
throw new EmbeddingModelMismatchError(opts.expectModel, v.model);
|
|
60
|
+
}
|
|
61
|
+
const score = cosine(query, v.vec);
|
|
62
|
+
if (score >= minScore) hits.push({ id: v.id, score });
|
|
63
|
+
}
|
|
64
|
+
hits.sort((a, b) => b.score - a.score);
|
|
65
|
+
return hits.slice(0, k);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/with-lookup/search/tokenize.ts
|
|
70
|
+
var WORD = /[\p{L}\p{N}]+/gu;
|
|
71
|
+
var tokenize = (text) => {
|
|
72
|
+
if (!text) return [];
|
|
73
|
+
return text.normalize("NFKC").toLowerCase().match(WORD) ?? [];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/with-lookup/search/scan.ts
|
|
77
|
+
var K1 = 1.2;
|
|
78
|
+
var B = 0.75;
|
|
79
|
+
function fieldText(record, field) {
|
|
80
|
+
const v = record[field];
|
|
81
|
+
if (typeof v === "string") return v;
|
|
82
|
+
if (v === null || v === void 0) return "";
|
|
83
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
function searchScan(entries, field, query, opts = {}, tokenizer = tokenize) {
|
|
87
|
+
const queryTerms = tokenizer(query);
|
|
88
|
+
if (queryTerms.length === 0) return [];
|
|
89
|
+
const match = opts.match ?? "any";
|
|
90
|
+
const usePrefix = opts.prefix ?? false;
|
|
91
|
+
const exactTerms = usePrefix ? queryTerms.slice(0, -1) : queryTerms;
|
|
92
|
+
const prefixTerm = usePrefix ? queryTerms[queryTerms.length - 1] : void 0;
|
|
93
|
+
const docs = entries.map((e) => ({ id: e.id, record: e.record, terms: tokenizer(fieldText(e.record, field)) }));
|
|
94
|
+
const N = docs.length || 1;
|
|
95
|
+
const df = /* @__PURE__ */ new Map();
|
|
96
|
+
let totalLen = 0;
|
|
97
|
+
for (const d of docs) {
|
|
98
|
+
totalLen += d.terms.length;
|
|
99
|
+
for (const t of new Set(d.terms)) df.set(t, (df.get(t) ?? 0) + 1);
|
|
100
|
+
}
|
|
101
|
+
const avgdl = totalLen / N || 1;
|
|
102
|
+
let prefixDf = 0;
|
|
103
|
+
if (prefixTerm !== void 0) {
|
|
104
|
+
for (const d of docs) {
|
|
105
|
+
if (d.terms.some((t) => t.startsWith(prefixTerm))) prefixDf++;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const requiredCount = exactTerms.length + (prefixTerm !== void 0 ? 1 : 0);
|
|
109
|
+
const results = [];
|
|
110
|
+
for (const d of docs) {
|
|
111
|
+
const tf = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const t of d.terms) tf.set(t, (tf.get(t) ?? 0) + 1);
|
|
113
|
+
const matched = [];
|
|
114
|
+
for (const qt of exactTerms) {
|
|
115
|
+
const c = tf.get(qt) ?? 0;
|
|
116
|
+
if (c > 0) matched.push({ tf: c, df: df.get(qt) ?? 0 });
|
|
117
|
+
}
|
|
118
|
+
if (prefixTerm !== void 0) {
|
|
119
|
+
let ptf = 0;
|
|
120
|
+
for (const [t, c] of tf) if (t.startsWith(prefixTerm)) ptf += c;
|
|
121
|
+
if (ptf > 0) matched.push({ tf: ptf, df: prefixDf });
|
|
122
|
+
}
|
|
123
|
+
if (matched.length === 0) continue;
|
|
124
|
+
if (match === "all" && matched.length < requiredCount) continue;
|
|
125
|
+
let score = 0;
|
|
126
|
+
for (const m of matched) {
|
|
127
|
+
const idf = Math.log(1 + (N - m.df + 0.5) / (m.df + 0.5));
|
|
128
|
+
const denom = m.tf + K1 * (1 - B + B * (d.terms.length / avgdl));
|
|
129
|
+
score += idf * (m.tf * (K1 + 1) / (denom || 1));
|
|
130
|
+
}
|
|
131
|
+
results.push({ id: d.id, score, record: d.record });
|
|
132
|
+
}
|
|
133
|
+
results.sort((a, b) => b.score - a.score);
|
|
134
|
+
return opts.limit !== void 0 ? results.slice(0, opts.limit) : results;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/with-lookup/search/segment.ts
|
|
138
|
+
var SEGMENTER = new Intl.Segmenter(void 0, { granularity: "word" });
|
|
139
|
+
var segmentTokens = (text) => {
|
|
140
|
+
const out = [];
|
|
141
|
+
if (!text) return out;
|
|
142
|
+
for (const s of SEGMENTER.segment(text)) {
|
|
143
|
+
if (s.isWordLike) out.push({ term: s.segment.normalize("NFKC").toLowerCase(), offset: s.index });
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
};
|
|
147
|
+
var segmentTokenizer = (text) => segmentTokens(text).map((t) => t.term);
|
|
148
|
+
|
|
149
|
+
// src/with-lookup/search/inverted-index.ts
|
|
150
|
+
var K12 = 1.2;
|
|
151
|
+
var B2 = 0.75;
|
|
152
|
+
var InvertedIndex = class _InvertedIndex {
|
|
153
|
+
// per field: df (term -> #docs), N (#docs), totalLen
|
|
154
|
+
fieldStats = /* @__PURE__ */ new Map();
|
|
155
|
+
docs = [];
|
|
156
|
+
static build(docs) {
|
|
157
|
+
const idx = new _InvertedIndex();
|
|
158
|
+
for (const d of docs) {
|
|
159
|
+
for (const f of d.fields) {
|
|
160
|
+
const tokens = segmentTokens(f.text);
|
|
161
|
+
const tf = /* @__PURE__ */ new Map();
|
|
162
|
+
const firstOffset = /* @__PURE__ */ new Map();
|
|
163
|
+
for (const t of tokens) {
|
|
164
|
+
tf.set(t.term, (tf.get(t.term) ?? 0) + 1);
|
|
165
|
+
if (!firstOffset.has(t.term)) firstOffset.set(t.term, t.offset);
|
|
166
|
+
}
|
|
167
|
+
const doc = { id: d.id, field: f.field, ...f.locale !== void 0 ? { locale: f.locale } : {}, text: f.text, len: tokens.length, tf, firstOffset };
|
|
168
|
+
idx.docs.push(doc);
|
|
169
|
+
let s = idx.fieldStats.get(f.field);
|
|
170
|
+
if (!s) {
|
|
171
|
+
s = { df: /* @__PURE__ */ new Map(), n: 0, totalLen: 0 };
|
|
172
|
+
idx.fieldStats.set(f.field, s);
|
|
173
|
+
}
|
|
174
|
+
s.n += 1;
|
|
175
|
+
s.totalLen += doc.len;
|
|
176
|
+
for (const term of tf.keys()) s.df.set(term, (s.df.get(term) ?? 0) + 1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return idx;
|
|
180
|
+
}
|
|
181
|
+
query(query, opts = {}) {
|
|
182
|
+
const terms = segmentTokenizer(query);
|
|
183
|
+
if (terms.length === 0) return [];
|
|
184
|
+
const usePrefix = opts.prefix ?? false;
|
|
185
|
+
const exact = usePrefix ? terms.slice(0, -1) : terms;
|
|
186
|
+
const prefix = usePrefix ? terms[terms.length - 1] : void 0;
|
|
187
|
+
const match = opts.match ?? "any";
|
|
188
|
+
const required = exact.length + (prefix !== void 0 ? 1 : 0);
|
|
189
|
+
const best = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const doc of this.docs) {
|
|
191
|
+
if (opts.fields !== void 0 && !opts.fields.includes(doc.field)) continue;
|
|
192
|
+
const stats = this.fieldStats.get(doc.field);
|
|
193
|
+
const avgdl = stats.totalLen / stats.n || 1;
|
|
194
|
+
let score = 0;
|
|
195
|
+
let matchedCount = 0;
|
|
196
|
+
let snippetOffset = -1;
|
|
197
|
+
const scoreTerm = (tf, df, offset) => {
|
|
198
|
+
if (tf <= 0) return;
|
|
199
|
+
matchedCount += 1;
|
|
200
|
+
if (snippetOffset < 0 && offset >= 0) snippetOffset = offset;
|
|
201
|
+
const idf = Math.log(1 + (stats.n - df + 0.5) / (df + 0.5));
|
|
202
|
+
const denom = tf + K12 * (1 - B2 + B2 * (doc.len / avgdl));
|
|
203
|
+
score += idf * (tf * (K12 + 1) / (denom || 1));
|
|
204
|
+
};
|
|
205
|
+
for (const qt of exact) scoreTerm(doc.tf.get(qt) ?? 0, stats.df.get(qt) ?? 0, doc.firstOffset.get(qt) ?? -1);
|
|
206
|
+
if (prefix !== void 0) {
|
|
207
|
+
const exactSet = new Set(exact);
|
|
208
|
+
let ptf = 0;
|
|
209
|
+
let poff = -1;
|
|
210
|
+
for (const [term, c] of doc.tf) {
|
|
211
|
+
if (term.startsWith(prefix) && !exactSet.has(term)) {
|
|
212
|
+
ptf += c;
|
|
213
|
+
if (poff < 0) poff = doc.firstOffset.get(term) ?? -1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (ptf > 0) {
|
|
217
|
+
let pdf = 0;
|
|
218
|
+
for (const d of this.docs) {
|
|
219
|
+
if (d.field === doc.field && [...d.tf.keys()].some((t) => t.startsWith(prefix))) pdf++;
|
|
220
|
+
}
|
|
221
|
+
scoreTerm(ptf, pdf || 1, poff);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (matchedCount === 0) continue;
|
|
225
|
+
if (match === "all" && matchedCount < required) continue;
|
|
226
|
+
const hit = {
|
|
227
|
+
id: doc.id,
|
|
228
|
+
score,
|
|
229
|
+
field: doc.field,
|
|
230
|
+
text: doc.text,
|
|
231
|
+
offset: snippetOffset < 0 ? 0 : snippetOffset,
|
|
232
|
+
...doc.locale !== void 0 ? { locale: doc.locale } : {}
|
|
233
|
+
};
|
|
234
|
+
const prev = best.get(doc.id);
|
|
235
|
+
if (!prev || hit.score > prev.score) best.set(doc.id, hit);
|
|
236
|
+
}
|
|
237
|
+
const results = [...best.values()].sort((a, b) => b.score - a.score);
|
|
238
|
+
return opts.limit !== void 0 ? results.slice(0, opts.limit) : results;
|
|
239
|
+
}
|
|
240
|
+
toSnapshot() {
|
|
241
|
+
return {
|
|
242
|
+
v: 1,
|
|
243
|
+
fieldStats: [...this.fieldStats].map(([f, s]) => [f, { df: [...s.df], n: s.n, totalLen: s.totalLen }]),
|
|
244
|
+
docs: this.docs.map((d) => ({
|
|
245
|
+
id: d.id,
|
|
246
|
+
field: d.field,
|
|
247
|
+
text: d.text,
|
|
248
|
+
len: d.len,
|
|
249
|
+
tf: [...d.tf],
|
|
250
|
+
firstOffset: [...d.firstOffset],
|
|
251
|
+
...d.locale !== void 0 ? { locale: d.locale } : {}
|
|
252
|
+
}))
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
static fromSnapshot(s) {
|
|
256
|
+
const idx = new _InvertedIndex();
|
|
257
|
+
for (const [f, st] of s.fieldStats) idx.fieldStats.set(f, { df: new Map(st.df), n: st.n, totalLen: st.totalLen });
|
|
258
|
+
for (const d of s.docs) {
|
|
259
|
+
idx.docs.push({
|
|
260
|
+
id: d.id,
|
|
261
|
+
field: d.field,
|
|
262
|
+
text: d.text,
|
|
263
|
+
len: d.len,
|
|
264
|
+
tf: new Map(d.tf),
|
|
265
|
+
firstOffset: new Map(d.firstOffset),
|
|
266
|
+
...d.locale !== void 0 ? { locale: d.locale } : {}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return idx;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/with-lookup/search/snippet.ts
|
|
274
|
+
function extractSnippet(text, offset, window = 80) {
|
|
275
|
+
const chars = Array.from(text);
|
|
276
|
+
if (chars.length <= window) return text;
|
|
277
|
+
const cpOffset = Array.from(text.slice(0, Math.max(0, offset))).length;
|
|
278
|
+
const half = Math.floor(window / 2);
|
|
279
|
+
let start = Math.max(0, cpOffset - half);
|
|
280
|
+
const end = Math.min(chars.length, start + window);
|
|
281
|
+
start = Math.max(0, end - window);
|
|
282
|
+
const body = chars.slice(start, end).join("");
|
|
283
|
+
return `${start > 0 ? "\u2026" : ""}${body}${end < chars.length ? "\u2026" : ""}`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/with-lookup/search/index-store.ts
|
|
287
|
+
var MemoryIndexStore = class {
|
|
288
|
+
index;
|
|
289
|
+
get built() {
|
|
290
|
+
return this.index !== void 0;
|
|
291
|
+
}
|
|
292
|
+
async ensureBuilt(build) {
|
|
293
|
+
if (this.index === void 0) this.index = InvertedIndex.build(build());
|
|
294
|
+
return this.index;
|
|
295
|
+
}
|
|
296
|
+
markDirty() {
|
|
297
|
+
this.index = void 0;
|
|
298
|
+
}
|
|
299
|
+
async flush() {
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/with-lookup/search/build-docs.ts
|
|
304
|
+
function buildStringFieldEntries(record, textIndexes, only) {
|
|
305
|
+
const fields = only ? textIndexes.filter((f) => only.includes(f)) : textIndexes;
|
|
306
|
+
const out = [];
|
|
307
|
+
for (const field of fields) {
|
|
308
|
+
for (const leaf of getAtPath(record, field)) {
|
|
309
|
+
if (typeof leaf === "string" && leaf !== "") out.push({ field, text: leaf });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return out;
|
|
313
|
+
}
|
|
314
|
+
function buildI18nFieldEntries(record, i18nFields, textIndexes, only) {
|
|
315
|
+
const fields = (only ? textIndexes.filter((f) => only.includes(f)) : textIndexes).filter((f) => f in i18nFields);
|
|
316
|
+
const out = [];
|
|
317
|
+
for (const field of fields) {
|
|
318
|
+
for (const leaf of getAtPath(record, field)) {
|
|
319
|
+
if (!leaf || typeof leaf !== "object" || Array.isArray(leaf)) continue;
|
|
320
|
+
for (const [locale, val] of Object.entries(leaf)) {
|
|
321
|
+
if (typeof val === "string" && val !== "") out.push({ field, locale, text: val });
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
function buildDictKeyFieldEntries(record, dictKeyFields, labelMaps, textIndexes, only) {
|
|
328
|
+
const fields = (only ? textIndexes.filter((f) => only.includes(f)) : textIndexes).filter((f) => f in dictKeyFields);
|
|
329
|
+
const out = [];
|
|
330
|
+
for (const field of fields) {
|
|
331
|
+
const map = labelMaps.get(field);
|
|
332
|
+
if (!map) continue;
|
|
333
|
+
for (const leaf of getAtPath(record, field)) {
|
|
334
|
+
const keys = typeof leaf === "string" ? [leaf] : Array.isArray(leaf) ? leaf.filter((k) => typeof k === "string") : [];
|
|
335
|
+
for (const key of keys) {
|
|
336
|
+
const labels = map.get(key);
|
|
337
|
+
if (!labels) continue;
|
|
338
|
+
for (const [locale, label] of Object.entries(labels)) {
|
|
339
|
+
if (label !== "") out.push({ field, locale, text: label });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
function buildBlobFieldEntries(filenamesByField) {
|
|
347
|
+
const out = [];
|
|
348
|
+
for (const [field, names] of filenamesByField) {
|
|
349
|
+
for (const name of names) if (name !== "") out.push({ field, text: name });
|
|
350
|
+
}
|
|
351
|
+
return out;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/with-lookup/search/active.ts
|
|
355
|
+
function withSearch() {
|
|
356
|
+
return {
|
|
357
|
+
async search(ctx, field, query, opts) {
|
|
358
|
+
const { search: search2 } = await import("./collection-facade-LVD22JLM.js");
|
|
359
|
+
return search2(ctx, field, query, opts);
|
|
360
|
+
},
|
|
361
|
+
async retrieve(ctx, query, opts) {
|
|
362
|
+
const { retrieve: retrieve2 } = await import("./collection-facade-LVD22JLM.js");
|
|
363
|
+
return retrieve2(ctx, query, opts);
|
|
364
|
+
},
|
|
365
|
+
async similarTo(ctx, vector, opts) {
|
|
366
|
+
const { similarTo: similarTo2 } = await import("./collection-facade-LVD22JLM.js");
|
|
367
|
+
return similarTo2(ctx, vector, opts);
|
|
368
|
+
},
|
|
369
|
+
async warmIndex(ctx) {
|
|
370
|
+
const { warmIndex: warmIndex2 } = await import("./collection-facade-LVD22JLM.js");
|
|
371
|
+
return warmIndex2(ctx);
|
|
372
|
+
},
|
|
373
|
+
async flushIndex(ctx) {
|
|
374
|
+
const { flushIndex: flushIndex2 } = await import("./collection-facade-LVD22JLM.js");
|
|
375
|
+
return flushIndex2(ctx);
|
|
376
|
+
},
|
|
377
|
+
async embedOnWrite(ctx, id, record, version) {
|
|
378
|
+
const { embedOnWrite: embedOnWrite2 } = await import("./collection-facade-LVD22JLM.js");
|
|
379
|
+
return embedOnWrite2(ctx, id, record, version);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// src/with-lookup/search/strategy.ts
|
|
385
|
+
var NO_SEARCH = {
|
|
386
|
+
async search() {
|
|
387
|
+
throw new SearchNotEnabledError();
|
|
388
|
+
},
|
|
389
|
+
async retrieve() {
|
|
390
|
+
throw new SearchNotEnabledError();
|
|
391
|
+
},
|
|
392
|
+
async similarTo() {
|
|
393
|
+
throw new SearchNotEnabledError();
|
|
394
|
+
},
|
|
395
|
+
async warmIndex() {
|
|
396
|
+
throw new SearchNotEnabledError();
|
|
397
|
+
},
|
|
398
|
+
async flushIndex() {
|
|
399
|
+
throw new SearchNotEnabledError();
|
|
400
|
+
},
|
|
401
|
+
async embedOnWrite() {
|
|
402
|
+
throw new SearchNotEnabledError();
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
// src/with-lookup/search/collection-facade.ts
|
|
407
|
+
async function search(ctx, field, query, opts = {}) {
|
|
408
|
+
if (ctx.lazy) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
`Collection "${ctx.name}": search() (scan mode) requires eager mode (prefetch: true). A store-usable blind index for lazy / at-scale search is a separate gated opt-in (#308).`
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
await ctx.ensureHydrated();
|
|
414
|
+
const entries = [];
|
|
415
|
+
for (const [id, e] of ctx.cache) entries.push({ id, record: stripI18nFilled(e.record) });
|
|
416
|
+
return searchScan(entries, field, query, opts);
|
|
417
|
+
}
|
|
418
|
+
function buildRetrievalDocs(ctx, labelMaps, blobFilenames, only) {
|
|
419
|
+
const docs = [];
|
|
420
|
+
for (const [id, e] of ctx.cache) {
|
|
421
|
+
const rec = stripI18nFilled(e.record);
|
|
422
|
+
const fields = buildStringFieldEntries(rec, ctx.textIndexes ?? [], only);
|
|
423
|
+
if (ctx.i18nFields) fields.push(...buildI18nFieldEntries(rec, ctx.i18nFields, ctx.textIndexes ?? [], only));
|
|
424
|
+
if (ctx.dictKeyFields) fields.push(...buildDictKeyFieldEntries(rec, ctx.dictKeyFields, labelMaps, ctx.textIndexes ?? [], only));
|
|
425
|
+
const blobNames = blobFilenames.get(id);
|
|
426
|
+
if (blobNames) fields.push(...buildBlobFieldEntries(blobNames));
|
|
427
|
+
if (fields.length > 0) docs.push({ id, fields });
|
|
428
|
+
}
|
|
429
|
+
return docs;
|
|
430
|
+
}
|
|
431
|
+
function hasIndexedBlobFields(ctx, only) {
|
|
432
|
+
if (!ctx.blobFields || !ctx.textIndexes) return false;
|
|
433
|
+
const fields = only ? ctx.textIndexes.filter((f) => only.includes(f)) : ctx.textIndexes;
|
|
434
|
+
return fields.some((f) => f in ctx.blobFields);
|
|
435
|
+
}
|
|
436
|
+
async function resolveBlobFilenames(ctx, only) {
|
|
437
|
+
const out = /* @__PURE__ */ new Map();
|
|
438
|
+
if (!hasIndexedBlobFields(ctx, only)) return out;
|
|
439
|
+
const indexed = (only ? ctx.textIndexes.filter((f) => only.includes(f)) : ctx.textIndexes).filter((f) => f in ctx.blobFields);
|
|
440
|
+
const indexedSet = new Set(indexed);
|
|
441
|
+
for (const id of ctx.cache.keys()) {
|
|
442
|
+
let slots;
|
|
443
|
+
try {
|
|
444
|
+
slots = await ctx.blob(id).list();
|
|
445
|
+
} catch {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
let byField;
|
|
449
|
+
for (const slot of slots) {
|
|
450
|
+
if (!indexedSet.has(slot.name) || !slot.filename) continue;
|
|
451
|
+
if (!byField) {
|
|
452
|
+
byField = /* @__PURE__ */ new Map();
|
|
453
|
+
out.set(id, byField);
|
|
454
|
+
}
|
|
455
|
+
const names = byField.get(slot.name);
|
|
456
|
+
if (names) names.push(slot.filename);
|
|
457
|
+
else byField.set(slot.name, [slot.filename]);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return out;
|
|
461
|
+
}
|
|
462
|
+
async function resolveDictLabelMaps(ctx) {
|
|
463
|
+
const maps = /* @__PURE__ */ new Map();
|
|
464
|
+
if (!ctx.dictKeyFields || !ctx.textIndexes) return maps;
|
|
465
|
+
for (const field of ctx.textIndexes) {
|
|
466
|
+
const desc = ctx.dictKeyFields[field];
|
|
467
|
+
if (!desc) continue;
|
|
468
|
+
const m = /* @__PURE__ */ new Map();
|
|
469
|
+
if (isStaticDictDescriptor(desc)) {
|
|
470
|
+
for (const [key, labels] of Object.entries(desc.table)) m.set(key, labels);
|
|
471
|
+
} else {
|
|
472
|
+
if (ctx.getDictionary) {
|
|
473
|
+
const handle = await ctx.getDictionary(desc.name);
|
|
474
|
+
for (const e of await handle.list()) m.set(e.key, e.labels);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
maps.set(field, m);
|
|
478
|
+
}
|
|
479
|
+
return maps;
|
|
480
|
+
}
|
|
481
|
+
async function flushIndex(ctx) {
|
|
482
|
+
if (!ctx.searchIndexStore) return;
|
|
483
|
+
await ctx.ensureHydrated();
|
|
484
|
+
const labelMaps = await resolveDictLabelMaps(ctx);
|
|
485
|
+
const blobFilenames = await resolveBlobFilenames(ctx);
|
|
486
|
+
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
487
|
+
await ctx.searchIndexStore.flush?.();
|
|
488
|
+
}
|
|
489
|
+
function buildVectorLoad(ctx) {
|
|
490
|
+
return async () => {
|
|
491
|
+
const ids = await ctx.adapter.list(ctx.vault, "_vec");
|
|
492
|
+
const out = [];
|
|
493
|
+
for (const id of ids) {
|
|
494
|
+
const env = await ctx.adapter.get(ctx.vault, "_vec", id);
|
|
495
|
+
if (!env) continue;
|
|
496
|
+
const body = await ctx.codec.decryptJsonString(env);
|
|
497
|
+
if (body === null) continue;
|
|
498
|
+
const parsed = JSON.parse(body);
|
|
499
|
+
out.push({ id, vec: new Float32Array(parsed.vec), model: parsed.model });
|
|
500
|
+
}
|
|
501
|
+
return out;
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function buildPersistedIndexCallbacks(provideCtx) {
|
|
505
|
+
const FT = "_ftindex";
|
|
506
|
+
return {
|
|
507
|
+
load: async () => {
|
|
508
|
+
const ctx = provideCtx();
|
|
509
|
+
const env = await ctx.adapter.get(ctx.vault, FT, ctx.name);
|
|
510
|
+
if (!env) return null;
|
|
511
|
+
const body = await ctx.codec.decryptJsonString(env);
|
|
512
|
+
if (body === null) return null;
|
|
513
|
+
try {
|
|
514
|
+
const wrapped = JSON.parse(body);
|
|
515
|
+
return { json: wrapped.idx, fingerprint: wrapped.fp };
|
|
516
|
+
} catch {
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
save: async (json, fp) => {
|
|
521
|
+
const ctx = provideCtx();
|
|
522
|
+
const body = JSON.stringify({ fp, idx: json });
|
|
523
|
+
const env = await ctx.codec.encryptJsonString(body, fp.count);
|
|
524
|
+
await ctx.adapter.put(ctx.vault, FT, ctx.name, env);
|
|
525
|
+
},
|
|
526
|
+
remove: async () => {
|
|
527
|
+
const ctx = provideCtx();
|
|
528
|
+
await ctx.adapter.delete(ctx.vault, FT, ctx.name);
|
|
529
|
+
},
|
|
530
|
+
currentFingerprint: () => {
|
|
531
|
+
const ctx = provideCtx();
|
|
532
|
+
let maxVersion = 0;
|
|
533
|
+
for (const e of ctx.cache.values()) if (e.version > maxVersion) maxVersion = e.version;
|
|
534
|
+
return { count: ctx.cache.size, maxVersion };
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
async function warmIndex(ctx) {
|
|
539
|
+
if (!ctx.searchIndexStore) return;
|
|
540
|
+
if (ctx.lazy) {
|
|
541
|
+
throw new Error(
|
|
542
|
+
`Collection "${ctx.name}": warmIndex() requires eager mode (prefetch: true).`
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
await ctx.ensureHydrated();
|
|
546
|
+
const built = ctx.searchIndexStore.built;
|
|
547
|
+
const labelMaps = built ? /* @__PURE__ */ new Map() : await resolveDictLabelMaps(ctx);
|
|
548
|
+
const blobFilenames = built ? /* @__PURE__ */ new Map() : await resolveBlobFilenames(ctx);
|
|
549
|
+
await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
550
|
+
}
|
|
551
|
+
async function retrieve(ctx, query, opts = {}) {
|
|
552
|
+
const hits = opts.mode === "semantic" ? await retrieveSemantic(ctx, query, opts) : opts.mode === "hybrid" ? await retrieveHybrid(ctx, query, opts) : await retrieveLexical(ctx, query, opts);
|
|
553
|
+
return opts.within ? applyWithin(hits, opts.within) : hits;
|
|
554
|
+
}
|
|
555
|
+
function applyWithin(hits, within) {
|
|
556
|
+
const ids = new Set(within._idArray());
|
|
557
|
+
return hits.filter((h) => ids.has(h.id)).map((h, i) => ({ ...h, rank: i + 1 }));
|
|
558
|
+
}
|
|
559
|
+
async function retrieveLexical(ctx, query, opts) {
|
|
560
|
+
if (!ctx.searchIndexStore) {
|
|
561
|
+
throw new Error(`Collection "${ctx.name}": retrieve() requires a textIndexes config.`);
|
|
562
|
+
}
|
|
563
|
+
if (ctx.lazy) {
|
|
564
|
+
throw new Error(
|
|
565
|
+
`Collection "${ctx.name}": retrieve() requires eager mode (prefetch: true).`
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
await ctx.ensureHydrated();
|
|
569
|
+
const built = ctx.searchIndexStore.built;
|
|
570
|
+
const labelMaps = built ? /* @__PURE__ */ new Map() : await resolveDictLabelMaps(ctx);
|
|
571
|
+
const blobFilenames = built ? /* @__PURE__ */ new Map() : await resolveBlobFilenames(ctx);
|
|
572
|
+
const index = await ctx.searchIndexStore.ensureBuilt(() => buildRetrievalDocs(ctx, labelMaps, blobFilenames));
|
|
573
|
+
const hits = index.query(query, {
|
|
574
|
+
...opts.limit !== void 0 ? { limit: opts.limit } : {},
|
|
575
|
+
...opts.match ? { match: opts.match } : {},
|
|
576
|
+
...opts.prefix ? { prefix: opts.prefix } : {},
|
|
577
|
+
...opts.fields ? { fields: opts.fields } : {}
|
|
578
|
+
});
|
|
579
|
+
const window = opts.snippetWindow ?? 80;
|
|
580
|
+
return hits.map((h, i) => {
|
|
581
|
+
const base = {
|
|
582
|
+
id: h.id,
|
|
583
|
+
score: h.score,
|
|
584
|
+
rank: i + 1,
|
|
585
|
+
field: h.field,
|
|
586
|
+
snippet: extractSnippet(h.text, h.offset, window),
|
|
587
|
+
...h.locale !== void 0 ? { locale: h.locale } : {},
|
|
588
|
+
...opts.includeRecord ? (() => {
|
|
589
|
+
const e = ctx.cache.get(h.id);
|
|
590
|
+
return e ? { record: stripI18nFilled(e.record) } : {};
|
|
591
|
+
})() : {}
|
|
592
|
+
};
|
|
593
|
+
return base;
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
async function retrieveHybrid(ctx, query, opts) {
|
|
597
|
+
if (!ctx.embeddings) {
|
|
598
|
+
throw new Error(`Collection "${ctx.name}": retrieve({mode:'hybrid'}) requires an embeddings config.`);
|
|
599
|
+
}
|
|
600
|
+
const [lex, sem] = await Promise.all([
|
|
601
|
+
retrieveLexical(ctx, query, opts),
|
|
602
|
+
retrieveSemantic(ctx, query, opts)
|
|
603
|
+
]);
|
|
604
|
+
return fuseRetrieval([lex, sem], opts.limit !== void 0 ? { limit: opts.limit } : {});
|
|
605
|
+
}
|
|
606
|
+
async function retrieveSemantic(ctx, query, opts) {
|
|
607
|
+
if (!ctx.embeddings) throw new Error(`Collection "${ctx.name}": retrieve({mode:'semantic'}) requires an embeddings config.`);
|
|
608
|
+
if (ctx.lazy) throw new Error(`Collection "${ctx.name}": retrieve() requires eager mode (prefetch: true).`);
|
|
609
|
+
const qVec = await ctx.embeddings.encode(query);
|
|
610
|
+
return similarTo(ctx, qVec, {
|
|
611
|
+
...opts.limit !== void 0 ? { k: opts.limit } : {},
|
|
612
|
+
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
613
|
+
...opts.includeRecord ? { includeRecord: true } : {}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
async function similarTo(ctx, vector, opts = {}) {
|
|
617
|
+
if (!ctx.embeddings || !ctx.vectorSet) throw new Error(`Collection "${ctx.name}": similarTo() requires an embeddings config.`);
|
|
618
|
+
if (ctx.lazy) throw new Error(`Collection "${ctx.name}": similarTo() requires eager mode (prefetch: true).`);
|
|
619
|
+
await ctx.ensureHydrated();
|
|
620
|
+
await ctx.vectorSet.ensureLoaded(buildVectorLoad(ctx));
|
|
621
|
+
const hits = ctx.vectorSet.cosineTopK(vector, opts.k ?? 10, {
|
|
622
|
+
...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
|
|
623
|
+
expectModel: ctx.embeddings.model
|
|
624
|
+
});
|
|
625
|
+
return hits.map((h, i) => {
|
|
626
|
+
const base = { id: h.id, score: h.score, rank: i + 1, field: "(vector)", snippet: "" };
|
|
627
|
+
if (opts.includeRecord) {
|
|
628
|
+
const e = ctx.cache.get(h.id);
|
|
629
|
+
if (e) base.record = stripI18nFilled(e.record);
|
|
630
|
+
}
|
|
631
|
+
return base;
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
async function embedOnWrite(ctx, id, record, version) {
|
|
635
|
+
if (!ctx.embeddings) return;
|
|
636
|
+
const text = embeddingSourceText(record, ctx.embeddings.source);
|
|
637
|
+
const vec = await ctx.embeddings.encode(text);
|
|
638
|
+
if (vec.length !== ctx.embeddings.dim) throw new EmbeddingDimMismatchError("embeddings", ctx.embeddings.dim, vec.length);
|
|
639
|
+
const body = JSON.stringify({ vec: Array.from(vec), model: ctx.embeddings.model, dim: ctx.embeddings.dim });
|
|
640
|
+
const vecEnv = await ctx.codec.encryptJsonString(body, version);
|
|
641
|
+
await ctx.adapter.put(ctx.vault, "_vec", id, vecEnv);
|
|
642
|
+
ctx.vectorSet?.markDirty();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export {
|
|
646
|
+
VectorSet,
|
|
647
|
+
tokenize,
|
|
648
|
+
InvertedIndex,
|
|
649
|
+
MemoryIndexStore,
|
|
650
|
+
withSearch,
|
|
651
|
+
NO_SEARCH,
|
|
652
|
+
search,
|
|
653
|
+
buildRetrievalDocs,
|
|
654
|
+
hasIndexedBlobFields,
|
|
655
|
+
flushIndex,
|
|
656
|
+
buildPersistedIndexCallbacks,
|
|
657
|
+
warmIndex,
|
|
658
|
+
retrieve,
|
|
659
|
+
similarTo,
|
|
660
|
+
embedOnWrite
|
|
661
|
+
};
|
|
662
|
+
//# sourceMappingURL=chunk-VJV7GKQK.js.map
|