@noy-db/hub 0.2.0-pre.27 → 0.2.0-pre.29

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.
Files changed (280) hide show
  1. package/dist/aggregate/index.cjs +7 -0
  2. package/dist/aggregate/index.cjs.map +1 -1
  3. package/dist/aggregate/index.d.cts +3 -3
  4. package/dist/aggregate/index.d.ts +3 -3
  5. package/dist/aggregate/index.js +5 -5
  6. package/dist/attestation/index.cjs.map +1 -1
  7. package/dist/attestation/index.d.cts +4 -4
  8. package/dist/attestation/index.d.ts +4 -4
  9. package/dist/attestation/index.js +6 -6
  10. package/dist/blobs/index.cjs +2 -2
  11. package/dist/blobs/index.cjs.map +1 -1
  12. package/dist/blobs/index.d.cts +6 -6
  13. package/dist/blobs/index.d.ts +6 -6
  14. package/dist/blobs/index.js +6 -6
  15. package/dist/bundle/index.cjs +947 -6
  16. package/dist/bundle/index.cjs.map +1 -1
  17. package/dist/bundle/index.d.cts +6 -6
  18. package/dist/bundle/index.d.ts +6 -6
  19. package/dist/bundle/index.js +10 -10
  20. package/dist/{chunk-KA5A5CSD.js → chunk-2QDWRK3B.js} +5 -5
  21. package/dist/{chunk-6H4CAHMQ.js → chunk-2UT7HJJR.js} +4 -4
  22. package/dist/{chunk-E5TJAQS7.js → chunk-2ZYIN3BL.js} +2 -2
  23. package/dist/{chunk-CVTPNW2Y.js → chunk-45QJXLLS.js} +8 -8
  24. package/dist/{chunk-H4XFA2LM.js → chunk-4K4QKYK4.js} +3 -3
  25. package/dist/{chunk-RHVYFAVQ.js → chunk-4L6N56B4.js} +2 -2
  26. package/dist/{chunk-EW3H5Y7N.js → chunk-4YD7VZH4.js} +2 -2
  27. package/dist/{chunk-BOMH3637.js → chunk-553CK4E2.js} +3 -3
  28. package/dist/{chunk-I2RX62RX.js → chunk-5PTX7PKD.js} +4 -4
  29. package/dist/{chunk-7DDTFGXY.js → chunk-6BSYMFYS.js} +7 -7
  30. package/dist/chunk-6BSYMFYS.js.map +1 -0
  31. package/dist/{chunk-TESFHBOW.js → chunk-6EKRQ7QF.js} +3 -3
  32. package/dist/{chunk-Q7P4WHTL.js → chunk-7GPQPLGO.js} +2 -2
  33. package/dist/{chunk-AD6RNBAW.js → chunk-A7DNZVAV.js} +1 -1
  34. package/dist/chunk-A7DNZVAV.js.map +1 -0
  35. package/dist/{chunk-OMBPGXCL.js → chunk-ASIGWYRA.js} +2 -2
  36. package/dist/{chunk-IWGVH2RR.js → chunk-AWU4JF7C.js} +6 -6
  37. package/dist/{chunk-SKYBEGHB.js → chunk-BEZ2EV43.js} +2 -2
  38. package/dist/{chunk-EJJTUDNI.js → chunk-BITB3T5Z.js} +3 -3
  39. package/dist/{chunk-6M5JKTUQ.js → chunk-CIZDUAHI.js} +4 -4
  40. package/dist/{chunk-5EITJMUJ.js → chunk-CUPTCF4R.js} +5 -5
  41. package/dist/{chunk-FO5WEDKF.js → chunk-DEE4CRYN.js} +2 -2
  42. package/dist/{chunk-WVYL6HM7.js → chunk-DJO4OYCJ.js} +2 -2
  43. package/dist/{chunk-7JSP3E67.js → chunk-E2MDPPOC.js} +2 -2
  44. package/dist/{chunk-LX4CPLU6.js → chunk-FFKQ65YX.js} +2 -2
  45. package/dist/{chunk-VUUQYWF5.js → chunk-G7ALNCQH.js} +2 -2
  46. package/dist/{chunk-Z3BJF7SF.js → chunk-GGXN73NM.js} +36 -4
  47. package/dist/chunk-GGXN73NM.js.map +1 -0
  48. package/dist/{chunk-HAKEZTA7.js → chunk-JOJPBZSZ.js} +5 -5
  49. package/dist/{chunk-DDOYOMAD.js → chunk-JZ5DS4DP.js} +32 -2
  50. package/dist/chunk-JZ5DS4DP.js.map +1 -0
  51. package/dist/{chunk-C7UIT5XY.js → chunk-K6NVSHAH.js} +4 -4
  52. package/dist/{chunk-3BANVNDH.js → chunk-KJ3K5VZM.js} +2 -2
  53. package/dist/{chunk-ZW2YSN6G.js → chunk-LBILABKZ.js} +4 -4
  54. package/dist/{chunk-K6PCTYAH.js → chunk-LXKBG52H.js} +4 -4
  55. package/dist/{chunk-YYTM4U4J.js → chunk-MPIZQGFA.js} +2 -2
  56. package/dist/{chunk-SID2NJNF.js → chunk-MRJPSXPE.js} +3 -3
  57. package/dist/{chunk-J73KU4AE.js → chunk-MSMDDDDJ.js} +2 -2
  58. package/dist/{chunk-6ZKXFMUG.js → chunk-QBLPY44S.js} +3 -3
  59. package/dist/{chunk-PS6PSEZL.js → chunk-QGBBQKDS.js} +35 -5
  60. package/dist/chunk-QGBBQKDS.js.map +1 -0
  61. package/dist/{chunk-2NYVA6FW.js → chunk-QWJCNXH2.js} +3 -3
  62. package/dist/{chunk-KD253AI5.js → chunk-QXWJQ7UU.js} +23 -4
  63. package/dist/chunk-QXWJQ7UU.js.map +1 -0
  64. package/dist/{chunk-YRQPI67X.js → chunk-RCB6GWTC.js} +2 -2
  65. package/dist/{chunk-PFKAT4NT.js → chunk-REHF3HSJ.js} +5 -5
  66. package/dist/{chunk-FUDVHE2U.js → chunk-SAAJYSVV.js} +2 -2
  67. package/dist/{chunk-VJNV2GRF.js → chunk-SHJ3BRTZ.js} +5 -5
  68. package/dist/{chunk-BMDVFBCL.js → chunk-SQXTKZL7.js} +3 -3
  69. package/dist/{chunk-2KA3PDUR.js → chunk-TMUMMAWV.js} +2 -2
  70. package/dist/{chunk-DONPLWRC.js → chunk-TZGWI5AX.js} +4 -4
  71. package/dist/{chunk-KNJ7MK4B.js → chunk-UBF5JEOJ.js} +2 -2
  72. package/dist/{chunk-FJ3C3ELF.js → chunk-XAYDHD2O.js} +2 -2
  73. package/dist/{chunk-RRCRITDM.js → chunk-XYW2CSCI.js} +3 -3
  74. package/dist/{chunk-LXA2E3VI.js → chunk-ZCMOS4H2.js} +4 -4
  75. package/dist/{chunk-KSKKLVPA.js → chunk-ZDW22N3E.js} +822 -57
  76. package/dist/chunk-ZDW22N3E.js.map +1 -0
  77. package/dist/consent/index.cjs.map +1 -1
  78. package/dist/consent/index.d.cts +5 -5
  79. package/dist/consent/index.d.ts +5 -5
  80. package/dist/consent/index.js +3 -3
  81. package/dist/{crypto-YBKBNPVM.js → crypto-G6XU2V2Y.js} +3 -3
  82. package/dist/{decrypt-partition-CptDdcCx.d.ts → decrypt-partition-5Gt0EcTc.d.ts} +1 -1
  83. package/dist/{decrypt-partition-DmkeOB4I.d.cts → decrypt-partition-DDSArPPW.d.cts} +1 -1
  84. package/dist/{delegation-4JSMM6BB.js → delegation-ZEH4LKEM.js} +5 -5
  85. package/dist/derivations/index.cjs.map +1 -1
  86. package/dist/derivations/index.d.cts +6 -6
  87. package/dist/derivations/index.d.ts +6 -6
  88. package/dist/derivations/index.js +4 -4
  89. package/dist/{dev-unlock-Y9znMkQ2.d.ts → dev-unlock-BF9IhLPn.d.ts} +1 -1
  90. package/dist/{dev-unlock-DUTLA3Sc.d.cts → dev-unlock-CIkHrcRm.d.cts} +1 -1
  91. package/dist/{errors-Dwk2k1xY.d.ts → errors-BAWO5Z5a.d.cts} +25 -1
  92. package/dist/{errors-Dwk2k1xY.d.cts → errors-BAWO5Z5a.d.ts} +25 -1
  93. package/dist/executor-DWVP4BSJ.js +8 -0
  94. package/dist/executor-HB2YMIYC.js +12 -0
  95. package/dist/executor-HO3SIRSF.js +8 -0
  96. package/dist/{fanout-sidecar-OC4QVTS2.js → fanout-sidecar-BMT7I6FI.js} +2 -2
  97. package/dist/forget/index.js +4 -4
  98. package/dist/guards/index.cjs.map +1 -1
  99. package/dist/guards/index.d.cts +6 -6
  100. package/dist/guards/index.d.ts +6 -6
  101. package/dist/guards/index.js +3 -3
  102. package/dist/{hash-DFK7cGdo.d.cts → hash-DfhndFcd.d.cts} +1 -1
  103. package/dist/{hash-Btl9IvQS.d.ts → hash-Jl0qarQx.d.ts} +1 -1
  104. package/dist/history/index.cjs.map +1 -1
  105. package/dist/history/index.d.cts +6 -6
  106. package/dist/history/index.d.ts +6 -6
  107. package/dist/history/index.js +5 -5
  108. package/dist/i18n/index.cjs +98 -1
  109. package/dist/i18n/index.cjs.map +1 -1
  110. package/dist/i18n/index.d.cts +5 -5
  111. package/dist/i18n/index.d.ts +5 -5
  112. package/dist/i18n/index.js +85 -6
  113. package/dist/i18n/index.js.map +1 -1
  114. package/dist/{index-DoxKSsMj.d.cts → index-C1SC1EPe.d.cts} +19 -2
  115. package/dist/{index-CqzZml-D.d.cts → index-DPG2nFmT.d.cts} +28 -5
  116. package/dist/{index-wRwJVVJQ.d.ts → index-DcxTv3zx.d.ts} +28 -5
  117. package/dist/{index-LaexBi3v.d.ts → index-Ddm8D3Oo.d.ts} +19 -2
  118. package/dist/index.cjs +969 -9
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.cts +16 -16
  121. package/dist/index.d.ts +16 -16
  122. package/dist/index.js +54 -47
  123. package/dist/index.js.map +1 -1
  124. package/dist/indexing/index.cjs.map +1 -1
  125. package/dist/indexing/index.js +4 -4
  126. package/dist/issue-FZRTVGRE.js +12 -0
  127. package/dist/kernel/index.cjs +33 -0
  128. package/dist/kernel/index.cjs.map +1 -1
  129. package/dist/kernel/index.d.cts +5 -5
  130. package/dist/kernel/index.d.ts +5 -5
  131. package/dist/kernel/index.js +9 -7
  132. package/dist/{ledger-XQ4KVFQ6.js → ledger-PMTR2Q62.js} +5 -5
  133. package/dist/materialized-views/index.cjs +7 -0
  134. package/dist/materialized-views/index.cjs.map +1 -1
  135. package/dist/materialized-views/index.d.cts +6 -6
  136. package/dist/materialized-views/index.d.ts +6 -6
  137. package/dist/materialized-views/index.js +8 -8
  138. package/dist/{mime-magic-OiPT1qed.d.ts → mime-magic-BOI-I5dq.d.ts} +1 -1
  139. package/dist/{mime-magic-Co4Pyj-O.d.cts → mime-magic-C0TM7FtF.d.cts} +1 -1
  140. package/dist/noydb-Y3ZLZNXA.js +39 -0
  141. package/dist/overlay-views/index.cjs.map +1 -1
  142. package/dist/overlay-views/index.d.cts +6 -6
  143. package/dist/overlay-views/index.d.ts +6 -6
  144. package/dist/overlay-views/index.js +4 -4
  145. package/dist/periods/index.cjs.map +1 -1
  146. package/dist/periods/index.d.cts +5 -5
  147. package/dist/periods/index.d.ts +5 -5
  148. package/dist/periods/index.js +5 -5
  149. package/dist/{public-envelope-O6X6AUUS.js → public-envelope-S2S2VR3F.js} +4 -4
  150. package/dist/query/index.cjs +37 -0
  151. package/dist/query/index.cjs.map +1 -1
  152. package/dist/query/index.d.cts +3 -3
  153. package/dist/query/index.d.ts +3 -3
  154. package/dist/query/index.js +7 -7
  155. package/dist/{registry-OUZ3VBZA.js → registry-53A55ZZE.js} +3 -3
  156. package/dist/registry-FKL4SLU4.js +8 -0
  157. package/dist/registry-IEU6ATO7.js +8 -0
  158. package/dist/{revoke-QJ2HUM4W.js → revoke-AOCAVR56.js} +6 -6
  159. package/dist/sealed-record/index.cjs.map +1 -1
  160. package/dist/sealed-record/index.d.cts +1 -1
  161. package/dist/sealed-record/index.d.ts +1 -1
  162. package/dist/sealed-record/index.js +2 -2
  163. package/dist/session/index.cjs.map +1 -1
  164. package/dist/session/index.d.cts +6 -6
  165. package/dist/session/index.d.ts +6 -6
  166. package/dist/session/index.js +3 -3
  167. package/dist/shadow/index.cjs.map +1 -1
  168. package/dist/shadow/index.d.cts +5 -5
  169. package/dist/shadow/index.d.ts +5 -5
  170. package/dist/shadow/index.js +2 -2
  171. package/dist/{signer-SCJ6C6HQ.js → signer-JMK6W2Y6.js} +5 -5
  172. package/dist/snapshots/index.cjs.map +1 -1
  173. package/dist/snapshots/index.d.cts +5 -5
  174. package/dist/snapshots/index.d.ts +5 -5
  175. package/dist/snapshots/index.js +4 -4
  176. package/dist/{stale-KKCHF2VB.js → stale-IIIGOHBW.js} +2 -2
  177. package/dist/store/index.cjs.map +1 -1
  178. package/dist/store/index.d.cts +5 -5
  179. package/dist/store/index.d.ts +5 -5
  180. package/dist/store/index.js +2 -2
  181. package/dist/{strategy-D1zjEV3n.d.cts → strategy-8QGs5KQE.d.ts} +21 -2
  182. package/dist/{strategy-YQ1qJWyq.d.ts → strategy-mJExw4LQ.d.cts} +21 -2
  183. package/dist/sync/index.cjs.map +1 -1
  184. package/dist/sync/index.d.cts +4 -4
  185. package/dist/sync/index.d.ts +4 -4
  186. package/dist/sync/index.js +4 -4
  187. package/dist/team/index.cjs.map +1 -1
  188. package/dist/team/index.d.cts +5 -5
  189. package/dist/team/index.d.ts +5 -5
  190. package/dist/team/index.js +8 -8
  191. package/dist/{transition-guard-CJmb8O8q.d.ts → transition-guard-BixCDmBI.d.ts} +1 -1
  192. package/dist/{transition-guard-Dzj68JWC.d.cts → transition-guard-DnAlUf9R.d.cts} +1 -1
  193. package/dist/tx/index.cjs.map +1 -1
  194. package/dist/tx/index.d.cts +5 -5
  195. package/dist/tx/index.d.ts +5 -5
  196. package/dist/tx/index.js +3 -3
  197. package/dist/{types-CwrTuYFI.d.cts → types-Ba1vQ3AY.d.cts} +203 -6
  198. package/dist/{types-CkSWJt0H.d.ts → types-CUmZYJwN.d.ts} +203 -6
  199. package/dist/util/index.cjs.map +1 -1
  200. package/dist/util/index.js +1 -1
  201. package/dist/{with-materialized-view-BVfcPlaE.d.ts → with-materialized-view-Bjx6VYPc.d.ts} +1 -1
  202. package/dist/{with-materialized-view-dPG213gd.d.cts → with-materialized-view-Z_aHLln6.d.cts} +1 -1
  203. package/dist/{with-overlayed-view-zYPQzGGh.d.ts → with-overlayed-view-B8PkL179.d.ts} +1 -1
  204. package/dist/{with-overlayed-view-CJ2UDBol.d.cts → with-overlayed-view-pTOFgHRq.d.cts} +1 -1
  205. package/dist/{with-rollup-BvaJefEs.d.ts → with-rollup-Cd3t01Mz.d.ts} +1 -1
  206. package/dist/{with-rollup-B_zbRi3f.d.cts → with-rollup-D9qQoffP.d.cts} +1 -1
  207. package/package.json +3 -3
  208. package/dist/chunk-7DDTFGXY.js.map +0 -1
  209. package/dist/chunk-AD6RNBAW.js.map +0 -1
  210. package/dist/chunk-DDOYOMAD.js.map +0 -1
  211. package/dist/chunk-KD253AI5.js.map +0 -1
  212. package/dist/chunk-KSKKLVPA.js.map +0 -1
  213. package/dist/chunk-PS6PSEZL.js.map +0 -1
  214. package/dist/chunk-Z3BJF7SF.js.map +0 -1
  215. package/dist/executor-3SVNESQ3.js +0 -8
  216. package/dist/executor-BIW4FT5R.js +0 -12
  217. package/dist/executor-VEZUBJNQ.js +0 -8
  218. package/dist/issue-ZZ2XPOGP.js +0 -12
  219. package/dist/noydb-EY52NVH4.js +0 -39
  220. package/dist/registry-CMEVTOCN.js +0 -8
  221. package/dist/registry-XUBRO5JJ.js +0 -8
  222. /package/dist/{chunk-KA5A5CSD.js.map → chunk-2QDWRK3B.js.map} +0 -0
  223. /package/dist/{chunk-6H4CAHMQ.js.map → chunk-2UT7HJJR.js.map} +0 -0
  224. /package/dist/{chunk-E5TJAQS7.js.map → chunk-2ZYIN3BL.js.map} +0 -0
  225. /package/dist/{chunk-CVTPNW2Y.js.map → chunk-45QJXLLS.js.map} +0 -0
  226. /package/dist/{chunk-H4XFA2LM.js.map → chunk-4K4QKYK4.js.map} +0 -0
  227. /package/dist/{chunk-RHVYFAVQ.js.map → chunk-4L6N56B4.js.map} +0 -0
  228. /package/dist/{chunk-EW3H5Y7N.js.map → chunk-4YD7VZH4.js.map} +0 -0
  229. /package/dist/{chunk-BOMH3637.js.map → chunk-553CK4E2.js.map} +0 -0
  230. /package/dist/{chunk-I2RX62RX.js.map → chunk-5PTX7PKD.js.map} +0 -0
  231. /package/dist/{chunk-TESFHBOW.js.map → chunk-6EKRQ7QF.js.map} +0 -0
  232. /package/dist/{chunk-Q7P4WHTL.js.map → chunk-7GPQPLGO.js.map} +0 -0
  233. /package/dist/{chunk-OMBPGXCL.js.map → chunk-ASIGWYRA.js.map} +0 -0
  234. /package/dist/{chunk-IWGVH2RR.js.map → chunk-AWU4JF7C.js.map} +0 -0
  235. /package/dist/{chunk-SKYBEGHB.js.map → chunk-BEZ2EV43.js.map} +0 -0
  236. /package/dist/{chunk-EJJTUDNI.js.map → chunk-BITB3T5Z.js.map} +0 -0
  237. /package/dist/{chunk-6M5JKTUQ.js.map → chunk-CIZDUAHI.js.map} +0 -0
  238. /package/dist/{chunk-5EITJMUJ.js.map → chunk-CUPTCF4R.js.map} +0 -0
  239. /package/dist/{chunk-FO5WEDKF.js.map → chunk-DEE4CRYN.js.map} +0 -0
  240. /package/dist/{chunk-WVYL6HM7.js.map → chunk-DJO4OYCJ.js.map} +0 -0
  241. /package/dist/{chunk-7JSP3E67.js.map → chunk-E2MDPPOC.js.map} +0 -0
  242. /package/dist/{chunk-LX4CPLU6.js.map → chunk-FFKQ65YX.js.map} +0 -0
  243. /package/dist/{chunk-VUUQYWF5.js.map → chunk-G7ALNCQH.js.map} +0 -0
  244. /package/dist/{chunk-HAKEZTA7.js.map → chunk-JOJPBZSZ.js.map} +0 -0
  245. /package/dist/{chunk-C7UIT5XY.js.map → chunk-K6NVSHAH.js.map} +0 -0
  246. /package/dist/{chunk-3BANVNDH.js.map → chunk-KJ3K5VZM.js.map} +0 -0
  247. /package/dist/{chunk-ZW2YSN6G.js.map → chunk-LBILABKZ.js.map} +0 -0
  248. /package/dist/{chunk-K6PCTYAH.js.map → chunk-LXKBG52H.js.map} +0 -0
  249. /package/dist/{chunk-YYTM4U4J.js.map → chunk-MPIZQGFA.js.map} +0 -0
  250. /package/dist/{chunk-SID2NJNF.js.map → chunk-MRJPSXPE.js.map} +0 -0
  251. /package/dist/{chunk-J73KU4AE.js.map → chunk-MSMDDDDJ.js.map} +0 -0
  252. /package/dist/{chunk-6ZKXFMUG.js.map → chunk-QBLPY44S.js.map} +0 -0
  253. /package/dist/{chunk-2NYVA6FW.js.map → chunk-QWJCNXH2.js.map} +0 -0
  254. /package/dist/{chunk-YRQPI67X.js.map → chunk-RCB6GWTC.js.map} +0 -0
  255. /package/dist/{chunk-PFKAT4NT.js.map → chunk-REHF3HSJ.js.map} +0 -0
  256. /package/dist/{chunk-FUDVHE2U.js.map → chunk-SAAJYSVV.js.map} +0 -0
  257. /package/dist/{chunk-VJNV2GRF.js.map → chunk-SHJ3BRTZ.js.map} +0 -0
  258. /package/dist/{chunk-BMDVFBCL.js.map → chunk-SQXTKZL7.js.map} +0 -0
  259. /package/dist/{chunk-2KA3PDUR.js.map → chunk-TMUMMAWV.js.map} +0 -0
  260. /package/dist/{chunk-DONPLWRC.js.map → chunk-TZGWI5AX.js.map} +0 -0
  261. /package/dist/{chunk-KNJ7MK4B.js.map → chunk-UBF5JEOJ.js.map} +0 -0
  262. /package/dist/{chunk-FJ3C3ELF.js.map → chunk-XAYDHD2O.js.map} +0 -0
  263. /package/dist/{chunk-RRCRITDM.js.map → chunk-XYW2CSCI.js.map} +0 -0
  264. /package/dist/{chunk-LXA2E3VI.js.map → chunk-ZCMOS4H2.js.map} +0 -0
  265. /package/dist/{crypto-YBKBNPVM.js.map → crypto-G6XU2V2Y.js.map} +0 -0
  266. /package/dist/{delegation-4JSMM6BB.js.map → delegation-ZEH4LKEM.js.map} +0 -0
  267. /package/dist/{executor-3SVNESQ3.js.map → executor-DWVP4BSJ.js.map} +0 -0
  268. /package/dist/{executor-BIW4FT5R.js.map → executor-HB2YMIYC.js.map} +0 -0
  269. /package/dist/{executor-VEZUBJNQ.js.map → executor-HO3SIRSF.js.map} +0 -0
  270. /package/dist/{fanout-sidecar-OC4QVTS2.js.map → fanout-sidecar-BMT7I6FI.js.map} +0 -0
  271. /package/dist/{issue-ZZ2XPOGP.js.map → issue-FZRTVGRE.js.map} +0 -0
  272. /package/dist/{ledger-XQ4KVFQ6.js.map → ledger-PMTR2Q62.js.map} +0 -0
  273. /package/dist/{noydb-EY52NVH4.js.map → noydb-Y3ZLZNXA.js.map} +0 -0
  274. /package/dist/{public-envelope-O6X6AUUS.js.map → public-envelope-S2S2VR3F.js.map} +0 -0
  275. /package/dist/{registry-CMEVTOCN.js.map → registry-53A55ZZE.js.map} +0 -0
  276. /package/dist/{registry-OUZ3VBZA.js.map → registry-FKL4SLU4.js.map} +0 -0
  277. /package/dist/{registry-XUBRO5JJ.js.map → registry-IEU6ATO7.js.map} +0 -0
  278. /package/dist/{revoke-QJ2HUM4W.js.map → revoke-AOCAVR56.js.map} +0 -0
  279. /package/dist/{signer-SCJ6C6HQ.js.map → signer-JMK6W2Y6.js.map} +0 -0
  280. /package/dist/{stale-KKCHF2VB.js.map → stale-IIIGOHBW.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -46,7 +46,7 @@ var init_types = __esm({
46
46
  });
47
47
 
48
48
  // src/errors.ts
49
- var NoydbError, DebugPlaintextError, DebugReservedFieldError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, ReadOnlyAtInstantError, ReadOnlyFrameError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, ReservedVaultNameError, PeriodClosedError, RecordLockedError, FieldFrozenError, IllegalTransitionError, InvariantError, AmendmentForbiddenError, DirectoryDisabledError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, NumberingUncertaintyError, BundleVersionConflictError, NetworkError, NotFoundError, ValidationError, SchemaValidationError, SchemaUpdateError, NonAdditiveSchemaChangeError, SchemaLockedError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, DictKeyMissingError, DictKeyInUseError, MissingTranslationError, LocaleNotSpecifiedError, ScriptViolationError, StaticDictReadonlyError, UnknownDictCodeError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, TransferSealError, AttestationError, SessionExpiredError, SessionNotFoundError, SessionPolicyError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, FilenameSanitizationError, PathEscapeError, DerivationCycleError, DerivationDepthError, DerivationOutputUnknownError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, MaterializedViewConfigError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, SnapshotNotFoundError, UnknownShardError, ShardProvisioningError, DataResidencyError, VaultTemplateNotFoundError, ForgetStrategyNotConfiguredError, SealedRecordExpiredError, SealedRecordMismatchError, RecordCekNotFoundError;
49
+ var NoydbError, DebugPlaintextError, DebugReservedFieldError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, ReadOnlyAtInstantError, ReadOnlyFrameError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, ReservedVaultNameError, PeriodClosedError, RecordLockedError, FieldFrozenError, IllegalTransitionError, InvariantError, AmendmentForbiddenError, DirectoryDisabledError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, NumberingUncertaintyError, BundleVersionConflictError, NetworkError, NotFoundError, ValidationError, SchemaValidationError, SchemaUpdateError, NonAdditiveSchemaChangeError, SchemaLockedError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, DictKeyMissingError, DictKeyInUseError, MissingTranslationError, LocaleNotSpecifiedError, ScriptViolationError, StaticDictReadonlyError, UnknownDictCodeError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, TransferSealError, AttestationError, SessionExpiredError, SessionNotFoundError, SessionPolicyError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, FilenameSanitizationError, PathEscapeError, DerivationCycleError, DerivationDepthError, DerivationOutputUnknownError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, MaterializedViewConfigError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, SnapshotNotFoundError, UnknownShardError, ShardProvisioningError, DataResidencyError, VaultTemplateNotFoundError, ForgetStrategyNotConfiguredError, SealedRecordExpiredError, SealedRecordMismatchError, RecordCekNotFoundError, EmbeddingDimMismatchError, EmbeddingModelMismatchError;
50
50
  var init_errors = __esm({
51
51
  "src/errors.ts"() {
52
52
  "use strict";
@@ -1125,6 +1125,34 @@ Resolutions:
1125
1125
  this.id = id;
1126
1126
  }
1127
1127
  };
1128
+ EmbeddingDimMismatchError = class extends NoydbError {
1129
+ field;
1130
+ expected;
1131
+ actual;
1132
+ constructor(field, expected, actual) {
1133
+ super(
1134
+ "EMBEDDING_DIM_MISMATCH",
1135
+ `Embedding for "${field}" has dim ${actual}, expected ${expected}.`
1136
+ );
1137
+ this.name = "EmbeddingDimMismatchError";
1138
+ this.field = field;
1139
+ this.expected = expected;
1140
+ this.actual = actual;
1141
+ }
1142
+ };
1143
+ EmbeddingModelMismatchError = class extends NoydbError {
1144
+ expected;
1145
+ found;
1146
+ constructor(expected, found) {
1147
+ super(
1148
+ "EMBEDDING_MODEL_MISMATCH",
1149
+ `Embedding model mismatch: collection uses "${expected}" but a stored vector is "${found}". Run vault.embeddings.reindex() after changing the encoder.`
1150
+ );
1151
+ this.name = "EmbeddingModelMismatchError";
1152
+ this.expected = expected;
1153
+ this.found = found;
1154
+ }
1155
+ };
1128
1156
  }
1129
1157
  });
