@noy-db/hub 0.7.0 → 0.8.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. package/CHANGELOG.md +105 -14
  2. package/LICENSE +202 -21
  3. package/NOTICE +1 -0
  4. package/README.md +27 -10
  5. package/codemods/0.8.0-pre.json +61 -0
  6. package/dist/api-GVYEKSJE.js +19 -0
  7. package/dist/as/index.js +11 -11
  8. package/dist/at/index.js +9 -9
  9. package/dist/attestation/index.js +20 -20
  10. package/dist/{backup-IJTB4S4M.js → backup-7TFRVFLH.js} +21 -15
  11. package/dist/backup-7TFRVFLH.js.map +1 -0
  12. package/dist/blobs/index.js +13 -13
  13. package/dist/broker/index.js +12 -12
  14. package/dist/by/index.js +2 -2
  15. package/dist/cargo/index.js +39 -36
  16. package/dist/{chunk-7O3Y4PPD.js → chunk-244VXYPG.js} +140 -16
  17. package/dist/chunk-244VXYPG.js.map +1 -0
  18. package/dist/{chunk-BUE2D7PX.js → chunk-32YV3TJT.js} +2 -2
  19. package/dist/{chunk-3RCJJBNR.js → chunk-3ELRMVJK.js} +12 -12
  20. package/dist/{chunk-6GMZ7HEE.js → chunk-3F7GLNAE.js} +6 -6
  21. package/dist/{chunk-2Y4IMKA6.js → chunk-3H5KLDZN.js} +4 -4
  22. package/dist/{chunk-VTFVLCUH.js → chunk-3JWHAR6E.js} +2 -2
  23. package/dist/{chunk-YMUFFJCO.js → chunk-3TDUWVWB.js} +5 -2
  24. package/dist/chunk-3TDUWVWB.js.map +1 -0
  25. package/dist/{chunk-JBDFMYKQ.js → chunk-4AF3TUMP.js} +2 -2
  26. package/dist/{chunk-ZORTV6NH.js → chunk-4I522ERM.js} +88 -4
  27. package/dist/chunk-4I522ERM.js.map +1 -0
  28. package/dist/{chunk-MUM7IANK.js → chunk-4MXI3ODD.js} +4 -4
  29. package/dist/chunk-4MXI3ODD.js.map +1 -0
  30. package/dist/{chunk-BLN54W3L.js → chunk-5FDLC6G7.js} +56 -3
  31. package/dist/chunk-5FDLC6G7.js.map +1 -0
  32. package/dist/chunk-5O7D6ZTW.js +53 -0
  33. package/dist/chunk-5O7D6ZTW.js.map +1 -0
  34. package/dist/{chunk-J6FXAEUG.js → chunk-6B3VNR4P.js} +12 -12
  35. package/dist/{chunk-TUFM4UZP.js → chunk-6K7DPM7D.js} +2 -2
  36. package/dist/{chunk-K6LHRFBL.js → chunk-6LMQ5R26.js} +7 -7
  37. package/dist/{chunk-SPXXX5E4.js → chunk-6LNL42F5.js} +94 -32
  38. package/dist/chunk-6LNL42F5.js.map +1 -0
  39. package/dist/{chunk-XLMEZIAJ.js → chunk-6OWXYZK2.js} +2 -2
  40. package/dist/{chunk-BOWNCWZT.js → chunk-6QSQQLSE.js} +3 -3
  41. package/dist/chunk-7JE7BDYJ.js +1558 -0
  42. package/dist/chunk-7JE7BDYJ.js.map +1 -0
  43. package/dist/{chunk-KG7TZKZG.js → chunk-7VCXZDA4.js} +5 -5
  44. package/dist/chunk-7VCXZDA4.js.map +1 -0
  45. package/dist/{chunk-NQKIUNW5.js → chunk-A6IJU4TK.js} +2 -2
  46. package/dist/{chunk-BM5TWITZ.js → chunk-ANWPSTZU.js} +38 -9
  47. package/dist/chunk-ANWPSTZU.js.map +1 -0
  48. package/dist/{chunk-QIZPZMUI.js → chunk-AOWGXU6D.js} +2 -2
  49. package/dist/{chunk-CUZLNGD5.js → chunk-B2YY6WDD.js} +1 -1
  50. package/dist/chunk-B2YY6WDD.js.map +1 -0
  51. package/dist/{chunk-SFAWCTEM.js → chunk-B57AFBY2.js} +2 -2
  52. package/dist/{chunk-GPEQUXHL.js → chunk-B6SJIBQK.js} +4 -4
  53. package/dist/chunk-BJ2IXQ5Q.js +100 -0
  54. package/dist/chunk-BJ2IXQ5Q.js.map +1 -0
  55. package/dist/{chunk-Q2PU57HC.js → chunk-BK2HHQGN.js} +2 -2
  56. package/dist/chunk-BKT776R5.js +1 -0
  57. package/dist/{chunk-KUX3OB6D.js → chunk-BP6DARYA.js} +33 -5
  58. package/dist/chunk-BP6DARYA.js.map +1 -0
  59. package/dist/{chunk-FXBIP2WD.js → chunk-BUDAGWL5.js} +6 -6
  60. package/dist/chunk-CF5UU4S7.js +757 -0
  61. package/dist/chunk-CF5UU4S7.js.map +1 -0
  62. package/dist/{chunk-BOET4NA4.js → chunk-CKNGS5MH.js} +3 -3
  63. package/dist/chunk-CY2CYVWZ.js +41 -0
  64. package/dist/chunk-CY2CYVWZ.js.map +1 -0
  65. package/dist/{chunk-2577DKXB.js → chunk-DC5QVPV7.js} +2 -2
  66. package/dist/chunk-DC5QVPV7.js.map +1 -0
  67. package/dist/{chunk-YSRUYAVU.js → chunk-DE4DH2RZ.js} +2 -2
  68. package/dist/{chunk-6I2RQCET.js → chunk-DF73H4UN.js} +4 -4
  69. package/dist/{chunk-4GVM6QZA.js → chunk-ENAG3IY7.js} +2 -2
  70. package/dist/chunk-ENAG3IY7.js.map +1 -0
  71. package/dist/{chunk-K7NTTA6P.js → chunk-EOVMT6TB.js} +2 -2
  72. package/dist/chunk-F24ZZTHQ.js +193 -0
  73. package/dist/chunk-F24ZZTHQ.js.map +1 -0
  74. package/dist/chunk-F2TDU7MQ.js +456 -0
  75. package/dist/chunk-F2TDU7MQ.js.map +1 -0
  76. package/dist/chunk-F6NCB7KT.js +13 -0
  77. package/dist/chunk-F6NCB7KT.js.map +1 -0
  78. package/dist/{chunk-SPYWXKJN.js → chunk-F7XGHL5O.js} +3 -3
  79. package/dist/chunk-F7XGHL5O.js.map +1 -0
  80. package/dist/{chunk-XTXOCYOJ.js → chunk-FCKWQE2H.js} +5 -5
  81. package/dist/{chunk-U4FOQDY4.js → chunk-FH2L2E34.js} +4 -4
  82. package/dist/chunk-FH2L2E34.js.map +1 -0
  83. package/dist/{chunk-4OZNXTO4.js → chunk-FN5EBVTQ.js} +2 -2
  84. package/dist/chunk-FQ54DWUQ.js +270 -0
  85. package/dist/chunk-FQ54DWUQ.js.map +1 -0
  86. package/dist/{chunk-NKHRDYOR.js → chunk-FQ5VRHIB.js} +4 -4
  87. package/dist/{chunk-FAHMLERK.js → chunk-FW22ZCXT.js} +2 -2
  88. package/dist/chunk-FXQBGFOX.js +524 -0
  89. package/dist/chunk-FXQBGFOX.js.map +1 -0
  90. package/dist/{chunk-AO42KJO6.js → chunk-GF5BZ7D4.js} +45 -9
  91. package/dist/chunk-GF5BZ7D4.js.map +1 -0
  92. package/dist/{chunk-TRGTKX5E.js → chunk-GHLTDZRS.js} +5 -3
  93. package/dist/{chunk-TRGTKX5E.js.map → chunk-GHLTDZRS.js.map} +1 -1
  94. package/dist/{chunk-5WDXHNSW.js → chunk-HBPPGWUM.js} +5 -5
  95. package/dist/chunk-HBPPGWUM.js.map +1 -0
  96. package/dist/{chunk-KTFRCC5C.js → chunk-HBRLNOHL.js} +82 -8
  97. package/dist/chunk-HBRLNOHL.js.map +1 -0
  98. package/dist/chunk-HLEK5VAN.js +275 -0
  99. package/dist/chunk-HLEK5VAN.js.map +1 -0
  100. package/dist/{chunk-RMS3NEA3.js → chunk-HT2AHGQI.js} +2 -2
  101. package/dist/{chunk-CHJBLCOG.js → chunk-HVSCEIYL.js} +7 -7
  102. package/dist/{chunk-UXWB3FPF.js → chunk-I3JDRCMW.js} +150 -22
  103. package/dist/chunk-I3JDRCMW.js.map +1 -0
  104. package/dist/{chunk-GY4WYNNG.js → chunk-ID6Z6E66.js} +2 -2
  105. package/dist/{chunk-EYBQEIUY.js → chunk-IEX7NK2K.js} +3 -3
  106. package/dist/{chunk-KUJDV5QH.js → chunk-ISZQJBML.js} +5 -5
  107. package/dist/{chunk-LWBCUYZW.js → chunk-IT22PWKV.js} +2 -2
  108. package/dist/{chunk-EQEYOJBM.js → chunk-IUWCVHQ7.js} +3 -3
  109. package/dist/chunk-IUWCVHQ7.js.map +1 -0
  110. package/dist/{chunk-7V4TP3AF.js → chunk-J6UOHJY5.js} +4 -4
  111. package/dist/{chunk-JMGDHKQF.js → chunk-JCN44NCY.js} +2 -2
  112. package/dist/{chunk-CARABLSQ.js → chunk-K6W7BVZ6.js} +3 -3
  113. package/dist/{chunk-77K4PG6P.js → chunk-KJFW62P4.js} +29 -11
  114. package/dist/chunk-KJFW62P4.js.map +1 -0
  115. package/dist/{chunk-453F654R.js → chunk-L7DOS3TE.js} +2 -2
  116. package/dist/chunk-LGNDFRYC.js +23 -0
  117. package/dist/chunk-LGNDFRYC.js.map +1 -0
  118. package/dist/{chunk-WEQEYLCS.js → chunk-LGRLME4M.js} +7 -7
  119. package/dist/{chunk-RMF67KCG.js → chunk-LQ4ZHOKP.js} +2 -2
  120. package/dist/{chunk-ZVO4QVPD.js → chunk-M522UYZ2.js} +5 -5
  121. package/dist/{chunk-G56KBWFY.js → chunk-M7NI3IWE.js} +45 -12
  122. package/dist/chunk-M7NI3IWE.js.map +1 -0
  123. package/dist/chunk-MDWKM2XC.js +293 -0
  124. package/dist/chunk-MDWKM2XC.js.map +1 -0
  125. package/dist/chunk-MKXXMNJH.js +204 -0
  126. package/dist/chunk-MKXXMNJH.js.map +1 -0
  127. package/dist/{chunk-SKGMN35F.js → chunk-MLPHLJIQ.js} +3 -3
  128. package/dist/chunk-MLPHLJIQ.js.map +1 -0
  129. package/dist/{chunk-2N4GY74U.js → chunk-MTL7MXGR.js} +6 -6
  130. package/dist/{chunk-TFR7DSOV.js → chunk-MVZ2TPVP.js} +2 -2
  131. package/dist/{chunk-CPWQB3N5.js → chunk-N5DNADLQ.js} +7 -7
  132. package/dist/{chunk-ELNXJMGB.js → chunk-NNARWO72.js} +6 -6
  133. package/dist/{chunk-PT43Y56J.js → chunk-NRT6QZQB.js} +102 -16
  134. package/dist/chunk-NRT6QZQB.js.map +1 -0
  135. package/dist/{chunk-QIBVIOXO.js → chunk-NWHBJQAL.js} +99 -8
  136. package/dist/chunk-NWHBJQAL.js.map +1 -0
  137. package/dist/chunk-NYMLINRP.js +28 -0
  138. package/dist/chunk-NYMLINRP.js.map +1 -0
  139. package/dist/{chunk-7MG7SJT7.js → chunk-ODVPTDPK.js} +1 -1
  140. package/dist/chunk-ODVPTDPK.js.map +1 -0
  141. package/dist/chunk-ORDURZBU.js +461 -0
  142. package/dist/chunk-ORDURZBU.js.map +1 -0
  143. package/dist/{chunk-6YXCPL4T.js → chunk-PDCG6PR5.js} +2 -2
  144. package/dist/{chunk-REDOOY2Q.js → chunk-PSIV7CJV.js} +2 -2
  145. package/dist/{chunk-NA2NIJZI.js → chunk-QBBUZ3I3.js} +126 -19
  146. package/dist/chunk-QBBUZ3I3.js.map +1 -0
  147. package/dist/{chunk-5VCRVKOZ.js → chunk-QOOUUR4A.js} +6 -4
  148. package/dist/{chunk-5VCRVKOZ.js.map → chunk-QOOUUR4A.js.map} +1 -1
  149. package/dist/{chunk-ANATMFIO.js → chunk-QWFHIOD2.js} +5 -5
  150. package/dist/{chunk-X2DLENDQ.js → chunk-QWGU66MP.js} +3 -3
  151. package/dist/chunk-RHVMZSUU.js +7 -0
  152. package/dist/chunk-RHVMZSUU.js.map +1 -0
  153. package/dist/{chunk-BSFNRLK2.js → chunk-S57HTZ6X.js} +5 -5
  154. package/dist/{chunk-SZJ3DLZA.js → chunk-SEE332EV.js} +2 -2
  155. package/dist/{chunk-YYP7WSEB.js → chunk-SI3V7D4G.js} +2 -2
  156. package/dist/{chunk-UGTBXF5U.js → chunk-SOIQ4MM4.js} +3 -3
  157. package/dist/chunk-SUZKW6UR.js +25 -0
  158. package/dist/chunk-SUZKW6UR.js.map +1 -0
  159. package/dist/{chunk-VXGSWL6L.js → chunk-SYVZW77S.js} +6 -6
  160. package/dist/{chunk-6GOE5PGN.js → chunk-T2LBQ5DV.js} +883 -227
  161. package/dist/chunk-T2LBQ5DV.js.map +1 -0
  162. package/dist/chunk-T52GX4SA.js +215 -0
  163. package/dist/chunk-T52GX4SA.js.map +1 -0
  164. package/dist/{chunk-MVMXZYXT.js → chunk-TKUOEU2F.js} +2 -2
  165. package/dist/chunk-TOPYQ6GA.js +31 -0
  166. package/dist/chunk-TOPYQ6GA.js.map +1 -0
  167. package/dist/{chunk-SMH6SRX7.js → chunk-TROR3ALR.js} +2 -2
  168. package/dist/{chunk-2C3AQB46.js → chunk-UD5EVGZ7.js} +42 -389
  169. package/dist/chunk-UD5EVGZ7.js.map +1 -0
  170. package/dist/{chunk-KJIMGIWO.js → chunk-UPD5NWI5.js} +65 -17
  171. package/dist/chunk-UPD5NWI5.js.map +1 -0
  172. package/dist/{chunk-SL3JAAKN.js → chunk-UYB234ZR.js} +30 -2
  173. package/dist/chunk-UYB234ZR.js.map +1 -0
  174. package/dist/chunk-VHM7HCKB.js +220 -0
  175. package/dist/chunk-VHM7HCKB.js.map +1 -0
  176. package/dist/{chunk-DGOZ4UZD.js → chunk-VNNRUGMM.js} +2 -2
  177. package/dist/{chunk-HDOU6I2Y.js → chunk-VNPEWFPD.js} +4 -4
  178. package/dist/{chunk-L7CIOOBW.js → chunk-WNJ4AVGE.js} +2 -2
  179. package/dist/{chunk-FMZY5Q6L.js → chunk-WX5ADGTZ.js} +3 -3
  180. package/dist/{chunk-VXANTWBJ.js → chunk-WY2XXTET.js} +92 -6
  181. package/dist/{chunk-VXANTWBJ.js.map → chunk-WY2XXTET.js.map} +1 -1
  182. package/dist/{chunk-6X6SEMEE.js → chunk-X25NWUZB.js} +33 -8
  183. package/dist/chunk-X25NWUZB.js.map +1 -0
  184. package/dist/{chunk-Q7HZX3IF.js → chunk-X4773RBR.js} +2 -2
  185. package/dist/chunk-XBKH4FOC.js +195 -0
  186. package/dist/chunk-XBKH4FOC.js.map +1 -0
  187. package/dist/{chunk-ANSIZYEG.js → chunk-YNIUIERI.js} +3 -3
  188. package/dist/chunk-YSK2CU2Q.js +936 -0
  189. package/dist/chunk-YSK2CU2Q.js.map +1 -0
  190. package/dist/{chunk-UXVWEX5L.js → chunk-Z5HTYMMQ.js} +6 -2
  191. package/dist/chunk-Z5HTYMMQ.js.map +1 -0
  192. package/dist/{chunk-RRNRNANG.js → chunk-ZE4CHIED.js} +66 -75
  193. package/dist/chunk-ZE4CHIED.js.map +1 -0
  194. package/dist/chunk-ZSX4S5XB.js +1289 -0
  195. package/dist/chunk-ZSX4S5XB.js.map +1 -0
  196. package/dist/{chunk-BZ3534YM.js → chunk-ZUVBC32X.js} +2 -2
  197. package/dist/{chunk-L742JPKZ.js → chunk-ZXABPVM6.js} +6 -6
  198. package/dist/classified/index.js +5 -5
  199. package/dist/{classified-marker-LI2SF2E4.js → classified-marker-W3USLL5M.js} +3 -3
  200. package/dist/collection-facade-QU6IJBN3.js +48 -0
  201. package/dist/{computed-VPOKQK4N.js → computed-TPFBX7U4.js} +3 -3
  202. package/dist/consent/index.js +9 -9
  203. package/dist/cover/index.js +10 -10
  204. package/dist/coverage/index.js +306 -0
  205. package/dist/coverage/index.js.map +1 -0
  206. package/dist/custody/index.js +12 -12
  207. package/dist/{dead-filter-TSWZQRR5.js → dead-filter-U2UYKSZL.js} +2 -2
  208. package/dist/debug/index.js +1 -1
  209. package/dist/{delegation-OVIFFPG4.js → delegation-S3AEPW2T.js} +11 -11
  210. package/dist/derivations/index.js +25 -22
  211. package/dist/derive-OX7F6TGG.js +21 -0
  212. package/dist/directory/index.js +10 -10
  213. package/dist/{dispatch-WC6X2M6C.js → dispatch-3CQDJV5Q.js} +5 -5
  214. package/dist/{dispatch-S73TK3IY.js → dispatch-RH4LHKBH.js} +21 -21
  215. package/dist/{enclave-KJOTOH7X.js → enclave-27SMF6GF.js} +15 -9
  216. package/dist/executor-B6SRO2QS.js +36 -0
  217. package/dist/executor-BI5CHWRY.js +8 -0
  218. package/dist/executor-RBKM5W5K.js +8 -0
  219. package/dist/export-accessible-VMA3YM5V.js +22 -0
  220. package/dist/extract-partition-NF7PXGPP.js +37 -0
  221. package/dist/{fanout-sidecar-WUFXNYP4.js → fanout-sidecar-OT6RYLOL.js} +9 -9
  222. package/dist/find-LZMP26KF.js +10 -0
  223. package/dist/forget/index.js +9 -9
  224. package/dist/guards/index.js +4 -4
  225. package/dist/history/index.js +13 -13
  226. package/dist/i18n/index.js +14 -14
  227. package/dist/index.d.ts +29 -6
  228. package/dist/index.js +999 -191
  229. package/dist/index.js.map +1 -1
  230. package/dist/indexing/index.js +13 -5
  231. package/dist/indexing/index.js.map +1 -1
  232. package/dist/introspection/index.js +11 -11
  233. package/dist/issue-IHARXWW5.js +18 -0
  234. package/dist/ivf-flat-UZ6DQDLS.js +314 -0
  235. package/dist/ivf-flat-UZ6DQDLS.js.map +1 -0
  236. package/dist/{json-schema-V3M5MUCM.js → json-schema-3SHX72CC.js} +2 -1
  237. package/dist/json-schema-3SHX72CC.js.map +1 -0
  238. package/dist/kernel/collection-config.d.ts +4 -20
  239. package/dist/kernel/collection.d.ts +29 -8
  240. package/dist/kernel/enclave/crypto.d.ts +16 -0
  241. package/dist/kernel/enclave/index.d.ts +1 -1
  242. package/dist/kernel/enclave/record-keys/record-codec.d.ts +25 -0
  243. package/dist/kernel/errors.d.ts +227 -36
  244. package/dist/kernel/generation-map.d.ts +48 -0
  245. package/dist/kernel/memory-store.d.ts +35 -7
  246. package/dist/kernel/noydb.d.ts +6 -1
  247. package/dist/kernel/present-cache.d.ts +58 -0
  248. package/dist/kernel/query/all.d.ts +7 -0
  249. package/dist/kernel/query/builder.d.ts +601 -270
  250. package/dist/kernel/query/civil-date.d.ts +64 -0
  251. package/dist/kernel/query/cursor.d.ts +40 -0
  252. package/dist/kernel/query/distinct-key.d.ts +98 -0
  253. package/dist/kernel/query/hydration.d.ts +76 -0
  254. package/dist/kernel/query/index.d.ts +31 -15
  255. package/dist/kernel/query/internal/core.d.ts +30 -0
  256. package/dist/kernel/query/internal/hooks.d.ts +22 -0
  257. package/dist/kernel/query/internal/maintenance.d.ts +43 -0
  258. package/dist/kernel/query/live/incremental.d.ts +314 -0
  259. package/dist/kernel/query/live/index.d.ts +22 -0
  260. package/dist/kernel/query/live/install.d.ts +2 -0
  261. package/dist/kernel/query/{live.d.ts → live/live.d.ts} +39 -9
  262. package/dist/kernel/query/live/methods.d.ts +107 -0
  263. package/dist/kernel/query/predicate.d.ts +119 -1
  264. package/dist/kernel/query/reduce/date-trunc.d.ts +75 -0
  265. package/dist/kernel/query/reduce/index.d.ts +36 -0
  266. package/dist/kernel/query/reduce/install.d.ts +2 -0
  267. package/dist/kernel/query/reduce/methods.d.ts +259 -0
  268. package/dist/kernel/query/reduce/scan-methods.d.ts +121 -0
  269. package/dist/kernel/query/relate/explain.d.ts +199 -0
  270. package/dist/kernel/query/relate/index.d.ts +48 -0
  271. package/dist/kernel/query/relate/install.d.ts +2 -0
  272. package/dist/kernel/query/relate/join-on.d.ts +126 -0
  273. package/dist/kernel/query/relate/join-reduce.d.ts +16 -0
  274. package/dist/kernel/query/relate/join.d.ts +452 -0
  275. package/dist/kernel/query/relate/methods.d.ts +426 -0
  276. package/dist/kernel/query/relate/partition.d.ts +87 -0
  277. package/dist/kernel/query/relate/scan-methods.d.ts +163 -0
  278. package/dist/kernel/query/relate/traverse.d.ts +109 -0
  279. package/dist/kernel/query/scan-builder.d.ts +79 -176
  280. package/dist/kernel/query/sort-key.d.ts +52 -0
  281. package/dist/kernel/tx-write-gate.d.ts +77 -0
  282. package/dist/kernel/types.d.ts +71 -3
  283. package/dist/kernel/validation.d.ts +27 -10
  284. package/dist/kernel/vault.d.ts +9 -4
  285. package/dist/kernel/via/compose.d.ts +3 -0
  286. package/dist/kernel/via/index.d.ts +56 -0
  287. package/dist/kernel/via/pipeline.d.ts +48 -0
  288. package/dist/{ledger-F33ZVMTK.js → ledger-KZPCMVZY.js} +11 -11
  289. package/dist/liberate-GRLCZMW4.js +24 -0
  290. package/dist/link-set-JCMJ7ULP.js +30 -0
  291. package/dist/{managed-secret-PQYKSR6T.js → managed-secret-S3MQ6SH6.js} +10 -10
  292. package/dist/materialized-views/index.js +30 -23
  293. package/dist/{migrate-cek-5ENH64AA.js → migrate-cek-V7GKJZ7O.js} +2 -2
  294. package/dist/money/index.js +5 -5
  295. package/dist/noydb-SWQJ3MZS.js +97 -0
  296. package/dist/overlay-views/index.js +4 -4
  297. package/dist/periods/index.js +12 -12
  298. package/dist/pod/index.js +75 -68
  299. package/dist/{pod-handle-Q736KYON.js → pod-handle-WGDFB4C2.js} +9 -9
  300. package/dist/policy/index.js +10 -10
  301. package/dist/port/with/blob-strategy.d.ts +9 -0
  302. package/dist/port/with/collection-options.d.ts +5 -0
  303. package/dist/port/with/coverage-strategy.d.ts +83 -0
  304. package/dist/port/with/service-bus.d.ts +46 -0
  305. package/dist/port/with/strategies.d.ts +2 -0
  306. package/dist/portability/index.js +8 -8
  307. package/dist/{post-register-LNE2FE2A.js → post-register-SLSXIPBV.js} +6 -6
  308. package/dist/query/all/index.js +31 -0
  309. package/dist/query/index.js +20 -32
  310. package/dist/query/live/index.js +21 -0
  311. package/dist/query/live/index.js.map +1 -0
  312. package/dist/query/reduce/index.js +33 -0
  313. package/dist/query/reduce/index.js.map +1 -0
  314. package/dist/query/relate/index.js +56 -0
  315. package/dist/query/relate/index.js.map +1 -0
  316. package/dist/reduce/index.js +72 -18
  317. package/dist/reduce/index.js.map +1 -1
  318. package/dist/register-F3OYE7MJ.js +31 -0
  319. package/dist/registry-CILQFXFK.js +8 -0
  320. package/dist/registry-XNNYQVKV.js +8 -0
  321. package/dist/registry-YCDZV3VW.js +35 -0
  322. package/dist/registry-ZGYS33TE.js +24 -0
  323. package/dist/request-withdrawal-Z5NC6TXT.js +30 -0
  324. package/dist/{reveal-67RDQRIN.js → reveal-4BCKPEC2.js} +6 -6
  325. package/dist/revoke-ZL62WC2D.js +23 -0
  326. package/dist/satellites/index.js +1 -1
  327. package/dist/schema-update/index.js +2 -2
  328. package/dist/sealed-record/index.js +12 -12
  329. package/dist/search/index.js +11 -5
  330. package/dist/{seed-G42JYN56.js → seed-4JS2RJ4A.js} +12 -12
  331. package/dist/sequence/index.js +9 -9
  332. package/dist/session/index.js +9 -9
  333. package/dist/shadow/index.js +2 -2
  334. package/dist/signer-MBZZMXTC.js +24 -0
  335. package/dist/snapshots/index.js +10 -10
  336. package/dist/{stale-DDL7WQEZ.js → stale-TJ3DYZMQ.js} +10 -10
  337. package/dist/storage-SVMKRGCW.js +22 -0
  338. package/dist/{store-coordination-provider-MEQ2MJQG.js → store-coordination-provider-2O2VUHKW.js} +10 -10
  339. package/dist/sync/index.js +10 -10
  340. package/dist/team/index.js +17 -15
  341. package/dist/tiers/index.js +13 -11
  342. package/dist/to/index.js +2 -2
  343. package/dist/transactions/index.js +3 -3
  344. package/dist/util/index.js +1 -1
  345. package/dist/vault-head/index.js +8 -8
  346. package/dist/{verify-KOV2G5D6.js → verify-RVT67IMH.js} +5 -5
  347. package/dist/via/blob/index.d.ts +1 -0
  348. package/dist/via/geo/binding.d.ts +31 -0
  349. package/dist/via/geo/descriptor.d.ts +54 -0
  350. package/dist/via/geo/geohash.d.ts +95 -0
  351. package/dist/via/geo/index.d.ts +13 -0
  352. package/dist/via/geo/where.d.ts +50 -0
  353. package/dist/via/i18n/core.d.ts +1 -1
  354. package/dist/via/lookup/registry.d.ts +1 -1
  355. package/dist/via/lookup/snapshot.d.ts +3 -3
  356. package/dist/walk-HJ42EISE.js +21 -0
  357. package/dist/walk-HJ42EISE.js.map +1 -0
  358. package/dist/with-audit/coverage/accounting.d.ts +112 -0
  359. package/dist/with-audit/coverage/active.d.ts +29 -0
  360. package/dist/with-audit/coverage/index.d.ts +61 -0
  361. package/dist/with-audit/coverage/sketch.d.ts +75 -0
  362. package/dist/with-audit/periods/periods.d.ts +55 -7
  363. package/dist/with-audit/periods/reserved-collections.d.ts +3 -0
  364. package/dist/with-audit/periods/vault-facade.d.ts +17 -0
  365. package/dist/with-audit/tiers/index.d.ts +51 -0
  366. package/dist/with-audit/tiers/strategy.d.ts +8 -0
  367. package/dist/with-cargo/floor.d.ts +2 -2
  368. package/dist/with-commit/tx/invariants.d.ts +1 -1
  369. package/dist/with-commit/tx/transaction.d.ts +13 -3
  370. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -3
  371. package/dist/with-formula/materialized-views/emit-memo.d.ts +40 -0
  372. package/dist/with-formula/materialized-views/executor.d.ts +8 -0
  373. package/dist/with-formula/materialized-views/index.d.ts +1 -1
  374. package/dist/with-formula/materialized-views/registry.d.ts +15 -0
  375. package/dist/with-formula/materialized-views/types.d.ts +106 -14
  376. package/dist/with-formula/materialized-views/window-stage.d.ts +11 -0
  377. package/dist/with-formula/overlay-views/types.d.ts +1 -1
  378. package/dist/with-formula/overlay-views/virtual-collection.d.ts +13 -4
  379. package/dist/with-lookup/embeddings/chunks.d.ts +79 -0
  380. package/dist/with-lookup/embeddings/descriptor.d.ts +21 -0
  381. package/dist/with-lookup/embeddings/index.d.ts +3 -0
  382. package/dist/with-lookup/embeddings/ivf-flat.d.ts +93 -0
  383. package/dist/with-lookup/embeddings/vector-index.d.ts +73 -0
  384. package/dist/with-lookup/embeddings/vector-set.d.ts +94 -1
  385. package/dist/with-lookup/embeddings/with-vector-index.d.ts +67 -0
  386. package/dist/with-lookup/indexing/collection-facade.d.ts +85 -2
  387. package/dist/with-lookup/indexing/compound-indexes.d.ts +129 -0
  388. package/dist/with-lookup/indexing/eager-indexes.d.ts +170 -1
  389. package/dist/with-lookup/indexing/index-snapshot.d.ts +62 -0
  390. package/dist/with-lookup/indexing/lazy-builder.d.ts +33 -0
  391. package/dist/with-lookup/indexing/persisted-field-indexes.d.ts +104 -0
  392. package/dist/with-lookup/indexing/persisted-indexes.d.ts +12 -0
  393. package/dist/with-lookup/indexing/sorted-indexes.d.ts +117 -0
  394. package/dist/with-lookup/indexing/unique-constraints.d.ts +106 -23
  395. package/dist/with-lookup/reduce/active.d.ts +2 -24
  396. package/dist/with-lookup/reduce/group-core.d.ts +43 -0
  397. package/dist/with-lookup/reduce/groupby.d.ts +195 -36
  398. package/dist/with-lookup/reduce/incremental-group.d.ts +153 -0
  399. package/dist/with-lookup/reduce/index.d.ts +26 -5
  400. package/dist/with-lookup/reduce/reducers.d.ts +255 -1
  401. package/dist/with-lookup/reduce/reduction.d.ts +44 -13
  402. package/dist/with-lookup/reduce/strategy.d.ts +43 -3
  403. package/dist/with-lookup/reduce/window.d.ts +262 -0
  404. package/dist/with-lookup/search/collection-facade.d.ts +44 -8
  405. package/dist/with-lookup/search/index-store.d.ts +5 -3
  406. package/dist/with-lookup/search/index.d.ts +4 -2
  407. package/dist/with-lookup/search/inverted-index.d.ts +38 -2
  408. package/dist/with-lookup/search/persisted-index-store.d.ts +5 -2
  409. package/dist/with-lookup/search/phrase.d.ts +28 -0
  410. package/dist/with-lookup/search/retrieve-types.d.ts +57 -1
  411. package/dist/with-lookup/search/serialize.d.ts +29 -3
  412. package/dist/with-lookup/search/strategy.d.ts +2 -6
  413. package/dist/with-party/directory/cover/index.d.ts +1 -1
  414. package/dist/with-party/directory/cover/storage.d.ts +1 -1
  415. package/dist/with-party/directory/cover/types.d.ts +1 -1
  416. package/dist/with-party/directory/index.d.ts +1 -1
  417. package/dist/with-party/directory/types.d.ts +1 -1
  418. package/dist/with-party/directory/user-envelope/api.d.ts +1 -1
  419. package/dist/with-party/policy/engine.d.ts +1 -1
  420. package/dist/with-party/policy/index.d.ts +1 -1
  421. package/dist/with-party/policy/presets.d.ts +1 -1
  422. package/dist/with-party/team/authenticators.d.ts +91 -1
  423. package/dist/with-party/team/index.d.ts +3 -2
  424. package/dist/with-party/team/keyring.d.ts +13 -6
  425. package/dist/with-party/team/managed-secret.d.ts +1 -1
  426. package/dist/with-party/team/noydb-facade.d.ts +12 -3
  427. package/dist/with-party/team/wrapped-deks.d.ts +4 -4
  428. package/dist/with-pod/format.d.ts +1 -1
  429. package/dist/with-pod/pod.d.ts +5 -5
  430. package/dist/with-shape/blobs/blob-compaction.d.ts +16 -0
  431. package/dist/with-shape/blobs/blob-set.d.ts +21 -2
  432. package/dist/with-shape/blobs/legacy-sweep.d.ts +35 -0
  433. package/dist/with-shape/introspection/describe.d.ts +6 -0
  434. package/dist/with-shape/introspection/field-meta.d.ts +18 -0
  435. package/dist/with-shape/introspection/types.d.ts +57 -1
  436. package/dist/with-shape/links/vault-facade.d.ts +1 -1
  437. package/dist/with-store/partitioned/index.d.ts +337 -0
  438. package/dist/with-sync/change-broadcast.d.ts +153 -0
  439. package/dist/withdraw-accessible-5NZUPAVA.js +27 -0
  440. package/dist/withdraw-accessible-5NZUPAVA.js.map +1 -0
  441. package/package.json +37 -10
  442. package/dist/api-TXFOVOXX.js +0 -19
  443. package/dist/backup-IJTB4S4M.js.map +0 -1
  444. package/dist/chunk-2577DKXB.js.map +0 -1
  445. package/dist/chunk-2C3AQB46.js.map +0 -1
  446. package/dist/chunk-4GVM6QZA.js.map +0 -1
  447. package/dist/chunk-5WDXHNSW.js.map +0 -1
  448. package/dist/chunk-6GOE5PGN.js.map +0 -1
  449. package/dist/chunk-6X6SEMEE.js.map +0 -1
  450. package/dist/chunk-77K4PG6P.js.map +0 -1
  451. package/dist/chunk-7MG2LHO5.js +0 -1616
  452. package/dist/chunk-7MG2LHO5.js.map +0 -1
  453. package/dist/chunk-7MG7SJT7.js.map +0 -1
  454. package/dist/chunk-7O3Y4PPD.js.map +0 -1
  455. package/dist/chunk-AO42KJO6.js.map +0 -1
  456. package/dist/chunk-ATL3ZVXT.js +0 -151
  457. package/dist/chunk-ATL3ZVXT.js.map +0 -1
  458. package/dist/chunk-BLN54W3L.js.map +0 -1
  459. package/dist/chunk-BM5TWITZ.js.map +0 -1
  460. package/dist/chunk-CUZLNGD5.js.map +0 -1
  461. package/dist/chunk-EQEYOJBM.js.map +0 -1
  462. package/dist/chunk-G56KBWFY.js.map +0 -1
  463. package/dist/chunk-I3ISCYT7.js +0 -159
  464. package/dist/chunk-I3ISCYT7.js.map +0 -1
  465. package/dist/chunk-KG7TZKZG.js.map +0 -1
  466. package/dist/chunk-KJIMGIWO.js.map +0 -1
  467. package/dist/chunk-KTFRCC5C.js.map +0 -1
  468. package/dist/chunk-KUX3OB6D.js.map +0 -1
  469. package/dist/chunk-MUM7IANK.js.map +0 -1
  470. package/dist/chunk-NA2NIJZI.js.map +0 -1
  471. package/dist/chunk-NSITFOCJ.js +0 -99
  472. package/dist/chunk-NSITFOCJ.js.map +0 -1
  473. package/dist/chunk-PT43Y56J.js.map +0 -1
  474. package/dist/chunk-QIBVIOXO.js.map +0 -1
  475. package/dist/chunk-RRNRNANG.js.map +0 -1
  476. package/dist/chunk-RTBJ5IOO.js +0 -87
  477. package/dist/chunk-RTBJ5IOO.js.map +0 -1
  478. package/dist/chunk-SKGMN35F.js.map +0 -1
  479. package/dist/chunk-SL3JAAKN.js.map +0 -1
  480. package/dist/chunk-SPXXX5E4.js.map +0 -1
  481. package/dist/chunk-SPYWXKJN.js.map +0 -1
  482. package/dist/chunk-U4FOQDY4.js.map +0 -1
  483. package/dist/chunk-UXVWEX5L.js.map +0 -1
  484. package/dist/chunk-UXWB3FPF.js.map +0 -1
  485. package/dist/chunk-YMUFFJCO.js.map +0 -1
  486. package/dist/chunk-ZN4FD4PE.js +0 -364
  487. package/dist/chunk-ZN4FD4PE.js.map +0 -1
  488. package/dist/chunk-ZORTV6NH.js.map +0 -1
  489. package/dist/collection-facade-4GRREZ6C.js +0 -45
  490. package/dist/derive-6O5SWQKN.js +0 -21
  491. package/dist/executor-5NIMLSKZ.js +0 -8
  492. package/dist/executor-AQVXV5GZ.js +0 -8
  493. package/dist/executor-PUAO6AKJ.js +0 -29
  494. package/dist/export-accessible-72EQNBMR.js +0 -22
  495. package/dist/extract-partition-PUYNU3UF.js +0 -37
  496. package/dist/find-2ABFCZX4.js +0 -10
  497. package/dist/issue-SIDORTSZ.js +0 -18
  498. package/dist/json-schema-V3M5MUCM.js.map +0 -1
  499. package/dist/kernel/query/join.d.ts +0 -232
  500. package/dist/liberate-LCDPNAG2.js +0 -24
  501. package/dist/link-set-FKNWAYKS.js +0 -30
  502. package/dist/noydb-DUXZPKSN.js +0 -90
  503. package/dist/register-I2DZXGAR.js +0 -31
  504. package/dist/registry-23WF3TGH.js +0 -8
  505. package/dist/registry-4AYVUNXK.js +0 -8
  506. package/dist/registry-VSSQPIGF.js +0 -18
  507. package/dist/registry-YLEWMGAC.js +0 -32
  508. package/dist/request-withdrawal-KFQHEZ25.js +0 -30
  509. package/dist/revoke-DQDZAZZM.js +0 -23
  510. package/dist/signer-WAMDZHEN.js +0 -24
  511. package/dist/storage-FLR73HHF.js +0 -22
  512. package/dist/walk-3UQBRMDV.js +0 -21
  513. package/dist/withdraw-accessible-EL5GXZBS.js +0 -27
  514. /package/dist/{api-TXFOVOXX.js.map → api-GVYEKSJE.js.map} +0 -0
  515. /package/dist/{chunk-BUE2D7PX.js.map → chunk-32YV3TJT.js.map} +0 -0
  516. /package/dist/{chunk-3RCJJBNR.js.map → chunk-3ELRMVJK.js.map} +0 -0
  517. /package/dist/{chunk-6GMZ7HEE.js.map → chunk-3F7GLNAE.js.map} +0 -0
  518. /package/dist/{chunk-2Y4IMKA6.js.map → chunk-3H5KLDZN.js.map} +0 -0
  519. /package/dist/{chunk-VTFVLCUH.js.map → chunk-3JWHAR6E.js.map} +0 -0
  520. /package/dist/{chunk-JBDFMYKQ.js.map → chunk-4AF3TUMP.js.map} +0 -0
  521. /package/dist/{chunk-J6FXAEUG.js.map → chunk-6B3VNR4P.js.map} +0 -0
  522. /package/dist/{chunk-TUFM4UZP.js.map → chunk-6K7DPM7D.js.map} +0 -0
  523. /package/dist/{chunk-K6LHRFBL.js.map → chunk-6LMQ5R26.js.map} +0 -0
  524. /package/dist/{chunk-XLMEZIAJ.js.map → chunk-6OWXYZK2.js.map} +0 -0
  525. /package/dist/{chunk-BOWNCWZT.js.map → chunk-6QSQQLSE.js.map} +0 -0
  526. /package/dist/{chunk-NQKIUNW5.js.map → chunk-A6IJU4TK.js.map} +0 -0
  527. /package/dist/{chunk-QIZPZMUI.js.map → chunk-AOWGXU6D.js.map} +0 -0
  528. /package/dist/{chunk-SFAWCTEM.js.map → chunk-B57AFBY2.js.map} +0 -0
  529. /package/dist/{chunk-GPEQUXHL.js.map → chunk-B6SJIBQK.js.map} +0 -0
  530. /package/dist/{chunk-Q2PU57HC.js.map → chunk-BK2HHQGN.js.map} +0 -0
  531. /package/dist/{collection-facade-4GRREZ6C.js.map → chunk-BKT776R5.js.map} +0 -0
  532. /package/dist/{chunk-FXBIP2WD.js.map → chunk-BUDAGWL5.js.map} +0 -0
  533. /package/dist/{chunk-BOET4NA4.js.map → chunk-CKNGS5MH.js.map} +0 -0
  534. /package/dist/{chunk-YSRUYAVU.js.map → chunk-DE4DH2RZ.js.map} +0 -0
  535. /package/dist/{chunk-6I2RQCET.js.map → chunk-DF73H4UN.js.map} +0 -0
  536. /package/dist/{chunk-K7NTTA6P.js.map → chunk-EOVMT6TB.js.map} +0 -0
  537. /package/dist/{chunk-XTXOCYOJ.js.map → chunk-FCKWQE2H.js.map} +0 -0
  538. /package/dist/{chunk-4OZNXTO4.js.map → chunk-FN5EBVTQ.js.map} +0 -0
  539. /package/dist/{chunk-NKHRDYOR.js.map → chunk-FQ5VRHIB.js.map} +0 -0
  540. /package/dist/{chunk-FAHMLERK.js.map → chunk-FW22ZCXT.js.map} +0 -0
  541. /package/dist/{chunk-RMS3NEA3.js.map → chunk-HT2AHGQI.js.map} +0 -0
  542. /package/dist/{chunk-CHJBLCOG.js.map → chunk-HVSCEIYL.js.map} +0 -0
  543. /package/dist/{chunk-GY4WYNNG.js.map → chunk-ID6Z6E66.js.map} +0 -0
  544. /package/dist/{chunk-EYBQEIUY.js.map → chunk-IEX7NK2K.js.map} +0 -0
  545. /package/dist/{chunk-KUJDV5QH.js.map → chunk-ISZQJBML.js.map} +0 -0
  546. /package/dist/{chunk-LWBCUYZW.js.map → chunk-IT22PWKV.js.map} +0 -0
  547. /package/dist/{chunk-7V4TP3AF.js.map → chunk-J6UOHJY5.js.map} +0 -0
  548. /package/dist/{chunk-JMGDHKQF.js.map → chunk-JCN44NCY.js.map} +0 -0
  549. /package/dist/{chunk-CARABLSQ.js.map → chunk-K6W7BVZ6.js.map} +0 -0
  550. /package/dist/{chunk-453F654R.js.map → chunk-L7DOS3TE.js.map} +0 -0
  551. /package/dist/{chunk-WEQEYLCS.js.map → chunk-LGRLME4M.js.map} +0 -0
  552. /package/dist/{chunk-RMF67KCG.js.map → chunk-LQ4ZHOKP.js.map} +0 -0
  553. /package/dist/{chunk-ZVO4QVPD.js.map → chunk-M522UYZ2.js.map} +0 -0
  554. /package/dist/{chunk-2N4GY74U.js.map → chunk-MTL7MXGR.js.map} +0 -0
  555. /package/dist/{chunk-TFR7DSOV.js.map → chunk-MVZ2TPVP.js.map} +0 -0
  556. /package/dist/{chunk-CPWQB3N5.js.map → chunk-N5DNADLQ.js.map} +0 -0
  557. /package/dist/{chunk-ELNXJMGB.js.map → chunk-NNARWO72.js.map} +0 -0
  558. /package/dist/{chunk-6YXCPL4T.js.map → chunk-PDCG6PR5.js.map} +0 -0
  559. /package/dist/{chunk-REDOOY2Q.js.map → chunk-PSIV7CJV.js.map} +0 -0
  560. /package/dist/{chunk-ANATMFIO.js.map → chunk-QWFHIOD2.js.map} +0 -0
  561. /package/dist/{chunk-X2DLENDQ.js.map → chunk-QWGU66MP.js.map} +0 -0
  562. /package/dist/{chunk-BSFNRLK2.js.map → chunk-S57HTZ6X.js.map} +0 -0
  563. /package/dist/{chunk-SZJ3DLZA.js.map → chunk-SEE332EV.js.map} +0 -0
  564. /package/dist/{chunk-YYP7WSEB.js.map → chunk-SI3V7D4G.js.map} +0 -0
  565. /package/dist/{chunk-UGTBXF5U.js.map → chunk-SOIQ4MM4.js.map} +0 -0
  566. /package/dist/{chunk-VXGSWL6L.js.map → chunk-SYVZW77S.js.map} +0 -0
  567. /package/dist/{chunk-MVMXZYXT.js.map → chunk-TKUOEU2F.js.map} +0 -0
  568. /package/dist/{chunk-SMH6SRX7.js.map → chunk-TROR3ALR.js.map} +0 -0
  569. /package/dist/{chunk-DGOZ4UZD.js.map → chunk-VNNRUGMM.js.map} +0 -0
  570. /package/dist/{chunk-HDOU6I2Y.js.map → chunk-VNPEWFPD.js.map} +0 -0
  571. /package/dist/{chunk-L7CIOOBW.js.map → chunk-WNJ4AVGE.js.map} +0 -0
  572. /package/dist/{chunk-FMZY5Q6L.js.map → chunk-WX5ADGTZ.js.map} +0 -0
  573. /package/dist/{chunk-Q7HZX3IF.js.map → chunk-X4773RBR.js.map} +0 -0
  574. /package/dist/{chunk-ANSIZYEG.js.map → chunk-YNIUIERI.js.map} +0 -0
  575. /package/dist/{chunk-BZ3534YM.js.map → chunk-ZUVBC32X.js.map} +0 -0
  576. /package/dist/{chunk-L742JPKZ.js.map → chunk-ZXABPVM6.js.map} +0 -0
  577. /package/dist/{classified-marker-LI2SF2E4.js.map → classified-marker-W3USLL5M.js.map} +0 -0
  578. /package/dist/{computed-VPOKQK4N.js.map → collection-facade-QU6IJBN3.js.map} +0 -0
  579. /package/dist/{derive-6O5SWQKN.js.map → computed-TPFBX7U4.js.map} +0 -0
  580. /package/dist/{dead-filter-TSWZQRR5.js.map → dead-filter-U2UYKSZL.js.map} +0 -0
  581. /package/dist/{delegation-OVIFFPG4.js.map → delegation-S3AEPW2T.js.map} +0 -0
  582. /package/dist/{enclave-KJOTOH7X.js.map → derive-OX7F6TGG.js.map} +0 -0
  583. /package/dist/{dispatch-WC6X2M6C.js.map → dispatch-3CQDJV5Q.js.map} +0 -0
  584. /package/dist/{dispatch-S73TK3IY.js.map → dispatch-RH4LHKBH.js.map} +0 -0
  585. /package/dist/{executor-5NIMLSKZ.js.map → enclave-27SMF6GF.js.map} +0 -0
  586. /package/dist/{executor-AQVXV5GZ.js.map → executor-B6SRO2QS.js.map} +0 -0
  587. /package/dist/{executor-PUAO6AKJ.js.map → executor-BI5CHWRY.js.map} +0 -0
  588. /package/dist/{export-accessible-72EQNBMR.js.map → executor-RBKM5W5K.js.map} +0 -0
  589. /package/dist/{extract-partition-PUYNU3UF.js.map → export-accessible-VMA3YM5V.js.map} +0 -0
  590. /package/dist/{find-2ABFCZX4.js.map → extract-partition-NF7PXGPP.js.map} +0 -0
  591. /package/dist/{fanout-sidecar-WUFXNYP4.js.map → fanout-sidecar-OT6RYLOL.js.map} +0 -0
  592. /package/dist/{issue-SIDORTSZ.js.map → find-LZMP26KF.js.map} +0 -0
  593. /package/dist/{ledger-F33ZVMTK.js.map → issue-IHARXWW5.js.map} +0 -0
  594. /package/dist/{liberate-LCDPNAG2.js.map → ledger-KZPCMVZY.js.map} +0 -0
  595. /package/dist/{link-set-FKNWAYKS.js.map → liberate-GRLCZMW4.js.map} +0 -0
  596. /package/dist/{managed-secret-PQYKSR6T.js.map → link-set-JCMJ7ULP.js.map} +0 -0
  597. /package/dist/{noydb-DUXZPKSN.js.map → managed-secret-S3MQ6SH6.js.map} +0 -0
  598. /package/dist/{migrate-cek-5ENH64AA.js.map → migrate-cek-V7GKJZ7O.js.map} +0 -0
  599. /package/dist/{register-I2DZXGAR.js.map → noydb-SWQJ3MZS.js.map} +0 -0
  600. /package/dist/{pod-handle-Q736KYON.js.map → pod-handle-WGDFB4C2.js.map} +0 -0
  601. /package/dist/{post-register-LNE2FE2A.js.map → post-register-SLSXIPBV.js.map} +0 -0
  602. /package/dist/{registry-23WF3TGH.js.map → query/all/index.js.map} +0 -0
  603. /package/dist/{registry-4AYVUNXK.js.map → register-F3OYE7MJ.js.map} +0 -0
  604. /package/dist/{registry-VSSQPIGF.js.map → registry-CILQFXFK.js.map} +0 -0
  605. /package/dist/{registry-YLEWMGAC.js.map → registry-XNNYQVKV.js.map} +0 -0
  606. /package/dist/{request-withdrawal-KFQHEZ25.js.map → registry-YCDZV3VW.js.map} +0 -0
  607. /package/dist/{revoke-DQDZAZZM.js.map → registry-ZGYS33TE.js.map} +0 -0
  608. /package/dist/{signer-WAMDZHEN.js.map → request-withdrawal-Z5NC6TXT.js.map} +0 -0
  609. /package/dist/{reveal-67RDQRIN.js.map → reveal-4BCKPEC2.js.map} +0 -0
  610. /package/dist/{stale-DDL7WQEZ.js.map → revoke-ZL62WC2D.js.map} +0 -0
  611. /package/dist/{seed-G42JYN56.js.map → seed-4JS2RJ4A.js.map} +0 -0
  612. /package/dist/{storage-FLR73HHF.js.map → signer-MBZZMXTC.js.map} +0 -0
  613. /package/dist/{walk-3UQBRMDV.js.map → stale-TJ3DYZMQ.js.map} +0 -0
  614. /package/dist/{withdraw-accessible-EL5GXZBS.js.map → storage-SVMKRGCW.js.map} +0 -0
  615. /package/dist/{store-coordination-provider-MEQ2MJQG.js.map → store-coordination-provider-2O2VUHKW.js.map} +0 -0
  616. /package/dist/{verify-KOV2G5D6.js.map → verify-RVT67IMH.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-lookup/indexing/index-snapshot.ts","../src/with-lookup/indexing/sorted-indexes.ts","../src/with-lookup/indexing/compound-indexes.ts","../src/with-lookup/indexing/eager-indexes.ts"],"sourcesContent":["/**\n * The on-disk shape of a persisted field index (#1359) — the format both\n * `SortedIndex` (#1344) and `CompoundIndex` (#1345) round-trip through, plus\n * the structural validator every load must pass.\n *\n * ⭐ **Nothing is flattened into a delimited string.** A compound entry keeps\n * its tuple as an ARRAY of per-component keys, each carrying its runtime KIND\n * alongside its value — which is the whole point of #1345's in-memory shape\n * and would be destroyed by a `join()`. Two properties depend on it:\n *\n * - **Kind survives.** Entries rank by runtime kind FIRST (mirroring\n * `predicate.ts`'s `isComparable`), so a `string` probe must not reach\n * `number` entries. An encoding that wrote only the value would collapse\n * `1` and `'1'` into one key space on the way back in.\n * - **Per-component ordering survives.** A string component may contain any\n * byte, including whatever a separator would have been.\n *\n * The validator is deliberately paranoid and its failure mode is a REBUILD,\n * never a partial load: a blob that is truncated, from a future format, or\n * internally out of order is rejected whole. See\n * {@link parseFieldIndexSnapshot}.\n */\n\n/** Bump on ANY incompatible change to the shapes below. An older stamp is rejected, not migrated. */\nexport const FIELD_INDEX_SNAPSHOT_VERSION = 1\n\n/** One `SortKey`, wire form: `[kind, key]`. `kind` IS the sort rank. */\nexport type WireKey = readonly [kind: number, key: number | string]\n\n/** One `SortedIndex` entry: `[kind, key, seq, id]`. */\nexport type WireSortedEntry = readonly [kind: number, key: number | string, seq: number, id: string]\n\n/** One `CompoundIndex` entry: `[tupleKeys, seq, id]` — the tuple stays an ARRAY. */\nexport type WireCompoundEntry = readonly [keys: readonly WireKey[], seq: number, id: string]\n\nexport interface SortedIndexSnapshot {\n readonly v: number\n readonly t: 'sorted'\n readonly field: string\n readonly nextSeq: number\n readonly entries: readonly WireSortedEntry[]\n}\n\nexport interface CompoundIndexSnapshot {\n readonly v: number\n readonly t: 'compound'\n readonly fields: readonly string[]\n readonly nextSeq: number\n readonly entries: readonly WireCompoundEntry[]\n}\n\nexport type FieldIndexSnapshot = SortedIndexSnapshot | CompoundIndexSnapshot\n\n/**\n * Sidecar key for a single-field sorted index. Field paths are\n * percent-encoded so no field name can collide with the `,` the compound\n * form joins on, nor with the `s:` / `c:` discriminator.\n */\nexport function sortedIndexKey(field: string): string {\n return `s:${encodeURIComponent(field)}`\n}\n\n/** Sidecar key for a compound index over an ordered field tuple. */\nexport function compoundIndexKey(fields: readonly string[]): string {\n return `c:${fields.map(encodeURIComponent).join(',')}`\n}\n\n/** A key is well-formed only if its declared kind matches its value's runtime type. */\nfunction isWireKey(x: unknown): x is WireKey {\n if (!Array.isArray(x) || x.length !== 2) return false\n const [kind, key] = x as [unknown, unknown]\n // 0 = number, 1 = string, 2 = Date-as-epoch-millis. See `sorted-indexes.ts`.\n if (kind === 0 || kind === 2) return typeof key === 'number' && Number.isFinite(key)\n if (kind === 1) return typeof key === 'string'\n return false\n}\n\nfunction isSeq(x: unknown): x is number {\n return typeof x === 'number' && Number.isInteger(x) && x >= 0\n}\n\n/**\n * Decode + validate a persisted snapshot. Returns `null` — meaning \"rebuild\"\n * — for anything that is not exactly the current format: bad JSON (a torn\n * write), a version stamp from another release, a shape mismatch, a\n * malformed key, or entries out of the order the index's binary searches\n * require. A caller must never repair a snapshot; the source of truth is the\n * cache, and rebuilding from it is always available.\n */\nexport function parseFieldIndexSnapshot(json: string): FieldIndexSnapshot | null {\n let raw: unknown\n try {\n raw = JSON.parse(json)\n } catch {\n return null\n }\n if (typeof raw !== 'object' || raw === null) return null\n const o = raw as Record<string, unknown>\n if (o['v'] !== FIELD_INDEX_SNAPSHOT_VERSION) return null\n if (!isSeq(o['nextSeq']) || !Array.isArray(o['entries'])) return null\n const nextSeq = o['nextSeq']\n const entries = o['entries'] as unknown[]\n\n if (o['t'] === 'sorted') {\n if (typeof o['field'] !== 'string') return null\n const out: WireSortedEntry[] = []\n for (const e of entries) {\n if (!Array.isArray(e) || e.length !== 4) return null\n const [kind, key, seq, id] = e as [unknown, unknown, unknown, unknown]\n if (!isWireKey([kind, key])) return null\n if (!isSeq(seq) || seq >= nextSeq || typeof id !== 'string') return null\n out.push([kind as number, key as number | string, seq, id])\n }\n if (!isAscending(out.map(e => [[e[0], e[1]] as WireKey]), out.map(e => e[2]))) return null\n return { v: FIELD_INDEX_SNAPSHOT_VERSION, t: 'sorted', field: o['field'], nextSeq, entries: out }\n }\n\n if (o['t'] === 'compound') {\n const fields = o['fields']\n if (!Array.isArray(fields) || fields.length === 0 || !fields.every(f => typeof f === 'string')) return null\n const out: WireCompoundEntry[] = []\n for (const e of entries) {\n if (!Array.isArray(e) || e.length !== 3) return null\n const [keys, seq, id] = e as [unknown, unknown, unknown]\n if (!Array.isArray(keys) || keys.length !== fields.length || !keys.every(isWireKey)) return null\n if (!isSeq(seq) || seq >= nextSeq || typeof id !== 'string') return null\n out.push([keys as readonly WireKey[], seq, id])\n }\n if (!isAscending(out.map(e => e[0]), out.map(e => e[1]))) return null\n return { v: FIELD_INDEX_SNAPSHOT_VERSION, t: 'compound', fields, nextSeq, entries: out }\n }\n\n return null\n}\n\n/**\n * Every binary search in both index classes assumes `(keys…, seq)` ascending.\n * A blob that is not sorted would not merely be slow — it would answer\n * WRONGLY, so it is rejected rather than re-sorted (re-sorting would launder\n * a corrupt blob into a plausible-looking answer).\n */\nfunction isAscending(keys: ReadonlyArray<readonly WireKey[]>, seqs: readonly number[]): boolean {\n for (let i = 1; i < keys.length; i++) {\n const c = compareWireTuples(keys[i - 1]!, keys[i]!)\n if (c > 0) return false\n if (c === 0 && seqs[i - 1]! >= seqs[i]!) return false\n }\n return true\n}\n\nfunction compareWireTuples(a: readonly WireKey[], b: readonly WireKey[]): number {\n for (let i = 0; i < a.length; i++) {\n const x = a[i]!\n const y = b[i]!\n if (x[0] !== y[0]) return x[0] - y[0]\n if (typeof x[1] === 'number' && typeof y[1] === 'number') {\n if (x[1] !== y[1]) return x[1] - y[1]\n } else if (x[1] !== y[1]) {\n return x[1] < y[1] ? -1 : 1\n }\n }\n return 0\n}\n","/**\n * Sorted (range) secondary indexes — the ordered sibling of the hash\n * index in `eager-indexes.ts` (#1344).\n *\n * A sorted index is an array of `{ kind, key, seq, id }` entries kept in\n * ascending `(kindRank, key, seq)` order. Binary search then answers\n * `<`, `<=`, `>`, `>=`, `between` and `startsWith` as a contiguous slice,\n * and `orderedIds()` walks the array for `orderBy(field).limit(n)`.\n *\n * Three properties are load-bearing, each mirroring the linear scan this\n * replaces (`kernel/query/predicate.ts`):\n *\n * - **Kind-partitioned.** `evaluateFieldClause`'s `isComparable` refuses\n * to order two values of different runtime types, so entries are ranked\n * by kind FIRST. A `string` probe therefore cannot reach `number`\n * entries, exactly as the scan cannot. Values with no order-defined\n * type (booleans, objects, arrays) are not indexed at all.\n * - **Nullish is not indexed**, same as the hash index.\n * - **Ties keep insertion order** (`seq`), which after a `build()` is\n * snapshot order — so an index-served `orderBy(...).limit(n)` returns\n * the same rows the stable scan-and-sort would. An in-place UPDATE\n * reinstates the rank it held rather than appending (#1369): the record\n * cache does not move a re-`put` record, so neither may the index.\n *\n * Keys canonicalise through the SAME per-field closure the hash index\n * uses (`ViaPipeline.canonicalizeIndexKey`), so a Via-covered field's\n * entries live in one key space here too. Range DISPATCH for a\n * Via-covered clause is nevertheless declined by the query builder (a\n * money operand has no ordered stored-form probe) — see\n * `kernel/query/builder.ts`'s `candidateRecords`.\n *\n * PERSISTENCE (#1359) is OPT-IN, via `{ persist: true }` on the declaration.\n * {@link SortedIndex.toSnapshot} / {@link SortedIndex.loadSnapshot} are the\n * whole of this class's part in it — the encrypted sidecar, the freshness\n * stamp and the debounce live in `persisted-field-indexes.ts`. Without the\n * opt-in the index is in memory only and rebuilt on hydrate, as before.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { KIND_STRING, compareKeys, toSortKey, type KeyKind, type SortKey } from '../../kernel/query/sort-key.js'\nimport {\n FIELD_INDEX_SNAPSHOT_VERSION,\n type FieldIndexSnapshot,\n type SortedIndexSnapshot,\n type WireSortedEntry,\n} from './index-snapshot.js'\n\n/** Range operators a sorted index can answer. */\nexport type RangeOperator = '<' | '<=' | '>' | '>=' | 'between' | 'startsWith'\n\n// The ordered-key encoding itself moved to `kernel/query/sort-key.ts` (#1339):\n// #1339's declared joins key on it too, and the kernel spine may not\n// statically import a `with-*` service (`check-architecture.mjs`'s\n// port-layering ratchet). Re-exported here so every existing importer of this\n// module is unchanged, and so there is still exactly ONE definition of what\n// makes two stored values comparable.\nexport { KIND_STRING, compareKeys, toSortKey, type KeyKind, type SortKey } from '../../kernel/query/sort-key.js'\n\ninterface Entry extends SortKey {\n readonly seq: number\n readonly id: string\n}\n\n/** A single field's sorted index. */\nexport class SortedIndex {\n private readonly entries: Entry[] = []\n private nextSeq = 0\n\n constructor(readonly field: string) {}\n\n get size(): number {\n return this.entries.length\n }\n\n clear(): void {\n this.entries.length = 0\n this.nextSeq = 0\n }\n\n /**\n * Insert one record. No-op when the value has no order-defined kind.\n *\n * `seq` REINSTATES a rank a previous entry for this id held — see\n * {@link remove}'s return value and `CollectionIndexes.upsert`. Omit it\n * for a fresh insert, which appends after every existing tie.\n */\n add(id: string, value: unknown, canonicalKey: string | undefined, seq?: number): void {\n const sk = toSortKey(value, canonicalKey)\n if (!sk) return\n const entry: Entry = { ...sk, seq: seq ?? this.nextSeq++, id }\n this.entries.splice(this.insertionPoint(entry), 0, entry)\n }\n\n /**\n * Remove one record, addressed by the value it was indexed under.\n * Returns the rank it held, so an UPDATE can reinstate it (#1369):\n * `sortRecords()` sorts a snapshot whose order does not change when a\n * record is written in place, so a tie-breaking rank that drifted to the\n * back on every `put` would make an index-served page disagree with the\n * scan it must match. Same contract as `CompoundIndex.remove`.\n */\n remove(id: string, value: unknown, canonicalKey: string | undefined): number | undefined {\n const sk = toSortKey(value, canonicalKey)\n if (!sk) return undefined\n // Every entry sharing this key is contiguous; walk that run for the id.\n for (let i = this.lowerBound(sk); i < this.entries.length; i++) {\n const e = this.entries[i]!\n if (compareKeys(e, sk) !== 0) break\n if (e.id === id) {\n this.entries.splice(i, 1)\n return e.seq\n }\n }\n return undefined\n }\n\n /**\n * Ids in ascending (or descending) key order. Ties keep INSERTION order\n * in both directions — `sortRecords()` negates its comparator over a\n * stable sort, which reverses the key order but not the order of equal\n * keys. A plain `.reverse()` here would disagree on ties.\n */\n orderedIds(direction: 'asc' | 'desc'): string[] {\n if (direction === 'asc') return this.entries.map(e => e.id)\n const out: string[] = []\n let end = this.entries.length\n while (end > 0) {\n let start = end - 1\n while (start > 0 && compareKeys(this.entries[start - 1]!, this.entries[end - 1]!) === 0) start--\n for (let i = start; i < end; i++) out.push(this.entries[i]!.id)\n end = start\n }\n return out\n }\n\n /**\n * Ids matching a range clause. Returns an empty set when the probe has\n * no comparable kind — which is what the linear scan would produce too.\n */\n lookup(op: RangeOperator, value: unknown): Set<string> {\n if (op === 'startsWith') return this.prefix(value)\n if (op === 'between') {\n if (!Array.isArray(value) || value.length !== 2) return new Set()\n const lo = toSortKey(value[0], undefined)\n const hi = toSortKey(value[1], undefined)\n if (!lo || !hi || lo.kind !== hi.kind) return new Set()\n return this.slice(this.lowerBound(lo), this.upperBound(hi))\n }\n const probe = toSortKey(value, undefined)\n if (!probe) return new Set()\n const lo = this.lowerBound(probe)\n const hi = this.upperBound(probe)\n // Kind-partitioned: `<`/`>` must stay inside the probe's own kind run.\n const [kindStart, kindEnd] = this.kindBounds(probe.kind)\n switch (op) {\n case '<':\n return this.slice(kindStart, lo)\n case '<=':\n return this.slice(kindStart, hi)\n case '>':\n return this.slice(hi, kindEnd)\n case '>=':\n return this.slice(lo, kindEnd)\n default: {\n const _exhaustive: never = op\n void _exhaustive\n return new Set()\n }\n }\n }\n\n private prefix(value: unknown): Set<string> {\n if (typeof value !== 'string') return new Set()\n const out = new Set<string>()\n const from = this.lowerBound({ kind: KIND_STRING, key: value })\n for (let i = from; i < this.entries.length; i++) {\n const e = this.entries[i]!\n if (e.kind !== KIND_STRING) break\n if (!(e.key as string).startsWith(value)) break\n out.add(e.id)\n }\n return out\n }\n\n private slice(from: number, to: number): Set<string> {\n const out = new Set<string>()\n for (let i = from; i < to; i++) out.add(this.entries[i]!.id)\n return out\n }\n\n /** [start, end) of the run of entries with the given kind — binary, not linear. */\n private kindBounds(kind: KeyKind): [number, number] {\n return [this.kindBoundary(k => k < kind), this.kindBoundary(k => k <= kind)]\n }\n\n private kindBoundary(before: (k: KeyKind) => boolean): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (before(this.entries[mid]!.kind)) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index whose key is >= `probe`. */\n private lowerBound(probe: SortKey): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (compareKeys(this.entries[mid]!, probe) < 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index whose key is > `probe`. */\n private upperBound(probe: SortKey): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (compareKeys(this.entries[mid]!, probe) <= 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /**\n * The persistable form of this index (#1359). `kind` travels with every\n * key: entries rank by runtime kind first, so an encoding that dropped it\n * would let a `string` probe reach `number` entries on the way back in.\n */\n toSnapshot(): SortedIndexSnapshot {\n return {\n v: FIELD_INDEX_SNAPSHOT_VERSION,\n t: 'sorted',\n field: this.field,\n nextSeq: this.nextSeq,\n entries: this.entries.map(e => [e.kind, e.key, e.seq, e.id] as WireSortedEntry),\n }\n }\n\n /**\n * Adopt a validated snapshot, or refuse it. Refusal (`false`) means the\n * caller rebuilds — it NEVER means a partial index: the entries are staged\n * and only swapped in once every one of them is accepted.\n *\n * `isLive` is the caller's liveness predicate over the record cache. An\n * entry naming a record the cache does not hold means the blob and the\n * collection have diverged (a crash between the two writes, say), so the\n * whole blob is discarded. Crash residue must be a rebuild, never a wrong\n * answer.\n */\n loadSnapshot(snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n if (snap.t !== 'sorted' || snap.field !== this.field) return false\n const staged: Entry[] = []\n for (const [kind, key, seq, id] of snap.entries) {\n if (!isLive(id)) return false\n staged.push({ kind: kind as KeyKind, key, seq, id })\n }\n this.entries.length = 0\n for (const e of staged) this.entries.push(e)\n this.nextSeq = snap.nextSeq\n return true\n }\n\n /**\n * Insertion point that keeps ties in `seq` order. A fresh entry lands at\n * the end of its tie run; a REINSTATED one (see {@link add}) lands back at\n * its own rank inside it.\n */\n private insertionPoint(entry: Entry): number {\n let i = this.upperBound(entry)\n while (i > 0 && compareKeys(this.entries[i - 1]!, entry) === 0 && this.entries[i - 1]!.seq > entry.seq) {\n i--\n }\n return i\n }\n}\n\n/** Build the whole index from a snapshot. Entry seqs follow snapshot order. */\nexport function buildSortedIndex<T>(\n idx: SortedIndex,\n records: ReadonlyArray<{ id: string; record: T }>,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n idx.clear()\n for (const { id, record } of records) {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) continue\n idx.add(id, value, canonicalize?.(idx.field, value))\n }\n}\n\n","/**\n * Compound (multi-field) sorted indexes — the tuple-keyed sibling of\n * `sorted-indexes.ts` (#1345).\n *\n * A compound index is an array of `{ keys, seq, id }` entries kept in\n * ascending `(keys[0], keys[1], …, seq)` order, where each `keys[i]` is\n * the SAME `SortKey` the single-field sorted index builds — so the tuple\n * encoding is order-preserving per component BY CONSTRUCTION rather than\n * by a second, hand-rolled serialization. Nothing is flattened into a\n * delimited string: a string component can therefore contain any byte\n * without colliding with a separator, and a money field canonicalized to\n * a scaled-integer string (`ViaPipeline.canonicalizeIndexKey`) or a date\n * stored as ISO text sorts inside its own component exactly as it does in\n * the single-field index.\n *\n * The two load-bearing properties of #1344 hold PER COMPONENT:\n *\n * - **Kind-partitioned.** `compareKeys` ranks by runtime kind first, so\n * within any equality-prefix run a `string` probe on the next\n * component cannot reach `number` entries — mirroring `predicate.ts`'s\n * `isComparable`, exactly as the linear scan behaves.\n * - **Ties keep insertion order** in both directions. `orderedIds()`\n * walks equal-key runs forward even when emitting descending, because\n * `sortRecords()` negates its comparator over a STABLE sort.\n *\n * **A record is indexed only when EVERY component has an order-defined\n * value.** One nullish or non-orderable component and the record is\n * absent — which is why the query builder compares {@link\n * CompoundIndex.size} against the snapshot size before dispatching, and\n * falls back to the scan when the index does not cover the collection.\n *\n * PERSISTENCE (#1359) is OPT-IN, same as its single-field sibling. The wire\n * form keeps the tuple as an ARRAY of per-component keys — see\n * `index-snapshot.ts`: flattening it to a delimited string would destroy\n * exactly the per-component ordering and kind partition this class is built\n * to preserve.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { KIND_STRING, compareKeys, toSortKey, type RangeOperator, type SortKey } from './sorted-indexes.js'\nimport {\n FIELD_INDEX_SNAPSHOT_VERSION,\n type CompoundIndexSnapshot,\n type FieldIndexSnapshot,\n type WireCompoundEntry,\n type WireKey,\n} from './index-snapshot.js'\n\n/** A range constraint on the component just past the equality prefix. */\nexport interface CompoundRangeProbe {\n readonly op: RangeOperator\n readonly value: unknown\n}\n\ninterface CompoundEntry {\n readonly keys: readonly SortKey[]\n readonly seq: number\n readonly id: string\n}\n\n/** One collection's index over an ordered field tuple. */\nexport class CompoundIndex {\n private readonly entries: CompoundEntry[] = []\n private nextSeq = 0\n\n constructor(readonly fields: readonly string[]) {}\n\n get size(): number {\n return this.entries.length\n }\n\n clear(): void {\n this.entries.length = 0\n this.nextSeq = 0\n }\n\n /**\n * Insert one record. No-op unless every component has an ordered key.\n *\n * `seq` REINSTATES a rank a previous entry for this id held — see\n * {@link remove}'s return value and `CollectionIndexes.upsert`. Omit it\n * for a fresh insert, which appends after every existing tie.\n */\n add(id: string, keys: readonly SortKey[] | undefined, seq?: number): void {\n if (!keys) return\n const entry: CompoundEntry = { keys, seq: seq ?? this.nextSeq++, id }\n this.entries.splice(this.insertionPoint(entry), 0, entry)\n }\n\n /**\n * Remove one record, addressed by the tuple it was indexed under.\n * Returns the rank it held, so an UPDATE can reinstate it: `sortRecords()`\n * sorts a snapshot whose order does not change when a record is written in\n * place, so a tie-breaking rank that drifted to the back on every `put`\n * would make an index-served page disagree with the scan it must match.\n */\n remove(id: string, keys: readonly SortKey[] | undefined): number | undefined {\n if (!keys) return undefined\n const [from, to] = this.run(keys, keys.length)\n for (let i = from; i < to; i++) {\n if (this.entries[i]!.id === id) {\n const [gone] = this.entries.splice(i, 1)\n return gone!.seq\n }\n }\n return undefined\n }\n\n /**\n * Ids matching an equality prefix, optionally narrowed by a range on\n * the next component. An empty set is authoritative: the index covers\n * these fields and nothing matches.\n */\n lookup(prefix: readonly SortKey[], range?: CompoundRangeProbe): Set<string> {\n const [from, to] = this.run(prefix, prefix.length)\n if (!range) return this.slice(from, to)\n const k = prefix.length\n if (k >= this.fields.length) return new Set()\n\n if (range.op === 'startsWith') {\n if (typeof range.value !== 'string') return new Set()\n const out = new Set<string>()\n const start = this.lowerBound([...prefix, { kind: KIND_STRING, key: range.value }], k + 1, from, to)\n for (let i = start; i < to; i++) {\n const key = this.entries[i]!.keys[k]!\n if (key.kind !== KIND_STRING) break\n if (!(key.key as string).startsWith(range.value)) break\n out.add(this.entries[i]!.id)\n }\n return out\n }\n\n if (range.op === 'between') {\n if (!Array.isArray(range.value) || range.value.length !== 2) return new Set()\n const lo = toSortKey(range.value[0], undefined)\n const hi = toSortKey(range.value[1], undefined)\n if (!lo || !hi || lo.kind !== hi.kind) return new Set()\n return this.slice(\n this.lowerBound([...prefix, lo], k + 1, from, to),\n this.upperBound([...prefix, hi], k + 1, from, to),\n )\n }\n\n const probe = toSortKey(range.value, undefined)\n if (!probe) return new Set()\n // Kind-partitioned per component: an open-ended bound stays inside the\n // probe's own kind run, so `< '5'` never sweeps up numeric entries.\n const [kindStart, kindEnd] = this.kindRun(from, to, k, probe.kind)\n const lo = this.lowerBound([...prefix, probe], k + 1, from, to)\n const hi = this.upperBound([...prefix, probe], k + 1, from, to)\n switch (range.op) {\n case '<':\n return this.slice(kindStart, lo)\n case '<=':\n return this.slice(kindStart, hi)\n case '>':\n return this.slice(hi, kindEnd)\n case '>=':\n return this.slice(lo, kindEnd)\n default: {\n const _exhaustive: never = range.op\n void _exhaustive\n return new Set()\n }\n }\n }\n\n /**\n * Ids matching an equality prefix, in the order of the remaining\n * components. Ties keep INSERTION order in both directions — a plain\n * `.reverse()` would disagree with `sortRecords()` on equal keys.\n */\n orderedIds(prefix: readonly SortKey[], direction: 'asc' | 'desc'): string[] {\n const [from, to] = this.run(prefix, prefix.length)\n const out: string[] = []\n if (direction === 'asc') {\n for (let i = from; i < to; i++) out.push(this.entries[i]!.id)\n return out\n }\n let end = to\n while (end > from) {\n let start = end - 1\n while (start > from && this.compare(this.entries[start - 1]!, this.entries[end - 1]!.keys, this.fields.length) === 0) {\n start--\n }\n for (let i = start; i < end; i++) out.push(this.entries[i]!.id)\n end = start\n }\n return out\n }\n\n private slice(from: number, to: number): Set<string> {\n const out = new Set<string>()\n for (let i = from; i < to; i++) out.add(this.entries[i]!.id)\n return out\n }\n\n /** [start, end) of the entries whose first `upto` components equal `probe`. */\n private run(probe: readonly SortKey[], upto: number): [number, number] {\n return [\n this.lowerBound(probe, upto, 0, this.entries.length),\n this.upperBound(probe, upto, 0, this.entries.length),\n ]\n }\n\n /** [start, end) of the entries in [from,to) whose component `k` has this kind. */\n private kindRun(from: number, to: number, k: number, kind: number): [number, number] {\n return [\n this.kindBoundary(from, to, k, x => x < kind),\n this.kindBoundary(from, to, k, x => x <= kind),\n ]\n }\n\n private kindBoundary(from: number, to: number, k: number, before: (kind: number) => boolean): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (before(this.entries[mid]!.keys[k]!.kind)) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index in [from,to) whose first `upto` components are >= `probe`. */\n private lowerBound(probe: readonly SortKey[], upto: number, from: number, to: number): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (this.compare(this.entries[mid]!, probe, upto) < 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index in [from,to) whose first `upto` components are > `probe`. */\n private upperBound(probe: readonly SortKey[], upto: number, from: number, to: number): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (this.compare(this.entries[mid]!, probe, upto) <= 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /**\n * The persistable form of this index (#1359). Each entry's tuple stays an\n * ARRAY of `[kind, key]` pairs: nothing is joined into a string, so a\n * string component may hold any byte and the per-component kind partition\n * survives the round trip intact.\n */\n toSnapshot(): CompoundIndexSnapshot {\n return {\n v: FIELD_INDEX_SNAPSHOT_VERSION,\n t: 'compound',\n fields: [...this.fields],\n nextSeq: this.nextSeq,\n entries: this.entries.map(\n e => [e.keys.map(k => [k.kind, k.key] as WireKey), e.seq, e.id] as WireCompoundEntry,\n ),\n }\n }\n\n /**\n * Adopt a validated snapshot, or refuse it. Same contract as\n * `SortedIndex.loadSnapshot`: all-or-nothing, and an entry naming a record\n * the cache does not hold rejects the whole blob so crash residue becomes a\n * rebuild rather than a wrong answer. A snapshot whose field tuple is not\n * exactly this index's is refused — the declaration changed under it.\n */\n loadSnapshot(snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n if (snap.t !== 'compound') return false\n if (snap.fields.length !== this.fields.length) return false\n for (let i = 0; i < snap.fields.length; i++) if (snap.fields[i] !== this.fields[i]) return false\n const staged: CompoundEntry[] = []\n for (const [keys, seq, id] of snap.entries) {\n if (!isLive(id)) return false\n staged.push({ keys: keys.map(k => ({ kind: k[0] as SortKey['kind'], key: k[1] })), seq, id })\n }\n this.entries.length = 0\n for (const e of staged) this.entries.push(e)\n this.nextSeq = snap.nextSeq\n return true\n }\n\n /**\n * Insertion point that keeps ties in `seq` order. A fresh entry lands at\n * the end of its tie run; a REINSTATED one (see {@link add}) lands back at\n * its own rank inside it.\n */\n private insertionPoint(entry: CompoundEntry): number {\n const to = this.upperBound(entry.keys, this.fields.length, 0, this.entries.length)\n let i = to\n while (i > 0 && this.compare(this.entries[i - 1]!, entry.keys, this.fields.length) === 0\n && this.entries[i - 1]!.seq > entry.seq) {\n i--\n }\n return i\n }\n\n private compare(entry: CompoundEntry, probe: readonly SortKey[], upto: number): number {\n for (let i = 0; i < upto; i++) {\n const c = compareKeys(entry.keys[i]!, probe[i]!)\n if (c !== 0) return c\n }\n return 0\n }\n}\n\n/**\n * The tuple key for one record, or `undefined` when any component is\n * nullish or has no order-defined runtime type. Canonicalizes through the\n * same per-field closure the hash and sorted indexes use, so a Via-covered\n * component lives in one key space across all three.\n */\nexport function tupleKeyOf<T>(\n fields: readonly string[],\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): SortKey[] | undefined {\n const keys: SortKey[] = []\n for (const field of fields) {\n const value = readPath(record, field)\n if (value === null || value === undefined) return undefined\n const key = toSortKey(value, canonicalize?.(field, value))\n if (!key) return undefined\n keys.push(key)\n }\n return keys\n}\n\n/** Probe keys for an equality prefix, or `undefined` if any operand is unorderable. */\nexport function probeKeysOf(values: readonly unknown[]): SortKey[] | undefined {\n const keys: SortKey[] = []\n for (const value of values) {\n const key = toSortKey(value, undefined)\n if (!key) return undefined\n keys.push(key)\n }\n return keys\n}\n\n/** Build the whole index from a snapshot. Entry seqs follow snapshot order. */\nexport function buildCompoundIndex<T>(\n idx: CompoundIndex,\n records: ReadonlyArray<{ id: string; record: T }>,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n idx.clear()\n for (const { id, record } of records) {\n idx.add(id, tupleKeyOf(idx.fields, record, canonicalize))\n }\n}\n\n/** Stable map key for a field tuple. `\\0` cannot appear in a field path. */\nexport function compoundKey(fields: readonly string[]): string {\n return fields.join('\\u0000')\n}\n","/**\n * Secondary indexes for the query DSL.\n *\n * ships **in-memory hash indexes**:\n * - Built during `Collection.ensureHydrated()` from the decrypted cache\n * - Maintained incrementally on `put` and `delete`\n * - Consulted by the query executor for `==` and `in` operators on\n * indexed fields, falling back to a linear scan otherwise\n * - Live entirely in memory — no adapter writes for the index itself\n *\n * Persistent encrypted index blobs (the spec's \"store as a separate\n * AES-256-GCM blob\" note) are deferred to a follow-up issue. The reasons\n * are documented in the PR body — short version: at the target\n * scale of 1K–50K records, building the index during hydrate is free,\n * so persistence buys nothing measurable.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { stringifyBucketKey, isProbeableBucketKey } from '../../kernel/query/distinct-key.js'\nimport { SortedIndex, buildSortedIndex, type RangeOperator } from './sorted-indexes.js'\nimport {\n CompoundIndex,\n buildCompoundIndex,\n compoundKey,\n probeKeysOf,\n tupleKeyOf,\n type CompoundRangeProbe,\n} from './compound-indexes.js'\nimport {\n compoundIndexKey,\n sortedIndexKey,\n type FieldIndexSnapshot,\n} from './index-snapshot.js'\n\n/**\n * Index declaration accepted by `Collection`'s constructor.\n *\n * Accepts:\n * - `string` — a single-field hash index (`'clientId'`)\n * - `{ fields: [...] }` or `readonly string[]` — a composite index\n * over an ordered field tuple. Only lazy-mode\n * collections consume composite declarations today; eager mode\n * silently treats a composite as equivalent to declaring each\n * component field as its own single-field index.\n *\n * Additive variants (unique constraints, partial indexes) will land as\n * further union members without breaking existing declarations.\n */\nexport type IndexDef =\n | string\n | {\n readonly fields: readonly string[]\n /**\n * Enforce that no two records share this field tuple. A MULTI-field\n * tuple is a COMPOUND unique — uniqueness over the tuple, never over\n * each component on its own (`['workerId','employerId']` allows one\n * worker at many employers). Null-distinct: a record with `null` or\n * `undefined` in any constrained field is exempt.\n *\n * ⚠️ **What \"unique\" means depends on the collection's mode (#1358),\n * and one of the four cannot promise prevention at all:**\n *\n * - eager (default) — prevented, from the in-memory map.\n * - lazy (`prefetch: false`) — prevented, by a point lookup through the\n * persisted `_idx/` mirror. Requires `withIndexing()`.\n * - tiered (`tiers: [...]`) — prevented across every tier whose DEK the\n * writer holds. **A tier the writer cannot read is outside the\n * guarantee** — those records are unreadable, so no local check can\n * see them, and a duplicate against one is accepted.\n * - CRDT (`crdt: '...'`) — **NOT prevented.** Uniqueness cannot be\n * enforced across concurrent replicas: two replicas that are offline\n * from each other can both accept the same value, and no local check\n * can prevent that. The write always succeeds and both records are\n * kept; the collision is reported on the `unique:violation` event as\n * a `UniqueConstraintError`, both when it happens and when a later\n * session first sees the two records together. What you get is\n * uniqueness within what this writer could see at write time, plus\n * detection when the replicas meet.\n */\n readonly unique?: boolean\n readonly kind?: IndexKind\n /**\n * Persist this index as an encrypted sidecar so a restart reuses it\n * instead of rebuilding (#1359). Only meaningful with `kind: 'sorted'`\n * — the hash index is not persisted. OPT-IN until measured: at the\n * 1K–50K target scale rebuild-on-open is free, and a sidecar is a\n * write on every debounce window plus a blob at rest.\n */\n readonly persist?: boolean\n }\n | readonly string[]\n\n/**\n * The access structure an index declaration asks for (#1344).\n *\n * `'hash'` (the default, and what every pre-#1344 declaration means) is\n * the equality/`in` bucket map. `'sorted'` additionally maintains an\n * ordered array over the same canonicalized keys, which lights up\n * index-driven `<`, `<=`, `>`, `>=`, `between`, `startsWith` and\n * `orderBy(field).limit(n)`. A `'sorted'` declaration keeps the hash\n * index too — `==`/`in` stay O(1).\n */\nexport type IndexKind = 'hash' | 'sorted'\n\n/**\n * Normalize a declared `IndexDef[]` into a uniform `{ fields, unique? }`\n * shape: `string` → `{fields:[s]}`, `string[]` → `{fields}`, object →\n * passthrough. Pure — used by `Collection`'s sensitive-field leak check\n * and by `getDeclaredIndexes()` (introspection).\n */\nexport function normalizeIndexDefs(\n defs: readonly IndexDef[],\n): ReadonlyArray<{ readonly fields: readonly string[]; readonly unique?: boolean }> {\n return defs.map((def) => {\n if (typeof def === 'string') return { fields: [def] }\n if (Array.isArray(def)) return { fields: def }\n return def as { readonly fields: readonly string[]; readonly unique?: boolean }\n })\n}\n\n/**\n * Internal representation of a built hash index.\n *\n * Maps stringified field values to the set of record ids whose value\n * for that field matches. Stringification keeps the index simple and\n * works uniformly for primitives (`'open'`, `'42'`, `'true'`).\n *\n * Records whose indexed field is `undefined` or `null` are NOT inserted\n * — `query().where('field', '==', undefined)` falls back to a linear\n * scan, which is the conservative behavior.\n */\nexport interface HashIndex {\n readonly field: string\n readonly buckets: Map<string, Set<string>>\n}\n\n/**\n * Container for all indexes on a single collection.\n *\n * Methods are pure with respect to the in-memory `buckets` Map — they\n * never touch the adapter or the keyring. The Collection class owns\n * lifecycle (build on hydrate, maintain on put/delete).\n */\nexport class CollectionIndexes {\n private readonly indexes = new Map<string, HashIndex>()\n\n /**\n * Sorted (range) indexes, keyed by field — the #1344 half. Parallel to\n * `indexes` above and maintained at the SAME mutation sites, through the\n * SAME `canonicalize` closure, so the two can never disagree about which\n * key space a field lives in.\n */\n private readonly sorted = new Map<string, SortedIndex>()\n\n /**\n * Compound (tuple-keyed) sorted indexes, keyed by the joined field\n * tuple — the #1345 half. Third parallel map, maintained at the SAME\n * mutation sites through the SAME `canonicalize` closure as the other\n * two, so no field can end up in disagreeing key spaces.\n */\n private readonly compound = new Map<string, CompoundIndex>()\n\n /**\n * The indexes declared `persist: true` (#1359), keyed by their SIDECAR key\n * (`s:<field>` / `c:<f1>,<f2>`). A separate map rather than a flag on the\n * index classes: persistence is a property of the DECLARATION, and the\n * index classes stay unaware of storage.\n */\n private readonly persistable = new Map<string, SortedIndex | CompoundIndex>()\n\n /**\n * Per-field bucket-key canonicalizer (#672 review C1), registered ONCE\n * via {@link setCanonicalizer} when the collection wires indexing up\n * (money-aware via `ViaPipeline.canonicalizeIndexKey`). Consulted by\n * EVERY bucket-mutation site — `build`/`upsert`/`remove` — so bucket\n * membership is symmetric by construction: a value can never be added\n * under a canonical key and later removed under the raw one (or vice\n * versa), which is what stranded ids on `put`/`delete` before this fix.\n */\n private canonicalize?: (field: string, value: unknown) => string | undefined\n\n /**\n * Register the bucket-key canonicalizer. Called once, where the\n * collection constructs its indexing state — safe to call again (the\n * closure is simply replaced) but there is normally only one caller.\n */\n setCanonicalizer(fn: (field: string, value: unknown) => string | undefined): void {\n this.canonicalize = fn\n }\n\n /**\n * Declare an index. Subsequent record additions are tracked under it.\n * Calling this twice for the same field is a no-op (idempotent).\n */\n declare(field: string): void {\n if (this.indexes.has(field)) return\n this.indexes.set(field, { field, buckets: new Map() })\n }\n\n /**\n * Declare a sorted (range) index on a field. Independent of\n * {@link declare} — callers that want both `==` speed and range speed\n * declare both (which is what `withIndexing()` does for a\n * `kind: 'sorted'` declaration). Idempotent.\n */\n declareSorted(field: string, opts?: { readonly persist?: boolean }): void {\n let idx = this.sorted.get(field)\n if (!idx) {\n idx = new SortedIndex(field)\n this.sorted.set(field, idx)\n }\n if (opts?.persist) this.persistable.set(sortedIndexKey(field), idx)\n }\n\n /** True if the given field has a declared SORTED index. */\n hasSorted(field: string): boolean {\n return this.sorted.has(field)\n }\n\n /** All sorted-index field names, in declaration order. */\n sortedFields(): string[] {\n return [...this.sorted.keys()]\n }\n\n /** Number of entries in a field's sorted index (0 when undeclared). */\n sortedSize(field: string): number {\n return this.sorted.get(field)?.size ?? 0\n }\n\n /**\n * Range lookup: ids whose `field` satisfies the operator. Returns\n * `null` when no SORTED index covers the field — the caller falls back\n * to a linear scan. An empty set means \"the index covers this field and\n * nothing matches\", which is authoritative.\n */\n lookupRange(field: string, op: RangeOperator, value: unknown): ReadonlySet<string> | null {\n return this.sorted.get(field)?.lookup(op, value) ?? null\n }\n\n /**\n * Ids of every indexed record in `field` order. `null` when no sorted\n * index covers the field. Records whose value is nullish or has no\n * order-defined type are absent — compare against {@link sortedSize}\n * before treating the result as the full collection.\n */\n orderedIds(field: string, direction: 'asc' | 'desc'): readonly string[] | null {\n return this.sorted.get(field)?.orderedIds(direction) ?? null\n }\n\n /**\n * Declare a compound (multi-field) sorted index over an ordered field\n * tuple. A tuple shorter than two fields is a single-field sorted index\n * and is ignored here. Idempotent.\n */\n declareCompound(fields: readonly string[], opts?: { readonly persist?: boolean }): void {\n if (fields.length < 2) return\n const key = compoundKey(fields)\n let idx = this.compound.get(key)\n if (!idx) {\n idx = new CompoundIndex([...fields])\n this.compound.set(key, idx)\n }\n if (opts?.persist) this.persistable.set(compoundIndexKey(fields), idx)\n }\n\n /** Every declared field tuple, in declaration order. */\n compoundTuples(): ReadonlyArray<readonly string[]> {\n return [...this.compound.values()].map(idx => idx.fields)\n }\n\n /**\n * Number of records the tuple's index holds (0 when undeclared). A\n * record with a nullish or non-orderable component is absent, so a\n * caller that removes clauses from the plan MUST compare this against\n * the snapshot size before trusting the result.\n */\n compoundSize(fields: readonly string[]): number {\n return this.compound.get(compoundKey(fields))?.size ?? 0\n }\n\n /**\n * Compound lookup: ids whose leading components equal `prefixValues`,\n * optionally narrowed by a range on the component just past them.\n * `null` when no compound index covers the tuple, or when an operand\n * has no order-defined type — the caller falls back to a linear scan.\n */\n lookupCompound(\n fields: readonly string[],\n prefixValues: readonly unknown[],\n range?: CompoundRangeProbe,\n ): ReadonlySet<string> | null {\n const idx = this.compound.get(compoundKey(fields))\n if (!idx) return null\n const prefix = probeKeysOf(prefixValues)\n if (!prefix) return null\n return idx.lookup(prefix, range)\n }\n\n /**\n * Ids matching an equality prefix, ordered by the remaining components.\n * `null` when no compound index covers the tuple or an operand has no\n * order-defined type. See {@link compoundSize} for the coverage caveat.\n */\n compoundOrderedIds(\n fields: readonly string[],\n prefixValues: readonly unknown[],\n direction: 'asc' | 'desc',\n ): readonly string[] | null {\n const idx = this.compound.get(compoundKey(fields))\n if (!idx) return null\n const prefix = probeKeysOf(prefixValues)\n if (!prefix) return null\n return idx.orderedIds(prefix, direction)\n }\n\n /** True if the given field has a declared index. */\n has(field: string): boolean {\n return this.indexes.has(field)\n }\n\n /** All declared field names, in declaration order. */\n fields(): string[] {\n return [...this.indexes.keys()]\n }\n\n /**\n * Build all declared indexes from a snapshot of records.\n * Called once per hydration. O(N × indexes.size). Buckets through the\n * registered {@link setCanonicalizer} closure, same as `upsert`/`remove`.\n */\n build<T>(records: ReadonlyArray<{ id: string; record: T }>, skip: ReadonlySet<string> = EMPTY_KEYS): void {\n for (const idx of this.indexes.values()) {\n idx.buckets.clear()\n for (const { id, record } of records) {\n addToIndex(idx, id, record, this.canonicalize)\n }\n }\n // `skip` names the sidecar keys a persisted snapshot already restored\n // (#1359) — rebuilding them would throw that work away AND renumber every\n // `seq`, which is what the whole ordered fast path rests on.\n for (const [field, idx] of this.sorted) {\n if (skip.has(sortedIndexKey(field))) continue\n buildSortedIndex(idx, records, this.canonicalize)\n }\n for (const idx of this.compound.values()) {\n if (skip.has(compoundIndexKey(idx.fields))) continue\n buildCompoundIndex(idx, records, this.canonicalize)\n }\n }\n\n /** Sidecar keys of every index declared `persist: true`, in declaration order. */\n persistableKeys(): readonly string[] {\n return [...this.persistable.keys()]\n }\n\n /** The persistable snapshot behind one sidecar key, or `undefined` if it is not declared. */\n snapshotIndex(key: string): FieldIndexSnapshot | undefined {\n return this.persistable.get(key)?.toSnapshot()\n }\n\n /**\n * Adopt a validated snapshot into the index behind `key`. `false` means the\n * caller must rebuild that index from the cache — the index is left\n * untouched, never half-loaded.\n */\n restoreIndex(key: string, snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n return this.persistable.get(key)?.loadSnapshot(snap, isLive) ?? false\n }\n\n /**\n * Insert or update a single record across all indexes.\n * Called by `Collection.put()` after the encrypted write succeeds.\n *\n * If `previousRecord` is provided, the record is removed from any old\n * buckets first — this is the update path. Pass `null` for fresh adds.\n */\n upsert<T>(id: string, newRecord: T, previousRecord: T | null): void {\n if (this.indexes.size === 0 && this.sorted.size === 0 && this.compound.size === 0) return\n // Detach the compound and sorted entries FIRST, holding the rank each one had. An\n // in-place `put` does not move a record within `snapshot()`, so it must\n // not move it within a tie run either — otherwise an index-served\n // `orderBy(...).limit(n)` page disagrees with the stable scan-and-sort\n // it is required to reproduce exactly (#1345, #1369). The `this.remove()`\n // below re-runs both removals, which are then no-ops.\n const ranks = new Map<string, number | undefined>()\n const sortedRanks = new Map<string, number | undefined>()\n if (previousRecord !== null) {\n for (const [key, idx] of this.compound) {\n ranks.set(key, idx.remove(id, tupleKeyOf(idx.fields, previousRecord, this.canonicalize)))\n }\n // Same for the single-field sorted indexes (#1369) — the defect and the\n // remedy are identical, and the two implementations must agree.\n for (const [key, idx] of this.sorted) {\n const value = readPath(previousRecord, idx.field)\n if (value === null || value === undefined) continue\n sortedRanks.set(key, idx.remove(id, value, this.canonicalize?.(idx.field, value)))\n }\n this.remove(id, previousRecord)\n }\n for (const idx of this.indexes.values()) {\n addToIndex(idx, id, newRecord, this.canonicalize)\n }\n for (const [key, idx] of this.sorted) {\n const value = readPath(newRecord, idx.field)\n if (value === null || value === undefined) continue\n idx.add(id, value, this.canonicalize?.(idx.field, value), sortedRanks.get(key))\n }\n for (const [key, idx] of this.compound) {\n idx.add(id, tupleKeyOf(idx.fields, newRecord, this.canonicalize), ranks.get(key))\n }\n }\n\n /**\n * Remove a record from all indexes. Called by `Collection.delete()`\n * (and as the first half of `upsert` for the update path).\n */\n remove<T>(id: string, record: T): void {\n if (this.indexes.size === 0 && this.sorted.size === 0 && this.compound.size === 0) return\n for (const idx of this.indexes.values()) {\n removeFromIndex(idx, id, record, this.canonicalize)\n }\n for (const idx of this.sorted.values()) {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) continue\n idx.remove(id, value, this.canonicalize?.(idx.field, value))\n }\n for (const idx of this.compound.values()) {\n idx.remove(id, tupleKeyOf(idx.fields, record, this.canonicalize))\n }\n }\n\n /** Drop all index data. Called when the collection is invalidated. */\n clear(): void {\n for (const idx of this.indexes.values()) {\n idx.buckets.clear()\n }\n for (const idx of this.sorted.values()) {\n idx.clear()\n }\n for (const idx of this.compound.values()) {\n idx.clear()\n }\n }\n\n /**\n * Equality lookup: return the set of record ids whose `field` matches\n * the given value. Returns `null` if no index covers the field — the\n * caller should fall back to a linear scan.\n *\n * ⛔ ALSO `null` when the OPERAND has no bucket ADDRESS (#1402) — a\n * nullish operand, or an object one, which every object-valued record in\n * the collection shares. Answering those from the buckets returns rows\n * the scan does not, silently, and only on the collections that happen to\n * have an index. See `isProbeableBucketKey` for the two measurements.\n *\n * The returned Set is a reference to the index's internal storage —\n * callers must NOT mutate it.\n */\n lookupEqual(field: string, value: unknown): ReadonlySet<string> | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n if (!isProbeableBucketKey(value)) return null\n const key = stringifyKey(value)\n return idx.buckets.get(key) ?? EMPTY_SET\n }\n\n /**\n * Set lookup: return the union of record ids whose `field` matches any\n * of the given values. Returns `null` if no index covers the field.\n *\n * ⛔ ALSO `null` when ANY member of `values` has no bucket address\n * (#1402) — one unaddressable member poisons the whole union, since the\n * result is a union and there is no partial answer to hand back. Same\n * measurement as {@link lookupEqual}.\n */\n lookupIn(field: string, values: readonly unknown[]): ReadonlySet<string> | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n if (!values.every(isProbeableBucketKey)) return null\n const out = new Set<string>()\n for (const value of values) {\n const key = stringifyKey(value)\n const bucket = idx.buckets.get(key)\n if (bucket) {\n for (const id of bucket) out.add(id)\n }\n }\n return out\n }\n\n /**\n * One record id per NON-EMPTY bucket of `field`'s hash index, in bucket\n * order — the index-backed spine of `Query.distinct()` (#1347). `null` when\n * no hash index covers the field, so the caller scans instead.\n *\n * The bucket set IS the distinct key set, so this costs O(buckets) rather\n * than O(records). It returns REPRESENTATIVE IDS rather than the keys\n * themselves on purpose: a bucket key is a canonical string (money's\n * BigInt-normalized scaled int, say), and `distinct()` owes its caller the\n * field's real value, which only the record carries.\n *\n * Bucket insertion order is first-seen record order — `build()` walks the\n * snapshot in order and `upsert()` appends — which is why an index-backed\n * `distinct()` and a scanned one agree on ORDER too, not merely on the set.\n * Empty buckets are skipped defensively; `removeFromIndex` already deletes\n * them, so this is belt-and-braces against a future partial removal path.\n */\n bucketRepresentatives(field: string): readonly string[] | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n const out: string[] = []\n for (const bucket of idx.buckets.values()) {\n for (const id of bucket) {\n out.push(id)\n break\n }\n }\n return out\n }\n}\n\nconst EMPTY_SET: ReadonlySet<string> = new Set()\nconst EMPTY_KEYS: ReadonlySet<string> = new Set()\n\n/**\n * Stringify a value into a stable bucket key.\n *\n * ⚠️ The DEFINITION moved to `kernel/query/distinct-key.ts` (#1347) and is\n * only aliased here. `distinct()` / `countDistinct()` recompute this key on\n * the scan path, and an index-backed `distinct()` reads the buckets it made —\n * one definition is what stops those two answers from drifting apart. Change\n * the shared function, not a copy.\n */\nconst stringifyKey = stringifyBucketKey\n\nfunction addToIndex<T>(\n idx: HashIndex,\n id: string,\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) return\n const key = canonicalize?.(idx.field, value) ?? stringifyKey(value)\n let bucket = idx.buckets.get(key)\n if (!bucket) {\n bucket = new Set()\n idx.buckets.set(key, bucket)\n }\n bucket.add(id)\n}\n\nfunction removeFromIndex<T>(\n idx: HashIndex,\n id: string,\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) return\n const key = canonicalize?.(idx.field, value) ?? stringifyKey(value)\n const bucket = idx.buckets.get(key)\n if (!bucket) return\n bucket.delete(id)\n // Clean up empty buckets so the Map doesn't accumulate dead keys.\n if (bucket.size === 0) idx.buckets.delete(key)\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBO,IAAM,+BAA+B;AAkCrC,S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M,eAAe,IAAI,OAAO,KAAK,KAAK,aAAa,KAAK;AAClE,QAAM,SAAS,IAAI,QAAQ,IAAI,GAAG;AAClC,MAAI,CAAC,OAAQ;AACb,SAAO,OAAO,EAAE;AAEhB,MAAI,OAAO,SAAS,EAAG,KAAI,QAAQ,OAAO,GAAG;AAC/C;","names":["lo","hi","lo","hi"]}
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  NoydbError
3
- } from "./chunk-7O3Y4PPD.js";
3
+ } from "./chunk-244VXYPG.js";
4
4
 
