@noy-db/hub 0.2.0-pre.3 → 0.2.0-pre.31

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 (384) hide show
  1. package/README.md +126 -0
  2. package/dist/adapter/index.d.ts +9 -0
  3. package/dist/adapter/index.js +14 -0
  4. package/dist/aggregate/index.d.ts +3 -2
  5. package/dist/aggregate/index.js +10 -8
  6. package/dist/aggregate/index.js.map +1 -1
  7. package/dist/attestation/index.d.ts +7 -5
  8. package/dist/attestation/index.js +7 -6
  9. package/dist/attestation/index.js.map +1 -1
  10. package/dist/blobs/index.d.ts +9 -7
  11. package/dist/blobs/index.js +12 -6
  12. package/dist/blobs/index.js.map +1 -1
  13. package/dist/bundle/index.d.ts +29 -18
  14. package/dist/bundle/index.js +53 -192
  15. package/dist/bundle/index.js.map +1 -1
  16. package/dist/{chunk-75QDHSE4.js → chunk-2QDWRK3B.js} +5 -5
  17. package/dist/{chunk-74JEQFMT.js → chunk-2UT7HJJR.js} +5 -5
  18. package/dist/chunk-2UT7HJJR.js.map +1 -0
  19. package/dist/{chunk-FCDO7UAO.js → chunk-2ZYIN3BL.js} +2 -2
  20. package/dist/{chunk-BFI3RS42.js → chunk-33EQCZXE.js} +2 -2
  21. package/dist/chunk-33EQCZXE.js.map +1 -0
  22. package/dist/{chunk-WRLHNG6H.js → chunk-4K4QKYK4.js} +4 -4
  23. package/dist/chunk-4K4QKYK4.js.map +1 -0
  24. package/dist/{chunk-HGZ7DC5H.js → chunk-4L6N56B4.js} +2 -2
  25. package/dist/chunk-4L6N56B4.js.map +1 -0
  26. package/dist/{chunk-YMYK7US4.js → chunk-4YD7VZH4.js} +2 -2
  27. package/dist/chunk-4YD7VZH4.js.map +1 -0
  28. package/dist/{chunk-ZUMGGHRB.js → chunk-5PTX7PKD.js} +4 -4
  29. package/dist/{chunk-QAU5HM6Q.js → chunk-6EKRQ7QF.js} +3 -3
  30. package/dist/{chunk-ZC2AAE6J.js → chunk-7GPQPLGO.js} +19 -4
  31. package/dist/chunk-7GPQPLGO.js.map +1 -0
  32. package/dist/{chunk-EPK6A3WJ.js → chunk-A3JMGXPG.js} +2 -2
  33. package/dist/chunk-A3JMGXPG.js.map +1 -0
  34. package/dist/{chunk-FXQYZNOW.js → chunk-A7DNZVAV.js} +1 -1
  35. package/dist/chunk-A7DNZVAV.js.map +1 -0
  36. package/dist/{chunk-UMLVJTYV.js → chunk-ADB7GPM3.js} +7 -4
  37. package/dist/chunk-ADB7GPM3.js.map +1 -0
  38. package/dist/{chunk-YL2DR3HY.js → chunk-ASIGWYRA.js} +2 -2
  39. package/dist/chunk-ASIGWYRA.js.map +1 -0
  40. package/dist/{chunk-2EYC3WDT.js → chunk-AWU4JF7C.js} +93 -93
  41. package/dist/chunk-AWU4JF7C.js.map +1 -0
  42. package/dist/chunk-BEZ2EV43.js +129 -0
  43. package/dist/chunk-BEZ2EV43.js.map +1 -0
  44. package/dist/{chunk-IS5HWQO7.js → chunk-CIZDUAHI.js} +30 -4
  45. package/dist/chunk-CIZDUAHI.js.map +1 -0
  46. package/dist/{chunk-4OQWR46B.js → chunk-CUPTCF4R.js} +5 -5
  47. package/dist/chunk-CUPTCF4R.js.map +1 -0
  48. package/dist/{chunk-5ZGZ6HIZ.js → chunk-DEE4CRYN.js} +30 -7
  49. package/dist/chunk-DEE4CRYN.js.map +1 -0
  50. package/dist/{chunk-UOF74WQY.js → chunk-E2MDPPOC.js} +37 -2
  51. package/dist/chunk-E2MDPPOC.js.map +1 -0
  52. package/dist/{chunk-SAVQ6E2O.js → chunk-FFKQ65YX.js} +10 -3
  53. package/dist/chunk-FFKQ65YX.js.map +1 -0
  54. package/dist/{chunk-2XLVPKXG.js → chunk-G7ALNCQH.js} +10 -2
  55. package/dist/chunk-G7ALNCQH.js.map +1 -0
  56. package/dist/chunk-GGXN73NM.js +252 -0
  57. package/dist/chunk-GGXN73NM.js.map +1 -0
  58. package/dist/{chunk-UVPGJXVO.js → chunk-JOJPBZSZ.js} +5 -5
  59. package/dist/{chunk-YDLAFP36.js → chunk-JZ5DS4DP.js} +346 -3
  60. package/dist/chunk-JZ5DS4DP.js.map +1 -0
  61. package/dist/{chunk-KMI2NBBF.js → chunk-K4JID2ZE.js} +44 -8
  62. package/dist/chunk-K4JID2ZE.js.map +1 -0
  63. package/dist/{aggregate/index.cjs → chunk-K6NVSHAH.js} +241 -210
  64. package/dist/chunk-K6NVSHAH.js.map +1 -0
  65. package/dist/chunk-KJ3K5VZM.js +524 -0
  66. package/dist/chunk-KJ3K5VZM.js.map +1 -0
  67. package/dist/chunk-L5HHBOMS.js +232 -0
  68. package/dist/chunk-L5HHBOMS.js.map +1 -0
  69. package/dist/{chunk-YK72A4IT.js → chunk-LBILABKZ.js} +4 -4
  70. package/dist/chunk-LXKBG52H.js +151 -0
  71. package/dist/chunk-LXKBG52H.js.map +1 -0
  72. package/dist/{chunk-NGSPBLLE.js → chunk-MPIZQGFA.js} +50 -20
  73. package/dist/chunk-MPIZQGFA.js.map +1 -0
  74. package/dist/{chunk-4X2S7PBF.js → chunk-MRJPSXPE.js} +84 -70
  75. package/dist/chunk-MRJPSXPE.js.map +1 -0
  76. package/dist/{chunk-6S3LLAQ5.js → chunk-MSMDDDDJ.js} +3 -3
  77. package/dist/{chunk-6S3LLAQ5.js.map → chunk-MSMDDDDJ.js.map} +1 -1
  78. package/dist/{chunk-GAUBWHAF.js → chunk-OCYFFBZS.js} +4 -4
  79. package/dist/{chunk-NCO2JGKK.js → chunk-PDVP3C2I.js} +1 -1
  80. package/dist/chunk-PDVP3C2I.js.map +1 -0
  81. package/dist/chunk-PZ5AY32C.js +10 -0
  82. package/dist/{chunk-P6256WTJ.js → chunk-QBLPY44S.js} +3 -3
  83. package/dist/chunk-QBLPY44S.js.map +1 -0
  84. package/dist/{query/index.cjs → chunk-QGBBQKDS.js} +706 -831
  85. package/dist/chunk-QGBBQKDS.js.map +1 -0
  86. package/dist/{chunk-FS7A4XNF.js → chunk-QWJCNXH2.js} +3 -3
  87. package/dist/chunk-QXWJQ7UU.js +380 -0
  88. package/dist/chunk-QXWJQ7UU.js.map +1 -0
  89. package/dist/{chunk-GDTCGIPX.js → chunk-RCB6GWTC.js} +27 -5
  90. package/dist/chunk-RCB6GWTC.js.map +1 -0
  91. package/dist/{chunk-K5PVGKE4.js → chunk-SAAJYSVV.js} +2 -2
  92. package/dist/{chunk-G7PAZ3TD.js → chunk-SHJ3BRTZ.js} +46 -10
  93. package/dist/chunk-SHJ3BRTZ.js.map +1 -0
  94. package/dist/chunk-SQXTKZL7.js +125 -0
  95. package/dist/chunk-SQXTKZL7.js.map +1 -0
  96. package/dist/chunk-STNPB3UM.js +9 -0
  97. package/dist/chunk-STNPB3UM.js.map +1 -0
  98. package/dist/{chunk-NSLTPGEN.js → chunk-TMUMMAWV.js} +12 -2
  99. package/dist/{chunk-NSLTPGEN.js.map → chunk-TMUMMAWV.js.map} +1 -1
  100. package/dist/{chunk-LS3JLEIB.js → chunk-TZGWI5AX.js} +4 -4
  101. package/dist/{chunk-GD3BGKAR.js → chunk-UBF5JEOJ.js} +44 -5
  102. package/dist/chunk-UBF5JEOJ.js.map +1 -0
  103. package/dist/{chunk-T6HQMVML.js → chunk-W5NVNJDX.js} +5250 -801
  104. package/dist/chunk-W5NVNJDX.js.map +1 -0
  105. package/dist/chunk-XAYDHD2O.js +123 -0
  106. package/dist/chunk-XAYDHD2O.js.map +1 -0
  107. package/dist/{chunk-LOL725S4.js → chunk-XYW2CSCI.js} +31 -3
  108. package/dist/chunk-XYW2CSCI.js.map +1 -0
  109. package/dist/{chunk-TLFUDXVV.js → chunk-ZCMOS4H2.js} +31 -10
  110. package/dist/chunk-ZCMOS4H2.js.map +1 -0
  111. package/dist/{chunk-FBMXWVGP.js → chunk-ZK66B5EY.js} +450 -30
  112. package/dist/chunk-ZK66B5EY.js.map +1 -0
  113. package/dist/{chunk-GVXBHCZ2.js → chunk-ZPJSQPQH.js} +66 -7
  114. package/dist/chunk-ZPJSQPQH.js.map +1 -0
  115. package/dist/consent/index.d.ts +8 -6
  116. package/dist/consent/index.js +4 -3
  117. package/dist/consent/index.js.map +1 -1
  118. package/dist/crdt/index.js +1 -0
  119. package/dist/crdt/index.js.map +1 -1
  120. package/dist/{crypto-H2Y3DDFW.js → crypto-OSIV2IIW.js} +8 -3
  121. package/dist/{ulid-CiM2OAeM.d.ts → decrypt-partition-CXS5KopB.d.ts} +37 -82
  122. package/dist/{delegation-QSC7G5QC.js → delegation-BQTRJATI.js} +6 -5
  123. package/dist/derivations/index.d.ts +11 -9
  124. package/dist/derivations/index.js +9 -6
  125. package/dist/{dev-unlock-Cf2B7Kih.d.ts → dev-unlock-CnHTTVea.d.ts} +1 -1
  126. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  127. package/dist/errors-BAWO5Z5a.d.ts +1500 -0
  128. package/dist/executor-KYSKFJ2R.js +9 -0
  129. package/dist/executor-M7W3NEKR.js +9 -0
  130. package/dist/executor-VDTDGWO6.js +13 -0
  131. package/dist/{fanout-sidecar-NRBWSLRK.js → fanout-sidecar-AZALISHB.js} +3 -2
  132. package/dist/fanout-sidecar-AZALISHB.js.map +1 -0
  133. package/dist/forget/index.d.ts +1 -0
  134. package/dist/forget/index.js +15 -0
  135. package/dist/guards/index.d.ts +16 -8
  136. package/dist/guards/index.js +12 -5
  137. package/dist/{hash-gVn_uKhp.d.ts → hash-oc5paYl0.d.ts} +1 -1
  138. package/dist/history/index.d.ts +9 -7
  139. package/dist/history/index.js +10 -7
  140. package/dist/history/index.js.map +1 -1
  141. package/dist/i18n/index.d.ts +8 -6
  142. package/dist/i18n/index.js +116 -15
  143. package/dist/i18n/index.js.map +1 -1
  144. package/dist/index-BMmajblo.d.ts +362 -0
  145. package/dist/index-BmhGztUi.d.ts +93 -0
  146. package/dist/{types-D9eB0Rvh.d.ts → index-DHn9lEP0.d.ts} +4305 -1523
  147. package/dist/{index-BF1B2HB9.d.ts → index-Ddm8D3Oo.d.ts} +186 -1151
  148. package/dist/index.d.ts +342 -70
  149. package/dist/index.js +420 -112
  150. package/dist/index.js.map +1 -1
  151. package/dist/indexing/index.d.ts +3 -3
  152. package/dist/indexing/index.js +5 -4
  153. package/dist/indexing/index.js.map +1 -1
  154. package/dist/issue-DPHRF2TI.js +13 -0
  155. package/dist/kernel/index.d.ts +11 -0
  156. package/dist/kernel/index.js +50 -0
  157. package/dist/{lazy-builder-Rpd-V3jP.d.ts → lazy-builder-ChSqcF5t.d.ts} +2 -2
  158. package/dist/{ledger-WOEJUYTP.js → ledger-CI7GSMLB.js} +7 -6
  159. package/dist/materialized-views/index.d.ts +23 -20
  160. package/dist/materialized-views/index.js +9 -7
  161. package/dist/mime-magic-JeLKHRng.d.ts +103 -0
  162. package/dist/noydb-NAU2DTFP.js +40 -0
  163. package/dist/overlay-views/index.d.ts +32 -12
  164. package/dist/overlay-views/index.js +7 -6
  165. package/dist/periods/index.d.ts +8 -6
  166. package/dist/periods/index.js +7 -6
  167. package/dist/{predicate-Dnu81tsS.d.cts → predicate-BmhBSPCH.d.ts} +87 -5
  168. package/dist/{public-envelope-OHQ5UZFM.js → public-envelope-MFMBFJLZ.js} +5 -4
  169. package/dist/query/index.d.ts +4 -3
  170. package/dist/query/index.js +14 -6
  171. package/dist/read-only-facade-3OQRZ3VS.js +8 -0
  172. package/dist/registry-IX5WKK4F.js +8 -0
  173. package/dist/registry-LMHO5265.js +11 -0
  174. package/dist/registry-TXCKWH26.js +9 -0
  175. package/dist/registry-VFEDQSYV.js +9 -0
  176. package/dist/revoke-5PUOZPJJ.js +18 -0
  177. package/dist/revoke-5PUOZPJJ.js.map +1 -0
  178. package/dist/sealed-record/index.d.ts +123 -0
  179. package/dist/sealed-record/index.js +43 -0
  180. package/dist/sealed-record/index.js.map +1 -0
  181. package/dist/session/index.d.ts +9 -7
  182. package/dist/session/index.js +4 -3
  183. package/dist/session/index.js.map +1 -1
  184. package/dist/shadow/index.d.ts +8 -6
  185. package/dist/shadow/index.js +3 -2
  186. package/dist/shadow/index.js.map +1 -1
  187. package/dist/{signer-M4K5HBLD.js → signer-UB5TQOZ6.js} +6 -5
  188. package/dist/signer-UB5TQOZ6.js.map +1 -0
  189. package/dist/snapshots/index.d.ts +30 -0
  190. package/dist/snapshots/index.js +153 -0
  191. package/dist/snapshots/index.js.map +1 -0
  192. package/dist/{stale-PAGCS4K5.js → stale-J3TUF5C5.js} +3 -2
  193. package/dist/stale-J3TUF5C5.js.map +1 -0
  194. package/dist/store/index.d.ts +15 -6
  195. package/dist/store/index.js +3 -2
  196. package/dist/{strategy-DSTrsZ8t.d.ts → strategy-8QGs5KQE.d.ts} +475 -7
  197. package/dist/sync/index.d.ts +7 -5
  198. package/dist/sync/index.js +5 -4
  199. package/dist/sync/index.js.map +1 -1
  200. package/dist/team/index.d.ts +8 -6
  201. package/dist/team/index.js +9 -8
  202. package/dist/transition-guard-Dy3NioQr.d.ts +165 -0
  203. package/dist/tx/index.d.ts +26 -8
  204. package/dist/tx/index.js +10 -5
  205. package/dist/tx/index.js.map +1 -1
  206. package/dist/ulid-DRH25k3y.d.ts +66 -0
  207. package/dist/{ulid-COREQ2RQ.js → ulid-KEPZMD2N.js} +2 -1
  208. package/dist/ulid-KEPZMD2N.js.map +1 -0
  209. package/dist/util/index.d.ts +2 -0
  210. package/dist/util/index.js +6 -1
  211. package/dist/util/index.js.map +1 -1
  212. package/dist/{with-materialized-view-qtoJ3xKJ.d.ts → with-materialized-view-DIVeez0W.d.ts} +2 -2
  213. package/dist/{with-overlayed-view-DFaRfgMr.d.ts → with-overlayed-view-DVZrc5Hb.d.ts} +2 -2
  214. package/dist/with-rollup-CbU-O4wP.d.ts +47 -0
  215. package/dist/zod-HAJM7LMS.js +14763 -0
  216. package/dist/zod-HAJM7LMS.js.map +1 -0
  217. package/package.json +73 -191
  218. package/dist/aggregate/index.cjs.map +0 -1
  219. package/dist/aggregate/index.d.cts +0 -38
  220. package/dist/attestation/index.cjs +0 -305
  221. package/dist/attestation/index.cjs.map +0 -1
  222. package/dist/attestation/index.d.cts +0 -52
  223. package/dist/blobs/index.cjs +0 -1480
  224. package/dist/blobs/index.cjs.map +0 -1
  225. package/dist/blobs/index.d.cts +0 -46
  226. package/dist/bundle/index.cjs +0 -18561
  227. package/dist/bundle/index.cjs.map +0 -1
  228. package/dist/bundle/index.d.cts +0 -176
  229. package/dist/chunk-2EYC3WDT.js.map +0 -1
  230. package/dist/chunk-2XLVPKXG.js.map +0 -1
  231. package/dist/chunk-4OQWR46B.js.map +0 -1
  232. package/dist/chunk-4UBOTYP5.js +0 -1367
  233. package/dist/chunk-4UBOTYP5.js.map +0 -1
  234. package/dist/chunk-4X2S7PBF.js.map +0 -1
  235. package/dist/chunk-5YHWBPOT.js +0 -19
  236. package/dist/chunk-5YHWBPOT.js.map +0 -1
  237. package/dist/chunk-5ZGZ6HIZ.js.map +0 -1
  238. package/dist/chunk-74JEQFMT.js.map +0 -1
  239. package/dist/chunk-A6SWRXUQ.js +0 -118
  240. package/dist/chunk-A6SWRXUQ.js.map +0 -1
  241. package/dist/chunk-BFI3RS42.js.map +0 -1
  242. package/dist/chunk-EMEX37ZN.js +0 -51
  243. package/dist/chunk-EMEX37ZN.js.map +0 -1
  244. package/dist/chunk-EPK6A3WJ.js.map +0 -1
  245. package/dist/chunk-FBMXWVGP.js.map +0 -1
  246. package/dist/chunk-FXQYZNOW.js.map +0 -1
  247. package/dist/chunk-G7PAZ3TD.js.map +0 -1
  248. package/dist/chunk-GD3BGKAR.js.map +0 -1
  249. package/dist/chunk-GDTCGIPX.js.map +0 -1
  250. package/dist/chunk-GVXBHCZ2.js.map +0 -1
  251. package/dist/chunk-HGZ7DC5H.js.map +0 -1
  252. package/dist/chunk-IS5HWQO7.js.map +0 -1
  253. package/dist/chunk-KMI2NBBF.js.map +0 -1
  254. package/dist/chunk-KYKMKLJ6.js +0 -340
  255. package/dist/chunk-KYKMKLJ6.js.map +0 -1
  256. package/dist/chunk-LOL725S4.js.map +0 -1
  257. package/dist/chunk-MRIBLZL3.js +0 -86
  258. package/dist/chunk-MRIBLZL3.js.map +0 -1
  259. package/dist/chunk-NCO2JGKK.js.map +0 -1
  260. package/dist/chunk-NGSPBLLE.js.map +0 -1
  261. package/dist/chunk-P6256WTJ.js.map +0 -1
  262. package/dist/chunk-SAVQ6E2O.js.map +0 -1
  263. package/dist/chunk-T6HQMVML.js.map +0 -1
  264. package/dist/chunk-TLFUDXVV.js.map +0 -1
  265. package/dist/chunk-UMLVJTYV.js.map +0 -1
  266. package/dist/chunk-UOF74WQY.js.map +0 -1
  267. package/dist/chunk-WRLHNG6H.js.map +0 -1
  268. package/dist/chunk-YDLAFP36.js.map +0 -1
  269. package/dist/chunk-YL2DR3HY.js.map +0 -1
  270. package/dist/chunk-YMYK7US4.js.map +0 -1
  271. package/dist/chunk-ZC2AAE6J.js.map +0 -1
  272. package/dist/consent/index.cjs +0 -204
  273. package/dist/consent/index.cjs.map +0 -1
  274. package/dist/consent/index.d.cts +0 -25
  275. package/dist/crdt/index.cjs +0 -152
  276. package/dist/crdt/index.cjs.map +0 -1
  277. package/dist/crdt/index.d.cts +0 -30
  278. package/dist/derivations/index.cjs +0 -351
  279. package/dist/derivations/index.cjs.map +0 -1
  280. package/dist/derivations/index.d.cts +0 -72
  281. package/dist/dev-unlock-De3mjQWv.d.cts +0 -263
  282. package/dist/executor-BZKFZVRC.js +0 -8
  283. package/dist/executor-GFZFDQXV.js +0 -8
  284. package/dist/executor-KT2IOZVP.js +0 -11
  285. package/dist/fanout-sidecar-NRBWSLRK.js.map +0 -1
  286. package/dist/guards/index.cjs +0 -322
  287. package/dist/guards/index.cjs.map +0 -1
  288. package/dist/guards/index.d.cts +0 -31
  289. package/dist/hash-vBCB0-Ps.d.cts +0 -63
  290. package/dist/history/index.cjs +0 -1222
  291. package/dist/history/index.cjs.map +0 -1
  292. package/dist/history/index.d.cts +0 -63
  293. package/dist/i18n/index.cjs +0 -840
  294. package/dist/i18n/index.cjs.map +0 -1
  295. package/dist/i18n/index.d.cts +0 -39
  296. package/dist/index-DVkvrgpm.d.cts +0 -2290
  297. package/dist/index.cjs +0 -23590
  298. package/dist/index.cjs.map +0 -1
  299. package/dist/index.d.cts +0 -778
  300. package/dist/indexing/index.cjs +0 -738
  301. package/dist/indexing/index.cjs.map +0 -1
  302. package/dist/indexing/index.d.cts +0 -36
  303. package/dist/issue-BAJ7ZB4S.js +0 -12
  304. package/dist/lazy-builder-C-rPfWG0.d.cts +0 -304
  305. package/dist/materialized-views/index.cjs +0 -837
  306. package/dist/materialized-views/index.cjs.map +0 -1
  307. package/dist/materialized-views/index.d.cts +0 -184
  308. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  309. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  310. package/dist/noydb-XNQSKXGO.js +0 -34
  311. package/dist/overlay-views/index.cjs +0 -359
  312. package/dist/overlay-views/index.cjs.map +0 -1
  313. package/dist/overlay-views/index.d.cts +0 -82
  314. package/dist/periods/index.cjs +0 -1041
  315. package/dist/periods/index.cjs.map +0 -1
  316. package/dist/periods/index.d.cts +0 -22
  317. package/dist/predicate-Dnu81tsS.d.ts +0 -185
  318. package/dist/query/index.cjs.map +0 -1
  319. package/dist/query/index.d.cts +0 -3
  320. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  321. package/dist/registry-2IEARCGT.js +0 -7
  322. package/dist/registry-CDHASH73.js +0 -10
  323. package/dist/registry-EMGLZGR6.js +0 -8
  324. package/dist/registry-NQALYR77.js +0 -8
  325. package/dist/revoke-7JOVLZFD.js +0 -17
  326. package/dist/session/index.cjs +0 -495
  327. package/dist/session/index.cjs.map +0 -1
  328. package/dist/session/index.d.cts +0 -46
  329. package/dist/shadow/index.cjs +0 -133
  330. package/dist/shadow/index.cjs.map +0 -1
  331. package/dist/shadow/index.d.cts +0 -17
  332. package/dist/store/index.cjs +0 -1083
  333. package/dist/store/index.cjs.map +0 -1
  334. package/dist/store/index.d.cts +0 -492
  335. package/dist/strategy-BSxFXGzb.d.cts +0 -110
  336. package/dist/strategy-DSTrsZ8t.d.cts +0 -601
  337. package/dist/sync/index.cjs +0 -1062
  338. package/dist/sync/index.cjs.map +0 -1
  339. package/dist/sync/index.d.cts +0 -43
  340. package/dist/team/index.cjs +0 -2798
  341. package/dist/team/index.cjs.map +0 -1
  342. package/dist/team/index.d.cts +0 -118
  343. package/dist/tx/index.cjs +0 -544
  344. package/dist/tx/index.cjs.map +0 -1
  345. package/dist/tx/index.d.cts +0 -21
  346. package/dist/types-CSLcfytP.d.cts +0 -12493
  347. package/dist/ulid-CG2YvAbg.d.cts +0 -603
  348. package/dist/util/index.cjs +0 -230
  349. package/dist/util/index.cjs.map +0 -1
  350. package/dist/util/index.d.cts +0 -77
  351. package/dist/with-derivation-Bzpj6UTv.d.ts +0 -13
  352. package/dist/with-derivation-DWajFh4K.d.cts +0 -13
  353. package/dist/with-guard-DF_Ul3DT.d.cts +0 -18
  354. package/dist/with-guard-DR7U-l4v.d.ts +0 -18
  355. package/dist/with-materialized-view-_piodoIz.d.cts +0 -27
  356. package/dist/with-overlayed-view-DwzCKxn2.d.cts +0 -13
  357. /package/dist/{crypto-H2Y3DDFW.js.map → adapter/index.js.map} +0 -0
  358. /package/dist/{chunk-75QDHSE4.js.map → chunk-2QDWRK3B.js.map} +0 -0
  359. /package/dist/{chunk-FCDO7UAO.js.map → chunk-2ZYIN3BL.js.map} +0 -0
  360. /package/dist/{chunk-ZUMGGHRB.js.map → chunk-5PTX7PKD.js.map} +0 -0
  361. /package/dist/{chunk-QAU5HM6Q.js.map → chunk-6EKRQ7QF.js.map} +0 -0
  362. /package/dist/{chunk-UVPGJXVO.js.map → chunk-JOJPBZSZ.js.map} +0 -0
  363. /package/dist/{chunk-YK72A4IT.js.map → chunk-LBILABKZ.js.map} +0 -0
  364. /package/dist/{chunk-GAUBWHAF.js.map → chunk-OCYFFBZS.js.map} +0 -0
  365. /package/dist/{delegation-QSC7G5QC.js.map → chunk-PZ5AY32C.js.map} +0 -0
  366. /package/dist/{chunk-FS7A4XNF.js.map → chunk-QWJCNXH2.js.map} +0 -0
  367. /package/dist/{chunk-K5PVGKE4.js.map → chunk-SAAJYSVV.js.map} +0 -0
  368. /package/dist/{chunk-LS3JLEIB.js.map → chunk-TZGWI5AX.js.map} +0 -0
  369. /package/dist/{executor-BZKFZVRC.js.map → crypto-OSIV2IIW.js.map} +0 -0
  370. /package/dist/{executor-GFZFDQXV.js.map → delegation-BQTRJATI.js.map} +0 -0
  371. /package/dist/{executor-KT2IOZVP.js.map → executor-KYSKFJ2R.js.map} +0 -0
  372. /package/dist/{issue-BAJ7ZB4S.js.map → executor-M7W3NEKR.js.map} +0 -0
  373. /package/dist/{ledger-WOEJUYTP.js.map → executor-VDTDGWO6.js.map} +0 -0
  374. /package/dist/{noydb-XNQSKXGO.js.map → forget/index.js.map} +0 -0
  375. /package/dist/{public-envelope-OHQ5UZFM.js.map → issue-DPHRF2TI.js.map} +0 -0
  376. /package/dist/{read-only-facade-ITU6L7BL.js.map → kernel/index.js.map} +0 -0
  377. /package/dist/{registry-2IEARCGT.js.map → ledger-CI7GSMLB.js.map} +0 -0
  378. /package/dist/{registry-CDHASH73.js.map → noydb-NAU2DTFP.js.map} +0 -0
  379. /package/dist/{registry-EMGLZGR6.js.map → public-envelope-MFMBFJLZ.js.map} +0 -0
  380. /package/dist/{registry-NQALYR77.js.map → read-only-facade-3OQRZ3VS.js.map} +0 -0
  381. /package/dist/{revoke-7JOVLZFD.js.map → registry-IX5WKK4F.js.map} +0 -0
  382. /package/dist/{signer-M4K5HBLD.js.map → registry-LMHO5265.js.map} +0 -0
  383. /package/dist/{stale-PAGCS4K5.js.map → registry-TXCKWH26.js.map} +0 -0
  384. /package/dist/{ulid-COREQ2RQ.js.map → registry-VFEDQSYV.js.map} +0 -0