1130
1158
 
@@ -7578,13 +7606,14 @@ function stripDisallowed(str, scripts) {
7578
7606
  for (const ch of str) if (ok.test(ch)) out += ch;
7579
7607
  return out;
7580
7608
  }
7581
- function enforceScript(value, field, descriptor) {
7609
+ function enforceScript(value, field, descriptor, exempt) {
7582
7610
  const opt = descriptor.options;
7583
7611
  if (!opt.script) return { value, warnings: [] };
7584
7612
  const mode = opt.onScriptViolation ?? "reject";
7585
7613
  const warnings = [];
7586
7614
  let out = value;
7587
7615
  for (const [locale, raw] of Object.entries(value)) {
7616
+ if (exempt?.has(locale)) continue;
7588
7617
  if (typeof raw !== "string") continue;
7589
7618
  const allowed = allowedFor(descriptor, locale);
7590
7619
  if (fullMatcher(allowed).test(raw)) continue;
@@ -7675,8 +7704,18 @@ var init_script = __esm({
7675
7704
 
7676
7705
  // src/i18n/core.ts
7677
7706
  function i18nText(options) {
7707
+ if (options.densifyOnWrite === true && hasThrowPolicy(options.onMissing)) {
7708
+ throw new Error(
7709
+ `i18nText: densifyOnWrite cannot be combined with an explicit onMissing 'throw' policy \u2014 densify fills every empty slot, so a 'throw' would be unreachable. Remove the 'throw' policy or disable densifyOnWrite.`
7710
+ );
7711
+ }
7678
7712
  return { _noydbI18nText: true, options };
7679
7713
  }
7714
+ function hasThrowPolicy(onMissing) {
7715
+ if (onMissing === void 0) return false;
7716
+ if (typeof onMissing === "string") return onMissing === "throw";
7717
+ return Object.values(onMissing).includes("throw");
7718
+ }
7680
7719
  function isI18nTextDescriptor(x) {
7681
7720
  return typeof x === "object" && x !== null && x._noydbI18nText === true;
7682
7721
  }
@@ -7874,8 +7913,15 @@ function applyI18nLocale(record, i18nFields, locale, fallback, layer = "read") {
7874
7913
  };
7875
7914
  result = applyAtPath(result, field, locale, fallback, opts);
7876
7915
  }
7916
+ result = stripI18nFilled(result);
7877
7917
  return result;
7878
7918
  }
7919
+ function stripI18nFilled(record) {
7920
+ if (!Object.prototype.hasOwnProperty.call(record, "_i18nFilled")) return record;
7921
+ const rest = { ...record };
7922
+ delete rest._i18nFilled;
7923
+ return rest;
7924
+ }
7879
7925
  var init_core = __esm({
7880
7926
  "src/i18n/core.ts"() {
7881
7927
  "use strict";
@@ -8905,6 +8951,11 @@ var init_strategy2 = __esm({
8905
8951
  enforceScript(value) {
8906
8952
  return { value, warnings: [] };
8907
8953
  },
8954
+ computeExemptFills() {
8955
+ return /* @__PURE__ */ new Map();
8956
+ },
8957
+ densify() {
8958
+ },
8908
8959
  buildDictionaryHandle() {
8909
8960
  throw notEnabled("vault.dictionary()");
8910
8961
  }
@@ -10091,6 +10142,36 @@ var init_builder = __esm({
10091
10142
  predicates
10092
10143
  );
10093
10144
  }
10145
+ /**
10146
+ * @internal — #308 L3. The ids of records matching this query's plan,
10147
+ * recovered by reference identity: `executePlanWithSource` returns the
10148
+ * ORIGINAL snapshot record references (money-decode and joins are applied
10149
+ * later, in `toArray`), so each matched record is found in the id-paired
10150
+ * `snapshotEntries()` map. Used by `collection.retrieve({ within })`.
10151
+ * Throws if the source is not collection-backed (no `snapshotEntries`).
10152
+ */
10153
+ _idArray() {
10154
+ const entries = this.source.snapshotEntries?.();
10155
+ if (entries === void 0) {
10156
+ throw new Error(
10157
+ "Query._idArray(): the query source has no snapshotEntries(); retrieve({ within }) requires a collection-backed query (collection.query())."
10158
+ );
10159
+ }
10160
+ if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
10161
+ throw new Error(
10162
+ "Query._idArray(): retrieve({ within }) does not support crossJoin queries (cross-join produces new row objects, breaking id recovery). Use where/filter/and/or, or a projection .join()."
10163
+ );
10164
+ }
10165
+ const refToId = /* @__PURE__ */ new Map();
10166
+ for (const { id, record } of entries) refToId.set(record, id);
10167
+ const matched = executePlanWithSource(this.source, this.plan, this.joinContext);
10168
+ const ids = [];
10169
+ for (const r of matched) {
10170
+ const id = refToId.get(r);
10171
+ if (id !== void 0) ids.push(id);
10172
+ }
10173
+ return ids;
10174
+ }
10094
10175
  /**
10095
10176
  * Filter by a registered deterministic predicate. Requires
10096
10177
  * the Query to have been augmented with a predicates map (typically
@@ -12052,12 +12133,470 @@ var init_scan = __esm({
12052
12133
  }
12053
12134
  });
12054
12135
 
12136
+ // src/search/segment.ts
12137
+ var SEGMENTER, segmentTokens, segmentTokenizer;
12138
+ var init_segment = __esm({
12139
+ "src/search/segment.ts"() {
12140
+ "use strict";
12141
+ SEGMENTER = new Intl.Segmenter(void 0, { granularity: "word" });
12142
+ segmentTokens = (text) => {
12143
+ const out = [];
12144
+ if (!text) return out;
12145
+ for (const s of SEGMENTER.segment(text)) {
12146
+ if (s.isWordLike) out.push({ term: s.segment.normalize("NFKC").toLowerCase(), offset: s.index });
12147
+ }
12148
+ return out;
12149
+ };
12150
+ segmentTokenizer = (text) => segmentTokens(text).map((t) => t.term);
12151
+ }
12152
+ });
12153
+
12154
+ // src/search/inverted-index.ts
12155
+ var K12, B2, InvertedIndex;
12156
+ var init_inverted_index = __esm({
12157
+ "src/search/inverted-index.ts"() {
12158
+ "use strict";
12159
+ init_segment();
12160
+ K12 = 1.2;
12161
+ B2 = 0.75;
12162
+ InvertedIndex = class _InvertedIndex {
12163
+ // per field: df (term -> #docs), N (#docs), totalLen
12164
+ fieldStats = /* @__PURE__ */ new Map();
12165
+ docs = [];
12166
+ static build(docs) {
12167
+ const idx = new _InvertedIndex();
12168
+ for (const d of docs) {
12169
+ for (const f of d.fields) {
12170
+ const tokens = segmentTokens(f.text);
12171
+ const tf = /* @__PURE__ */ new Map();
12172
+ const firstOffset = /* @__PURE__ */ new Map();
12173
+ for (const t of tokens) {
12174
+ tf.set(t.term, (tf.get(t.term) ?? 0) + 1);
12175
+ if (!firstOffset.has(t.term)) firstOffset.set(t.term, t.offset);
12176
+ }
12177
+ const doc = { id: d.id, field: f.field, ...f.locale !== void 0 ? { locale: f.locale } : {}, text: f.text, len: tokens.length, tf, firstOffset };
12178
+ idx.docs.push(doc);
12179
+ let s = idx.fieldStats.get(f.field);
12180
+ if (!s) {
12181
+ s = { df: /* @__PURE__ */ new Map(), n: 0, totalLen: 0 };
12182
+ idx.fieldStats.set(f.field, s);
12183
+ }
12184
+ s.n += 1;
12185
+ s.totalLen += doc.len;
12186
+ for (const term of tf.keys()) s.df.set(term, (s.df.get(term) ?? 0) + 1);
12187
+ }
12188
+ }
12189
+ return idx;
12190
+ }
12191
+ query(query, opts = {}) {
12192
+ const terms = segmentTokenizer(query);
12193
+ if (terms.length === 0) return [];
12194
+ const usePrefix = opts.prefix ?? false;
12195
+ const exact = usePrefix ? terms.slice(0, -1) : terms;
12196
+ const prefix = usePrefix ? terms[terms.length - 1] : void 0;
12197
+ const match = opts.match ?? "any";
12198
+ const required = exact.length + (prefix !== void 0 ? 1 : 0);
12199
+ const best = /* @__PURE__ */ new Map();
12200
+ for (const doc of this.docs) {
12201
+ if (opts.fields !== void 0 && !opts.fields.includes(doc.field)) continue;
12202
+ const stats = this.fieldStats.get(doc.field);
12203
+ const avgdl = stats.totalLen / stats.n || 1;
12204
+ let score = 0;
12205
+ let matchedCount = 0;
12206
+ let snippetOffset = -1;
12207
+ const scoreTerm = (tf, df, offset) => {
12208
+ if (tf <= 0) return;
12209
+ matchedCount += 1;
12210
+ if (snippetOffset < 0 && offset >= 0) snippetOffset = offset;
12211
+ const idf = Math.log(1 + (stats.n - df + 0.5) / (df + 0.5));
12212
+ const denom = tf + K12 * (1 - B2 + B2 * (doc.len / avgdl));
12213
+ score += idf * (tf * (K12 + 1) / (denom || 1));
12214
+ };
12215
+ for (const qt of exact) scoreTerm(doc.tf.get(qt) ?? 0, stats.df.get(qt) ?? 0, doc.firstOffset.get(qt) ?? -1);
12216
+ if (prefix !== void 0) {
12217
+ const exactSet = new Set(exact);
12218
+ let ptf = 0;
12219
+ let poff = -1;
12220
+ for (const [term, c] of doc.tf) {
12221
+ if (term.startsWith(prefix) && !exactSet.has(term)) {
12222
+ ptf += c;
12223
+ if (poff < 0) poff = doc.firstOffset.get(term) ?? -1;
12224
+ }
12225
+ }
12226
+ if (ptf > 0) {
12227
+ let pdf = 0;
12228
+ for (const d of this.docs) {
12229
+ if (d.field === doc.field && [...d.tf.keys()].some((t) => t.startsWith(prefix))) pdf++;
12230
+ }
12231
+ scoreTerm(ptf, pdf || 1, poff);
12232
+ }
12233
+ }
12234
+ if (matchedCount === 0) continue;
12235
+ if (match === "all" && matchedCount < required) continue;
12236
+ const hit = {
12237
+ id: doc.id,
12238
+ score,
12239
+ field: doc.field,
12240
+ text: doc.text,
12241
+ offset: snippetOffset < 0 ? 0 : snippetOffset,
12242
+ ...doc.locale !== void 0 ? { locale: doc.locale } : {}
12243
+ };
12244
+ const prev = best.get(doc.id);
12245
+ if (!prev || hit.score > prev.score) best.set(doc.id, hit);
12246
+ }
12247
+ const results = [...best.values()].sort((a, b) => b.score - a.score);
12248
+ return opts.limit !== void 0 ? results.slice(0, opts.limit) : results;
12249
+ }
12250
+ toSnapshot() {
12251
+ return {
12252
+ v: 1,
12253
+ fieldStats: [...this.fieldStats].map(([f, s]) => [f, { df: [...s.df], n: s.n, totalLen: s.totalLen }]),
12254
+ docs: this.docs.map((d) => ({
12255
+ id: d.id,
12256
+ field: d.field,
12257
+ text: d.text,
12258
+ len: d.len,
12259
+ tf: [...d.tf],
12260
+ firstOffset: [...d.firstOffset],
12261
+ ...d.locale !== void 0 ? { locale: d.locale } : {}
12262
+ }))
12263
+ };
12264
+ }
12265
+ static fromSnapshot(s) {
12266
+ const idx = new _InvertedIndex();
12267
+ for (const [f, st] of s.fieldStats) idx.fieldStats.set(f, { df: new Map(st.df), n: st.n, totalLen: st.totalLen });
12268
+ for (const d of s.docs) {
12269
+ idx.docs.push({
12270
+ id: d.id,
12271
+ field: d.field,
12272
+ text: d.text,
12273
+ len: d.len,
12274
+ tf: new Map(d.tf),
12275
+ firstOffset: new Map(d.firstOffset),
12276
+ ...d.locale !== void 0 ? { locale: d.locale } : {}
12277
+ });
12278
+ }
12279
+ return idx;
12280
+ }
12281
+ };
12282
+ }
12283
+ });
12284
+
12285
+ // src/search/snippet.ts
12286
+ function extractSnippet(text, offset, window2 = 80) {
12287
+ const chars = Array.from(text);
12288
+ if (chars.length <= window2) return text;
12289
+ const cpOffset = Array.from(text.slice(0, Math.max(0, offset))).length;
12290
+ const half = Math.floor(window2 / 2);
12291
+ let start = Math.max(0, cpOffset - half);
12292
+ const end = Math.min(chars.length, start + window2);
12293
+ start = Math.max(0, end - window2);
12294
+ const body = chars.slice(start, end).join("");
12295
+ return `${start > 0 ? "\u2026" : ""}${body}${end < chars.length ? "\u2026" : ""}`;
12296
+ }
12297
+ var init_snippet = __esm({
12298
+ "src/search/snippet.ts"() {
12299
+ "use strict";
12300
+ }
12301
+ });
12302
+
12303
+ // src/search/index-store.ts
12304
+ var MemoryIndexStore;
12305
+ var init_index_store = __esm({
12306
+ "src/search/index-store.ts"() {
12307
+ "use strict";
12308
+ init_inverted_index();
12309
+ MemoryIndexStore = class {
12310
+ index;
12311
+ get built() {
12312
+ return this.index !== void 0;
12313
+ }
12314
+ async ensureBuilt(build) {
12315
+ if (this.index === void 0) this.index = InvertedIndex.build(build());
12316
+ return this.index;
12317
+ }
12318
+ markDirty() {
12319
+ this.index = void 0;
12320
+ }
12321
+ async flush() {
12322
+ }
12323
+ };
12324
+ }
12325
+ });
12326
+
12327
+ // src/search/build-docs.ts
12328
+ function buildStringFieldEntries(record, textIndexes, only) {
12329
+ const fields = only ? textIndexes.filter((f) => only.includes(f)) : textIndexes;
12330
+ const out = [];
12331
+ for (const field of fields) {
12332
+ for (const leaf of getAtPath(record, field)) {
12333
+ if (typeof leaf === "string" && leaf !== "") out.push({ field, text: leaf });
12334
+ }
12335
+ }
12336
+ return out;
12337
+ }
12338
+ function buildI18nFieldEntries(record, i18nFields, textIndexes, only) {
12339
+ const fields = (only ? textIndexes.filter((f) => only.includes(f)) : textIndexes).filter((f) => f in i18nFields);
12340
+ const out = [];
12341
+ for (const field of fields) {
12342
+ for (const leaf of getAtPath(record, field)) {
12343
+ if (!leaf || typeof leaf !== "object" || Array.isArray(leaf)) continue;
12344
+ for (const [locale, val] of Object.entries(leaf)) {
12345
+ if (typeof val === "string" && val !== "") out.push({ field, locale, text: val });
12346
+ }
12347
+ }
12348
+ }
12349
+ return out;
12350
+ }
12351
+ function buildDictKeyFieldEntries(record, dictKeyFields, labelMaps, textIndexes, only) {
12352
+ const fields = (only ? textIndexes.filter((f) => only.includes(f)) : textIndexes).filter((f) => f in dictKeyFields);
12353
+ const out = [];
12354
+ for (const field of fields) {
12355
+ const map = labelMaps.get(field);
12356
+ if (!map) continue;
12357
+ for (const leaf of getAtPath(record, field)) {
12358
+ const keys = typeof leaf === "string" ? [leaf] : Array.isArray(leaf) ? leaf.filter((k) => typeof k === "string") : [];
12359
+ for (const key of keys) {
12360
+ const labels = map.get(key);
12361
+ if (!labels) continue;
12362
+ for (const [locale, label] of Object.entries(labels)) {
12363
+ if (label !== "") out.push({ field, locale, text: label });
12364
+ }
12365
+ }
12366
+ }
12367
+ }
12368
+ return out;
12369
+ }
12370
+ function buildBlobFieldEntries(filenamesByField) {
12371
+ const out = [];
12372
+ for (const [field, names] of filenamesByField) {
12373
+ for (const name of names) if (name !== "") out.push({ field, text: name });
12374
+ }
12375
+ return out;
12376
+ }
12377
+ var init_build_docs = __esm({
12378
+ "src/search/build-docs.ts"() {
12379
+ "use strict";
12380
+ init_core();
12381
+ }
12382
+ });
12383
+
12384
+ // src/search/fuse.ts
12385
+ function fuseRetrieval(lists, opts = {}) {
12386
+ const k = opts.k ?? 60;
12387
+ const acc = /* @__PURE__ */ new Map();
12388
+ for (const list of lists) {
12389
+ for (const hit of list) {
12390
+ const contribution = 1 / (k + hit.rank);
12391
+ const prev = acc.get(hit.id);
12392
+ if (prev === void 0) {
12393
+ acc.set(hit.id, { score: contribution, hit });
12394
+ } else {
12395
+ prev.score += contribution;
12396
+ prev.hit = mergePresentation(prev.hit, hit);
12397
+ }
12398
+ }
12399
+ }
12400
+ const merged = [...acc.values()].sort(
12401
+ (a, b) => b.score - a.score || (a.hit.id < b.hit.id ? -1 : a.hit.id > b.hit.id ? 1 : 0)
12402
+ );
12403
+ const limited = opts.limit !== void 0 ? merged.slice(0, opts.limit) : merged;
12404
+ return limited.map((m, i) => ({ ...m.hit, score: m.score, rank: i + 1 }));
12405
+ }
12406
+ function mergePresentation(a, b) {
12407
+ const lexical = a.field !== "(vector)" ? a : b;
12408
+ const other = lexical === a ? b : a;
12409
+ return {
12410
+ ...lexical,
12411
+ ...lexical.record === void 0 && other.record !== void 0 ? { record: other.record } : {}
12412
+ };
12413
+ }
12414
+ var init_fuse = __esm({
12415
+ "src/search/fuse.ts"() {
12416
+ "use strict";
12417
+ }
12418
+ });
12419
+
12055
12420
  // src/search/index.ts
12056
12421
  var init_search = __esm({
12057
12422
  "src/search/index.ts"() {
12058
12423
  "use strict";
12059
12424
  init_tokenize();
12060
12425
  init_scan();
12426
+ init_fuse();
12427
+ }
12428
+ });
12429
+
12430
+ // src/search/serialize.ts
12431
+ function serializeIndex(idx) {
12432
+ return JSON.stringify(idx.toSnapshot());
12433
+ }
12434
+ function deserializeIndex(json) {
12435
+ return InvertedIndex.fromSnapshot(JSON.parse(json));
12436
+ }
12437
+ var init_serialize = __esm({
12438
+ "src/search/serialize.ts"() {
12439
+ "use strict";
12440
+ init_inverted_index();
12441
+ }
12442
+ });
12443
+
12444
+ // src/search/persisted-index-store.ts
12445
+ function fpEqual(a, b) {
12446
+ return a.count === b.count && a.maxVersion === b.maxVersion;
12447
+ }
12448
+ var PersistedIndexStore;
12449
+ var init_persisted_index_store = __esm({
12450
+ "src/search/persisted-index-store.ts"() {
12451
+ "use strict";
12452
+ init_inverted_index();
12453
+ init_serialize();
12454
+ PersistedIndexStore = class {
12455
+ constructor(cb) {
12456
+ this.cb = cb;
12457
+ this.debounceMs = cb.debounceMs ?? 1e3;
12458
+ }
12459
+ cb;
12460
+ index;
12461
+ timer = null;
12462
+ lastBuild;
12463
+ debounceMs;
12464
+ get built() {
12465
+ return this.index !== void 0;
12466
+ }
12467
+ async ensureBuilt(build) {
12468
+ this.lastBuild = build;
12469
+ if (this.index !== void 0) return this.index;
12470
+ const loaded = await this.cb.load();
12471
+ if (loaded !== null && fpEqual(loaded.fingerprint, this.cb.currentFingerprint())) {
12472
+ this.index = deserializeIndex(loaded.json);
12473
+ return this.index;
12474
+ }
12475
+ this.index = InvertedIndex.build(build());
12476
+ await this.persist();
12477
+ return this.index;
12478
+ }
12479
+ markDirty() {
12480
+ this.index = void 0;
12481
+ if (this.timer) clearTimeout(this.timer);
12482
+ this.timer = setTimeout(() => {
12483
+ this.timer = null;
12484
+ void this.rebuildAndPersist().catch(() => {
12485
+ });
12486
+ }, this.debounceMs);
12487
+ }
12488
+ /** Force an immediate persist (cancels any pending debounce). */
12489
+ async flush() {
12490
+ if (this.timer) {
12491
+ clearTimeout(this.timer);
12492
+ this.timer = null;
12493
+ }
12494
+ await this.rebuildAndPersist();
12495
+ }
12496
+ /** Delete the persisted blob and drop the in-memory index (forget/erasure). */
12497
+ async removePersisted() {
12498
+ if (this.timer) {
12499
+ clearTimeout(this.timer);
12500
+ this.timer = null;
12501
+ }
12502
+ this.index = void 0;
12503
+ await this.cb.remove();
12504
+ }
12505
+ /** Rebuild using the last known build thunk, then persist. */
12506
+ async rebuildAndPersist() {
12507
+ if (this.lastBuild === void 0) return;
12508
+ if (this.index === void 0) {
12509
+ this.index = InvertedIndex.build(this.lastBuild());
12510
+ }
12511
+ await this.persist();
12512
+ }
12513
+ async persist() {
12514
+ if (this.index === void 0) return;
12515
+ await this.cb.save(serializeIndex(this.index), this.cb.currentFingerprint());
12516
+ }
12517
+ };
12518
+ }
12519
+ });
12520
+
12521
+ // src/embeddings/cosine.ts
12522
+ function cosine(a, b) {
12523
+ if (a.length !== b.length) return 0;
12524
+ let dot = 0, na = 0, nb = 0;
12525
+ for (let i = 0; i < a.length; i++) {
12526
+ const x = a[i], y = b[i];
12527
+ dot += x * y;
12528
+ na += x * x;
12529
+ nb += y * y;
12530
+ }
12531
+ if (na === 0 || nb === 0) return 0;
12532
+ return dot / (Math.sqrt(na) * Math.sqrt(nb));
12533
+ }
12534
+ var init_cosine = __esm({
12535
+ "src/embeddings/cosine.ts"() {
12536
+ "use strict";
12537
+ }
12538
+ });
12539
+
12540
+ // src/embeddings/descriptor.ts
12541
+ function embeddingSourceText(record, source) {
12542
+ const fields = typeof source === "string" ? [source] : source;
12543
+ const parts = [];
12544
+ for (const f of fields) {
12545
+ for (const leaf of getAtPath(record, f)) {
12546
+ if (typeof leaf === "string" && leaf !== "") parts.push(leaf);
12547
+ }
12548
+ }
12549
+ return parts.join(" ");
12550
+ }
12551
+ var init_descriptor2 = __esm({
12552
+ "src/embeddings/descriptor.ts"() {
12553
+ "use strict";
12554
+ init_core();
12555
+ }
12556
+ });
12557
+
12558
+ // src/embeddings/vector-set.ts
12559
+ var VectorSet;
12560
+ var init_vector_set = __esm({
12561
+ "src/embeddings/vector-set.ts"() {
12562
+ "use strict";
12563
+ init_cosine();
12564
+ init_errors();
12565
+ VectorSet = class {
12566
+ vectors;
12567
+ get loaded() {
12568
+ return this.vectors !== void 0;
12569
+ }
12570
+ async ensureLoaded(load) {
12571
+ if (this.vectors === void 0) this.vectors = await load();
12572
+ }
12573
+ markDirty() {
12574
+ this.vectors = void 0;
12575
+ }
12576
+ cosineTopK(query, k, opts = {}) {
12577
+ const all = this.vectors ?? [];
12578
+ const minScore = opts.minScore ?? -Infinity;
12579
+ const hits = [];
12580
+ for (const v of all) {
12581
+ if (opts.expectModel !== void 0 && v.model !== opts.expectModel) {
12582
+ throw new EmbeddingModelMismatchError(opts.expectModel, v.model);
12583
+ }
12584
+ const score = cosine(query, v.vec);
12585
+ if (score >= minScore) hits.push({ id: v.id, score });
12586
+ }
12587
+ hits.sort((a, b) => b.score - a.score);
12588
+ return hits.slice(0, k);
12589
+ }
12590
+ };
12591
+ }
12592
+ });
12593
+
12594
+ // src/embeddings/index.ts
12595
+ var init_embeddings = __esm({
12596
+ "src/embeddings/index.ts"() {
12597
+ "use strict";
12598
+ init_descriptor2();
12599
+ init_vector_set();
12061
12600
  }
12062
12601
  });
12063
12602
 
@@ -13716,7 +14255,12 @@ var init_collection = __esm({
13716
14255
  init_lazy_builder();
13717
14256
  init_strategy5();
13718
14257
  init_search();
14258
+ init_index_store();
14259
+ init_persisted_index_store();
14260
+ init_snippet();
14261
+ init_build_docs();
13719
14262
  init_errors();
14263
+ init_embeddings();
13720
14264
  init_unique_constraints();
13721
14265
  init_cache();
13722
14266
  init_ulid();
@@ -13868,6 +14412,33 @@ var init_collection = __esm({
13868
14412
  * Declared via the `i18nFields` collection option.
13869
14413
  */
13870
14414
  i18nFields;
14415
+ /**
14416
+ * #308 L1 — the configured string fields exposed to `retrieve()`. `undefined`
14417
+ * for ordinary collections, so the search path costs nothing when unused.
14418
+ */
14419
+ textIndexes;
14420
+ /**
14421
+ * #308 L1 — the session-scoped lexical index store. `undefined` (so the dirty
14422
+ * poke + retrieve are zero-cost) unless `textIndexes` is non-empty.
14423
+ */
14424
+ searchIndexStore;
14425
+ /**
14426
+ * #435 — the densify-enabled subset of {@link i18nFields} (fields whose
14427
+ * descriptor opts in via `densifyOnWrite: true`). `undefined` when none opt
14428
+ * in, so the write path skips all densify work for ordinary collections.
14429
+ */
14430
+ i18nDensifyFields;
14431
+ /**
14432
+ * #308 L2 — embedding config for write-time vector derivation. `undefined`
14433
+ * for ordinary collections (zero cost). When set, `put()` encodes the
14434
+ * source field(s) and stores an encrypted `_vec` sidecar.
14435
+ */
14436
+ embeddings;
14437
+ /**
14438
+ * #308 L2 — in-memory vector set, populated lazily from `_vec` sidecars.
14439
+ * `undefined` when no embedding config is declared.
14440
+ */
14441
+ vectorSet;
13871
14442
  /**
13872
14443
  * Map of field name → `DictKeyDescriptor` for fields declared with
13873
14444
  * `dictKey()`. Used by `get()`/`list()` to add `<field>Label` virtual
@@ -13894,6 +14465,12 @@ var init_collection = __esm({
13894
14465
  * Signature: `(dictName, key, locale, fallback?) => Promise<string | undefined>`
13895
14466
  */
13896
14467
  dictLabelResolver;
14468
+ /**
14469
+ * #308 L1 — async callback provided by the Vault to open a dynamic
14470
+ * dictionary handle (for label-map pre-computation in the search index).
14471
+ * Only used in `resolveDictLabelMaps()`; static dicts bypass this entirely.
14472
+ */
14473
+ getDictionary;
13897
14474
  /**
13898
14475
  * Synchronous callback provided by the Vault that validates
13899
14476
  * i18nText fields on `put()`. Throws `MissingTranslationError` when
@@ -14054,11 +14631,25 @@ var init_collection = __esm({
14054
14631
  this.refEnforcer = opts.refEnforcer;
14055
14632
  this.joinResolver = opts.joinResolver;
14056
14633
  this.i18nFields = opts.i18nFields;
14634
+ this.textIndexes = opts.textIndexes;
14635
+ this.searchIndexStore = opts.textIndexes && opts.textIndexes.length > 0 ? opts.textIndexPersist ? new PersistedIndexStore(this.buildPersistedIndexCallbacks()) : new MemoryIndexStore() : void 0;
14636
+ const densifyFields = opts.i18nFields ? Object.fromEntries(
14637
+ Object.entries(opts.i18nFields).filter(([, d]) => d.options.densifyOnWrite === true)
14638
+ ) : {};
14639
+ this.i18nDensifyFields = Object.keys(densifyFields).length > 0 ? densifyFields : void 0;
14640
+ if (opts.embeddings && opts.crdt) {
14641
+ throw new Error(
14642
+ `Collection "${opts.name}": embeddings are not supported on CRDT collections (L2). Use a non-CRDT collection for semantic search.`
14643
+ );
14644
+ }
14645
+ this.embeddings = opts.embeddings;
14646
+ this.vectorSet = opts.embeddings ? new VectorSet() : void 0;
14057
14647
  this.dictKeyFields = opts.dictKeyFields;
14058
14648
  if (opts.moneyFields) validateMoneyFieldPaths(opts.moneyFields);
14059
14649
  this.moneyFields = opts.moneyFields;
14060
14650
  this.computed = opts.computed;
14061
14651
  this.dictLabelResolver = opts.dictLabelResolver;
14652
+ this.getDictionary = opts.getDictionary;
14062
14653
  this.i18nPutValidator = opts.i18nPutValidator;
14063
14654
  this.autoTranslateHook = opts.autoTranslateHook;
14064
14655
  this.defaultLocale = opts.defaultLocale;
@@ -14373,6 +14964,32 @@ var init_collection = __esm({
14373
14964
  if (busAfterPut) await this.subsystemBus.dispatch("afterPut", event);
14374
14965
  }
14375
14966
  }
14967
+ /**
14968
+ * #435 — resolve the prior stored record (with its `_i18nFilled` marker) for
14969
+ * densify. Eager: in-memory cache; lazy: LRU then adapter. undefined if absent.
14970
+ */
14971
+ async resolveDensifyPrior(id) {
14972
+ if (this.lazy && this.lru) {
14973
+ const cached = this.lru.get(id);
14974
+ if (cached) return cached.record;
14975
+ const env = await this.adapter.get(this.vault, this.name, id);
14976
+ if (!env) return void 0;
14977
+ const rec = await this.decryptRecord(env);
14978
+ return rec === null ? void 0 : rec;
14979
+ }
14980
+ await this.ensureHydrated();
14981
+ return this.cache.get(id)?.record;
14982
+ }
14983
+ /**
14984
+ * #435 — densify provenance for a record: which i18n slots were auto-filled,
14985
+ * e.g. `{ name: ['en'] }`. undefined when nothing was filled. The marker is
14986
+ * stripped from ordinary reads; this is the sanctioned audit accessor.
14987
+ */
14988
+ async i18nProvenance(id) {
14989
+ const prior = await this.resolveDensifyPrior(id);
14990
+ const marker = prior?.["_i18nFilled"];
14991
+ return marker && Object.keys(marker).length > 0 ? marker : void 0;
14992
+ }
14376
14993
  /**
14377
14994
  * Validate a record against this collection's schema WITHOUT writing it.
14378
14995
  * Returns the (possibly coerced) record on success; throws
@@ -14487,6 +15104,16 @@ var init_collection = __esm({
14487
15104
  setAtPathInPlace(obj, field, translated);
14488
15105
  }
14489
15106
  }
15107
+ let densifyPrior;
15108
+ let exemptFills;
15109
+ if (this.i18nDensifyFields) {
15110
+ densifyPrior = await this.resolveDensifyPrior(id);
15111
+ exemptFills = this.i18nStrategy.computeExemptFills(
15112
+ densifyPrior,
15113
+ record,
15114
+ this.i18nDensifyFields
15115
+ );
15116
+ }
14490
15117
  if (this.i18nFields) {
14491
15118
  const obj = record;
14492
15119
  for (const [field, descriptor] of Object.entries(this.i18nFields)) {
@@ -14494,18 +15121,38 @@ var init_collection = __esm({
14494
15121
  for (const leaf of getAtPath(obj, field)) {
14495
15122
  if (!leaf || typeof leaf !== "object" || Array.isArray(leaf)) continue;
14496
15123
  const leafMap = leaf;
14497
- const { value: cleaned } = this.i18nStrategy.enforceScript(
15124
+ const { value: cleaned, warnings } = this.i18nStrategy.enforceScript(
14498
15125
  leafMap,
14499
15126
  field,
14500
- descriptor
15127
+ descriptor,
15128
+ exemptFills?.get(field)
14501
15129
  );
14502
15130
  if (cleaned !== leafMap) Object.assign(leafMap, cleaned);
15131
+ const mode = descriptor.options.onScriptViolation;
15132
+ if (mode === "warn" || mode === "filter") {
15133
+ for (const w of warnings) {
15134
+ this.emitter.emit("i18n:script-violation", {
15135
+ vault: this.vault,
15136
+ collection: this.name,
15137
+ id,
15138
+ mode,
15139
+ warning: w
15140
+ });
15141
+ }
15142
+ }
14503
15143
  }
14504
15144
  }
14505
15145
  }
14506
15146
  if (this.i18nPutValidator !== void 0) {
14507
15147
  this.i18nPutValidator(record);
14508
15148
  }
15149
+ if (this.i18nDensifyFields) {
15150
+ this.i18nStrategy.densify(
15151
+ record,
15152
+ densifyPrior,
15153
+ this.i18nDensifyFields
15154
+ );
15155
+ }
14509
15156
  if (this.refEnforcer !== void 0) {
14510
15157
  await this.refEnforcer.enforceRefsOnPut(this.name, record);
14511
15158
  }
@@ -14584,6 +15231,7 @@ var init_collection = __esm({
14584
15231
  }
14585
15232
  await this.onDirty?.(this.name, id, "put", version2);
14586
15233
  this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action: "put" });
15234
+ this.searchIndexStore?.markDirty();
14587
15235
  await this.onAccess?.("put", id);
14588
15236
  await this.dispatchDerivations(id, record, version2);
14589
15237
  await this.dispatchMaterializedViews(id, record);
@@ -14625,6 +15273,15 @@ var init_collection = __esm({
14625
15273
  }
14626
15274
  const envelope = await this.encryptRecord(record, version, cek, options?.source, options?.sourceTs);
14627
15275
  await this.adapter.put(this.vault, this.name, id, envelope);
15276
+ if (this.embeddings) {
15277
+ const text = embeddingSourceText(record, this.embeddings.source);
15278
+ const vec = await this.embeddings.encode(text);
15279
+ if (vec.length !== this.embeddings.dim) throw new EmbeddingDimMismatchError("embeddings", this.embeddings.dim, vec.length);
15280
+ const body = JSON.stringify({ vec: Array.from(vec), model: this.embeddings.model, dim: this.embeddings.dim });
15281
+ const vecEnv = await this.encryptJsonString(body, version);
15282
+ await this.adapter.put(this.vault, "_vec", id, vecEnv);
15283
+ this.vectorSet?.markDirty();
15284
+ }
14628
15285
  if (this.ledger) {
14629
15286
  const appendInput = {
14630
15287
  op: "put",
@@ -14655,6 +15312,7 @@ var init_collection = __esm({
14655
15312
  id,
14656
15313
  action: "put"
14657
15314
  });
15315
+ this.searchIndexStore?.markDirty();
14658
15316
  await this.onAccess?.("put", id);
14659
15317
  await this.dispatchDerivations(id, record, version);
14660
15318
  await this.dispatchMaterializedViews(id, record);
@@ -15178,6 +15836,7 @@ var init_collection = __esm({
15178
15836
  id,
15179
15837
  action: "delete"
15180
15838
  });
15839
+ this.searchIndexStore?.markDirty();
15181
15840
  await this.onAccess?.("delete", id);
15182
15841
  if (!internal) {
15183
15842
  await this.dispatchMaterializedViewsOnDelete(id);
@@ -15359,9 +16018,255 @@ var init_collection = __esm({
15359
16018
  }
15360
16019
  await this.ensureHydrated();
15361
16020
  const entries = [];
15362
- for (const [id, e] of this.cache) entries.push({ id, record: e.record });
16021
+ for (const [id, e] of this.cache) entries.push({ id, record: stripI18nFilled(e.record) });
15363
16022
  return searchScan(entries, field, query, opts);
15364
16023
  }
16024
+ /** #308 L1 — build IndexDoc[] for the configured text fields over the live cache. */
16025
+ buildRetrievalDocs(labelMaps, blobFilenames, only) {
16026
+ const docs = [];
16027
+ for (const [id, e] of this.cache) {
16028
+ const rec = stripI18nFilled(e.record);
16029
+ const fields = buildStringFieldEntries(rec, this.textIndexes ?? [], only);
16030
+ if (this.i18nFields) fields.push(...buildI18nFieldEntries(rec, this.i18nFields, this.textIndexes ?? [], only));
16031
+ if (this.dictKeyFields) fields.push(...buildDictKeyFieldEntries(rec, this.dictKeyFields, labelMaps, this.textIndexes ?? [], only));
16032
+ const blobNames = blobFilenames.get(id);
16033
+ if (blobNames) fields.push(...buildBlobFieldEntries(blobNames));
16034
+ if (fields.length > 0) docs.push({ id, fields });
16035
+ }
16036
+ return docs;
16037
+ }
16038
+ /** #308 L1 — true iff any configured text index is also a blob field (gates ALL slot I/O). */
16039
+ hasIndexedBlobFields(only) {
16040
+ if (!this.blobFields || !this.textIndexes) return false;
16041
+ const fields = only ? this.textIndexes.filter((f) => only.includes(f)) : this.textIndexes;
16042
+ return fields.some((f) => f in this.blobFields);
16043
+ }
16044
+ /**
16045
+ * #308 L1 — resolve `recordId -> (blobField -> filenames[])` by listing slots
16046
+ * for the configured blob fields of each cached record. Blob slot metadata is
16047
+ * NOT inline on the record: it lives in a separate `_blob_slots_*` collection,
16048
+ * so this costs ONE `blob(id).list()` (a `listSlots`) per record at build time
16049
+ * — the heaviest indexing source. Fully gated by {@link hasIndexedBlobFields};
16050
+ * non-blob (and blob-but-not-indexed) collections do ZERO slot I/O.
16051
+ */
16052
+ async resolveBlobFilenames(only) {
16053
+ const out = /* @__PURE__ */ new Map();
16054
+ if (!this.hasIndexedBlobFields(only)) return out;
16055
+ const indexed = (only ? this.textIndexes.filter((f) => only.includes(f)) : this.textIndexes).filter((f) => f in this.blobFields);
16056
+ const indexedSet = new Set(indexed);
16057
+ for (const id of this.cache.keys()) {
16058
+ let slots;
16059
+ try {
16060
+ slots = await this.blob(id).list();
16061
+ } catch {
16062
+ continue;
16063
+ }
16064
+ let byField;
16065
+ for (const slot of slots) {
16066
+ if (!indexedSet.has(slot.name) || !slot.filename) continue;
16067
+ if (!byField) {
16068
+ byField = /* @__PURE__ */ new Map();
16069
+ out.set(id, byField);
16070
+ }
16071
+ const names = byField.get(slot.name);
16072
+ if (names) names.push(slot.filename);
16073
+ else byField.set(slot.name, [slot.filename]);
16074
+ }
16075
+ }
16076
+ return out;
16077
+ }
16078
+ /** #308 L1 — field -> (key -> {locale->label}) for dictKey fields; static from table, dynamic via getDictionary().list(). */
16079
+ async resolveDictLabelMaps() {
16080
+ const maps = /* @__PURE__ */ new Map();
16081
+ if (!this.dictKeyFields || !this.textIndexes) return maps;
16082
+ for (const field of this.textIndexes) {
16083
+ const desc = this.dictKeyFields[field];
16084
+ if (!desc) continue;
16085
+ const m = /* @__PURE__ */ new Map();
16086
+ if (isStaticDictDescriptor(desc)) {
16087
+ for (const [key, labels] of Object.entries(desc.table)) m.set(key, labels);
16088
+ } else {
16089
+ if (this.getDictionary) {
16090
+ const handle = await this.getDictionary(desc.name);
16091
+ for (const e of await handle.list()) m.set(e.key, e.labels);
16092
+ }
16093
+ }
16094
+ maps.set(field, m);
16095
+ }
16096
+ return maps;
16097
+ }
16098
+ /** #308 L1.5 — force-persist the lexical index now (e.g. on save/idle). Persists only when textIndexPersist is enabled; a no-op otherwise. */
16099
+ async flushIndex() {
16100
+ if (!this.searchIndexStore) return;
16101
+ await this.ensureHydrated();
16102
+ const labelMaps = await this.resolveDictLabelMaps();
16103
+ const blobFilenames = await this.resolveBlobFilenames();
16104
+ await this.searchIndexStore.ensureBuilt(() => this.buildRetrievalDocs(labelMaps, blobFilenames));
16105
+ await this.searchIndexStore.flush?.();
16106
+ }
16107
+ /** #308 L2 — load + decrypt all _vec sidecars into StoredVector[] for the VectorSet. */
16108
+ buildVectorLoad() {
16109
+ return async () => {
16110
+ const ids = await this.adapter.list(this.vault, "_vec");
16111
+ const out = [];
16112
+ for (const id of ids) {
16113
+ const env = await this.adapter.get(this.vault, "_vec", id);
16114
+ if (!env) continue;
16115
+ const body = await this.decryptJsonString(env);
16116
+ if (body === null) continue;
16117
+ const parsed = JSON.parse(body);
16118
+ out.push({ id, vec: new Float32Array(parsed.vec), model: parsed.model });
16119
+ }
16120
+ return out;
16121
+ };
16122
+ }
16123
+ /**
16124
+ * #308 L1.5 — build the PersistedIndexCallbacks bridge: crypto lives here
16125
+ * (collection has getDEK / encryptJsonString / decryptJsonString / adapter),
16126
+ * the index store itself is crypto-free.
16127
+ *
16128
+ * Fingerprint encoding: body-wrap approach — save(json, fp) stores
16129
+ * JSON.stringify({ fp, idx: json }) as the encrypted body so the standard
16130
+ * EncryptedEnvelope shape is never extended. load() decrypts and JSON.parses
16131
+ * the wrapper back out.
16132
+ *
16133
+ * Cache shape: this.cache stores { record, version } — currentFingerprint()
16134
+ * iterates over e.version.
16135
+ */
16136
+ buildPersistedIndexCallbacks() {
16137
+ const FT = "_ftindex";
16138
+ return {
16139
+ load: async () => {
16140
+ const env = await this.adapter.get(this.vault, FT, this.name);
16141
+ if (!env) return null;
16142
+ const body = await this.decryptJsonString(env);
16143
+ if (body === null) return null;
16144
+ try {
16145
+ const wrapped = JSON.parse(body);
16146
+ return { json: wrapped.idx, fingerprint: wrapped.fp };
16147
+ } catch {
16148
+ return null;
16149
+ }
16150
+ },
16151
+ save: async (json, fp) => {
16152
+ const body = JSON.stringify({ fp, idx: json });
16153
+ const env = await this.encryptJsonString(body, fp.count);
16154
+ await this.adapter.put(this.vault, FT, this.name, env);
16155
+ },
16156
+ remove: async () => {
16157
+ await this.adapter.delete(this.vault, FT, this.name);
16158
+ },
16159
+ currentFingerprint: () => {
16160
+ let maxVersion = 0;
16161
+ for (const e of this.cache.values()) if (e.version > maxVersion) maxVersion = e.version;
16162
+ return { count: this.cache.size, maxVersion };
16163
+ }
16164
+ };
16165
+ }
16166
+ /** #308 L1 — pre-build the lexical index (e.g. on open) so the first retrieve() pays no build scan. */
16167
+ async warmIndex() {
16168
+ if (!this.searchIndexStore) return;
16169
+ if (this.lazy) {
16170
+ throw new Error(
16171
+ `Collection "${this.name}": warmIndex() requires eager mode (prefetch: true).`
16172
+ );
16173
+ }
16174
+ await this.ensureHydrated();
16175
+ const built = this.searchIndexStore.built;
16176
+ const labelMaps = built ? /* @__PURE__ */ new Map() : await this.resolveDictLabelMaps();
16177
+ const blobFilenames = built ? /* @__PURE__ */ new Map() : await this.resolveBlobFilenames();
16178
+ await this.searchIndexStore.ensureBuilt(() => this.buildRetrievalDocs(labelMaps, blobFilenames));
16179
+ }
16180
+ /** #308 — retrieval. mode: 'lexical' (default) | 'semantic' (L2) | 'hybrid' (L3). */
16181
+ async retrieve(query, opts = {}) {
16182
+ const hits = opts.mode === "semantic" ? await this.retrieveSemantic(query, opts) : opts.mode === "hybrid" ? await this.retrieveHybrid(query, opts) : await this.retrieveLexical(query, opts);
16183
+ return opts.within ? this.applyWithin(hits, opts.within) : hits;
16184
+ }
16185
+ /** #308 L3 — keep only hits whose id matches the structured query, re-rank 1-based. */
16186
+ applyWithin(hits, within) {
16187
+ const ids = new Set(within._idArray());
16188
+ return hits.filter((h) => ids.has(h.id)).map((h, i) => ({ ...h, rank: i + 1 }));
16189
+ }
16190
+ /** #308 L1 — client-side lexical retrieval; ranked { id, score, field, snippet, locale? }. */
16191
+ async retrieveLexical(query, opts) {
16192
+ if (!this.searchIndexStore) {
16193
+ throw new Error(`Collection "${this.name}": retrieve() requires a textIndexes config.`);
16194
+ }
16195
+ if (this.lazy) {
16196
+ throw new Error(
16197
+ `Collection "${this.name}": retrieve() requires eager mode (prefetch: true).`
16198
+ );
16199
+ }
16200
+ await this.ensureHydrated();
16201
+ const built = this.searchIndexStore.built;
16202
+ const labelMaps = built ? /* @__PURE__ */ new Map() : await this.resolveDictLabelMaps();
16203
+ const blobFilenames = built ? /* @__PURE__ */ new Map() : await this.resolveBlobFilenames();
16204
+ const index = await this.searchIndexStore.ensureBuilt(() => this.buildRetrievalDocs(labelMaps, blobFilenames));
16205
+ const hits = index.query(query, {
16206
+ ...opts.limit !== void 0 ? { limit: opts.limit } : {},
16207
+ ...opts.match ? { match: opts.match } : {},
16208
+ ...opts.prefix ? { prefix: opts.prefix } : {},
16209
+ ...opts.fields ? { fields: opts.fields } : {}
16210
+ });
16211
+ const window2 = opts.snippetWindow ?? 80;
16212
+ return hits.map((h, i) => {
16213
+ const base = {
16214
+ id: h.id,
16215
+ score: h.score,
16216
+ rank: i + 1,
16217
+ field: h.field,
16218
+ snippet: extractSnippet(h.text, h.offset, window2),
16219
+ ...h.locale !== void 0 ? { locale: h.locale } : {},
16220
+ ...opts.includeRecord ? (() => {
16221
+ const e = this.cache.get(h.id);
16222
+ return e ? { record: stripI18nFilled(e.record) } : {};
16223
+ })() : {}
16224
+ };
16225
+ return base;
16226
+ });
16227
+ }
16228
+ /** #308 L3 — hybrid: fuse lexical (L1) + semantic (L2) by RRF. Requires embeddings. */
16229
+ async retrieveHybrid(query, opts) {
16230
+ if (!this.embeddings) {
16231
+ throw new Error(`Collection "${this.name}": retrieve({mode:'hybrid'}) requires an embeddings config.`);
16232
+ }
16233
+ const [lex, sem] = await Promise.all([
16234
+ this.retrieveLexical(query, opts),
16235
+ this.retrieveSemantic(query, opts)
16236
+ ]);
16237
+ return fuseRetrieval([lex, sem], opts.limit !== void 0 ? { limit: opts.limit } : {});
16238
+ }
16239
+ /** #308 L2 — semantic branch of retrieve(): encode query → similarTo(). */
16240
+ async retrieveSemantic(query, opts) {
16241
+ if (!this.embeddings) throw new Error(`Collection "${this.name}": retrieve({mode:'semantic'}) requires an embeddings config.`);
16242
+ if (this.lazy) throw new Error(`Collection "${this.name}": retrieve() requires eager mode (prefetch: true).`);
16243
+ const qVec = await this.embeddings.encode(query);
16244
+ return this.similarTo(qVec, {
16245
+ ...opts.limit !== void 0 ? { k: opts.limit } : {},
16246
+ ...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
16247
+ ...opts.includeRecord ? { includeRecord: true } : {}
16248
+ });
16249
+ }
16250
+ /** #308 L2 — raw-vector kNN over the encrypted vector set (decrypted in the trusted tier).
16251
+ * Snippet is '' for vector hits in v1 (semantic match isn't span-located). */
16252
+ async similarTo(vector, opts = {}) {
16253
+ if (!this.embeddings || !this.vectorSet) throw new Error(`Collection "${this.name}": similarTo() requires an embeddings config.`);
16254
+ if (this.lazy) throw new Error(`Collection "${this.name}": similarTo() requires eager mode (prefetch: true).`);
16255
+ await this.ensureHydrated();
16256
+ await this.vectorSet.ensureLoaded(this.buildVectorLoad());
16257
+ const hits = this.vectorSet.cosineTopK(vector, opts.k ?? 10, {
16258
+ ...opts.minScore !== void 0 ? { minScore: opts.minScore } : {},
16259
+ expectModel: this.embeddings.model
16260
+ });
16261
+ return hits.map((h, i) => {
16262
+ const base = { id: h.id, score: h.score, rank: i + 1, field: "(vector)", snippet: "" };
16263
+ if (opts.includeRecord) {
16264
+ const e = this.cache.get(h.id);
16265
+ if (e) base.record = stripI18nFilled(e.record);
16266
+ }
16267
+ return base;
16268
+ });
16269
+ }
15365
16270
  // ─── Bulk operations ─────────────────────────────────────
15366
16271
  /**
15367
16272
  * Put many records in one call. Each item is processed sequentially
@@ -15531,6 +16436,7 @@ var init_collection = __esm({
15531
16436
  // back to a linear scan otherwise.
15532
16437
  getIndexes: () => this.getIndexes(),
15533
16438
  lookupById: (id) => this.cache.get(id)?.record,
16439
+ snapshotEntries: () => [...this.cache.entries()].map(([id, e]) => ({ id, record: e.record })),
15534
16440
  ...this.moneyFields ? { moneyFields: this.moneyFields } : {}
15535
16441
  };
15536
16442
  const resolver = this.joinResolver;
@@ -15961,6 +16867,7 @@ var init_collection = __esm({
15961
16867
  async _applyRemoteChange(id, action) {
15962
16868
  await this._invalidateCacheEntry(id);
15963
16869
  this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action });
16870
+ this.searchIndexStore?.markDirty();
15964
16871
  }
15965
16872
  /** @internal — the current in-memory record without a store read (for conflict capture). */
15966
16873
  _peekCached(id) {
@@ -16273,7 +17180,7 @@ var init_collection = __esm({
16273
17180
  const hasStaticDisplay = hasDict && this.dictKeyFields !== void 0 && Object.values(this.dictKeyFields).some(
16274
17181
  (d) => isStaticDictDescriptor(d) && d.displayLocale !== void 0
16275
17182
  );
16276
- if (!locale && !hasStaticDisplay) return result;
17183
+ if (!locale && !hasStaticDisplay) return stripI18nFilled(result);
16277
17184
  const layer = localeOpts?._layer ?? "read";
16278
17185
  if (locale && hasI18n && this.i18nFields) {
16279
17186
  result = this.i18nStrategy.applyI18nLocale(result, this.i18nFields, locale, localeOpts?.fallback, layer);
@@ -16340,7 +17247,7 @@ var init_collection = __esm({
16340
17247
  }
16341
17248
  result = withLabels;
16342
17249
  }
16343
- return result;
17250
+ return stripI18nFilled(result);
16344
17251
  }
16345
17252
  /**
16346
17253
  * Low-level: encrypt a pre-serialised JSON string into an EncryptedEnvelope.
@@ -16459,6 +17366,19 @@ var init_collection = __esm({
16459
17366
  }
16460
17367
  return { purged, residue };
16461
17368
  }
17369
+ /** #308 L2 — drop a record's encrypted _vec sidecar on erasure (a vector is text-invertible).
17370
+ * Called by vault.ts forget() inside a resilient try/catch; residue is reported in ForgetResult. */
17371
+ async _purgeVector(id) {
17372
+ await this.adapter.delete(this.vault, "_vec", id);
17373
+ this.vectorSet?.markDirty();
17374
+ }
17375
+ /** #308 L1.5 — drop the persisted lexical-index blob (forget/erasure): an opaque
17376
+ * all-records index must not survive crypto-shred. Idempotent; no-op without persist. */
17377
+ async _purgeSearchIndex() {
17378
+ const store = this.searchIndexStore;
17379
+ if (store && "removePersisted" in store) await store.removePersisted();
17380
+ else store?.markDirty();
17381
+ }
16462
17382
  /**
16463
17383
  * Bulk-load the persisted-index mirror from `_idx/<field>/*` side-cars
16464
17384
  * on first lazy-mode query. Idempotent — subsequent calls short-circuit
@@ -19744,6 +20664,10 @@ var init_vault = __esm({
19744
20664
  collOpts.onCrossTierAccess = (event) => this.emitCrossTier(event);
19745
20665
  if (this.syncAdapter !== void 0) collOpts.syncAdapter = this.syncAdapter;
19746
20666
  if (options?.i18nFields !== void 0) collOpts.i18nFields = options.i18nFields;
20667
+ if (options?.embeddings !== void 0) collOpts.embeddings = options.embeddings;
20668
+ if (options?.textIndexes !== void 0) collOpts.textIndexes = options.textIndexes;
20669
+ if (options?.warmIndexOnOpen !== void 0) collOpts.warmIndexOnOpen = options.warmIndexOnOpen;
20670
+ if (options?.textIndexPersist !== void 0) collOpts.textIndexPersist = options.textIndexPersist;
19747
20671
  if (options?.moneyFields !== void 0) collOpts.moneyFields = options.moneyFields;
19748
20672
  if (options?.computed !== void 0) collOpts.computed = options.computed;
19749
20673
  if (options?.dictKeyFields !== void 0) {
@@ -19756,6 +20680,7 @@ var init_vault = __esm({
19756
20680
  const handle = this.dictionary(dictName);
19757
20681
  return handle.resolveLabel(key, locale, fallback);
19758
20682
  };
20683
+ collOpts.getDictionary = async (name) => this.dictionary(name);
19759
20684
  collOpts.dictKeyFields = options.dictKeyFields;
19760
20685
  }
19761
20686
  if (options?.i18nFields !== void 0 || options?.dictKeyFields !== void 0) {
@@ -19769,6 +20694,10 @@ var init_vault = __esm({
19769
20694
  }
19770
20695
  coll = new Collection(collOpts);
19771
20696
  this.collectionCache.set(collectionName, coll);
20697
+ if (options?.warmIndexOnOpen === true && options.prefetch !== false) {
20698
+ void coll.warmIndex().catch(() => {
20699
+ });
20700
+ }
19772
20701
  if (options?.persistJsonSchema === true && options.schema !== void 0 && (options.schemaUpdate?.length ?? 0) === 0) {
19773
20702
  const validator = options.schema;
19774
20703
  const work = (async () => {
@@ -19878,6 +20807,16 @@ var init_vault = __esm({
19878
20807
  this.#fenceWatcher = void 0;
19879
20808
  this.#fenceCoordinationStarted = false;
19880
20809
  }
20810
+ /** @internal #308 L1.5 — best-effort flush of all open collections' persisted
20811
+ * lexical indexes on close(). Called fire-and-forget from noydb.close().
20812
+ * Correctness is backstopped by the fingerprint: a missed flush → rebuild on
20813
+ * next load. Only collections with textIndexPersist have a flush(); others no-op. */
20814
+ async _flushSearchIndexes() {
20815
+ for (const coll of this.collectionCache.values()) {
20816
+ await coll.flushIndex().catch(() => {
20817
+ });
20818
+ }
20819
+ }
19881
20820
  /** @internal Drive one heartbeat + watch cycle deterministically (tests). */
19882
20821
  async _fenceTick() {
19883
20822
  this._ensureFenceCoordination();
@@ -20952,6 +21891,11 @@ var init_vault = __esm({
20952
21891
  const idxPurge = await coll._purgePersistedIndexes(ref2.id);
20953
21892
  indexPostingsPurged += idxPurge.purged;
20954
21893
  for (const field of idxPurge.residue) indexResidue.push(`${ref2.collection}:${ref2.id}:${field}`);
21894
+ try {
21895
+ await coll._purgeVector(ref2.id);
21896
+ } catch {
21897
+ indexResidue.push(`${ref2.collection}:${ref2.id}:_vec`);
21898
+ }
20955
21899
  if (blobsEnabled) {
20956
21900
  const r = await this.collection(ref2.collection).blob(ref2.id).shredAllForRecord();
20957
21901
  blobsShredded += r.shredded.length;
@@ -20966,6 +21910,13 @@ var init_vault = __esm({
20966
21910
  }
20967
21911
  await this._removeSubjectRef(subjectId, ref2);
20968
21912
  }
21913
+ for (const collName of collections) {
21914
+ try {
21915
+ await this.collection(collName)._purgeSearchIndex();
21916
+ } catch {
21917
+ indexResidue.push(`${collName}:_ftindex`);
21918
+ }
21919
+ }
20969
21920
  const subjectHash = await sha256Hex3(subjectId);
20970
21921
  const ledger = this.getLedgerOrNull();
20971
21922
  if (!ledger) {
@@ -24841,6 +25792,7 @@ var init_noydb = __esm({
24841
25792
  }
24842
25793
  this.syncEngines.clear();
24843
25794
  for (const v of this.vaultCache.values()) v._stopFenceCoordination();
25795
+ for (const v of this.vaultCache.values()) void v._flushSearchIndexes();
24844
25796
  this.disableTabCoordination();
24845
25797
  this.keyringCache.clear();
24846
25798
  this.vaultCache.clear();
@@ -25992,6 +26944,8 @@ __export(src_exports, {
25992
26944
  ELEVATION_AUDIT_COLLECTION: () => ELEVATION_AUDIT_COLLECTION,
25993
26945
  ElevatedHandle: () => ElevatedHandle,
25994
26946
  ElevationExpiredError: () => ElevationExpiredError,
26947
+ EmbeddingDimMismatchError: () => EmbeddingDimMismatchError,
26948
+ EmbeddingModelMismatchError: () => EmbeddingModelMismatchError,
25995
26949
  ExportCapabilityError: () => ExportCapabilityError,
25996
26950
  FieldFrozenError: () => FieldFrozenError,
25997
26951
  FilenameSanitizationError: () => FilenameSanitizationError,
@@ -26201,6 +27155,7 @@ __export(src_exports, {
26201
27155
  exportAccessibleData: () => exportAccessibleData,
26202
27156
  findAuthenticator: () => findAuthenticator,
26203
27157
  formatDiff: () => formatDiff,
27158
+ fuseRetrieval: () => fuseRetrieval,
26204
27159
  generateULID: () => generateULID,
26205
27160
  getCredential: () => getCredential,
26206
27161
  groupAndReduce: () => groupAndReduce,
@@ -27049,7 +28004,7 @@ var BlobSet = class {
27049
28004
  ...backlink.token ? { backlink: backlink.token } : {},
27050
28005
  ...prevMeta ? { meta: prevMeta } : {}
27051
28006
  },
27052
- filename: slotName,
28007
+ filename: opts?.filename ?? slotName,
27053
28008
  size: data.byteLength,
27054
28009
  mimeType: contentType,
27055
28010
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -27121,7 +28076,7 @@ var BlobSet = class {
27121
28076
  const oldETag = slots[slotName]?.eTag;
27122
28077
  slots[slotName] = {
27123
28078
  eTag,
27124
- filename: slotName,
28079
+ filename: opts?.filename ?? slotName,
27125
28080
  size: data.byteLength,
27126
28081
  ...mimeType !== void 0 ? { mimeType } : {},
27127
28082
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -30559,6 +31514,8 @@ init_crypto();
30559
31514
  init_crypto();
30560
31515
  init_errors();
30561
31516
  init_errors();
31517
+ init_fuse();
31518
+ init_errors();
30562
31519
  init_errors();
30563
31520
  init_tiers();
30564
31521
  init_delegation();
@@ -30838,6 +31795,8 @@ init_search();
30838
31795
  ELEVATION_AUDIT_COLLECTION,
30839
31796
  ElevatedHandle,
30840
31797
  ElevationExpiredError,
31798
+ EmbeddingDimMismatchError,
31799
+ EmbeddingModelMismatchError,
30841
31800
  ExportCapabilityError,
30842
31801
  FieldFrozenError,
30843
31802
  FilenameSanitizationError,
@@ -31047,6 +32006,7 @@ init_search();
31047
32006
  exportAccessibleData,
31048
32007
  findAuthenticator,
31049
32008
  formatDiff,
32009
+ fuseRetrieval,
31050
32010
  generateULID,
31051
32011
  getCredential,
31052
32012
  groupAndReduce,