/** * @fileoverview Pure logic behind worldbank_get_data's source-scoped path — the * `/v2/sources/{id}/...` data API that serves the indicators the standard data * endpoint rejects with message id 175. Reads a source's concept layout, picks * the default value of its extra dimension, normalizes the concept/id/value rows * the API returns, and orders them locally, since upstream's row order changes * with the shape of the request. `mrv` and `mrnev` are selected locally from the * rows through {@link SCOPED_ROW_READER}, after the default WDI Database Archives * release is resolved from them. * @module services/worldbank/source-scoped */ import type { RowReader } from './latest-values.js'; import type { DimensionValue, RawSourceListing, RawSourceObservation } from './types.js'; /** * How a source's data is addressed: its display name and, when it has one, the * concept beyond Country/Series/Time (`Version`, `Classification`, `Sector`, * `Counterpart-Area`), spelled as upstream reports it. */ export type SourceLayout = { sourceId: string; sourceName: string; dimension: string | undefined; }; /** * Read `/sources/{id}/concepts` into a layout. A source is routable when it * carries Country, Series, and Time plus at most one further concept; anything * else — a subnational geography, a `Year` axis, two extra dimensions — has no * mapping onto the tool's inputs and yields `undefined`. */ export declare function layoutFromConcepts(sourceId: string, listing: RawSourceListing): SourceLayout | undefined; /** Flatten a value listing (`/sources/{id}/{concept}`) into id/label pairs. */ export declare function valuesFromListing(listing: RawSourceListing): DimensionValue[]; /** * The value to pin when the caller names none, or how to resolve one: * * - a dimension with a single value pins it; * - `Counterpart-Area` pins `WLD`, the World total across counterparts — the * counterpart the standard endpoint reports for International Debt Statistics * series; * - `Version` is resolved from the data (`resolve_version`), because a series an * archive retired carries only nulls in every later version; * - any other dimension — ICP measures, GDLD sectors, FPN methodology releases — * is left unpinned, and every value comes back with each row labelled. */ export declare function defaultSelection(concept: string, values: readonly DimensionValue[]): { selection: 'only_value' | 'world_total'; value: DimensionValue; } | { selection: 'resolve_version' | 'every_value'; }; /** One source-scoped observation, normalized. */ export type ScopedRow = { countryId: string; countryName: string; period: string; dimension: DimensionValue | undefined; value: number | null; }; /** * Pick a row's country, time, and dimension out of its `variable[]` by concept * name — upstream orders the tuple differently from one request to the next. A * row without a country or a time can't be placed and yields `undefined`. */ export declare function readRow(raw: RawSourceObservation, dimensionConcept: string | undefined): ScopedRow | undefined; /** * The newest version, by its position in the source's own ascending listing, * that holds at least one value among the rows. `undefined` when every row is null. */ export declare function newestVersionWithData(rows: readonly ScopedRow[], versions: readonly DimensionValue[]): DimensionValue | undefined; /** * How the latest-value selection reads a source-scoped row. Each country and * dimension value is its own series, so an unpinned dimension answers `mrnev` * with every value's own latest periods. */ export declare const SCOPED_ROW_READER: RowReader; /** * Order rows the way the standard endpoint does — country name, then newest period * first — with dimension values in the source's listing order. Upstream's own * order changes with the shape of the request, so it can't be paginated as-is. */ export declare function sortRows(rows: readonly ScopedRow[], values: readonly DimensionValue[]): ScopedRow[]; //# sourceMappingURL=source-scoped.d.ts.map