/** * Fetches CC0 sub-venue concept labels and airport-terminal names from the Wikidata Query Service. * * The labels are candidates that need curation before any recipe uses them as designators. */ import { APIClient, type ClockLike } from "@mailwoman/core/api"; import type { PathBuilderLike } from "path-ts"; import type { BaseFetchOptions, FetchSummary } from "#tools/fetch/download"; /** * The public SPARQL endpoint of the Wikidata Query Service. */ export declare const WDQS_ENDPOINT = "https://query.wikidata.org/sparql"; /** * The descriptive `User-Agent` that Wikidata requires, with the tool name, URL and contact address. */ export declare const WIKIDATA_USER_AGENT = "mailwoman/1.0 (https://github.com/sister-software/mailwoman; teffen@sister.software) corpus-subvenue-fetch"; /** * A Wikidata concept whose labels are collected for one sub-venue designator. */ export interface SubVenueConcept { designatorID: string; qid: string; /** * An English description that lets a reviewer confirm the QID. */ gloss: string; } /** * The concepts whose labels and aliases the fetcher collects. */ export declare const SUBVENUE_CONCEPTS: readonly SubVenueConcept[]; /** * Builds a query for the labels and aliases of the concepts in every language. */ export declare function buildDesignatorLabelQuery(concepts?: readonly SubVenueConcept[]): string; /** * Builds a query for the labels of instances of the class and its subclasses. * * The subclass walk returns some unrelated items. * Consumers must filter them. */ export declare function buildTerminalInstanceQuery(classQID?: string): string; /** * The SPARQL JSON results shape. */ export interface SPARQLResults { results: { bindings: Array>; }; } /** * Reports whether a value has the SPARQL JSON results shape. */ export declare function isSPARQLResults(value: unknown): value is SPARQLResults; /** * Options for {@link createWikidataClient}. */ export interface CreateWikidataClientOptions { /** * The directory of the on-disk response cache. */ cacheDir: PathBuilderLike; /** * The clock for pacing and retries. * Tests can replace it. */ clock?: ClockLike; /** * Axios overrides. * Replacement headers must keep the required `User-Agent`. */ axios?: ConstructorParameters[0]["axios"]; /** * Where the client's own lines go. * A test passes `silentLogger()`. */ logger?: ConstructorParameters[0]["logger"]; } /** * A paced, cached and retrying Wikidata Query Service client. */ export declare class WikidataClient extends APIClient { /** * Runs one SPARQL query. */ query(sparql: string): Promise; } /** * What distinguishes one Wikimedia host's client from another's in {@linkcode wikidataClientConfig}. */ export interface WikidataHostConfig { displayName: string; minRequestIntervalMs: number; timeoutMs: number; /** * The first wait before a retry whose answer sets no `Retry-After`, doubling on each further attempt. * * @defaultValue the client's own default */ retryBaseDelayMs?: number; /** * The `Accept` header the host's JSON answer is requested under. */ accept: string; /** * Whether a cached response body is one the host answered, so a cached error page isn't replayed. */ validate: (body: unknown) => boolean; } /** * The client configuration every Wikimedia host shares: the required `User-Agent`, * three attempts, a disk cache under the caller's TTL, and strict JSON parsing. */ export declare function wikidataClientConfig(host: WikidataHostConfig, options: CreateWikidataClientOptions): ConstructorParameters[0]; /** * Creates a Wikidata client with the fetcher's pacing, retry, cache and header defaults. */ export declare function createWikidataClient(options: CreateWikidataClientOptions): WikidataClient; /** * Options for {@link fetchWikidataSubVenue}. */ export type FetchWikidataSubVenueOptions = BaseFetchOptions; /** * Runs the label and terminal queries. * It saves their raw JSON and writes a manifest. */ export declare function fetchWikidataSubVenue(options: FetchWikidataSubVenueOptions, report?: (line: string) => void): Promise; //# sourceMappingURL=subvenue.d.ts.map