@noy-db/hub 0.1.0-pre.14 → 0.1.0-pre.16
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.
- package/dist/aggregate/index.cjs +91 -36
- package/dist/aggregate/index.cjs.map +1 -1
- package/dist/aggregate/index.d.cts +2 -2
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/aggregate/index.js +15 -8
- package/dist/aggregate/index.js.map +1 -1
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +5 -4
- package/dist/blobs/index.d.ts +5 -4
- package/dist/blobs/index.js +4 -4
- package/dist/bundle/index.cjs +214 -7
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +5 -4
- package/dist/bundle/index.d.ts +5 -4
- package/dist/bundle/index.js +6 -4
- package/dist/{chunk-CX2S2IBB.js → chunk-23TTQXVO.js} +53 -79
- package/dist/chunk-23TTQXVO.js.map +1 -0
- package/dist/{chunk-WLZWITX3.js → chunk-2AXFIYHT.js} +1 -1
- package/dist/chunk-2AXFIYHT.js.map +1 -0
- package/dist/{chunk-SBOSKCXD.js → chunk-2R6G2WST.js} +209 -13
- package/dist/chunk-2R6G2WST.js.map +1 -0
- package/dist/{chunk-HENWE2QQ.js → chunk-34YSDCDP.js} +2 -2
- package/dist/{chunk-3J5PYYUL.js → chunk-5DWL3JBF.js} +2 -2
- package/dist/{chunk-562AT3V6.js → chunk-5NGHX6ME.js} +5 -5
- package/dist/chunk-5ZGZ6HIZ.js +100 -0
- package/dist/chunk-5ZGZ6HIZ.js.map +1 -0
- package/dist/{chunk-ZJICDHNH.js → chunk-6HPZY4ON.js} +5 -4
- package/dist/chunk-6HPZY4ON.js.map +1 -0
- package/dist/{chunk-LTKFPLTW.js → chunk-A3K2ECAM.js} +192 -11
- package/dist/chunk-A3K2ECAM.js.map +1 -0
- package/dist/{chunk-W7M3E5M5.js → chunk-ADQ5MQ54.js} +48 -1
- package/dist/{chunk-W7M3E5M5.js.map → chunk-ADQ5MQ54.js.map} +1 -1
- package/dist/{chunk-Q3OWJPJI.js → chunk-DPMFBCV6.js} +32 -19
- package/dist/chunk-DPMFBCV6.js.map +1 -0
- package/dist/{chunk-AD4FMCXZ.js → chunk-DYBQG5PQ.js} +2 -2
- package/dist/{chunk-PNTWORBA.js → chunk-DYECX3IX.js} +2 -2
- package/dist/chunk-EGQYGYIU.js +51 -0
- package/dist/chunk-EGQYGYIU.js.map +1 -0
- package/dist/{chunk-RGHN6WV7.js → chunk-FCXOFQAJ.js} +2 -2
- package/dist/{chunk-PMMNH7VZ.js → chunk-H7XROQJM.js} +1 -1
- package/dist/chunk-H7XROQJM.js.map +1 -0
- package/dist/chunk-HB3Z2GCR.js +124 -0
- package/dist/chunk-HB3Z2GCR.js.map +1 -0
- package/dist/{chunk-CRNMA2FB.js → chunk-I6MX32UC.js} +4 -4
- package/dist/{chunk-PHSGPPV7.js → chunk-KESP7GOK.js} +3 -3
- package/dist/{chunk-FB34MDSJ.js → chunk-KJJKHKFP.js} +4 -4
- package/dist/{chunk-J3E2UMET.js → chunk-MIQHZESA.js} +3 -3
- package/dist/{chunk-TNYWH7Z2.js → chunk-MKSA2V7A.js} +2 -2
- package/dist/{chunk-E4ZSYZSN.js → chunk-NVBUGT76.js} +4 -4
- package/dist/{chunk-XFVOTOYQ.js → chunk-O4RHR7FV.js} +6 -6
- package/dist/{chunk-EEEFQTYN.js → chunk-OMLIZL2P.js} +2 -2
- package/dist/{chunk-GVPFL6XF.js → chunk-P7EQ2S5O.js} +2 -2
- package/dist/{chunk-E3VAKWJ7.js → chunk-QQUUAXDY.js} +7 -6
- package/dist/chunk-QQUUAXDY.js.map +1 -0
- package/dist/chunk-RD5LYKD6.js +82 -0
- package/dist/chunk-RD5LYKD6.js.map +1 -0
- package/dist/{chunk-7QGJ7RTL.js → chunk-RRMDLTIL.js} +4 -4
- package/dist/{chunk-432R4RDC.js → chunk-SIZWEV2Y.js} +35 -5
- package/dist/chunk-SIZWEV2Y.js.map +1 -0
- package/dist/{chunk-U7YDBNFC.js → chunk-UZXLQCHP.js} +2 -2
- package/dist/{chunk-PPJA7KL6.js → chunk-V6SGP2KX.js} +3 -3
- package/dist/{chunk-7AQKLLI5.js → chunk-WCA2NROQ.js} +2 -2
- package/dist/{chunk-ERV4AXVO.js → chunk-XGSOTWYX.js} +90 -131
- package/dist/chunk-XGSOTWYX.js.map +1 -0
- package/dist/{chunk-5Y4AKEZ6.js → chunk-Z72JH4KG.js} +2 -2
- package/dist/{chunk-IXFP66OV.js → chunk-ZNOEIM6Y.js} +2 -2
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +5 -4
- package/dist/consent/index.d.ts +5 -4
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-VTEMMJK6.js → crypto-A7FRXYHC.js} +3 -3
- package/dist/{delegation-HYQULPZR.js → delegation-YBA4X4JN.js} +5 -5
- package/dist/derivations/index.cjs +97 -1
- package/dist/derivations/index.cjs.map +1 -1
- package/dist/derivations/index.d.cts +37 -10
- package/dist/derivations/index.d.ts +37 -10
- package/dist/derivations/index.js +6 -4
- package/dist/{dev-unlock-CpJ9rHW2.d.ts → dev-unlock-C8u6MRfS.d.ts} +1 -1
- package/dist/{dev-unlock-DEUUpWoR.d.cts → dev-unlock-gBjwzB6A.d.cts} +1 -1
- package/dist/executor-7E3VFGW7.js +11 -0
- package/dist/executor-CEWX2FQI.js +8 -0
- package/dist/executor-X4SQ3ZLC.js +8 -0
- package/dist/fanout-sidecar-ACJNXFU6.js +51 -0
- package/dist/fanout-sidecar-ACJNXFU6.js.map +1 -0
- package/dist/guards/index.cjs.map +1 -1
- package/dist/guards/index.d.cts +6 -5
- package/dist/guards/index.d.ts +6 -5
- package/dist/guards/index.js +6 -6
- package/dist/{hash-_9VyW44M.d.cts → hash-BXy5DuTD.d.cts} +1 -1
- package/dist/{hash-CJ9LfuY5.d.ts → hash-C6KOPK9Q.d.ts} +1 -1
- package/dist/history/index.cjs +2 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +6 -5
- package/dist/history/index.d.ts +6 -5
- package/dist/history/index.js +6 -6
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +5 -4
- package/dist/i18n/index.d.ts +5 -4
- package/dist/i18n/index.js +6 -6
- package/dist/{index-s31g3m-D.d.cts → index-BA7A-MJs.d.cts} +96 -4
- package/dist/{index-BWAXR9tV.d.ts → index-CLK67MZE.d.ts} +96 -4
- package/dist/{index-7nd15fgy.d.ts → index-CNwA-B6-.d.ts} +70 -2
- package/dist/{index-CFJKJXWa.d.cts → index-CmVgTkqk.d.cts} +70 -2
- package/dist/index.cjs +2400 -571
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +128 -18
- package/dist/index.d.ts +128 -18
- package/dist/index.js +1217 -107
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs.map +1 -1
- package/dist/indexing/index.js +2 -2
- package/dist/{ledger-LHLIVPJ3.js → ledger-GHIZQLKR.js} +6 -6
- package/dist/materialized-views/index.cjs +255 -21
- package/dist/materialized-views/index.cjs.map +1 -1
- package/dist/materialized-views/index.d.cts +7 -6
- package/dist/materialized-views/index.d.ts +7 -6
- package/dist/materialized-views/index.js +9 -5
- package/dist/overlay-views/index.cjs.map +1 -1
- package/dist/overlay-views/index.d.cts +6 -5
- package/dist/overlay-views/index.d.ts +6 -5
- package/dist/overlay-views/index.js +3 -3
- package/dist/periods/index.cjs +2 -1
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +5 -4
- package/dist/periods/index.d.ts +5 -4
- package/dist/periods/index.js +6 -6
- package/dist/{public-envelope-66ZBXVXK.js → public-envelope-CRJAVW3E.js} +4 -4
- package/dist/query/index.cjs +139 -113
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +2 -2
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +13 -9
- package/dist/{registry-JYALMHGM.js → registry-3L3N3PTG.js} +3 -3
- package/dist/registry-O47PUPSY.js +8 -0
- package/dist/registry-WLLMODKN.js +8 -0
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +6 -5
- package/dist/session/index.d.ts +6 -5
- package/dist/session/index.js +3 -3
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +5 -4
- package/dist/shadow/index.d.ts +5 -4
- package/dist/shadow/index.js +2 -2
- package/dist/{stale-EET5YFYL.js → stale-HSC5YO2O.js} +2 -2
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +5 -4
- package/dist/store/index.d.ts +5 -4
- package/dist/store/index.js +2 -2
- package/dist/{strategy-D-SrOLCl.d.cts → strategy-DSTrsZ8t.d.cts} +72 -19
- package/dist/{strategy-D-SrOLCl.d.ts → strategy-DSTrsZ8t.d.ts} +72 -19
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +4 -3
- package/dist/sync/index.d.ts +4 -3
- package/dist/sync/index.js +4 -4
- package/dist/team/index.cjs +136 -6
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +5 -4
- package/dist/team/index.d.ts +5 -4
- package/dist/team/index.js +7 -7
- package/dist/tx/index.cjs +2 -1
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +5 -4
- package/dist/tx/index.d.ts +5 -4
- package/dist/tx/index.js +2 -2
- package/dist/{types-2JGVRzO2.d.cts → types-DDy02bWN.d.cts} +1159 -257
- package/dist/{types-DIOLYPUq.d.ts → types-DImsOlJe.d.ts} +1159 -257
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.js +1 -1
- package/dist/{with-derivation-ClhfQvRa.d.ts → with-derivation-3AdLeSw8.d.ts} +1 -1
- package/dist/{with-derivation-3JX8SMxY.d.cts → with-derivation-CkCHx_J8.d.cts} +1 -1
- package/dist/{with-guard-Br3YPxRW.d.ts → with-guard-Br9zLEdi.d.ts} +1 -1
- package/dist/{with-guard-fJVfWBLs.d.cts → with-guard-DtKsFExw.d.cts} +1 -1
- package/dist/with-materialized-view-CMhEX4FK.d.cts +27 -0
- package/dist/with-materialized-view-Zal2bE1T.d.ts +27 -0
- package/dist/{with-overlayed-view-BLUKxdiJ.d.cts → with-overlayed-view-CA6zHrBt.d.cts} +1 -1
- package/dist/{with-overlayed-view-CtvJxhU3.d.ts → with-overlayed-view-R4BNG9OB.d.ts} +1 -1
- package/package.json +14 -2
- package/dist/chunk-432R4RDC.js.map +0 -1
- package/dist/chunk-CX2S2IBB.js.map +0 -1
- package/dist/chunk-E3VAKWJ7.js.map +0 -1
- package/dist/chunk-ERV4AXVO.js.map +0 -1
- package/dist/chunk-GV47JHIF.js +0 -29
- package/dist/chunk-GV47JHIF.js.map +0 -1
- package/dist/chunk-LTKFPLTW.js.map +0 -1
- package/dist/chunk-PMMNH7VZ.js.map +0 -1
- package/dist/chunk-Q2L5ZYX7.js +0 -66
- package/dist/chunk-Q2L5ZYX7.js.map +0 -1
- package/dist/chunk-Q3OWJPJI.js.map +0 -1
- package/dist/chunk-SBK6CETA.js +0 -30
- package/dist/chunk-SBK6CETA.js.map +0 -1
- package/dist/chunk-SBOSKCXD.js.map +0 -1
- package/dist/chunk-WLZWITX3.js.map +0 -1
- package/dist/chunk-ZJICDHNH.js.map +0 -1
- package/dist/executor-3H3NSIVZ.js +0 -8
- package/dist/executor-7ZOXGY7P.js +0 -8
- package/dist/executor-A5LTUAG2.js +0 -9
- package/dist/registry-J2UI37XJ.js +0 -8
- package/dist/registry-UMAL72WL.js +0 -8
- package/dist/with-materialized-view-CHho83hN.d.cts +0 -15
- package/dist/with-materialized-view-CgPphnza.d.ts +0 -15
- /package/dist/{chunk-HENWE2QQ.js.map → chunk-34YSDCDP.js.map} +0 -0
- /package/dist/{chunk-3J5PYYUL.js.map → chunk-5DWL3JBF.js.map} +0 -0
- /package/dist/{chunk-562AT3V6.js.map → chunk-5NGHX6ME.js.map} +0 -0
- /package/dist/{chunk-AD4FMCXZ.js.map → chunk-DYBQG5PQ.js.map} +0 -0
- /package/dist/{chunk-PNTWORBA.js.map → chunk-DYECX3IX.js.map} +0 -0
- /package/dist/{chunk-RGHN6WV7.js.map → chunk-FCXOFQAJ.js.map} +0 -0
- /package/dist/{chunk-CRNMA2FB.js.map → chunk-I6MX32UC.js.map} +0 -0
- /package/dist/{chunk-PHSGPPV7.js.map → chunk-KESP7GOK.js.map} +0 -0
- /package/dist/{chunk-FB34MDSJ.js.map → chunk-KJJKHKFP.js.map} +0 -0
- /package/dist/{chunk-J3E2UMET.js.map → chunk-MIQHZESA.js.map} +0 -0
- /package/dist/{chunk-TNYWH7Z2.js.map → chunk-MKSA2V7A.js.map} +0 -0
- /package/dist/{chunk-E4ZSYZSN.js.map → chunk-NVBUGT76.js.map} +0 -0
- /package/dist/{chunk-XFVOTOYQ.js.map → chunk-O4RHR7FV.js.map} +0 -0
- /package/dist/{chunk-EEEFQTYN.js.map → chunk-OMLIZL2P.js.map} +0 -0
- /package/dist/{chunk-GVPFL6XF.js.map → chunk-P7EQ2S5O.js.map} +0 -0
- /package/dist/{chunk-7QGJ7RTL.js.map → chunk-RRMDLTIL.js.map} +0 -0
- /package/dist/{chunk-U7YDBNFC.js.map → chunk-UZXLQCHP.js.map} +0 -0
- /package/dist/{chunk-PPJA7KL6.js.map → chunk-V6SGP2KX.js.map} +0 -0
- /package/dist/{chunk-7AQKLLI5.js.map → chunk-WCA2NROQ.js.map} +0 -0
- /package/dist/{chunk-5Y4AKEZ6.js.map → chunk-Z72JH4KG.js.map} +0 -0
- /package/dist/{chunk-IXFP66OV.js.map → chunk-ZNOEIM6Y.js.map} +0 -0
- /package/dist/{crypto-VTEMMJK6.js.map → crypto-A7FRXYHC.js.map} +0 -0
- /package/dist/{delegation-HYQULPZR.js.map → delegation-YBA4X4JN.js.map} +0 -0
- /package/dist/{executor-3H3NSIVZ.js.map → executor-7E3VFGW7.js.map} +0 -0
- /package/dist/{executor-7ZOXGY7P.js.map → executor-CEWX2FQI.js.map} +0 -0
- /package/dist/{executor-A5LTUAG2.js.map → executor-X4SQ3ZLC.js.map} +0 -0
- /package/dist/{ledger-LHLIVPJ3.js.map → ledger-GHIZQLKR.js.map} +0 -0
- /package/dist/{public-envelope-66ZBXVXK.js.map → public-envelope-CRJAVW3E.js.map} +0 -0
- /package/dist/{registry-J2UI37XJ.js.map → registry-3L3N3PTG.js.map} +0 -0
- /package/dist/{registry-JYALMHGM.js.map → registry-O47PUPSY.js.map} +0 -0
- /package/dist/{registry-UMAL72WL.js.map → registry-WLLMODKN.js.map} +0 -0
- /package/dist/{stale-EET5YFYL.js.map → stale-HSC5YO2O.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AggregateStrategy } from '../strategy-
|
|
2
|
-
export { a as AggregateResult, b as AggregateSpec, c as Aggregation, d as AggregationUpstream, G as GROUPBY_MAX_CARDINALITY, e as GROUPBY_WARN_CARDINALITY, f as GroupedAggregation, g as GroupedQuery, h as GroupedRow, L as LiveAggregation, R as Reducer,
|
|
1
|
+
import { A as AggregateStrategy } from '../strategy-DSTrsZ8t.js';
|
|
2
|
+
export { a as AggregateResult, b as AggregateSpec, c as Aggregation, d as AggregationUpstream, G as GROUPBY_MAX_CARDINALITY, e as GROUPBY_WARN_CARDINALITY, f as GroupedAggregation, g as GroupedQuery, h as GroupedQueryN, i as GroupedRow, j as GroupedRowN, L as LiveAggregation, R as Reducer, k as ReducerOptions, l as avg, m as buildLiveAggregation, n as count, o as groupAndReduce, p as max, q as min, r as reduceRecords, s as resetGroupByWarnings, t as sum } from '../strategy-DSTrsZ8t.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Active aggregate strategy factory. Calling `withAggregate()` returns
|
package/dist/aggregate/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
avg,
|
|
3
|
+
count,
|
|
4
|
+
max,
|
|
5
|
+
min,
|
|
6
|
+
sum
|
|
7
|
+
} from "../chunk-5ZGZ6HIZ.js";
|
|
1
8
|
import {
|
|
2
9
|
Aggregation,
|
|
3
10
|
GROUPBY_MAX_CARDINALITY,
|
|
4
11
|
GROUPBY_WARN_CARDINALITY,
|
|
5
12
|
GroupedAggregation,
|
|
6
13
|
GroupedQuery,
|
|
7
|
-
|
|
14
|
+
GroupedQueryN,
|
|
8
15
|
buildLiveAggregation,
|
|
9
|
-
count,
|
|
10
16
|
groupAndReduce,
|
|
11
|
-
max,
|
|
12
|
-
min,
|
|
13
17
|
reduceRecords,
|
|
14
|
-
resetGroupByWarnings
|
|
15
|
-
|
|
16
|
-
} from "../chunk-ERV4AXVO.js";
|
|
18
|
+
resetGroupByWarnings
|
|
19
|
+
} from "../chunk-XGSOTWYX.js";
|
|
17
20
|
import "../chunk-MRIBLZL3.js";
|
|
18
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-ADQ5MQ54.js";
|
|
19
22
|
|
|
20
23
|
// src/aggregate/active.ts
|
|
21
24
|
function withAggregate() {
|
|
@@ -26,6 +29,9 @@ function withAggregate() {
|
|
|
26
29
|
groupBy(executeRecords, field, upstreams, dictLabelResolver) {
|
|
27
30
|
return new GroupedQuery(executeRecords, field, upstreams, dictLabelResolver);
|
|
28
31
|
},
|
|
32
|
+
groupByN(executeRecords, fields, upstreams) {
|
|
33
|
+
return new GroupedQueryN(executeRecords, fields, upstreams);
|
|
34
|
+
},
|
|
29
35
|
async scanAggregate(iter, spec) {
|
|
30
36
|
const collected = [];
|
|
31
37
|
for await (const record of iter) collected.push(record);
|
|
@@ -39,6 +45,7 @@ export {
|
|
|
39
45
|
GROUPBY_WARN_CARDINALITY,
|
|
40
46
|
GroupedAggregation,
|
|
41
47
|
GroupedQuery,
|
|
48
|
+
GroupedQueryN,
|
|
42
49
|
avg,
|
|
43
50
|
buildLiveAggregation,
|
|
44
51
|
count,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/aggregate/active.ts"],"sourcesContent":["/**\n * Active aggregate strategy factory. Calling `withAggregate()` returns\n * an `AggregateStrategy` whose methods construct real `Aggregation` /\n * `GroupedQuery` instances and run the streaming reducer protocol.\n *\n * This module is only reachable through the `@noy-db/hub/aggregate`\n * subpath — a consumer that never imports the subpath ships none of\n * this (ESM tree-shaking + hub's `\"sideEffects\": false`).\n */\n\nimport { Aggregation, reduceRecords } from './aggregation.js'\nimport type { AggregateSpec, AggregateResult } from './aggregation.js'\nimport { GroupedQuery } from './groupby.js'\nimport type { AggregateStrategy } from './strategy.js'\n\n/**\n * Build the default aggregate strategy. Pass into\n * `createNoydb({ aggregateStrategy: withAggregate() })` to light up\n * `.aggregate()` and `.groupBy()` on `Query` and `ScanBuilder`.\n *\n * @example\n * ```ts\n * import { createNoydb } from '@noy-db/hub'\n * import { withAggregate, sum, count } from '@noy-db/hub/aggregate'\n *\n * const db = await createNoydb({\n * store, user, secret,\n * aggregateStrategy: withAggregate(),\n * })\n *\n * const totals = invoices.query()\n * .where('status', '==', 'paid')\n * .groupBy('clientId')\n * .aggregate({ amount: sum('amount'), n: count() })\n * .run()\n * ```\n */\nexport function withAggregate(): AggregateStrategy {\n return {\n aggregate(executeRecords, spec, upstreams) {\n return new Aggregation(executeRecords, spec as unknown as AggregateSpec, upstreams) as unknown as Aggregation<AggregateResult<typeof spec>>\n },\n groupBy(executeRecords, field, upstreams, dictLabelResolver) {\n return new GroupedQuery(executeRecords, field, upstreams, dictLabelResolver)\n },\n async scanAggregate(iter, spec) {\n const collected: unknown[] = []\n for await (const record of iter) collected.push(record)\n return reduceRecords(collected, spec as unknown as AggregateSpec) as unknown as AggregateResult<typeof spec>\n },\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/aggregate/active.ts"],"sourcesContent":["/**\n * Active aggregate strategy factory. Calling `withAggregate()` returns\n * an `AggregateStrategy` whose methods construct real `Aggregation` /\n * `GroupedQuery` instances and run the streaming reducer protocol.\n *\n * This module is only reachable through the `@noy-db/hub/aggregate`\n * subpath — a consumer that never imports the subpath ships none of\n * this (ESM tree-shaking + hub's `\"sideEffects\": false`).\n */\n\nimport { Aggregation, reduceRecords } from './aggregation.js'\nimport type { AggregateSpec, AggregateResult } from './aggregation.js'\nimport { GroupedQuery, GroupedQueryN } from './groupby.js'\nimport type { AggregateStrategy } from './strategy.js'\n\n/**\n * Build the default aggregate strategy. Pass into\n * `createNoydb({ aggregateStrategy: withAggregate() })` to light up\n * `.aggregate()` and `.groupBy()` on `Query` and `ScanBuilder`.\n *\n * @example\n * ```ts\n * import { createNoydb } from '@noy-db/hub'\n * import { withAggregate, sum, count } from '@noy-db/hub/aggregate'\n *\n * const db = await createNoydb({\n * store, user, secret,\n * aggregateStrategy: withAggregate(),\n * })\n *\n * const totals = invoices.query()\n * .where('status', '==', 'paid')\n * .groupBy('clientId')\n * .aggregate({ amount: sum('amount'), n: count() })\n * .run()\n * ```\n */\nexport function withAggregate(): AggregateStrategy {\n return {\n aggregate(executeRecords, spec, upstreams) {\n return new Aggregation(executeRecords, spec as unknown as AggregateSpec, upstreams) as unknown as Aggregation<AggregateResult<typeof spec>>\n },\n groupBy(executeRecords, field, upstreams, dictLabelResolver) {\n return new GroupedQuery(executeRecords, field, upstreams, dictLabelResolver)\n },\n groupByN(executeRecords, fields, upstreams) {\n return new GroupedQueryN(executeRecords, fields, upstreams)\n },\n async scanAggregate(iter, spec) {\n const collected: unknown[] = []\n for await (const record of iter) collected.push(record)\n return reduceRecords(collected, spec as unknown as AggregateSpec) as unknown as AggregateResult<typeof spec>\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAAS,gBAAmC;AACjD,SAAO;AAAA,IACL,UAAU,gBAAgB,MAAM,WAAW;AACzC,aAAO,IAAI,YAAY,gBAAgB,MAAkC,SAAS;AAAA,IACpF;AAAA,IACA,QAAQ,gBAAgB,OAAO,WAAW,mBAAmB;AAC3D,aAAO,IAAI,aAAa,gBAAgB,OAAO,WAAW,iBAAiB;AAAA,IAC7E;AAAA,IACA,SAAS,gBAAgB,QAAQ,WAAW;AAC1C,aAAO,IAAI,cAAc,gBAAgB,QAAQ,SAAS;AAAA,IAC5D;AAAA,IACA,MAAM,cAAc,MAAM,MAAM;AAC9B,YAAM,YAAuB,CAAC;AAC9B,uBAAiB,UAAU,KAAM,WAAU,KAAK,MAAM;AACtD,aAAO,cAAc,WAAW,IAAgC;AAAA,IAClE;AAAA,EACF;AACF;","names":[]}
|