5
5
  // src/kernel/via/index.ts
6
+ function isViaPrefixProbe(x) {
7
+ return typeof x === "object" && x !== null && x.kind === "via-prefixes" && Array.isArray(x.prefixes);
8
+ }
6
9
  var binders = /* @__PURE__ */ new Map();
7
10
  function installViaBinder(brand, binder) {
8
11
  if (!binders.has(brand)) binders.set(brand, binder);
@@ -22,8 +25,9 @@ function viaBinder(brand) {
22
25
  }
23
26
 
24
27
  export {
28
+ isViaPrefixProbe,
25
29
  installViaBinder,
26
30
  isViaInstalled,
27
31
  viaBinder
28
32
  };
29
- //# sourceMappingURL=chunk-UXVWEX5L.js.map
33
+ //# sourceMappingURL=chunk-Z5HTYMMQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/kernel/via/index.ts"],"sourcesContent":["// kernel/via/index.ts — the ONLY kernel-resident via surface.\nimport { NoydbError } from '../errors.js'\nimport type { EncryptedEnvelope } from '../types.js'\n\n/** Awaitable type for potentially async results. */\ntype Awaitable<T> = T | Promise<T>\n\n/** Declared security posture — a property the kernel enforces (enforcement activates in phases B/C). */\nexport interface ViaPosture {\n readonly encryptedAtRest: 'envelope' | 'sealed'\n readonly queryable: 'none' | 'det-exact' | 'ordered' | 'full'\n readonly exportable: boolean\n readonly forgettable: boolean\n}\n\n/** Opaque marker every feature descriptor extends; the kernel never sees concrete descriptor types. */\nexport interface ViaDescriptor { readonly _viaBrand: string }\n\n/** Per-call write context (A: minimal; B/C extend). */\nexport interface ViaWriteCtx {\n readonly id: string\n /** Owning vault name (event payload identity — e.g. i18n:script-violation). */\n readonly vault: string\n /** Prior stored record (decoded), lazily resolved. Null when creating. */\n readonly prior: () => Promise<Record<string, unknown> | null>\n /** Typed event emission (e.g. i18n:script-violation). */\n readonly emit: (event: string, payload: unknown) => void\n}\n\n/** Per-call read context — mirrors LocaleReadOptions loosely; features narrow. */\nexport interface ViaReadCtx {\n readonly locale?: unknown\n readonly fallback?: unknown\n readonly layer: string\n}\n\n/** One sealed slot's ciphertext — matches the existing `iv:data` sealed map entries (seam map §2 step 2). */\nexport interface SealedSlotRef { readonly iv: string; readonly data: string }\n\n/**\n * A scoped crypto capability handed to a `via` feature's `encodeAtRest`/\n * `decodeAtRest`/`erase` hooks — never the keyring, never the enclave.\n * `sealedSlots` is pre-bound to one `(collection, recordId)`; `reservedEnvelopes`\n * is a whole-envelope encrypt/decrypt door scoped to collection names under a\n * declared prefix (e.g. `_dict_`).\n */\nexport interface ViaCryptoCtx {\n readonly sealedSlots: {\n seal(field: string, plaintext: unknown): Promise<SealedSlotRef>\n unseal(field: string, ref: SealedSlotRef): Promise<unknown>\n delete(field: string): Promise<void>\n }\n reservedEnvelopes(prefix: string): {\n /**\n * `id` is the record id the envelope will be stored under. Required\n * (#1051) because this function holds the DEK, so it is where record-identity\n * AAD is applied — a caller that cannot name the id cannot be bound.\n */\n encrypt(\n identity: { readonly collection: string; readonly id: string; readonly by?: string },\n json: string,\n v: number,\n ): Promise<EncryptedEnvelope>\n decrypt(collection: string, id: string, env: EncryptedEnvelope): Promise<string>\n }\n}\n\n/** Per-call erase context — `forget()`'s per-ref participation door (phase C). */\nexport interface ViaEraseCtx { readonly id: string; readonly vault: string; readonly live: unknown /* EncryptedEnvelope */; readonly crypto: ViaCryptoCtx }\n/**\n * What an `erase` hook reports back to `forget()`'s summary ledger entry.\n * `retainedShared` is additive (#629 Task 10) — content NOT erased because\n * still referenced by another live record (blob's shared-chunk dual\n * accounting, `shredAllForRecord()`'s `retainedShared` count). Absent/0 for\n * bindings with no such concept (a sealed field is never \"shared\").\n */\nexport interface ViaEraseReport { readonly shredded: number; readonly residue: readonly unknown[]; readonly retainedShared?: number }\n\n/**\n * A feature bound to one collection's declared config. Record-grain hooks —\n * every hook receives the whole record (matches the real engine signatures,\n * e.g. quantizeMoneyFields(record, moneyFields)). All hooks optional;\n * absent = passthrough. Query-participation hooks are SYNC (#553).\n */\nexport interface NoydbVia {\n readonly brand: string\n readonly posture: ViaPosture\n /** Declared dependencies (field paths / cross-record specs). MANDATORY for any future\n * derive-bearing binding — phase C validates well-formedness (strings, non-empty,\n * reference declared fields) and graph-registers a derived edge for each covered\n * field at declare time, right after `compileVias` builds the bindings\n * (unknown source field throws `ValidationError`). See\n * `kernel/collection-config.ts`'s `resolveViaDepsEdges`. */\n readonly deps?: readonly string[]\n /** Collection-name prefixes this binding's `reservedEnvelopes` capability may address (e.g. `_dict_`). */\n readonly reservedPrefixes?: readonly string[]\n /**\n * Does this binding own `field`? Backs `ViaPipeline.postureFor` (#629 Task\n * 8's posture consumer) — a passive coverage check, independent of\n * `buildClause`/`compareForOrder` (which some bindings, e.g. classified and\n * blob, never define). SYNC, no side effects.\n *\n * Contract (documentation only — not enforced at runtime, future work):\n * any binding declaring a non-default posture value — `queryable: 'none'`\n * (#629 Task 8) or `exportable: false` (#629 Task 9's `redactForExport`)\n * — MUST implement `covers()`. `postureFor`'s consumers only engage for\n * fields a binding actively claims via `covers()`; a binding that omits\n * it would silently fall through to the generic (unrefused/unredacted)\n * path instead.\n */\n covers?(field: string): boolean\n // NOTE: phase C adds a `derive` hook ADDITIVELY — do not stub it now.\n // ── write pipeline ──\n /** Refuse a write before crypto runs (classified step-3 slot: storage:'never' rejection + validators). Throws to refuse. */\n enforceWrite?(record: Record<string, unknown>, ctx: ViaWriteCtx): void | Promise<void>\n /** First pipeline stage (money canonicalizeIncomingMoney). SYNC. */\n ingest?(record: Record<string, unknown>): Record<string, unknown>\n /** Decode STORED form to canonical for internal boundaries (gates, derivations, patch bases). SYNC. */\n canonicalizeStored?(record: Record<string, unknown>): Record<string, unknown>\n /** Post-validation write encoding (money quantize; i18n translate→script→validate→densify). May be async. */\n encodeWrite?(record: Record<string, unknown>, ctx: ViaWriteCtx): Awaitable<Record<string, unknown>>\n /** Final write-pipeline stage: seal/encrypt declared fields via `crypto` before the envelope body is built (classified step-2 slot). */\n encodeAtRest?(record: Record<string, unknown>, crypto: ViaCryptoCtx): Promise<{ record: Record<string, unknown>; sealed?: Record<string, SealedSlotRef> }>\n // ── read pipeline ──\n /** First read-pipeline stage: unseal/decrypt declared fields via `crypto` before `present` runs (classified sealed-handle slot). */\n decodeAtRest?(record: Record<string, unknown>, sealed: Record<string, SealedSlotRef>, crypto: ViaCryptoCtx, opts: { asHandles: boolean }): Promise<Record<string, unknown>>\n /** Read-time presentation (money decode+virtuals; i18n locale/labels/strip). May be async. */\n present?(record: Record<string, unknown>, ctx: ViaReadCtx): Awaitable<Record<string, unknown>>\n /**\n * Late read-time presentation (#669) — runs AFTER every binding's `present()` in the\n * money+computed present-order segment (`ViaPipeline`'s `_presentOrder`, `kernel/via/\n * pipeline.ts`), BEFORE the \"everything else\" segment (i18n/lookup dressing, taint\n * redaction) runs. Exists for a binding that needs to react to a virtual computed\n * field's fresh OWN-field output before anything dresses it (money's MAJOR-UNITS\n * quantize-and-present for a field that is BOTH money AND `mode:'virtual'` computed) —\n * `present()` alone can't express \"run after computed for THESE fields only, before\n * computed for all others\", since it's a per-BINDING fold, not per-field. Folded over\n * `bindings` in declaration order (mirrors every other per-binding fold), so lookup/\n * i18n dressing and taint/redaction (both in the \"everything else\" segment) still see\n * the already-dressed value.\n */\n presentLate?(record: Record<string, unknown>, ctx: ViaReadCtx): Awaitable<Record<string, unknown>>\n /**\n * #1416 — declare that BOTH `present` and `presentLate` return synchronously,\n * so `ViaPipeline.presentSync` may fold this binding.\n *\n * ⛔ DECLARED, NOT SNIFFED, and that is the whole point. A plain function\n * returning a promise is indistinguishable at runtime from one that does not\n * (`constructor.name === 'AsyncFunction'` catches `async () =>` and nothing\n * else), so detecting it would silently mis-classify the one binding that\n * matters. Calling an async hook and discarding its promise is worse still:\n * side effects run and a rejection surfaces unhandled.\n *\n * Defaults to `false` — a binding that has not thought about it is skipped by\n * the sync path and dressed only on the async one, which is today's\n * behaviour. `money` and `computed` set it; `i18n` and `lookup` cannot.\n */\n readonly presentIsSync?: boolean\n /**\n * #1447 — the fields this binding covers, ENUMERATED.\n *\n * ⛔ `covers()` is a PREDICATE and cannot answer this. Iterating a\n * collection's declared fields and asking \"do you cover this?\" misses every\n * field that exists only in the binding's own config — a\n * `computed({ mode: 'virtual' })` field is exactly that, and it is the case\n * that motivated the report: a consumer's rulebook described three vault\n * -computed fields as app-owned, and a predicate-based check would not have\n * caught it because it never thinks to ask about them.\n *\n * Optional, and absence is honest rather than empty: a binding that has not\n * declared its set is omitted from the report rather than reported as\n * covering nothing.\n */\n readonly coveredFields?: readonly string[]\n // ── query participation (ALL SYNC — #553) ──\n /** Returns an opaque clause payload when this binding covers `field`, else undefined. */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n buildClause?(field: string, op: string, value: unknown): unknown | undefined\n /** Evaluate a payload produced by buildClause against a raw stored value. */\n evaluateClause?(actual: unknown, op: string, payload: unknown): boolean\n /**\n * Optional: the STORED-form operand for a direct secondary-index probe\n * against a payload produced by `buildClause` (#625) — lets\n * `candidateRecords()` (`query/builder.ts`) hit `CollectionIndexes.\n * lookupEqual`/`lookupIn` for `==`/`in` clauses instead of falling back\n * to a linear scan + per-record `evaluateClause`. Returning `undefined`\n * means \"no sound probe for this op/payload\" (e.g. a comparison whose\n * stored form isn't a single index-bucketable value, or an op the index\n * can't serve) — the caller falls back to the scan. A binding that\n * never implements this hook always falls back, unchanged from before\n * this hook existed.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n indexProbe?(op: string, payload: unknown): unknown | undefined\n /**\n * Optional: canonicalize a raw STORED field value into the bucket key an\n * eager index should use (#672) — lets `CollectionIndexes` group a\n * pre-declaration / non-canonical stored value (e.g. a money field's\n * leftover `'0100'` written before its `money()` declaration) under the\n * SAME key a canonical write produces (`'100'`), so the index-probe fast\n * path (`indexProbe` above) and the fallback scan (`evaluateClause`)\n * agree on which records match. `undefined` means \"not mine / can't\n * canonicalize this value\" — the caller buckets the raw stringified\n * value, unchanged from before this hook existed. MUST agree with what\n * this binding's own `evaluateClause`/`indexProbe` treat as equal, or\n * the fast path and the scan will disagree.\n */\n canonicalizeIndexKey?(field: string, rawValue: unknown): string | undefined\n /** Decode a raw stored record for query/scan results and callback views ('raw' — no virtuals). */\n decodeResults?(record: unknown): unknown\n /** Exact ordering for a covered field; undefined when the field is not covered. */\n compareForOrder?(field: string, a: unknown, b: unknown): number | undefined\n /**\n * Per-key, PER-CALL-locale label resolution for `orderBy(field, dir,\n * { by: 'label' })` (#650 Task 7) — the sibling `compareForOrder` above\n * structurally cannot serve, since it carries no locale parameter.\n * `locale` is the query's per-call locale (`undefined` for a locale-less\n * query — a binding may fall back to its own descriptor-level default,\n * mirroring `present`'s displayLocale hinge). `undefined` return = this\n * binding doesn't resolve a label for `key` at `field` — caller falls\n * back to the raw stored value, same graceful-degrade discipline every\n * other via query hook uses. SYNC (#553 — query participation).\n */\n resolveOrderLabel?(field: string, key: string, locale: string | undefined): string | undefined\n /** Rewrite an aggregate spec (money exact reducers). */\n wrapReducers?(spec: unknown): unknown\n // ── forget participation ──\n /** `forget()`'s per-ref erasure door — shred/report this binding's residue for one record (classified/blob forget participation). */\n erase?(ctx: ViaEraseCtx): Promise<ViaEraseReport>\n // ── introspection ──\n describeFragment?(): Record<string, unknown>\n}\n\n/**\n * An `indexProbe` result asking for a UNION of sorted-index PREFIX slices\n * (#1355), rather than the single equality operand `indexProbe` yielded\n * before it existed.\n *\n * ⛔ IT IS A SUPERSET, AND THAT IS THE CONTRACT. `candidateRecords()`\n * (`kernel/query/builder.ts`) narrows to the union of these prefixes and\n * then keeps the clause in `remainingClauses`, so the binding's own\n * `evaluateClause` still runs over every candidate. A binding returning\n * this promises only that no MATCHING record lies outside the union —\n * never that every record inside it matches. Return `undefined` instead\n * of a cover you cannot prove complete: an over-wide cover costs\n * predicate calls, a short one silently drops rows.\n *\n * Generic on purpose. Geo is today's only producer, but nothing here is\n * spatial — any binding whose stored key is an ordered string with a\n * meaningful prefix (a path, a bucketed timestamp) can use it.\n */\nexport interface ViaPrefixProbe {\n readonly kind: 'via-prefixes'\n readonly prefixes: readonly string[]\n}\n\n/** Runtime predicate for a {@link ViaPrefixProbe} handed back by `indexProbe`. */\nexport function isViaPrefixProbe(x: unknown): x is ViaPrefixProbe {\n return (\n typeof x === 'object' && x !== null &&\n (x as { kind?: unknown }).kind === 'via-prefixes' &&\n Array.isArray((x as { prefixes?: unknown }).prefixes)\n )\n}\n\n/** Binder: constructs a binding from a collection's declared config. Installed by the feature's declaration factory. */\nexport type ViaBinder = (config: unknown) => NoydbVia\n\nconst binders = new Map<string, ViaBinder>()\n\n/** @internal — called (idempotently, first-wins) by a feature's declaration factory, e.g. money(). */\nexport function installViaBinder(brand: string, binder: ViaBinder): void {\n if (!binders.has(brand)) binders.set(brand, binder)\n}\n\n/** @internal — registry presence check. Used by tests (mirrors isMoneyEngineInstalled) and by vault's i18n validator delegators as a no-i18n-ever-declared fast path. */\nexport function isViaInstalled(brand: string): boolean {\n return binders.has(brand)\n}\n\n/** @internal — resolve a binder; throws when the declaration factory never ran (hand-rolled descriptors). */\nexport function viaBinder(brand: string): ViaBinder {\n const b = binders.get(brand)\n if (!b) {\n throw new NoydbError(\n 'VIA_NOT_LINKED',\n `via feature \"${brand}\" requires descriptors created via its declaration factory from @noy-db/hub`,\n )\n }\n return b\n}\n"],"mappings":";;;;;AAiQO,SAAS,iBAAiB,GAAiC;AAChE,SACE,OAAO,MAAM,YAAY,MAAM,QAC9B,EAAyB,SAAS,kBACnC,MAAM,QAAS,EAA6B,QAAQ;AAExD;AAKA,IAAM,UAAU,oBAAI,IAAuB;AAGpC,SAAS,iBAAiB,OAAe,QAAyB;AACvE,MAAI,CAAC,QAAQ,IAAI,KAAK,EAAG,SAAQ,IAAI,OAAO,MAAM;AACpD;AAGO,SAAS,eAAe,OAAwB;AACrD,SAAO,QAAQ,IAAI,KAAK;AAC1B;AAGO,SAAS,UAAU,OAA0B;AAClD,QAAM,IAAI,QAAQ,IAAI,KAAK;AAC3B,MAAI,CAAC,GAAG;AACN,UAAM,IAAI;AAAA,MACR;AAAA,MACA,gBAAgB,KAAK;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadVaultPolicy
3
- } from "./chunk-2577DKXB.js";
3
+ } from "./chunk-DC5QVPV7.js";
4
4
  import {
5
5
  assertRosterAuthenticated,
6
6
  assertRosterTagValid,
@@ -13,33 +13,40 @@ import {
13
13
  nextRosterEpoch,
14
14
  persistKeyring,
15
15
  readKeyringFile,
16
- requireRosterKey
17
- } from "./chunk-G56KBWFY.js";
16
+ requireRosterKey,
17
+ rotateKeys
18
+ } from "./chunk-M7NI3IWE.js";
18
19
  import {
19
20
  dekKey
20
- } from "./chunk-JMGDHKQF.js";
21
+ } from "./chunk-JCN44NCY.js";
21
22
  import {
22
23
  buildRecordAad,
23
24
  openEnvelopeJson
24
- } from "./chunk-77K4PG6P.js";
25
+ } from "./chunk-KJFW62P4.js";
25
26
  import {
26
27
  buildRecordEnvelope
27
- } from "./chunk-SZJ3DLZA.js";
28
+ } from "./chunk-SEE332EV.js";
28
29
  import {
29
30
  base64ToBuffer,
30
31
  bufferToBase64,
32
+ decryptBytes,
31
33
  deriveEchoKey,
32
34
  deriveKey,
33
35
  deriveSecretKey,
34
36
  encrypt,
37
+ encryptBytes,
38
+ exportDekSet,
39
+ generateRecoverySecret,
35
40
  generateSalt,
41
+ importDekSet,
36
42
  unwrapKey,
37
43
  wrapKey
38
- } from "./chunk-SL3JAAKN.js";
44
+ } from "./chunk-UYB234ZR.js";
39
45
  import {
40
46
  NOYDB_KEYRING_VERSION
41
- } from "./chunk-7MG7SJT7.js";
47
+ } from "./chunk-ODVPTDPK.js";
42
48
  import {
49
+ BLOB_ADDRESS_KEY_ID,
43
50
  DelegationTargetMissingError,
44
51
  InvalidKeyError,
45
52
  NoAccessError,
@@ -47,9 +54,10 @@ import {
47
54
  PrivilegeEscalationError,
48
55
  ROSTER_KEY_ID,
49
56
  RecoveryProfileNotImplementedError,
57
+ TamperedError,
50
58
  TeamNotEnabledError,
51
59
  ValidationError
52
- } from "./chunk-7O3Y4PPD.js";
60
+ } from "./chunk-244VXYPG.js";
53
61
 
