/** * Strategy seam between the core Query / ScanBuilder chain and the * optional aggregate / groupBy service. Core imports * `AggregateStrategy` as a TYPE-ONLY symbol and `NO_AGGREGATE` as a * tiny runtime stub. * * The heavy machinery — `Aggregation`, `GroupedQuery`, the * reducer-step logic — is only reachable from `withAggregate()` in * `./active.ts`, which is only exported through the * `@noy-db/hub/aggregate` subpath. Consumers that don't import the * subpath ship none of the ~886 LOC. * * @internal */ import type { Aggregation, AggregateSpec, AggregateResult, AggregationUpstream } from './aggregation.js'; import type { GroupedQuery, GroupedQueryN } from './groupby.js'; import type { ViaPipeline } from '../../kernel/via/pipeline.js'; /** * Seam interface. `@internal` — will promote to public only when the * aggregate service is extracted into its own package. * * @internal */ export interface AggregateStrategy { /** * Build an `Aggregation` for `Query.aggregate(spec)`. `executeRecords` * is a closure that produces the matching record set when the * aggregation runs. NO_AGGREGATE throws; the active strategy * constructs a real `Aggregation`. */ aggregate(executeRecords: () => readonly unknown[], spec: Spec, upstreams: readonly AggregationUpstream[]): Aggregation>; /** * Build a `GroupedQuery` for `Query.groupBy(field)`. Same * closure / upstream inputs as `aggregate` plus the group key field. */ groupBy(executeRecords: () => readonly unknown[], field: F, upstreams: readonly AggregationUpstream[], dictLabelResolver?: (key: string, locale: string, fallback?: string | readonly string[]) => Promise, via?: ViaPipeline): GroupedQuery; /** * Variadic-keyed sibling — builds a `GroupedQueryN` for * `Query.groupBy(...fields)`. No dictLabelResolver — `Label` * projection only applies to single-field groupings, which dispatch * through `groupBy` above. */ groupByN(executeRecords: () => readonly unknown[], fields: F, upstreams: readonly AggregationUpstream[], via?: ViaPipeline): GroupedQueryN; /** * Terminal streaming aggregator for `ScanBuilder.aggregate(spec)`. * Takes an async iterable of decrypted records + the spec and * returns the reduced result. */ scanAggregate(iter: AsyncIterable, spec: Spec): Promise>; } /** * No-aggregate stub. Every `.aggregate()` / `.groupBy()` / streaming * `scan().aggregate()` call throws with a pointer at the subpath. The * real `Aggregation` / `GroupedQuery` classes are never referenced at * runtime, so the bundler drops the ~886 LOC. * * @internal */ export declare const NO_AGGREGATE: AggregateStrategy;