@noy-db/hub 0.2.0-pre.11 → 0.2.0-pre.12

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 (265) hide show
  1. package/README.md +126 -0
  2. package/dist/aggregate/index.cjs +289 -12
  3. package/dist/aggregate/index.cjs.map +1 -1
  4. package/dist/aggregate/index.d.cts +2 -2
  5. package/dist/aggregate/index.d.ts +2 -2
  6. package/dist/aggregate/index.js +7 -7
  7. package/dist/aggregate/index.js.map +1 -1
  8. package/dist/attestation/index.cjs.map +1 -1
  9. package/dist/attestation/index.d.cts +3 -3
  10. package/dist/attestation/index.d.ts +3 -3
  11. package/dist/attestation/index.js +6 -6
  12. package/dist/blobs/index.cjs +28 -0
  13. package/dist/blobs/index.cjs.map +1 -1
  14. package/dist/blobs/index.d.cts +4 -4
  15. package/dist/blobs/index.d.ts +4 -4
  16. package/dist/blobs/index.js +5 -5
  17. package/dist/bundle/index.cjs +1452 -16
  18. package/dist/bundle/index.cjs.map +1 -1
  19. package/dist/bundle/index.d.cts +5 -5
  20. package/dist/bundle/index.d.ts +5 -5
  21. package/dist/bundle/index.js +9 -9
  22. package/dist/{chunk-7CEGU63S.js → chunk-4BHFNKTP.js} +2 -2
  23. package/dist/{chunk-5OEJ6GOT.js → chunk-5ARRXIVR.js} +2 -2
  24. package/dist/{chunk-77DWLQRY.js → chunk-6AD5TBF2.js} +31 -3
  25. package/dist/chunk-6AD5TBF2.js.map +1 -0
  26. package/dist/{chunk-YM7LFCG7.js → chunk-6BYBVRZU.js} +3 -3
  27. package/dist/{chunk-73YLDCNF.js → chunk-7JJE3OMJ.js} +5 -5
  28. package/dist/{chunk-GKI4SDP7.js → chunk-7LVRIW4G.js} +4 -4
  29. package/dist/{chunk-O6EJ6WTI.js → chunk-AGRC7NQQ.js} +62 -2
  30. package/dist/chunk-AGRC7NQQ.js.map +1 -0
  31. package/dist/{chunk-IMYKDWB4.js → chunk-B7GGYNKQ.js} +2 -2
  32. package/dist/{chunk-BDV7INMP.js → chunk-BXOUVUES.js} +4 -4
  33. package/dist/{chunk-FO3UEG4S.js → chunk-C2CIIQRG.js} +2 -2
  34. package/dist/{chunk-ZROPXHJY.js → chunk-CHBXWJZQ.js} +2 -2
  35. package/dist/{chunk-RYIL3PI2.js → chunk-CILT6V3V.js} +2 -2
  36. package/dist/{chunk-YVZRTCGG.js → chunk-DLTU4M2I.js} +6 -6
  37. package/dist/{chunk-GAUEWM7D.js → chunk-EKNUBIIQ.js} +4 -4
  38. package/dist/{chunk-QCXNMCHN.js → chunk-GFPR7VJS.js} +4 -4
  39. package/dist/{chunk-V2PZC6AW.js → chunk-HBAJDI2N.js} +5 -5
  40. package/dist/{chunk-PVUUIWHY.js → chunk-HLGDYFWR.js} +10 -3
  41. package/dist/chunk-HLGDYFWR.js.map +1 -0
  42. package/dist/{chunk-RRNA5GKT.js → chunk-IEPT7HVP.js} +2 -2
  43. package/dist/{chunk-R233SLY3.js → chunk-IUBHXEPJ.js} +2 -2
  44. package/dist/{chunk-CH22FZHT.js → chunk-L6BYRCYB.js} +2 -2
  45. package/dist/{chunk-PC3ZZBTO.js → chunk-LOA2VCMS.js} +5 -5
  46. package/dist/{chunk-TGALXXLV.js → chunk-LSEW3ZZ2.js} +3 -3
  47. package/dist/{chunk-Y26YV5R3.js → chunk-LWSD4QPT.js} +3 -3
  48. package/dist/{chunk-SLV4LAKX.js → chunk-LYNNZEQD.js} +1 -1
  49. package/dist/chunk-LYNNZEQD.js.map +1 -0
  50. package/dist/{chunk-26NK23DZ.js → chunk-M45IRXDM.js} +3 -3
  51. package/dist/{chunk-CXJG63MA.js → chunk-NP6EZT44.js} +20 -6
  52. package/dist/chunk-NP6EZT44.js.map +1 -0
  53. package/dist/{chunk-ZBBW7YQN.js → chunk-O53RIZCC.js} +5 -5
  54. package/dist/chunk-OPDTLHFA.js +783 -0
  55. package/dist/chunk-OPDTLHFA.js.map +1 -0
  56. package/dist/{chunk-LSTBFLL2.js → chunk-P3Z5Y2TS.js} +2 -2
  57. package/dist/{chunk-QSOYKKMD.js → chunk-P4EDT5ZP.js} +2 -2
  58. package/dist/{chunk-PC6ZEDRL.js → chunk-RHQYVHFH.js} +2 -2
  59. package/dist/{chunk-3DGHRDCX.js → chunk-RRDWXNBQ.js} +3 -3
  60. package/dist/{chunk-6MFH4BMK.js → chunk-SJJQKNMP.js} +4 -4
  61. package/dist/{chunk-EBVBE7UK.js → chunk-SZ4N3IL5.js} +5 -5
  62. package/dist/{chunk-MPOLUAMI.js → chunk-TMHJEYW7.js} +497 -57
  63. package/dist/chunk-TMHJEYW7.js.map +1 -0
  64. package/dist/{chunk-JQ4NEJJ6.js → chunk-UA6G45ME.js} +3 -3
  65. package/dist/{chunk-6YLPHBKR.js → chunk-UOC7JMZO.js} +13 -4
  66. package/dist/chunk-UOC7JMZO.js.map +1 -0
  67. package/dist/{chunk-DAP2XL7Q.js → chunk-VOXMU6LB.js} +2 -2
  68. package/dist/chunk-WNRGOVLG.js +64 -0
  69. package/dist/chunk-WNRGOVLG.js.map +1 -0
  70. package/dist/{chunk-YW5DBAPG.js → chunk-WUG3E423.js} +4 -4
  71. package/dist/{chunk-LJXYPGRH.js → chunk-XHM2SARW.js} +3 -3
  72. package/dist/{chunk-RC6SU5NO.js → chunk-XSIFXX54.js} +2 -2
  73. package/dist/{chunk-CXFOITNS.js → chunk-ZC7MNVYN.js} +2 -2
  74. package/dist/{chunk-6T2UDBKG.js → chunk-ZCFS7U4J.js} +2 -2
  75. package/dist/consent/index.cjs.map +1 -1
  76. package/dist/consent/index.d.cts +4 -4
  77. package/dist/consent/index.d.ts +4 -4
  78. package/dist/consent/index.js +3 -3
  79. package/dist/{crypto-2CRLG4F4.js → crypto-AJB72OKN.js} +3 -3
  80. package/dist/{delegation-ZTRT2PRV.js → delegation-6FCWDRUS.js} +5 -5
  81. package/dist/derivations/index.cjs.map +1 -1
  82. package/dist/derivations/index.d.cts +5 -5
  83. package/dist/derivations/index.d.ts +5 -5
  84. package/dist/derivations/index.js +4 -4
  85. package/dist/{dev-unlock-BH6y3Hx0.d.ts → dev-unlock-D3mpVFRc.d.ts} +1 -1
  86. package/dist/{dev-unlock-H1Xwxc3U.d.cts → dev-unlock-ckqa_Nso.d.cts} +1 -1
  87. package/dist/executor-7KSCEIFA.js +8 -0
  88. package/dist/executor-D2QMNGRJ.js +8 -0
  89. package/dist/executor-O5AZK7UW.js +11 -0
  90. package/dist/{fanout-sidecar-F3ZRFU4H.js → fanout-sidecar-ZSKEQ6NI.js} +2 -2
  91. package/dist/guards/index.cjs +53 -1
  92. package/dist/guards/index.cjs.map +1 -1
  93. package/dist/guards/index.d.cts +12 -6
  94. package/dist/guards/index.d.ts +12 -6
  95. package/dist/guards/index.js +5 -3
  96. package/dist/{hash-D89JdDbj.d.ts → hash-CTZVkXLx.d.ts} +1 -1
  97. package/dist/{hash-_sDFvtmX.d.cts → hash-rDSSd_oW.d.cts} +1 -1
  98. package/dist/history/index.cjs.map +1 -1
  99. package/dist/history/index.d.cts +5 -5
  100. package/dist/history/index.d.ts +5 -5
  101. package/dist/history/index.js +5 -5
  102. package/dist/i18n/index.cjs.map +1 -1
  103. package/dist/i18n/index.d.cts +4 -4
  104. package/dist/i18n/index.d.ts +4 -4
  105. package/dist/i18n/index.js +6 -6
  106. package/dist/immutable-guard-C51vAHuh.d.cts +67 -0
  107. package/dist/immutable-guard-DyD0qg2k.d.ts +67 -0
  108. package/dist/index-CkFHr4OP.d.ts +1190 -0
  109. package/dist/index-Cmop06zJ.d.cts +1190 -0
  110. package/dist/index.cjs +1620 -58
  111. package/dist/index.cjs.map +1 -1
  112. package/dist/index.d.cts +46 -13
  113. package/dist/index.d.ts +46 -13
  114. package/dist/index.js +76 -44
  115. package/dist/index.js.map +1 -1
  116. package/dist/indexing/index.cjs.map +1 -1
  117. package/dist/indexing/index.js +2 -2
  118. package/dist/issue-YIYG4OW5.js +12 -0
  119. package/dist/{ledger-NYCGJX2D.js → ledger-5JMVF7PY.js} +5 -5
  120. package/dist/materialized-views/index.cjs.map +1 -1
  121. package/dist/materialized-views/index.d.cts +5 -6
  122. package/dist/materialized-views/index.d.ts +5 -6
  123. package/dist/materialized-views/index.js +6 -6
  124. package/dist/noydb-D5SLAJ6V.js +34 -0
  125. package/dist/overlay-views/index.cjs.map +1 -1
  126. package/dist/overlay-views/index.d.cts +5 -5
  127. package/dist/overlay-views/index.d.ts +5 -5
  128. package/dist/overlay-views/index.js +4 -4
  129. package/dist/periods/index.cjs.map +1 -1
  130. package/dist/periods/index.d.cts +4 -4
  131. package/dist/periods/index.d.ts +4 -4
  132. package/dist/periods/index.js +5 -5
  133. package/dist/{public-envelope-QOXZEHKH.js → public-envelope-PFLZI5MO.js} +4 -4
  134. package/dist/query/index.cjs +293 -10
  135. package/dist/query/index.cjs.map +1 -1
  136. package/dist/query/index.d.cts +2 -2
  137. package/dist/query/index.d.ts +2 -2
  138. package/dist/query/index.js +4 -4
  139. package/dist/registry-BVQ5ITMF.js +8 -0
  140. package/dist/registry-JLP3QOLD.js +8 -0
  141. package/dist/{registry-ST2VNFZC.js → registry-NCY445U5.js} +3 -3
  142. package/dist/{revoke-RT7QYB4G.js → revoke-7RLGQWZ7.js} +6 -6
  143. package/dist/session/index.cjs.map +1 -1
  144. package/dist/session/index.d.cts +5 -5
  145. package/dist/session/index.d.ts +5 -5
  146. package/dist/session/index.js +3 -3
  147. package/dist/shadow/index.cjs.map +1 -1
  148. package/dist/shadow/index.d.cts +4 -4
  149. package/dist/shadow/index.d.ts +4 -4
  150. package/dist/shadow/index.js +2 -2
  151. package/dist/{signer-QNU66JF5.js → signer-6JF44I4A.js} +5 -5
  152. package/dist/snapshots/index.cjs.map +1 -1
  153. package/dist/snapshots/index.d.cts +4 -4
  154. package/dist/snapshots/index.d.ts +4 -4
  155. package/dist/snapshots/index.js +4 -4
  156. package/dist/{stale-VKXSXJF4.js → stale-UBLP3RJ3.js} +2 -2
  157. package/dist/store/index.cjs.map +1 -1
  158. package/dist/store/index.d.cts +4 -4
  159. package/dist/store/index.d.ts +4 -4
  160. package/dist/store/index.js +2 -2
  161. package/dist/strategy-rtpKDfTC.d.cts +2029 -0
  162. package/dist/strategy-rtpKDfTC.d.ts +2029 -0
  163. package/dist/sync/index.cjs.map +1 -1
  164. package/dist/sync/index.d.cts +3 -3
  165. package/dist/sync/index.d.ts +3 -3
  166. package/dist/sync/index.js +4 -4
  167. package/dist/team/index.cjs.map +1 -1
  168. package/dist/team/index.d.cts +4 -4
  169. package/dist/team/index.d.ts +4 -4
  170. package/dist/team/index.js +8 -8
  171. package/dist/tx/index.cjs +8 -1
  172. package/dist/tx/index.cjs.map +1 -1
  173. package/dist/tx/index.d.cts +4 -4
  174. package/dist/tx/index.d.ts +4 -4
  175. package/dist/tx/index.js +3 -3
  176. package/dist/{types-DiSXn3a4.d.cts → types-BGwjsDef.d.cts} +511 -6
  177. package/dist/{types-CD8mc8zR.d.ts → types-DRdfwgTG.d.ts} +511 -6
  178. package/dist/{ulid-DQ1hcJvZ.d.cts → ulid-D4d0Xto3.d.cts} +1 -1
  179. package/dist/{ulid-8p83wbR4.d.ts → ulid-DOTPZ5_h.d.ts} +1 -1
  180. package/dist/util/index.cjs.map +1 -1
  181. package/dist/util/index.js +1 -1
  182. package/dist/vault-group-Z4KB75ZH.js +450 -0
  183. package/dist/vault-group-Z4KB75ZH.js.map +1 -0
  184. package/dist/{with-derivation-DWMTpgEH.d.ts → with-derivation-B082Y_WQ.d.ts} +1 -1
  185. package/dist/{with-derivation-CVT7-dUt.d.cts → with-derivation-CB1EdcFF.d.cts} +1 -1
  186. package/dist/{with-materialized-view-BTTU3BNK.d.cts → with-materialized-view-CzRg1Dpr.d.cts} +1 -1
  187. package/dist/{with-materialized-view-X0CoL8-L.d.ts → with-materialized-view-Dw4SwjKl.d.ts} +1 -1
  188. package/dist/{with-overlayed-view-DcacRRsS.d.cts → with-overlayed-view-C9YFKXzn.d.cts} +1 -1
  189. package/dist/{with-overlayed-view-DQjO_DSG.d.ts → with-overlayed-view-CaCXeW26.d.ts} +1 -1
  190. package/package.json +3 -3
  191. package/dist/chunk-2LPPNWF6.js +0 -340
  192. package/dist/chunk-2LPPNWF6.js.map +0 -1
  193. package/dist/chunk-6YLPHBKR.js.map +0 -1
  194. package/dist/chunk-77DWLQRY.js.map +0 -1
  195. package/dist/chunk-C3WE6UJY.js +0 -19
  196. package/dist/chunk-C3WE6UJY.js.map +0 -1
  197. package/dist/chunk-CXJG63MA.js.map +0 -1
  198. package/dist/chunk-MPOLUAMI.js.map +0 -1
  199. package/dist/chunk-O6EJ6WTI.js.map +0 -1
  200. package/dist/chunk-PVUUIWHY.js.map +0 -1
  201. package/dist/chunk-SLV4LAKX.js.map +0 -1
  202. package/dist/executor-S76VN45G.js +0 -8
  203. package/dist/executor-UCXLIGLW.js +0 -11
  204. package/dist/executor-ZCNZJMGR.js +0 -8
  205. package/dist/index-B8bjExET.d.cts +0 -2434
  206. package/dist/index-DfUbNad8.d.ts +0 -2434
  207. package/dist/issue-IVTVSKWW.js +0 -12
  208. package/dist/noydb-SH4RLE47.js +0 -34
  209. package/dist/registry-UFIK7CSR.js +0 -8
  210. package/dist/registry-ZGYYSM5I.js +0 -8
  211. package/dist/strategy-CT2LCKAX.d.cts +0 -613
  212. package/dist/strategy-CT2LCKAX.d.ts +0 -613
  213. package/dist/with-guard-BRvt53da.d.ts +0 -18
  214. package/dist/with-guard-Dx2zZnTA.d.cts +0 -18
  215. /package/dist/{chunk-7CEGU63S.js.map → chunk-4BHFNKTP.js.map} +0 -0
  216. /package/dist/{chunk-5OEJ6GOT.js.map → chunk-5ARRXIVR.js.map} +0 -0
  217. /package/dist/{chunk-YM7LFCG7.js.map → chunk-6BYBVRZU.js.map} +0 -0
  218. /package/dist/{chunk-73YLDCNF.js.map → chunk-7JJE3OMJ.js.map} +0 -0
  219. /package/dist/{chunk-GKI4SDP7.js.map → chunk-7LVRIW4G.js.map} +0 -0
  220. /package/dist/{chunk-IMYKDWB4.js.map → chunk-B7GGYNKQ.js.map} +0 -0
  221. /package/dist/{chunk-BDV7INMP.js.map → chunk-BXOUVUES.js.map} +0 -0
  222. /package/dist/{chunk-FO3UEG4S.js.map → chunk-C2CIIQRG.js.map} +0 -0
  223. /package/dist/{chunk-ZROPXHJY.js.map → chunk-CHBXWJZQ.js.map} +0 -0
  224. /package/dist/{chunk-RYIL3PI2.js.map → chunk-CILT6V3V.js.map} +0 -0
  225. /package/dist/{chunk-YVZRTCGG.js.map → chunk-DLTU4M2I.js.map} +0 -0
  226. /package/dist/{chunk-GAUEWM7D.js.map → chunk-EKNUBIIQ.js.map} +0 -0
  227. /package/dist/{chunk-QCXNMCHN.js.map → chunk-GFPR7VJS.js.map} +0 -0
  228. /package/dist/{chunk-V2PZC6AW.js.map → chunk-HBAJDI2N.js.map} +0 -0
  229. /package/dist/{chunk-RRNA5GKT.js.map → chunk-IEPT7HVP.js.map} +0 -0
  230. /package/dist/{chunk-R233SLY3.js.map → chunk-IUBHXEPJ.js.map} +0 -0
  231. /package/dist/{chunk-CH22FZHT.js.map → chunk-L6BYRCYB.js.map} +0 -0
  232. /package/dist/{chunk-PC3ZZBTO.js.map → chunk-LOA2VCMS.js.map} +0 -0
  233. /package/dist/{chunk-TGALXXLV.js.map → chunk-LSEW3ZZ2.js.map} +0 -0
  234. /package/dist/{chunk-Y26YV5R3.js.map → chunk-LWSD4QPT.js.map} +0 -0
  235. /package/dist/{chunk-26NK23DZ.js.map → chunk-M45IRXDM.js.map} +0 -0
  236. /package/dist/{chunk-ZBBW7YQN.js.map → chunk-O53RIZCC.js.map} +0 -0
  237. /package/dist/{chunk-LSTBFLL2.js.map → chunk-P3Z5Y2TS.js.map} +0 -0
  238. /package/dist/{chunk-QSOYKKMD.js.map → chunk-P4EDT5ZP.js.map} +0 -0
  239. /package/dist/{chunk-PC6ZEDRL.js.map → chunk-RHQYVHFH.js.map} +0 -0
  240. /package/dist/{chunk-3DGHRDCX.js.map → chunk-RRDWXNBQ.js.map} +0 -0
  241. /package/dist/{chunk-6MFH4BMK.js.map → chunk-SJJQKNMP.js.map} +0 -0
  242. /package/dist/{chunk-EBVBE7UK.js.map → chunk-SZ4N3IL5.js.map} +0 -0
  243. /package/dist/{chunk-JQ4NEJJ6.js.map → chunk-UA6G45ME.js.map} +0 -0
  244. /package/dist/{chunk-DAP2XL7Q.js.map → chunk-VOXMU6LB.js.map} +0 -0
  245. /package/dist/{chunk-YW5DBAPG.js.map → chunk-WUG3E423.js.map} +0 -0
  246. /package/dist/{chunk-LJXYPGRH.js.map → chunk-XHM2SARW.js.map} +0 -0
  247. /package/dist/{chunk-RC6SU5NO.js.map → chunk-XSIFXX54.js.map} +0 -0
  248. /package/dist/{chunk-CXFOITNS.js.map → chunk-ZC7MNVYN.js.map} +0 -0
  249. /package/dist/{chunk-6T2UDBKG.js.map → chunk-ZCFS7U4J.js.map} +0 -0
  250. /package/dist/{crypto-2CRLG4F4.js.map → crypto-AJB72OKN.js.map} +0 -0
  251. /package/dist/{delegation-ZTRT2PRV.js.map → delegation-6FCWDRUS.js.map} +0 -0
  252. /package/dist/{executor-S76VN45G.js.map → executor-7KSCEIFA.js.map} +0 -0
  253. /package/dist/{executor-UCXLIGLW.js.map → executor-D2QMNGRJ.js.map} +0 -0
  254. /package/dist/{executor-ZCNZJMGR.js.map → executor-O5AZK7UW.js.map} +0 -0
  255. /package/dist/{fanout-sidecar-F3ZRFU4H.js.map → fanout-sidecar-ZSKEQ6NI.js.map} +0 -0
  256. /package/dist/{issue-IVTVSKWW.js.map → issue-YIYG4OW5.js.map} +0 -0
  257. /package/dist/{ledger-NYCGJX2D.js.map → ledger-5JMVF7PY.js.map} +0 -0
  258. /package/dist/{noydb-SH4RLE47.js.map → noydb-D5SLAJ6V.js.map} +0 -0
  259. /package/dist/{public-envelope-QOXZEHKH.js.map → public-envelope-PFLZI5MO.js.map} +0 -0
  260. /package/dist/{registry-ST2VNFZC.js.map → registry-BVQ5ITMF.js.map} +0 -0
  261. /package/dist/{registry-UFIK7CSR.js.map → registry-JLP3QOLD.js.map} +0 -0
  262. /package/dist/{registry-ZGYYSM5I.js.map → registry-NCY445U5.js.map} +0 -0
  263. /package/dist/{revoke-RT7QYB4G.js.map → revoke-7RLGQWZ7.js.map} +0 -0
  264. /package/dist/{signer-QNU66JF5.js.map → signer-6JF44I4A.js.map} +0 -0
  265. /package/dist/{stale-VKXSXJF4.js.map → stale-UBLP3RJ3.js.map} +0 -0
