@noy-db/hub 0.2.0-pre.6 → 0.2.0-pre.8

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 (259) hide show
  1. package/dist/aggregate/index.cjs.map +1 -1
  2. package/dist/aggregate/index.js +4 -4
  3. package/dist/attestation/index.cjs.map +1 -1
  4. package/dist/attestation/index.d.cts +4 -4
  5. package/dist/attestation/index.d.ts +4 -4
  6. package/dist/attestation/index.js +6 -6
  7. package/dist/blobs/index.cjs.map +1 -1
  8. package/dist/blobs/index.d.cts +5 -5
  9. package/dist/blobs/index.d.ts +5 -5
  10. package/dist/blobs/index.js +5 -5
  11. package/dist/bundle/index.cjs +420 -29
  12. package/dist/bundle/index.cjs.map +1 -1
  13. package/dist/bundle/index.d.cts +6 -6
  14. package/dist/bundle/index.d.ts +6 -6
  15. package/dist/bundle/index.js +12 -12
  16. package/dist/{chunk-JICBEFBT.js → chunk-22DWZL57.js} +63 -27
  17. package/dist/chunk-22DWZL57.js.map +1 -0
  18. package/dist/{chunk-XDW37COG.js → chunk-2GLDA55J.js} +212 -7
  19. package/dist/chunk-2GLDA55J.js.map +1 -0
  20. package/dist/{chunk-RIHZBSWJ.js → chunk-2WUSG3IT.js} +3 -3
  21. package/dist/{chunk-JSYTGEX4.js → chunk-3BFJOWSU.js} +3 -3
  22. package/dist/{chunk-Y3P5DEMZ.js → chunk-3YPCK6JX.js} +6 -6
  23. package/dist/{chunk-A4JNVBPF.js → chunk-53XBRIRT.js} +5 -5
  24. package/dist/{chunk-CKH247ZR.js → chunk-5T22KDPN.js} +4 -4
  25. package/dist/{chunk-PX3MJ6RB.js → chunk-5XHKQ56N.js} +3 -3
  26. package/dist/{chunk-W277AG6N.js → chunk-6774ZOQ7.js} +170 -57
  27. package/dist/chunk-6774ZOQ7.js.map +1 -0
  28. package/dist/chunk-6STK5TQP.js +139 -0
  29. package/dist/chunk-6STK5TQP.js.map +1 -0
  30. package/dist/{chunk-6HJ2ZALB.js → chunk-B6PB7JLN.js} +66 -2
  31. package/dist/chunk-B6PB7JLN.js.map +1 -0
  32. package/dist/{chunk-5QPF2MJ5.js → chunk-BVRYKATC.js} +3 -3
  33. package/dist/{chunk-UGVDIOY7.js → chunk-DE6GKS6G.js} +2 -2
  34. package/dist/{chunk-R4LTCI6O.js → chunk-DFMLEQZB.js} +2 -2
  35. package/dist/{chunk-34XGYMQT.js → chunk-DJHHA6XH.js} +2 -2
  36. package/dist/{chunk-OPD3PZOG.js → chunk-DL3HWOQ5.js} +4 -4
  37. package/dist/{chunk-DFCINPB5.js → chunk-DO7C2TOG.js} +2 -2
  38. package/dist/{chunk-T6MTNGBM.js → chunk-DONMZAD2.js} +4 -4
  39. package/dist/{chunk-ARZAHCCF.js → chunk-F3GDRNUT.js} +3 -3
  40. package/dist/{chunk-XVJFFGTG.js → chunk-H2X3ISXG.js} +3 -3
  41. package/dist/{chunk-R7JTYCRX.js → chunk-HNRHLRDC.js} +2 -2
  42. package/dist/{chunk-E225X5CQ.js → chunk-I5FOWO4J.js} +3 -3
  43. package/dist/{chunk-ZQMYB56Z.js → chunk-JWRVQKRZ.js} +3 -3
  44. package/dist/{chunk-LWFQYT4N.js → chunk-K3DK3NU5.js} +2 -2
  45. package/dist/{chunk-WEA4TDTJ.js → chunk-ML236QKC.js} +3 -3
  46. package/dist/{chunk-G26QAQNI.js → chunk-NONAAENK.js} +2 -2
  47. package/dist/{chunk-YEHUEUNP.js → chunk-O3VZPBZG.js} +4 -4
  48. package/dist/{chunk-HIELMTUK.js → chunk-OIF6LZUR.js} +2 -2
  49. package/dist/{chunk-ED3E3OLO.js → chunk-OQ6PIGHA.js} +2 -2
  50. package/dist/{chunk-6A4AMQ2H.js → chunk-PE2FR4J3.js} +4 -4
  51. package/dist/{chunk-EKTOYEZ3.js → chunk-PP6W64Y3.js} +2 -2
  52. package/dist/{chunk-SGSHQ4PH.js → chunk-PX35GA7L.js} +5 -5
  53. package/dist/{chunk-YJ46RFCD.js → chunk-QEILDE6R.js} +2 -2
  54. package/dist/{chunk-KGFV72WK.js → chunk-QODLLGQ7.js} +5 -5
  55. package/dist/{chunk-2GMRNNI3.js → chunk-RAZ4OVLL.js} +2 -2
  56. package/dist/{chunk-25WFLKOH.js → chunk-SYMWGEET.js} +2 -2
  57. package/dist/{chunk-7TX7HN42.js → chunk-T7JEBOGN.js} +20 -3
  58. package/dist/chunk-T7JEBOGN.js.map +1 -0
  59. package/dist/{chunk-LJO6Q3X6.js → chunk-TFBP23BX.js} +3 -3
  60. package/dist/{chunk-ICH4AIGL.js → chunk-TV3YZ35S.js} +5 -1
  61. package/dist/chunk-TV3YZ35S.js.map +1 -0
  62. package/dist/{chunk-TNBIWSQ7.js → chunk-U26HQ6KJ.js} +2 -2
  63. package/dist/{chunk-CGJFCT3X.js → chunk-VTKGMEPP.js} +2 -2
  64. package/dist/{chunk-5VMTAX4Y.js → chunk-W6EQLGMB.js} +2 -2
  65. package/dist/{chunk-5OVIFUQE.js → chunk-WIRRPTFH.js} +1 -1
  66. package/dist/chunk-WIRRPTFH.js.map +1 -0
  67. package/dist/{chunk-PS5G6A3Y.js → chunk-WPLVTJ5D.js} +4 -4
  68. package/dist/{chunk-MDIC4FAU.js → chunk-XJFLDA7A.js} +2 -2
  69. package/dist/{chunk-CCC25PA7.js → chunk-ZYWZWG6G.js} +5 -5
  70. package/dist/consent/index.cjs.map +1 -1
  71. package/dist/consent/index.d.cts +5 -5
  72. package/dist/consent/index.d.ts +5 -5
  73. package/dist/consent/index.js +3 -3
  74. package/dist/{crypto-5UDZZL26.js → crypto-HTZ4FJOP.js} +3 -3
  75. package/dist/{delegation-42LO4WFO.js → delegation-RI54P6I5.js} +5 -5
  76. package/dist/derivations/index.cjs.map +1 -1
  77. package/dist/derivations/index.d.cts +6 -6
  78. package/dist/derivations/index.d.ts +6 -6
  79. package/dist/derivations/index.js +4 -4
  80. package/dist/{dev-unlock-Dy1qVpkL.d.cts → dev-unlock-M4VAWNq_.d.cts} +1 -1
  81. package/dist/{dev-unlock-Cvo-xCQC.d.ts → dev-unlock-p3ysikWP.d.ts} +1 -1
  82. package/dist/executor-5PNY7LGW.js +8 -0
  83. package/dist/executor-B4QIYGZX.js +8 -0
  84. package/dist/executor-BWXXDQ7K.js +11 -0
  85. package/dist/{fanout-sidecar-EVICRM46.js → fanout-sidecar-OKPMMPLG.js} +2 -2
  86. package/dist/guards/index.cjs.map +1 -1
  87. package/dist/guards/index.d.cts +6 -6
  88. package/dist/guards/index.d.ts +6 -6
  89. package/dist/guards/index.js +3 -3
  90. package/dist/{hash-BgEQklQc.d.cts → hash-BPsYPcv_.d.cts} +1 -1
  91. package/dist/{hash-BAlWR4WD.d.ts → hash-C1GtiOhR.d.ts} +1 -1
  92. package/dist/history/index.cjs.map +1 -1
  93. package/dist/history/index.d.cts +6 -6
  94. package/dist/history/index.d.ts +6 -6
  95. package/dist/history/index.js +5 -5
  96. package/dist/i18n/index.cjs +217 -22
  97. package/dist/i18n/index.cjs.map +1 -1
  98. package/dist/i18n/index.d.cts +5 -5
  99. package/dist/i18n/index.d.ts +5 -5
  100. package/dist/i18n/index.js +16 -5
  101. package/dist/i18n/index.js.map +1 -1
  102. package/dist/{index-5I0MZ0jQ.d.cts → index-4fBVt8j9.d.cts} +104 -7
  103. package/dist/{index-fIPPh5dg.d.ts → index-D8I_pyJD.d.ts} +104 -7
  104. package/dist/index.cjs +625 -41
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +13 -13
  107. package/dist/index.d.ts +13 -13
  108. package/dist/index.js +70 -52
  109. package/dist/index.js.map +1 -1
  110. package/dist/indexing/index.cjs +4 -0
  111. package/dist/indexing/index.cjs.map +1 -1
  112. package/dist/indexing/index.d.cts +3 -3
  113. package/dist/indexing/index.d.ts +3 -3
  114. package/dist/indexing/index.js +4 -4
  115. package/dist/issue-VGDPP4B5.js +12 -0
  116. package/dist/{lazy-builder-D1MyR1qH.d.ts → lazy-builder-7tIpFyWN.d.ts} +1 -1
  117. package/dist/{lazy-builder-DXlSCNCJ.d.cts → lazy-builder-wY4pMCEe.d.cts} +1 -1
  118. package/dist/{ledger-UX4QIHWI.js → ledger-TMRZYNVJ.js} +5 -5
  119. package/dist/materialized-views/index.cjs +18 -1
  120. package/dist/materialized-views/index.cjs.map +1 -1
  121. package/dist/materialized-views/index.d.cts +10 -8
  122. package/dist/materialized-views/index.d.ts +10 -8
  123. package/dist/materialized-views/index.js +12 -12
  124. package/dist/noydb-LZBH3XDK.js +34 -0
  125. package/dist/overlay-views/index.cjs.map +1 -1
  126. package/dist/overlay-views/index.d.cts +6 -6
  127. package/dist/overlay-views/index.d.ts +6 -6
  128. package/dist/overlay-views/index.js +6 -6
  129. package/dist/periods/index.cjs.map +1 -1
  130. package/dist/periods/index.d.cts +5 -5
  131. package/dist/periods/index.d.ts +5 -5
  132. package/dist/periods/index.js +5 -5
  133. package/dist/{predicate-B0IKeBXx.d.cts → predicate-BSAGEyu5.d.cts} +26 -2
  134. package/dist/{predicate-B0IKeBXx.d.ts → predicate-BSAGEyu5.d.ts} +26 -2
  135. package/dist/{public-envelope-YKHKP74C.js → public-envelope-BW6OXORV.js} +4 -4
  136. package/dist/query/index.cjs +244 -4
  137. package/dist/query/index.cjs.map +1 -1
  138. package/dist/query/index.d.cts +2 -2
  139. package/dist/query/index.d.ts +2 -2
  140. package/dist/query/index.js +12 -6
  141. package/dist/registry-3QP3YKQS.js +8 -0
  142. package/dist/{registry-4NEW7LQY.js → registry-OJIOSBV6.js} +3 -3
  143. package/dist/registry-USRVT6YF.js +8 -0
  144. package/dist/{revoke-R5NIQ74J.js → revoke-JCC7N56X.js} +6 -6
  145. package/dist/session/index.cjs.map +1 -1
  146. package/dist/session/index.d.cts +6 -6
  147. package/dist/session/index.d.ts +6 -6
  148. package/dist/session/index.js +3 -3
  149. package/dist/shadow/index.cjs.map +1 -1
  150. package/dist/shadow/index.d.cts +5 -5
  151. package/dist/shadow/index.d.ts +5 -5
  152. package/dist/shadow/index.js +2 -2
  153. package/dist/{signer-WGDJNWSU.js → signer-72QAUSVW.js} +5 -5
  154. package/dist/snapshots/index.cjs +903 -0
  155. package/dist/snapshots/index.cjs.map +1 -0
  156. package/dist/snapshots/index.d.cts +21 -0
  157. package/dist/snapshots/index.d.ts +21 -0
  158. package/dist/snapshots/index.js +118 -0
  159. package/dist/snapshots/index.js.map +1 -0
  160. package/dist/{stale-74WGLVZ2.js → stale-6ZDBTQT7.js} +2 -2
  161. package/dist/store/index.cjs.map +1 -1
  162. package/dist/store/index.d.cts +5 -5
  163. package/dist/store/index.d.ts +5 -5
  164. package/dist/store/index.js +2 -2
  165. package/dist/sync/index.cjs.map +1 -1
  166. package/dist/sync/index.d.cts +4 -4
  167. package/dist/sync/index.d.ts +4 -4
  168. package/dist/sync/index.js +4 -4
  169. package/dist/team/index.cjs.map +1 -1
  170. package/dist/team/index.d.cts +5 -5
  171. package/dist/team/index.d.ts +5 -5
  172. package/dist/team/index.js +8 -8
  173. package/dist/tx/index.cjs.map +1 -1
  174. package/dist/tx/index.d.cts +5 -5
  175. package/dist/tx/index.d.ts +5 -5
  176. package/dist/tx/index.js +3 -3
  177. package/dist/{types-DlnZh1_i.d.ts → types-DGU60JDt.d.ts} +235 -7
  178. package/dist/{types-DVlvNn2c.d.cts → types-DjunxzJa.d.cts} +235 -7
  179. package/dist/{ulid-CzPONlhG.d.ts → ulid-BFJkYRRW.d.ts} +1 -1
  180. package/dist/{ulid-r98nkjVd.d.cts → ulid-DPeuPgi3.d.cts} +1 -1
  181. package/dist/util/index.cjs.map +1 -1
  182. package/dist/util/index.js +1 -1
  183. package/dist/{with-derivation-BMQ9pIHe.d.cts → with-derivation-Df0kMlED.d.cts} +1 -1
  184. package/dist/{with-derivation-B98shCV8.d.ts → with-derivation-DfOpKjFw.d.ts} +1 -1
  185. package/dist/{with-guard-DmT50nVG.d.ts → with-guard-0KksDtSR.d.ts} +1 -1
  186. package/dist/{with-guard-DUnC3JDN.d.cts → with-guard-C6W5RVrH.d.cts} +1 -1
  187. package/dist/{with-materialized-view-Bp_M3sNG.d.ts → with-materialized-view-BiasFcYx.d.ts} +1 -1
  188. package/dist/{with-materialized-view-eMTZ65_J.d.cts → with-materialized-view-BmDKyHrm.d.cts} +1 -1
  189. package/dist/{with-overlayed-view-BoY6PB3n.d.cts → with-overlayed-view-CA66vhHz.d.cts} +1 -1
  190. package/dist/{with-overlayed-view-zzSnRQmS.d.ts → with-overlayed-view-CQViuko_.d.ts} +1 -1
  191. package/package.json +15 -4
  192. package/dist/chunk-5OVIFUQE.js.map +0 -1
  193. package/dist/chunk-6HJ2ZALB.js.map +0 -1
  194. package/dist/chunk-7TX7HN42.js.map +0 -1
  195. package/dist/chunk-ICH4AIGL.js.map +0 -1
  196. package/dist/chunk-JICBEFBT.js.map +0 -1
  197. package/dist/chunk-W277AG6N.js.map +0 -1
  198. package/dist/chunk-XDW37COG.js.map +0 -1
  199. package/dist/executor-AWCHQ2KN.js +0 -8
  200. package/dist/executor-RWICJI7J.js +0 -11
  201. package/dist/executor-SOLEQVUB.js +0 -8
  202. package/dist/issue-IODMTPME.js +0 -12
  203. package/dist/noydb-FY2666NY.js +0 -34
  204. package/dist/registry-446I2NMN.js +0 -8
  205. package/dist/registry-524KJZG4.js +0 -8
  206. /package/dist/{chunk-RIHZBSWJ.js.map → chunk-2WUSG3IT.js.map} +0 -0
  207. /package/dist/{chunk-JSYTGEX4.js.map → chunk-3BFJOWSU.js.map} +0 -0
  208. /package/dist/{chunk-Y3P5DEMZ.js.map → chunk-3YPCK6JX.js.map} +0 -0
  209. /package/dist/{chunk-A4JNVBPF.js.map → chunk-53XBRIRT.js.map} +0 -0
  210. /package/dist/{chunk-CKH247ZR.js.map → chunk-5T22KDPN.js.map} +0 -0
  211. /package/dist/{chunk-PX3MJ6RB.js.map → chunk-5XHKQ56N.js.map} +0 -0
  212. /package/dist/{chunk-5QPF2MJ5.js.map → chunk-BVRYKATC.js.map} +0 -0
  213. /package/dist/{chunk-UGVDIOY7.js.map → chunk-DE6GKS6G.js.map} +0 -0
  214. /package/dist/{chunk-R4LTCI6O.js.map → chunk-DFMLEQZB.js.map} +0 -0
  215. /package/dist/{chunk-34XGYMQT.js.map → chunk-DJHHA6XH.js.map} +0 -0
  216. /package/dist/{chunk-OPD3PZOG.js.map → chunk-DL3HWOQ5.js.map} +0 -0
  217. /package/dist/{chunk-DFCINPB5.js.map → chunk-DO7C2TOG.js.map} +0 -0
  218. /package/dist/{chunk-T6MTNGBM.js.map → chunk-DONMZAD2.js.map} +0 -0
  219. /package/dist/{chunk-ARZAHCCF.js.map → chunk-F3GDRNUT.js.map} +0 -0
  220. /package/dist/{chunk-XVJFFGTG.js.map → chunk-H2X3ISXG.js.map} +0 -0
  221. /package/dist/{chunk-R7JTYCRX.js.map → chunk-HNRHLRDC.js.map} +0 -0
  222. /package/dist/{chunk-E225X5CQ.js.map → chunk-I5FOWO4J.js.map} +0 -0
  223. /package/dist/{chunk-ZQMYB56Z.js.map → chunk-JWRVQKRZ.js.map} +0 -0
  224. /package/dist/{chunk-LWFQYT4N.js.map → chunk-K3DK3NU5.js.map} +0 -0
  225. /package/dist/{chunk-WEA4TDTJ.js.map → chunk-ML236QKC.js.map} +0 -0
  226. /package/dist/{chunk-G26QAQNI.js.map → chunk-NONAAENK.js.map} +0 -0
  227. /package/dist/{chunk-YEHUEUNP.js.map → chunk-O3VZPBZG.js.map} +0 -0
  228. /package/dist/{chunk-HIELMTUK.js.map → chunk-OIF6LZUR.js.map} +0 -0
  229. /package/dist/{chunk-ED3E3OLO.js.map → chunk-OQ6PIGHA.js.map} +0 -0
  230. /package/dist/{chunk-6A4AMQ2H.js.map → chunk-PE2FR4J3.js.map} +0 -0
  231. /package/dist/{chunk-EKTOYEZ3.js.map → chunk-PP6W64Y3.js.map} +0 -0
  232. /package/dist/{chunk-SGSHQ4PH.js.map → chunk-PX35GA7L.js.map} +0 -0
  233. /package/dist/{chunk-YJ46RFCD.js.map → chunk-QEILDE6R.js.map} +0 -0
  234. /package/dist/{chunk-KGFV72WK.js.map → chunk-QODLLGQ7.js.map} +0 -0
  235. /package/dist/{chunk-2GMRNNI3.js.map → chunk-RAZ4OVLL.js.map} +0 -0
  236. /package/dist/{chunk-25WFLKOH.js.map → chunk-SYMWGEET.js.map} +0 -0
  237. /package/dist/{chunk-LJO6Q3X6.js.map → chunk-TFBP23BX.js.map} +0 -0
  238. /package/dist/{chunk-TNBIWSQ7.js.map → chunk-U26HQ6KJ.js.map} +0 -0
  239. /package/dist/{chunk-CGJFCT3X.js.map → chunk-VTKGMEPP.js.map} +0 -0
  240. /package/dist/{chunk-5VMTAX4Y.js.map → chunk-W6EQLGMB.js.map} +0 -0
  241. /package/dist/{chunk-PS5G6A3Y.js.map → chunk-WPLVTJ5D.js.map} +0 -0
  242. /package/dist/{chunk-MDIC4FAU.js.map → chunk-XJFLDA7A.js.map} +0 -0
  243. /package/dist/{chunk-CCC25PA7.js.map → chunk-ZYWZWG6G.js.map} +0 -0
  244. /package/dist/{crypto-5UDZZL26.js.map → crypto-HTZ4FJOP.js.map} +0 -0
  245. /package/dist/{delegation-42LO4WFO.js.map → delegation-RI54P6I5.js.map} +0 -0
  246. /package/dist/{executor-AWCHQ2KN.js.map → executor-5PNY7LGW.js.map} +0 -0
  247. /package/dist/{executor-RWICJI7J.js.map → executor-B4QIYGZX.js.map} +0 -0
  248. /package/dist/{executor-SOLEQVUB.js.map → executor-BWXXDQ7K.js.map} +0 -0
  249. /package/dist/{fanout-sidecar-EVICRM46.js.map → fanout-sidecar-OKPMMPLG.js.map} +0 -0
  250. /package/dist/{issue-IODMTPME.js.map → issue-VGDPP4B5.js.map} +0 -0
  251. /package/dist/{ledger-UX4QIHWI.js.map → ledger-TMRZYNVJ.js.map} +0 -0
  252. /package/dist/{noydb-FY2666NY.js.map → noydb-LZBH3XDK.js.map} +0 -0
  253. /package/dist/{public-envelope-YKHKP74C.js.map → public-envelope-BW6OXORV.js.map} +0 -0
  254. /package/dist/{registry-446I2NMN.js.map → registry-3QP3YKQS.js.map} +0 -0
  255. /package/dist/{registry-4NEW7LQY.js.map → registry-OJIOSBV6.js.map} +0 -0
  256. /package/dist/{registry-524KJZG4.js.map → registry-USRVT6YF.js.map} +0 -0
  257. /package/dist/{revoke-R5NIQ74J.js.map → revoke-JCC7N56X.js.map} +0 -0
  258. /package/dist/{signer-WGDJNWSU.js.map → signer-72QAUSVW.js.map} +0 -0
  259. /package/dist/{stale-74WGLVZ2.js.map → stale-6ZDBTQT7.js.map} +0 -0
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  base64ToBuffer,
6
6
  bufferToBase64
