/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * @file Deterministic canonical-row emission shared by WOF GeoJSON adapters. */ import type { ComponentTag } from "@mailwoman/codex/component"; import type { AdapterOptions, CanonicalRow } from "#types"; import { type AncestorNames, type WOFRecord } from "#utils"; /** * Display name for the country, keyed by ISO 3166-1 alpha-2. * * Must be the **OpenCage-canonical** surface form: the `address-formatter` library expands some * country names en route to its output (e.g. `"United States"` → `"United States of America"`). * If `components.country` and the formatted `raw` disagree, alignment will fail downstream. * * The canonical form keeps the two in lockstep. * * Phase 1 US + FR only. * Extend as new locales come online. * * A missing country uses the country row's `wof:name`; this preserves the * alignment risk for non-canonicalized names. */ export declare const COUNTRY_DISPLAY_NAME: Record; /** * BCP-47 locale defaulting for the corpus row's `locale` field. * * Defaulted by country. */ export declare const LOCALE_BY_COUNTRY: Record; export interface WOFVariantSpec { suffix: string; components: Partial>; /** * Render this variant as an admin hierarchy rather than as a postal address. * * A hierarchy variant is a query — `Paris`, then `Paris, Île-de-France`, then * `Paris, Île-de-France, France` — and several of its steps are not addresses at all. * France's postal layout has no region, so rendering `{ locality, region }` through * it prints `Paris` and the whole variant collapses into the one below it. * * So the hierarchy is joined in its own order: smallest unit first, or largest first * for the systems that write that way, with the country's own separator. */ hierarchy?: boolean; } export interface NameSlotOptions { /** * Canonical surface for the record's own `"default"` slot. * * Default `rec.name` verbatim. * The admin adapter substitutes the OpenCage-canonical {@link COUNTRY_DISPLAY_NAME} for country records. */ canonicalName?: (rec: WOFRecord) => string; } /** * Build the per-record name-slot list: the canonical `"default"` slot, then every `name:*` variant * deduplicated against it so a redundant `"default"`-equivalent row is not emitted under a localized key. */ export declare function nameSlotsFor(rec: WOFRecord, options?: NameSlotOptions): Array<{ key: string; value: string; }>; interface EmitWOFJSONRowsOptions { records: ReadonlyMap; /** * The ancestor names each record's variants read, rather than its ancestor records. * * A record absent from the map resolves to an empty set of ancestor names. * Records with no resolvable ancestor produce the same value. */ ancestry: ReadonlyMap; adapterOptions: AdapterOptions; adapterID: string; localeByCountry: Readonly>; shouldEmit?: (record: WOFRecord) => boolean; nameSlotsFor: (record: WOFRecord) => Array<{ key: string; value: string; }>; variantsFor: (record: WOFRecord, ancestry: AncestorNames, selfName: string) => WOFVariantSpec[]; } /** * Emit aligned rows in WOF-id order, enforcing the adapter limit across all name and hierarchy variants. */ export declare function emitWOFJSONRows(options: EmitWOFJSONRowsOptions): Generator; export {}; //# sourceMappingURL=json-rows.d.ts.map