@noy-db/hub 0.2.0-pre.10 → 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 (266) 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 +1468 -19
  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-DRXIZOFV.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-5IXJGFF2.js → chunk-7JJE3OMJ.js} +5 -5
  28. package/dist/{chunk-HHOO7HGH.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-PXTQPZO4.js → chunk-DLTU4M2I.js} +6 -6
  37. package/dist/{chunk-GAUEWM7D.js → chunk-EKNUBIIQ.js} +4 -4
  38. package/dist/{chunk-HQSQC2XL.js → chunk-GFPR7VJS.js} +17 -4
  39. package/dist/chunk-GFPR7VJS.js.map +1 -0
  40. package/dist/{chunk-6EOXTJS2.js → chunk-HBAJDI2N.js} +5 -5
  41. package/dist/{chunk-PVUUIWHY.js → chunk-HLGDYFWR.js} +10 -3
  42. package/dist/chunk-HLGDYFWR.js.map +1 -0
  43. package/dist/{chunk-RRNA5GKT.js → chunk-IEPT7HVP.js} +2 -2
  44. package/dist/{chunk-R233SLY3.js → chunk-IUBHXEPJ.js} +2 -2
  45. package/dist/{chunk-CH22FZHT.js → chunk-L6BYRCYB.js} +2 -2
  46. package/dist/{chunk-5OX6XVNS.js → chunk-LOA2VCMS.js} +5 -5
  47. package/dist/{chunk-BB27JMWB.js → chunk-LSEW3ZZ2.js} +3 -3
  48. package/dist/{chunk-Y26YV5R3.js → chunk-LWSD4QPT.js} +3 -3
  49. package/dist/{chunk-WIRRPTFH.js → chunk-LYNNZEQD.js} +1 -1
  50. package/dist/chunk-LYNNZEQD.js.map +1 -0
  51. package/dist/{chunk-26NK23DZ.js → chunk-M45IRXDM.js} +3 -3
  52. package/dist/{chunk-CXJG63MA.js → chunk-NP6EZT44.js} +20 -6
  53. package/dist/chunk-NP6EZT44.js.map +1 -0
  54. package/dist/{chunk-GNHAC43Q.js → chunk-O53RIZCC.js} +5 -5
  55. package/dist/chunk-OPDTLHFA.js +783 -0
  56. package/dist/chunk-OPDTLHFA.js.map +1 -0
  57. package/dist/{chunk-LSTBFLL2.js → chunk-P3Z5Y2TS.js} +2 -2
  58. package/dist/{chunk-QSOYKKMD.js → chunk-P4EDT5ZP.js} +2 -2
  59. package/dist/{chunk-PC6ZEDRL.js → chunk-RHQYVHFH.js} +2 -2
  60. package/dist/{chunk-3LPV6BXR.js → chunk-RRDWXNBQ.js} +3 -3
  61. package/dist/{chunk-4CLICFEY.js → chunk-SJJQKNMP.js} +4 -4
  62. package/dist/{chunk-TY32C732.js → chunk-SZ4N3IL5.js} +5 -5
  63. package/dist/{chunk-4USCAEDT.js → chunk-TMHJEYW7.js} +502 -60
  64. package/dist/chunk-TMHJEYW7.js.map +1 -0
  65. package/dist/{chunk-2N62W5YP.js → chunk-UA6G45ME.js} +3 -3
  66. package/dist/{chunk-6YLPHBKR.js → chunk-UOC7JMZO.js} +13 -4
  67. package/dist/chunk-UOC7JMZO.js.map +1 -0
  68. package/dist/{chunk-DAP2XL7Q.js → chunk-VOXMU6LB.js} +2 -2
  69. package/dist/chunk-WNRGOVLG.js +64 -0
  70. package/dist/chunk-WNRGOVLG.js.map +1 -0
  71. package/dist/{chunk-DJRWA3Q5.js → chunk-WUG3E423.js} +4 -4
  72. package/dist/{chunk-PM3QYWUU.js → chunk-XHM2SARW.js} +3 -3
  73. package/dist/{chunk-RC6SU5NO.js → chunk-XSIFXX54.js} +2 -2
  74. package/dist/{chunk-CXFOITNS.js → chunk-ZC7MNVYN.js} +2 -2
  75. package/dist/{chunk-6T2UDBKG.js → chunk-ZCFS7U4J.js} +2 -2
  76. package/dist/consent/index.cjs.map +1 -1
  77. package/dist/consent/index.d.cts +4 -4
  78. package/dist/consent/index.d.ts +4 -4
  79. package/dist/consent/index.js +3 -3
  80. package/dist/{crypto-2CRLG4F4.js → crypto-AJB72OKN.js} +3 -3
  81. package/dist/{delegation-ZTRT2PRV.js → delegation-6FCWDRUS.js} +5 -5
  82. package/dist/derivations/index.cjs.map +1 -1
  83. package/dist/derivations/index.d.cts +5 -5
  84. package/dist/derivations/index.d.ts +5 -5
  85. package/dist/derivations/index.js +4 -4
  86. package/dist/{dev-unlock-BOEYl1xl.d.ts → dev-unlock-D3mpVFRc.d.ts} +1 -1
  87. package/dist/{dev-unlock-AglVnkPY.d.cts → dev-unlock-ckqa_Nso.d.cts} +1 -1
  88. package/dist/executor-7KSCEIFA.js +8 -0
  89. package/dist/executor-D2QMNGRJ.js +8 -0
  90. package/dist/executor-O5AZK7UW.js +11 -0
  91. package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-ZSKEQ6NI.js} +2 -2
  92. package/dist/guards/index.cjs +53 -1
  93. package/dist/guards/index.cjs.map +1 -1
  94. package/dist/guards/index.d.cts +12 -6
  95. package/dist/guards/index.d.ts +12 -6
  96. package/dist/guards/index.js +5 -3
  97. package/dist/{hash-B9m3_fhj.d.ts → hash-CTZVkXLx.d.ts} +1 -1
  98. package/dist/{hash-RVqz2zi8.d.cts → hash-rDSSd_oW.d.cts} +1 -1
  99. package/dist/history/index.cjs.map +1 -1
  100. package/dist/history/index.d.cts +5 -5
  101. package/dist/history/index.d.ts +5 -5
  102. package/dist/history/index.js +5 -5
  103. package/dist/i18n/index.cjs.map +1 -1
  104. package/dist/i18n/index.d.cts +4 -4
  105. package/dist/i18n/index.d.ts +4 -4
  106. package/dist/i18n/index.js +6 -6
  107. package/dist/immutable-guard-C51vAHuh.d.cts +67 -0
  108. package/dist/immutable-guard-DyD0qg2k.d.ts +67 -0
  109. package/dist/index-CkFHr4OP.d.ts +1190 -0
  110. package/dist/index-Cmop06zJ.d.cts +1190 -0
  111. package/dist/index.cjs +1636 -61
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +46 -13
  114. package/dist/index.d.ts +46 -13
  115. package/dist/index.js +76 -44
  116. package/dist/index.js.map +1 -1
  117. package/dist/indexing/index.cjs.map +1 -1
  118. package/dist/indexing/index.js +2 -2
  119. package/dist/issue-YIYG4OW5.js +12 -0
  120. package/dist/{ledger-O7FXOG3D.js → ledger-5JMVF7PY.js} +5 -5
  121. package/dist/materialized-views/index.cjs.map +1 -1
  122. package/dist/materialized-views/index.d.cts +5 -6
  123. package/dist/materialized-views/index.d.ts +5 -6
  124. package/dist/materialized-views/index.js +6 -6
  125. package/dist/noydb-D5SLAJ6V.js +34 -0
  126. package/dist/overlay-views/index.cjs.map +1 -1
  127. package/dist/overlay-views/index.d.cts +5 -5
  128. package/dist/overlay-views/index.d.ts +5 -5
  129. package/dist/overlay-views/index.js +4 -4
  130. package/dist/periods/index.cjs.map +1 -1
  131. package/dist/periods/index.d.cts +4 -4
  132. package/dist/periods/index.d.ts +4 -4
  133. package/dist/periods/index.js +5 -5
  134. package/dist/{public-envelope-HMYHZIRH.js → public-envelope-PFLZI5MO.js} +4 -4
  135. package/dist/query/index.cjs +293 -10
  136. package/dist/query/index.cjs.map +1 -1
  137. package/dist/query/index.d.cts +2 -2
  138. package/dist/query/index.d.ts +2 -2
  139. package/dist/query/index.js +4 -4
  140. package/dist/registry-BVQ5ITMF.js +8 -0
  141. package/dist/registry-JLP3QOLD.js +8 -0
  142. package/dist/{registry-ST2VNFZC.js → registry-NCY445U5.js} +3 -3
  143. package/dist/{revoke-S6JMSLUN.js → revoke-7RLGQWZ7.js} +6 -6
  144. package/dist/session/index.cjs.map +1 -1
  145. package/dist/session/index.d.cts +5 -5
  146. package/dist/session/index.d.ts +5 -5
  147. package/dist/session/index.js +3 -3
  148. package/dist/shadow/index.cjs.map +1 -1
  149. package/dist/shadow/index.d.cts +4 -4
  150. package/dist/shadow/index.d.ts +4 -4
  151. package/dist/shadow/index.js +2 -2
  152. package/dist/{signer-7NPTB3SQ.js → signer-6JF44I4A.js} +5 -5
  153. package/dist/snapshots/index.cjs.map +1 -1
  154. package/dist/snapshots/index.d.cts +4 -4
  155. package/dist/snapshots/index.d.ts +4 -4
  156. package/dist/snapshots/index.js +4 -4
  157. package/dist/{stale-VKXSXJF4.js → stale-UBLP3RJ3.js} +2 -2
  158. package/dist/store/index.cjs.map +1 -1
  159. package/dist/store/index.d.cts +4 -4
  160. package/dist/store/index.d.ts +4 -4
  161. package/dist/store/index.js +2 -2
  162. package/dist/strategy-rtpKDfTC.d.cts +2029 -0
  163. package/dist/strategy-rtpKDfTC.d.ts +2029 -0
  164. package/dist/sync/index.cjs.map +1 -1
  165. package/dist/sync/index.d.cts +3 -3
  166. package/dist/sync/index.d.ts +3 -3
  167. package/dist/sync/index.js +4 -4
  168. package/dist/team/index.cjs.map +1 -1
  169. package/dist/team/index.d.cts +4 -4
  170. package/dist/team/index.d.ts +4 -4
  171. package/dist/team/index.js +8 -8
  172. package/dist/tx/index.cjs +8 -1
  173. package/dist/tx/index.cjs.map +1 -1
  174. package/dist/tx/index.d.cts +4 -4
  175. package/dist/tx/index.d.ts +4 -4
  176. package/dist/tx/index.js +3 -3
  177. package/dist/{types-n2_IfwlQ.d.cts → types-BGwjsDef.d.cts} +520 -6
  178. package/dist/{types-CaNQm4i8.d.ts → types-DRdfwgTG.d.ts} +520 -6
  179. package/dist/{ulid-CLMjmyhG.d.cts → ulid-D4d0Xto3.d.cts} +1 -1
  180. package/dist/{ulid-B9SMWj5i.d.ts → ulid-DOTPZ5_h.d.ts} +1 -1
  181. package/dist/util/index.cjs.map +1 -1
  182. package/dist/util/index.js +1 -1
  183. package/dist/vault-group-Z4KB75ZH.js +450 -0
  184. package/dist/vault-group-Z4KB75ZH.js.map +1 -0
  185. package/dist/{with-derivation-CVIOPTUf.d.ts → with-derivation-B082Y_WQ.d.ts} +1 -1
  186. package/dist/{with-derivation-aKrtS7Jj.d.cts → with-derivation-CB1EdcFF.d.cts} +1 -1
  187. package/dist/{with-materialized-view-C1eA1_T_.d.cts → with-materialized-view-CzRg1Dpr.d.cts} +1 -1
  188. package/dist/{with-materialized-view-DaYaE8-Q.d.ts → with-materialized-view-Dw4SwjKl.d.ts} +1 -1
  189. package/dist/{with-overlayed-view-DleJfKcV.d.cts → with-overlayed-view-C9YFKXzn.d.cts} +1 -1
  190. package/dist/{with-overlayed-view-DQsh2p8H.d.ts → with-overlayed-view-CaCXeW26.d.ts} +1 -1
  191. package/package.json +3 -3
  192. package/dist/chunk-2LPPNWF6.js +0 -340
  193. package/dist/chunk-2LPPNWF6.js.map +0 -1
  194. package/dist/chunk-4USCAEDT.js.map +0 -1
  195. package/dist/chunk-6YLPHBKR.js.map +0 -1
  196. package/dist/chunk-C3WE6UJY.js +0 -19
  197. package/dist/chunk-C3WE6UJY.js.map +0 -1
  198. package/dist/chunk-CXJG63MA.js.map +0 -1
  199. package/dist/chunk-DRXIZOFV.js.map +0 -1
  200. package/dist/chunk-HQSQC2XL.js.map +0 -1
  201. package/dist/chunk-O6EJ6WTI.js.map +0 -1
  202. package/dist/chunk-PVUUIWHY.js.map +0 -1
  203. package/dist/chunk-WIRRPTFH.js.map +0 -1
  204. package/dist/executor-S76VN45G.js +0 -8
  205. package/dist/executor-UCXLIGLW.js +0 -11
  206. package/dist/executor-ZCNZJMGR.js +0 -8
  207. package/dist/index-B8bjExET.d.cts +0 -2434
  208. package/dist/index-DfUbNad8.d.ts +0 -2434
  209. package/dist/issue-3W6IVLKH.js +0 -12
  210. package/dist/noydb-YAZNH5TI.js +0 -34
  211. package/dist/registry-UFIK7CSR.js +0 -8
  212. package/dist/registry-ZGYYSM5I.js +0 -8
  213. package/dist/strategy-CT2LCKAX.d.cts +0 -613
  214. package/dist/strategy-CT2LCKAX.d.ts +0 -613
  215. package/dist/with-guard-DZQbPzoP.d.cts +0 -18
  216. package/dist/with-guard-DseETUrF.d.ts +0 -18
  217. /package/dist/{chunk-7CEGU63S.js.map → chunk-4BHFNKTP.js.map} +0 -0
  218. /package/dist/{chunk-5OEJ6GOT.js.map → chunk-5ARRXIVR.js.map} +0 -0
  219. /package/dist/{chunk-YM7LFCG7.js.map → chunk-6BYBVRZU.js.map} +0 -0
  220. /package/dist/{chunk-5IXJGFF2.js.map → chunk-7JJE3OMJ.js.map} +0 -0
  221. /package/dist/{chunk-HHOO7HGH.js.map → chunk-7LVRIW4G.js.map} +0 -0
  222. /package/dist/{chunk-IMYKDWB4.js.map → chunk-B7GGYNKQ.js.map} +0 -0
  223. /package/dist/{chunk-BDV7INMP.js.map → chunk-BXOUVUES.js.map} +0 -0
  224. /package/dist/{chunk-FO3UEG4S.js.map → chunk-C2CIIQRG.js.map} +0 -0
  225. /package/dist/{chunk-ZROPXHJY.js.map → chunk-CHBXWJZQ.js.map} +0 -0
  226. /package/dist/{chunk-RYIL3PI2.js.map → chunk-CILT6V3V.js.map} +0 -0
  227. /package/dist/{chunk-PXTQPZO4.js.map → chunk-DLTU4M2I.js.map} +0 -0
  228. /package/dist/{chunk-GAUEWM7D.js.map → chunk-EKNUBIIQ.js.map} +0 -0
  229. /package/dist/{chunk-6EOXTJS2.js.map → chunk-HBAJDI2N.js.map} +0 -0
  230. /package/dist/{chunk-RRNA5GKT.js.map → chunk-IEPT7HVP.js.map} +0 -0
  231. /package/dist/{chunk-R233SLY3.js.map → chunk-IUBHXEPJ.js.map} +0 -0
  232. /package/dist/{chunk-CH22FZHT.js.map → chunk-L6BYRCYB.js.map} +0 -0
  233. /package/dist/{chunk-5OX6XVNS.js.map → chunk-LOA2VCMS.js.map} +0 -0
  234. /package/dist/{chunk-BB27JMWB.js.map → chunk-LSEW3ZZ2.js.map} +0 -0
  235. /package/dist/{chunk-Y26YV5R3.js.map → chunk-LWSD4QPT.js.map} +0 -0
  236. /package/dist/{chunk-26NK23DZ.js.map → chunk-M45IRXDM.js.map} +0 -0
  237. /package/dist/{chunk-GNHAC43Q.js.map → chunk-O53RIZCC.js.map} +0 -0
  238. /package/dist/{chunk-LSTBFLL2.js.map → chunk-P3Z5Y2TS.js.map} +0 -0
  239. /package/dist/{chunk-QSOYKKMD.js.map → chunk-P4EDT5ZP.js.map} +0 -0
  240. /package/dist/{chunk-PC6ZEDRL.js.map → chunk-RHQYVHFH.js.map} +0 -0
  241. /package/dist/{chunk-3LPV6BXR.js.map → chunk-RRDWXNBQ.js.map} +0 -0
  242. /package/dist/{chunk-4CLICFEY.js.map → chunk-SJJQKNMP.js.map} +0 -0
  243. /package/dist/{chunk-TY32C732.js.map → chunk-SZ4N3IL5.js.map} +0 -0
  244. /package/dist/{chunk-2N62W5YP.js.map → chunk-UA6G45ME.js.map} +0 -0
  245. /package/dist/{chunk-DAP2XL7Q.js.map → chunk-VOXMU6LB.js.map} +0 -0
  246. /package/dist/{chunk-DJRWA3Q5.js.map → chunk-WUG3E423.js.map} +0 -0
  247. /package/dist/{chunk-PM3QYWUU.js.map → chunk-XHM2SARW.js.map} +0 -0
  248. /package/dist/{chunk-RC6SU5NO.js.map → chunk-XSIFXX54.js.map} +0 -0
  249. /package/dist/{chunk-CXFOITNS.js.map → chunk-ZC7MNVYN.js.map} +0 -0
  250. /package/dist/{chunk-6T2UDBKG.js.map → chunk-ZCFS7U4J.js.map} +0 -0
  251. /package/dist/{crypto-2CRLG4F4.js.map → crypto-AJB72OKN.js.map} +0 -0
  252. /package/dist/{delegation-ZTRT2PRV.js.map → delegation-6FCWDRUS.js.map} +0 -0
  253. /package/dist/{executor-S76VN45G.js.map → executor-7KSCEIFA.js.map} +0 -0
  254. /package/dist/{executor-UCXLIGLW.js.map → executor-D2QMNGRJ.js.map} +0 -0
  255. /package/dist/{executor-ZCNZJMGR.js.map → executor-O5AZK7UW.js.map} +0 -0
  256. /package/dist/{fanout-sidecar-OKPMMPLG.js.map → fanout-sidecar-ZSKEQ6NI.js.map} +0 -0
  257. /package/dist/{issue-3W6IVLKH.js.map → issue-YIYG4OW5.js.map} +0 -0
  258. /package/dist/{ledger-O7FXOG3D.js.map → ledger-5JMVF7PY.js.map} +0 -0
  259. /package/dist/{noydb-YAZNH5TI.js.map → noydb-D5SLAJ6V.js.map} +0 -0
  260. /package/dist/{public-envelope-HMYHZIRH.js.map → public-envelope-PFLZI5MO.js.map} +0 -0
  261. /package/dist/{registry-ST2VNFZC.js.map → registry-BVQ5ITMF.js.map} +0 -0
  262. /package/dist/{registry-UFIK7CSR.js.map → registry-JLP3QOLD.js.map} +0 -0
  263. /package/dist/{registry-ZGYYSM5I.js.map → registry-NCY445U5.js.map} +0 -0
  264. /package/dist/{revoke-S6JMSLUN.js.map → revoke-7RLGQWZ7.js.map} +0 -0
  265. /package/dist/{signer-7NPTB3SQ.js.map → signer-6JF44I4A.js.map} +0 -0
  266. /package/dist/{stale-VKXSXJF4.js.map → stale-UBLP3RJ3.js.map} +0 -0
