/** * Money-aware aggregation: exact `sum` / `min` / `max` over money * fields. * * The generic reducers (`aggregate/reducers.ts`) read a field via * `readNumber`, which coerces a string (the stored scaled-integer form * of money, e.g. `'12345'`) to `0` — so an un-wrapped money `sum` would * silently return zero. {@link wrapMoneyReducers} rewrites any `sum` / * `min` / `max` over a declared money field into a reducer that * accumulates per-currency `BigInt` totals of the stored integers, so * the result is exact for any magnitude (past `Number.MAX_SAFE_INTEGER` * included). * * Results are currency-aware and never silently mix currencies: * - **fixed** mode → a single exact decimal string. * - **multi** mode → an exact `Record` map. * - **`sum` with `convertTo` + `fx`** → a single exact string, with * each currency converted via BigInt arithmetic (no float). * * `remove()` is implemented for every money reducer so they participate * in incremental live-aggregation and materialized-view maintenance * exactly like the generic reducers they replace. */ import type { MoneyDescriptor } from './descriptor.js'; import type { AggregateSpec } from '../../with-lookup/aggregate/aggregation.js'; export type FxRates = Record; /** * Rewrite any `sum` / `min` / `max` reducer over a declared money field * into its exact BigInt money-aware equivalent. Other reducers (and * reducers over non-money fields) pass through unchanged. Returns a new * spec; the input is not mutated. */ export declare function wrapMoneyReducers(spec: AggregateSpec, moneyFields: Record): AggregateSpec;