7
- } from "./chunk-EKTOYEZ3.js";
7
+ } from "./chunk-PP6W64Y3.js";
8
8
  import {
9
9
  SessionExpiredError,
10
10
  SessionNotFoundError,
11
11
  SessionPolicyError,
12
12
  ValidationError
13
- } from "./chunk-6HJ2ZALB.js";
13
+ } from "./chunk-B6PB7JLN.js";
14
14
 
15
15
  // src/session/session.ts
16
16
  var subtle = globalThis.crypto.subtle;
@@ -364,4 +364,4 @@ export {
364
364
  clearDevUnlock,
365
365
  isDevUnlockActive
366
366
  };
367
- //# sourceMappingURL=chunk-XVJFFGTG.js.map
367
+ //# sourceMappingURL=chunk-H2X3ISXG.js.map
@@ -30,7 +30,7 @@ async function resolveStaleMVOnRead(accessor, outputCollection) {
30
30
  continue;
31
31
  }
32
32
  if (executor === null) {
33
- ({ MaterializedViewExecutor: executor } = await import("./executor-RWICJI7J.js"));
33
+ ({ MaterializedViewExecutor: executor } = await import("./executor-BWXXDQ7K.js"));
34
34
  }
35
35
  await executor.refresh(reg, {
36
36
  getCollection: (n) => accessor.getCollection(n),
@@ -50,4 +50,4 @@ export {
50
50
  resolveStaleMVOnRead,
51
51
  clearMVStale
52
52
  };
53
- //# sourceMappingURL=chunk-R7JTYCRX.js.map
53
+ //# sourceMappingURL=chunk-HNRHLRDC.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-5OVIFUQE.js";
3
+ } from "./chunk-WIRRPTFH.js";
4
4
  import {
5
5
  decrypt,
6
6
  encrypt
7
- } from "./chunk-EKTOYEZ3.js";
7
+ } from "./chunk-PP6W64Y3.js";
8
8
 