54
62
  // src/port/with/team-strategy.ts
55
63
  var NO_TEAM = {
@@ -72,66 +80,30 @@ var NO_TEAM = {
72
80
 
73
81
  // src/with-party/team/wrapped-deks.ts
74
82
  var PBKDF2_ITERATIONS = 6e5;
75
- var SALT_BYTES = 32;
76
- var IV_BYTES = 12;
77
- var subtle = globalThis.crypto.subtle;
78
83
  async function mintWrappedDeksBlob(deks, credential) {
79
- const salt = crypto.getRandomValues(new Uint8Array(SALT_BYTES));
80
- const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
84
+ const salt = generateSalt();
81
85
  const wrappingKey = await deriveWrappingKey(credential, salt);
82
- const exported = {};
83
- for (const [coll, dek] of deks) {
84
- const raw = await subtle.exportKey("raw", dek);
85
- exported[coll] = bytesToBase64(new Uint8Array(raw));
86
- }
87
- const plaintext = new TextEncoder().encode(JSON.stringify({ deks: exported }));
88
- const ciphertext = await subtle.encrypt(
89
- { name: "AES-GCM", iv },
90
- wrappingKey,
91
- plaintext
92
- );
93
- return {
94
- salt: bytesToBase64(salt),
95
- iv: bytesToBase64(iv),
96
- wrappedDeks: bytesToBase64(new Uint8Array(ciphertext))
97
- };
86
+ const plaintext = new TextEncoder().encode(JSON.stringify({ deks: await exportDekSet(deks) }));
87
+ const { iv, data } = await encryptBytes(plaintext, wrappingKey);
88
+ return { salt: bufferToBase64(salt), iv, wrappedDeks: data };
98
89
  }
99
90
  async function unwrapDeksFromBlob(blob, credential) {
100
- const wrappingKey = await deriveWrappingKey(credential, base64ToBytes(blob.salt));
101
- const plaintext = await subtle.decrypt(
102
- { name: "AES-GCM", iv: base64ToBytes(blob.iv) },
103
- wrappingKey,
104
- base64ToBytes(blob.wrappedDeks)
105
- );
106
- const parsed = JSON.parse(new TextDecoder().decode(plaintext));
107
- const deks = /* @__PURE__ */ new Map();
108
- for (const [coll, b64] of Object.entries(parsed.deks)) {
109
- const raw = base64ToBytes(b64);
110
- const key = await subtle.importKey(
111
- "raw",
112
- raw,
113
- { name: "AES-GCM", length: 256 },
114
- true,
115
- ["encrypt", "decrypt"]
116
- );
117
- deks.set(coll, key);
91
+ const wrappingKey = await deriveWrappingKey(credential, base64ToBuffer(blob.salt));
92
+ let plaintext;
93
+ try {
94
+ plaintext = await decryptBytes(blob.iv, blob.wrappedDeks, wrappingKey);
95
+ } catch (e) {
96
+ if (e instanceof TamperedError) {
97
+ throw new InvalidKeyError("Wrapped DEK set did not open \u2014 the credential does not match this blob, or the blob is corrupted");
98
+ }
99
+ throw e;
118
100
  }
119
- return deks;
101
+ const parsed = JSON.parse(new TextDecoder().decode(plaintext));
102
+ return importDekSet(parsed.deks);
120
103
  }
121
104
  async function deriveWrappingKey(credential, salt) {
122
105
  return deriveSecretKey(credential, salt, { iterations: PBKDF2_ITERATIONS, keyUsage: "aes-gcm" });
123
106
  }
124
- function bytesToBase64(b) {
125
- let s = "";
126
- for (const x of b) s += String.fromCharCode(x);
127
- return btoa(s);
128
- }
129
- function base64ToBytes(b64) {
130
- const s = atob(b64);
131
- const out = new Uint8Array(s.length);
132
- for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
133
- return out;
134
- }
135
107
 
136
108
  // src/with-party/team/recovery.ts
137
109
  var PAPER_DOC_ID = "recovery-paper";
@@ -198,9 +170,9 @@ async function saveShamirRecoveryEntries(store, vault, entries) {
198
170
  await store.put(vault, "_meta", SHAMIR_DOC_ID, envelope);
199
171
  }
200
172
  async function mintShamirRecoveryEntry(provider, deks, entryId, k, n, label) {
201
- const recoverySecret = crypto.getRandomValues(new Uint8Array(32));
173
+ const recoverySecret = generateRecoverySecret();
202
174
  try {
203
- const credential = bytesToBase642(recoverySecret);
175
+ const credential = bufferToBase64(recoverySecret);
204
176
  const blob = await mintWrappedDeksBlob(deks, credential);
205
177
  const shareStrings = provider.splitToShares(recoverySecret, k, n);
206
178
  const entry = {
@@ -224,16 +196,11 @@ async function unwrapDeksFromShamirEntry(provider, entry, shareStrings) {
224
196
  }
225
197
  const secret = provider.combineShares(shareStrings);
226
198
  try {
227
- return await unwrapDeksFromBlob(entry, bytesToBase642(secret));
199
+ return await unwrapDeksFromBlob(entry, bufferToBase64(secret));
228
200
  } finally {
229
201
  secret.fill(0);
230
202
  }
231
203
  }
232
- function bytesToBase642(b) {
233
- let s = "";
234
- for (const x of b) s += String.fromCharCode(x);
235
- return btoa(s);
236
- }
237
204
  async function mintPaperRecoveryEntry(deks, code, codeId) {
238
205
  const blob = await mintWrappedDeksBlob(deks, code);
239
206
  return {
@@ -250,13 +217,13 @@ async function unwrapDeksFromPaperEntry(entry, code) {
250
217
  var MAGIC_LINK_GRANTS_COLLECTION = "_magic_link_grants";
251
218
  var MAGIC_LINK_CONTENT_INFO_PREFIX = "noydb-magic-link-content-v1:";
252
219
  async function deriveMagicLinkContentKey(serverSecret, token, vault) {
253
- const subtle2 = globalThis.crypto.subtle;
220
+ const subtle = globalThis.crypto.subtle;
254
221
  const ikmBytes = serverSecret instanceof Uint8Array ? serverSecret : new TextEncoder().encode(serverSecret);
255
222
  const tokenBytes = new TextEncoder().encode(token);
256
- const saltBuffer = await subtle2.digest("SHA-256", tokenBytes);
223
+ const saltBuffer = await subtle.digest("SHA-256", tokenBytes);
257
224
  const info = new TextEncoder().encode(MAGIC_LINK_CONTENT_INFO_PREFIX + vault);
258
- const ikm = await subtle2.importKey("raw", ikmBytes, "HKDF", false, ["deriveKey"]);
259
- return subtle2.deriveKey(
225
+ const ikm = await subtle.importKey("raw", ikmBytes, "HKDF", false, ["deriveKey"]);
226
+ return subtle.deriveKey(
260
227
  { name: "HKDF", hash: "SHA-256", salt: saltBuffer, info },
261
228
  ikm,
262
229
  { name: "AES-GCM", length: 256 },
@@ -471,7 +438,7 @@ async function recoverSecret(provider, store, vault, userId, input) {
471
438
  }
472
439
  throw new RecoveryProfileNotImplementedError(
473
440
  profile,
474
- "https://github.com/vLannaAi/noy-db/issues/196"
441
+ "https://github.com/noy-db/core/issues/196"
475
442
  );
476
443
  }
477
444
  async function recoverViaPaperCode(store, vault, userId, input) {
@@ -860,6 +827,7 @@ function sanitizeId(s) {
860
827
 
861
828
  // src/with-party/team/authenticators.ts
862
829
  async function enrollAuthenticator(store, vault, keyring, options) {
830
+ assertSlotListVisible(keyring, "enrollAuthenticator", vault);
863
831
  const existing = keyring.authenticators.find((a) => a.id === options.id);
864
832
  if (existing) {
865
833
  throw new ValidationError(
@@ -892,6 +860,7 @@ async function updateAuthenticator(store, vault, keyring, slotId, options) {
892
860
  `updateAuthenticator: at least one of meta must be provided (slotId: "${slotId}").`
893
861
  );
894
862
  }
863
+ assertSlotListVisible(keyring, "updateAuthenticator", vault);
895
864
  const idx = keyring.authenticators.findIndex((a) => a.id === slotId);
896
865
  if (idx === -1) {
897
866
  throw new NoAccessError(
@@ -918,7 +887,14 @@ async function updateAuthenticator(store, vault, keyring, slotId, options) {
918
887
  await persistKeyring(store, vault, nextKeyring);
919
888
  return nextKeyring;
920
889
  }
890
+ function assertSlotListVisible(keyring, op, vault) {
891
+ if (keyring.kek) return;
892
+ throw new ValidationError(
893
+ `${op}: keyring.kek is null, so the authenticator slot list for vault "${vault}" is not readable from this session and no slot decision can be made. This typically means the keyring was opened via tier-3 PIN resume, session restore, or a wrap-DEKs tier-2 unlock. Re-authenticate at tier 1 (secret) before enrolling, updating or removing a slot.`
894
+ );
895
+ }
921
896
  async function removeAuthenticator(store, vault, keyring, slotId) {
897
+ assertSlotListVisible(keyring, "removeAuthenticator", vault);
922
898
  const filtered = keyring.authenticators.filter((a) => a.id !== slotId);
923
899
  if (filtered.length === keyring.authenticators.length) {
924
900
  return keyring;
@@ -939,6 +915,20 @@ function appendSlot(keyring, slot) {
939
915
  authenticators: [...keyring.authenticators, slot]
940
916
  };
941
917
  }
918
+ async function revokeAuthenticator(store, vault, keyring, options) {
919
+ const next = await removeAuthenticator(store, vault, keyring, options.slotId);
920
+ const collections = new Set(next.deks.keys());
921
+ collections.delete(ROSTER_KEY_ID);
922
+ collections.delete(BLOB_ADDRESS_KEY_ID);
923
+ if (collections.size > 0) {
924
+ await rotateKeys(store, vault, next, { collections: [...collections] });
925
+ }
926
+ return rotateSecret(store, vault, next.userId, {
927
+ oldSecret: options.secret,
928
+ newSecret: options.secret,
929
+ ...options.slotCeremonies !== void 0 && { slotCeremonies: options.slotCeremonies }
930
+ });
931
+ }
942
932
 
943
933
  export {
944
934
  NO_TEAM,
@@ -973,6 +963,7 @@ export {
973
963
  enrollAuthenticator,
974
964
  updateAuthenticator,
975
965
  removeAuthenticator,
976
- findAuthenticator
966
+ findAuthenticator,
967
+ revokeAuthenticator
977
968
  };
978
- //# sourceMappingURL=chunk-RRNRNANG.js.map
969
+ //# sourceMappingURL=chunk-ZE4CHIED.js.map