@noy-db/hub 0.3.0-pre.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (955) hide show
  1. package/dist/aggregate/index.js +9 -8
  2. package/dist/aggregate/index.js.map +1 -1
  3. package/dist/api-ZGS6LCOF.js +20 -0
  4. package/dist/as/index.js +11 -11
  5. package/dist/attestation/index.js +18 -18
  6. package/dist/backup-BJ57IKAO.js +242 -0
  7. package/dist/backup-BJ57IKAO.js.map +1 -0
  8. package/dist/blobs/index.js +13 -11
  9. package/dist/blobs/index.js.map +1 -1
  10. package/dist/broker/index.js +92 -0
  11. package/dist/broker/index.js.map +1 -0
  12. package/dist/bundle/index.js +25 -22
  13. package/dist/bundle/index.js.map +1 -1
  14. package/dist/by/index.js +2 -2
  15. package/dist/cargo/index.js +31 -31
  16. package/dist/chunk-2NVOWNI3.js +167 -0
  17. package/dist/chunk-2NVOWNI3.js.map +1 -0
  18. package/dist/chunk-3B5VVCNY.js +71 -0
  19. package/dist/chunk-3LQ2YKO4.js +230 -0
  20. package/dist/chunk-3QCRBHCY.js +54 -0
  21. package/dist/chunk-454JXE57.js +1697 -0
  22. package/dist/chunk-454JXE57.js.map +1 -0
  23. package/dist/chunk-4CTHCN4J.js +480 -0
  24. package/dist/chunk-4CTHCN4J.js.map +1 -0
  25. package/dist/chunk-4GPE63GU.js +111 -0
  26. package/dist/chunk-4GPE63GU.js.map +1 -0
  27. package/dist/chunk-4JBYV75E.js +150 -0
  28. package/dist/chunk-4NXKCLLQ.js +97 -0
  29. package/dist/chunk-4VNQOLML.js +29 -0
  30. package/dist/chunk-4VNQOLML.js.map +1 -0
  31. package/dist/chunk-5M5DVGV7.js +69 -0
  32. package/dist/chunk-5O3XF4DV.js +150 -0
  33. package/dist/chunk-5O3XF4DV.js.map +1 -0
  34. package/dist/chunk-5YOLBEQ6.js +30 -0
  35. package/dist/chunk-6CRIV7DE.js +129 -0
  36. package/dist/chunk-6JTIAGHD.js +621 -0
  37. package/dist/chunk-6JTIAGHD.js.map +1 -0
  38. package/dist/chunk-6QTNZJBS.js +255 -0
  39. package/dist/chunk-6T2SCQRU.js +86 -0
  40. package/dist/chunk-7DSTRQIJ.js +45 -0
  41. package/dist/chunk-AUSTCW2X.js +589 -0
  42. package/dist/chunk-B3HJYUOF.js +209 -0
  43. package/dist/chunk-BDVFPG6Y.js +164 -0
  44. package/dist/chunk-BIOUI4HL.js +1554 -0
  45. package/dist/chunk-BIOUI4HL.js.map +1 -0
  46. package/dist/chunk-CAF6WOK7.js +36 -0
  47. package/dist/chunk-CDUQTA3Z.js +381 -0
  48. package/dist/chunk-CDUQTA3Z.js.map +1 -0
  49. package/dist/chunk-CIE2BASH.js +404 -0
  50. package/dist/chunk-CRI4OUV4.js +42 -0
  51. package/dist/chunk-DLG74CNB.js +91 -0
  52. package/dist/chunk-E5ZQT5KX.js +30 -0
  53. package/dist/chunk-E5ZQT5KX.js.map +1 -0
  54. package/dist/chunk-EQO2UVP4.js +247 -0
  55. package/dist/chunk-EQO2UVP4.js.map +1 -0
  56. package/dist/chunk-ERJ7FU55.js +367 -0
  57. package/dist/chunk-EVVGJDRQ.js +205 -0
  58. package/dist/chunk-EVX47VBM.js +74 -0
  59. package/dist/chunk-EVX47VBM.js.map +1 -0
  60. package/dist/chunk-EXK7QRWF.js +59 -0
  61. package/dist/chunk-EYZ6IQ6X.js +202 -0
  62. package/dist/chunk-F64IRYG3.js +45 -0
  63. package/dist/chunk-FHS2HQSH.js +823 -0
  64. package/dist/chunk-FM3G3NOY.js +206 -0
  65. package/dist/chunk-FM3G3NOY.js.map +1 -0
  66. package/dist/chunk-FUG4SFN3.js +36 -0
  67. package/dist/chunk-FUG4SFN3.js.map +1 -0
  68. package/dist/chunk-GKEWXIV5.js +80 -0
  69. package/dist/chunk-GTGPO5KW.js +59 -0
  70. package/dist/chunk-HB3RFQSC.js +95 -0
  71. package/dist/chunk-HDMEGAQE.js +957 -0
  72. package/dist/chunk-HDMEGAQE.js.map +1 -0
  73. package/dist/chunk-HDQIIUPH.js +135 -0
  74. package/dist/chunk-HDQIIUPH.js.map +1 -0
  75. package/dist/chunk-HTJQYHZP.js +344 -0
  76. package/dist/chunk-HTJQYHZP.js.map +1 -0
  77. package/dist/chunk-I6GALP6E.js +99 -0
  78. package/dist/chunk-IGJCYUT5.js +99 -0
  79. package/dist/chunk-IGJCYUT5.js.map +1 -0
  80. package/dist/chunk-IL6POWCW.js +130 -0
  81. package/dist/chunk-IU6SNYX6.js +117 -0
  82. package/dist/chunk-J2ZX2XUV.js +778 -0
  83. package/dist/chunk-JIF24JPM.js +495 -0
  84. package/dist/chunk-JIF24JPM.js.map +1 -0
  85. package/dist/chunk-JK733I5V.js +23 -0
  86. package/dist/chunk-JK733I5V.js.map +1 -0
  87. package/dist/chunk-JKJOGPZN.js +29 -0
  88. package/dist/chunk-JNAI2HN2.js +32 -0
  89. package/dist/chunk-JNAI2HN2.js.map +1 -0
  90. package/dist/chunk-JZUV47FZ.js +41 -0
  91. package/dist/chunk-K5IMOGHB.js +30 -0
  92. package/dist/chunk-KPZS5QAQ.js +151 -0
  93. package/dist/chunk-KPZS5QAQ.js.map +1 -0
  94. package/dist/chunk-KSKBRKGJ.js +291 -0
  95. package/dist/chunk-KSKBRKGJ.js.map +1 -0
  96. package/dist/chunk-LASZKVMO.js +382 -0
  97. package/dist/chunk-LXEXBTKL.js +515 -0
  98. package/dist/chunk-LXEXBTKL.js.map +1 -0
  99. package/dist/chunk-M4CV6BRT.js +524 -0
  100. package/dist/chunk-M4CV6BRT.js.map +1 -0
  101. package/dist/chunk-MEFJPTZ4.js +371 -0
  102. package/dist/chunk-MEFJPTZ4.js.map +1 -0
  103. package/dist/chunk-MV43JSJF.js +265 -0
  104. package/dist/chunk-MV43JSJF.js.map +1 -0
  105. package/dist/chunk-NJ4EOKMB.js +392 -0
  106. package/dist/chunk-NJ4EOKMB.js.map +1 -0
  107. package/dist/chunk-NR5LT5RY.js +135 -0
  108. package/dist/chunk-NWSGI5C7.js +261 -0
  109. package/dist/chunk-NWSGI5C7.js.map +1 -0
  110. package/dist/chunk-OSDB5WW3.js +739 -0
  111. package/dist/chunk-OSDB5WW3.js.map +1 -0
  112. package/dist/chunk-PN2XMATY.js +37 -0
  113. package/dist/chunk-PN2XMATY.js.map +1 -0
  114. package/dist/chunk-Q5VNKNE5.js +70 -0
  115. package/dist/chunk-QLWMEXCT.js +21 -0
  116. package/dist/chunk-QRB7NAOJ.js +123 -0
  117. package/dist/chunk-R4ROFEYC.js +74 -0
  118. package/dist/chunk-RCVJZMFE.js +164 -0
  119. package/dist/chunk-RCVJZMFE.js.map +1 -0
  120. package/dist/chunk-RIX4V2TB.js +367 -0
  121. package/dist/chunk-RYCTDFUX.js +40 -0
  122. package/dist/chunk-RZ5SVOYR.js +155 -0
  123. package/dist/chunk-SLFHQTTW.js +99 -0
  124. package/dist/chunk-SNZ6URZZ.js +2782 -0
  125. package/dist/chunk-SNZ6URZZ.js.map +1 -0
  126. package/dist/chunk-T2FFWNPK.js +75 -0
  127. package/dist/chunk-T2FFWNPK.js.map +1 -0
  128. package/dist/chunk-UNFPPVNI.js +23 -0
  129. package/dist/chunk-VFUPHI2Z.js +333 -0
  130. package/dist/chunk-VFUPHI2Z.js.map +1 -0
  131. package/dist/chunk-VLFCJYTL.js +235 -0
  132. package/dist/chunk-VN3DBQAU.js +124 -0
  133. package/dist/chunk-VYYM3MEN.js +98 -0
  134. package/dist/chunk-VYYM3MEN.js.map +1 -0
  135. package/dist/chunk-VZRODIM3.js +49 -0
  136. package/dist/chunk-W22IKJE2.js +94 -0
  137. package/dist/chunk-X3YYQWOQ.js +155 -0
  138. package/dist/chunk-X7QBD67R.js +14405 -0
  139. package/dist/chunk-X7QBD67R.js.map +1 -0
  140. package/dist/chunk-XDYREZWE.js +1128 -0
  141. package/dist/chunk-XDYREZWE.js.map +1 -0
  142. package/dist/chunk-XWZVFISC.js +720 -0
  143. package/dist/chunk-XWZVFISC.js.map +1 -0
  144. package/dist/chunk-YFXZEAYK.js +85 -0
  145. package/dist/chunk-ZAJAVEXY.js +50 -0
  146. package/dist/chunk-ZICD77GM.js +34 -0
  147. package/dist/chunk-ZJ2AK4V7.js +38 -0
  148. package/dist/chunk-ZJ2AK4V7.js.map +1 -0
  149. package/dist/chunk-ZUODRVHY.js +14 -0
  150. package/dist/classified/index.js +5 -3
  151. package/dist/classified-marker-CZKA6ITE.js +28 -0
  152. package/dist/classified-marker-CZKA6ITE.js.map +1 -0
  153. package/dist/collection-facade-TLWIPI76.js +44 -0
  154. package/dist/computed-ZIQTYTDI.js +11 -0
  155. package/dist/consent/index.js +9 -9
  156. package/dist/crdt/index.js +1 -1
  157. package/dist/dead-filter-ESOBZZP5.js +28 -0
  158. package/dist/delegation-W7ZV2322.js +25 -0
  159. package/dist/derivations/index.js +12 -11
  160. package/dist/derive-H2BJTLUI.js +21 -0
  161. package/dist/enclave-AP3I5W7O.js +141 -0
  162. package/dist/executor-KGWTNEQD.js +9 -0
  163. package/dist/executor-OVEXR6RT.js +9 -0
  164. package/dist/executor-UNEH5ZYH.js +25 -0
  165. package/dist/export-accessible-PCMXSUZS.js +23 -0
  166. package/dist/extract-partition-SWHFSYJO.js +38 -0
  167. package/dist/fanout-sidecar-A765THMX.js +74 -0
  168. package/dist/find-N6345CNT.js +11 -0
  169. package/dist/forget/index.js +10 -10
  170. package/dist/forget/index.js.map +1 -1
  171. package/dist/guards/index.js +6 -6
  172. package/dist/history/index.js +14 -11
  173. package/dist/history/index.js.map +1 -1
  174. package/dist/i18n/index.js +50 -37
  175. package/dist/i18n/index.js.map +1 -1
  176. package/dist/index.d.ts +307 -1459
  177. package/dist/index.js +595 -198
  178. package/dist/index.js.map +1 -1
  179. package/dist/indexing/index.js +7 -7
  180. package/dist/indexing/index.js.map +1 -1
  181. package/dist/issue-5OKB6I2R.js +19 -0
  182. package/dist/kernel/best-effort-revert.d.ts +52 -0
  183. package/dist/kernel/cache/index.d.ts +10 -0
  184. package/dist/kernel/cache/lru.d.ts +97 -0
  185. package/dist/kernel/cache/policy.d.ts +32 -0
  186. package/dist/kernel/collection-config.d.ts +809 -0
  187. package/dist/kernel/collection.d.ts +1522 -0
  188. package/dist/kernel/constants.d.ts +18 -0
  189. package/dist/kernel/debug.d.ts +25 -0
  190. package/dist/kernel/enclave/broker/proof.d.ts +154 -0
  191. package/dist/kernel/enclave/classify/bidx.d.ts +77 -0
  192. package/dist/kernel/enclave/classify/compare.d.ts +10 -0
  193. package/dist/kernel/enclave/classify/digest.d.ts +8 -0
  194. package/dist/kernel/enclave/classify/find.d.ts +36 -0
  195. package/dist/kernel/enclave/classify/kofn.d.ts +7 -0
  196. package/dist/kernel/enclave/classify/normalize.d.ts +7 -0
  197. package/dist/kernel/enclave/classify/reveal.d.ts +10 -0
  198. package/dist/kernel/enclave/classify/vdig.d.ts +39 -0
  199. package/dist/kernel/enclave/classify/verify.d.ts +36 -0
  200. package/dist/kernel/enclave/classify/write.d.ts +8 -0
  201. package/dist/kernel/enclave/crypto.d.ts +263 -0
  202. package/dist/kernel/enclave/index.d.ts +79 -0
  203. package/dist/kernel/enclave/record-keys/deterministic.d.ts +55 -0
  204. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +79 -0
  205. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +107 -0
  206. package/dist/kernel/enclave/record-keys/record-codec.d.ts +328 -0
  207. package/dist/kernel/enclave/record-keys/sealed-slot.d.ts +14 -0
  208. package/dist/kernel/enclave/record-keys/sealed-slots.d.ts +123 -0
  209. package/dist/kernel/enclave/record-keys/sealing.d.ts +70 -0
  210. package/dist/kernel/enclave/record-keys/tombstone.d.ts +57 -0
  211. package/dist/kernel/env-check.d.ts +1 -0
  212. package/dist/kernel/errors.d.ts +1922 -0
  213. package/dist/kernel/events.d.ts +11 -0
  214. package/dist/kernel/lazy-count.d.ts +13 -0
  215. package/dist/kernel/memory-store.d.ts +17 -0
  216. package/dist/kernel/mutation.d.ts +14 -0
  217. package/dist/kernel/noydb.d.ts +826 -0
  218. package/dist/kernel/paths.d.ts +25 -0
  219. package/dist/kernel/query/builder.d.ts +520 -0
  220. package/dist/kernel/query/index.d.ts +31 -0
  221. package/dist/kernel/query/join.d.ts +205 -0
  222. package/dist/kernel/query/live.d.ts +111 -0
  223. package/dist/kernel/query/predicate.d.ts +139 -0
  224. package/dist/kernel/query/scan-builder.d.ts +334 -0
  225. package/dist/kernel/refs.d.ts +205 -0
  226. package/dist/kernel/schema.d.ts +134 -0
  227. package/dist/kernel/sync-policy.d.ts +188 -0
  228. package/dist/kernel/tier-visibility.d.ts +54 -0
  229. package/dist/kernel/types.d.ts +3239 -0
  230. package/dist/kernel/util/discriminant.d.ts +58 -0
  231. package/dist/kernel/util/index.d.ts +14 -0
  232. package/dist/kernel/util/sanitize-filename.d.ts +75 -0
  233. package/dist/kernel/validation.d.ts +130 -0
  234. package/dist/kernel/vault.d.ts +1740 -0
  235. package/dist/kernel/via/compose.d.ts +144 -0
  236. package/dist/kernel/via/dispatch.d.ts +195 -0
  237. package/dist/kernel/via/graph-wiring.d.ts +145 -0
  238. package/dist/kernel/via/graph.d.ts +166 -0
  239. package/dist/kernel/via/index.d.ts +200 -0
  240. package/dist/kernel/via/pipeline.d.ts +266 -0
  241. package/dist/kernel/via/reconcile.d.ts +153 -0
  242. package/dist/kernel/via/taint-binding.d.ts +66 -0
  243. package/dist/kernel/write-queue.d.ts +46 -0
  244. package/dist/ledger-GFBKVPV4.js +42 -0
  245. package/dist/legacy/bundle.d.ts +30 -0
  246. package/dist/legacy/kernel.d.ts +33 -0
  247. package/dist/liberate-3VDOT4KO.js +24 -0
  248. package/dist/link-set-Z7Q2ASFX.js +31 -0
  249. package/dist/materialized-views/index.js +19 -15
  250. package/dist/noydb-ZCJOYBDI.js +68 -0
  251. package/dist/on/index.js +9 -9
  252. package/dist/overlay-views/index.js +4 -4
  253. package/dist/periods/index.js +12 -12
  254. package/dist/pod/index.js +11 -11
  255. package/dist/policy-Z3RUAIY2.js +41 -0
  256. package/dist/port/as/index.d.ts +26 -0
  257. package/dist/port/at/index.d.ts +18 -0
  258. package/dist/port/by/default-provider.d.ts +9 -0
  259. package/dist/port/by/index.d.ts +17 -0
  260. package/dist/port/by/types.d.ts +86 -0
  261. package/dist/port/in/index.d.ts +21 -0
  262. package/dist/port/on/index.d.ts +27 -0
  263. package/dist/port/to/index.d.ts +19 -0
  264. package/dist/port/ui/index.d.ts +21 -0
  265. package/dist/port/with/blob-strategy.d.ts +98 -0
  266. package/dist/port/with/broker-strategy.d.ts +84 -0
  267. package/dist/port/with/capabilities.d.ts +31 -0
  268. package/dist/port/with/classified-marker.d.ts +9 -0
  269. package/dist/port/with/classified-strategy.d.ts +62 -0
  270. package/dist/port/with/computed-strategy.d.ts +19 -0
  271. package/dist/port/with/i18n-strategy.d.ts +175 -0
  272. package/dist/port/with/index.d.ts +18 -0
  273. package/dist/port/with/lazy-strategy.d.ts +48 -0
  274. package/dist/port/with/lookup-strategy.d.ts +129 -0
  275. package/dist/port/with/service-bus.d.ts +156 -0
  276. package/dist/port/with/team-strategy.d.ts +36 -0
  277. package/dist/port/with/write-hooks.d.ts +34 -0
  278. package/dist/portability/index.js +8 -8
  279. package/dist/post-register-JTH76BLY.js +60 -0
  280. package/dist/post-register-JTH76BLY.js.map +1 -0
  281. package/dist/public-envelope-B4KNWVUA.js +32 -0
  282. package/dist/purge-scope-FGNNLWHD.js +24 -0
  283. package/dist/purge-scope-FGNNLWHD.js.map +1 -0
  284. package/dist/query/index.js +9 -6
  285. package/dist/read-only-facade-CHCKSEPD.js +8 -0
  286. package/dist/register-VAHONCID.js +23 -0
  287. package/dist/registry-7MLVD3VO.js +19 -0
  288. package/dist/registry-EPKPD5SM.js +18 -0
  289. package/dist/registry-P5T7PS2U.js +9 -0
  290. package/dist/request-withdrawal-TI3A5WPS.js +31 -0
  291. package/dist/reveal-DIBHLUZX.js +38 -0
  292. package/dist/reveal-DIBHLUZX.js.map +1 -0
  293. package/dist/revoke-FDRD6GRW.js +24 -0
  294. package/dist/satellites/index.js +1 -1
  295. package/dist/sealed-record/index.js +12 -12
  296. package/dist/seed-Q6M2IZFL.js +231 -0
  297. package/dist/seed-Q6M2IZFL.js.map +1 -0
  298. package/dist/session/index.js +9 -9
  299. package/dist/shadow/index.js +2 -2
  300. package/dist/signer-MUWEIUI6.js +25 -0
  301. package/dist/snapshots/index.js +10 -10
  302. package/dist/stale-OSQ7J3AA.js +29 -0
  303. package/dist/storage-MVFCGEQE.js +23 -0
  304. package/dist/store-coordination-provider-64OEZFGS.js +142 -0
  305. package/dist/sync/index.js +9 -9
  306. package/dist/team/index.js +15 -15
  307. package/dist/tiers/index.js +14 -10
  308. package/dist/to/index.js +1 -2
  309. package/dist/tx/index.js +3 -3
  310. package/dist/util/index.js +1 -1
  311. package/dist/verify-ZASTRNPR.js +140 -0
  312. package/dist/verify-ZASTRNPR.js.map +1 -0
  313. package/dist/via/blob/active.d.ts +34 -0
  314. package/dist/via/blob/binding.d.ts +86 -0
  315. package/dist/via/blob/index.d.ts +34 -0
  316. package/dist/via/classified/active.d.ts +3 -0
  317. package/dist/via/classified/binding.d.ts +83 -0
  318. package/dist/via/classified/config-drift.d.ts +34 -0
  319. package/dist/via/classified/descriptor.d.ts +66 -0
  320. package/dist/via/classified/errors.d.ts +19 -0
  321. package/dist/via/classified/guards.d.ts +23 -0
  322. package/dist/via/classified/index.d.ts +11 -0
  323. package/dist/via/classified/presets.d.ts +65 -0
  324. package/dist/via/classified/resolve.d.ts +9 -0
  325. package/dist/via/classified/strategy.d.ts +11 -0
  326. package/dist/via/classified/validators.d.ts +3 -0
  327. package/dist/via/classified/write.d.ts +4 -0
  328. package/dist/via/computed/binding.d.ts +34 -0
  329. package/dist/via/computed/descriptor.d.ts +35 -0
  330. package/dist/via/i18n/active.d.ts +28 -0
  331. package/dist/via/i18n/binding.d.ts +36 -0
  332. package/dist/via/i18n/core.d.ts +267 -0
  333. package/dist/via/i18n/densify.d.ts +24 -0
  334. package/dist/via/i18n/dictionary.d.ts +200 -0
  335. package/dist/via/i18n/index.d.ts +21 -0
  336. package/dist/via/i18n/policy.d.ts +44 -0
  337. package/dist/via/i18n/script.d.ts +26 -0
  338. package/dist/via/i18n/strategy.d.ts +13 -0
  339. package/dist/via/lookup/active.d.ts +19 -0
  340. package/dist/via/lookup/binding.d.ts +99 -0
  341. package/dist/via/lookup/descriptor.d.ts +123 -0
  342. package/dist/via/lookup/handle.d.ts +220 -0
  343. package/dist/via/lookup/index.d.ts +17 -0
  344. package/dist/via/lookup/registry.d.ts +228 -0
  345. package/dist/via/lookup/snapshot.d.ts +67 -0
  346. package/dist/via/money/arith.d.ts +68 -0
  347. package/dist/via/money/binding.d.ts +21 -0
  348. package/dist/via/money/branded.d.ts +61 -0
  349. package/dist/via/money/descriptor.d.ts +73 -0
  350. package/dist/via/money/fixed-point.d.ts +51 -0
  351. package/dist/via/money/index.d.ts +15 -0
  352. package/dist/via/money/iso4217.d.ts +6 -0
  353. package/dist/via/money/money-reducer.d.ts +33 -0
  354. package/dist/via/money/normalize.d.ts +105 -0
  355. package/dist/via/money/paths.d.ts +61 -0
  356. package/dist/via/money/where.d.ts +127 -0
  357. package/dist/walk-SVNDIZ62.js +241 -0
  358. package/dist/with/index.js +11 -11
  359. package/dist/with-audit/attestation/active.d.ts +10 -0
  360. package/dist/with-audit/attestation/index.d.ts +16 -0
  361. package/dist/with-audit/attestation/issue.d.ts +29 -0
  362. package/dist/with-audit/attestation/revoke.d.ts +15 -0
  363. package/dist/with-audit/attestation/signer.d.ts +33 -0
  364. package/dist/with-audit/attestation/strategy.d.ts +44 -0
  365. package/dist/with-audit/attestation/vault-facade.d.ts +62 -0
  366. package/dist/with-audit/consent/active.d.ts +14 -0
  367. package/dist/with-audit/consent/consent.d.ts +114 -0
  368. package/dist/with-audit/consent/index.d.ts +14 -0
  369. package/dist/with-audit/consent/strategy.d.ts +36 -0
  370. package/dist/with-audit/forget/active.d.ts +31 -0
  371. package/dist/with-audit/forget/index.d.ts +28 -0
  372. package/dist/with-audit/forget/purge-scope.d.ts +54 -0
  373. package/dist/with-audit/forget/strategy.d.ts +199 -0
  374. package/dist/with-audit/forget/subject-index.d.ts +83 -0
  375. package/dist/with-audit/guards/executor.d.ts +26 -0
  376. package/dist/with-audit/guards/immutable-guard.d.ts +63 -0
  377. package/dist/with-audit/guards/index.d.ts +10 -0
  378. package/dist/with-audit/guards/read-only-facade.d.ts +31 -0
  379. package/dist/with-audit/guards/registry.d.ts +83 -0
  380. package/dist/with-audit/guards/transition-guard.d.ts +82 -0
  381. package/dist/with-audit/guards/types.d.ts +134 -0
  382. package/dist/with-audit/guards/with-guard.d.ts +15 -0
  383. package/dist/with-audit/periods/active.d.ts +11 -0
  384. package/dist/with-audit/periods/index.d.ts +18 -0
  385. package/dist/with-audit/periods/periods.d.ts +417 -0
  386. package/dist/with-audit/periods/strategy.d.ts +32 -0
  387. package/dist/with-audit/periods/vault-facade.d.ts +95 -0
  388. package/dist/with-audit/portability/active.d.ts +11 -0
  389. package/dist/with-audit/portability/export-accessible.d.ts +46 -0
  390. package/dist/with-audit/portability/index.d.ts +18 -0
  391. package/dist/with-audit/portability/request-withdrawal.d.ts +85 -0
  392. package/dist/with-audit/portability/strategy.d.ts +31 -0
  393. package/dist/with-audit/portability/withdraw-accessible.d.ts +82 -0
  394. package/dist/with-audit/sealed-record/active.d.ts +9 -0
  395. package/dist/with-audit/sealed-record/index.d.ts +55 -0
  396. package/dist/with-audit/sealed-record/strategy.d.ts +34 -0
  397. package/dist/with-audit/sealed-record/types.d.ts +27 -0
  398. package/dist/with-audit/tiers/active.d.ts +9 -0
  399. package/dist/with-audit/tiers/index.d.ts +394 -0
  400. package/dist/with-audit/tiers/strategy.d.ts +36 -0
  401. package/dist/with-cargo/active.d.ts +11 -0
  402. package/dist/with-cargo/adopt-partition.d.ts +81 -0
  403. package/dist/with-cargo/decrypt-partition.d.ts +19 -0
  404. package/dist/with-cargo/describe-extraction.d.ts +41 -0
  405. package/dist/with-cargo/extract-partition.d.ts +155 -0
  406. package/dist/with-cargo/index.d.ts +33 -0
  407. package/dist/with-cargo/strategy.d.ts +30 -0
  408. package/dist/with-cargo/vault-diff.d.ts +144 -0
  409. package/dist/with-cargo/walk-closure.d.ts +67 -0
  410. package/dist/with-commit/crdt/active.d.ts +25 -0
  411. package/dist/with-commit/crdt/crdt.d.ts +42 -0
  412. package/dist/with-commit/crdt/index.d.ts +16 -0
  413. package/dist/with-commit/crdt/strategy.d.ts +25 -0
  414. package/dist/with-commit/history/active.d.ts +40 -0
  415. package/dist/with-commit/history/diff.d.ts +23 -0
  416. package/dist/with-commit/history/history.d.ts +73 -0
  417. package/dist/with-commit/history/index.d.ts +30 -0
  418. package/dist/with-commit/history/ledger/constants.d.ts +37 -0
  419. package/dist/with-commit/history/ledger/entry.d.ts +195 -0
  420. package/dist/with-commit/history/ledger/hash.d.ts +30 -0
  421. package/dist/with-commit/history/ledger/index.d.ts +19 -0
  422. package/dist/with-commit/history/ledger/patch.d.ts +99 -0
  423. package/dist/with-commit/history/ledger/store.d.ts +356 -0
  424. package/dist/with-commit/history/strategy.d.ts +136 -0
  425. package/dist/with-commit/history/time-machine.d.ts +202 -0
  426. package/dist/with-commit/numbering/descriptor.d.ts +27 -0
  427. package/dist/with-commit/numbering/index.d.ts +69 -0
  428. package/dist/with-commit/sequence/active.d.ts +10 -0
  429. package/dist/with-commit/sequence/index.d.ts +150 -0
  430. package/dist/with-commit/sequence/strategy.d.ts +26 -0
  431. package/dist/with-commit/tx/active.d.ts +27 -0
  432. package/dist/with-commit/tx/dry-run.d.ts +29 -0
  433. package/dist/with-commit/tx/elevated-handle.d.ts +59 -0
  434. package/dist/with-commit/tx/index.d.ts +13 -0
  435. package/dist/with-commit/tx/invariants.d.ts +68 -0
  436. package/dist/with-commit/tx/strategy.d.ts +23 -0
  437. package/dist/with-commit/tx/transaction.d.ts +212 -0
  438. package/dist/with-fork/archive/engine.d.ts +71 -0
  439. package/dist/with-fork/archive/index.d.ts +23 -0
  440. package/dist/with-fork/shadow/active.d.ts +6 -0
  441. package/dist/with-fork/shadow/index.d.ts +14 -0
  442. package/dist/with-fork/shadow/strategy.d.ts +28 -0
  443. package/dist/with-fork/shadow/vault-frame.d.ts +93 -0
  444. package/dist/with-fork/snapshots/active.d.ts +20 -0
  445. package/dist/with-fork/snapshots/engine.d.ts +36 -0
  446. package/dist/with-fork/snapshots/index.d.ts +5 -0
  447. package/dist/with-fork/snapshots/noydb-facade.d.ts +64 -0
  448. package/dist/with-fork/snapshots/policy.d.ts +23 -0
  449. package/dist/with-fork/snapshots/scheduler.d.ts +34 -0
  450. package/dist/with-fork/snapshots/strategy.d.ts +48 -0
  451. package/dist/with-formula/computed/index.d.ts +48 -0
  452. package/dist/with-formula/computed/lazy.d.ts +13 -0
  453. package/dist/with-formula/derivations/executor.d.ts +61 -0
  454. package/dist/with-formula/derivations/fanout-sidecar.d.ts +75 -0
  455. package/dist/with-formula/derivations/index.d.ts +6 -0
  456. package/dist/with-formula/derivations/registry.d.ts +67 -0
  457. package/dist/with-formula/derivations/stale.d.ts +39 -0
  458. package/dist/with-formula/derivations/strategy-hash.d.ts +1 -0
  459. package/dist/with-formula/derivations/types.d.ts +248 -0
  460. package/dist/with-formula/derivations/with-derivation.d.ts +10 -0
  461. package/dist/with-formula/derivations/with-rollup.d.ts +34 -0
  462. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +58 -0
  463. package/dist/with-formula/materialized-views/executor.d.ts +80 -0
  464. package/dist/with-formula/materialized-views/index.d.ts +11 -0
  465. package/dist/with-formula/materialized-views/query-hash.d.ts +23 -0
  466. package/dist/with-formula/materialized-views/registry.d.ts +99 -0
  467. package/dist/with-formula/materialized-views/stale.d.ts +113 -0
  468. package/dist/with-formula/materialized-views/types.d.ts +318 -0
  469. package/dist/with-formula/materialized-views/with-materialized-view.d.ts +24 -0
  470. package/dist/with-formula/overlay-views/index.d.ts +5 -0
  471. package/dist/with-formula/overlay-views/registry.d.ts +42 -0
  472. package/dist/with-formula/overlay-views/types.d.ts +97 -0
  473. package/dist/with-formula/overlay-views/virtual-collection.d.ts +90 -0
  474. package/dist/with-formula/overlay-views/with-overlayed-view.d.ts +9 -0
  475. package/dist/with-lookup/aggregate/active.d.ts +33 -0
  476. package/dist/with-lookup/aggregate/aggregation.d.ts +166 -0
  477. package/dist/with-lookup/aggregate/canonical-key.d.ts +16 -0
  478. package/dist/with-lookup/aggregate/groupby.d.ts +280 -0
  479. package/dist/with-lookup/aggregate/index.d.ts +23 -0
  480. package/dist/with-lookup/aggregate/reducers.d.ts +257 -0
  481. package/dist/with-lookup/aggregate/strategy.d.ts +59 -0
  482. package/dist/with-lookup/embeddings/cosine.d.ts +2 -0
  483. package/dist/with-lookup/embeddings/descriptor.d.ts +8 -0
  484. package/dist/with-lookup/embeddings/index.d.ts +4 -0
  485. package/dist/with-lookup/embeddings/vec-id.d.ts +47 -0
  486. package/dist/with-lookup/embeddings/vector-set.d.ts +19 -0
  487. package/dist/with-lookup/indexing/active.d.ts +30 -0
  488. package/dist/with-lookup/indexing/collection-facade.d.ts +157 -0
  489. package/dist/with-lookup/indexing/eager-indexes.d.ts +122 -0
  490. package/dist/with-lookup/indexing/index.d.ts +27 -0
  491. package/dist/with-lookup/indexing/lazy-builder.d.ts +102 -0
  492. package/dist/with-lookup/indexing/persisted-indexes.d.ts +229 -0
  493. package/dist/with-lookup/indexing/strategy.d.ts +56 -0
  494. package/dist/with-lookup/indexing/unique-constraints.d.ts +74 -0
  495. package/dist/with-lookup/search/active.d.ts +10 -0
  496. package/dist/with-lookup/search/build-docs.d.ts +15 -0
  497. package/dist/with-lookup/search/collection-facade.d.ts +163 -0
  498. package/dist/with-lookup/search/fuse.d.ts +22 -0
  499. package/dist/with-lookup/search/index-store.d.ts +19 -0
  500. package/dist/with-lookup/search/index.d.ts +19 -0
  501. package/dist/with-lookup/search/inverted-index.d.ts +47 -0
  502. package/dist/with-lookup/search/persisted-index-store.d.ts +121 -0
  503. package/dist/with-lookup/search/retrieve-types.d.ts +29 -0
  504. package/dist/with-lookup/search/scan.d.ts +28 -0
  505. package/dist/with-lookup/search/segment.d.ts +15 -0
  506. package/dist/with-lookup/search/serialize.d.ts +4 -0
  507. package/dist/with-lookup/search/snippet.d.ts +5 -0
  508. package/dist/with-lookup/search/strategy.d.ts +41 -0
  509. package/dist/with-lookup/search/tokenize.d.ts +12 -0
  510. package/dist/with-party/auth-introspection/index.d.ts +44 -0
  511. package/dist/with-party/broker/active.d.ts +23 -0
  512. package/dist/with-party/broker/index.d.ts +28 -0
  513. package/dist/with-party/broker/seed.d.ts +77 -0
  514. package/dist/with-party/custody/active.d.ts +10 -0
  515. package/dist/with-party/custody/index.d.ts +69 -0
  516. package/dist/with-party/custody/liberate.d.ts +64 -0
  517. package/dist/with-party/custody/strategy.d.ts +48 -0
  518. package/dist/with-party/directory/index.d.ts +11 -0
  519. package/dist/with-party/directory/public-envelope/index.d.ts +12 -0
  520. package/dist/with-party/directory/public-envelope/schema.d.ts +24 -0
  521. package/dist/with-party/directory/public-envelope/storage.d.ts +59 -0
  522. package/dist/with-party/directory/public-envelope/types.d.ts +80 -0
  523. package/dist/with-party/directory/storage.d.ts +33 -0
  524. package/dist/with-party/directory/types.d.ts +43 -0
  525. package/dist/with-party/directory/user-envelope/api.d.ts +201 -0
  526. package/dist/with-party/directory/user-envelope/index.d.ts +12 -0
  527. package/dist/with-party/directory/user-envelope/storage.d.ts +54 -0
  528. package/dist/with-party/directory/visibility.d.ts +47 -0
  529. package/dist/with-party/policy/engine.d.ts +60 -0
  530. package/dist/with-party/policy/index.d.ts +15 -0
  531. package/dist/with-party/policy/noydb-facade.d.ts +39 -0
  532. package/dist/with-party/policy/presets.d.ts +38 -0
  533. package/dist/with-party/policy/storage.d.ts +31 -0
  534. package/dist/with-party/session/active.d.ts +34 -0
  535. package/dist/with-party/session/dev-unlock.d.ts +128 -0
  536. package/dist/with-party/session/index.d.ts +23 -0
  537. package/dist/with-party/session/session-policy.d.ts +92 -0
  538. package/dist/with-party/session/session.d.ts +131 -0
  539. package/dist/with-party/session/strategy.d.ts +42 -0
  540. package/dist/with-party/session/unlock-state.d.ts +47 -0
  541. package/dist/with-party/sync/index.d.ts +31 -0
  542. package/dist/with-party/tab-coordination.d.ts +73 -0
  543. package/dist/with-party/tab-write-relay.d.ts +39 -0
  544. package/dist/with-party/team/active.d.ts +13 -0
  545. package/dist/with-party/team/authenticators.d.ts +95 -0
  546. package/dist/with-party/team/deed.d.ts +97 -0
  547. package/dist/with-party/team/delegation.d.ts +88 -0
  548. package/dist/with-party/team/index.d.ts +38 -0
  549. package/dist/with-party/team/keyring.d.ts +318 -0
  550. package/dist/with-party/team/magic-link-grant.d.ts +152 -0
  551. package/dist/with-party/team/managed-passphrase.d.ts +280 -0
  552. package/dist/with-party/team/noydb-facade.d.ts +484 -0
  553. package/dist/with-party/team/peer-recover.d.ts +81 -0
  554. package/dist/with-party/team/presence.d.ts +81 -0
  555. package/dist/with-party/team/recovery.d.ts +191 -0
  556. package/dist/with-party/team/reserved-secret-collections.d.ts +41 -0
  557. package/dist/with-party/team/rotate-recover.d.ts +275 -0
  558. package/dist/with-party/team/shamir-recovery-provider.d.ts +15 -0
  559. package/dist/with-party/team/strategy.d.ts +9 -0
  560. package/dist/with-party/team/sync-active.d.ts +33 -0
  561. package/dist/with-party/team/sync-credentials.d.ts +113 -0
  562. package/dist/with-party/team/sync-strategy.d.ts +67 -0
  563. package/dist/with-party/team/sync-transaction.d.ts +39 -0
  564. package/dist/with-party/team/sync.d.ts +174 -0
  565. package/dist/with-party/team/tiers.d.ts +39 -0
  566. package/dist/with-party/team/wrapped-deks.d.ts +86 -0
  567. package/dist/with-pod/backup.d.ts +74 -0
  568. package/dist/with-pod/bundle.d.ts +414 -0
  569. package/dist/with-pod/format.d.ts +203 -0
  570. package/dist/with-pod/index.d.ts +20 -0
  571. package/dist/with-pod/pod-store.d.ts +54 -0
  572. package/dist/with-pod/ulid.d.ts +64 -0
  573. package/dist/with-shape/blobs/blob-compaction.d.ts +170 -0
  574. package/dist/with-shape/blobs/blob-intent.d.ts +153 -0
  575. package/dist/with-shape/blobs/blob-set.d.ts +1286 -0
  576. package/dist/with-shape/blobs/export-blobs.d.ts +110 -0
  577. package/dist/with-shape/blobs/import-external.d.ts +50 -0
  578. package/dist/with-shape/blobs/mime-magic.d.ts +48 -0
  579. package/dist/with-shape/blobs/object-projection.d.ts +70 -0
  580. package/dist/with-shape/introspection/describe.d.ts +237 -0
  581. package/dist/with-shape/introspection/field-meta.d.ts +61 -0
  582. package/dist/with-shape/introspection/fields.d.ts +14 -0
  583. package/dist/with-shape/introspection/index.d.ts +12 -0
  584. package/dist/with-shape/introspection/json-schema.d.ts +13 -0
  585. package/dist/with-shape/introspection/meta.d.ts +22 -0
  586. package/dist/with-shape/introspection/projection.d.ts +13 -0
  587. package/dist/with-shape/introspection/types.d.ts +154 -0
  588. package/dist/with-shape/introspection/walk.d.ts +50 -0
  589. package/dist/with-shape/links/lazy-handle.d.ts +36 -0
  590. package/dist/with-shape/links/link-set.d.ts +67 -0
  591. package/dist/with-shape/links/names.d.ts +65 -0
  592. package/dist/with-shape/links/vault-facade.d.ts +211 -0
  593. package/dist/with-shape/persisted-schemas/canonicalize.d.ts +11 -0
  594. package/dist/with-shape/persisted-schemas/derive.d.ts +29 -0
  595. package/dist/with-shape/persisted-schemas/index.d.ts +21 -0
  596. package/dist/with-shape/persisted-schemas/register.d.ts +66 -0
  597. package/dist/with-shape/persisted-schemas/storage.d.ts +61 -0
  598. package/dist/with-shape/persisted-schemas/types.d.ts +54 -0
  599. package/dist/with-shape/satellites/dead-filter.d.ts +21 -0
  600. package/dist/with-shape/satellites/declare.d.ts +60 -0
  601. package/dist/with-shape/satellites/existence.d.ts +5 -0
  602. package/dist/with-shape/satellites/fanout.d.ts +38 -0
  603. package/dist/with-shape/satellites/forget.d.ts +47 -0
  604. package/dist/with-shape/satellites/index.d.ts +3 -0
  605. package/dist/with-shape/satellites/joined.d.ts +19 -0
  606. package/dist/with-shape/satellites/marker.d.ts +10 -0
  607. package/dist/with-shape/satellites/migrate-cek.d.ts +26 -0
  608. package/dist/with-shape/satellites/post-register.d.ts +6 -0
  609. package/dist/with-shape/satellites/proxy.d.ts +37 -0
  610. package/dist/with-shape/satellites/raw-target.d.ts +14 -0
  611. package/dist/with-shape/satellites/registry.d.ts +19 -0
  612. package/dist/with-shape/satellites/types.d.ts +37 -0
  613. package/dist/with-shape/satellites/validate.d.ts +17 -0
  614. package/dist/with-shape/schema-update/client-registry.d.ts +35 -0
  615. package/dist/with-shape/schema-update/cutover.d.ts +5 -0
  616. package/dist/with-shape/schema-update/delta.d.ts +2 -0
  617. package/dist/with-shape/schema-update/dispatch.d.ts +3 -0
  618. package/dist/with-shape/schema-update/fence-controller.d.ts +62 -0
  619. package/dist/with-shape/schema-update/fence-watcher.d.ts +37 -0
  620. package/dist/with-shape/schema-update/fence.d.ts +15 -0
  621. package/dist/with-shape/schema-update/gate.d.ts +16 -0
  622. package/dist/with-shape/schema-update/index.d.ts +6 -0
  623. package/dist/with-shape/schema-update/store-coordination-provider.d.ts +29 -0
  624. package/dist/with-shape/schema-update/strategies.d.ts +12 -0
  625. package/dist/with-shape/schema-update/types.d.ts +53 -0
  626. package/dist/with-store/index.d.ts +15 -0
  627. package/dist/with-store/lazy/active.d.ts +12 -0
  628. package/dist/with-store/lazy/index.d.ts +14 -0
  629. package/dist/with-store/lazy/strategy.d.ts +9 -0
  630. package/dist/with-store/route-store.d.ts +259 -0
  631. package/dist/with-store/store-middleware.d.ts +189 -0
  632. package/dist/withdraw-accessible-WZIEVWSR.js +28 -0
  633. package/package.json +47 -55
  634. package/dist/adapter/index.d.ts +0 -5
  635. package/dist/adapter/index.js +0 -15
  636. package/dist/aggregate/index.d.ts +0 -42
  637. package/dist/api-JDWL67WL.js +0 -20
  638. package/dist/as/index.d.ts +0 -7
  639. package/dist/at/index.d.ts +0 -5
  640. package/dist/attestation/index.d.ts +0 -20
  641. package/dist/backup-WRGNTGJF.js +0 -225
  642. package/dist/backup-WRGNTGJF.js.map +0 -1
  643. package/dist/blobs/index.d.ts +0 -44
  644. package/dist/bundle/index.d.ts +0 -122
  645. package/dist/bundle-DzWtVw7w.d.ts +0 -548
  646. package/dist/by/index.d.ts +0 -1
  647. package/dist/cargo/index.d.ts +0 -9
  648. package/dist/chunk-25G7PUTA.js +0 -235
  649. package/dist/chunk-26FSVNBL.js +0 -34
  650. package/dist/chunk-2PJB6H3H.js +0 -167
  651. package/dist/chunk-2PJB6H3H.js.map +0 -1
  652. package/dist/chunk-37JZR7CY.js +0 -91
  653. package/dist/chunk-3KBK5LU4.js +0 -117
  654. package/dist/chunk-3YKBGS3I.js +0 -686
  655. package/dist/chunk-3YKBGS3I.js.map +0 -1
  656. package/dist/chunk-44DV37ZV.js +0 -75
  657. package/dist/chunk-44DV37ZV.js.map +0 -1
  658. package/dist/chunk-47C4CI7R.js +0 -108
  659. package/dist/chunk-47C4CI7R.js.map +0 -1
  660. package/dist/chunk-4VDFUBTS.js +0 -275
  661. package/dist/chunk-4VDFUBTS.js.map +0 -1
  662. package/dist/chunk-55LSDABW.js +0 -94
  663. package/dist/chunk-56JB2BGI.js +0 -13003
  664. package/dist/chunk-56JB2BGI.js.map +0 -1
  665. package/dist/chunk-5GQE5IDB.js +0 -513
  666. package/dist/chunk-5GQE5IDB.js.map +0 -1
  667. package/dist/chunk-5HRJQSKN.js +0 -202
  668. package/dist/chunk-5HZULLHE.js +0 -404
  669. package/dist/chunk-5JQMX2EH.js +0 -50
  670. package/dist/chunk-5UOPIPZC.js +0 -95
  671. package/dist/chunk-5YBUFCFF.js +0 -135
  672. package/dist/chunk-62APEMF3.js +0 -280
  673. package/dist/chunk-62APEMF3.js.map +0 -1
  674. package/dist/chunk-6P5AJ2ZS.js +0 -120
  675. package/dist/chunk-6P5AJ2ZS.js.map +0 -1
  676. package/dist/chunk-6PALJTC2.js +0 -430
  677. package/dist/chunk-6PALJTC2.js.map +0 -1
  678. package/dist/chunk-6S7T6WC4.js +0 -111
  679. package/dist/chunk-6S7T6WC4.js.map +0 -1
  680. package/dist/chunk-6Z435B6N.js +0 -1656
  681. package/dist/chunk-6Z435B6N.js.map +0 -1
  682. package/dist/chunk-723XB5NX.js +0 -86
  683. package/dist/chunk-7CZ6YXMO.js +0 -124
  684. package/dist/chunk-7KTL4RHZ.js +0 -120
  685. package/dist/chunk-7KTL4RHZ.js.map +0 -1
  686. package/dist/chunk-7TAV3BFQ.js +0 -766
  687. package/dist/chunk-7TAV3BFQ.js.map +0 -1
  688. package/dist/chunk-BASCPHNM.js +0 -380
  689. package/dist/chunk-BASCPHNM.js.map +0 -1
  690. package/dist/chunk-BGIZAFY7.js +0 -1
  691. package/dist/chunk-BJ2XF2RC.js +0 -823
  692. package/dist/chunk-BM6E4MUT.js +0 -881
  693. package/dist/chunk-BM6E4MUT.js.map +0 -1
  694. package/dist/chunk-BTFTHF6Q.js +0 -42
  695. package/dist/chunk-C4NOLA5X.js +0 -132
  696. package/dist/chunk-C4NOLA5X.js.map +0 -1
  697. package/dist/chunk-CHK5VVMI.js +0 -155
  698. package/dist/chunk-DCVVCJVB.js +0 -45
  699. package/dist/chunk-EU7HDMT3.js +0 -54
  700. package/dist/chunk-F3EKFGUS.js +0 -99
  701. package/dist/chunk-FCOZ7DEC.js +0 -355
  702. package/dist/chunk-FCOZ7DEC.js.map +0 -1
  703. package/dist/chunk-FWART3VA.js +0 -205
  704. package/dist/chunk-FZK3JJJK.js +0 -150
  705. package/dist/chunk-GDOOG5YQ.js +0 -382
  706. package/dist/chunk-GLVXQU3E.js +0 -155
  707. package/dist/chunk-HU55NPHZ.js +0 -80
  708. package/dist/chunk-I6JJ6VJS.js +0 -97
  709. package/dist/chunk-I6URUNTD.js +0 -59
  710. package/dist/chunk-IARAK3PK.js +0 -14
  711. package/dist/chunk-II6DLDZM.js +0 -30
  712. package/dist/chunk-J5YUA6JB.js +0 -23
  713. package/dist/chunk-J7OH6R4K.js +0 -49
  714. package/dist/chunk-K2WCO3NX.js +0 -1
  715. package/dist/chunk-L6Q5NA22.js +0 -40
  716. package/dist/chunk-LFGJG4XZ.js +0 -30
  717. package/dist/chunk-M3OYTM5Z.js +0 -85
  718. package/dist/chunk-MOQ5M46U.js +0 -209
  719. package/dist/chunk-NTPWQH4S.js +0 -589
  720. package/dist/chunk-OJ64XMPJ.js +0 -1434
  721. package/dist/chunk-OJ64XMPJ.js.map +0 -1
  722. package/dist/chunk-OWGAXPRE.js +0 -129
  723. package/dist/chunk-P2PEPSPK.js +0 -230
  724. package/dist/chunk-P6TZ3IVN.js +0 -453
  725. package/dist/chunk-P6TZ3IVN.js.map +0 -1
  726. package/dist/chunk-PAJCRV7O.js +0 -123
  727. package/dist/chunk-PMMV5SQC.js +0 -416
  728. package/dist/chunk-PMMV5SQC.js.map +0 -1
  729. package/dist/chunk-PPPZIBKY.js +0 -261
  730. package/dist/chunk-PPPZIBKY.js.map +0 -1
  731. package/dist/chunk-PVC2FBCQ.js +0 -45
  732. package/dist/chunk-PYIUDUGS.js +0 -36
  733. package/dist/chunk-QABECTNN.js +0 -255
  734. package/dist/chunk-QYMMMKOO.js +0 -164
  735. package/dist/chunk-R4IVPJHN.js +0 -130
  736. package/dist/chunk-REWTMYSF.js +0 -32
  737. package/dist/chunk-REWTMYSF.js.map +0 -1
  738. package/dist/chunk-RNYDHIQL.js +0 -367
  739. package/dist/chunk-RUIMKQTA.js +0 -23
  740. package/dist/chunk-RUIMKQTA.js.map +0 -1
  741. package/dist/chunk-TCGVRKOS.js +0 -367
  742. package/dist/chunk-TIAYXOEI.js +0 -99
  743. package/dist/chunk-TQ3REHVF.js +0 -95
  744. package/dist/chunk-TQ3REHVF.js.map +0 -1
  745. package/dist/chunk-TUL5YQWF.js +0 -777
  746. package/dist/chunk-U7LV2DUN.js +0 -74
  747. package/dist/chunk-UB3XHGFG.js +0 -181
  748. package/dist/chunk-UB3XHGFG.js.map +0 -1
  749. package/dist/chunk-UMH35AQV.js +0 -70
  750. package/dist/chunk-UWZ7O4NR.js +0 -29
  751. package/dist/chunk-V76PHWLE.js +0 -41
  752. package/dist/chunk-VFQOE76I.js +0 -69
  753. package/dist/chunk-VIWOGJ2O.js +0 -71
  754. package/dist/chunk-VK6OC22R.js +0 -37
  755. package/dist/chunk-VK6OC22R.js.map +0 -1
  756. package/dist/chunk-VVLOWY74.js +0 -150
  757. package/dist/chunk-VVLOWY74.js.map +0 -1
  758. package/dist/chunk-W3JABOVB.js +0 -53
  759. package/dist/chunk-W3JABOVB.js.map +0 -1
  760. package/dist/chunk-WPNP3NF5.js +0 -1221
  761. package/dist/chunk-WPNP3NF5.js.map +0 -1
  762. package/dist/chunk-X5QZAJDB.js +0 -59
  763. package/dist/chunk-X6VNIRHS.js +0 -239
  764. package/dist/chunk-X6VNIRHS.js.map +0 -1
  765. package/dist/chunk-XBPUVQDO.js +0 -664
  766. package/dist/chunk-XBPUVQDO.js.map +0 -1
  767. package/dist/chunk-XW5LZYV4.js +0 -21
  768. package/dist/chunk-YTCCC6NG.js +0 -320
  769. package/dist/chunk-YTCCC6NG.js.map +0 -1
  770. package/dist/classified/index.d.ts +0 -17
  771. package/dist/collection-facade-EJVIN2BY.js +0 -39
  772. package/dist/computed-6FOFXQPE.js +0 -11
  773. package/dist/config-drift-RFEVGBKR.js +0 -24
  774. package/dist/config-drift-RFEVGBKR.js.map +0 -1
  775. package/dist/consent/index.d.ts +0 -23
  776. package/dist/crdt/index.d.ts +0 -34
  777. package/dist/dead-filter-RHMNYOXP.js +0 -28
  778. package/dist/decrypt-partition-IHtxEnTi.d.ts +0 -21
  779. package/dist/delegation-IHXOASHV.js +0 -25
  780. package/dist/derivations/index.d.ts +0 -70
  781. package/dist/derive-CD3ZVIXK.js +0 -21
  782. package/dist/describe/index.d.ts +0 -1
  783. package/dist/describe/index.js +0 -1
  784. package/dist/describe-C6iHNlqJ.d.ts +0 -162
  785. package/dist/dev-unlock-wgQ7Ci5I.d.ts +0 -263
  786. package/dist/discriminant-BN9REW3o.d.ts +0 -60
  787. package/dist/enclave-KGEUW2GL.js +0 -123
  788. package/dist/executor-EUPYHCLU.js +0 -9
  789. package/dist/executor-KZ4B3PRT.js +0 -9
  790. package/dist/executor-MHUM2VZK.js +0 -21
  791. package/dist/export-accessible-Z3NSZZHN.js +0 -23
  792. package/dist/extract-partition-VSKT35JG.js +0 -36
  793. package/dist/fanout-sidecar-NBDKKCHT.js +0 -74
  794. package/dist/find-OH4BEULF.js +0 -11
  795. package/dist/forget/index.d.ts +0 -36
  796. package/dist/guards/index.d.ts +0 -35
  797. package/dist/hash-CwHnoKyW.d.ts +0 -72
  798. package/dist/history/index.d.ts +0 -61
  799. package/dist/i18n/index.d.ts +0 -37
  800. package/dist/in/index.d.ts +0 -5
  801. package/dist/index-B9QdHytu.d.ts +0 -123
  802. package/dist/index-CTvUp94-.d.ts +0 -123
  803. package/dist/index-Dn5GzPg_.d.ts +0 -22138
  804. package/dist/indexing/index.d.ts +0 -39
  805. package/dist/issue-AEOL6RXA.js +0 -19
  806. package/dist/kernel/index.d.ts +0 -32
  807. package/dist/kernel/index.js +0 -59
  808. package/dist/lazy/index.d.ts +0 -21
  809. package/dist/ledger-3LR3YO2W.js +0 -42
  810. package/dist/liberate-XSEPRWEA.js +0 -24
  811. package/dist/link-set-NSUIX6BR.js +0 -31
  812. package/dist/materialized-views/index.d.ts +0 -173
  813. package/dist/mime-magic-CYbFNQ4h.d.ts +0 -103
  814. package/dist/noydb-POVTIVQ6.js +0 -62
  815. package/dist/on/index.d.ts +0 -5
  816. package/dist/overlay-views/index.d.ts +0 -98
  817. package/dist/periods/index.d.ts +0 -20
  818. package/dist/pod/index.d.ts +0 -63
  819. package/dist/policy-Y7HL2KGA.js +0 -41
  820. package/dist/portability/index.d.ts +0 -20
  821. package/dist/post-register-KOFRTCDD.js +0 -55
  822. package/dist/post-register-KOFRTCDD.js.map +0 -1
  823. package/dist/public-envelope-NC7SPNMV.js +0 -32
  824. package/dist/query/index.d.ts +0 -5
  825. package/dist/read-only-facade-5ADRJVTM.js +0 -8
  826. package/dist/register-3D6R2MKN.js +0 -23
  827. package/dist/registry-AI4E46PD.js +0 -19
  828. package/dist/registry-HSNQ4NBP.js +0 -9
  829. package/dist/registry-WIX6QCV5.js +0 -17
  830. package/dist/request-withdrawal-GU4XS2R5.js +0 -31
  831. package/dist/reveal-5Y777N5Q.js +0 -38
  832. package/dist/reveal-5Y777N5Q.js.map +0 -1
  833. package/dist/revoke-ZFETCLYV.js +0 -24
  834. package/dist/revoke-ZFETCLYV.js.map +0 -1
  835. package/dist/satellites/index.d.ts +0 -5
  836. package/dist/sealed-record/index.d.ts +0 -69
  837. package/dist/session/index.d.ts +0 -44
  838. package/dist/shadow/index.d.ts +0 -15
  839. package/dist/signer-GAIMQQ2J.js +0 -25
  840. package/dist/signer-GAIMQQ2J.js.map +0 -1
  841. package/dist/snapshots/index.d.ts +0 -26
  842. package/dist/stale-77LP2EEF.js +0 -14
  843. package/dist/stale-77LP2EEF.js.map +0 -1
  844. package/dist/storage-KEXIXLGM.js +0 -23
  845. package/dist/storage-KEXIXLGM.js.map +0 -1
  846. package/dist/store-coordination-provider-NJDDZ264.js +0 -142
  847. package/dist/subject-index-O75wKshW.d.ts +0 -362
  848. package/dist/sync/index.d.ts +0 -41
  849. package/dist/team/index.d.ts +0 -155
  850. package/dist/tiers/index.d.ts +0 -5
  851. package/dist/to/index.d.ts +0 -5
  852. package/dist/transition-guard-D5RLJv8S.d.ts +0 -165
  853. package/dist/tx/index.d.ts +0 -35
  854. package/dist/ui/index.d.ts +0 -1
  855. package/dist/ulid-DRH25k3y.d.ts +0 -66
  856. package/dist/util/index.d.ts +0 -79
  857. package/dist/validators-C3lrVF-c.d.ts +0 -101
  858. package/dist/vault-diff-_LSIcOMv.d.ts +0 -147
  859. package/dist/verify-CAYGXYNO.js +0 -139
  860. package/dist/verify-CAYGXYNO.js.map +0 -1
  861. package/dist/walk-SMAE4IEI.js +0 -241
  862. package/dist/with/index.d.ts +0 -38
  863. package/dist/with-materialized-view-Xv1-9Bh0.d.ts +0 -27
  864. package/dist/with-overlayed-view-CuWhq_-C.d.ts +0 -12
  865. package/dist/with-rollup-K_iwal4b.d.ts +0 -47
  866. package/dist/withdraw-accessible-Q7BULAN5.js +0 -28
  867. package/dist/withdraw-accessible-Q7BULAN5.js.map +0 -1
  868. /package/dist/{adapter/index.js.map → api-ZGS6LCOF.js.map} +0 -0
  869. /package/dist/{chunk-VIWOGJ2O.js.map → chunk-3B5VVCNY.js.map} +0 -0
  870. /package/dist/{chunk-P2PEPSPK.js.map → chunk-3LQ2YKO4.js.map} +0 -0
  871. /package/dist/{chunk-EU7HDMT3.js.map → chunk-3QCRBHCY.js.map} +0 -0
  872. /package/dist/{chunk-FZK3JJJK.js.map → chunk-4JBYV75E.js.map} +0 -0
  873. /package/dist/{chunk-I6JJ6VJS.js.map → chunk-4NXKCLLQ.js.map} +0 -0
  874. /package/dist/{chunk-VFQOE76I.js.map → chunk-5M5DVGV7.js.map} +0 -0
  875. /package/dist/{chunk-LFGJG4XZ.js.map → chunk-5YOLBEQ6.js.map} +0 -0
  876. /package/dist/{chunk-OWGAXPRE.js.map → chunk-6CRIV7DE.js.map} +0 -0
  877. /package/dist/{chunk-QABECTNN.js.map → chunk-6QTNZJBS.js.map} +0 -0
  878. /package/dist/{chunk-723XB5NX.js.map → chunk-6T2SCQRU.js.map} +0 -0
  879. /package/dist/{chunk-PVC2FBCQ.js.map → chunk-7DSTRQIJ.js.map} +0 -0
  880. /package/dist/{chunk-NTPWQH4S.js.map → chunk-AUSTCW2X.js.map} +0 -0
  881. /package/dist/{chunk-MOQ5M46U.js.map → chunk-B3HJYUOF.js.map} +0 -0
  882. /package/dist/{chunk-QYMMMKOO.js.map → chunk-BDVFPG6Y.js.map} +0 -0
  883. /package/dist/{chunk-PYIUDUGS.js.map → chunk-CAF6WOK7.js.map} +0 -0
  884. /package/dist/{chunk-5HZULLHE.js.map → chunk-CIE2BASH.js.map} +0 -0
  885. /package/dist/{chunk-BTFTHF6Q.js.map → chunk-CRI4OUV4.js.map} +0 -0
  886. /package/dist/{chunk-37JZR7CY.js.map → chunk-DLG74CNB.js.map} +0 -0
  887. /package/dist/{chunk-TCGVRKOS.js.map → chunk-ERJ7FU55.js.map} +0 -0
  888. /package/dist/{chunk-FWART3VA.js.map → chunk-EVVGJDRQ.js.map} +0 -0
  889. /package/dist/{chunk-X5QZAJDB.js.map → chunk-EXK7QRWF.js.map} +0 -0
  890. /package/dist/{chunk-5HRJQSKN.js.map → chunk-EYZ6IQ6X.js.map} +0 -0
  891. /package/dist/{chunk-DCVVCJVB.js.map → chunk-F64IRYG3.js.map} +0 -0
  892. /package/dist/{chunk-BJ2XF2RC.js.map → chunk-FHS2HQSH.js.map} +0 -0
  893. /package/dist/{chunk-HU55NPHZ.js.map → chunk-GKEWXIV5.js.map} +0 -0
  894. /package/dist/{chunk-I6URUNTD.js.map → chunk-GTGPO5KW.js.map} +0 -0
  895. /package/dist/{chunk-5UOPIPZC.js.map → chunk-HB3RFQSC.js.map} +0 -0
  896. /package/dist/{chunk-F3EKFGUS.js.map → chunk-I6GALP6E.js.map} +0 -0
  897. /package/dist/{chunk-R4IVPJHN.js.map → chunk-IL6POWCW.js.map} +0 -0
  898. /package/dist/{chunk-3KBK5LU4.js.map → chunk-IU6SNYX6.js.map} +0 -0
  899. /package/dist/{chunk-TUL5YQWF.js.map → chunk-J2ZX2XUV.js.map} +0 -0
  900. /package/dist/{chunk-UWZ7O4NR.js.map → chunk-JKJOGPZN.js.map} +0 -0
  901. /package/dist/{chunk-V76PHWLE.js.map → chunk-JZUV47FZ.js.map} +0 -0
  902. /package/dist/{chunk-II6DLDZM.js.map → chunk-K5IMOGHB.js.map} +0 -0
  903. /package/dist/{chunk-GDOOG5YQ.js.map → chunk-LASZKVMO.js.map} +0 -0
  904. /package/dist/{chunk-5YBUFCFF.js.map → chunk-NR5LT5RY.js.map} +0 -0
  905. /package/dist/{chunk-UMH35AQV.js.map → chunk-Q5VNKNE5.js.map} +0 -0
  906. /package/dist/{chunk-XW5LZYV4.js.map → chunk-QLWMEXCT.js.map} +0 -0
  907. /package/dist/{chunk-PAJCRV7O.js.map → chunk-QRB7NAOJ.js.map} +0 -0
  908. /package/dist/{chunk-U7LV2DUN.js.map → chunk-R4ROFEYC.js.map} +0 -0
  909. /package/dist/{chunk-RNYDHIQL.js.map → chunk-RIX4V2TB.js.map} +0 -0
  910. /package/dist/{chunk-L6Q5NA22.js.map → chunk-RYCTDFUX.js.map} +0 -0
  911. /package/dist/{chunk-CHK5VVMI.js.map → chunk-RZ5SVOYR.js.map} +0 -0
  912. /package/dist/{chunk-TIAYXOEI.js.map → chunk-SLFHQTTW.js.map} +0 -0
  913. /package/dist/{chunk-J5YUA6JB.js.map → chunk-UNFPPVNI.js.map} +0 -0
  914. /package/dist/{chunk-25G7PUTA.js.map → chunk-VLFCJYTL.js.map} +0 -0
  915. /package/dist/{chunk-7CZ6YXMO.js.map → chunk-VN3DBQAU.js.map} +0 -0
  916. /package/dist/{chunk-J7OH6R4K.js.map → chunk-VZRODIM3.js.map} +0 -0
  917. /package/dist/{chunk-55LSDABW.js.map → chunk-W22IKJE2.js.map} +0 -0
  918. /package/dist/{chunk-GLVXQU3E.js.map → chunk-X3YYQWOQ.js.map} +0 -0
  919. /package/dist/{chunk-M3OYTM5Z.js.map → chunk-YFXZEAYK.js.map} +0 -0
  920. /package/dist/{chunk-5JQMX2EH.js.map → chunk-ZAJAVEXY.js.map} +0 -0
  921. /package/dist/{chunk-26FSVNBL.js.map → chunk-ZICD77GM.js.map} +0 -0
  922. /package/dist/{chunk-IARAK3PK.js.map → chunk-ZUODRVHY.js.map} +0 -0
  923. /package/dist/{api-JDWL67WL.js.map → collection-facade-TLWIPI76.js.map} +0 -0
  924. /package/dist/{chunk-BGIZAFY7.js.map → computed-ZIQTYTDI.js.map} +0 -0
  925. /package/dist/{dead-filter-RHMNYOXP.js.map → dead-filter-ESOBZZP5.js.map} +0 -0
  926. /package/dist/{chunk-K2WCO3NX.js.map → delegation-W7ZV2322.js.map} +0 -0
  927. /package/dist/{collection-facade-EJVIN2BY.js.map → derive-H2BJTLUI.js.map} +0 -0
  928. /package/dist/{computed-6FOFXQPE.js.map → enclave-AP3I5W7O.js.map} +0 -0
  929. /package/dist/{delegation-IHXOASHV.js.map → executor-KGWTNEQD.js.map} +0 -0
  930. /package/dist/{derive-CD3ZVIXK.js.map → executor-OVEXR6RT.js.map} +0 -0
  931. /package/dist/{describe/index.js.map → executor-UNEH5ZYH.js.map} +0 -0
  932. /package/dist/{enclave-KGEUW2GL.js.map → export-accessible-PCMXSUZS.js.map} +0 -0
  933. /package/dist/{executor-EUPYHCLU.js.map → extract-partition-SWHFSYJO.js.map} +0 -0
  934. /package/dist/{fanout-sidecar-NBDKKCHT.js.map → fanout-sidecar-A765THMX.js.map} +0 -0
  935. /package/dist/{executor-KZ4B3PRT.js.map → find-N6345CNT.js.map} +0 -0
  936. /package/dist/{executor-MHUM2VZK.js.map → issue-5OKB6I2R.js.map} +0 -0
  937. /package/dist/{export-accessible-Z3NSZZHN.js.map → ledger-GFBKVPV4.js.map} +0 -0
  938. /package/dist/{extract-partition-VSKT35JG.js.map → liberate-3VDOT4KO.js.map} +0 -0
  939. /package/dist/{find-OH4BEULF.js.map → link-set-Z7Q2ASFX.js.map} +0 -0
  940. /package/dist/{issue-AEOL6RXA.js.map → noydb-ZCJOYBDI.js.map} +0 -0
  941. /package/dist/{kernel/index.js.map → policy-Z3RUAIY2.js.map} +0 -0
  942. /package/dist/{ledger-3LR3YO2W.js.map → public-envelope-B4KNWVUA.js.map} +0 -0
  943. /package/dist/{liberate-XSEPRWEA.js.map → read-only-facade-CHCKSEPD.js.map} +0 -0
  944. /package/dist/{link-set-NSUIX6BR.js.map → register-VAHONCID.js.map} +0 -0
  945. /package/dist/{noydb-POVTIVQ6.js.map → registry-7MLVD3VO.js.map} +0 -0
  946. /package/dist/{policy-Y7HL2KGA.js.map → registry-EPKPD5SM.js.map} +0 -0
  947. /package/dist/{public-envelope-NC7SPNMV.js.map → registry-P5T7PS2U.js.map} +0 -0
  948. /package/dist/{read-only-facade-5ADRJVTM.js.map → request-withdrawal-TI3A5WPS.js.map} +0 -0
  949. /package/dist/{register-3D6R2MKN.js.map → revoke-FDRD6GRW.js.map} +0 -0
  950. /package/dist/{registry-AI4E46PD.js.map → signer-MUWEIUI6.js.map} +0 -0
  951. /package/dist/{registry-HSNQ4NBP.js.map → stale-OSQ7J3AA.js.map} +0 -0
  952. /package/dist/{registry-WIX6QCV5.js.map → storage-MVFCGEQE.js.map} +0 -0
  953. /package/dist/{store-coordination-provider-NJDDZ264.js.map → store-coordination-provider-64OEZFGS.js.map} +0 -0
  954. /package/dist/{walk-SMAE4IEI.js.map → walk-SVNDIZ62.js.map} +0 -0
  955. /package/dist/{request-withdrawal-GU4XS2R5.js.map → withdraw-accessible-WZIEVWSR.js.map} +0 -0
