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