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