9
9
  // src/persisted-schemas/storage.ts
10
10
  var SCHEMAS_COLLECTION = "_schemas";
@@ -248,4 +248,4 @@ export {
248
248
  loadSealedPassphrase,
249
249
  resolveManagedSecret
250
250
  };
251
- //# sourceMappingURL=chunk-E225X5CQ.js.map
251
+ //# sourceMappingURL=chunk-I5FOWO4J.js.map
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  PeriodClosedError,
7
7
  ValidationError
8
- } from "./chunk-6HJ2ZALB.js";
8
+ } from "./chunk-B6PB7JLN.js";
9
9
 
10
10
  // src/periods/periods.ts
11
11
  var PERIODS_COLLECTION = "_periods";
@@ -56,7 +56,7 @@ function validatePeriodName(name, existing) {
56
56
  }
57
57
  async function appendPeriodLedgerEntry(ledger, actor, envelope, name) {
58
58
  if (!ledger) return;
59
- const { envelopePayloadHash } = await import("./ledger-UX4QIHWI.js");
59
+ const { envelopePayloadHash } = await import("./ledger-TMRZYNVJ.js");
60
60
  await ledger.append({
61
61
  op: "put",
62
62
  collection: PERIODS_COLLECTION,
@@ -87,4 +87,4 @@ export {
87
87
  appendPeriodLedgerEntry,
88
88
  withPeriods
89
89
  };
90
- //# sourceMappingURL=chunk-ZQMYB56Z.js.map
90
+ //# sourceMappingURL=chunk-JWRVQKRZ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MaterializedViewConfigError,
3
3
  ValidationError
4
- } from "./chunk-6HJ2ZALB.js";
4
+ } from "./chunk-B6PB7JLN.js";
5
5
 
6
6
  // src/materialized-views/with-materialized-view.ts
7
7
  function withMaterializedView(spec) {
@@ -79,4 +79,4 @@ function withMaterializedView(spec) {
79
79
  export {
80
80
  withMaterializedView
81
81
  };
82
- //# sourceMappingURL=chunk-LWFQYT4N.js.map
82
+ //# sourceMappingURL=chunk-K3DK3NU5.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-5OVIFUQE.js";
3
+ } from "./chunk-WIRRPTFH.js";
4
4
  import {
5
5
  ValidationError
6
- } from "./chunk-6HJ2ZALB.js";
6
+ } from "./chunk-B6PB7JLN.js";
7
7
 
8
8
  // src/meta/public-envelope/schema.ts
9
9
  var DATA_URL_PREFIX = /^data:([a-zA-Z0-9.+-]+\/[a-zA-Z0-9.+-]+);base64,/;
@@ -152,4 +152,4 @@ export {
152
152
  resolveLocale,
153
153
  pickLocale
154
154
  };
155
- //# sourceMappingURL=chunk-WEA4TDTJ.js.map
155
+ //# sourceMappingURL=chunk-ML236QKC.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FieldFrozenError,
3
3
  InvariantError
4
- } from "./chunk-6HJ2ZALB.js";
4
+ } from "./chunk-B6PB7JLN.js";
5
5
 
6
6
  // src/guards/executor.ts
7
7
  var GuardExecutor = {
@@ -70,4 +70,4 @@ function deepEqual(a, b) {
70
70
  export {
71
71
  GuardExecutor
72
72
  };
73
- //# sourceMappingURL=chunk-G26QAQNI.js.map
73
+ //# sourceMappingURL=chunk-NONAAENK.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  wrapDbWithPredicates
3
- } from "./chunk-7TX7HN42.js";
3
+ } from "./chunk-T7JEBOGN.js";
4
4
  import {
5
5
  canonicalGroupKey,
6
6
  groupAndReduce
7
- } from "./chunk-PX3MJ6RB.js";
7
+ } from "./chunk-5XHKQ56N.js";
8
8
  import {
9
9
  MaterializedViewTooLargeError
10
- } from "./chunk-6HJ2ZALB.js";
10
+ } from "./chunk-B6PB7JLN.js";
11
11
 
