/** * @fileoverview Latest-period selection behind worldbank_get_data's `mrv` and * `mrnev`, shared by both data paths. Upstream's own `mrv`, `mrnev`, and * `frequency` are never sent: the Indicators API's response cache does not key * on them, so a request carrying one can be answered with the body computed for * another. The standard path reads the `date` window {@link latestWindow} * computes at the selected period form and, when that falls short, the * {@link fullSpan} at that form; both paths reduce what they read with * {@link selectLatest}. * @module services/worldbank/latest-values */ import { type PeriodForm } from './periods.js'; /** * Which latest periods to keep: `mrv`, the N most recent periods holding a value * for any series in the set, every series at each; `mrnev`, each series' own N * most recent periods holding a value. */ export type LatestSelection = { mode: 'mrv' | 'mrnev'; count: number; }; /** * Every period a series carries at `form`, as a `date` span. A span's form * selects which periods a series publishing several forms returns — Global * Economic Monitor answers `1900:2100` with its annual rows only, and * `1900M01:2100M12` with its months — while a series with one form answers a * span at any other form with its whole series. `1900:2100` returns the same rows * as a request without `date`. */ export declare function fullSpan(form: PeriodForm): string; /** * The window a latest-value read asks for first, at `form`, open-ended: from * {@link WINDOW_YEARS} years before `year`, or far enough back to hold `count` * periods when that is further — `2016:2100`, `2016Q1:2100Q4`, or * `2024M01:2100M12` in 2026. It holds the answer for nearly every series and * country; a series short of `count` values inside it is read again over the * {@link fullSpan} at the same form. */ export declare function latestWindow(count: number, year: number, form?: PeriodForm): string; /** * The period form a selection is made within when the caller names none: annual * whenever the periods include a year, otherwise the first form they carry. A * series that publishes an annual value beside monthly or quarterly ones is * selected annually; a quarterly-only series keeps its quarters. */ export declare function selectionForm(periods: Iterable): PeriodForm | undefined; /** How to read a row of either data path. */ export type RowReader = { /** The series a row belongs to: its country, plus any further dimension value. */ series: (row: T) => string; period: (row: T) => string; hasValue: (row: T) => boolean; }; /** The rows a selection keeps, in input order, and whether the rows held enough to make it. */ export type LatestRows = { rows: T[]; /** * True when the rows answered the selection in full: `mrv` found `count` periods * holding a value, `mrnev` found `count` values for every series. False on no rows. */ complete: boolean; /** For `mrnev`, the series holding fewer than `count` values at the form, in input order. */ short: string[]; }; /** * Keep the latest periods `selection` asks for out of `rows`, counting only rows * at `form`: a row at any other form never matches. A series with no value at all * keeps no row under `mrnev`, and under `mrv` a series is kept at each selected * period, null or not, as the standard endpoint's own `mrv` returns it. */ export declare function selectLatest(rows: readonly T[], selection: LatestSelection, form: PeriodForm | undefined, read: RowReader): LatestRows; //# sourceMappingURL=latest-values.d.ts.map