/** * The aggregates in code-land — the handful of reductions an island reaches for * by name, over core's ONE numeric reduce ({@link reduceNumeric}). * * They no longer build expression SOURCE and hand it to an evaluator. They * used to, because `$expr` was a closed dialect with its own `sum` and the rule * was that this repo may hold only one. A `{...}` gap is JavaScript now, so * `sum(rows, "amount_cents")` here and * `rows.reduce((t, r) => t + r.amount_cents, 0)` in a screen are the same * language reaching the same arithmetic — there is no second implementation to * avoid, only a second copy of the REDUCE, and that still lives in core. * * One posture, as everywhere in this package: the number (or the points), or * `undefined` — loading and a mismatch both. An island renders a placeholder, * never a throw. */ import { type Json, type NumericReduction } from "../../core/index.js"; /** Total of a numeric column. */ export declare const sum: (rows: Json | undefined, field: string) => number | undefined; /** Mean of a numeric column; no values means no answer. */ export declare const average: (rows: Json | undefined, field: string) => number | undefined; export declare const min: (rows: Json | undefined, field: string) => number | undefined; export declare const max: (rows: Json | undefined, field: string) => number | undefined; /** How many rows the list holds. */ export declare const count: (rows: Json | undefined) => number | undefined; /** `left - right`, with either side absent meaning no answer. */ export declare const difference: (left: Json | undefined, right: Json | undefined) => number | undefined; /** Whole days from now (UTC day boundaries) to an ISO date string. `now` is * injectable so a render is testable — the ONE clock read in this module, and * the reason it is a parameter rather than an ambient call. */ export declare const daysUntil: (date: Json | undefined, options?: { now?: number; }) => number | undefined; /** The buckets {@link groupBy} can cut a date field into. */ export type GroupByBucket = "day" | "month" | "year"; /** The reductions {@link groupBy} can aggregate a bucket with. */ export type GroupByAggregate = NumericReduction | "count"; /** One bucket of a {@link groupBy}, ready for a Kit chart's `{ key, value }`. */ export interface GroupedPoint { key: string; value: number; } /** * Bucket rows by a date field and aggregate each bucket, oldest bucket first. * `valueField` is unused by (and unnecessary for) `count`. */ export declare const groupBy: (rows: Json | undefined, keyField: string, bucket: GroupByBucket, aggregate: GroupByAggregate, valueField?: string) => GroupedPoint[] | undefined;