import { ReactNode } from "react"; //#region src/source/queryContract.d.ts /** A single condition in a filter tree: one column, one operator, one value. */ interface QueryCondition { /** Column or filter key. */ key: string; /** * Operator id — `"eq"`, `"contains"`, `"between"`, … The operator set is * owned by the filtering work; this contract only carries it. */ op: string; /** Operand, if the operator takes one. `"empty"` and friends do not. */ value?: unknown; } /** * A node in the filter tree: conditions combined with one operator, nestable * so `(a AND b) OR c` is expressible. */ interface QueryFilterGroup { /** How this group's children combine. */ combinator: "and" | "or"; /** Conditions and nested groups, in the order the user built them. */ conditions: readonly (QueryCondition | QueryFilterGroup)[]; } /** Narrows a filter-tree child to a nested group. */ declare function isFilterGroup(node: QueryCondition | QueryFilterGroup): node is QueryFilterGroup; //#endregion //#region src/filters/filterTreeCodec.d.ts /** URL param for the versioned tree (`ft=1.{…}`). */ declare const FILTER_TREE_PARAM = "ft"; /** Current encoding version. Unknown versions are dropped, never reinterpreted. */ declare const FILTER_TREE_VERSION = 1; /** True when a tree has at least one condition (nested groups count). */ declare function isActiveFilterTree(tree: QueryFilterGroup | undefined): tree is QueryFilterGroup; /** * Parse a stored `ft` value. Missing, malformed, or unknown-version * strings return `undefined` so an old or hand-edited link never * silently becomes a different query. */ declare function parseFilterTree(raw: string | null | undefined): QueryFilterGroup | undefined; /** Encode a tree for the URL. Empty / undefined trees omit the param. */ declare function serializeFilterTree(tree: QueryFilterGroup | undefined): string | undefined; //#endregion //#region src/sort/compare.d.ts /** One level of a multi-column sort. */ interface SortLevel { key: string; dir: SortDirection; } //#endregion //#region src/types.d.ts /** Sort direction for a column. */ type SortDirection = "asc" | "desc"; /** Comparable primitive returned by a sort-value extractor. */ type SortableValue = string | number | boolean | null | undefined; //#endregion //#region src/formula/evaluate.d.ts /** The error values a formula can produce, spelled as a spreadsheet spells them. */ declare const FORMULA_ERRORS: { /** A column the formula names does not exist. */readonly name: "#NAME?"; /** A number was needed and the value was not one. */ readonly value: "#VALUE!"; /** Division by zero. */ readonly divideByZero: "#DIV/0!"; /** The formula depends on itself, directly or through others. */ readonly cycle: "#CYCLE!"; /** The formula could not be parsed at all. */ readonly syntax: "#ERROR!"; }; /** One of the error codes above. */ type FormulaErrorCode = (typeof FORMULA_ERRORS)[keyof typeof FORMULA_ERRORS]; /** What a formula evaluates to. */ type FormulaValue = { readonly kind: "number"; readonly value: number; } | { readonly kind: "text"; readonly value: string; } | { readonly kind: "boolean"; readonly value: boolean; } | { readonly kind: "blank"; } | { readonly kind: "error"; readonly code: FormulaErrorCode; }; //#endregion //#region src/formula/formulaColumn.d.ts /** One user-typed formula column. */ interface FormulaColumnSpec { /** Column key — also the name other formulas reference it by. */ key: string; /** Header caption. Defaults to the key. */ header?: string; /** The formula text, as the user typed it. A leading `=` is fine. */ formula: string; /** Format the result for display. The raw value still sorts and exports. */ format?: (value: FormulaValue) => string; } //#endregion //#region src/formula/formulaUrlCodec.d.ts /** * Write formula columns as a URL parameter value. * * @param specs - The columns to serialize, in the order to show them. * @returns The parameter value, or `""` when there is nothing to say. */ declare function serializeFormulaColumns(specs: readonly FormulaColumnSpec[]): string; /** * Read formula columns back from a URL parameter value. * * A malformed entry is dropped rather than thrown: a URL is user input, and a * hand-edited one should degrade to the columns it still describes instead of * an error page. The formula text is carried through untouched and unparsed. * * @param raw - The parameter value. * @returns The columns it describes, in order, each key appearing once. */ declare function deserializeFormulaColumns(raw: string | null): FormulaColumnSpec[]; //#endregion //#region src/aggregate/aggregate.d.ts /** The aggregate functions available by name. */ type AggregateName = "sum" | "avg" | "count" | "min" | "max"; /** * A custom aggregator: the values found for one column across the rows being * aggregated, already narrowed to those that are present. * * Return whatever the cell should show — a number, a formatted string, a * node. Return `undefined` for "no cell here". * * The return type is `ReactNode` so the built mapper is directly assignable * to `summaryRow` and `groupAggregates`, which is the whole point of it. */ type Aggregator = (values: readonly TValue[]) => ReactNode; //#endregion //#region src/pivot/pivotModel.d.ts /** One computed value per cell. */ interface PivotMeasure { /** The column key whose values are aggregated. */ key: string; /** A built-in aggregate name, or your own function. */ agg: AggregateName | Aggregator; /** Header caption. Defaults to the column key. */ label?: string; } /** What to pivot, and how. */ interface PivotConfig { /** Dimensions down the side, outermost first. Empty pivots to one line. */ rows: readonly string[]; /** Dimensions across the top, outermost first. Empty gives measure columns. */ columns: readonly string[]; /** What every cell computes. At least one, or there is nothing to show. */ measures: readonly PivotMeasure[]; /** A totals line for every level above the innermost. Defaults to `true`. */ subtotals?: boolean; /** A grand-total line across everything. Defaults to `true`. */ grandTotals?: boolean; } //#endregion //#region src/pivot/pivotUrlCodec.d.ts /** Everything the pivot parameter carries. */ interface PivotUrlState { /** What to pivot, and how. */ config: PivotConfig; /** * The keys of the folded subtotal lines — a `PivotRow.key`, which is what * `pivot`'s `collapsed` option matches against. */ collapsed: readonly string[]; } /** * Write the whole pivot state as a URL parameter value. * * @param state - The configuration, and which groups are folded. * @returns The parameter value, or `""` when there is nothing to say. */ declare function serializePivotState(state: PivotUrlState): string; /** * Read the whole pivot state back from a URL parameter value. * * Unknown segments are ignored rather than throwing: a URL is user input, * and a hand-edited one should degrade to a simpler pivot instead of an * error page. * * @param raw - The parameter value. * @returns The configuration it describes, and which groups are folded. */ declare function deserializePivotState(raw: string | null): PivotUrlState; /** * Write a configuration as a URL parameter value. * * @param config - The configuration to serialize. * @returns The parameter value, or `""` when there is nothing to say. */ declare function serializePivot(config: PivotConfig): string; /** * Read a configuration back from a URL parameter value. * * @param raw - The parameter value. * @returns The configuration it describes. */ declare function deserializePivot(raw: string | null): PivotConfig; //#endregion export { FILTER_TREE_PARAM, FILTER_TREE_VERSION, type FormulaColumnSpec, type PivotConfig, type PivotMeasure, type PivotUrlState, type QueryCondition, type QueryFilterGroup, type SortDirection, type SortLevel, deserializeFormulaColumns, deserializePivot, deserializePivotState, isActiveFilterTree, isFilterGroup, parseFilterTree, serializeFilterTree, serializeFormulaColumns, serializePivot, serializePivotState }; //# sourceMappingURL=query.d.cts.map