12
12
  // src/materialized-views/executor.ts
13
13
  var DEFAULT_MAX_ROWS = 1e5;
@@ -142,4 +142,4 @@ async function listOutputIds(outputColl) {
142
142
  export {
143
143
  MaterializedViewExecutor
144
144
  };
145
- //# sourceMappingURL=chunk-YEHUEUNP.js.map
145
+ //# sourceMappingURL=chunk-O3VZPBZG.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readPath
3
- } from "./chunk-ICH4AIGL.js";
3
+ } from "./chunk-TV3YZ35S.js";
4
4
 
5
5
  // src/indexing/eager-indexes.ts
6
6
  var CollectionIndexes = class {
@@ -129,4 +129,4 @@ function removeFromIndex(idx, id, record) {
129
129
  export {
130
130
  CollectionIndexes
131
131
  };
132
- //# sourceMappingURL=chunk-HIELMTUK.js.map
132
+ //# sourceMappingURL=chunk-OIF6LZUR.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-6HJ2ZALB.js";
3
+ } from "./chunk-B6PB7JLN.js";
4
4
 
5
5
  // src/guards/with-guard.ts
6
6
  function withGuard(strategy) {
@@ -16,4 +16,4 @@ function withGuard(strategy) {
16
16
  export {
17
17
  withGuard
18
18
  };
19
- //# sourceMappingURL=chunk-ED3E3OLO.js.map
19
+ //# sourceMappingURL=chunk-OQ6PIGHA.js.map
@@ -6,15 +6,15 @@ import {
6
6
  } from "./chunk-Z6FNBOTC.js";
7
7
  import {
8
8
  NOYDB_FORMAT_VERSION
9
- } from "./chunk-5OVIFUQE.js";
9
+ } from "./chunk-WIRRPTFH.js";
10
10
  import {
11
11
  decrypt,
12
12
  encrypt
13
- } from "./chunk-EKTOYEZ3.js";
13
+ } from "./chunk-PP6W64Y3.js";
14
14
  import {
15
15
  ConflictError,
16
16
  LedgerContentionError
17
- } from "./chunk-6HJ2ZALB.js";
17
+ } from "./chunk-B6PB7JLN.js";
18
18
 
19
19
  // src/history/ledger/patch.ts
20
20
  function computePatch(prev, next) {
@@ -683,4 +683,4 @@ export {
683
683
  LEDGER_DELTAS_COLLECTION,
684
684
  LedgerStore
685
685
  };
686
- //# sourceMappingURL=chunk-6A4AMQ2H.js.map
686
+ //# sourceMappingURL=chunk-PE2FR4J3.js.map
@@ -2,7 +2,7 @@ import {
2
2
  DecryptionError,
3
3
  InvalidKeyError,
4
4
  TamperedError
5
- } from "./chunk-6HJ2ZALB.js";
5
+ } from "./chunk-B6PB7JLN.js";
6
6
 
7
7
  // src/crypto.ts
8
8
  var PBKDF2_ITERATIONS = 6e5;
@@ -272,4 +272,4 @@ export {
272
272
  bufferToBase64,
273
273
  base64ToBuffer
274
274
  };
275
- //# sourceMappingURL=chunk-EKTOYEZ3.js.map
275
+ //# sourceMappingURL=chunk-PP6W64Y3.js.map
@@ -2,18 +2,18 @@ import {
2
2
  ATTESTATIONS_COLLECTION,
3
3
  REVOKED_RECORD_ID,
4
4
  loadOrCreateSigner
5
- } from "./chunk-OPD3PZOG.js";
5
+ } from "./chunk-DL3HWOQ5.js";
6
6
  import {
7
7
  NOYDB_FORMAT_VERSION
8
- } from "./chunk-5OVIFUQE.js";
8
+ } from "./chunk-WIRRPTFH.js";
9
9
  import {
10
10
  decrypt,
11
11
  encrypt
12
- } from "./chunk-EKTOYEZ3.js";
12
+ } from "./chunk-PP6W64Y3.js";
13
13
  import {
14
14
  AttestationError,
15
15
  ConflictError
16
- } from "./chunk-6HJ2ZALB.js";
16
+ } from "./chunk-B6PB7JLN.js";
17
17
 
18
18
  // src/attestation/revoke.ts
19
19
  import { signRevocationList } from "@noy-db/attestation";
@@ -80,4 +80,4 @@ export {
80
80
  getRevokedDocIdsCore,
81
81
  publishRevocationListCore
82
82
  };
83
- //# sourceMappingURL=chunk-SGSHQ4PH.js.map
83
+ //# sourceMappingURL=chunk-PX35GA7L.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  BundleVersionConflictError,
3
3
  ConflictError
4
- } from "./chunk-6HJ2ZALB.js";
4
+ } from "./chunk-B6PB7JLN.js";
5
5
 
6
6
  // src/store/bundle-store.ts
7
7
  var BUNDLE_STORE_VERSION = 1;
@@ -790,4 +790,4 @@ export {
790
790
  withCache,
791
791
  withHealthCheck
792
792
  };
793
- //# sourceMappingURL=chunk-YJ46RFCD.js.map
793
+ //# sourceMappingURL=chunk-QEILDE6R.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NOYDB_FORMAT_VERSION
3
- } from "./chunk-5OVIFUQE.js";
3
+ } from "./chunk-WIRRPTFH.js";
4
4
  import {
5
5
  base64ToBuffer,
6
6
  bufferToBase64,
@@ -10,11 +10,11 @@ import {
10
10
  encryptBytesWithAAD,
11
11
  hmacSha256Hex,
12
12
  sha256Hex
13
- } from "./chunk-EKTOYEZ3.js";
13
+ } from "./chunk-PP6W64Y3.js";
14
14
  import {
15
15
  ConflictError,
16
16
  NotFoundError
17
- } from "./chunk-6HJ2ZALB.js";
17
+ } from "./chunk-B6PB7JLN.js";
18
18
 
19
19
  // src/blobs/mime-magic.ts