@@ -1,613 +0,0 @@
1
- /**
2
- * Aggregation reducers for the query DSL.
3
- *
4
- * the reducer protocol plus five built-in factories
5
- * (`count`, `sum`, `avg`, `min`, `max`) consumed by `Query.aggregate()`
6
- * and, in the future, `Scan.aggregate()`. Every factory accepts
7
- * an optional `{ seed }` parameter that is plumbed through the
8
- * protocol but unused by the executor — that's the load-bearing
9
- * half of constraint #2. When partition-aware aggregation
10
- * lands, the seed carries the previous partition's running total into
11
- * the next partition without requiring a protocol change.
12
- *
13
- * Reducers are intentionally generic over their internal state type
14
- * `S` so compound reducers (avg keeps `{sum, count}`, min/max keep a
15
- * value bag) can model internal bookkeeping without leaking the
16
- * implementation through the accumulator's public shape. `finalize`
17
- * collapses `S` back into the user-visible `R`.
18
- *
19
- * Reducers are pure data — `init` / `step` / `finalize` / optional
20
- * `remove` are stateless functions that receive and return `S`. This
21
- * is the shape that admits O(1) incremental maintenance in a future
22
- * optimization (delta-aware `LiveAggregation` applies `step` or
23
- * `remove` per delta), without blocking the simpler "full re-run on
24
- * source change" that ships.
25
- */
26
- /**
27
- * A single reducer: factory-produced, ready to plug into an
28
- * `.aggregate()` spec.
29
- *
30
- * Type parameters:
31
- * - `R` — user-visible result type (what the aggregation returns
32
- * for this slot, e.g. `number` for `sum()`)
33
- * - `S` — internal state type, defaults to `R` for simple reducers
34
- * that don't need compound bookkeeping
35
- *
36
- * A reducer is stateless: every method is pure over `S`. `init()` is
37
- * called once per aggregation run to build the initial state; `step()`
38
- * folds a record into the state; `remove()` (optional) un-folds a
39
- * record, enabling incremental live maintenance; `finalize()` reads
40
- * the final answer out of the state at the end of the run.
41
- */
42
- interface Reducer<R, S = R> {
43
- /** Build the initial state for a fresh aggregation run. */
44
- init(): S;
45
- /** Fold a record into the state. Returns the new state. */
46
- step(state: S, record: unknown): S;
47
- /**
48
- * Un-fold a record from the state. Returns the new state.
49
- *
50
- * Optional — reducers without `remove` cannot be maintained
51
- * incrementally and must be re-run from scratch when the underlying
52
- * record set changes. `sum`, `count`, `avg` implement `remove` in
53
- * O(1); `min` and `max` implement it in O(N) worst case (when the
54
- * extremum itself is removed and the next extremum must be
55
- * recomputed from the remaining contributing values).
56
- */
57
- remove?(state: S, record: unknown): S;
58
- /** Collapse the internal state into the user-visible result. */
59
- finalize(state: S): R;
60
- /**
61
- * Identifying operation tag stamped by each built-in factory.
62
- * Used by `summariseAggregateOp` in the introspection walker to
63
- * render human-readable aggregate descriptors in `dumpSchema()`.
64
- * Optional so third-party custom reducers are unaffected.
65
- */
66
- readonly op?: 'count' | 'sum' | 'avg' | 'min' | 'max';
67
- /**
68
- * Field name for field-based reducers (`sum`, `avg`, `min`, `max`).
69
- * Absent on `count` which aggregates over record count, not a field.
70
- */
71
- readonly field?: string;
72
- }
73
- /**
74
- * Common options accepted by every reducer factory.
75
- *
76
- * `seed` — optional initial value for the internal state. **Unused by
77
- * the executor**, plumbed through the protocol for constraint
78
- * #2 (partition-aware aggregation seam). In, partitioned
79
- * aggregations will pass the previous partition's carry as `seed` so
80
- * a long time series can be rolled forward one partition at a time
81
- * without re-aggregating closed partitions.
82
- *
83
- * always uses `init()` with the factory's zero value, regardless
84
- * of whether `seed` was passed. Do not remove the parameter — that's
85
- * the whole point of having it exist now.
86
- */
87
- interface ReducerOptions<TSeed = unknown> {
88
- /** constraint #2 — seed is plumbed through but unused in. */
89
- readonly seed?: TSeed;
90
- }
91
- /**
92
- * Count the number of records that match the query. Ignores field
93
- * values entirely — the count is over the number of records, not over
94
- * the number of non-null field values in any column.
95
- */
96
- declare function count(opts?: ReducerOptions<number>): Reducer<number>;
97
- /**
98
- * Sum a numeric field across all matching records. Non-number values
99
- * at the field path are coerced to 0 — consumers who want a different
100
- * behavior (throw, skip, treat as NaN) should filter upstream via
101
- * `.where()` or write a custom reducer.
102
- */
103
- declare function sum(field: string, opts?: ReducerOptions<number>): Reducer<number>;
104
- /**
105
- * Arithmetic mean of a numeric field across all matching records.
106
- *
107
- * Returns `null` for an empty result set (zero records is not a
108
- * well-defined denominator — returning NaN would poison downstream
109
- * arithmetic, and throwing would force every consumer to wrap in
110
- * try/catch just to handle "no matches"). Consumers who want an
111
- * explicit zero should coalesce with `?? 0`.
112
- *
113
- * Internal state is `{sum, count}` so the running average can be
114
- * maintained incrementally — on each delta, both fields update in
115
- * O(1) and `finalize` divides. Directly storing `avg` as state would
116
- * not admit incremental removal without also tracking count.
117
- */
118
- declare function avg(field: string, opts?: ReducerOptions<{
119
- sum: number;
120
- count: number;
121
- }>): Reducer<number | null, {
122
- sum: number;
123
- count: number;
124
- }>;
125
- interface MinMaxState {
126
- /**
127
- * Multiset of contributing field values. Stored as a plain array
128
- * because we need to support `remove` and a plain array gives us
129
- * O(1) push + O(N) worst-case removal — which matches the
130
- * documented min/max removal complexity. A sorted structure would
131
- * let us drop the O(N) rescan but adds complexity that doesn't
132
- * need; consumers hitting the O(N) ceiling should file an issue.
133
- */
134
- readonly values: number[];
135
- }
136
- /**
137
- * Smallest numeric value of a field across all matching records.
138
- * Returns `null` for an empty result set. See `avg()` for the
139
- * reasoning on `null` vs NaN vs throwing.
140
- *
141
- * Incremental complexity: O(1) for `step`, O(N) worst case for
142
- * `remove` when the current minimum is removed (the state holds the
143
- * full multiset of contributing values and `finalize` scans for the
144
- * new minimum). Consumers with very large result sets and frequent
145
- * removals of the current extremum should either accept the cost or
146
- * wait for a future optimization.
147
- */
148
- declare function min(field: string, opts?: ReducerOptions<number>): Reducer<number | null, MinMaxState>;
149
- /**
150
- * Largest numeric value of a field across all matching records.
151
- * Mirror of `min()` — see that doc for semantics, null-on-empty
152
- * behavior, and the O(N) removal caveat.
153
- */
154
- declare function max(field: string, opts?: ReducerOptions<number>): Reducer<number | null, MinMaxState>;
155
-
156
- /**
157
- * Aggregate execution — the runtime behind `Query.aggregate()`.
158
- *
159
- * takes an `AggregateSpec` (a record of named reducers
160
- * built from `reducers.ts`) and runs every reducer over the records
161
- * produced by the underlying query. Two terminal surfaces:
162
- *
163
- * - `.run(): R` — synchronous one-shot reduction. Matches the
164
- * existing `Query.toArray()` / `.first()` / `.count()` style.
165
- * - `.live(): LiveAggregation<R>` — reactive primitive that
166
- * re-runs the reduction whenever the query's source notifies of
167
- * a change. uses naive full re-run; incremental delta
168
- * maintenance is admitted by the reducer protocol (`remove()`)
169
- * but not wired to the executor yet — a follow-up optimization
170
- * can switch from full re-run to delta-based without breaking
171
- * the public API. Consumers get correct, reactive values today.
172
- *
173
- * The `Aggregation<R>` wrapper is deliberately tiny — it exists so
174
- * `.aggregate(spec)` can be chained with either `.run()` or `.live()`
175
- * without the builder needing two separate terminal methods. It
176
- * holds the closure over the query execution (produces the current
177
- * matching record set) and the spec, and stitches them together in
178
- * either mode.
179
- *
180
- * This file depends ONLY on `reducers.ts` — it has no knowledge of
181
- * the `Query` class. Tests can therefore exercise the reduction
182
- * surface with plain record arrays, without spinning up a Collection.
183
- */
184
-
185
- /**
186
- * A named set of reducers, keyed by output field name. Each key
187
- * becomes a field on the aggregated result.
188
- *
189
- * ```ts
190
- * const spec = {
191
- * total: sum('amount'),
192
- * n: count(),
193
- * avgAmount: avg('amount'),
194
- * }
195
- * ```
196
- */
197
- type AggregateSpec = Readonly<Record<string, Reducer<unknown, unknown>>>;
198
- /**
199
- * Map an `AggregateSpec` to its reduced result shape — each key
200
- * carries the finalized result type from its reducer. A spec built
201
- * from `{ total: sum('amount'), n: count() }` yields a result of
202
- * `{ total: number, n: number }`.
203
- *
204
- * This uses a mapped type with a conditional to extract `R` from
205
- * each `Reducer<R, _>`. The `infer` captures the user-visible result
206
- * type, discarding the internal state type `S`.
207
- */
208
- type AggregateResult<Spec extends AggregateSpec> = {
209
- [K in keyof Spec]: Spec[K] extends Reducer<infer R, unknown> ? R : never;
210
- };
211
- /**
212
- * Pure reduction over a record array. Runs every reducer's
213
- * `init → step* → finalize` pipeline exactly once over the records.
214
- *
215
- * Called by `Aggregation.run()` and by the live-mode refresh path.
216
- * Exported for tests and for future `scan().aggregate()` reuse
217
- * — the streaming path will call the same reducer protocol with a
218
- * per-page loop instead of a single array.
219
- */
220
- declare function reduceRecords<Spec extends AggregateSpec>(records: readonly unknown[], spec: Spec): AggregateResult<Spec>;
221
- /**
222
- * A minimal reactive primitive for aggregation results.
223
- *
224
- * Same spirit as the `LiveQuery` in : frame-agnostic, a plain
225
- * object with `value` / `error` fields and a `subscribe(cb)`
226
- * notification channel that Vue / React / Solid adapters wrap in
227
- * their own primitive. Intentionally NOT a Promise — aggregations
228
- * have a well-defined "current value" at every instant, and the
229
- * reactive consumer wants to read that value synchronously.
230
- *
231
- * Error semantics mirror `LiveQuery`: if a re-run throws, the
232
- * previous successful `value` is preserved and the error is stored
233
- * in `error` so consumers can render an error state without losing
234
- * the last-known-good result. The throw does NOT propagate out of
235
- * the source's change handler (which would tear down the upstream
236
- * emitter).
237
- *
238
- * `stop()` tears down the upstream subscription. It is idempotent —
239
- * calling it multiple times is safe — and subscribe calls after
240
- * stop are no-ops (they immediately return a no-op unsubscribe).
241
- * Always call `stop()` when done; Vue's `onUnmounted` is the
242
- * canonical place. Raw consumers must do it themselves.
243
- */
244
- interface LiveAggregation<R> {
245
- /** Current reduced value. Undefined only if the first compute threw. */
246
- readonly value: R | undefined;
247
- /** Last execution error, if any. Cleared on the next successful run. */
248
- readonly error: unknown;
249
- /** Notify on every recomputation (success or error). Returns unsubscribe. */
250
- subscribe(cb: () => void): () => void;
251
- /** Tear down the upstream subscription. Idempotent. */
252
- stop(): void;
253
- }
254
- /**
255
- * Upstream change-notification hook for live aggregation.
256
- *
257
- * Matches the shape that `QuerySource.subscribe` already uses — a
258
- * single method that accepts a callback and returns an unsubscribe
259
- * function. The `Aggregation` wrapper collects upstreams from the
260
- * query's source and wires them into a single re-run trigger.
261
- */
262
- interface AggregationUpstream {
263
- subscribe(cb: () => void): () => void;
264
- }
265
- /**
266
- * Chainable wrapper returned by `Query.aggregate(spec)`. Holds the
267
- * execute-records closure and the spec; terminal methods (`run`,
268
- * `live`) stitch them together in either mode.
269
- *
270
- * Why a wrapper instead of two terminal methods on `Query` directly?
271
- *
272
- * The `.aggregate(spec)` call is where the spec is bound — both
273
- * `.run()` and `.live()` need the same spec, and the consumer's
274
- * fluent style is `query.where(...).aggregate(spec).run()` or
275
- * `.aggregate(spec).live()`. Wrapping lets the spec be named once
276
- * and reused for either terminal, and keeps the `Query` class
277
- * from growing a pair of near-duplicate method overloads
278
- * (`aggregateRun` / `aggregateLive`) that would be harder to
279
- * discover.
280
- */
281
- declare class Aggregation<R> {
282
- private readonly executeRecords;
283
- private readonly spec;
284
- private readonly upstreams;
285
- constructor(executeRecords: () => readonly unknown[], spec: AggregateSpec, upstreams: readonly AggregationUpstream[]);
286
- /**
287
- * Execute the query and reduce the results synchronously.
288
- * Returns the reduced shape matching the spec — e.g. a spec of
289
- * `{ total: sum('amount'), n: count() }` returns
290
- * `{ total: number, n: number }`.
291
- */
292
- run(): R;
293
- /**
294
- * Build a reactive `LiveAggregation<R>` that re-runs the reduction
295
- * whenever any upstream source notifies of a change. The initial
296
- * value is computed eagerly in the constructor, so consumers can
297
- * read `live.value` immediately after calling `.live()`.
298
- *
299
- * Always call `live.stop()` when finished — it tears down the
300
- * upstream subscriptions. Vue's `onUnmounted` is the canonical
301
- * place.
302
- *
303
- * **Implementation note:** every upstream change triggers a full
304
- * re-reduction. Incremental maintenance (O(1) per delta for
305
- * sum/count/avg via the reducer protocol's `remove()` method) is a
306
- * planned follow-up optimization — the protocol already supports
307
- * it, but the executor doesn't drive it yet. Consumers get
308
- * correct, reactive values today; future PRs can switch to
309
- * delta-based maintenance without changing this API.
310
- */
311
- live(): LiveAggregation<R>;
312
- }
313
- /**
314
- * Build a `LiveAggregation<V>` from a recompute closure and a list
315
- * of upstreams. Exposed so sibling files in the query DSL
316
- * (currently `groupby.ts`) can reuse the reactive primitive
317
- * without reaching into `LiveAggregationImpl` directly. This keeps
318
- * the implementation class private while still allowing planned
319
- * composition with `.groupBy().aggregate().live()`.
320
- */
321
- declare function buildLiveAggregation<V>(recompute: () => V, upstreams: readonly AggregationUpstream[]): LiveAggregation<V>;
322
-
323
- /**
324
- * Query DSL `.groupBy()` —.
325
- *
326
- * Chains after `.where()` / `.filter()` / `.or()` / `.and()` on a
327
- * Query and before a reducer spec, so consumers can compute
328
- * per-bucket aggregates without folding in userland:
329
- *
330
- * ```ts
331
- * const byClient = invoices.query()
332
- * .where('status', '==', 'open')
333
- * .groupBy('clientId')
334
- * .aggregate({ total: sum('amount'), n: count() })
335
- * .run()
336
- * // → [ { clientId: 'c1', total: 5250, n: 3 }, … ]
337
- * ```
338
- *
339
- * Execution pipeline:
340
- *
341
- * 1. Run the query's where/filter clauses (same candidate /
342
- * filter pipeline as `.aggregate()` directly on Query).
343
- * 2. Partition the matching records into buckets keyed by
344
- * `readPath(record, field)`. JS `Map` preserves insertion
345
- * order, so the first-seen key for a bucket determines its
346
- * position in the result array — consumers who want a
347
- * specific ordering should `.sort()` downstream.
348
- * 3. Enforce cardinality: warn once per field at 10% of the cap
349
- * (10_000 buckets), throw `GroupCardinalityError` at 100% of
350
- * the cap (100_000 buckets).
351
- * 4. For each bucket, build a per-group reducer state and
352
- * step every record in the bucket through it.
353
- * 5. Emit one result row per bucket, shaped as
354
- * `{ [field]: key, ...reduced }`.
355
- *
356
- * **Null / undefined keys:** `Map` distinguishes `null` from
357
- * `undefined`, so records with a missing group field get their own
358
- * bucket, and records with an explicit `null` value get a separate
359
- * bucket from that. Consumers who want them merged can coalesce
360
- * upstream with `.filter()`.
361
- *
362
- * **Live mode:** `.groupBy().aggregate().live()` re-runs the full
363
- * grouping pipeline on every source change. Per-bucket incremental
364
- * delta maintenance is a future optimization — the reducer
365
- * protocol's `remove()` hook admits it, but ships naive
366
- * re-grouping for simplicity.
367
- *
368
- * **Type-level stable-key narrowing:** when
369
- * `dictKey` lands, `groupBy<DictField>()` will narrow the group key
370
- * type to the stable dictionary key rather than the resolved locale
371
- * label. That prevents grouping by the locale-resolved label,
372
- * which would produce different buckets per reader. types the
373
- * key as `unknown` at the result shape; the dictKey narrowing
374
- * layers on top without an API break.
375
- *
376
- * Partition-awareness seam: when partitioned collections land,
377
- * per-partition grouping will need to merge sub-results across
378
- * partitions. The reducer protocol's `{ seed }` parameter
379
- * (already plumbed through in `reducers.ts`) is the mechanism —
380
- * groupBy doesn't need its own seam for the moment, because it
381
- * delegates to the reducer protocol for all per-bucket state.
382
- */
383
-
384
- /**
385
- * Cardinality thresholds for `.groupBy()`. The warn threshold gives
386
- * consumers a heads-up before the hard error; the cap is a fixed
387
- * constant in (not overridable). A `{ maxGroups }` override
388
- * can be added later without a break if a real consumer asks.
389
- */
390
- declare const GROUPBY_WARN_CARDINALITY = 10000;
391
- declare const GROUPBY_MAX_CARDINALITY = 100000;
392
- /**
393
- * Test-only: clear the per-field cardinality warning dedup between
394
- * tests. Production code never calls this — matching the
395
- * `resetJoinWarnings` pattern in `join.ts`.
396
- */
397
- declare function resetGroupByWarnings(): void;
398
- /**
399
- * Result row shape for a grouped aggregation. Each row carries the
400
- * group key value under the grouping field name plus every reducer
401
- * output from the spec.
402
- *
403
- * types the group key as `unknown` at the result shape — the
404
- * runtime read via `readPath` can return any value, and narrowing
405
- * to a specific type would require the caller to assert at the
406
- * call site. `dictKey` narrowing layers on top of this by
407
- * adding an overload that constrains `F` when the grouping field
408
- * is a `dictKey`.
409
- */
410
- type GroupedRow<F extends string, R> = {
411
- [K in F]: unknown;
412
- } & R;
413
- /**
414
- * Multi-key variant — result-row shape for variadic
415
- * `.groupBy(...fields)`. Every grouped field name appears on the row
416
- * (typed as `unknown` for the same reason as `GroupedRow`), plus the
417
- * reducer outputs from the spec.
418
- */
419
- type GroupedRowN<F extends readonly string[], R> = {
420
- [K in F[number]]: unknown;
421
- } & R;
422
- /**
423
- * Shared base class for the chainable grouped-query wrappers. Holds
424
- * the constructor + protected fields that both single-key
425
- * `GroupedQuery<T, F>` and variadic `GroupedQueryN<T, F>` need; each
426
- * subclass only overrides `aggregate()` with its own result-row
427
- * generic.
428
- *
429
- * Not exported — implementation detail. Adding `.having()` /
430
- * `.live()` / `.orderByGroup()` etc. in the future lands here once
431
- * and both subclasses pick it up automatically.
432
- *
433
- * @internal
434
- */
435
- declare abstract class GroupedQueryBase {
436
- protected readonly executeRecords: () => readonly unknown[];
437
- protected readonly upstreams: readonly AggregationUpstream[];
438
- /**
439
- * Optional dict label resolver attached by the query builder when
440
- * the grouping field is a dictKey. Variadic groupings always pass
441
- * `undefined` — `<field>Label` projection has no meaningful shape
442
- * for composite keys.
443
- */
444
- protected readonly dictLabelResolver?: ((key: string, locale: string, fallback?: string | readonly string[]) => Promise<string | undefined>) | undefined;
445
- /**
446
- * Field set this grouped query buckets on. Stored in declaration
447
- * order — the same order is preserved on every result row by
448
- * `groupAndReduce`. For the single-field constructor, this is
449
- * `[field]`.
450
- */
451
- protected readonly fields: readonly string[];
452
- constructor(executeRecords: () => readonly unknown[], fieldOrFields: string | readonly string[], upstreams: readonly AggregationUpstream[],
453
- /**
454
- * Optional dict label resolver attached by the query builder when
455
- * the grouping field is a dictKey. Variadic groupings always pass
456
- * `undefined` — `<field>Label` projection has no meaningful shape
457
- * for composite keys.
458
- */
459
- dictLabelResolver?: ((key: string, locale: string, fallback?: string | readonly string[]) => Promise<string | undefined>) | undefined);
460
- }
461
- /**
462
- * Chainable wrapper returned by `Query.groupBy(field)`. Terminates
463
- * with `.aggregate(spec)` which returns a `GroupedAggregation`.
464
- *
465
- * Kept minimal — the only operation on a grouped query is
466
- * aggregation. Ordering, limiting, and further filtering belong on
467
- * the underlying `Query` before `.groupBy()` is called; applying
468
- * them post-group would be a different operation (`having` /
469
- * `groupOrderBy`), out of scope for.
470
- */
471
- declare class GroupedQuery<T, F extends string> extends GroupedQueryBase {
472
- /**
473
- * Build a grouped aggregation. Returns a `GroupedAggregation`
474
- * with `.run()`, `.runAsync()`, and `.live()` terminals — same shape
475
- * as the non-grouped `.aggregate()` wrapper, just with an array
476
- * result (one row per bucket) instead of a single reduced object.
477
- */
478
- aggregate<Spec extends AggregateSpec>(spec: Spec): GroupedAggregation<GroupedRow<F, AggregateResult<Spec>>>;
479
- }
480
- /**
481
- * Variadic-keyed sibling of `GroupedQuery<T, F>`. Constructed by the
482
- * multi-arg `Query.groupBy(...fields)` overload. The runtime shape is
483
- * identical — only the type-level result-row narrowing differs.
484
- */
485
- declare class GroupedQueryN<T, F extends readonly string[]> extends GroupedQueryBase {
486
- aggregate<Spec extends AggregateSpec>(spec: Spec): GroupedAggregation<GroupedRowN<F, AggregateResult<Spec>>>;
487
- }
488
- /**
489
- * Execute the group-and-reduce pipeline. Pure function over a
490
- * record array and a spec — shared by `GroupedAggregation.run()`
491
- * and the live-mode refresh path. Exported for tests and for any
492
- * future `scan().groupBy().aggregate()` reuse.
493
- *
494
- * Enforces the cardinality cap incrementally during the partition
495
- * loop, so a runaway grouping throws at the moment the 100_001st
496
- * bucket would be created — the consumer doesn't have to wait for
497
- * the full partition to materialize before the error fires.
498
- */
499
- declare function groupAndReduce<R>(records: readonly unknown[], fieldOrFields: string | readonly string[], spec: AggregateSpec): R[];
500
- /**
501
- * Grouped aggregation wrapper — the `.groupBy(field).aggregate(spec)`
502
- * terminal. Shape mirrors `Aggregation<R>` from aggregate.ts: two
503
- * terminals (`.run()` and `.live()`), spec bound at construction
504
- * time, upstreams collected for live mode.
505
- *
506
- * The generic `R` is the per-row result shape (i.e. a single
507
- * grouped row), and the terminals return `R[]` — one row per
508
- * bucket.
509
- */
510
- declare class GroupedAggregation<R> {
511
- private readonly executeRecords;
512
- private readonly spec;
513
- private readonly upstreams;
514
- /**
515
- * Optional dict label resolver for `<field>Label` projection
516
- *. Present when the grouping field is a dictKey.
517
- */
518
- private readonly dictLabelResolver?;
519
- private readonly fields;
520
- constructor(executeRecords: () => readonly unknown[], fields: string | readonly string[], spec: AggregateSpec, upstreams: readonly AggregationUpstream[],
521
- /**
522
- * Optional dict label resolver for `<field>Label` projection
523
- *. Present when the grouping field is a dictKey.
524
- */
525
- dictLabelResolver?: ((key: string, locale: string, fallback?: string | readonly string[]) => Promise<string | undefined>) | undefined);
526
- /** Execute the query, group, reduce, and return an array of rows. */
527
- run(): R[];
528
- /**
529
- * Execute the query, group, reduce, and resolve `<field>Label` for
530
- * each result row when the grouping field is a `dictKey` and a
531
- * `locale` is provided. Returns `R[]` synchronously when
532
- * no locale is specified (identical to `.run()`).
533
- *
534
- * The `<field>Label` field is appended to each row. Rows whose group
535
- * key has no dictionary entry get `<field>Label: undefined`.
536
- *
537
- * Dict-label resolution is single-field only — multi-key groupings
538
- * do not produce a `<field>Label`. The resolver is only attached
539
- * by the builder when `fields.length === 1`.
540
- */
541
- runAsync(opts?: {
542
- locale?: string;
543
- fallback?: string | readonly string[];
544
- }): Promise<R[]>;
545
- /**
546
- * Build a reactive `LiveAggregation<R[]>` that re-runs the full
547
- * group-and-reduce pipeline whenever any upstream source notifies
548
- * of a change. Same error-isolation and idempotent-stop contract
549
- * as `Aggregation.live()` — the implementation delegates to the
550
- * same `LiveAggregationImpl` class by threading a fresh
551
- * recompute closure through the existing constructor.
552
- *
553
- * uses naive full re-run on every change. Incremental
554
- * per-bucket maintenance (apply `step` on inserted records,
555
- * `remove` on deleted records, route by bucket key) is a future
556
- * optimization — the reducer protocol admits it, but wiring
557
- * delta-aware source subscriptions is a separate PR.
558
- *
559
- * Always call `live.stop()` when finished.
560
- */
561
- live(): LiveAggregation<R[]>;
562
- }
563
-
564
- /**
565
- * Strategy seam between the core Query / ScanBuilder chain and the
566
- * optional aggregate / groupBy subsystem. Core imports
567
- * `AggregateStrategy` as a TYPE-ONLY symbol and `NO_AGGREGATE` as a
568
- * tiny runtime stub.
569
- *
570
- * The heavy machinery — `Aggregation`, `GroupedQuery`, the
571
- * reducer-step logic — is only reachable from `withAggregate()` in
572
- * `./active.ts`, which is only exported through the
573
- * `@noy-db/hub/aggregate` subpath. Consumers that don't import the
574
- * subpath ship none of the ~886 LOC.
575
- *
576
- * @internal
577
- */
578
-
579
- /**
580
- * Seam interface. `@internal` — will promote to public only when the
581
- * aggregate subsystem is extracted into its own package.
582
- *
583
- * @internal
584
- */
585
- interface AggregateStrategy {
586
- /**
587
- * Build an `Aggregation<R>` for `Query.aggregate(spec)`. `executeRecords`
588
- * is a closure that produces the matching record set when the
589
- * aggregation runs. NO_AGGREGATE throws; the active strategy
590
- * constructs a real `Aggregation`.
591
- */
592
- aggregate<Spec extends AggregateSpec>(executeRecords: () => readonly unknown[], spec: Spec, upstreams: readonly AggregationUpstream[]): Aggregation<AggregateResult<Spec>>;
593
- /**
594
- * Build a `GroupedQuery<T, F>` for `Query.groupBy(field)`. Same
595
- * closure / upstream inputs as `aggregate` plus the group key field.
596
- */
597
- groupBy<T, F extends string>(executeRecords: () => readonly unknown[], field: F, upstreams: readonly AggregationUpstream[], dictLabelResolver?: (key: string, locale: string, fallback?: string | readonly string[]) => Promise<string | undefined>): GroupedQuery<T, F>;
598
- /**
599
- * Variadic-keyed sibling — builds a `GroupedQueryN<T, F>` for
600
- * `Query.groupBy(...fields)`. No dictLabelResolver — `<field>Label`
601
- * projection only applies to single-field groupings, which dispatch
602
- * through `groupBy` above.
603
- */
604
- groupByN<T, F extends readonly string[]>(executeRecords: () => readonly unknown[], fields: F, upstreams: readonly AggregationUpstream[]): GroupedQueryN<T, F>;
605
- /**
606
- * Terminal streaming aggregator for `ScanBuilder.aggregate(spec)`.
607
- * Takes an async iterable of decrypted records + the spec and
608
- * returns the reduced result.
609
- */
610
- scanAggregate<Spec extends AggregateSpec>(iter: AsyncIterable<unknown>, spec: Spec): Promise<AggregateResult<Spec>>;
611
- }
612
-
613
- export { type AggregateStrategy as A, GROUPBY_MAX_CARDINALITY as G, type LiveAggregation as L, type Reducer as R, type AggregateResult as a, type AggregateSpec as b, Aggregation as c, type AggregationUpstream as d, GROUPBY_WARN_CARDINALITY as e, GroupedAggregation as f, GroupedQuery as g, GroupedQueryN as h, type GroupedRow as i, type GroupedRowN as j, type ReducerOptions as k, avg as l, buildLiveAggregation as m, count as n, groupAndReduce as o, max as p, min as q, reduceRecords as r, resetGroupByWarnings as s, sum as t };
@@ -1,18 +0,0 @@
1
- import { as as GuardStrategy, aw as GuardStrategyHandle } from './types-n2_IfwlQ.cjs';
2
-
3
- /**
4
- * Register a guard for a collection. Guards run on every `put()` /
5
- * `delete()` for the named collection (after permissions, before
6
- * encryption) and may:
7
- *
8
- * - `check` — block writes by throwing (typically `RecordLockedError`)
9
- * - `frozenFields` — freeze specific fields once a condition is true
10
- * - `amendment` — declare an authorized-override path with invariant
11
- *
12
- * Pass the returned handle to `createNoydb({ strategies: [...] })`.
13
- *
14
- * @see docs/superpowers/specs/2026-05-18-guards-design.md
15
- */
16
- declare function withGuard<T extends Record<string, unknown>>(strategy: GuardStrategy<T>): GuardStrategyHandle<T>;
17
-
18
- export { withGuard as w };
@@ -1,18 +0,0 @@
1
- import { as as GuardStrategy, aw as GuardStrategyHandle } from './types-CaNQm4i8.js';
2
-
3
- /**
4
- * Register a guard for a collection. Guards run on every `put()` /
5
- * `delete()` for the named collection (after permissions, before
6
- * encryption) and may:
7
- *
8
- * - `check` — block writes by throwing (typically `RecordLockedError`)
9
- * - `frozenFields` — freeze specific fields once a condition is true
10
- * - `amendment` — declare an authorized-override path with invariant
11
- *
12
- * Pass the returned handle to `createNoydb({ strategies: [...] })`.
13
- *
14
- * @see docs/superpowers/specs/2026-05-18-guards-design.md
15
- */
16
- declare function withGuard<T extends Record<string, unknown>>(strategy: GuardStrategy<T>): GuardStrategyHandle<T>;
17
-
18
- export { withGuard as w };