@@ -1,340 +0,0 @@
1
- import {
2
- readPath
3
- } from "./chunk-TV3YZ35S.js";
4
- import {
5
- GroupCardinalityError
6
- } from "./chunk-O6EJ6WTI.js";
7
-
8
- // src/aggregate/aggregation.ts
9
- function reduceRecords(records, spec) {
10
- const state = {};
11
- for (const key of Object.keys(spec)) {
12
- state[key] = spec[key].init();
13
- }
14
- for (const record of records) {
15
- for (const key of Object.keys(spec)) {
16
- state[key] = spec[key].step(state[key], record);
17
- }
18
- }
19
- const result = {};
20
- for (const key of Object.keys(spec)) {
21
- result[key] = spec[key].finalize(state[key]);
22
- }
23
- return result;
24
- }
25
- var LiveAggregationImpl = class {
26
- constructor(recompute, upstreams) {
27
- this.recompute = recompute;
28
- try {
29
- this.value = recompute();
30
- this.error = void 0;
31
- } catch (err) {
32
- this.value = void 0;
33
- this.error = err;
34
- }
35
- for (const upstream of upstreams) {
36
- const unsub = upstream.subscribe(() => this.refresh());
37
- this.unsubscribes.push(unsub);
38
- }
39
- }
40
- recompute;
41
- value;
42
- error;
43
- listeners = /* @__PURE__ */ new Set();
44
- unsubscribes = [];
45
- stopped = false;
46
- refresh() {
47
- if (this.stopped) return;
48
- try {
49
- this.value = this.recompute();
50
- this.error = void 0;
51
- } catch (err) {
52
- this.error = err;
53
- }
54
- for (const listener of this.listeners) {
55
- try {
56
- listener();
57
- } catch (err) {
58
- console.warn("[noy-db] LiveAggregation listener threw:", err);
59
- }
60
- }
61
- }
62
- subscribe(cb) {
63
- if (this.stopped) {
64
- return () => {
65
- };
66
- }
67
- this.listeners.add(cb);
68
- return () => {
69
- this.listeners.delete(cb);
70
- };
71
- }
72
- stop() {
73
- if (this.stopped) return;
74
- this.stopped = true;
75
- for (const unsub of this.unsubscribes) {
76
- try {
77
- unsub();
78
- } catch (err) {
79
- console.warn("[noy-db] LiveAggregation upstream unsubscribe threw:", err);
80
- }
81
- }
82
- this.unsubscribes.length = 0;
83
- this.listeners.clear();
84
- }
85
- };
86
- var Aggregation = class {
87
- constructor(executeRecords, spec, upstreams) {
88
- this.executeRecords = executeRecords;
89
- this.spec = spec;
90
- this.upstreams = upstreams;
91
- }
92
- executeRecords;
93
- spec;
94
- upstreams;
95
- /**
96
- * Execute the query and reduce the results synchronously.
97
- * Returns the reduced shape matching the spec — e.g. a spec of
98
- * `{ total: sum('amount'), n: count() }` returns
99
- * `{ total: number, n: number }`.
100
- */
101
- run() {
102
- return reduceRecords(this.executeRecords(), this.spec);
103
- }
104
- /**
105
- * Build a reactive `LiveAggregation<R>` that re-runs the reduction
106
- * whenever any upstream source notifies of a change. The initial
107
- * value is computed eagerly in the constructor, so consumers can
108
- * read `live.value` immediately after calling `.live()`.
109
- *
110
- * Always call `live.stop()` when finished — it tears down the
111
- * upstream subscriptions. Vue's `onUnmounted` is the canonical
112
- * place.
113
- *
114
- * **Implementation note:** every upstream change triggers a full
115
- * re-reduction. Incremental maintenance (O(1) per delta for
116
- * sum/count/avg via the reducer protocol's `remove()` method) is a
117
- * planned follow-up optimization — the protocol already supports
118
- * it, but the executor doesn't drive it yet. Consumers get
119
- * correct, reactive values today; future PRs can switch to
120
- * delta-based maintenance without changing this API.
121
- */
122
- live() {
123
- const recompute = () => reduceRecords(this.executeRecords(), this.spec);
124
- return new LiveAggregationImpl(recompute, this.upstreams);
125
- }
126
- };
127
- function buildLiveAggregation(recompute, upstreams) {
128
- return new LiveAggregationImpl(recompute, upstreams);
129
- }
130
-
131
- // src/aggregate/canonical-key.ts
132
- function canonicalGroupKey(fields, row) {
133
- const sorted = [...fields].sort();
134
- const parts = [];
135
- for (const name of sorted) {
136
- const v = row[name];
137
- const serialised = v === void 0 ? "undefined" : JSON.stringify(v);
138
- parts.push(`${name}=${serialised}`);
139
- }
140
- return parts.join("|");
141
- }
142
-
143
- // src/aggregate/groupby.ts
144
- var GROUPBY_WARN_CARDINALITY = 1e4;
145
- var GROUPBY_MAX_CARDINALITY = 1e5;
146
- var warnedCardinalityFields = /* @__PURE__ */ new Set();
147
- function warnCardinalityApproaching(fields, observed) {
148
- const key = JSON.stringify([...fields].sort());
149
- if (warnedCardinalityFields.has(key)) return;
150
- warnedCardinalityFields.add(key);
151
- const label = `[${fields.join(", ")}]`;
152
- console.warn(
153
- `[noy-db] .groupBy(${label}) produced ${observed} distinct groups, ${Math.round(observed / GROUPBY_MAX_CARDINALITY * 100)}% of the ${GROUPBY_MAX_CARDINALITY}-group ceiling. Narrow the query with .where() before grouping, or switch to a lower-cardinality field.`
154
- );
155
- }
156
- function resetGroupByWarnings() {
157
- warnedCardinalityFields.clear();
158
- }
159
- var GroupedQueryBase = class {
160
- constructor(executeRecords, fieldOrFields, upstreams, dictLabelResolver) {
161
- this.executeRecords = executeRecords;
162
- this.upstreams = upstreams;
163
- this.dictLabelResolver = dictLabelResolver;
164
- this.fields = typeof fieldOrFields === "string" ? [fieldOrFields] : [...fieldOrFields];
165
- }
166
- executeRecords;
167
- upstreams;
168
- dictLabelResolver;
169
- /**
170
- * Field set this grouped query buckets on. Stored in declaration
171
- * order — the same order is preserved on every result row by
172
- * `groupAndReduce`. For the single-field constructor, this is
173
- * `[field]`.
174
- */
175
- fields;
176
- };
177
- var GroupedQuery = class extends GroupedQueryBase {
178
- /**
179
- * Build a grouped aggregation. Returns a `GroupedAggregation`
180
- * with `.run()`, `.runAsync()`, and `.live()` terminals — same shape
181
- * as the non-grouped `.aggregate()` wrapper, just with an array
182
- * result (one row per bucket) instead of a single reduced object.
183
- */
184
- aggregate(spec) {
185
- return new GroupedAggregation(
186
- this.executeRecords,
187
- this.fields,
188
- spec,
189
- this.upstreams,
190
- this.dictLabelResolver
191
- );
192
- }
193
- };
194
- var GroupedQueryN = class extends GroupedQueryBase {
195
- aggregate(spec) {
196
- return new GroupedAggregation(
197
- this.executeRecords,
198
- this.fields,
199
- spec,
200
- this.upstreams,
201
- this.dictLabelResolver
202
- );
203
- }
204
- };
205
- function groupAndReduce(records, fieldOrFields, spec) {
206
- const fields = typeof fieldOrFields === "string" ? [fieldOrFields] : fieldOrFields;
207
- if (fields.length === 0) {
208
- throw new Error(".groupBy() requires at least one field");
209
- }
210
- const buckets = /* @__PURE__ */ new Map();
211
- const fieldLabel = fields.length === 1 ? fields[0] : `[${fields.join(", ")}]`;
212
- for (const record of records) {
213
- const keyValues = {};
214
- for (const f of fields) {
215
- keyValues[f] = readPath(record, f);
216
- }
217
- const dedupKey = canonicalGroupKey(fields, keyValues);
218
- let bucket = buckets.get(dedupKey);
219
- if (bucket === void 0) {
220
- if (buckets.size >= GROUPBY_MAX_CARDINALITY) {
221
- throw new GroupCardinalityError(
222
- fieldLabel,
223
- buckets.size + 1,
224
- GROUPBY_MAX_CARDINALITY
225
- );
226
- }
227
- bucket = { keyValues, records: [] };
228
- buckets.set(dedupKey, bucket);
229
- }
230
- bucket.records.push(record);
231
- }
232
- if (buckets.size >= GROUPBY_WARN_CARDINALITY) {
233
- warnCardinalityApproaching(fields, buckets.size);
234
- }
235
- const reducerKeys = Object.keys(spec);
236
- const out = [];
237
- for (const bucket of buckets.values()) {
238
- const state = {};
239
- for (const rk of reducerKeys) {
240
- state[rk] = spec[rk].init();
241
- }
242
- for (const record of bucket.records) {
243
- for (const rk of reducerKeys) {
244
- state[rk] = spec[rk].step(state[rk], record);
245
- }
246
- }
247
- const row = {};
248
- for (const f of fields) {
249
- row[f] = bucket.keyValues[f];
250
- }
251
- for (const rk of reducerKeys) {
252
- row[rk] = spec[rk].finalize(state[rk]);
253
- }
254
- out.push(row);
255
- }
256
- return out;
257
- }
258
- var GroupedAggregation = class {
259
- constructor(executeRecords, fields, spec, upstreams, dictLabelResolver) {
260
- this.executeRecords = executeRecords;
261
- this.spec = spec;
262
- this.upstreams = upstreams;
263
- this.dictLabelResolver = dictLabelResolver;
264
- this.fields = typeof fields === "string" ? [fields] : [...fields];
265
- }
266
- executeRecords;
267
- spec;
268
- upstreams;
269
- dictLabelResolver;
270
- fields;
271
- /** Execute the query, group, reduce, and return an array of rows. */
272
- run() {
273
- return groupAndReduce(this.executeRecords(), this.fields, this.spec);
274
- }
275
- /**
276
- * Execute the query, group, reduce, and resolve `<field>Label` for
277
- * each result row when the grouping field is a `dictKey` and a
278
- * `locale` is provided. Returns `R[]` synchronously when
279
- * no locale is specified (identical to `.run()`).
280
- *
281
- * The `<field>Label` field is appended to each row. Rows whose group
282
- * key has no dictionary entry get `<field>Label: undefined`.
283
- *
284
- * Dict-label resolution is single-field only — multi-key groupings
285
- * do not produce a `<field>Label`. The resolver is only attached
286
- * by the builder when `fields.length === 1`.
287
- */
288
- async runAsync(opts) {
289
- const rows = groupAndReduce(this.executeRecords(), this.fields, this.spec);
290
- if (!opts?.locale || !this.dictLabelResolver || this.fields.length !== 1) return rows;
291
- const resolve = this.dictLabelResolver;
292
- const locale = opts.locale;
293
- const fallback = opts.fallback;
294
- const field = this.fields[0];
295
- const labelKey = `${field}Label`;
296
- return Promise.all(
297
- rows.map(async (row) => {
298
- const key = row[field];
299
- if (typeof key !== "string") return row;
300
- const label = await resolve(key, locale, fallback);
301
- return { ...row, [labelKey]: label };
302
- })
303
- );
304
- }
305
- /**
306
- * Build a reactive `LiveAggregation<R[]>` that re-runs the full
307
- * group-and-reduce pipeline whenever any upstream source notifies
308
- * of a change. Same error-isolation and idempotent-stop contract
309
- * as `Aggregation.live()` — the implementation delegates to the
310
- * same `LiveAggregationImpl` class by threading a fresh
311
- * recompute closure through the existing constructor.
312
- *
313
- * uses naive full re-run on every change. Incremental
314
- * per-bucket maintenance (apply `step` on inserted records,
315
- * `remove` on deleted records, route by bucket key) is a future
316
- * optimization — the reducer protocol admits it, but wiring
317
- * delta-aware source subscriptions is a separate PR.
318
- *
319
- * Always call `live.stop()` when finished.
320
- */
321
- live() {
322
- const recompute = () => groupAndReduce(this.executeRecords(), this.fields, this.spec);
323
- return buildLiveAggregation(recompute, this.upstreams);
324
- }
325
- };
326
-
327
- export {
328
- reduceRecords,
329
- Aggregation,
330
- buildLiveAggregation,
331
- canonicalGroupKey,
332
- GROUPBY_WARN_CARDINALITY,
333
- GROUPBY_MAX_CARDINALITY,
334
- resetGroupByWarnings,
335
- GroupedQuery,
336
- GroupedQueryN,
337
- groupAndReduce,
338
- GroupedAggregation
339
- };
340
- //# sourceMappingURL=chunk-2LPPNWF6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/aggregate/aggregation.ts","../src/aggregate/canonical-key.ts","../src/aggregate/groupby.ts"],"sourcesContent":["/**\n * Aggregate execution — the runtime behind `Query.aggregate()`.\n *\n * takes an `AggregateSpec` (a record of named reducers\n * built from `reducers.ts`) and runs every reducer over the records\n * produced by the underlying query. Two terminal surfaces:\n *\n * - `.run(): R` — synchronous one-shot reduction. Matches the\n * existing `Query.toArray()` / `.first()` / `.count()` style.\n * - `.live(): LiveAggregation<R>` — reactive primitive that\n * re-runs the reduction whenever the query's source notifies of\n * a change. uses naive full re-run; incremental delta\n * maintenance is admitted by the reducer protocol (`remove()`)\n * but not wired to the executor yet — a follow-up optimization\n * can switch from full re-run to delta-based without breaking\n * the public API. Consumers get correct, reactive values today.\n *\n * The `Aggregation<R>` wrapper is deliberately tiny — it exists so\n * `.aggregate(spec)` can be chained with either `.run()` or `.live()`\n * without the builder needing two separate terminal methods. It\n * holds the closure over the query execution (produces the current\n * matching record set) and the spec, and stitches them together in\n * either mode.\n *\n * This file depends ONLY on `reducers.ts` — it has no knowledge of\n * the `Query` class. Tests can therefore exercise the reduction\n * surface with plain record arrays, without spinning up a Collection.\n */\n\nimport type { Reducer } from './reducers.js'\n\n/**\n * A named set of reducers, keyed by output field name. Each key\n * becomes a field on the aggregated result.\n *\n * ```ts\n * const spec = {\n * total: sum('amount'),\n * n: count(),\n * avgAmount: avg('amount'),\n * }\n * ```\n */\nexport type AggregateSpec = Readonly<Record<string, Reducer<unknown, unknown>>>\n\n/**\n * Map an `AggregateSpec` to its reduced result shape — each key\n * carries the finalized result type from its reducer. A spec built\n * from `{ total: sum('amount'), n: count() }` yields a result of\n * `{ total: number, n: number }`.\n *\n * This uses a mapped type with a conditional to extract `R` from\n * each `Reducer<R, _>`. The `infer` captures the user-visible result\n * type, discarding the internal state type `S`.\n */\nexport type AggregateResult<Spec extends AggregateSpec> = {\n [K in keyof Spec]: Spec[K] extends Reducer<infer R, unknown> ? R : never\n}\n\n/**\n * Pure reduction over a record array. Runs every reducer's\n * `init → step* → finalize` pipeline exactly once over the records.\n *\n * Called by `Aggregation.run()` and by the live-mode refresh path.\n * Exported for tests and for future `scan().aggregate()` reuse\n * — the streaming path will call the same reducer protocol with a\n * per-page loop instead of a single array.\n */\nexport function reduceRecords<Spec extends AggregateSpec>(\n records: readonly unknown[],\n spec: Spec,\n): AggregateResult<Spec> {\n // Per-slot state, keyed by the spec's output field name.\n const state: Record<string, unknown> = {}\n for (const key of Object.keys(spec)) {\n state[key] = spec[key]!.init()\n }\n for (const record of records) {\n for (const key of Object.keys(spec)) {\n state[key] = spec[key]!.step(state[key], record)\n }\n }\n const result: Record<string, unknown> = {}\n for (const key of Object.keys(spec)) {\n result[key] = spec[key]!.finalize(state[key])\n }\n return result as AggregateResult<Spec>\n}\n\n/**\n * A minimal reactive primitive for aggregation results.\n *\n * Same spirit as the `LiveQuery` in : frame-agnostic, a plain\n * object with `value` / `error` fields and a `subscribe(cb)`\n * notification channel that Vue / React / Solid adapters wrap in\n * their own primitive. Intentionally NOT a Promise — aggregations\n * have a well-defined \"current value\" at every instant, and the\n * reactive consumer wants to read that value synchronously.\n *\n * Error semantics mirror `LiveQuery`: if a re-run throws, the\n * previous successful `value` is preserved and the error is stored\n * in `error` so consumers can render an error state without losing\n * the last-known-good result. The throw does NOT propagate out of\n * the source's change handler (which would tear down the upstream\n * emitter).\n *\n * `stop()` tears down the upstream subscription. It is idempotent —\n * calling it multiple times is safe — and subscribe calls after\n * stop are no-ops (they immediately return a no-op unsubscribe).\n * Always call `stop()` when done; Vue's `onUnmounted` is the\n * canonical place. Raw consumers must do it themselves.\n */\nexport interface LiveAggregation<R> {\n /** Current reduced value. Undefined only if the first compute threw. */\n readonly value: R | undefined\n /** Last execution error, if any. Cleared on the next successful run. */\n readonly error: unknown\n /** Notify on every recomputation (success or error). Returns unsubscribe. */\n subscribe(cb: () => void): () => void\n /** Tear down the upstream subscription. Idempotent. */\n stop(): void\n}\n\n/**\n * Upstream change-notification hook for live aggregation.\n *\n * Matches the shape that `QuerySource.subscribe` already uses — a\n * single method that accepts a callback and returns an unsubscribe\n * function. The `Aggregation` wrapper collects upstreams from the\n * query's source and wires them into a single re-run trigger.\n */\nexport interface AggregationUpstream {\n subscribe(cb: () => void): () => void\n}\n\n/**\n * Internal implementation of `LiveAggregation`. Not exported —\n * consumers get the interface only. The class wraps a `recompute`\n * closure (which runs the full reduction and returns the new value)\n * and a list of upstreams (sources whose changes should trigger a\n * re-run).\n *\n * Error isolation: if an individual listener callback throws, the\n * other listeners still fire and the error is logged to the warn\n * channel. This matches `LiveQuery` from and keeps one misbehaving\n * consumer from tearing down the whole live aggregation.\n */\nclass LiveAggregationImpl<R> implements LiveAggregation<R> {\n public value: R | undefined\n public error: unknown\n private readonly listeners = new Set<() => void>()\n private readonly unsubscribes: Array<() => void> = []\n private stopped = false\n\n constructor(\n private readonly recompute: () => R,\n upstreams: readonly AggregationUpstream[],\n ) {\n // Initial computation — surface any error through the `error`\n // field rather than letting the constructor throw, so consumers\n // can always construct a LiveAggregation and check its state\n // afterwards. Throwing from a constructor would force every\n // caller to wrap in try/catch, which is the opposite of the\n // \"reactive value with error state\" ergonomics we want.\n try {\n this.value = recompute()\n this.error = undefined\n } catch (err) {\n this.value = undefined\n this.error = err\n }\n\n // Wire up upstream subscriptions. Each one triggers a full\n // recomputation; we don't attempt incremental updates in.\n for (const upstream of upstreams) {\n const unsub = upstream.subscribe(() => this.refresh())\n this.unsubscribes.push(unsub)\n }\n }\n\n private refresh(): void {\n if (this.stopped) return\n try {\n this.value = this.recompute()\n this.error = undefined\n } catch (err) {\n // Preserve the previous successful value — consumers render an\n // error state using `error` without losing the last-known-good\n // number. This matches LiveQuery's error-preservation contract.\n this.error = err\n }\n for (const listener of this.listeners) {\n try {\n listener()\n } catch (err) {\n // Isolate listener errors so one bad consumer can't tear\n // down every other subscriber on the same aggregation.\n console.warn('[noy-db] LiveAggregation listener threw:', err)\n }\n }\n }\n\n subscribe(cb: () => void): () => void {\n if (this.stopped) {\n // No-op after stop. Returning a harmless unsubscribe lets\n // consumers use the same teardown pattern unconditionally.\n return () => {}\n }\n this.listeners.add(cb)\n return () => {\n this.listeners.delete(cb)\n }\n }\n\n stop(): void {\n if (this.stopped) return\n this.stopped = true\n for (const unsub of this.unsubscribes) {\n try {\n unsub()\n } catch (err) {\n console.warn('[noy-db] LiveAggregation upstream unsubscribe threw:', err)\n }\n }\n this.unsubscribes.length = 0\n this.listeners.clear()\n }\n}\n\n/**\n * Chainable wrapper returned by `Query.aggregate(spec)`. Holds the\n * execute-records closure and the spec; terminal methods (`run`,\n * `live`) stitch them together in either mode.\n *\n * Why a wrapper instead of two terminal methods on `Query` directly?\n *\n * The `.aggregate(spec)` call is where the spec is bound — both\n * `.run()` and `.live()` need the same spec, and the consumer's\n * fluent style is `query.where(...).aggregate(spec).run()` or\n * `.aggregate(spec).live()`. Wrapping lets the spec be named once\n * and reused for either terminal, and keeps the `Query` class\n * from growing a pair of near-duplicate method overloads\n * (`aggregateRun` / `aggregateLive`) that would be harder to\n * discover.\n */\nexport class Aggregation<R> {\n constructor(\n private readonly executeRecords: () => readonly unknown[],\n private readonly spec: AggregateSpec,\n private readonly upstreams: readonly AggregationUpstream[],\n ) {}\n\n /**\n * Execute the query and reduce the results synchronously.\n * Returns the reduced shape matching the spec — e.g. a spec of\n * `{ total: sum('amount'), n: count() }` returns\n * `{ total: number, n: number }`.\n */\n run(): R {\n return reduceRecords(this.executeRecords(), this.spec) as unknown as R\n }\n\n /**\n * Build a reactive `LiveAggregation<R>` that re-runs the reduction\n * whenever any upstream source notifies of a change. The initial\n * value is computed eagerly in the constructor, so consumers can\n * read `live.value` immediately after calling `.live()`.\n *\n * Always call `live.stop()` when finished — it tears down the\n * upstream subscriptions. Vue's `onUnmounted` is the canonical\n * place.\n *\n * **Implementation note:** every upstream change triggers a full\n * re-reduction. Incremental maintenance (O(1) per delta for\n * sum/count/avg via the reducer protocol's `remove()` method) is a\n * planned follow-up optimization — the protocol already supports\n * it, but the executor doesn't drive it yet. Consumers get\n * correct, reactive values today; future PRs can switch to\n * delta-based maintenance without changing this API.\n */\n live(): LiveAggregation<R> {\n const recompute = (): R =>\n reduceRecords(this.executeRecords(), this.spec) as unknown as R\n return new LiveAggregationImpl<R>(recompute, this.upstreams)\n }\n}\n\n/**\n * Build a `LiveAggregation<V>` from a recompute closure and a list\n * of upstreams. Exposed so sibling files in the query DSL\n * (currently `groupby.ts`) can reuse the reactive primitive\n * without reaching into `LiveAggregationImpl` directly. This keeps\n * the implementation class private while still allowing planned\n * composition with `.groupBy().aggregate().live()`.\n */\nexport function buildLiveAggregation<V>(\n recompute: () => V,\n upstreams: readonly AggregationUpstream[],\n): LiveAggregation<V> {\n return new LiveAggregationImpl<V>(recompute, upstreams)\n}\n","/**\n * Canonicalise a group-key tuple to a stable string for dedup hashing.\n *\n * Sorts field names lexicographically before serialising, so that\n * `.groupBy('a', 'b')` and `.groupBy('b', 'a')` produce identical\n * keys for the same logical group. Values are JSON-stringified;\n * `undefined` and `null` are distinguished (matching the Map-key\n * semantics in `groupAndReduce`).\n *\n * NOT part of the public API. Used by:\n * - `groupAndReduce` for the dedup Map's key\n * - `materialized-views/query-hash` for UNION MV cross-arm row-key dedup (PR 2)\n *\n * Pure: same input → same output, no side effects.\n */\nexport function canonicalGroupKey(\n fields: readonly string[],\n row: Record<string, unknown>,\n): string {\n const sorted = [...fields].sort()\n const parts: string[] = []\n for (const name of sorted) {\n const v = row[name]\n const serialised =\n v === undefined ? 'undefined' : JSON.stringify(v)\n parts.push(`${name}=${serialised}`)\n }\n return parts.join('|')\n}\n","/**\n * Query DSL `.groupBy()` —.\n *\n * Chains after `.where()` / `.filter()` / `.or()` / `.and()` on a\n * Query and before a reducer spec, so consumers can compute\n * per-bucket aggregates without folding in userland:\n *\n * ```ts\n * const byClient = invoices.query()\n * .where('status', '==', 'open')\n * .groupBy('clientId')\n * .aggregate({ total: sum('amount'), n: count() })\n * .run()\n * // → [ { clientId: 'c1', total: 5250, n: 3 }, … ]\n * ```\n *\n * Execution pipeline:\n *\n * 1. Run the query's where/filter clauses (same candidate /\n * filter pipeline as `.aggregate()` directly on Query).\n * 2. Partition the matching records into buckets keyed by\n * `readPath(record, field)`. JS `Map` preserves insertion\n * order, so the first-seen key for a bucket determines its\n * position in the result array — consumers who want a\n * specific ordering should `.sort()` downstream.\n * 3. Enforce cardinality: warn once per field at 10% of the cap\n * (10_000 buckets), throw `GroupCardinalityError` at 100% of\n * the cap (100_000 buckets).\n * 4. For each bucket, build a per-group reducer state and\n * step every record in the bucket through it.\n * 5. Emit one result row per bucket, shaped as\n * `{ [field]: key, ...reduced }`.\n *\n * **Null / undefined keys:** `Map` distinguishes `null` from\n * `undefined`, so records with a missing group field get their own\n * bucket, and records with an explicit `null` value get a separate\n * bucket from that. Consumers who want them merged can coalesce\n * upstream with `.filter()`.\n *\n * **Live mode:** `.groupBy().aggregate().live()` re-runs the full\n * grouping pipeline on every source change. Per-bucket incremental\n * delta maintenance is a future optimization — the reducer\n * protocol's `remove()` hook admits it, but ships naive\n * re-grouping for simplicity.\n *\n * **Type-level stable-key narrowing:** when\n * `dictKey` lands, `groupBy<DictField>()` will narrow the group key\n * type to the stable dictionary key rather than the resolved locale\n * label. That prevents grouping by the locale-resolved label,\n * which would produce different buckets per reader. types the\n * key as `unknown` at the result shape; the dictKey narrowing\n * layers on top without an API break.\n *\n * Partition-awareness seam: when partitioned collections land,\n * per-partition grouping will need to merge sub-results across\n * partitions. The reducer protocol's `{ seed }` parameter\n * (already plumbed through in `reducers.ts`) is the mechanism —\n * groupBy doesn't need its own seam for the moment, because it\n * delegates to the reducer protocol for all per-bucket state.\n */\n\nimport { readPath } from '../query/predicate.js'\nimport type {\n AggregateSpec,\n AggregateResult,\n AggregationUpstream,\n LiveAggregation,\n} from './aggregation.js'\nimport { buildLiveAggregation } from './aggregation.js'\nimport { canonicalGroupKey } from './canonical-key.js'\nimport { GroupCardinalityError } from '../errors.js'\n\n/**\n * Cardinality thresholds for `.groupBy()`. The warn threshold gives\n * consumers a heads-up before the hard error; the cap is a fixed\n * constant in (not overridable). A `{ maxGroups }` override\n * can be added later without a break if a real consumer asks.\n */\nexport const GROUPBY_WARN_CARDINALITY = 10_000\nexport const GROUPBY_MAX_CARDINALITY = 100_000\n\n/**\n * One-shot warning dedup per-field-set — reactive dashboards\n * re-executing the same grouped query should produce the warning\n * once, not once per re-fire. Keyed on the sorted JSON of grouping\n * field names so `.groupBy('a', 'b')` and `.groupBy('b', 'a')`\n * share the same dedup slot (their result tuples are isomorphic).\n */\nconst warnedCardinalityFields = new Set<string>()\nfunction warnCardinalityApproaching(\n fields: readonly string[],\n observed: number,\n): void {\n const key = JSON.stringify([...fields].sort())\n if (warnedCardinalityFields.has(key)) return\n warnedCardinalityFields.add(key)\n const label = `[${fields.join(', ')}]`\n console.warn(\n `[noy-db] .groupBy(${label}) produced ${observed} distinct groups, ` +\n `${Math.round((observed / GROUPBY_MAX_CARDINALITY) * 100)}% of the ` +\n `${GROUPBY_MAX_CARDINALITY}-group ceiling. Narrow the query with ` +\n `.where() before grouping, or switch to a lower-cardinality field.`,\n )\n}\n\n/**\n * Test-only: clear the per-field cardinality warning dedup between\n * tests. Production code never calls this — matching the\n * `resetJoinWarnings` pattern in `join.ts`.\n */\nexport function resetGroupByWarnings(): void {\n warnedCardinalityFields.clear()\n}\n\n/**\n * Result row shape for a grouped aggregation. Each row carries the\n * group key value under the grouping field name plus every reducer\n * output from the spec.\n *\n * types the group key as `unknown` at the result shape — the\n * runtime read via `readPath` can return any value, and narrowing\n * to a specific type would require the caller to assert at the\n * call site. `dictKey` narrowing layers on top of this by\n * adding an overload that constrains `F` when the grouping field\n * is a `dictKey`.\n */\nexport type GroupedRow<F extends string, R> = { [K in F]: unknown } & R\n\n/**\n * Multi-key variant — result-row shape for variadic\n * `.groupBy(...fields)`. Every grouped field name appears on the row\n * (typed as `unknown` for the same reason as `GroupedRow`), plus the\n * reducer outputs from the spec.\n */\nexport type GroupedRowN<F extends readonly string[], R> =\n { [K in F[number]]: unknown } & R\n\n/**\n * Shared base class for the chainable grouped-query wrappers. Holds\n * the constructor + protected fields that both single-key\n * `GroupedQuery<T, F>` and variadic `GroupedQueryN<T, F>` need; each\n * subclass only overrides `aggregate()` with its own result-row\n * generic.\n *\n * Not exported — implementation detail. Adding `.having()` /\n * `.live()` / `.orderByGroup()` etc. in the future lands here once\n * and both subclasses pick it up automatically.\n *\n * @internal\n */\nabstract class GroupedQueryBase {\n /**\n * Field set this grouped query buckets on. Stored in declaration\n * order — the same order is preserved on every result row by\n * `groupAndReduce`. For the single-field constructor, this is\n * `[field]`.\n */\n protected readonly fields: readonly string[]\n\n constructor(\n protected readonly executeRecords: () => readonly unknown[],\n fieldOrFields: string | readonly string[],\n protected readonly upstreams: readonly AggregationUpstream[],\n /**\n * Optional dict label resolver attached by the query builder when\n * the grouping field is a dictKey. Variadic groupings always pass\n * `undefined` — `<field>Label` projection has no meaningful shape\n * for composite keys.\n */\n protected readonly dictLabelResolver?: (\n key: string,\n locale: string,\n fallback?: string | readonly string[],\n ) => Promise<string | undefined>,\n ) {\n this.fields =\n typeof fieldOrFields === 'string' ? [fieldOrFields] : [...fieldOrFields]\n }\n}\n\n/**\n * Chainable wrapper returned by `Query.groupBy(field)`. Terminates\n * with `.aggregate(spec)` which returns a `GroupedAggregation`.\n *\n * Kept minimal — the only operation on a grouped query is\n * aggregation. Ordering, limiting, and further filtering belong on\n * the underlying `Query` before `.groupBy()` is called; applying\n * them post-group would be a different operation (`having` /\n * `groupOrderBy`), out of scope for.\n */\nexport class GroupedQuery<T, F extends string> extends GroupedQueryBase {\n /**\n * Build a grouped aggregation. Returns a `GroupedAggregation`\n * with `.run()`, `.runAsync()`, and `.live()` terminals — same shape\n * as the non-grouped `.aggregate()` wrapper, just with an array\n * result (one row per bucket) instead of a single reduced object.\n */\n aggregate<Spec extends AggregateSpec>(\n spec: Spec,\n ): GroupedAggregation<GroupedRow<F, AggregateResult<Spec>>> {\n // T is phantom on the wrapper so consumers can still see the\n // source row type on hover. Reference it to keep lint quiet.\n void undefined as T | undefined\n return new GroupedAggregation<GroupedRow<F, AggregateResult<Spec>>>(\n this.executeRecords,\n this.fields,\n spec,\n this.upstreams,\n this.dictLabelResolver,\n )\n }\n}\n\n/**\n * Variadic-keyed sibling of `GroupedQuery<T, F>`. Constructed by the\n * multi-arg `Query.groupBy(...fields)` overload. The runtime shape is\n * identical — only the type-level result-row narrowing differs.\n */\nexport class GroupedQueryN<T, F extends readonly string[]> extends GroupedQueryBase {\n aggregate<Spec extends AggregateSpec>(\n spec: Spec,\n ): GroupedAggregation<GroupedRowN<F, AggregateResult<Spec>>> {\n void undefined as T | undefined\n return new GroupedAggregation<GroupedRowN<F, AggregateResult<Spec>>>(\n this.executeRecords,\n this.fields,\n spec,\n this.upstreams,\n this.dictLabelResolver,\n )\n }\n}\n\n/**\n * Execute the group-and-reduce pipeline. Pure function over a\n * record array and a spec — shared by `GroupedAggregation.run()`\n * and the live-mode refresh path. Exported for tests and for any\n * future `scan().groupBy().aggregate()` reuse.\n *\n * Enforces the cardinality cap incrementally during the partition\n * loop, so a runaway grouping throws at the moment the 100_001st\n * bucket would be created — the consumer doesn't have to wait for\n * the full partition to materialize before the error fires.\n */\nexport function groupAndReduce<R>(\n records: readonly unknown[],\n fieldOrFields: string | readonly string[],\n spec: AggregateSpec,\n): R[] {\n const fields: readonly string[] =\n typeof fieldOrFields === 'string' ? [fieldOrFields] : fieldOrFields\n if (fields.length === 0) {\n throw new Error('.groupBy() requires at least one field')\n }\n\n // Bucket value is { keyValues, records } so the output row can stamp\n // every grouped field in DECLARATION ORDER. Map preserves insertion\n // order natively (ES2015), so first-seen keys determine ordering.\n interface Bucket {\n keyValues: Record<string, unknown>\n records: unknown[]\n }\n const buckets = new Map<string, Bucket>()\n // Field-label string for error messages — matches the variadic\n // surface (`[a, b]` for multi-key, `\"k\"` for single-key back-compat).\n const fieldLabel = fields.length === 1 ? fields[0]! : `[${fields.join(', ')}]`\n\n for (const record of records) {\n // Read each field's value into a row object, then canonicalise.\n const keyValues: Record<string, unknown> = {}\n for (const f of fields) {\n keyValues[f] = readPath(record, f)\n }\n const dedupKey = canonicalGroupKey(fields, keyValues)\n let bucket = buckets.get(dedupKey)\n if (bucket === undefined) {\n if (buckets.size >= GROUPBY_MAX_CARDINALITY) {\n throw new GroupCardinalityError(\n fieldLabel,\n buckets.size + 1,\n GROUPBY_MAX_CARDINALITY,\n )\n }\n bucket = { keyValues, records: [] }\n buckets.set(dedupKey, bucket)\n }\n bucket.records.push(record)\n }\n\n if (buckets.size >= GROUPBY_WARN_CARDINALITY) {\n warnCardinalityApproaching(fields, buckets.size)\n }\n\n // Reduce each bucket through the spec. Same init/step/finalize\n // pipeline as `reduceRecords` in aggregate.ts, but one state per\n // bucket. Inlining the loop here keeps the per-bucket path tight\n // — calling `reduceRecords` per bucket would recompute\n // `Object.keys(spec)` once per bucket unnecessarily.\n const reducerKeys = Object.keys(spec)\n const out: R[] = []\n for (const bucket of buckets.values()) {\n const state: Record<string, unknown> = {}\n for (const rk of reducerKeys) {\n state[rk] = spec[rk]!.init()\n }\n for (const record of bucket.records) {\n for (const rk of reducerKeys) {\n state[rk] = spec[rk]!.step(state[rk], record)\n }\n }\n // Stamp grouped fields FIRST, in declaration order — this is\n // tested via `Object.keys(row).slice(0, fields.length)`.\n const row: Record<string, unknown> = {}\n for (const f of fields) {\n row[f] = bucket.keyValues[f]\n }\n for (const rk of reducerKeys) {\n row[rk] = spec[rk]!.finalize(state[rk])\n }\n out.push(row as unknown as R)\n }\n return out\n}\n\n/**\n * Grouped aggregation wrapper — the `.groupBy(field).aggregate(spec)`\n * terminal. Shape mirrors `Aggregation<R>` from aggregate.ts: two\n * terminals (`.run()` and `.live()`), spec bound at construction\n * time, upstreams collected for live mode.\n *\n * The generic `R` is the per-row result shape (i.e. a single\n * grouped row), and the terminals return `R[]` — one row per\n * bucket.\n */\nexport class GroupedAggregation<R> {\n private readonly fields: readonly string[]\n\n constructor(\n private readonly executeRecords: () => readonly unknown[],\n fields: string | readonly string[],\n private readonly spec: AggregateSpec,\n private readonly upstreams: readonly AggregationUpstream[],\n /**\n * Optional dict label resolver for `<field>Label` projection\n *. Present when the grouping field is a dictKey.\n */\n private readonly dictLabelResolver?: (\n key: string,\n locale: string,\n fallback?: string | readonly string[],\n ) => Promise<string | undefined>,\n ) {\n this.fields = typeof fields === 'string' ? [fields] : [...fields]\n }\n\n /** Execute the query, group, reduce, and return an array of rows. */\n run(): R[] {\n return groupAndReduce<R>(this.executeRecords(), this.fields, this.spec)\n }\n\n /**\n * Execute the query, group, reduce, and resolve `<field>Label` for\n * each result row when the grouping field is a `dictKey` and a\n * `locale` is provided. Returns `R[]` synchronously when\n * no locale is specified (identical to `.run()`).\n *\n * The `<field>Label` field is appended to each row. Rows whose group\n * key has no dictionary entry get `<field>Label: undefined`.\n *\n * Dict-label resolution is single-field only — multi-key groupings\n * do not produce a `<field>Label`. The resolver is only attached\n * by the builder when `fields.length === 1`.\n */\n async runAsync(opts?: {\n locale?: string\n fallback?: string | readonly string[]\n }): Promise<R[]> {\n const rows = groupAndReduce<R>(this.executeRecords(), this.fields, this.spec)\n if (!opts?.locale || !this.dictLabelResolver || this.fields.length !== 1) return rows\n\n const resolve = this.dictLabelResolver\n const locale = opts.locale\n const fallback = opts.fallback\n const field = this.fields[0]!\n const labelKey = `${field}Label`\n\n return Promise.all(\n rows.map(async (row) => {\n const key = (row as Record<string, unknown>)[field]\n if (typeof key !== 'string') return row\n const label = await resolve(key, locale, fallback)\n return { ...(row as Record<string, unknown>), [labelKey]: label } as unknown as R\n }),\n )\n }\n\n /**\n * Build a reactive `LiveAggregation<R[]>` that re-runs the full\n * group-and-reduce pipeline whenever any upstream source notifies\n * of a change. Same error-isolation and idempotent-stop contract\n * as `Aggregation.live()` — the implementation delegates to the\n * same `LiveAggregationImpl` class by threading a fresh\n * recompute closure through the existing constructor.\n *\n * uses naive full re-run on every change. Incremental\n * per-bucket maintenance (apply `step` on inserted records,\n * `remove` on deleted records, route by bucket key) is a future\n * optimization — the reducer protocol admits it, but wiring\n * delta-aware source subscriptions is a separate PR.\n *\n * Always call `live.stop()` when finished.\n */\n live(): LiveAggregation<R[]> {\n const recompute = (): R[] =>\n groupAndReduce<R>(this.executeRecords(), this.fields, this.spec)\n return buildLiveAggregation<R[]>(recompute, this.upstreams)\n }\n}\n"],"mappings":";;;;;;;;AAoEO,SAAS,cACd,SACA,MACuB;AAEvB,QAAM,QAAiC,CAAC;AACxC,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,UAAM,GAAG,IAAI,KAAK,GAAG,EAAG,KAAK;AAAA,EAC/B;AACA,aAAW,UAAU,SAAS;AAC5B,eAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,YAAM,GAAG,IAAI,KAAK,GAAG,EAAG,KAAK,MAAM,GAAG,GAAG,MAAM;AAAA,IACjD;AAAA,EACF;AACA,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,OAAO,KAAK,IAAI,GAAG;AACnC,WAAO,GAAG,IAAI,KAAK,GAAG,EAAG,SAAS,MAAM,GAAG,CAAC;AAAA,EAC9C;AACA,SAAO;AACT;AA4DA,IAAM,sBAAN,MAA2D;AAAA,EAOzD,YACmB,WACjB,WACA;AAFiB;AASjB,QAAI;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