@@ -0,0 +1,1697 @@
1
+ import {
2
+ reducerBuilder
3
+ } from "./chunk-LXEXBTKL.js";
4
+ import {
5
+ evaluateClause,
6
+ hasFnClause,
7
+ readPath
8
+ } from "./chunk-IGJCYUT5.js";
9
+ import {
10
+ CrossJoinSourceUnknownError,
11
+ CrossJoinTooLargeError,
12
+ DanglingReferenceError,
13
+ FieldNotQueryableError,
14
+ JoinTooLargeError
15
+ } from "./chunk-BIOUI4HL.js";
16
+
17
+ // src/kernel/query/join.ts
18
+ var DEFAULT_JOIN_MAX_ROWS = 5e4;
19
+ var JOIN_WARN_FRACTION = 0.8;
20
+ function coerceRefKey(value) {
21
+ if (value === null || value === void 0) return null;
22
+ if (typeof value === "string") return value;
23
+ if (typeof value === "number" || typeof value === "bigint") return String(value);
24
+ return null;
25
+ }
26
+ var warnedDanglingKeys = /* @__PURE__ */ new Set();
27
+ function warnOnceDangling(field, target, refId) {
28
+ const key = `${field}\u2192${target}:${refId}`;
29
+ if (warnedDanglingKeys.has(key)) return;
30
+ warnedDanglingKeys.add(key);
31
+ console.warn(
32
+ `[noy-db] .join() encountered dangling ref in 'warn' mode: field "${field}" \u2192 "${target}:${refId}" not found. Attaching null.`
33
+ );
34
+ }
35
+ var warnedCeilingKeys = /* @__PURE__ */ new Set();
36
+ function warnCeilingApproaching(target, side, rows, maxRows) {
37
+ const key = `${target}:${side}`;
38
+ if (warnedCeilingKeys.has(key)) return;
39
+ warnedCeilingKeys.add(key);
40
+ const pct = Math.round(rows / maxRows * 100);
41
+ console.warn(
42
+ `[noy-db] .join() ${side} side is at ${pct}% of the ${maxRows}-row ceiling for target "${target}" (${rows} rows). Streaming joins over scan() are not yet supported for collections that need to exceed this.`
43
+ );
44
+ }
45
+ function applyJoins(rows, joins, context, locale) {
46
+ if (joins.length === 0) return [...rows];
47
+ let result = [...rows];
48
+ for (const leg of joins) {
49
+ result = applyOneJoin(result, leg, context, locale);
50
+ }
51
+ return result;
52
+ }
53
+ function applyOneJoin(leftRows, leg, context, locale) {
54
+ if (leg.isDictJoin) {
55
+ const dictSource = context.resolveDictSource?.(leg.field);
56
+ if (!dictSource) {
57
+ throw new Error(
58
+ `.join() field "${leg.field}" on "${context.leftCollection}" is declared as a dictKey join but the dict source could not be resolved. Ensure the dictionary has at least one entry.`
59
+ );
60
+ }
61
+ const out = [];
62
+ const snapshot = dictSource.snapshot();
63
+ const dictMap = /* @__PURE__ */ new Map();
64
+ for (const entry of snapshot) {
65
+ const k = readPath(entry, "key");
66
+ if (typeof k === "string") dictMap.set(k, entry);
67
+ }
68
+ for (const left of leftRows) {
69
+ const rawId = readPath(left, leg.field);
70
+ const key = coerceRefKey(rawId);
71
+ const dictEntry = key === null ? void 0 : dictMap.get(key);
72
+ out.push({ ...left, [leg.as]: dictEntry ?? null });
73
+ }
74
+ return out;
75
+ }
76
+ const source = context.resolveSource(leg.target);
77
+ if (!source) {
78
+ throw new Error(
79
+ `.join() cannot resolve target collection "${leg.target}" (referenced from field "${leg.field}" on "${context.leftCollection}"). Make sure the target collection has been opened via vault.collection() at least once before running the query.`
80
+ );
81
+ }
82
+ const maxRows = leg.maxRows ?? DEFAULT_JOIN_MAX_ROWS;
83
+ if (leftRows.length > maxRows) {
84
+ throw new JoinTooLargeError({
85
+ leftRows: leftRows.length,
86
+ rightRows: -1,
87
+ maxRows,
88
+ side: "left",
89
+ message: `.join() left side has ${leftRows.length} rows, exceeding the ${maxRows}-row ceiling for target "${leg.target}". Filter the left side further with where()/limit() before joining, or raise the ceiling via { maxRows }. Streaming joins over scan() are not yet supported.`
90
+ });
91
+ }
92
+ if (leftRows.length > maxRows * JOIN_WARN_FRACTION) {
93
+ warnCeilingApproaching(leg.target, "left", leftRows.length, maxRows);
94
+ }
95
+ const rightSnapshot = source.snapshot();
96
+ if (rightSnapshot.length > maxRows) {
97
+ throw new JoinTooLargeError({
98
+ leftRows: leftRows.length,
99
+ rightRows: rightSnapshot.length,
100
+ maxRows,
101
+ side: "right",
102
+ message: `.join() right side "${leg.target}" has ${rightSnapshot.length} rows, exceeding the ${maxRows}-row ceiling. Raise the ceiling via { maxRows } if the data genuinely fits in memory, or track for streaming joins.`
103
+ });
104
+ }
105
+ if (rightSnapshot.length > maxRows * JOIN_WARN_FRACTION) {
106
+ warnCeilingApproaching(leg.target, "right", rightSnapshot.length, maxRows);
107
+ }
108
+ const effLocale = locale ?? context.defaultLocale;
109
+ const presentResolve = effLocale !== void 0 && source.presentForJoin !== void 0 ? (right) => right !== null && typeof right === "object" ? source.presentForJoin(right, effLocale) : right : void 0;
110
+ const strategy = leg.strategy ?? (source.lookupById ? "nested" : "hash");
111
+ if (strategy === "nested" && source.lookupById) {
112
+ const lookup = (id) => source.lookupById?.(id);
113
+ return nestedLoopJoin(leftRows, leg, lookup, presentResolve);
114
+ }
115
+ return hashJoin(leftRows, leg, rightSnapshot, presentResolve);
116
+ }
117
+ function nestedLoopJoin(leftRows, leg, lookupById, presentResolve) {
118
+ const out = [];
119
+ for (const left of leftRows) {
120
+ const rawId = readPath(left, leg.field);
121
+ const key = coerceRefKey(rawId);
122
+ let right = key === null ? void 0 : lookupById(key);
123
+ if (presentResolve && right !== void 0) right = presentResolve(right);
124
+ out.push(attachJoin(left, leg, right, rawId));
125
+ }
126
+ return out;
127
+ }
128
+ function hashJoin(leftRows, leg, rightSnapshot, presentResolve) {
129
+ const rightMap = /* @__PURE__ */ new Map();
130
+ for (const record of rightSnapshot) {
131
+ const rawId = readPath(record, "id");
132
+ const key = coerceRefKey(rawId);
133
+ if (key !== null) {
134
+ rightMap.set(key, record);
135
+ }
136
+ }
137
+ const out = [];
138
+ for (const left of leftRows) {
139
+ const rawId = readPath(left, leg.field);
140
+ const key = coerceRefKey(rawId);
141
+ let right = key === null ? void 0 : rightMap.get(key);
142
+ if (presentResolve && right !== void 0) right = presentResolve(right);
143
+ out.push(attachJoin(left, leg, right, rawId));
144
+ }
145
+ return out;
146
+ }
147
+ function attachJoin(left, leg, right, rawId) {
148
+ if (left === null || typeof left !== "object") {
149
+ return left;
150
+ }
151
+ const merged = { ...left };
152
+ const refKey = coerceRefKey(rawId);
153
+ if (right === void 0) {
154
+ if (refKey !== null && leg.mode === "strict") {
155
+ throw new DanglingReferenceError({
156
+ field: leg.field,
157
+ target: leg.target,
158
+ refId: refKey,
159
+ message: `.join() strict dangling: record references "${leg.target}:${refKey}" via field "${leg.field}", but no such record exists. Use ref() mode 'warn' or 'cascade' if dangling refs are acceptable, or run vault.checkIntegrity() to find and fix the orphans.`
160
+ });
161
+ }
162
+ if (refKey !== null && leg.mode === "warn") {
163
+ warnOnceDangling(leg.field, leg.target, refKey);
164
+ }
165
+ merged[leg.as] = null;
166
+ } else {
167
+ merged[leg.as] = right;
168
+ }
169
+ return merged;
170
+ }
171
+ function resetJoinWarnings() {
172
+ warnedDanglingKeys.clear();
173
+ warnedCeilingKeys.clear();
174
+ }
175
+
176
+ // src/kernel/query/live.ts
177
+ function buildLiveQuery(recompute, upstreams) {
178
+ return new LiveQueryImpl(recompute, upstreams);
179
+ }
180
+ var LiveQueryImpl = class {
181
+ constructor(recompute, upstreams) {
182
+ this.recompute = recompute;
183
+ this.refresh();
184
+ for (const upstream of upstreams) {
185
+ try {
186
+ this.unsubs.push(upstream.subscribe(this.onUpstreamChange));
187
+ } catch (err) {
188
+ this._error = err instanceof Error ? err : new Error(String(err));
189
+ }
190
+ }
191
+ }
192
+ recompute;
193
+ _value = [];
194
+ _error = null;
195
+ listeners = /* @__PURE__ */ new Set();
196
+ unsubs = [];
197
+ stopped = false;
198
+ get value() {
199
+ return this._value;
200
+ }
201
+ get error() {
202
+ return this._error;
203
+ }
204
+ /**
205
+ * Bound change handler — used as the callback passed to every
206
+ * upstream's subscribe. Bound via class field so the `this`
207
+ * context survives the indirect call from arbitrary upstreams.
208
+ */
209
+ onUpstreamChange = () => {
210
+ this.refresh();
211
+ for (const cb of this.listeners) {
212
+ try {
213
+ cb();
214
+ } catch {
215
+ }
216
+ }
217
+ };
218
+ refresh() {
219
+ if (this.stopped) return;
220
+ try {
221
+ this._value = this.recompute();
222
+ this._error = null;
223
+ } catch (err) {
224
+ this._error = err instanceof Error ? err : new Error(String(err));
225
+ }
226
+ }
227
+ subscribe(cb) {
228
+ if (this.stopped) return () => {
229
+ };
230
+ this.listeners.add(cb);
231
+ return () => this.listeners.delete(cb);
232
+ }
233
+ stop() {
234
+ if (this.stopped) return;
235
+ this.stopped = true;
236
+ for (const unsub of this.unsubs) {
237
+ try {
238
+ unsub();
239
+ } catch {
240
+ }
241
+ }
242
+ this.unsubs.length = 0;
243
+ this.listeners.clear();
244
+ }
245
+ };
246
+
247
+ // src/with-lookup/aggregate/strategy.ts
248
+ var NOT_ENABLED = new Error(
249
+ 'Aggregate / groupBy is not enabled on this Noydb instance. Import `{ withAggregate }` from "@noy-db/hub/aggregate" and pass it to `createNoydb({ aggregateStrategy: withAggregate() })`.'
250
+ );
251
+ var NO_AGGREGATE = {
252
+ aggregate() {
253
+ throw NOT_ENABLED;
254
+ },
255
+ groupBy() {
256
+ throw NOT_ENABLED;
257
+ },
258
+ groupByN() {
259
+ throw NOT_ENABLED;
260
+ },
261
+ scanAggregate() {
262
+ throw NOT_ENABLED;
263
+ }
264
+ };
265
+
266
+ // src/kernel/query/builder.ts
267
+ var EMPTY_PLAN = {
268
+ clauses: [],
269
+ orderBy: [],
270
+ limit: void 0,
271
+ offset: 0,
272
+ joins: []
273
+ };
274
+ var DEFAULT_CROSS_JOIN_MAX_ROWS = 5e4;
275
+ var Query = class _Query {
276
+ source;
277
+ plan;
278
+ joinContext;
279
+ aggregateStrategy;
280
+ predicates;
281
+ constructor(source, plan = EMPTY_PLAN, joinContext, aggregateStrategy = NO_AGGREGATE, predicates) {
282
+ this.source = source;
283
+ this.plan = plan;
284
+ this.joinContext = joinContext;
285
+ this.aggregateStrategy = aggregateStrategy;
286
+ this.predicates = predicates;
287
+ }
288
+ /**
289
+ * @internal — accessor for the materialized-view dependency
290
+ * analyzer. Not part of the public API; consumers should use the
291
+ * builder methods, not inspect the plan directly.
292
+ */
293
+ _plan() {
294
+ return this.plan;
295
+ }
296
+ /**
297
+ * @internal — accessor for the materialized-view dependency
298
+ * analyzer. Returns the join resolution context (or `undefined` for
299
+ * queries constructed without a Collection backing).
300
+ */
301
+ _joinContext() {
302
+ return this.joinContext;
303
+ }
304
+ /**
305
+ * @internal — clone this Query with a declared-predicate map
306
+ * attached. Used by the materialized-view registry to enable
307
+ * `.wherePredicate(name, ctx?)` for the MV's query callback.
308
+ * Consumers don't call this directly.
309
+ */
310
+ _withPredicates(predicates) {
311
+ return new _Query(
312
+ this.source,
313
+ this.plan,
314
+ this.joinContext,
315
+ this.aggregateStrategy,
316
+ predicates
317
+ );
318
+ }
319
+ /**
320
+ * @internal — the ids of records matching this query's plan,
321
+ * recovered by reference identity: `executePlanWithSource` returns the
322
+ * ORIGINAL snapshot record references (money-decode and joins are applied
323
+ * later, in `toArray`), so each matched record is found in the id-paired
324
+ * `snapshotEntries()` map. Used by `collection.retrieve({ within })`.
325
+ * Throws if the source is not collection-backed (no `snapshotEntries`).
326
+ */
327
+ _idArray() {
328
+ const entries = this.source.snapshotEntries?.();
329
+ if (entries === void 0) {
330
+ throw new Error(
331
+ "Query._idArray(): the query source has no snapshotEntries(); retrieve({ within }) requires a collection-backed query (collection.query())."
332
+ );
333
+ }
334
+ if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
335
+ throw new Error(
336
+ "Query._idArray(): retrieve({ within }) does not support crossJoin queries (cross-join produces new row objects, breaking id recovery). Use where/filter/and/or, or a projection .join()."
337
+ );
338
+ }
339
+ const refToId = /* @__PURE__ */ new Map();
340
+ for (const { id, record } of entries) refToId.set(record, id);
341
+ const matched = executePlanWithSource(this.source, this.plan, this.joinContext);
342
+ const ids = [];
343
+ for (const r of matched) {
344
+ const id = refToId.get(r);
345
+ if (id !== void 0) ids.push(id);
346
+ }
347
+ return ids;
348
+ }
349
+ /**
350
+ * Filter by a registered deterministic predicate. Requires
351
+ * the Query to have been augmented with a predicates map (typically
352
+ * via the materialized-view registry — bare Queries constructed
353
+ * outside an MV throw on `.wherePredicate()`).
354
+ *
355
+ * `ctx` is an optional opaque value passed verbatim to the predicate
356
+ * function. Both `predicateHash` (from the registration) and a
357
+ * canonical-JSON hash of `ctx` fold into the MV's `queryHash`, so
358
+ * either changing forces refresh on next visit.
359
+ */
360
+ wherePredicate(name, ctx) {
361
+ if (!this.predicates) {
362
+ throw new Error(
363
+ `.wherePredicate("${name}"): no predicates registered on this Query. Function-based predicates require the Query to be obtained from inside a materialized-view query() callback whose strategy declares \`predicates: { ${name}: { hash, fn } }\`.`
364
+ );
365
+ }
366
+ const decl = this.predicates.get(name);
367
+ if (!decl) {
368
+ throw new Error(
369
+ `.wherePredicate("${name}"): predicate not registered. Available: ${[...this.predicates.keys()].join(", ") || "(none)"}.`
370
+ );
371
+ }
372
+ const clause = {
373
+ type: "wherePredicate",
374
+ name,
375
+ ctx,
376
+ predicateHash: decl.hash,
377
+ ctxHash: canonicalCtxHash(ctx),
378
+ fn: decl.fn
379
+ };
380
+ return new _Query(
381
+ this.source,
382
+ { ...this.plan, clauses: [...this.plan.clauses, clause] },
383
+ this.joinContext,
384
+ this.aggregateStrategy,
385
+ this.predicates
386
+ );
387
+ }
388
+ /**
389
+ * Add a field comparison. Multiple where() calls are AND-combined.
390
+ *
391
+ * A declared money field compares in MAJOR units: the operand
392
+ * (`10000`, `'10000.00'`, or `{ amount, currency }` in multi mode) is
393
+ * quantized into stored scaled-int space at build time and evaluated
394
+ * BigInt-exact per record. A malformed operand or a string operator
395
+ * (`contains`/`startsWith`) throws here, at the call site.
396
+ *
397
+ * Consults the Via pipeline's posture before building a clause (#629
398
+ * Task 8): a field whose posture is `queryable: 'none'` (e.g. a
399
+ * `blobFields` slot) throws `FieldNotQueryableError` here, at the call
400
+ * site. Every other posture is unaffected — the existing per-binding
401
+ * `buildClause` machinery runs exactly as before.
402
+ */
403
+ where(field, op, value) {
404
+ const via = this.source.via;
405
+ if (via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
406
+ const viaClause = via?.buildClause(field, op, value);
407
+ const clause = viaClause ? {
408
+ type: "field",
409
+ field,
410
+ op,
411
+ value,
412
+ via: {
413
+ brand: viaClause.brand,
414
+ payload: viaClause.payload,
415
+ evaluate: (actual, evalOp) => via.evaluateClause(viaClause, actual, evalOp),
416
+ indexValue: via.indexProbe(viaClause, op)
417
+ }
418
+ } : { type: "field", field, op, value };
419
+ return new _Query(
420
+ this.source,
421
+ { ...this.plan, clauses: [...this.plan.clauses, clause] },
422
+ this.joinContext,
423
+ this.aggregateStrategy,
424
+ this.predicates
425
+ );
426
+ }
427
+ /**
428
+ * Logical OR group. Pass a callback that builds a sub-query.
429
+ * Each clause inside the callback is OR-combined; the group itself
430
+ * joins the parent plan with AND.
431
+ */
432
+ or(builder) {
433
+ const sub = builder(
434
+ new _Query(this.source, EMPTY_PLAN, this.joinContext, this.aggregateStrategy, this.predicates)
435
+ );
436
+ const group = {
437
+ type: "group",
438
+ op: "or",
439
+ clauses: sub.plan.clauses
440
+ };
441
+ return new _Query(
442
+ this.source,
443
+ { ...this.plan, clauses: [...this.plan.clauses, group] },
444
+ this.joinContext,
445
+ this.aggregateStrategy,
446
+ this.predicates
447
+ );
448
+ }
449
+ /**
450
+ * Logical AND group. Same shape as `or()` but every clause inside the group
451
+ * must match. Useful for explicit grouping inside a larger OR.
452
+ */
453
+ and(builder) {
454
+ const sub = builder(
455
+ new _Query(this.source, EMPTY_PLAN, this.joinContext, this.aggregateStrategy, this.predicates)
456
+ );
457
+ const group = {
458
+ type: "group",
459
+ op: "and",
460
+ clauses: sub.plan.clauses
461
+ };
462
+ return new _Query(
463
+ this.source,
464
+ { ...this.plan, clauses: [...this.plan.clauses, group] },
465
+ this.joinContext,
466
+ this.aggregateStrategy,
467
+ this.predicates
468
+ );
469
+ }
470
+ /** Escape hatch: add an arbitrary predicate function. Not serializable. */
471
+ filter(fn) {
472
+ const clause = {
473
+ type: "filter",
474
+ fn
475
+ };
476
+ return new _Query(
477
+ this.source,
478
+ { ...this.plan, clauses: [...this.plan.clauses, clause] },
479
+ this.joinContext,
480
+ this.aggregateStrategy,
481
+ this.predicates
482
+ );
483
+ }
484
+ /**
485
+ * Sort by a field. Subsequent calls are tie-breakers. Pass
486
+ * `{ by: 'label' }` to sort a `dictKey`/`staticDict` field by its resolved
487
+ * label at the query locale instead of the stored code.
488
+ *
489
+ * Consults the Via pipeline's posture (#629 Task 8): a field whose posture
490
+ * is `queryable: 'none'` throws `FieldNotQueryableError` here, at the call
491
+ * site — same gate as `where()`.
492
+ */
493
+ orderBy(field, direction = "asc", opts) {
494
+ if (this.source.via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
495
+ const entry = opts?.by === "label" ? { field, direction, by: "label" } : { field, direction };
496
+ return new _Query(
497
+ this.source,
498
+ { ...this.plan, orderBy: [...this.plan.orderBy, entry] },
499
+ this.joinContext,
500
+ this.aggregateStrategy,
501
+ this.predicates
502
+ );
503
+ }
504
+ /** Cap the result size. */
505
+ limit(n) {
506
+ return new _Query(
507
+ this.source,
508
+ { ...this.plan, limit: n },
509
+ this.joinContext,
510
+ this.aggregateStrategy,
511
+ this.predicates
512
+ );
513
+ }
514
+ /** Skip the first N matching records (after ordering). */
515
+ offset(n) {
516
+ return new _Query(
517
+ this.source,
518
+ { ...this.plan, offset: n },
519
+ this.joinContext,
520
+ this.aggregateStrategy,
521
+ this.predicates
522
+ );
523
+ }
524
+ /**
525
+ * Resolve a `ref()`-declared foreign key and attach the right-side
526
+ * record under `opts.as`. — eager, single-FK, intra-
527
+ * vault joins.
528
+ *
529
+ * ```ts
530
+ * const rows = invoices.query()
531
+ * .where('status', '==', 'open')
532
+ * .join('clientId', { as: 'client' })
533
+ * .toArray()
534
+ * // → [{ id, amount, client: { id, name, ... } }, ...]
535
+ * ```
536
+ *
537
+ * Preconditions:
538
+ * - The Query must have a `joinContext` (constructed via
539
+ * `Collection.query()`, not `new Query`).
540
+ * - `field` must have a matching `refs: { [field]: ref('<target>') }`
541
+ * declaration on the left collection.
542
+ * - The target collection must be reachable via the vault
543
+ * (either currently open or openable on demand).
544
+ *
545
+ * Strategy:
546
+ * - Nested-loop against `lookupById` when the target source
547
+ * provides it (the common path for Collection targets).
548
+ * - Hash join otherwise, or when `{ strategy: 'hash' }` is
549
+ * explicitly passed for test purposes.
550
+ *
551
+ * Ref-mode semantics on dangling refs (left record has a non-null
552
+ * FK value pointing at a right-side id that doesn't exist):
553
+ * - `strict` → throws `DanglingReferenceError` with the full
554
+ * field / target / refId context.
555
+ * - `warn` → attaches `null` and emits a one-shot warning per
556
+ * unique dangling pair.
557
+ * - `cascade` → attaches `null` silently. Cascade is a
558
+ * delete-time mode; dangling refs visible at read time are
559
+ * either mid-flight cascades or pre-existing orphans, not a
560
+ * DSL-level error.
561
+ *
562
+ * A left-side record whose FK field is `null` / `undefined` is NOT
563
+ * a dangling ref — it's "no reference at all", always allowed
564
+ * regardless of mode.
565
+ *
566
+ * The return type widens `T` with `Record<As, R | null>`. The `R`
567
+ * parameter is optional — supply it explicitly for type-checked
568
+ * access to the joined fields:
569
+ *
570
+ * ```ts
571
+ * invoices.query().join<'client', Client>('clientId', { as: 'client' })
572
+ * // ^^^^^^^^^^^^^^^^^^^ alias literal + right-side type
573
+ * ```
574
+ *
575
+ * Without the generic, the joined field is typed as `unknown`, which
576
+ * still works but requires a cast to access its properties.
577
+ *
578
+ * Joins stay intra-vault by construction — cross-vault
579
+ * correlation goes through `Noydb.queryAcross`, not
580
+ * `.join()`.
581
+ */
582
+ join(field, opts) {
583
+ if (!this.joinContext) {
584
+ throw new Error(
585
+ `Query.join() requires a join context. Use collection.query() to construct a join-capable Query instead of the Query constructor directly (the direct constructor is only used for tests with plain-object sources).`
586
+ );
587
+ }
588
+ const descriptor = this.joinContext.resolveRef(field);
589
+ const isDictJoinField = !descriptor && this.joinContext.resolveDictSource?.(field) != null;
590
+ if (!descriptor && !isDictJoinField) {
591
+ throw new Error(
592
+ `Query.join(): no ref() declared for field "${field}" on collection "${this.joinContext.leftCollection}". Add refs: { ${field}: ref('<target-collection>') } to the collection options, then retry. See the ref() docs for the full list of modes.`
593
+ );
594
+ }
595
+ const leg = descriptor ? {
596
+ field,
597
+ as: opts.as,
598
+ target: descriptor.target,
599
+ mode: descriptor.mode,
600
+ strategy: opts.strategy,
601
+ maxRows: opts.maxRows,
602
+ // constraint #1 — always 'all' in. Do not remove.
603
+ partitionScope: "all"
604
+ } : {
605
+ // Dict join leg
606
+ field,
607
+ as: opts.as,
608
+ target: field,
609
+ // dict name = field name for dictKey
610
+ mode: "strict",
611
+ strategy: opts.strategy,
612
+ maxRows: opts.maxRows,
613
+ partitionScope: "all",
614
+ isDictJoin: true
615
+ };
616
+ return new _Query(
617
+ this.source,
618
+ { ...this.plan, joins: [...this.plan.joins, leg] },
619
+ this.joinContext,
620
+ this.aggregateStrategy,
621
+ this.predicates
622
+ );
623
+ }
624
+ /**
625
+ * Cartesian-product cross-join against `target` collection. Each result row
626
+ * carries the original `T` fields plus `result[as]` populated from every
627
+ * right-side row (or the filtered subset when `on:` is supplied).
628
+ *
629
+ * **Order matters:** `.where().crossJoin()` filters BEFORE expanding (cheaper);
630
+ * `.crossJoin().where('alias.field', ...)` filters AFTER (required when the
631
+ * where clause references the aliased fields).
632
+ *
633
+ * **Cost ceiling:** `CrossJoinTooLargeError` fires before allocation when
634
+ * `leftRows × rightRows` (or the cumulative lateral count) exceeds the limit.
635
+ * Default: 50,000 rows. Override per-clause with `{ maxRows: N }`.
636
+ *
637
+ * **`on:` shapes:**
638
+ * - `on: (left) => TTarget[]` — subset form (most efficient)
639
+ * - `on: (left) => (right) => boolean` — predicate form
640
+ * - `on: { predicate: 'name' }` — MV-safe, hash-tracked form
641
+ * (requires the Query to have been augmented via `_withPredicates`)
642
+ *
643
+ * Requires a JoinContext (constructed via `collection.query()`).
644
+ */
645
+ crossJoin(target, opts) {
646
+ if (!this.joinContext) {
647
+ throw new Error(
648
+ `Query.crossJoin("${target}"): requires a join context. Use collection.query() to construct a cross-join-capable Query instead of the Query constructor directly.`
649
+ );
650
+ }
651
+ let onFn;
652
+ let onPredicateName;
653
+ if (opts.on !== void 0) {
654
+ if (typeof opts.on === "function") {
655
+ onFn = opts.on;
656
+ if (this.predicates) {
657
+ console.warn(
658
+ `Query.crossJoin("${target}", { on: callback }): inline on: callback inside a withMaterializedView query() disables queryHash drift detection for this cross-join. Use on: { predicate: '<name>' } to enable it.`
659
+ );
660
+ }
661
+ } else {
662
+ const predName = opts.on.predicate;
663
+ if (!this.predicates) {
664
+ throw new Error(
665
+ `Query.crossJoin("${target}", { on: { predicate: "${predName}" } }): the { predicate } form requires a predicates map. Use this form inside a withMaterializedView query() callback that declares predicates: { ${predName}: { hash, fn } }.`
666
+ );
667
+ }
668
+ const decl = this.predicates.get(predName);
669
+ if (!decl) {
670
+ throw new Error(
671
+ `Query.crossJoin("${target}"): predicate "${predName}" not registered. Available: ${[...this.predicates.keys()].join(", ") || "(none)"}.`
672
+ );
673
+ }
674
+ const as = opts.as;
675
+ const predicateFn = decl.fn;
676
+ onFn = (_left) => (right) => predicateFn({ ..._left, [as]: right });
677
+ onPredicateName = predName;
678
+ }
679
+ }
680
+ const clause = {
681
+ type: "crossJoin",
682
+ target,
683
+ as: opts.as,
684
+ ...onFn !== void 0 && { on: onFn },
685
+ ...onPredicateName !== void 0 && { onPredicateName },
686
+ ...opts.maxRows !== void 0 && { maxRows: opts.maxRows }
687
+ };
688
+ return new _Query(
689
+ this.source,
690
+ { ...this.plan, clauses: [...this.plan.clauses, clause] },
691
+ this.joinContext,
692
+ this.aggregateStrategy,
693
+ this.predicates
694
+ );
695
+ }
696
+ /**
697
+ * Execute the plan and return the matching records. When the plan
698
+ * carries any join legs, they are applied after `where` / `orderBy`
699
+ * / `limit` / `offset` narrow the left set. See the `.join()` doc
700
+ * for the ordering rationale.
701
+ *
702
+ * `opts.locale` resolves JOINED right-side i18n fields at the
703
+ * `join` layer to that locale; without it, the owning collection's default
704
+ * locale applies, and a locale-less query leaves joined i18n fields raw.
705
+ * (Left/base i18n fields are resolved by `get`/`list`, not here.)
706
+ */
707
+ toArray(opts) {
708
+ const base = this.decodeVia(executePlanWithSource(this.source, this.plan, this.joinContext, opts?.locale));
709
+ if (this.plan.joins.length === 0) return base;
710
+ if (!this.joinContext) {
711
+ throw new Error(
712
+ `Query.toArray(): plan carries ${this.plan.joins.length} join leg(s) but no JoinContext is attached. This usually means the Query was constructed via the raw Query constructor with a plan that had joins pre-populated. Use collection.query().join(...) instead.`
713
+ );
714
+ }
715
+ return applyJoins(base, this.plan.joins, this.joinContext, opts?.locale);
716
+ }
717
+ /**
718
+ * Decode this source's Via-covered fields on read (e.g. money: stored
719
+ * scaled-int → canonical decimal), so `query().toArray()` agrees with
720
+ * `get()`/`sum()` on the value. No-op when the source's Via pipeline
721
+ * declares no result decode.
722
+ *
723
+ * The query layer carries no locale context, so money decodes with
724
+ * `'raw'` — canonical decimal, WITHOUT fabricating locale-formatted
725
+ * `<field>Formatted` / `<field>Number` virtuals. Producing a
726
+ * guessed-locale string here would reintroduce a "two read paths
727
+ * disagree" failure on the virtual field (e.g. it-IT via `get()` vs
728
+ * en-US here). Consumers who need formatted money read through
729
+ * `get()`/`list()` with a locale.
730
+ */
731
+ decodeVia(records) {
732
+ const via = this.source.via;
733
+ if (!via || !via.hasResultDecode) return records;
734
+ return records.map((r) => via.decodeResults(r));
735
+ }
736
+ /** Return the first matching record, or null. Joins are applied. `opts.locale` resolves joined i18n fields. */
737
+ first(opts) {
738
+ const arr = this.limit(1).toArray(opts);
739
+ return arr[0] ?? null;
740
+ }
741
+ /**
742
+ * Return the number of matching records (after where/filter,
743
+ * before limit). **Joins are NOT applied** — count() reports the
744
+ * left-side cardinality, because joins in are projection-only
745
+ * (they attach an aliased field; they never filter). Running joins
746
+ * here just to discard the aliases would be wasteful, and in strict
747
+ * mode it could throw `DanglingReferenceError` for a call whose
748
+ * intent is purely to count.
749
+ */
750
+ count() {
751
+ if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
752
+ if (!this.joinContext) {
753
+ throw new Error(
754
+ `Query.count(): plan contains crossJoin clauses but no JoinContext is attached.`
755
+ );
756
+ }
757
+ return executeClausePipeline(this.source, this.plan.clauses, this.joinContext).length;
758
+ }
759
+ const { candidates, remainingClauses } = candidateRecords(this.source, this.plan.clauses);
760
+ if (remainingClauses.length === 0) return candidates.length;
761
+ return filterRecords(candidates, remainingClauses, fnViewDecoder(this.source)).length;
762
+ }
763
+ aggregate(specOrBuild) {
764
+ let spec = typeof specOrBuild === "function" ? specOrBuild(reducerBuilder) : specOrBuild;
765
+ spec = this.source.via?.wrapReducers(spec) ?? spec;
766
+ const source = this.source;
767
+ const clauses = this.plan.clauses;
768
+ const joinCtx = this.joinContext;
769
+ const hasCrossJoins = clauses.some((c) => c.type === "crossJoin");
770
+ const executeRecords = () => {
771
+ if (hasCrossJoins) {
772
+ if (!joinCtx) throw new Error("Query.aggregate(): crossJoin requires a join context");
773
+ return executeClausePipeline(source, clauses, joinCtx);
774
+ }
775
+ const { candidates, remainingClauses } = candidateRecords(source, clauses);
776
+ return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
777
+ };
778
+ const upstreams = [];
779
+ if (source.subscribe) {
780
+ const subscribe = source.subscribe.bind(source);
781
+ upstreams.push({ subscribe: (cb) => subscribe(cb) });
782
+ }
783
+ return this.aggregateStrategy.aggregate(executeRecords, spec, upstreams);
784
+ }
785
+ groupBy(...fields) {
786
+ if (fields.length === 0) {
787
+ throw new Error(".groupBy() requires at least one field");
788
+ }
789
+ const source = this.source;
790
+ const clauses = this.plan.clauses;
791
+ const joinCtx = this.joinContext;
792
+ const hasCrossJoins = clauses.some((c) => c.type === "crossJoin");
793
+ const executeRecords = () => {
794
+ if (hasCrossJoins) {
795
+ if (!joinCtx) throw new Error("Query.groupBy(): crossJoin requires a join context");
796
+ return executeClausePipeline(source, clauses, joinCtx);
797
+ }
798
+ const { candidates, remainingClauses } = candidateRecords(source, clauses);
799
+ return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
800
+ };
801
+ const upstreams = [];
802
+ if (source.subscribe) {
803
+ const subscribe = source.subscribe.bind(source);
804
+ upstreams.push({ subscribe: (cb) => subscribe(cb) });
805
+ }
806
+ if (fields.length === 1) {
807
+ const field = fields[0];
808
+ const dictLabelResolver = buildDictLabelResolver(this.joinContext, field);
809
+ return this.aggregateStrategy.groupBy(
810
+ executeRecords,
811
+ field,
812
+ upstreams,
813
+ dictLabelResolver,
814
+ this.source.via
815
+ );
816
+ }
817
+ return this.aggregateStrategy.groupByN(
818
+ executeRecords,
819
+ fields,
820
+ upstreams,
821
+ this.source.via
822
+ );
823
+ }
824
+ /**
825
+ * Re-run the query whenever the source notifies of changes.
826
+ * Returns an unsubscribe function. The callback receives the latest result.
827
+ * Throws if the source does not support subscriptions.
828
+ *
829
+ * **For joined queries, prefer `.live()`** — `subscribe()`
830
+ * only re-fires on LEFT-side changes, so joined data can be
831
+ * stale if the right side mutates between emissions. `.live()`
832
+ * merges change streams from every join target.
833
+ */
834
+ subscribe(cb) {
835
+ if (!this.source.subscribe) {
836
+ throw new Error("Query source does not support subscriptions. Pass a source with a subscribe() method.");
837
+ }
838
+ cb(this.toArray());
839
+ return this.source.subscribe(() => cb(this.toArray()));
840
+ }
841
+ /**
842
+ * Reactive terminal — returns a `LiveQuery<T>` that re-runs the
843
+ * query and updates its `value` whenever any source feeding it
844
+ * mutates..
845
+ *
846
+ * For non-joined queries, `.live()` is a convenience over the
847
+ * existing `.subscribe()` callback shape: a hand-rolled reactive
848
+ * primitive with `value` / `error` fields and a `subscribe(cb)`
849
+ * notification channel. Frame-agnostic — Vue / React / Solid
850
+ * adapters wrap it in their own primitive.
851
+ *
852
+ * For joined queries, `.live()` additionally subscribes to every
853
+ * join target's change stream. Mutations on a right-side
854
+ * collection (insert / update / delete of a client referenced by
855
+ * an invoice) re-fire the live query and re-evaluate every
856
+ * dependent left row. Right-side targets are deduped by
857
+ * collection name, so a chain that joins the same target twice
858
+ * (e.g. billing client + shipping client → both 'clients') only
859
+ * subscribes once.
860
+ *
861
+ * **Ref-mode behavior on right-side disappearance** — matches the
862
+ * eager `.toArray()` contract from :
863
+ * - `strict` → re-run throws `DanglingReferenceError`. The
864
+ * LiveQuery catches the throw, stores it in `live.error`, and
865
+ * notifies listeners (the throw does NOT propagate out of
866
+ * the source's change handler — that would tear down the
867
+ * emitter). Consumers check `live.error` after each
868
+ * notification and render an error state in the UI.
869
+ * - `warn` → joined value flips to `null`; the existing
870
+ * warn-channel deduplication keeps repeated re-runs from
871
+ * spamming the console.
872
+ * - `cascade` → no special handling needed; the cascade-
873
+ * delete mechanism propagates the right-side delete into the
874
+ * left collection on the next tick, and the live query
875
+ * naturally re-fires with the orphaned left rows gone.
876
+ *
877
+ * Always call `live.stop()` when finished — it tears down every
878
+ * upstream subscription. The Vue layer's `onUnmounted` hook
879
+ * should call `stop()` automatically; raw consumers must do it
880
+ * themselves.
881
+ *
882
+ * **Limitations:**
883
+ * - No granular delta updates — the whole query re-runs on
884
+ * every change.
885
+ * - No microtask batching — bursty changes produce one re-run
886
+ * per change.
887
+ * - No re-planning under live mutations — the planner picks
888
+ * once at subscription time and reuses the same plan.
889
+ * - Streaming live joins are deferred.
890
+ */
891
+ live() {
892
+ const upstreams = [];
893
+ if (this.source.subscribe) {
894
+ const leftSubscribe = this.source.subscribe.bind(this.source);
895
+ upstreams.push({
896
+ subscribe: (cb) => leftSubscribe(cb)
897
+ });
898
+ }
899
+ if (this.plan.joins.length > 0 && this.joinContext) {
900
+ const subscribed = /* @__PURE__ */ new Set();
901
+ for (const leg of this.plan.joins) {
902
+ if (subscribed.has(leg.target)) continue;
903
+ subscribed.add(leg.target);
904
+ const rightSource = this.joinContext.resolveSource(leg.target);
905
+ if (rightSource?.subscribe) {
906
+ const rightSubscribe = rightSource.subscribe.bind(rightSource);
907
+ upstreams.push({
908
+ subscribe: (cb) => rightSubscribe(cb)
909
+ });
910
+ }
911
+ }
912
+ }
913
+ if (this.joinContext) {
914
+ const subscribedCross = /* @__PURE__ */ new Set();
915
+ for (const clause of this.plan.clauses) {
916
+ if (clause.type !== "crossJoin") continue;
917
+ if (subscribedCross.has(clause.target)) continue;
918
+ subscribedCross.add(clause.target);
919
+ const rightSource = this.joinContext.resolveSource(clause.target);
920
+ if (rightSource?.subscribe) {
921
+ const rightSubscribe = rightSource.subscribe.bind(rightSource);
922
+ upstreams.push({
923
+ subscribe: (cb) => rightSubscribe(cb)
924
+ });
925
+ }
926
+ }
927
+ }
928
+ return buildLiveQuery(() => this.toArray(), upstreams);
929
+ }
930
+ /**
931
+ * Return the plan as a JSON-friendly object. FilterClause entries are
932
+ * stripped (their `fn` cannot be serialized) and replaced with
933
+ * { type: 'filter', fn: '[function]' } so devtools can still see them.
934
+ */
935
+ toPlan() {
936
+ return serializePlan(this.plan);
937
+ }
938
+ };
939
+ function executePlanWithSource(source, plan, joinContext, locale) {
940
+ const hasCrossJoins = plan.clauses.some((c) => c.type === "crossJoin");
941
+ let result;
942
+ if (hasCrossJoins) {
943
+ if (!joinContext) {
944
+ throw new Error(
945
+ `Query.toArray(): plan contains crossJoin clauses but no JoinContext is attached. Use collection.query() instead of new Query() for cross-join support.`
946
+ );
947
+ }
948
+ result = executeClausePipeline(source, plan.clauses, joinContext);
949
+ } else {
950
+ const { candidates, remainingClauses } = candidateRecords(source, plan.clauses);
951
+ result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
952
+ }
953
+ if (plan.orderBy.length > 0) {
954
+ const labelMaps = buildOrderLabelMaps(plan.orderBy, joinContext, locale, source.via);
955
+ result = sortRecords(result, plan.orderBy, source.via, labelMaps);
956
+ }
957
+ if (plan.offset > 0) {
958
+ result = result.slice(plan.offset);
959
+ }
960
+ if (plan.limit !== void 0) {
961
+ result = result.slice(0, plan.limit);
962
+ }
963
+ return result;
964
+ }
965
+ function candidateRecords(source, clauses) {
966
+ const indexes = source.getIndexes?.();
967
+ if (!indexes || !source.lookupById || clauses.length === 0) {
968
+ return { candidates: source.snapshot(), remainingClauses: clauses };
969
+ }
970
+ const lookupById = (id) => source.lookupById?.(id);
971
+ for (let i = 0; i < clauses.length; i++) {
972
+ const clause = clauses[i];
973
+ if (clause.type !== "field") continue;
974
+ if (!indexes.has(clause.field)) continue;
975
+ if (clause.via && clause.via.indexValue === void 0) continue;
976
+ const probeValue = clause.via ? clause.via.indexValue : clause.value;
977
+ let ids = null;
978
+ if (clause.op === "==") {
979
+ ids = indexes.lookupEqual(clause.field, probeValue);
980
+ } else if (clause.op === "in" && Array.isArray(probeValue)) {
981
+ ids = indexes.lookupIn(clause.field, probeValue);
982
+ }
983
+ if (ids !== null) {
984
+ const remaining = [];
985
+ for (let j = 0; j < clauses.length; j++) {
986
+ if (j !== i) remaining.push(clauses[j]);
987
+ }
988
+ return {
989
+ candidates: materializeIds(ids, lookupById),
990
+ remainingClauses: remaining
991
+ };
992
+ }
993
+ }
994
+ return { candidates: source.snapshot(), remainingClauses: clauses };
995
+ }
996
+ function materializeIds(ids, lookupById) {
997
+ const out = [];
998
+ for (const id of ids) {
999
+ const record = lookupById(id);
1000
+ if (record !== void 0) out.push(record);
1001
+ }
1002
+ return out;
1003
+ }
1004
+ function executePlan(records, plan) {
1005
+ if (plan.clauses.some((c) => c.type === "crossJoin")) {
1006
+ throw new Error(
1007
+ `executePlan(): does not support crossJoin clauses. executePlan is a stateless pure function \u2014 it cannot resolve cross-join right-side collections. Use Query.toArray() (via collection.query()) instead.`
1008
+ );
1009
+ }
1010
+ let result = filterRecords(records, plan.clauses);
1011
+ if (plan.orderBy.length > 0) {
1012
+ result = sortRecords(result, plan.orderBy);
1013
+ }
1014
+ if (plan.offset > 0) {
1015
+ result = result.slice(plan.offset);
1016
+ }
1017
+ if (plan.limit !== void 0) {
1018
+ result = result.slice(0, plan.limit);
1019
+ }
1020
+ return result;
1021
+ }
1022
+ function fnViewDecoder(source) {
1023
+ const via = source.via;
1024
+ if (!via || !via.hasResultDecode) return void 0;
1025
+ return (r) => via.decodeResults(r);
1026
+ }
1027
+ function filterRecords(records, clauses, decodeForFns) {
1028
+ if (clauses.length === 0) return [...records];
1029
+ const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
1030
+ const out = [];
1031
+ for (const r of records) {
1032
+ const fnView = needsFnView ? decodeForFns(r) : void 0;
1033
+ let matches = true;
1034
+ for (const clause of clauses) {
1035
+ if (!evaluateClause(r, clause, fnView)) {
1036
+ matches = false;
1037
+ break;
1038
+ }
1039
+ }
1040
+ if (matches) out.push(r);
1041
+ }
1042
+ return out;
1043
+ }
1044
+ function executeClausePipeline(source, clauses, joinContext) {
1045
+ let rel = [...source.snapshot()];
1046
+ let filterBatch = [];
1047
+ const decodeForFns = fnViewDecoder(source);
1048
+ for (const clause of clauses) {
1049
+ if (clause.type === "crossJoin") {
1050
+ if (filterBatch.length > 0) {
1051
+ rel = filterRecords(rel, filterBatch, decodeForFns);
1052
+ filterBatch = [];
1053
+ }
1054
+ const rightSource = joinContext.resolveSource(clause.target);
1055
+ if (!rightSource) {
1056
+ throw new CrossJoinSourceUnknownError(clause.target, joinContext.leftCollection);
1057
+ }
1058
+ rel = applyCrossJoin(rel, clause, rightSource);
1059
+ } else {
1060
+ filterBatch.push(clause);
1061
+ }
1062
+ }
1063
+ if (filterBatch.length > 0) {
1064
+ rel = filterRecords(rel, filterBatch, decodeForFns);
1065
+ }
1066
+ return rel;
1067
+ }
1068
+ function applyCrossJoin(leftRel, clause, rightSource) {
1069
+ const rightRows = rightSource.snapshot();
1070
+ const maxRows = clause.maxRows ?? DEFAULT_CROSS_JOIN_MAX_ROWS;
1071
+ const { as } = clause;
1072
+ if (!clause.on) {
1073
+ const product = leftRel.length * rightRows.length;
1074
+ if (product > maxRows) {
1075
+ throw new CrossJoinTooLargeError({ target: clause.target, expected: product, limit: maxRows });
1076
+ }
1077
+ const expanded2 = [];
1078
+ for (const left of leftRel) {
1079
+ const leftObj = left;
1080
+ for (const right of rightRows) {
1081
+ expanded2.push({ ...leftObj, [as]: right });
1082
+ }
1083
+ }
1084
+ return expanded2;
1085
+ }
1086
+ const expanded = [];
1087
+ let cumulative = 0;
1088
+ for (const left of leftRel) {
1089
+ const callbackResult = clause.on(left);
1090
+ let filteredRight;
1091
+ if (Array.isArray(callbackResult)) {
1092
+ filteredRight = callbackResult;
1093
+ } else {
1094
+ filteredRight = rightRows.filter(
1095
+ callbackResult
1096
+ );
1097
+ }
1098
+ cumulative += filteredRight.length;
1099
+ if (cumulative > maxRows) {
1100
+ throw new CrossJoinTooLargeError({
1101
+ target: clause.target,
1102
+ expected: cumulative,
1103
+ limit: maxRows
1104
+ });
1105
+ }
1106
+ const leftObj = left;
1107
+ for (const right of filteredRight) {
1108
+ expanded.push({ ...leftObj, [as]: right });
1109
+ }
1110
+ }
1111
+ return expanded;
1112
+ }
1113
+ function sortRecords(records, orderBy, via, labelMaps) {
1114
+ return [...records].sort((a, b) => {
1115
+ for (const { field, direction, by } of orderBy) {
1116
+ let av = readField(a, field);
1117
+ let bv = readField(b, field);
1118
+ const labelResolver = by === "label" ? labelMaps?.get(field) : void 0;
1119
+ if (labelResolver) {
1120
+ av = (typeof av === "string" ? labelResolver(av) : void 0) ?? av;
1121
+ bv = (typeof bv === "string" ? labelResolver(bv) : void 0) ?? bv;
1122
+ const cmp2 = compareValues(av, bv);
1123
+ if (cmp2 !== 0) return direction === "asc" ? cmp2 : -cmp2;
1124
+ continue;
1125
+ }
1126
+ const viaCmp = via?.compareForOrder(field, av, bv);
1127
+ const cmp = viaCmp !== void 0 ? viaCmp : compareValues(av, bv);
1128
+ if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
1129
+ }
1130
+ return 0;
1131
+ });
1132
+ }
1133
+ function buildOrderLabelMaps(orderBy, joinContext, locale, via) {
1134
+ let maps;
1135
+ for (const { field, by } of orderBy) {
1136
+ if (by !== "label") continue;
1137
+ const dictSource = joinContext?.resolveDictSource?.(field);
1138
+ if (dictSource) {
1139
+ const loc = locale ?? dictSource.displayLocale;
1140
+ if (loc === void 0) continue;
1141
+ const codeToLabel = /* @__PURE__ */ new Map();
1142
+ for (const entry of dictSource.snapshot()) {
1143
+ const k = entry["key"];
1144
+ const labels = entry["labels"];
1145
+ const label = labels?.[loc];
1146
+ if (typeof k === "string" && typeof label === "string") codeToLabel.set(k, label);
1147
+ }
1148
+ ;
1149
+ (maps ??= /* @__PURE__ */ new Map()).set(field, (code) => codeToLabel.get(code));
1150
+ continue;
1151
+ }
1152
+ if (via) {
1153
+ const cache = /* @__PURE__ */ new Map();
1154
+ (maps ??= /* @__PURE__ */ new Map()).set(field, (code) => {
1155
+ if (!cache.has(code)) cache.set(code, via.resolveOrderLabel(field, code, locale));
1156
+ return cache.get(code);
1157
+ });
1158
+ }
1159
+ }
1160
+ return maps;
1161
+ }
1162
+ function readField(record, field) {
1163
+ if (record === null || record === void 0) return void 0;
1164
+ if (!field.includes(".")) {
1165
+ return record[field];
1166
+ }
1167
+ const segments = field.split(".");
1168
+ let cursor = record;
1169
+ for (const segment of segments) {
1170
+ if (cursor === null || cursor === void 0) return void 0;
1171
+ cursor = cursor[segment];
1172
+ }
1173
+ return cursor;
1174
+ }
1175
+ function compareValues(a, b) {
1176
+ if (a === void 0 || a === null) return b === void 0 || b === null ? 0 : 1;
1177
+ if (b === void 0 || b === null) return -1;
1178
+ if (typeof a === "number" && typeof b === "number") return a - b;
1179
+ if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
1180
+ if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
1181
+ return 0;
1182
+ }
1183
+ function serializePlan(plan) {
1184
+ return {
1185
+ clauses: plan.clauses.map(serializeClause),
1186
+ orderBy: plan.orderBy,
1187
+ limit: plan.limit,
1188
+ offset: plan.offset,
1189
+ joins: plan.joins
1190
+ };
1191
+ }
1192
+ function serializeClause(clause) {
1193
+ if (clause.type === "filter") {
1194
+ return { type: "filter", fn: "[function]" };
1195
+ }
1196
+ if (clause.type === "wherePredicate") {
1197
+ return {
1198
+ type: "wherePredicate",
1199
+ name: clause.name,
1200
+ ctx: clause.ctx,
1201
+ predicateHash: clause.predicateHash,
1202
+ ctxHash: clause.ctxHash,
1203
+ fn: "[function]"
1204
+ };
1205
+ }
1206
+ if (clause.type === "group") {
1207
+ return {
1208
+ type: "group",
1209
+ op: clause.op,
1210
+ clauses: clause.clauses.map(serializeClause)
1211
+ };
1212
+ }
1213
+ if (clause.type === "crossJoin") {
1214
+ return {
1215
+ type: "crossJoin",
1216
+ target: clause.target,
1217
+ as: clause.as,
1218
+ on: clause.on ? "[function]" : void 0,
1219
+ onPredicateName: clause.onPredicateName,
1220
+ maxRows: clause.maxRows
1221
+ };
1222
+ }
1223
+ return clause;
1224
+ }
1225
+ function canonicalCtxHash(ctx) {
1226
+ if (ctx === void 0) return "";
1227
+ const canonical = JSON.stringify(ctx, (_key, value) => {
1228
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1229
+ const sorted = {};
1230
+ for (const k of Object.keys(value).sort()) {
1231
+ sorted[k] = value[k];
1232
+ }
1233
+ return sorted;
1234
+ }
1235
+ return value;
1236
+ });
1237
+ let h = 5381;
1238
+ for (let i = 0; i < canonical.length; i++) {
1239
+ h = (h << 5) + h ^ canonical.charCodeAt(i);
1240
+ }
1241
+ return (h >>> 0).toString(16).padStart(8, "0");
1242
+ }
1243
+ function buildDictLabelResolver(joinCtx, field) {
1244
+ if (!joinCtx?.resolveDictSource) return void 0;
1245
+ const dictSource = joinCtx.resolveDictSource(field);
1246
+ if (!dictSource) return void 0;
1247
+ const snapshot = dictSource.snapshot();
1248
+ const displayLocale = dictSource.displayLocale;
1249
+ const dictMap = /* @__PURE__ */ new Map();
1250
+ for (const entry of snapshot) {
1251
+ const k = entry["key"];
1252
+ const labels = entry["labels"];
1253
+ if (typeof k === "string" && labels && typeof labels === "object") {
1254
+ dictMap.set(k, labels);
1255
+ }
1256
+ }
1257
+ return async (key, locale, fallback) => {
1258
+ const effLocale = locale || displayLocale;
1259
+ if (!effLocale) return void 0;
1260
+ const labels = dictMap.get(key);
1261
+ if (!labels) return void 0;
1262
+ if (labels[effLocale] !== void 0) return labels[effLocale];
1263
+ const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
1264
+ for (const fb of chain) {
1265
+ if (fb === "any") {
1266
+ const any = Object.values(labels)[0];
1267
+ if (any !== void 0) return any;
1268
+ } else if (labels[fb] !== void 0) {
1269
+ return labels[fb];
1270
+ }
1271
+ }
1272
+ return void 0;
1273
+ };
1274
+ }
1275
+
1276
+ // src/kernel/query/scan-builder.ts
1277
+ var DEFAULT_SCAN_PAGE_SIZE = 100;
1278
+ var ScanBuilder = class _ScanBuilder {
1279
+ pageProvider;
1280
+ pageSize;
1281
+ clauses;
1282
+ /**
1283
+ * Zero-or-more join legs to apply per record as the stream flows.
1284
+ * Each leg attaches the resolved right-side record (or null) under
1285
+ * its alias. — streaming joins.
1286
+ *
1287
+ * Joins are evaluated AFTER clauses, so a `where()` filtered-out
1288
+ * record never triggers a right-side lookup. This is the same
1289
+ * ordering as `Query.toArray()` (clauses first, joins after) and
1290
+ * keeps the streaming path from doing wasted work.
1291
+ */
1292
+ joins;
1293
+ /**
1294
+ * Join resolution context. Required for `.join()` to translate a
1295
+ * field name into a target collection + ref mode and to resolve
1296
+ * the right-side `JoinableSource`. Optional because tests
1297
+ * construct ScanBuilder directly with synthetic page providers
1298
+ * that don't know about ref() — calling `.join()` without a
1299
+ * context throws with an actionable error.
1300
+ */
1301
+ joinContext;
1302
+ /**
1303
+ * The backing collection's compiled Via pipeline (money now; more Via
1304
+ * features later). When it declares a result decode, yielded records
1305
+ * are decoded (e.g. money: stored scaled-int → canonical decimal) so
1306
+ * `scan()` agrees with `get()`/`list()`/`query().toArray()`. Decoded
1307
+ * with `'raw'` (canonical decimal, no locale-formatted virtuals) since
1308
+ * the scan stream carries no locale context, mirroring `Query.toArray()`.
1309
+ */
1310
+ via;
1311
+ constructor(pageProvider, pageSize = DEFAULT_SCAN_PAGE_SIZE, clauses = [], joins = [], joinContext, via) {
1312
+ this.pageProvider = pageProvider;
1313
+ this.pageSize = pageSize;
1314
+ this.clauses = clauses;
1315
+ this.joins = joins;
1316
+ this.joinContext = joinContext;
1317
+ this.via = via;
1318
+ }
1319
+ /**
1320
+ * Decode this scan's Via-covered fields on a record (e.g. money: stored
1321
+ * scaled-int → canonical decimal). No-op when the Via pipeline declares
1322
+ * no result decode. See {@link via}.
1323
+ */
1324
+ decodeVia(record) {
1325
+ if (!this.via || !this.via.hasResultDecode) return record;
1326
+ return this.via.decodeResults(record);
1327
+ }
1328
+ /**
1329
+ * Add a field comparison. Runs per record as the scan stream
1330
+ * flows through, so non-matching records are dropped before they
1331
+ * reach `.aggregate()` or the iteration consumer. Multiple
1332
+ * `.where()` calls are AND-combined — same semantics as
1333
+ * `Query.where()`.
1334
+ *
1335
+ * Clauses cannot use the secondary-index fast path here because
1336
+ * the scan sources records from the adapter's paginator, not from
1337
+ * the in-memory cache where indexes live. Index-accelerated scans
1338
+ * are a future optimization — the current implementation
1339
+ * evaluates clauses per record in O(1) per clause.
1340
+ *
1341
+ * Consults the Via pipeline's posture before building a clause (#629
1342
+ * Task 8): a field whose posture is `queryable: 'none'` throws
1343
+ * `FieldNotQueryableError` here, at the call site — same gate as
1344
+ * `Query.where()`.
1345
+ */
1346
+ where(field, op, value) {
1347
+ const via = this.via;
1348
+ if (via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
1349
+ const viaClause = via?.buildClause(field, op, value);
1350
+ const clause = viaClause ? {
1351
+ type: "field",
1352
+ field,
1353
+ op,
1354
+ value,
1355
+ via: {
1356
+ brand: viaClause.brand,
1357
+ payload: viaClause.payload,
1358
+ evaluate: (actual, evalOp) => via.evaluateClause(viaClause, actual, evalOp)
1359
+ }
1360
+ } : { type: "field", field, op, value };
1361
+ return new _ScanBuilder(
1362
+ this.pageProvider,
1363
+ this.pageSize,
1364
+ [...this.clauses, clause],
1365
+ this.joins,
1366
+ this.joinContext,
1367
+ this.via
1368
+ );
1369
+ }
1370
+ /**
1371
+ * Escape hatch: add an arbitrary predicate function. Same
1372
+ * non-serializable caveat as `Query.filter()` — filter clauses
1373
+ * don't round-trip through `toPlan()`. Prefer `.where()` when
1374
+ * possible.
1375
+ */
1376
+ filter(fn) {
1377
+ const clause = {
1378
+ type: "filter",
1379
+ fn
1380
+ };
1381
+ return new _ScanBuilder(
1382
+ this.pageProvider,
1383
+ this.pageSize,
1384
+ [...this.clauses, clause],
1385
+ this.joins,
1386
+ this.joinContext,
1387
+ this.via
1388
+ );
1389
+ }
1390
+ /**
1391
+ * Resolve a `ref()`-declared foreign key per record as the scan
1392
+ * stream flows, attaching the right-side record (or null) under
1393
+ * `opts.as`. — streaming joins over `scan()`.
1394
+ *
1395
+ * ```ts
1396
+ * for await (const inv of invoices.scan().join('clientId', { as: 'client' })) {
1397
+ * await processInvoice(inv) // inv.client is attached
1398
+ * }
1399
+ *
1400
+ * // Or terminate with .aggregate() for streaming joined aggregation
1401
+ * const { total } = await invoices.scan()
1402
+ * .where('status', '==', 'open')
1403
+ * .join('clientId', { as: 'client' })
1404
+ * .aggregate({ total: sum('amount') })
1405
+ * ```
1406
+ *
1407
+ * **The key difference from eager `.join()`:** the LEFT
1408
+ * side streams page-by-page from the adapter and is never
1409
+ * materialized. Memory ceiling on the left is O(pageSize), not
1410
+ * O(rowCount). This is what makes streaming joins suitable for
1411
+ * collections that exceed the eager join's 50_000-row ceiling.
1412
+ *
1413
+ * **Right-side strategy** is auto-selected per leg:
1414
+ * - **Indexed** — right source exposes `lookupById`, so each
1415
+ * left row costs O(1). This is the common path for
1416
+ * Collection right sides, which back `lookupById` with a Map
1417
+ * lookup over the in-memory cache. The right collection must
1418
+ * be in eager mode (the same constraint as eager join's
1419
+ * `querySourceForJoin` from ).
1420
+ * - **Hash** — right source has only `snapshot()`. Build a
1421
+ * `Map<id, record>` once at iteration start, probe per left
1422
+ * row. Same correctness, same per-row cost as the indexed
1423
+ * path; the difference is the upfront cost of materializing
1424
+ * the right side once.
1425
+ *
1426
+ * Both strategies hold the right side in memory for the duration
1427
+ * of the iteration. The "streaming" property applies to the LEFT
1428
+ * side only — true left-and-right streaming joins (where neither
1429
+ * side fits in memory) require a sort-merge join planner that's
1430
+ * out of scope for.
1431
+ *
1432
+ * **Ref-mode semantics** match eager `.join()` exactly:
1433
+ * - `strict` → throws `DanglingReferenceError` mid-stream
1434
+ * when a left record points at a non-existent right id.
1435
+ * The throw aborts the async iterator — consumers should
1436
+ * wrap the `for await` in try/catch if they want to recover.
1437
+ * - `warn` → attaches `null` and emits a one-shot warning
1438
+ * per unique dangling pair (deduped via the same warn
1439
+ * channel as eager join).
1440
+ * - `cascade` → attaches `null` silently. A delete-time mode;
1441
+ * dangling refs at read time are mid-flight or pre-existing
1442
+ * orphans, not a DSL error.
1443
+ *
1444
+ * Left records with null/undefined FK values attach `null`
1445
+ * regardless of mode — same "no reference at all" policy as
1446
+ * eager join and write-time `enforceRefsOnPut`.
1447
+ *
1448
+ * **Multi-FK chaining** is supported via repeated `.join()`
1449
+ * calls: each leg resolves an independent ref. Each leg
1450
+ * independently picks its right-side strategy and applies its
1451
+ * own ref mode.
1452
+ *
1453
+ * **Joins are NOT applied** to a `.aggregate()` terminal that
1454
+ * doesn't reference joined fields — wait, that's not quite
1455
+ * right. The streaming path actually DOES apply joins before
1456
+ * `.aggregate()` because the join attaches a field that the
1457
+ * spec might reference. Unlike `Query.aggregate()` (which skips
1458
+ * joins entirely as a projection-only short-circuit), the
1459
+ * streaming aggregation can't know whether the spec touches a
1460
+ * joined field, so it always applies joins. Consumers who want
1461
+ * unjoined streaming aggregation should leave `.join()` off the
1462
+ * chain — the chain is composable for a reason.
1463
+ *
1464
+ * constraint #1 — every JoinLeg carries `partitionScope:
1465
+ * 'all'` plumbed through but never read by. Same seam as
1466
+ * eager join.
1467
+ */
1468
+ join(field, opts) {
1469
+ if (!this.joinContext) {
1470
+ throw new Error(
1471
+ `ScanBuilder.join() requires a join context. Use collection.scan() to construct a join-capable scan instead of the ScanBuilder constructor directly (the direct constructor is only used for tests with synthetic page providers).`
1472
+ );
1473
+ }
1474
+ const descriptor = this.joinContext.resolveRef(field);
1475
+ if (!descriptor) {
1476
+ throw new Error(
1477
+ `ScanBuilder.join(): no ref() declared for field "${field}" on collection "${this.joinContext.leftCollection}". Add refs: { ${field}: ref('<target-collection>') } to the collection options, then retry.`
1478
+ );
1479
+ }
1480
+ const leg = {
1481
+ field,
1482
+ as: opts.as,
1483
+ target: descriptor.target,
1484
+ mode: descriptor.mode,
1485
+ strategy: void 0,
1486
+ maxRows: void 0,
1487
+ // constraint #1 — always 'all' in, never read by
1488
+ // the streaming executor. partition-aware scan joins
1489
+ // will populate this from where() predicates without
1490
+ // changing the planner shape.
1491
+ partitionScope: "all"
1492
+ };
1493
+ return new _ScanBuilder(
1494
+ this.pageProvider,
1495
+ this.pageSize,
1496
+ this.clauses,
1497
+ [...this.joins, leg],
1498
+ this.joinContext,
1499
+ this.via
1500
+ );
1501
+ }
1502
+ /**
1503
+ * Iterate the scan as an async iterable. Walks the page
1504
+ * provider's cursors forward until exhaustion, applying every
1505
+ * clause per record — only matching records are yielded.
1506
+ *
1507
+ * Backward-compatible with the previous async-generator `scan()`
1508
+ * return type for `for await … of` consumers.
1509
+ */
1510
+ async *[Symbol.asyncIterator]() {
1511
+ const joinResolvers = this.joins.length === 0 ? null : this.buildJoinResolvers();
1512
+ let page = await this.pageProvider.listPage({ limit: this.pageSize });
1513
+ while (true) {
1514
+ for (const record of page.items) {
1515
+ if (!this.recordMatches(record)) continue;
1516
+ const decoded = this.decodeVia(record);
1517
+ if (joinResolvers === null) {
1518
+ yield decoded;
1519
+ } else {
1520
+ let attached = decoded;
1521
+ for (const resolver of joinResolvers) {
1522
+ attached = this.applyOneJoinStreaming(attached, resolver);
1523
+ }
1524
+ yield attached;
1525
+ }
1526
+ }
1527
+ if (page.nextCursor === null) return;
1528
+ page = await this.pageProvider.listPage({
1529
+ cursor: page.nextCursor,
1530
+ limit: this.pageSize
1531
+ });
1532
+ }
1533
+ }
1534
+ /**
1535
+ * Per-leg right-side resolution state. Built once at iteration
1536
+ * start and reused for every left record. Two strategies:
1537
+ *
1538
+ * - `lookupById`: present when the right source exposes the
1539
+ * hook directly (typical Collection right side). Per-row
1540
+ * cost is O(1).
1541
+ * - `hashByPrimaryKey`: built from `snapshot()` when no
1542
+ * lookupById. Per-row cost is O(1) after the upfront O(N)
1543
+ * materialization. Same as eager join's hash strategy.
1544
+ *
1545
+ * `warnedKeys` is the per-leg dedup set for ref-mode 'warn'. We
1546
+ * key on `field→target:refId` so the same dangling pair only
1547
+ * warns once per iteration. The dedup is per-iteration, not
1548
+ * per-process — a long-running scan that re-iterates would warn
1549
+ * again, which is the desired behavior (the data may have
1550
+ * changed between iterations).
1551
+ */
1552
+ buildJoinResolvers() {
1553
+ if (!this.joinContext) {
1554
+ throw new Error(
1555
+ `ScanBuilder iterator: ${this.joins.length} join leg(s) present but no JoinContext attached. Use collection.scan() to construct a join-capable scan.`
1556
+ );
1557
+ }
1558
+ const resolvers = [];
1559
+ for (const leg of this.joins) {
1560
+ const source = this.joinContext.resolveSource(leg.target);
1561
+ if (!source) {
1562
+ throw new Error(
1563
+ `ScanBuilder.join() cannot resolve target collection "${leg.target}" (referenced from field "${leg.field}" on "${this.joinContext.leftCollection}"). Make sure the target collection has been opened via vault.collection() at least once before iterating the scan.`
1564
+ );
1565
+ }
1566
+ let lookupById = null;
1567
+ let hashByPrimaryKey = null;
1568
+ if (source.lookupById) {
1569
+ const fn = source.lookupById.bind(source);
1570
+ lookupById = (id) => fn(id);
1571
+ } else {
1572
+ const map = /* @__PURE__ */ new Map();
1573
+ for (const record of source.snapshot()) {
1574
+ const rawId = readPath(record, "id");
1575
+ const key = coerceRefKey2(rawId);
1576
+ if (key !== null) map.set(key, record);
1577
+ }
1578
+ hashByPrimaryKey = map;
1579
+ }
1580
+ resolvers.push({
1581
+ leg,
1582
+ source,
1583
+ lookupById,
1584
+ hashByPrimaryKey,
1585
+ warnedKeys: /* @__PURE__ */ new Set()
1586
+ });
1587
+ }
1588
+ return resolvers;
1589
+ }
1590
+ /**
1591
+ * Resolve a single join leg for one left record and return the
1592
+ * left record with the joined field attached under
1593
+ * `leg.as`. Pure function over `(left, resolver)`; never
1594
+ * mutates the input.
1595
+ *
1596
+ * Ref-mode dispatch matches eager `applyJoins` from :
1597
+ * - null/undefined FK → attach null silently (always allowed)
1598
+ * - dangling FK + strict → throw `DanglingReferenceError`
1599
+ * - dangling FK + warn → attach null, warn-once per pair
1600
+ * - dangling FK + cascade → attach null silently
1601
+ */
1602
+ applyOneJoinStreaming(left, resolver) {
1603
+ if (left === null || typeof left !== "object") {
1604
+ return left;
1605
+ }
1606
+ const { leg } = resolver;
1607
+ const rawId = readPath(left, leg.field);
1608
+ const refKey = coerceRefKey2(rawId);
1609
+ let right = void 0;
1610
+ if (refKey !== null) {
1611
+ if (resolver.lookupById !== null) {
1612
+ right = resolver.lookupById(refKey);
1613
+ } else if (resolver.hashByPrimaryKey !== null) {
1614
+ right = resolver.hashByPrimaryKey.get(refKey);
1615
+ }
1616
+ }
1617
+ const merged = {
1618
+ ...left
1619
+ };
1620
+ if (right === void 0) {
1621
+ if (refKey !== null && leg.mode === "strict") {
1622
+ throw new DanglingReferenceError({
1623
+ field: leg.field,
1624
+ target: leg.target,
1625
+ refId: refKey,
1626
+ message: `ScanBuilder.join() strict dangling: record references "${leg.target}:${refKey}" via field "${leg.field}", but no such record exists. Use ref() mode 'warn' or 'cascade' if dangling refs are acceptable, or run vault.checkIntegrity() to find and fix the orphans.`
1627
+ });
1628
+ }
1629
+ if (refKey !== null && leg.mode === "warn") {
1630
+ const dedupKey = `${leg.field}\u2192${leg.target}:${refKey}`;
1631
+ if (!resolver.warnedKeys.has(dedupKey)) {
1632
+ resolver.warnedKeys.add(dedupKey);
1633
+ console.warn(
1634
+ `[noy-db] ScanBuilder.join() encountered dangling ref in 'warn' mode: field "${leg.field}" \u2192 "${leg.target}:${refKey}" not found. Attaching null.`
1635
+ );
1636
+ }
1637
+ }
1638
+ merged[leg.as] = null;
1639
+ } else {
1640
+ merged[leg.as] = right;
1641
+ }
1642
+ return merged;
1643
+ }
1644
+ async aggregate(specOrBuild) {
1645
+ const spec = typeof specOrBuild === "function" ? specOrBuild(reducerBuilder) : specOrBuild;
1646
+ this.via?.refuseUnqueryableReducers(spec);
1647
+ const keys = Object.keys(spec);
1648
+ const state = {};
1649
+ for (const key of keys) {
1650
+ state[key] = spec[key].init();
1651
+ }
1652
+ for await (const record of this) {
1653
+ for (const key of keys) {
1654
+ state[key] = spec[key].step(state[key], record);
1655
+ }
1656
+ }
1657
+ const result = {};
1658
+ for (const key of keys) {
1659
+ result[key] = spec[key].finalize(state[key]);
1660
+ }
1661
+ return result;
1662
+ }
1663
+ /**
1664
+ * Evaluate the clause list against a single record. Linear in
1665
+ * the clause count; short-circuits on first false. Clauses on a
1666
+ * scan are always re-evaluated per record — no index-accelerated
1667
+ * path, because the stream sources records from the adapter
1668
+ * paginator, not from the in-memory cache where indexes live.
1669
+ */
1670
+ recordMatches(record) {
1671
+ if (this.clauses.length === 0) return true;
1672
+ const fnView = this.via?.hasResultDecode && hasFnClause(this.clauses) ? this.decodeVia(record) : void 0;
1673
+ for (const clause of this.clauses) {
1674
+ if (!evaluateClause(record, clause, fnView)) return false;
1675
+ }
1676
+ return true;
1677
+ }
1678
+ };
1679
+ function coerceRefKey2(value) {
1680
+ if (value === null || value === void 0) return null;
1681
+ if (typeof value === "string") return value;
1682
+ if (typeof value === "number" || typeof value === "bigint") return String(value);
1683
+ return null;
1684
+ }
1685
+
1686
+ export {
1687
+ DEFAULT_JOIN_MAX_ROWS,
1688
+ applyJoins,
1689
+ resetJoinWarnings,
1690
+ buildLiveQuery,
1691
+ NO_AGGREGATE,
1692
+ DEFAULT_CROSS_JOIN_MAX_ROWS,
1693
+ Query,
1694
+ executePlan,
1695
+ ScanBuilder
1696
+ };
1697
+ //# sourceMappingURL=chunk-454JXE57.js.map