import type { ComponentTag } from "@mailwoman/codex/component"; import type { RowSampler } from "#adapters/wof/sample"; import type { AdapterOptions, CanonicalRow } from "#types"; import { type WOFRecord } from "#utils"; /** * Render an admin-hierarchy variant: the components it contains, in hierarchy order, * joined the way the country joins a line. * * This adapter emits a gazetteer query. * It follows the gazetteer path without a postal layout. * * A country whose postal layout drops the region would collapse `Paris, Île-de-France` back into `Paris`. */ export declare function renderHierarchy(components: Partial>, country: string): { raw: string; components: Partial>; } | null; /** * 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; /** * The country whose hierarchy order and line join render this variant, * when it differs from the record's own. */ layoutCountry?: string; } export interface NameSlotOptions { /** * Canonical surface for the record's own `"default"` slot. * * The admin adapter substitutes the OpenCage-canonical {@link COUNTRY_DISPLAY_NAME} for country records. * * @defaultValue `rec.name` verbatim. */ canonicalName?: (rec: WOFRecord) => string; /** * Ranks a preferred-name language for one record, lower first. * * The adapter visits keys in rank order. * If two keys share a value, the first key's rank decides which language renders the name. * * Brooklyn's `name:wuu_x_preferred` and `name:zho_x_preferred` both hold 布鲁克林区, * and in source order `wuu` would claim it. * * Keys without a preferred-name language follow the ranked ones in source order. * * @defaultValue Source order. */ languageRank?: (language: string) => number; } /** * One name a record's rows are rendered from. */ export interface NameSlot { /** * The `source_id` fragment: `default`, a normalized `name:*` key, or that key * with `-2`, `-3`… for a key's later values. */ key: string; value: string; /** * The ISO 639-3 language of a `name:_x_preferred` slot. * The admin adapter uses it to render a localized hierarchy. */ language?: string; } /** * Build the per-record name-slot list: the canonical `"default"` slot, * then every value of every `name:*` variant, deduplicated so a redundant * `"default"`-equivalent row isn't emitted under a localized key. */ export declare function nameSlotsFor(rec: WOFRecord, options?: NameSlotOptions): NameSlot[]; /** * One record and the ancestors its variants read: names for `wof-postalcode`, records for `wof-admin`. */ export interface WOFRecordEntry { record: WOFRecord; ancestors: A; } interface EmitWOFJSONRowsOptions { /** * The records to render, in ascending WOF-id order. */ records: Iterable>; adapterOptions: AdapterOptions; adapterID: string; localeByCountry: Readonly>; shouldEmit?: (record: WOFRecord) => boolean; nameSlotsFor: (record: WOFRecord) => NameSlot[]; variantsFor: (record: WOFRecord, ancestry: A, slot: NameSlot) => WOFVariantSpec[]; /** * Chooses the rows to emit when the adapter options include a sample. * * The emitter renders every row once into it, then emits the rows it keeps, in WOF-id order. * The caller reads its cell counts afterwards. */ sampler?: RowSampler; /** * Rows the adapter refuses or requires whatever the sample keeps. */ rowRule?: WOFRowRule; /** * Whether a place keeps one row of a name slot whatever the sample keeps, * read from the row's country and slot key. * * Of a kept slot's rows, the one with the most components is emitted while the * records are rendered, so the sampler holds no payload for it. */ placeSlot?: (country: string, slotKey: string) => boolean; } /** * An adapter's decision about single rendered rows, applied on top of the sample. */ export interface WOFRowRule { /** * Whether the row is left out of the output. * * A sampled run still observes the row, so leaving it out moves no other row's keep decision. */ drops: (row: CanonicalRow) => boolean; /** * Whether a sampled run keeps the row whatever its hash. */ requires: (row: CanonicalRow) => boolean; } /** * Emit aligned rows in WOF-id order, enforcing the adapter limit across all name and hierarchy variants. * * A variant's `country` renders it in another country's order and join * (a Japanese hierarchy of a US place is written largest first with no separator), * while the row keeps the record's own country. */ export declare function emitWOFJSONRows(options: EmitWOFJSONRowsOptions): Generator; export {}; //# sourceMappingURL=json-rows.d.ts.map