import type { LayerSourceExclusion } from "@mailwoman/license/admission"; import { type PathBuilder, type PathBuilderLike } from "path-ts"; /** * The run counts a parallel build's worker reports for its state. */ export interface USStateWorkerResult { /** * Runs the register excludes. */ refusedRuns: number; missingRuns: number; } /** * One OpenAddresses run as a plan lists it, with the license its source definition records. * * The recorded license is OpenAddresses' summary of the publisher's terms. * The build admits a run by its register decision. * It copies this field into the region's `ATTRIBUTION.json`. */ export interface OpenAddressesPlanEntry { member: string; license: unknown; /** * The job's layer name, such as `city`, `county` or `state`, which ranks the * run against the state's other runs. */ level?: string | null; /** * When the job last updated. * Runs of one level are ordered by it. */ updated?: string | null; /** * The job's feature count. * * A parallel build starts its states in descending order of it. */ features?: number | null; skip?: boolean; } export interface BuildUSAddressLayerOptions { /** * The data root's `db` directory, under which `addresses///` is written. */ root: PathBuilderLike; version: string; /** * The published version whose regions a new version's first build keeps, * for the states it doesn't rebuild. */ baseVersion?: string; nadParquet: PathBuilderLike; /** * The Overture US address Parquet file whose non-NAD rows join NAD's. */ overtureParquet: PathBuilderLike; /** * The OpenAddresses runs to consider, and the directory of their cached `.zip` archives. */ openAddresses: { plan: readonly OpenAddressesPlanEntry[]; cache: PathBuilderLike; }; /** * The states to build, as USPS codes. * Every state and DC when absent. */ states?: readonly string[]; /** * Regions to leave out of the manifest, such as `us-hi` while its files fall short of the current ones. * Their files are still built. */ omitFromManifest?: readonly string[]; /** * Whether to exclude a source whose register terms are unread or that maps to no register row. * A refused source is excluded either way. * * @defaultValue {@linkcode EXCLUDE_UNREAD_SOURCES} */ excludeUnreadSources?: boolean; /** * The commit the build ran from, for each file's `layer_manifest`. */ buildSHA: string; /** * The Who's On First admin database a record's point is checked against its state's bounding box in. */ adminDatabase: PathBuilderLike; /** * The number of states to build at once, each in its own worker process. * One builds them in this process. */ jobs?: number; /** * SQLite sorter helper threads for each state's build. * * @defaultValue The host's cores divided by `jobs`, between 1 and 8. */ sortThreads?: number; /** * Keep each region this version already holds, read from its `build.json`, and build only the others. * * A region with files and no `build.json` is refused, because its record * and refusal counts cannot be read. */ resume?: boolean; /** * Whether to write the US manifest. * * A parallel build's worker builds one state and leaves the manifest to the parent. * * @defaultValue true */ writeManifest?: boolean; onState?: (summary: USStateBuild) => void; } /** * What one state's build wrote. */ export interface USStateBuild { state: string; records: number; nad: number; overture: number; openAddresses: number; runs: number; seconds: number; /** * Records left out of the state, per source id and reason. */ refused: Record>; /** * Sources whose rows the build never read, because the register doesn't admit them. */ excluded: LayerSourceExclusion[]; /** * Sources read with unread terms or no register row, because the build was told to admit them. */ admittedUnread: LayerSourceExclusion[]; } export interface USAddressLayerBuild { /** * The US manifest, or null for a build that was told to write none. */ manifest: PathBuilder | null; states: USStateBuild[]; refusedRuns: number; missingRuns: number; } /** * Where the cache holds a run, preferring the batch job output, or null when it holds neither form. */ export declare function cachedRun(cache: PathBuilderLike, member: string): Promise<{ path: string; geojson: boolean; } | null>; /** * The US layer's source ranking, highest first: NAD, then OpenAddresses runs by * their publisher's level, then Overture's datasets. * * A city's address points rank above a county's, and a county's above a statewide file. * Runs of one level rank newest job first. * * Overture's datasets rank last because most are copies of OpenAddresses runs from an earlier release. */ export declare const US_ADDRESS_SOURCE_RANKING: readonly ["usgov-nad", "openaddresses:city", "openaddresses:county", "openaddresses:state", "openaddresses:other", "overture:*"]; /** * Ranks every source a state's build reads, lowest first, for the duplicate rule. * * NAD ranks 0. * Each OpenAddresses run takes its own rank, ordered by its level in * {@linkcode US_ADDRESS_SOURCE_RANKING}, then by newest job, then by member. * * Overture's datasets rank after every run, so one run's record repeated by another run, * or by Overture, is dropped from the lower-ranked source. */ export declare function usAddressSourceRanks(runs: readonly OpenAddressesPlanEntry[]): (source: string) => number; /** * Builds every requested state's `lookup.db` and `detail.db` under `addresses/us-//`, * one state at a time, and writes the US manifest once every state is built. * * A state takes NAD's rows when release 24 has any, Overture's rows from the datasets * other than NAD, and the plan's runs for the state that the cache holds. * Each is read only when {@linkcode admitUSStateSources} admits it by its register decisions. * * The state's `build.json` lists every source the register excluded, and each * admitted source whose terms are unread, with the reason. * A record that a higher-ranked source repeats, by {@linkcode usAddressSourceRanks}, is dropped. * * Territories are their own ISO 3166-1 countries and are not built here. */ export declare function buildUSAddressLayer(options: BuildUSAddressLayerOptions): Promise; //# sourceMappingURL=layer.d.ts.map