20
20
  function hex(s) {
@@ -820,7 +820,7 @@ var BlobSet = class {
820
820
  return this.buildResponse(slot, result.blob, { inline: true });
821
821
  }
822
822
  const aad = chunkAAD(slot.eTag, 0, result.blob.chunkCount);
823
- const { decryptBytesWithAAD: decryptAAD } = await import("./crypto-5UDZZL26.js");
823
+ const { decryptBytesWithAAD: decryptAAD } = await import("./crypto-HTZ4FJOP.js");
824
824
  const decrypted = await decryptAAD(envelope._iv, envelope._data, blobDEK, aad);
825
825
  const plaintext = result.blob.compression === "gzip" ? await decompressBytes(decrypted) : decrypted;
826
826
  const body = new ReadableStream({
@@ -883,4 +883,4 @@ export {
883
883
  DEFAULT_CHUNK_SIZE,
884
884
  BlobSet
885
885
  };
886
- //# sourceMappingURL=chunk-KGFV72WK.js.map
886
+ //# sourceMappingURL=chunk-QODLLGQ7.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-6HJ2ZALB.js";
3
+ } from "./chunk-B6PB7JLN.js";
4
4
 
5
5
  // src/derivations/with-derivation.ts
6
6
  function withDerivation(spec) {
@@ -48,4 +48,4 @@ function withDerivation(spec) {
48
48
  export {
49
49
  withDerivation
50
50
  };
51
- //# sourceMappingURL=chunk-2GMRNNI3.js.map
51
+ //# sourceMappingURL=chunk-RAZ4OVLL.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ValidationError
3
- } from "./chunk-6HJ2ZALB.js";
3
+ } from "./chunk-B6PB7JLN.js";
4
4
 
5
5
  // src/overlay-views/with-overlayed-view.ts
6
6
  function withOverlayedView(spec) {
@@ -33,4 +33,4 @@ function withOverlayedView(spec) {
33
33
  export {
34
34
  withOverlayedView
35
35
  };
36
- //# sourceMappingURL=chunk-25WFLKOH.js.map
36
+ //# sourceMappingURL=chunk-SYMWGEET.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MaterializedViewCycleError,
3
3
  MaterializedViewSourceUnknownError
4
- } from "./chunk-6HJ2ZALB.js";
4
+ } from "./chunk-B6PB7JLN.js";
5
5
 
6
6
  // src/materialized-views/dependency-analyzer.ts
7
7
  function analyzeDependencies(query) {
@@ -14,6 +14,11 @@ function analyzeDependencies(query) {
14
14
  for (const leg of plan.joins) {
15
15
  deps.add(leg.target);
16
16
  }
17
+ for (const clause of plan.clauses) {
18
+ if (clause.type === "crossJoin") {
19
+ deps.add(clause.target);
20
+ }
21
+ }
17
22
  walkClausesForJoins(plan, deps, ctx);
18
23
  return deps;
19
24
  }
@@ -29,7 +34,19 @@ function summarizeQueryPlan(query) {
29
34
  const ctx = query._joinContext();
30
35
  return JSON.stringify({
31
36
  root: ctx?.leftCollection ?? null,
32
- clauses: plan.clauses,
37
+ clauses: plan.clauses.map((c) => {
38
+ if (c.type === "crossJoin") {
39
+ return {
40
+ type: "crossJoin",
41
+ target: c.target,
42
+ as: c.as,
43
+ // Inline on: callback: use sentinel — drift detection disabled for this MV
44
+ onPredicateName: c.onPredicateName ?? (c.on ? "[inline]" : null),
45
+ maxRows: c.maxRows ?? null
46
+ };
47
+ }
48
+ return c;
49
+ }),
33
50
  orderBy: plan.orderBy,
34
51
  limit: plan.limit ?? null,
35
52
  offset: plan.offset,
@@ -293,4 +310,4 @@ export {
293
310
  MaterializedViewRegistry,
294
311
  wrapDbWithPredicates
295
312
  };
296
- //# sourceMappingURL=chunk-7TX7HN42.js.map
313
+ //# sourceMappingURL=chunk-T7JEBOGN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/materialized-views/dependency-analyzer.ts","../src/materialized-views/query-hash.ts","../src/materialized-views/registry.ts"],"sourcesContent":["import type { Query, QueryPlan } from '../query/builder.js'\nimport type { JoinContext } from '../query/join.js'\nimport type { MaterializedViewStrategy } from './types.js'\n\n/**\n * Walks a `Query<T>` plan and returns the set of source collection\n * names that any source-write should trigger a refresh on.\n *\n * Handles:\n * - root collection (the one the query was built from)\n * - FK join targets (`.join(field, { as })`)\n *\n * Also handles:\n * - cross-join targets (`.crossJoin(target, { as })`) — v3\n *\n * Deferred:\n * - `.wherePredicate(name)` — v2 predicate primitive\n * - Overlay-name expansion to {base, overlay}\n *\n * The set is materialized at MV registration time. The MV registry\n * uses it to (a) dispatch `onSourceWrite` only to MVs that actually\n * care, and (b) contribute edges to the shared cycle-detection graph.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function analyzeDependencies(query: Query<any>): Set<string> {\n const deps = new Set<string>()\n const plan = query._plan()\n const ctx = query._joinContext()\n\n // The root collection is always a dependency.\n if (ctx?.leftCollection) {\n deps.add(ctx.leftCollection)\n }\n\n // FK join targets contribute additional sources.\n for (const leg of plan.joins) {\n deps.add(leg.target)\n }\n\n // Cross-join targets are also dependency sources — writes to either side\n // must trigger MV refresh. Symmetric with FK-join target handling above.\n for (const clause of plan.clauses) {\n if (clause.type === 'crossJoin') {\n deps.add(clause.target)\n }\n }\n\n // Sub-plans inside OR clauses can carry nested joins. Walk them.\n // (Today only top-level `.join()` populates `plan.joins`, but the\n // OR-group machinery permits sub-plans, so we recurse defensively.)\n walkClausesForJoins(plan, deps, ctx)\n\n return deps\n}\n\nfunction walkClausesForJoins(\n plan: QueryPlan,\n deps: Set<string>,\n ctx: JoinContext | undefined,\n): void {\n void ctx\n // Today `plan.joins` carries all join legs at top level. Sub-plans\n // inside OR groups don't currently support nested joins, so the loop\n // below is a no-op safety net for future builder extensions.\n for (const clause of plan.clauses) {\n if (clause.type === 'group') {\n // Group clauses don't (yet) carry their own joins; this is a\n // forward-compat anchor for when OR-groups support nested\n // sources.\n }\n }\n}\n\n/**\n * Convenience: produce a stable string summary of the query plan\n * suitable for `queryHash` derivation. Captures everything the\n * dependency analyzer reads + the where/orderBy/limit/offset\n * structure that affects materialized rows.\n *\n * `joinContext` is intentionally NOT included — the join-resolution\n * function references would defeat hash determinism. The set of join\n * TARGETS (collection names) IS included via the plan.joins legs.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function summarizeQueryPlan(query: Query<any>): string {\n const plan = query._plan()\n const ctx = query._joinContext()\n return JSON.stringify({\n root: ctx?.leftCollection ?? null,\n clauses: plan.clauses.map(c => {\n if (c.type === 'crossJoin') {\n return {\n type: 'crossJoin',\n target: c.target,\n as: c.as,\n // Inline on: callback: use sentinel — drift detection disabled for this MV\n onPredicateName: c.onPredicateName ?? (c.on ? '[inline]' : null),\n maxRows: c.maxRows ?? null,\n }\n }\n return c\n }),\n orderBy: plan.orderBy,\n limit: plan.limit ?? null,\n offset: plan.offset,\n joins: plan.joins.map(j => ({ field: j.field, as: j.as, target: j.target, mode: j.mode })),\n })\n}\n\n/**\n * Canonical string description of a UNION MV's plan, used as input to\n * `computeQueryHash`.\n *\n * Asymmetry note:\n * - Arm collection names are NOT sorted. Declaration order is\n * semantically meaningful for the dedup-only UNION path —\n * `materializeUnionResult` iterates `spec.unionSources` in\n * declaration order and keeps the first-seen row per composite key\n * (tie-break precedence). If we sorted arms here, a consumer who\n * reordered `unionSources` to change precedence would compute the\n * same `queryHash`, refresh would be a no-op, and stale MV rows\n * would persist. Hashing in declaration order makes any reorder\n * trigger a refresh.\n * - `groupBy` fields ARE sorted. Multi-key groupBy buckets are\n * commutative (`canonicalGroupKey` produces the same composite key\n * regardless of field order in the input spec).\n * - `aggregate` keys ARE sorted. Reducer-spec keys are independent\n * of each other — order of declaration doesn't change output.\n *\n * Per-arm `map` functions are NOT fingerprinted; consumers must bump\n * the MV's `name` (or rely on application-level cache busting) when\n * `map` semantics change non-equivalently.\n */\nexport function summarizeUnionPlan<T extends Record<string, unknown>>(\n spec: MaterializedViewStrategy<T>,\n): string {\n const arms = (spec.unionSources ?? [])\n .map(s => s.collection)\n .join(',')\n const groupBy: string = Array.isArray(spec.groupBy)\n ? [...spec.groupBy].sort().join(',')\n : typeof spec.groupBy === 'string'\n ? spec.groupBy\n : ''\n const aggKeys = spec.aggregate ? Object.keys(spec.aggregate).sort().join(',') : ''\n return `union(${arms})|groupBy(${groupBy})|aggregate(${aggKeys})`\n}\n","/**\n * Deterministic hash of a materialized view strategy's \"shape\": MV\n * name + canonical query-plan summary + sorted dependency-set.\n *\n * Used to detect strategy drift: a row whose `_materializedFrom.queryHash`\n * doesn't match the current strategy is considered stale.\n *\n * Web Crypto SHA-256 — no extra deps. Mirrors the v1\n * `computeStrategyHash` pattern.\n */\nexport async function computeQueryHash(\n mvName: string,\n /**\n * Source-collection set the query depends on. Sorted before\n * canonicalization so set iteration order doesn't affect the hash.\n */\n dependencies: ReadonlySet<string>,\n /**\n * Stringified query-plan summary. The caller produces this from the\n * `Query<T>` builder — concretely: a JSON serialization of clauses +\n * orderBy + limit + offset + joins. Function bodies inside\n * `wherePredicate` are NOT included here (those carry their own\n * `predicateHash` to be folded in by a later sub-issue).\n */\n queryPlanSummary: string,\n): Promise<string> {\n const canonical = JSON.stringify({\n mvName,\n dependencies: [...dependencies].sort(),\n queryPlanSummary,\n })\n const bytes = new TextEncoder().encode(canonical)\n const digest = await crypto.subtle.digest('SHA-256', bytes)\n return Array.from(new Uint8Array(digest))\n .map(b => b.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/**\n * Canonicalize a query plan for hashing. Walks the plan structure\n * with sorted keys so insertion order doesn't perturb the result.\n * Lives here rather than in `query/builder.ts` to keep that module\n * stable across MV-specific evolutions.\n *\n * @internal exported for testing\n */\nexport function canonicalizeQueryPlan(plan: unknown): string {\n return JSON.stringify(plan, (_key, value) => {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {}\n for (const k of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[k] = (value as Record<string, unknown>)[k]\n }\n return sorted\n }\n return value\n })\n}\n","import { MaterializedViewCycleError, MaterializedViewSourceUnknownError } from '../errors.js'\nimport type { DerivationRegistry } from '../derivations/registry.js'\nimport type { Clause, FieldClause } from '../query/predicate.js'\nimport type { DeclaredPredicate } from '../query/builder.js'\nimport { analyzeDependencies, summarizeQueryPlan, summarizeUnionPlan } from './dependency-analyzer.js'\nimport { computeQueryHash } from './query-hash.js'\nimport type { MaterializedViewStrategy, MVQueryContext } from './types.js'\n\n/**\n * One registered MV strategy alongside its derived metadata. Stored\n * type-erased on `TRow` so the registry can hold heterogeneous MVs.\n */\nexport interface RegisteredMV {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly spec: MaterializedViewStrategy<any>\n /** Output collection name (`spec.output?.collection ?? spec.name`). */\n readonly outputCollection: string\n /** Set of source collections; populated at registration via the analyzer. */\n readonly dependencies: ReadonlySet<string>\n /** Canonical `queryHash` — `_materializedFrom.queryHash` for every emitted row. */\n readonly queryHash: string\n /**\n * Top-level FieldClauses on the partition field, captured at\n * registration time. Used by the cycle detector to resolve\n * same-collection-as-source edges via the partition-discriminator\n * check. Empty when `spec.output?.partition` is undefined.\n */\n readonly partitionClauses: readonly FieldClause[]\n}\n\n/**\n * Vault-internal registry of MV strategies. Owned by `Vault`; not\n * exported. Parallel to v1's `DerivationRegistry`; the two graphs share\n * a single cycle-detection pass at vault open (see `validate`).\n *\n * @internal\n */\nexport class MaterializedViewRegistry {\n /** Keyed by `spec.name`. */\n private readonly _byName = new Map<string, RegisteredMV>()\n /** Keyed by dependency source-collection → MVs that depend on it. */\n private readonly _bySource = new Map<string, RegisteredMV[]>()\n\n /**\n * Register an MV. Invokes `spec.query()` once at registration time to\n * read the plan + join context; the resulting `Query<T>` is discarded\n * after dependency extraction. `vault.collection(...)` must therefore\n * be functional by the time this runs — typically wired from\n * `Vault._initMaterializedViews` after collection bootstrap.\n *\n * Throws `MaterializedViewSourceUnknownError` if the analyzer\n * surfaces a dependency the vault doesn't know about (when a\n * `knownCollections` checker is supplied).\n */\n async register(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: MaterializedViewStrategy<any>,\n db: MVQueryContext,\n options?: { knownCollections?: (name: string) => boolean },\n ): Promise<void> {\n // Build a predicate-aware db wrapper. If `spec.predicates` is\n // declared, the wrapper intercepts `.collection().query()` and\n // attaches the predicates map to the resulting Query<T>. With no\n // predicates declared, the wrapper is the original db unchanged.\n const dbForQuery = spec.predicates ? wrapDbWithPredicates(db, spec.predicates) : db\n\n // Invoke the query callback once to inspect its plan / dependencies.\n // For Query<T> shapes the analyzer extracts deps + plan summary\n // automatically. Aggregation / GroupedAggregation shapes don't\n // expose the underlying Query, so the spec must declare `sources`\n // explicitly. `partitionClauses` are only populated for Query<T>\n // since same-collection-partition is a non-aggregate concern.\n // UNION-form strategies: dependencies and plan summary come\n // straight off the strategy — no `query` callback to introspect.\n // The dependency-analyzer + summarizer are bypassed entirely; the\n // executor handles materialization via `materializeUnionResult`.\n let dependencies: Set<string>\n let queryPlanSummary: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let qAny: any = null\n let isQuery = false\n if (spec.unionSources) {\n dependencies = new Set(spec.unionSources.map(s => s.collection))\n queryPlanSummary = summarizeUnionPlan(spec)\n } else {\n const q = spec.query!(dbForQuery)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n qAny = q as any\n isQuery = typeof qAny._plan === 'function'\n if (isQuery) {\n dependencies = analyzeDependencies(q)\n queryPlanSummary = summarizeQueryPlan(q)\n // Fold `.wherePredicate(name, ctx)` references into the plan\n // summary so predicate function or ctx changes (signalled by\n // bumping `hash` or supplying a different ctx) propagate into\n // `queryHash` and force refresh on next visit.\n const predicateRefs = extractPredicateRefs(qAny._plan())\n if (predicateRefs.length > 0) {\n queryPlanSummary = JSON.stringify({ plan: queryPlanSummary, predicates: predicateRefs })\n }\n // If `sources` is ALSO declared, take the union (consumer's\n // explicit list extends the auto-analyzed set).\n if (spec.sources) for (const s of spec.sources) dependencies.add(s)\n } else {\n // Aggregate shape: require explicit `sources`.\n if (!spec.sources || spec.sources.length === 0) {\n throw new Error(\n `withMaterializedView \"${spec.name}\": query() returned an aggregate ` +\n `(Aggregation or GroupedAggregation) but no \\`sources\\` field is declared. ` +\n `The dependency analyzer cannot walk through groupBy().aggregate() ` +\n `back to the source — declare sources: [...] explicitly.`,\n )\n }\n dependencies = new Set(spec.sources)\n // Aggregate plans don't carry a chainable query plan for summary\n // purposes; the dep-set + spec.name serve as the queryHash inputs.\n queryPlanSummary = JSON.stringify({ aggregate: true, sources: [...spec.sources].sort() })\n }\n }\n\n // Sanity-check declared dependencies against the vault's known\n // collections. Optional — when the checker isn't supplied (test\n // wiring, in-process composition) the registration succeeds and\n // any typo surfaces at first onSourceWrite as a no-op.\n if (options?.knownCollections) {\n for (const dep of dependencies) {\n if (!options.knownCollections(dep)) {\n throw new MaterializedViewSourceUnknownError(spec.name, dep)\n }\n }\n }\n\n const outputCollection = spec.output?.collection ?? spec.name\n const queryHash = await computeQueryHash(spec.name, dependencies, queryPlanSummary)\n // For same-collection-as-source MVs, capture the where-clauses on\n // the partition field so cycle detection can prove disjointness.\n // Only applicable to Query<T> shapes — aggregate MVs don't carry\n // a chainable plan to inspect (and same-collection aggregation\n // doesn't make sense for same-collection aggregation).\n const partitionClauses: FieldClause[] = []\n const partitionField = spec.output?.partition?.field\n if (partitionField !== undefined && isQuery) {\n const plan = qAny._plan()\n for (const clause of plan.clauses) {\n if (isFieldClauseOnField(clause, partitionField)) partitionClauses.push(clause)\n }\n }\n const reg: RegisteredMV = { spec, outputCollection, dependencies, queryHash, partitionClauses }\n\n this._byName.set(spec.name, reg)\n for (const dep of dependencies) {\n const arr = this._bySource.get(dep)\n if (arr) arr.push(reg)\n else this._bySource.set(dep, [reg])\n }\n }\n\n /** All MVs that depend on `source`, in registration order. */\n mvsForSource(source: string): ReadonlyArray<RegisteredMV> {\n return this._bySource.get(source) ?? []\n }\n\n /** Single MV by name, or `undefined`. */\n byName(name: string): RegisteredMV | undefined {\n return this._byName.get(name)\n }\n\n /** Iterate over every registered MV. */\n all(): ReadonlyArray<RegisteredMV> {\n return [...this._byName.values()]\n }\n\n /**\n * Cycle detection over the combined derivation + MV graph. Edges:\n * - Derivation: derivation.source → output.collection (each output)\n * - MV: every dep in MV.dependencies → MV.outputCollection\n *\n * Throws `MaterializedViewCycleError` if the cycle's terminal node\n * is an MV output collection; otherwise (a pure-derivation cycle)\n * the caller's `DerivationRegistry.validate()` will surface\n * `DerivationCycleError` separately at vault open.\n *\n * Call AFTER all `register()` calls complete.\n */\n validate(derivationRegistry?: DerivationRegistry | null): void {\n const visited = new Set<string>()\n const stack: string[] = []\n const mvOutputs = new Set<string>()\n for (const reg of this._byName.values()) mvOutputs.add(reg.outputCollection)\n\n const edges = new Map<string, string[]>()\n\n // MV edges: every dep → output. Same-collection edges (dep ===\n // outputCollection) are skipped IFF the MV declares an\n // `output.partition` discriminator AND the query has a where-clause\n // that provably excludes the partition value. Otherwise the cycle\n // detector treats the edge as real — naïve same-collection MVs\n // surface as `MaterializedViewCycleError`.\n for (const reg of this._byName.values()) {\n for (const dep of reg.dependencies) {\n if (dep === reg.outputCollection && partitionDisjoint(reg)) continue\n const arr = edges.get(dep)\n if (arr) arr.push(reg.outputCollection)\n else edges.set(dep, [reg.outputCollection])\n }\n }\n\n // Derivation edges: source → output collections\n if (derivationRegistry) {\n // The shared DerivationRegistry exposes its edges via the same\n // `strategiesForSource` API its own `validate()` uses. We don't\n // duplicate cycle detection — we add MV nodes to the graph and\n // run the unified DFS, attributing cycles that touch an MV\n // output to `MaterializedViewCycleError`.\n for (const reg of this._byName.values()) {\n // Walk every dependency through derivation edges too: a\n // derivation whose output we depend on is itself a source.\n void reg\n }\n // Pull derivation edges by scanning every MV dep + every MV\n // output as potential derivation sources.\n const sourcesToScan = new Set<string>()\n for (const reg of this._byName.values()) {\n for (const dep of reg.dependencies) sourcesToScan.add(dep)\n sourcesToScan.add(reg.outputCollection)\n }\n for (const src of sourcesToScan) {\n const strategies = derivationRegistry.strategiesForSource(src)\n if (strategies.length === 0) continue\n for (const s of strategies) {\n for (const key of Object.keys(s.spec.outputs)) {\n const o = s.spec.outputs[key]\n if (!o) continue\n const arr = edges.get(src)\n if (arr) arr.push(o.collection)\n else edges.set(src, [o.collection])\n }\n }\n }\n }\n\n const visit = (node: string): void => {\n if (stack.includes(node)) {\n const cycle = stack.slice(stack.indexOf(node)).concat(node)\n // If any node on the cycle is an MV output, attribute as MV\n // cycle. Otherwise let DerivationRegistry.validate() surface it.\n if (cycle.some(n => mvOutputs.has(n))) {\n throw new MaterializedViewCycleError(cycle)\n }\n // Pure-derivation cycle — caller's DerivationRegistry.validate()\n // will catch it separately. Don't double-report.\n return\n }\n if (visited.has(node)) return\n stack.push(node)\n const outs = edges.get(node)\n if (outs) for (const o of outs) visit(o)\n stack.pop()\n visited.add(node)\n }\n\n for (const node of edges.keys()) visit(node)\n }\n}\n\n/**\n * Type guard: is the clause a top-level `FieldClause` on the given\n * field? Used by the partition-disjoint check.\n *\n * @internal\n */\nfunction isFieldClauseOnField(clause: Clause, field: string): clause is FieldClause {\n return clause.type === 'field' && clause.field === field\n}\n\n/**\n * Wrap an `MVQueryContext` so its `.collection().query()` returns a\n * Query<T> with the MV's declared predicates attached. Bare Queries\n * (outside of any MV) don't gain `.wherePredicate()` — only Queries\n * obtained through this wrapped db do.\n *\n * @internal\n */\nexport function wrapDbWithPredicates(\n db: MVQueryContext,\n predicates: NonNullable<MaterializedViewStrategy<Record<string, unknown>>['predicates']>,\n): MVQueryContext {\n // Build the predicate map once — the fn signature in the MV spec\n // is row-typed but the QueryBuilder casts to unknown, so we widen\n // here for the Map.\n const map = new Map<string, DeclaredPredicate>()\n for (const [name, decl] of Object.entries(predicates)) {\n map.set(name, {\n hash: decl.hash,\n fn: decl.fn as (record: unknown, ctx?: unknown) => boolean,\n })\n }\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n collection<T extends Record<string, unknown>>(name: string): any {\n const c = db.collection<T>(name)\n // Return an object that delegates everything to `c` but\n // overrides `.query()` to attach predicates via the new\n // `Query._withPredicates()` accessor.\n return new Proxy(c, {\n get(target, prop, receiver) {\n if (prop === 'query') {\n return (...args: unknown[]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const q = (target.query as any)(...args)\n // For non-aggregate Query<T>, attach predicates. For\n // legacy predicate-arg overload that returns T[] (sync\n // filter), pass through unchanged.\n \n if (q && typeof q._withPredicates === 'function') {\n return q._withPredicates(map)\n }\n return q\n }\n }\n return Reflect.get(target, prop, receiver)\n },\n })\n },\n }\n}\n\n/**\n * Walk a QueryPlan's clauses and collect predicate-reference markers\n * for `queryHash` derivation. Returns a sorted array (deterministic\n * order) of `{ name, predicateHash, ctxHash }` tuples — these are the\n * hashable identity of each `.wherePredicate()` call site.\n *\n * @internal\n */\nfunction extractPredicateRefs(\n plan: { clauses: readonly Clause[] },\n): Array<{ name: string; predicateHash: string; ctxHash: string }> {\n const refs: Array<{ name: string; predicateHash: string; ctxHash: string }> = []\n const walk = (clauses: readonly Clause[]): void => {\n for (const c of clauses) {\n if (c.type === 'wherePredicate') {\n refs.push({ name: c.name, predicateHash: c.predicateHash, ctxHash: c.ctxHash })\n } else if (c.type === 'group') {\n walk(c.clauses)\n }\n }\n }\n walk(plan.clauses)\n // Stable-sort by (name, predicateHash, ctxHash) — same predicate\n // appearing twice with different ctx hashes both flow through.\n refs.sort((a, b) => {\n if (a.name !== b.name) return a.name < b.name ? -1 : 1\n if (a.predicateHash !== b.predicateHash) return a.predicateHash < b.predicateHash ? -1 : 1\n return a.ctxHash < b.ctxHash ? -1 : a.ctxHash > b.ctxHash ? 1 : 0\n })\n return refs\n}\n\n/**\n * Provability check for the same-collection partition-discriminator\n * (spec § Same-collection-as-source MV). Returns `true` when\n * the captured partition clauses on the MV's query provably exclude\n * the partition's value — meaning the input filter and the output\n * partition are disjoint and the same-collection edge isn't really a\n * cycle.\n *\n * Supported provability shapes (narrow on purpose — DERIV-PP30-001\n * is the load-bearing case):\n *\n * - `.where(field, '==', X)` where X !== partition.value → disjoint\n * - `.where(field, '!=', partition.value)` → disjoint\n * - `.where(field, 'in', [...])` where partition.value NOT in list → disjoint\n *\n * Anything else (no clause on the partition field, an 'in' list that\n * contains partition.value, unsupported operators) → not disjoint,\n * the cycle detector surfaces `MaterializedViewCycleError`.\n *\n * @internal\n */\nfunction partitionDisjoint(reg: RegisteredMV): boolean {\n const partition = reg.spec.output?.partition\n if (partition === undefined) return false\n const value = partition.value\n // The OR-semantics of multiple where-clauses on the same field\n // would muddy this check. v2 only treats AND-chained clauses;\n // any clause that proves disjoint is sufficient.\n for (const c of reg.partitionClauses) {\n if (c.op === '==' && c.value !== value) return true\n if (c.op === '!=' && c.value === value) return true\n if (c.op === 'in' && Array.isArray(c.value)) {\n const list = c.value as readonly unknown[]\n if (!list.includes(value)) return true\n }\n }\n return false\n}\n"],"mappings":";;;;;;AAwBO,SAAS,oBAAoB,OAAgC;AAClE,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,OAAO,MAAM,MAAM;AACzB,QAAM,MAAM,MAAM,aAAa;AAG/B,MAAI,KAAK,gBAAgB;AACvB,SAAK,IAAI,IAAI,cAAc;AAAA,EAC7B;AAGA,aAAW,OAAO,KAAK,OAAO;AAC5B,SAAK,IAAI,IAAI,MAAM;AAAA,EACrB;AAIA,aAAW,UAAU,KAAK,SAAS;AACjC,QAAI,OAAO,SAAS,aAAa;AAC/B,WAAK,IAAI,OAAO,MAAM;AAAA,IACxB;AAAA,EACF;AAKA,sBAAoB,MAAM,MAAM,GAAG;AAEnC,SAAO;AACT;AAEA,SAAS,oBACP,MACA,MACA,KACM;AACN,OAAK;AAIL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B;AACrD,QAAM,YAAY,IAAI,KAAK,QAAQ;AACnC,MAAI,cAAc,OAAW,QAAO;AACpC,QAAM,QAAQ,UAAU;AAIxB,aAAW,KAAK,IAAI,kBAAkB;AACpC,QAAI,EAAE,OAAO,QAAQ,EAAE,UAAU,MAAO,QAAO;AAC/C,QAAI,EAAE,OAAO,QAAQ,EAAE,UAAU,MAAO,QAAO;AAC/C,QAAI,EAAE,OAAO,QAAQ,MAAM,QAAQ,EAAE,KAAK,GAAG;AAC3C,YAAM,OAAO,EAAE;AACf,UAAI,CAAC,KAAK,SAAS,KAAK,EAAG,QAAO;AAAA,IACpC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  ConflictError,
7
7
  InvariantError,
8
8
  ValidationError
9
- } from "./chunk-6HJ2ZALB.js";
9
+ } from "./chunk-B6PB7JLN.js";
10
10
 
11
11
  // src/tx/transaction.ts
12
12
  var TxContext = class {
@@ -209,7 +209,7 @@ async function runTransaction(db, fn, options) {
209
209
  db._clearActiveTxContext(ctx);
210
210
  }
211
211
  if (ctx._amendment) {
212
- const { GuardExecutor } = await import("./executor-AWCHQ2KN.js");
212
+ const { GuardExecutor } = await import("./executor-5PNY7LGW.js");
213
213
  try {
214
214
  for (const [vaultName, v] of ctx._amendmentVaults) {
215
215
  const registry = v._getGuardRegistry();
@@ -293,4 +293,4 @@ export {
293
293
  runTransaction,
294
294
  revertExecuted
295
295
  };
296
- //# sourceMappingURL=chunk-LJO6Q3X6.js.map
296
+ //# sourceMappingURL=chunk-TFBP23BX.js.map
@@ -63,6 +63,10 @@ function evaluateClause(record, clause) {
63
63
  return clause.fn(record);
64
64
  case "wherePredicate":
65
65
  return clause.fn(record, clause.ctx);
66
+ case "crossJoin":
67
+ throw new Error(
68
+ `evaluateClause: 'crossJoin' clauses are expansion primitives and are not evaluated per-record. This is a query planner routing error \u2014 crossJoin clauses must be extracted from the clause list before calling evaluateClause or filterRecords.`
69
+ );
66
70
  case "group":
67
71
  if (clause.op === "and") {
68
72
  for (const child of clause.clauses) {
@@ -83,4 +87,4 @@ export {
83
87
  evaluateFieldClause,
84
88
  evaluateClause
85
89
  };
86
- //# sourceMappingURL=chunk-ICH4AIGL.js.map
90
+ //# sourceMappingURL=chunk-TV3YZ35S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query/predicate.ts"],"sourcesContent":["/**\n * Operator implementations for the query DSL.\n *\n * All predicates run client-side, AFTER decryption — they never see ciphertext.\n * This file is dependency-free and tree-shakeable.\n */\n\n/** Comparison operators supported by the where() builder. */\nexport type Operator =\n | '=='\n | '!='\n | '<'\n | '<='\n | '>'\n | '>='\n | 'in'\n | 'contains'\n | 'startsWith'\n | 'between'\n\n/**\n * A single field comparison clause inside a query plan.\n * Plans are JSON-serializable, so this type uses primitives only.\n */\nexport interface FieldClause {\n readonly type: 'field'\n readonly field: string\n readonly op: Operator\n readonly value: unknown\n}\n\n/**\n * A user-supplied predicate function escape hatch. Not serializable.\n *\n * The predicate accepts `unknown` at the type level so the surrounding\n * Clause type can stay non-parametric — this keeps Collection<T> covariant\n * in T at the public API surface. Builder methods cast user predicates\n * (typed `(record: T) => boolean`) into this shape on the way in.\n */\nexport interface FilterClause {\n readonly type: 'filter'\n readonly fn: (record: unknown) => boolean\n}\n\n/**\n * A declared deterministic predicate reference. The query\n * builder produces this via `.wherePredicate(name, ctx?)` when a\n * Query has been augmented with a predicates map (typically by the\n * materialized-view registry — see MV v2 spec § Function-based\n * source-row predicates).\n *\n * `predicateHash` is the consumer-supplied stable hash for the\n * function body; `ctxHash` is the canonical-JSON SHA-256 of `ctx`.\n * Both fold into the MV's `queryHash` so a function or ctx change\n * forces refresh on next visit.\n *\n * `fn` is resolved at builder time from the predicates map and\n * embedded directly — so `evaluateClause` can fire it without a\n * runtime lookup.\n */\nexport interface WherePredicateClause {\n readonly type: 'wherePredicate'\n readonly name: string\n readonly ctx: unknown\n readonly predicateHash: string\n readonly ctxHash: string\n readonly fn: (record: unknown, ctx?: unknown) => boolean\n}\n\n/** A logical group of clauses combined by AND or OR. */\nexport interface GroupClause {\n readonly type: 'group'\n readonly op: 'and' | 'or'\n readonly clauses: readonly Clause[]\n}\n\n/**\n * Cartesian-product expansion clause. Appended to `QueryPlan.clauses`\n * by `Query.crossJoin()`. Processed in declaration order by\n * `executeClausePipeline` — NOT by `evaluateClause` (which is a\n * per-record predicate and throws on this type).\n */\nexport interface CrossJoinClause {\n readonly type: 'crossJoin'\n /** Target collection name to cross-join against. */\n readonly target: string\n /** Alias under which the right-side record is exposed on each result row. */\n readonly as: string\n /**\n * Lateral filter callback. `undefined` → full cartesian product.\n * Two call shapes:\n * - Subset: `(left) => TTarget[]` — returns the right rows for this left row\n * - Predicate: `(left) => (right) => boolean` — executor materializes then filters\n */\n readonly on?: (left: unknown) => unknown[] | ((right: unknown) => boolean)\n /** When `on:` was supplied as `{ predicate: name }`, the name is stored here for queryHash. */\n readonly onPredicateName?: string\n /** Per-clause row ceiling override. `undefined` → `DEFAULT_CROSS_JOIN_MAX_ROWS`. */\n readonly maxRows?: number\n}\n\nexport type Clause = FieldClause | FilterClause | WherePredicateClause | GroupClause | CrossJoinClause\n\n/**\n * Read a possibly nested field path like \"address.city\" from a record.\n * Returns undefined if any segment is missing.\n */\nexport function readPath(record: unknown, path: string): unknown {\n if (record === null || record === undefined) return undefined\n if (!path.includes('.')) {\n return (record as Record<string, unknown>)[path]\n }\n const segments = path.split('.')\n let cursor: unknown = record\n for (const segment of segments) {\n if (cursor === null || cursor === undefined) return undefined\n cursor = (cursor as Record<string, unknown>)[segment]\n }\n return cursor\n}\n\n/**\n * Evaluate a single field clause against a record.\n * Returns false on type mismatches rather than throwing — query results\n * exclude non-matching records by definition.\n */\nexport function evaluateFieldClause(record: unknown, clause: FieldClause): boolean {\n const actual = readPath(record, clause.field)\n const { op, value } = clause\n\n switch (op) {\n case '==':\n return actual === value\n case '!=':\n return actual !== value\n case '<':\n return isComparable(actual, value) && (actual as number) < (value as number)\n case '<=':\n return isComparable(actual, value) && (actual as number) <= (value as number)\n case '>':\n return isComparable(actual, value) && (actual as number) > (value as number)\n case '>=':\n return isComparable(actual, value) && (actual as number) >= (value as number)\n case 'in':\n return Array.isArray(value) && value.includes(actual)\n case 'contains':\n if (typeof actual === 'string') return typeof value === 'string' && actual.includes(value)\n if (Array.isArray(actual)) return actual.includes(value)\n return false\n case 'startsWith':\n return typeof actual === 'string' && typeof value === 'string' && actual.startsWith(value)\n case 'between': {\n if (!Array.isArray(value) || value.length !== 2) return false\n const [lo, hi] = value\n if (!isComparable(actual, lo) || !isComparable(actual, hi)) return false\n return (actual as number) >= (lo as number) && (actual as number) <= (hi as number)\n }\n default: {\n // Exhaustiveness — TS will error if a new operator is added without a case.\n const _exhaustive: never = op\n void _exhaustive\n return false\n }\n }\n}\n\n/**\n * Two values are \"comparable\" if they share an order-defined runtime type.\n * Strings compare lexicographically; numbers and Dates numerically; otherwise false.\n */\nfunction isComparable(a: unknown, b: unknown): boolean {\n if (typeof a === 'number' && typeof b === 'number') return true\n if (typeof a === 'string' && typeof b === 'string') return true\n if (a instanceof Date && b instanceof Date) return true\n return false\n}\n\n/**\n * Evaluate any clause (field / filter / group) against a record.\n * The recursion depth is bounded by the user's query expression — no risk of\n * blowing the stack on a 50K-record collection.\n */\nexport function evaluateClause(record: unknown, clause: Clause): boolean {\n switch (clause.type) {\n case 'field':\n return evaluateFieldClause(record, clause)\n case 'filter':\n return clause.fn(record)\n case 'wherePredicate':\n return clause.fn(record, clause.ctx)\n case 'crossJoin':\n throw new Error(\n `evaluateClause: 'crossJoin' clauses are expansion primitives and are not ` +\n `evaluated per-record. This is a query planner routing error — ` +\n `crossJoin clauses must be extracted from the clause list before calling ` +\n `evaluateClause or filterRecords.`,\n )\n case 'group':\n if (clause.op === 'and') {\n for (const child of clause.clauses) {\n if (!evaluateClause(record, child)) return false\n }\n return true\n } else {\n for (const child of clause.clauses) {\n if (evaluateClause(record, child)) return true\n }\n return false\n }\n }\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AAI,EAAE,IAAI;AACjB,UAAI,CAAC,aAAa,QAAQ,EAAE,KAAK,CAAC,aAAa,QAAQ,EAAE,EAAG,QAAO;AACnE,aAAQ,UAAsB,MAAkB,UAAsB;AAAA,IACxE;AAAA,IACA,SAAS;AAEP,YAAM,cAAqB;AAC3B,WAAK;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAMA,SAAS,aAAa,GAAY,GAAqB;AACrD,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SAAU,QAAO;AAC3D,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SAAU,QAAO;AAC3D,MAAI,aAAa,QAAQ,aAAa,KAAM,QAAO;AACnD,SAAO;AACT;AAOO,SAAS,eAAe,QAAiB,QAAyB;AACvE,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,oBAAoB,QAAQ,MAAM;AAAA,IAC3C,KAAK;AACH,aAAO,OAAO,GAAG,MAAM;AAAA,IACzB,KAAK;AACH,aAAO,OAAO,GAAG,QAAQ,OAAO,GAAG;AAAA,IACrC,KAAK;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MAIF;AAAA,IACF,KAAK;AACH,UAAI,OAAO,OAAO,OAAO;AACvB,mBAAW,SAAS,OAAO,SAAS;AAClC,cAAI,CAAC,eAAe,QAAQ,KAAK,EAAG,QAAO;AAAA,QAC7C;AACA,eAAO;AAAA,MACT,OAAO;AACL,mBAAW,SAAS,OAAO,SAAS;AAClC,cAAI,eAAe,QAAQ,KAAK,EAAG,QAAO;AAAA,QAC5C;AACA,eAAO;AAAA,MACT;AAAA,EACJ;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TierNotGrantedError
3
- } from "./chunk-6HJ2ZALB.js";
3
+ } from "./chunk-B6PB7JLN.js";
4
4
 
5
5
  // src/team/tiers.ts
6
6
  function dekKey(collection, tier) {
@@ -31,4 +31,4 @@ export {
31
31
  effectiveClearance,
32
32
  assertTierAccess
33
33
  };
34
- //# sourceMappingURL=chunk-TNBIWSQ7.js.map
34
+ //# sourceMappingURL=chunk-U26HQ6KJ.js.map
@@ -2,7 +2,7 @@ import {
2
2
  OverlayBaseIsVirtualError,
3
3
  OverlayCollectionUnavailableError,
4
4
  OverlayNameCollisionError
5
- } from "./chunk-6HJ2ZALB.js";
5
+ } from "./chunk-B6PB7JLN.js";
6
6
 
7
7
  // src/overlay-views/registry.ts
8
8
  var OverlayedViewRegistry = class {
@@ -58,4 +58,4 @@ var OverlayedViewRegistry = class {
58
58
  export {
59
59
  OverlayedViewRegistry
60
60
  };
61
- //# sourceMappingURL=chunk-CGJFCT3X.js.map
61
+ //# sourceMappingURL=chunk-VTKGMEPP.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readPath
3
- } from "./chunk-ICH4AIGL.js";
3
+ } from "./chunk-TV3YZ35S.js";
4
4
 
5
5
  // src/aggregate/reducers.ts
6
6
  function count(opts) {
@@ -97,4 +97,4 @@ export {
97
97
  min,
98
98
  max
99
99
  };
100
- //# sourceMappingURL=chunk-5VMTAX4Y.js.map
100
+ //# sourceMappingURL=chunk-W6EQLGMB.js.map
@@ -14,4 +14,4 @@ export {
14
14
  NOYDB_SYNC_VERSION,
15
15
  createStore
16
16
  };
17
- //# sourceMappingURL=chunk-5OVIFUQE.js.map
17
+ //# sourceMappingURL=chunk-WIRRPTFH.js.map