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

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