@@ -1,738 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/indexing/index.ts
21
- var indexing_exports = {};
22
- __export(indexing_exports, {
23
- COMPOSITE_DELIMITER: () => COMPOSITE_DELIMITER,
24
- CollectionIndexes: () => CollectionIndexes,
25
- IDX_PREFIX: () => IDX_PREFIX,
26
- LazyQuery: () => LazyQuery,
27
- PersistedCollectionIndex: () => PersistedCollectionIndex,
28
- compositeKey: () => compositeKey,
29
- decodeIdxId: () => decodeIdxId,
30
- encodeIdxId: () => encodeIdxId,
31
- isIdxId: () => isIdxId,
32
- withIndexing: () => withIndexing
33
- });
34
- module.exports = __toCommonJS(indexing_exports);
35
-
36
- // src/query/predicate.ts
37
- function readPath(record, path) {
38
- if (record === null || record === void 0) return void 0;
39
- if (!path.includes(".")) {
40
- return record[path];
41
- }
42
- const segments = path.split(".");
43
- let cursor = record;
44
- for (const segment of segments) {
45
- if (cursor === null || cursor === void 0) return void 0;
46
- cursor = cursor[segment];
47
- }
48
- return cursor;
49
- }
50
- function evaluateFieldClause(record, clause) {
51
- const actual = readPath(record, clause.field);
52
- const { op, value } = clause;
53
- switch (op) {
54
- case "==":
55
- return actual === value;
56
- case "!=":
57
- return actual !== value;
58
- case "<":
59
- return isComparable(actual, value) && actual < value;
60
- case "<=":
61
- return isComparable(actual, value) && actual <= value;
62
- case ">":
63
- return isComparable(actual, value) && actual > value;
64
- case ">=":
65
- return isComparable(actual, value) && actual >= value;
66
- case "in":
67
- return Array.isArray(value) && value.includes(actual);
68
- case "contains":
69
- if (typeof actual === "string") return typeof value === "string" && actual.includes(value);
70
- if (Array.isArray(actual)) return actual.includes(value);
71
- return false;
72
- case "startsWith":
73
- return typeof actual === "string" && typeof value === "string" && actual.startsWith(value);
74
- case "between": {
75
- if (!Array.isArray(value) || value.length !== 2) return false;
76
- const [lo, hi] = value;
77
- if (!isComparable(actual, lo) || !isComparable(actual, hi)) return false;
78
- return actual >= lo && actual <= hi;
79
- }
80
- default: {
81
- const _exhaustive = op;
82
- void _exhaustive;
83
- return false;
84
- }
85
- }
86
- }
87
- function isComparable(a, b) {
88
- if (typeof a === "number" && typeof b === "number") return true;
89
- if (typeof a === "string" && typeof b === "string") return true;
90
- if (a instanceof Date && b instanceof Date) return true;
91
- return false;
92
- }
93
- function evaluateClause(record, clause) {
94
- switch (clause.type) {
95
- case "field":
96
- return evaluateFieldClause(record, clause);
97
- case "filter":
98
- return clause.fn(record);
99
- case "wherePredicate":
100
- return clause.fn(record, clause.ctx);
101
- case "group":
102
- if (clause.op === "and") {
103
- for (const child of clause.clauses) {
104
- if (!evaluateClause(record, child)) return false;
105
- }
106
- return true;
107
- } else {
108
- for (const child of clause.clauses) {
109
- if (evaluateClause(record, child)) return true;
110
- }
111
- return false;
112
- }
113
- }
114
- }
115
-
116
- // src/indexing/eager-indexes.ts
117
- var CollectionIndexes = class {
118
- indexes = /* @__PURE__ */ new Map();
119
- /**
120
- * Declare an index. Subsequent record additions are tracked under it.
121
- * Calling this twice for the same field is a no-op (idempotent).
122
- */
123
- declare(field) {
124
- if (this.indexes.has(field)) return;
125
- this.indexes.set(field, { field, buckets: /* @__PURE__ */ new Map() });
126
- }
127
- /** True if the given field has a declared index. */
128
- has(field) {
129
- return this.indexes.has(field);
130
- }
131
- /** All declared field names, in declaration order. */
132
- fields() {
133
- return [...this.indexes.keys()];
134
- }
135
- /**
136
- * Build all declared indexes from a snapshot of records.
137
- * Called once per hydration. O(N × indexes.size).
138
- */
139
- build(records) {
140
- for (const idx of this.indexes.values()) {
141
- idx.buckets.clear();
142
- for (const { id, record } of records) {
143
- addToIndex(idx, id, record);
144
- }
145
- }
146
- }
147
- /**
148
- * Insert or update a single record across all indexes.
149
- * Called by `Collection.put()` after the encrypted write succeeds.
150
- *
151
- * If `previousRecord` is provided, the record is removed from any old
152
- * buckets first — this is the update path. Pass `null` for fresh adds.
153
- */
154
- upsert(id, newRecord, previousRecord) {
155
- if (this.indexes.size === 0) return;
156
- if (previousRecord !== null) {
157
- this.remove(id, previousRecord);
158
- }
159
- for (const idx of this.indexes.values()) {
160
- addToIndex(idx, id, newRecord);
161
- }
162
- }
163
- /**
164
- * Remove a record from all indexes. Called by `Collection.delete()`
165
- * (and as the first half of `upsert` for the update path).
166
- */
167
- remove(id, record) {
168
- if (this.indexes.size === 0) return;
169
- for (const idx of this.indexes.values()) {
170
- removeFromIndex(idx, id, record);
171
- }
172
- }
173
- /** Drop all index data. Called when the collection is invalidated. */
174
- clear() {
175
- for (const idx of this.indexes.values()) {
176
- idx.buckets.clear();
177
- }
178
- }
179
- /**
180
- * Equality lookup: return the set of record ids whose `field` matches
181
- * the given value. Returns `null` if no index covers the field — the
182
- * caller should fall back to a linear scan.
183
- *
184
- * The returned Set is a reference to the index's internal storage —
185
- * callers must NOT mutate it.
186
- */
187
- lookupEqual(field, value) {
188
- const idx = this.indexes.get(field);
189
- if (!idx) return null;
190
- const key = stringifyKey(value);
191
- return idx.buckets.get(key) ?? EMPTY_SET;
192
- }
193
- /**
194
- * Set lookup: return the union of record ids whose `field` matches any
195
- * of the given values. Returns `null` if no index covers the field.
196
- */
197
- lookupIn(field, values) {
198
- const idx = this.indexes.get(field);
199
- if (!idx) return null;
200
- const out = /* @__PURE__ */ new Set();
201
- for (const value of values) {
202
- const key = stringifyKey(value);
203
- const bucket = idx.buckets.get(key);
204
- if (bucket) {
205
- for (const id of bucket) out.add(id);
206
- }
207
- }
208
- return out;
209
- }
210
- };
211
- var EMPTY_SET = /* @__PURE__ */ new Set();
212
- function stringifyKey(value) {
213
- if (value === null || value === void 0) return "\0NULL\0";
214
- if (typeof value === "string") return value;
215
- if (typeof value === "number" || typeof value === "boolean") return String(value);
216
- if (value instanceof Date) return value.toISOString();
217
- return "\0OBJECT\0";
218
- }
219
- function addToIndex(idx, id, record) {
220
- const value = readPath(record, idx.field);
221
- if (value === null || value === void 0) return;
222
- const key = stringifyKey(value);
223
- let bucket = idx.buckets.get(key);
224
- if (!bucket) {
225
- bucket = /* @__PURE__ */ new Set();
226
- idx.buckets.set(key, bucket);
227
- }
228
- bucket.add(id);
229
- }
230
- function removeFromIndex(idx, id, record) {
231
- const value = readPath(record, idx.field);
232
- if (value === null || value === void 0) return;
233
- const key = stringifyKey(value);
234
- const bucket = idx.buckets.get(key);
235
- if (!bucket) return;
236
- bucket.delete(id);
237
- if (bucket.size === 0) idx.buckets.delete(key);
238
- }
239
-
240
- // src/indexing/persisted-indexes.ts
241
- var IDX_PREFIX = "_idx/";
242
- function encodeIdxId(field, recordId) {
243
- return `${IDX_PREFIX}${field}/${recordId}`;
244
- }
245
- function decodeIdxId(id) {
246
- if (!id.startsWith(IDX_PREFIX)) return null;
247
- const rest = id.slice(IDX_PREFIX.length);
248
- const firstSlash = rest.indexOf("/");
249
- if (firstSlash <= 0) return null;
250
- const field = rest.slice(0, firstSlash);
251
- const recordId = rest.slice(firstSlash + 1);
252
- if (recordId.length === 0) return null;
253
- return { field, recordId };
254
- }
255
- function isIdxId(id) {
256
- return decodeIdxId(id) !== null;
257
- }
258
- var COMPOSITE_DELIMITER = "|";
259
- function compositeKey(fields) {
260
- return fields.join(COMPOSITE_DELIMITER);
261
- }
262
- var PersistedCollectionIndex = class {
263
- indexes = /* @__PURE__ */ new Map();
264
- defs = /* @__PURE__ */ new Map();
265
- /**
266
- * Declare a single-field index. Subsequent `upsert` / `ingest` calls
267
- * populate the in-memory mirror; calls before `declare` are no-ops
268
- * (tolerant bulk-load ordering). Idempotent.
269
- */
270
- declare(field) {
271
- if (this.indexes.has(field)) return;
272
- this.indexes.set(field, { buckets: /* @__PURE__ */ new Map(), values: /* @__PURE__ */ new Map() });
273
- this.defs.set(field, { kind: "single", field, key: field });
274
- }
275
- /**
276
- * Declare a composite (multi-field) index. The synthetic
277
- * key is `fields.join('|')`; it doubles as the in-memory map key and
278
- * the `_idx/<key>/<recordId>` side-car field segment. Callers upsert
279
- * and lookup via the same `key` as single-field indexes, just with a
280
- * tuple value (JSON-stringified for bucketing).
281
- */
282
- declareComposite(fields) {
283
- if (fields.length === 0) {
284
- throw new Error("declareComposite: fields array must be non-empty");
285
- }
286
- for (const f of fields) {
287
- if (f.includes(COMPOSITE_DELIMITER)) {
288
- throw new Error(
289
- `declareComposite: field "${f}" contains the composite delimiter "${COMPOSITE_DELIMITER}" \u2014 pick a different field name or open an issue to add hash-based composite keys.`
290
- );
291
- }
292
- }
293
- const key = compositeKey(fields);
294
- if (this.indexes.has(key)) return;
295
- this.indexes.set(key, { buckets: /* @__PURE__ */ new Map(), values: /* @__PURE__ */ new Map() });
296
- this.defs.set(key, { kind: "composite", fields: [...fields], key });
297
- }
298
- /**
299
- * Every declared index's structured definition. Collection walks this
300
- * when materialising side-cars on put/delete so it can extract a
301
- * single-field value or a composite tuple appropriately.
302
- */
303
- definitions() {
304
- return [...this.defs.values()];
305
- }
306
- /** True if `field` has been declared as indexable on this mirror. */
307
- has(field) {
308
- return this.indexes.has(field);
309
- }
310
- /** All declared field names, in declaration order. */
311
- fields() {
312
- return [...this.indexes.keys()];
313
- }
314
- /**
315
- * Bulk-load the mirror from decrypted index bodies. Intended to be
316
- * called once per field after reading the collection's `_idx/<field>/*`
317
- * side-cars. Safe to call twice with the same rows — bucket Sets
318
- * deduplicate recordIds. If `field` is not declared, this is a no-op
319
- * (tolerates the case where bulk-load runs before `declare()` lands).
320
- */
321
- ingest(field, rows) {
322
- const state = this.indexes.get(field);
323
- if (!state) return;
324
- for (const row of rows) {
325
- addToState(state, row.recordId, row.value);
326
- }
327
- }
328
- /**
329
- * Incrementally update a record's index entry for one field. Called by
330
- * `Collection.put()` after the main write succeeds. If
331
- * `previousValue` is non-null, the record is removed from the old
332
- * bucket first — this is the update path. Pass `null` for fresh adds.
333
- * No-op if the field is not declared.
334
- */
335
- upsert(recordId, field, newValue, previousValue) {
336
- const state = this.indexes.get(field);
337
- if (!state) return;
338
- if (previousValue !== null && previousValue !== void 0) {
339
- removeFromState(state, recordId, previousValue);
340
- }
341
- addToState(state, recordId, newValue);
342
- }
343
- /**
344
- * Remove a record from the index for one field. Called by
345
- * `Collection.delete()`. No-op if the field is not declared or
346
- * the record isn't in the bucket. Empty buckets are dropped to keep
347
- * the Map clean.
348
- */
349
- remove(recordId, field, value) {
350
- const state = this.indexes.get(field);
351
- if (!state) return;
352
- removeFromState(state, recordId, value);
353
- }
354
- /**
355
- * Drop all bucket data while preserving field declarations. Called on
356
- * invalidation (incoming sync changes, keyring rotation) — the next
357
- * query re-populates via `ingest`.
358
- */
359
- clear() {
360
- for (const state of this.indexes.values()) {
361
- state.buckets.clear();
362
- state.values.clear();
363
- }
364
- }
365
- /**
366
- * Equality lookup — return the set of record ids whose `field` matches
367
- * `value`. Returns `null` if the field is not declared (caller falls
368
- * back to scan or throws `IndexRequiredError`). Returns a shared empty
369
- * set if the field is declared but no record matches — that set MUST
370
- * NOT be mutated by the caller.
371
- */
372
- lookupEqual(field, value) {
373
- const state = this.indexes.get(field);
374
- if (!state) return null;
375
- const key = stringifyKey2(value);
376
- return state.buckets.get(key) ?? EMPTY_SET2;
377
- }
378
- /**
379
- * Set lookup — return the union of record ids whose `field` matches any
380
- * of `values`. Returns `null` if the field is not declared. Returns a
381
- * fresh (non-shared) Set — safe for the caller to mutate.
382
- */
383
- lookupIn(field, values) {
384
- const state = this.indexes.get(field);
385
- if (!state) return null;
386
- const out = /* @__PURE__ */ new Set();
387
- for (const value of values) {
388
- const bucket = state.buckets.get(stringifyKey2(value));
389
- if (bucket) for (const id of bucket) out.add(id);
390
- }
391
- return out;
392
- }
393
- /**
394
- * Range lookup. Return record ids whose indexed value
395
- * satisfies the predicate. Comparison happens on the ORIGINAL TYPED
396
- * value carried in `state.values` — so numeric `<` sorts numerically,
397
- * not lexicographically on `String(n)`. Returns `null` if the field
398
- * is not declared.
399
- *
400
- * Supported ops: `'<'`, `'<='`, `'>'`, `'>='`, `'between'`. For
401
- * `'between'`, `value` is `[lo, hi]` and both bounds are inclusive
402
- * (matches the eager-mode operator contract in `predicate.ts`).
403
- */
404
- lookupRange(field, op, value) {
405
- const state = this.indexes.get(field);
406
- if (!state) return null;
407
- const out = /* @__PURE__ */ new Set();
408
- for (const [recordId, live] of state.values) {
409
- if (live === void 0 || live === null) continue;
410
- if (matchesRange(live, op, value)) out.add(recordId);
411
- }
412
- return out;
413
- }
414
- /**
415
- * Sorted iteration — return every entry on `field` as an
416
- * `OrderedEntry[]`, sorted by the ORIGINAL TYPED value (#275: no more
417
- * `'10' < '2'` surprises on numeric fields). Consumers paginate with
418
- * a numeric offset. `OrderedEntry.value` is the typed value.
419
- */
420
- orderedBy(field, dir) {
421
- const state = this.indexes.get(field);
422
- if (!state) return null;
423
- const entries = [];
424
- for (const [recordId, value] of state.values) {
425
- entries.push({ recordId, value });
426
- }
427
- entries.sort((a, b) => compareTyped(a.value, b.value));
428
- if (dir === "desc") entries.reverse();
429
- return entries;
430
- }
431
- };
432
- var EMPTY_SET2 = /* @__PURE__ */ new Set();
433
- function stringifyKey2(value) {
434
- if (value === null || value === void 0) return "\0NULL\0";
435
- if (typeof value === "string") return value;
436
- if (typeof value === "number" || typeof value === "boolean") return String(value);
437
- if (value instanceof Date) return value.toISOString();
438
- if (Array.isArray(value)) {
439
- const parts = [];
440
- for (const el of value) parts.push(stringifyKey2(el));
441
- return JSON.stringify(parts);
442
- }
443
- return "\0OBJECT\0";
444
- }
445
- function addToState(state, recordId, value) {
446
- if (value === null || value === void 0) return;
447
- const key = stringifyKey2(value);
448
- let bucket = state.buckets.get(key);
449
- if (!bucket) {
450
- bucket = /* @__PURE__ */ new Set();
451
- state.buckets.set(key, bucket);
452
- }
453
- bucket.add(recordId);
454
- state.values.set(recordId, value);
455
- }
456
- function removeFromState(state, recordId, value) {
457
- if (value === null || value === void 0) return;
458
- const key = stringifyKey2(value);
459
- const bucket = state.buckets.get(key);
460
- if (bucket) {
461
- bucket.delete(recordId);
462
- if (bucket.size === 0) state.buckets.delete(key);
463
- }
464
- state.values.delete(recordId);
465
- }
466
- function matchesRange(live, op, bound) {
467
- if (op === "between") {
468
- if (!Array.isArray(bound) || bound.length !== 2) return false;
469
- return compareTyped(live, bound[0]) >= 0 && compareTyped(live, bound[1]) <= 0;
470
- }
471
- const cmp = compareTyped(live, bound);
472
- switch (op) {
473
- case "<":
474
- return cmp < 0;
475
- case "<=":
476
- return cmp <= 0;
477
- case ">":
478
- return cmp > 0;
479
- case ">=":
480
- return cmp >= 0;
481
- }
482
- }
483
- function compareTyped(a, b) {
484
- if (a === void 0 || a === null) return b === void 0 || b === null ? 0 : 1;
485
- if (b === void 0 || b === null) return -1;
486
- if (typeof a === "number" && typeof b === "number") return a - b;
487
- if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
488
- if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
489
- if (typeof a === "boolean" && typeof b === "boolean") {
490
- return a === b ? 0 : a ? 1 : -1;
491
- }
492
- return 0;
493
- }
494
-
495
- // src/indexing/active.ts
496
- function withIndexing() {
497
- return {
498
- createState({ defs, lazy }) {
499
- if (lazy) {
500
- const persisted = new PersistedCollectionIndex();
501
- declareAll(persisted, defs);
502
- return makeLazyState(persisted);
503
- }
504
- const eager = new CollectionIndexes();
505
- for (const def of defs) {
506
- if (typeof def === "string") {
507
- eager.declare(def);
508
- } else if (Array.isArray(def)) {
509
- for (const f of def) eager.declare(f);
510
- } else {
511
- for (const f of def.fields) eager.declare(f);
512
- }
513
- }
514
- return makeEagerState(eager);
515
- }
516
- };
517
- }
518
- function declareAll(persisted, defs) {
519
- for (const def of defs) {
520
- if (typeof def === "string") {
521
- persisted.declare(def);
522
- } else if (Array.isArray(def)) {
523
- persisted.declareComposite(def);
524
- } else {
525
- persisted.declareComposite(def.fields);
526
- }
527
- }
528
- }
529
- function makeEagerState(eager) {
530
- return {
531
- isEnabled: true,
532
- getEagerIndexes: () => eager,
533
- getPersistedIndexes: () => null
534
- };
535
- }
536
- function makeLazyState(persisted) {
537
- return {
538
- isEnabled: true,
539
- getEagerIndexes: () => null,
540
- getPersistedIndexes: () => persisted
541
- };
542
- }
543
-
544
- // src/errors.ts
545
- var NoydbError = class extends Error {
546
- /** Machine-readable error code. Stable across library versions. */
547
- code;
548
- constructor(code, message) {
549
- super(message);
550
- this.name = "NoydbError";
551
- this.code = code;
552
- }
553
- };
554
- var IndexRequiredError = class extends NoydbError {
555
- collection;
556
- touchedFields;
557
- missingFields;
558
- constructor(args) {
559
- super(
560
- "INDEX_REQUIRED",
561
- `Collection "${args.collection}": query references unindexed fields in lazy mode (missing: ${args.missingFields.join(", ")}). Declare an index on each field, or use collection.scan() for non-indexed iteration.`
562
- );
563
- this.name = "IndexRequiredError";
564
- this.collection = args.collection;
565
- this.touchedFields = [...args.touchedFields];
566
- this.missingFields = [...args.missingFields];
567
- }
568
- };
569
-
570
- // src/indexing/lazy-builder.ts
571
- var EMPTY_PLAN = {
572
- clauses: [],
573
- orderBy: [],
574
- limit: void 0,
575
- offset: 0
576
- };
577
- var LazyQuery = class _LazyQuery {
578
- source;
579
- plan;
580
- constructor(source, plan = EMPTY_PLAN) {
581
- this.source = source;
582
- this.plan = plan;
583
- }
584
- where(field, op, value) {
585
- const clause = { type: "field", field, op, value };
586
- return new _LazyQuery(this.source, {
587
- ...this.plan,
588
- clauses: [...this.plan.clauses, clause]
589
- });
590
- }
591
- orderBy(field, direction = "asc") {
592
- return new _LazyQuery(this.source, {
593
- ...this.plan,
594
- orderBy: [...this.plan.orderBy, { field, direction }]
595
- });
596
- }
597
- limit(n) {
598
- return new _LazyQuery(this.source, { ...this.plan, limit: n });
599
- }
600
- offset(n) {
601
- return new _LazyQuery(this.source, { ...this.plan, offset: n });
602
- }
603
- async toArray() {
604
- await this.source.ensurePersistedIndexesLoaded();
605
- const touchedFields = collectTouchedFields(this.plan);
606
- const missingFields = touchedFields.filter((f) => !isFieldIndexed(f, this.source.persistedIndexes));
607
- if (missingFields.length > 0) {
608
- throw new IndexRequiredError({
609
- collection: this.source.collectionName,
610
- touchedFields,
611
- missingFields
612
- });
613
- }
614
- const candidateIds = this.resolveCandidateIds();
615
- if (candidateIds === null) {
616
- throw new IndexRequiredError({
617
- collection: this.source.collectionName,
618
- touchedFields,
619
- missingFields: touchedFields
620
- });
621
- }
622
- const records = [];
623
- for (const id of candidateIds) {
624
- const record = await this.source.getRecord(id);
625
- if (record === null) continue;
626
- if (!matchesAll(record, this.plan.clauses)) continue;
627
- records.push(record);
628
- }
629
- const sorted = this.plan.orderBy.length > 0 ? sortRecords(records, this.plan.orderBy) : records;
630
- const offset = this.plan.offset > 0 ? this.plan.offset : 0;
631
- const limited = this.plan.limit === void 0 ? sorted.slice(offset) : sorted.slice(offset, offset + this.plan.limit);
632
- return limited;
633
- }
634
- async first() {
635
- const out = await this.limit(1).toArray();
636
- return out.length > 0 ? out[0] : null;
637
- }
638
- async count() {
639
- const out = await this.toArray();
640
- return out.length;
641
- }
642
- /**
643
- * Resolve the candidate record-id set to decrypt. Returns null when the
644
- * query has no usable driver — no `==`/`in` clause and no `orderBy`
645
- * clause that can scope the scan. Callers interpret null as
646
- * IndexRequiredError (see `toArray`).
647
- */
648
- resolveCandidateIds() {
649
- const idx = this.source.persistedIndexes;
650
- const eqMap = /* @__PURE__ */ new Map();
651
- for (const clause of this.plan.clauses) {
652
- if (clause.op === "==") eqMap.set(clause.field, clause.value);
653
- }
654
- if (eqMap.size >= 2) {
655
- for (const def of idx.definitions()) {
656
- if (def.kind !== "composite") continue;
657
- if (def.fields.every((f) => eqMap.has(f))) {
658
- const tuple = def.fields.map((f) => eqMap.get(f));
659
- const ids = idx.lookupEqual(def.key, tuple);
660
- if (ids) return [...ids];
661
- }
662
- }
663
- }
664
- for (const clause of this.plan.clauses) {
665
- if (clause.op === "==") {
666
- const ids = idx.lookupEqual(clause.field, clause.value);
667
- if (ids) return [...ids];
668
- } else if (clause.op === "in" && Array.isArray(clause.value)) {
669
- const ids = idx.lookupIn(clause.field, clause.value);
670
- if (ids) return [...ids];
671
- } else if (isRangeOp(clause.op)) {
672
- const ids = idx.lookupRange(clause.field, clause.op, clause.value);
673
- if (ids) return [...ids];
674
- }
675
- }
676
- if (this.plan.orderBy.length > 0) {
677
- const primary = this.plan.orderBy[0];
678
- const entries = idx.orderedBy(primary.field, primary.direction);
679
- if (entries) return entries.map((e) => e.recordId);
680
- }
681
- return null;
682
- }
683
- };
684
- function isFieldIndexed(field, idx) {
685
- if (idx.has(field)) return true;
686
- for (const def of idx.definitions()) {
687
- if (def.kind === "composite" && def.fields.includes(field)) return true;
688
- }
689
- return false;
690
- }
691
- function isRangeOp(op) {
692
- return op === "<" || op === "<=" || op === ">" || op === ">=" || op === "between";
693
- }
694
- function collectTouchedFields(plan) {
695
- const seen = /* @__PURE__ */ new Set();
696
- for (const c of plan.clauses) seen.add(c.field);
697
- for (const o of plan.orderBy) seen.add(o.field);
698
- return [...seen];
699
- }
700
- function matchesAll(record, clauses) {
701
- for (const c of clauses) {
702
- if (!evaluateClause(record, c)) return false;
703
- }
704
- return true;
705
- }
706
- function sortRecords(records, orderBy) {
707
- return [...records].sort((a, b) => {
708
- for (const { field, direction } of orderBy) {
709
- const av = readPath(a, field);
710
- const bv = readPath(b, field);
711
- const cmp = compareValues(av, bv);
712
- if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
713
- }
714
- return 0;
715
- });
716
- }
717
- function compareValues(a, b) {
718
- if (a === void 0 || a === null) return b === void 0 || b === null ? 0 : 1;
719
- if (b === void 0 || b === null) return -1;
720
- if (typeof a === "number" && typeof b === "number") return a - b;
721
- if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
722
- if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
723
- return 0;
724
- }
725
- // Annotate the CommonJS export names for ESM import in node:
726
- 0 && (module.exports = {
727
- COMPOSITE_DELIMITER,
728
- CollectionIndexes,
729
- IDX_PREFIX,
730
- LazyQuery,
731
- PersistedCollectionIndex,
732
- compositeKey,
733
- decodeIdxId,
734
- encodeIdxId,
735
- isIdxId,
736
- withIndexing
737
- });
738
- //# sourceMappingURL=index.cjs.map