import { Map, MapProfile, UnmapMapOptions, UnmapControlsOptions } from '@unmap/maps'; export { DEMO_CITIES, DemoCity, Map, MapProfile, Projection, STYLE_NAMES, StyleInput, StyleName, UnmapControlsOptions, UnmapMapOptions, createMap, maplibregl, unmapStyle } from '@unmap/maps'; import { Geocoder, Places, QueryOptions, QueryResponse, IdentifyOptions, IdentifyResponse } from '@unmap/geocoding'; export * from '@unmap/geocoding'; import { RetryPolicy, UnmapError } from '@unmap/core'; export { RetryPolicy, UnmapError, parseRetryAfter } from '@unmap/core'; import { Router } from '@unmap/routing'; export * from '@unmap/routing'; import { Elevation } from '@unmap/elevation'; export * from '@unmap/elevation'; /** * Typed clients for road events (`/incidents`, `/closures`, `/road-conditions`) and for data * correction (`POST /feedback`). * * These live in `@unmap/sdk` rather than in packages of their own. A twelfth and thirteenth npm * package would each need an entry in the changesets fixed group and a trusted publisher * configured on npmjs.com, which is founder work, and neither has a framework wrapper the way * geocoding and routing do. If a customer ever wants roads without the rest of the SDK, that is * the moment to split it out. */ type RoadEventType = "closure" | "incident" | "construction" | "weather" | "restriction" | "ferry" | "hazard" | "special_event" | "unknown"; type RoadCondition = "dry" | "wet" | "snow" | "ice" | "packed_snow" | "reduced_visibility" | "travel_not_recommended" | "closed" | "unknown"; type RoadSeverity = "minor" | "major" | "unknown"; interface AffectedRoad { name: string; direction: "north" | "south" | "east" | "west" | "both" | "unknown"; /** True only when the publisher says closed. Never inferred from the description. */ closed: boolean; from?: string; to?: string; condition: RoadCondition; } interface RoadEvent { /** `um:road::`. */ id: string; /** The publisher's own id, so a report can be taken back to them. */ source_id: string; /** ISO 3166-2, e.g. `CA-BC`. */ jurisdiction: string; type: RoadEventType; /** The publisher's own subtype strings, untranslated. */ subtypes: string[]; status: "active" | "planned" | "archived"; severity: RoadSeverity; /** * The publisher's description, verbatim. * * Believe this over `type` when they disagree: our categories are a lossy projection of someone * else's taxonomy, and the sentence a driver needs is in the prose. */ description: string; headline?: string; /** The worst surface condition across this event's roads. */ condition: RoadCondition; roads: AffectedRoad[]; /** GeoJSON Point or LineString, WGS84. */ geometry: { type: string; coordinates: unknown; } | null; starts_at: string | null; ends_at: string | null; source_updated_at: string | null; unmap_updated_at: string; source: string; } interface RoadEventsResponse { data: RoadEvent[]; meta: { status: "current" | "stale" | "partial" | "unknown"; attribution: string; unmap_updated_at: string; /** * Jurisdictions that could not be reached, each with a reason. * * **Check this.** On `/closures` an empty `data` reads as "nothing is shut" to someone * deciding whether to drive, and that is a very different answer from "we could not reach * British Columbia". */ unavailable?: { jurisdiction: string; reason: string; }[]; /** * Feeds served from unmap's five-minute poll rather than fetched for this request (Alberta), * each with its age. A feed older than `max_age_seconds` is in `unavailable` instead. */ polled?: { jurisdiction: string; feed: "events" | "conditions"; polled_at: string; age_seconds: number; max_age_seconds: number; }[]; }; } interface RoadEventQuery { /** Comma-separated ISO 3166-2 codes, or an array. An uncovered code is a 400, not an empty list. */ jurisdiction?: string | readonly string[]; bbox?: [number, number, number, number]; near?: [number, number]; /** Metres from `near`. Default 25000, max 500000. */ radius?: number; type?: RoadEventType | readonly RoadEventType[]; severity?: RoadSeverity | readonly RoadSeverity[]; status?: "active" | "planned" | "archived"; /** ISO 8601. Only events the publisher changed at or after this time. */ updated_since?: string; /** 1 to 500, default 100. Applied AFTER the endpoint's own narrowing. */ limit?: number; signal?: AbortSignal; } interface RoadsOptions { key: string; gateway?: string; fetch?: typeof fetch; /** * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it. * * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container * `503`. A `502` has none: routing and `/elevation` both use * `upstream_error`. With no header the client backs off itself. A wait longer than * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead. * See `RetryPolicy` in `@unmap/core`. */ retry?: RetryPolicy | false; } /** * A road events failure. * * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside * every other unmap client's errors. `status` and `code` carry the HTTP status and the * gateway's error code, and `retryAfterSeconds` comes from the `Retry-After` header. */ declare class RoadsError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } /** * Canadian road events. * * const { data, meta } = await unmap.roads.closures({ jurisdiction: "CA-BC" }); * * A 503 means every requested jurisdiction was unreachable; the body still carries * `meta.unavailable`, so the thrown error is the exception rather than the information. Prefer * reading `meta.unavailable` on a 200 over treating an empty list as good news. */ declare class Roads { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: RoadsOptions); /** Every current road event. */ incidents(query?: RoadEventQuery): Promise; /** The subset where a road is actually shut. Narrowed before `limit` is applied. */ closures(query?: RoadEventQuery): Promise; /** * The subset carrying a surface condition. * * Thin for British Columbia by design: its feed reports lane availability rather than the * surface, so unmap answers `unknown` instead of inferring a dry road from open lanes. */ conditions(query?: RoadEventQuery): Promise; private request; } type FeedbackProduct = "tiles" | "terrain" | "names" | "geocoding" | "places" | "routing" | "layers" | "transit" | "roads" | "ev"; type FeedbackCategory = "incorrect_location" | "incorrect_address" | "missing_place" | "wrong_place_name" | "wrong_category" | "bad_route" | "missing_road_closure" | "incorrect_road_condition" | "incorrect_transit_result" | "other"; interface FeedbackReport { product: FeedbackProduct; category: FeedbackCategory; /** Up to 2000 characters, stored exactly as written. One of this or `resultId` is required. */ description?: string; /** The unmap id of the result being reported. */ resultId?: string; /** * The request being reported. * * **Only send this with the reporter's explicit agreement.** The gateway refuses it without * `include_context: true`, which this sets whenever `context` is present, and that flag is * meant to record a person's choice rather than a client default. unmap redacts query strings * from its own logs; a client that attached them here would undo that. */ context?: unknown; signal?: AbortSignal; } interface FeedbackReceipt { /** Quote this in a follow-up. */ id: string; status: string; created_at: string; /** Whether a request context was actually kept. `false` when none was offered. */ context_stored: boolean; } /** * Report wrong data. * * await unmap.feedback.submit({ * product: "geocoding", * category: "incorrect_location", * description: "17 Ave SW returns a street in Edmonton.", * }); * * Authenticated like everything else and **never metered**: telling us our data is wrong does not * cost a call. At most 200 reports per account per day. */ declare class Feedback { private readonly key; private readonly base; private readonly fetchImpl; constructor(opts: RoadsOptions); submit(report: FeedbackReport): Promise; /** A report about one place. `product` and `result_id` come from the path. */ aboutPlace(placeId: string, report: Omit): Promise; private post; } type TransitMetaStatus = "current" | "stale" | "partial" | "unknown"; interface TransitMeta { /** Static GTFS is scheduled data. Realtime will use a different value and updated_at. */ schedule_type: "scheduled"; source?: string; source_updated_at?: string | null; source_version?: string; content_hash?: string | null; sources?: readonly { id: string; source: string; source_url: string; attribution: string; source_updated_at: string | null; source_version: string; content_hash: string | null; status: "current" | "stale" | "unknown"; }[]; unmap_updated_at: string; data_version?: string; status: TransitMetaStatus; attribution: string; } interface TransitResponse { data: T; meta: TransitMeta; } interface TransitAgency { id: string; feed: string; name: string; url?: string; timezone: string; lang?: string; phone?: string; fare_url?: string; } interface TransitStop { id: string; feed: string; name: string; coordinates: [number, number]; code?: string; description?: string; zone_id?: string; parent_station_id?: string; wheelchair_boarding?: 0 | 1 | 2; route_ids: string[]; /** Metres from the requested point. Present only on nearbyStops. */ distance?: number; } interface TransitRoute { id: string; feed: string; agency_id: string; short_name?: string; long_name?: string; description?: string; route_type: number; colour?: string; text_colour?: string; url?: string; } interface TransitDeparture { stop_id: string; route_id: string; trip_id: string; headsign?: string; arrival: string; departure: string; stop_sequence: number; /** 2 = phone agency; 3 = coordinate with driver. Omitted for ordinary pickup. */ pickup_type?: 2 | 3; schedule_type: "scheduled"; } interface NearbyStopsOptions { /** Metres. Default 1000, range 50 to 10000. */ radius?: number; /** Default 20, maximum 100. */ limit?: number; signal?: AbortSignal; } interface DepartureOptions { /** An instant. Date values serialize to ISO; strings must include Z or an offset. Default now. */ at?: Date | string; /** Minutes after at. Default 60, maximum 240. */ window?: number; /** Default 50, maximum 200. */ limit?: number; signal?: AbortSignal; } interface TransitOptions { key: string; gateway?: string; fetch?: typeof fetch; /** * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it. * * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container * `503`. A `502` has none: routing and `/elevation` both use * `upstream_error`. With no header the client backs off itself. A wait longer than * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead. * See `RetryPolicy` in `@unmap/core`. */ retry?: RetryPolicy | false; } /** * A transit failure. * * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside * every other unmap client's errors. `status` and `code` carry the HTTP status and the * gateway's error code, and `retryAfterSeconds` comes from the `Retry-After` header. */ declare class TransitError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } /** Static Canadian GTFS data. Scheduled departures ship before realtime. */ declare class Transit { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: TransitOptions); agencies(signal?: AbortSignal): Promise>; nearbyStops(near: [number, number], options?: NearbyStopsOptions): Promise>; getStop(id: string, signal?: AbortSignal): Promise>; getRoute(id: string, signal?: AbortSignal): Promise>; departures(id: string, options?: DepartureOptions): Promise>; private get; } /** Freshness of a capability or a source. `unknown` means no cadence was declared. */ type CoverageFreshness = "current" | "stale" | "unknown"; /** How a source's freshness is judged, mirrored from the gateway's `FreshnessPolicy`. */ interface CoverageFreshnessPolicy { /** ISO 8601 duration, `static`, or `unknown`. */ interval: string; basis: string; /** When `freshness_status` stops being true, or null when staleness cannot be asked. */ stale_after: string | null; } /** Where a source's data came from and when unmap last produced it. */ interface CoverageProvenance { source_updated_at: string | null; unmap_updated_at: string | null; build_id: string | null; version: string; content_hash: string | null; freshness_policy: CoverageFreshnessPolicy; freshness_status: CoverageFreshness; /** Counts the producing job measured. Omitted when it measured none. */ measurements?: Record; } interface CoverageSource { id: string; provider: string; /** Bilingual, like every human-readable field in this document. */ dataset_name: { en: string; fr: string; }; canonical_url: string; licence: { en: string; fr: string; }; licence_url: string; attribution: string; jurisdiction: string[]; /** ISO 8601 duration, e.g. `P1D`. */ refresh_interval: string; last_checked_at: string; /** Upstream's edition date, when unmap last produced the data, which build did, and how fresh that is. */ provenance: CoverageProvenance; coverage: string; known_gaps: { en: string; fr: string; }; quality_status: string; /** A note on the source, in English, present only when there is one. */ notes?: string; } interface CoverageCapability { /** `tiles`, `geocoding`, `routing`, `places`, `transit`, `roads`, and so on. */ id: string; display_name: { en: string; fr: string; }; /** `planned` is published as honestly as `live`: a capability absent from the page reads as "not our problem". */ availability: "live" | "planned"; /** The endpoints that serve it. Empty while planned. */ endpoints: string[]; coverage: { en: string; fr: string; }; /** Written to be accurate rather than flattering. Read this before promising coverage to a user. */ known_gaps: { en: string; fr: string; }; /** ISO 3166-2 subdivisions, or `CA` for national. */ jurisdictions: string[]; freshness_status: CoverageFreshness; sources: CoverageSource[]; } interface CoverageDocument { generated_at: string; /** How to read the dates below, in both official languages. */ freshness_basis: { en: string; fr: string; }; /** Schema tag of the manifests behind `provenance`, so a consumer can pin what it parses. */ provenance_schema: string; capabilities: CoverageCapability[]; /** Every jurisdiction code any source claims. */ jurisdictions: string[]; } declare class CoverageError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } interface CoverageOptions { gateway?: string; /** Override the fetch implementation (tests, non-global environments). */ fetch?: typeof fetch; retry?: RetryPolicy | false; } /** Where unmap works. Takes no key: the endpoint is unauthenticated and unmetered. */ declare class Coverage { private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts?: CoverageOptions); /** The whole document. Cached an hour at the edge, so polling it is cheap. */ get(opts?: { signal?: AbortSignal; }): Promise; /** * One capability by id, or `undefined` when the document does not describe it. * * const transit = await unmap.coverage.capability("transit"); * if (!transit?.jurisdictions.includes("CA-ON")) return "not available here yet"; */ capability(id: string, opts?: { signal?: AbortSignal; }): Promise; } /** DB-IP City Lite is CC BY 4.0: show `text`, linked to `url`, wherever the result is used. */ interface GeoIpAttribution { text: string; url: string; } /** An address the database lists. Accuracy is city level at best, often only the country. */ interface GeoIpFound { /** The canonical form of the address that was looked up. */ ip: string; found: true; /** ISO 3166-1 alpha-2. */ country_code: string; country: string; /** `null` when the database has no region for the address. */ region: string | null; /** `null` when the database has no city for the address. */ city: string | null; /** `[longitude, latitude]`, the same order as the rest of the SDK. */ coordinates: [number, number]; accuracy: "city"; release: string; attribution: GeoIpAttribution; } /** * A public address the database does not list, such as unassigned space. Private, loopback, * link-local and other reserved addresses are not this: like a malformed address, they throw * `GeoIpError` with status `400` and code `invalid_ip`. */ interface GeoIpNotFound { ip: string; found: false; release: string; attribution: GeoIpAttribution; } type GeoIpResult = GeoIpFound | GeoIpNotFound; interface GeoIpLocateOptions { signal?: AbortSignal; } declare class GeoIpError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } interface GeoIpOptions { key: string; gateway?: string; fetch?: typeof fetch; retry?: RetryPolicy | false; } /** * City-level location for an IP address, worldwide. * * const here = await unmap.geoip.locate(); // the caller's own address * const google = await unmap.geoip.locate("8.8.8.8"); * * Omit the address to look up the machine making the request. From a browser that is the * visitor; from a server it is the server. Show `attribution` wherever you use the result. * A malformed, private or reserved address throws `GeoIpError` (`400`, `invalid_ip`); an * unavailable dataset throws one with status `503`. */ declare class GeoIp { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: GeoIpOptions); locate(ip?: string, opts?: GeoIpLocateOptions): Promise; } interface TimezoneResult { timezone: string | null; offset: string | null; offsetSeconds: number | null; dst: boolean | null; } interface TimezoneLookupOptions { /** Instant the offset is evaluated at. Omit it for the current time. */ at?: Date; signal?: AbortSignal; } declare class TimezoneError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } interface TimezoneOptions { key: string; gateway?: string; fetch?: typeof fetch; retry?: RetryPolicy | false; } /** * IANA timezone for a coordinate. * * const zone = await unmap.timezone.lookup([-114.0719, 51.0447]); * * The coordinate is `[longitude, latitude]`, the same order as the rest of the SDK. * `at` selects the offset. It does not change which zone the coordinate falls in. */ declare class Timezone { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: TimezoneOptions); lookup(coordinate: [number, number], opts?: TimezoneLookupOptions): Promise; } /** * Clients for the named Canadian layer catalog (`/layers`) and for tenant overlays (`/byod`). * * Both existed as endpoints with no client until the SDK parity audit * (`apps/gateway/test/sdk-parity.test.ts`) went looking and found them. They were the two entries * in that audit's `KNOWN_GAPS`; this closes both. * * ## Why these are the two that mattered * * `@unmap/maps` already consumes layer and overlay **tiles** through a style document, which is * why the gap was easy to miss: maps work. What had no client was everything *around* the tiles. * Nothing could ask what layers exist, what a layer's licence says, or which add-on it needs, and * nothing could upload an overlay without hand-rolling a multipart request. */ interface LayerArchive { id: string; minzoom: number; maxzoom: number; } /** * The capability a gated layer's tiles need. These are capability ids (`urbanNoise`), not the * `addon-*` SKUs a customer buys (`addon-urban-noise`). */ type LayerCapability = "agriculture" | "remote" | "mining" | "ski" | "urbanNoise"; /** * One catalog layer. * * `licence`, `attribution` and `known_gaps` are the reason to read this rather than hard-code a * layer id: they are the governance record, and a caller displaying a layer has to display its * attribution. */ interface Layer { id: string; display_name: { en: string; fr: string; }; namespace?: "core" | "agriculture" | "remote" | "mining" | "ski" | "noise"; /** ISO 3166 codes where coverage is VERIFIED. `coverage` carries the prose, including gaps. */ jurisdiction?: string[]; source?: string; source_url?: string; licence: string; attribution: string; coverage: string; resolution?: string; updated_at?: string; source_updated_at?: string; ingestion_version?: string; schema_version?: string; freshness_policy?: string; known_gaps?: string; /** * The capability this layer's tiles need, or null when it is core. Reading the catalog is never * gated; the tiles are, and answer `403` `addon_required` on a key without the add-on. */ addon?: LayerCapability | null; archives?: LayerArchive[]; /** Vector source-layer name inside the archive. */ source_layer?: string; /** Every source-layer, present only when the archive stacks more than one (survey grids). */ source_layers?: string[]; } interface ByodOverlay { /** `ovl_` plus twelve hex characters. */ id: string; name: string; kind: "geojson" | "pmtiles"; bytes: number; createdAt: string; url: string; /** The `byod:` token to pass to `overlays`. This is the field you actually want. */ overlay: string; } interface ByodList { overlays: ByodOverlay[]; /** The caps, from the server rather than from a constant here that could drift. */ limits: { maxFiles: number; maxBytes: number; kinds: string[]; }; } interface CatalogOptions { key: string; gateway?: string; fetch?: typeof fetch; /** * Retry policy for reads (`429`, `502`, `503` and transport failures). `false` disables it. * Uploads and deletes are never retried. See `RetryPolicy` in `@unmap/core`. */ retry?: RetryPolicy | false; } /** * A layer-catalog or overlay failure. * * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches it alongside every * other unmap client's errors. `code` is the gateway's: `not_found` for an unknown layer or * overlay id, `bad_request` for an upload the server refused (wrong type, over the size cap, or * over the overlay count). */ declare class CatalogError extends UnmapError { constructor(status: number, message: string, code?: string, retryAfterSeconds?: number); } /** The pieces both clients share: the key, the base URL, fetch, and the read path. */ declare abstract class KeyedClient { protected readonly key: string; protected readonly base: string; protected readonly fetchImpl: typeof fetch; private readonly retry; constructor(opts: CatalogOptions); protected url(path: string, values?: Record): string; /** A GET, retried per the policy. Throws `CatalogError` on a non-2xx. */ protected read(path: string, init: RequestInit, values?: Record): Promise; } /** * The named Canadian layer catalog. * * const layers = await unmap.layers.list({ jurisdiction: "CA-AB" }); * const soils = await unmap.layers.get("agriculture.soils"); * console.log(soils.attribution, soils.known_gaps); * * A retired or misspelled id is a plain `404` `not_found`, the same as one that never existed: * the gateway keeps no aliases for renamed layers. */ declare class Catalog extends KeyedClient { /** * Every catalog layer, or only those with verified coverage in `jurisdiction`. * * A country code matches its own subdivisions (`CA` includes `CA-AB`). An unknown code is an * empty list, not an error: the catalog has nothing there. */ list(opts?: { jurisdiction?: string; signal?: AbortSignal; }): Promise; /** One layer by id. Throws `CatalogError` 404 `not_found` when it does not exist. */ get(id: string, opts?: { signal?: AbortSignal; }): Promise; } /** * Tenant overlays: your own GeoJSON or PMTiles, stored against your key. `upload`, `list` and * `delete` need a server key; a browser key only reads an overlay by id (403 `server_key_required`). * * const { overlay } = await unmap.byod.upload(file, { name: "Service areas" }); * const map = new Unmap({ key, container: "#map", overlays: [overlay] }); * * The `overlay` field on the result is the `byod:` token: that is what `overlays` takes, not * the bare id, and returning the whole record rather than just the id is what makes that hard to * get wrong. * * Hard caps are the server's (10 overlays, 5 MiB each) and are reported by `list()` rather than * duplicated here, so a change on the server cannot leave a stale constant in the client. */ declare class Byod extends KeyedClient { /** Overlays on this tenant, plus the server's current limits. */ list(opts?: { signal?: AbortSignal; }): Promise; /** One overlay's metadata. */ get(id: string, opts?: { signal?: AbortSignal; }): Promise; /** * Upload an overlay. * * Accepts a `Blob`/`File`, a `GeoJSON` object, or raw bytes. The content type is chosen from * what was passed rather than asked for: a plain object is GeoJSON, and anything binary is * PMTiles unless the caller says otherwise. Getting that wrong is a 400 from the server, so * inferring it here removes the most likely way to fail this call. * * Never retried: an upload mints a new overlay id and carries no idempotency key, so a retry * after a lost response would spend a second of the ten slots on a duplicate. */ upload(body: Blob | ArrayBuffer | Uint8Array | Record, opts?: { name?: string; kind?: "geojson" | "pmtiles"; signal?: AbortSignal; }): Promise; /** * Delete an overlay. * * Never retried: a retry after a delete whose response was lost answers `404`, which would * report a failure for a delete that succeeded. */ delete(id: string, opts?: { signal?: AbortSignal; }): Promise; /** The stored bytes. GeoJSON parses; PMTiles is binary and belongs to MapLibre. */ data(id: string, opts?: { signal?: AbortSignal; }): Promise; } /** * Canadian and US ski areas (`/ski/areas`, `/ski/areas/{id}`), their 3D lifts * (`/ski/areas/{id}/lifts-3d`) and their runs and lifts with stable ids * (`/ski/areas/{id}/features`), behind the Ski add-on. * * const { data } = await unmap.ski.areas({ country: "CA", region: "BC", activity: "downhill" }); * const { data: area } = await unmap.ski.area(data[0].id); * const { data: { features } } = await unmap.ski.features(area.id); * * Every field is derived from OpenStreetMap, so every response is ODbL: show * `meta.attribution` ("© OpenStreetMap contributors") wherever you show the data. The numbers * are terrain information, not avalanche or safety advice. * * A key without the add-on gets `SkiError` 403 `addon_required` (or `dev_only` / * `usage_limit_reached` on the dev plan), with the SKU that unlocks it in `addon`. */ type SkiActivity = "downhill" | "nordic"; /** The eight compass directions the aspect histogram is binned into. */ type SkiAspectDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw"; /** One ski area, as the gateway returns it (`apps/gateway/src/ski.ts`). */ interface SkiArea { /** * Stable id, `ska_` and ten base32 characters (`ska_3f8k2m9qxa`). It survives a redrawn OSM * outline, a cluster gaining one and a deleted lift, and is never reused. */ id: string; /** * Every id the area was served under before: OSM-derived ids from releases before 2026-11-22 * (`osm-way-`, `osm-cluster-way-`, ...) and the id of any area merged into it. Map each to * `id` to migrate stored ids; `area()`, `lifts3d()` and `features()` also accept them. */ previous_ids: string[]; /** The OSM ski-area objects the area comes from (`way/123`, `relation/45`), or a cluster's lift ways. */ osm_ids: string[]; name: string; /** ISO 3166-1 alpha-2 country: `CA` or `US`. */ country: string; /** ISO 3166-2 subdivision without the country prefix: `BC`, `QC`, `VT`, `CO`. */ region: string; /** The nearest town: our reverse geocoder in Canada, the nearest OSM town in the same state in the US. */ locality: string; /** Representative point, [lng, lat]. */ location: [number, number]; /** The lowest lift station, where the road and the car park are; null with no lifts or runs. */ base: [number, number] | null; /** [west, south, east, north]. */ bbox: [number, number, number, number]; activities: SkiActivity[]; status: string | null; websites: string[]; wikidata_id: string | null; /** From the terrain release the build sampled; null when the area has no lifts or runs to sample. */ elevation: { top_m: number; base_m: number; vertical_m: number; } | null; runs: { count: number; downhill_km: number; nordic_km: number; }; lifts: { count: number; }; /** Share of downhill run length facing each way, from the terrain release the build sampled. */ aspect: Record; /** * Fastest drive from the nearest of the three closest census metropolitan areas of 100,000 or * more. Null when none is within the routing engine's matrix limit, and for every US area. */ drive: { from: string; minutes: number; } | null; /** * Where `name` came from: the OSM element, or for an area OSM leaves unnamed, a Wikidata item * (CC0-1.0) or a BC Ski Resorts record (OGL-BC-2.0). Null when the area has no name. Absent from * releases built before 2026-11-16. */ name_source?: { source: "openstreetmap" | "wikidata" | "bc-ski-resorts"; id: string; licence: string; } | null; source: string; licence: string; } /** The provenance every ski response carries. `data_version` is the ski release that answered. */ interface SkiMeta { source?: string; source_updated_at?: string | null; source_version?: string; content_hash?: string | null; sources?: readonly { id: string; source: string; source_url: string; attribution: string; source_updated_at: string | null; source_version: string; content_hash: string | null; status: "current" | "stale" | "unknown"; }[]; unmap_updated_at: string; data_version?: string; status: "current" | "stale" | "partial" | "unknown"; /** "© OpenStreetMap contributors". Display it with the data: the data is ODbL. */ attribution: string; } interface SkiResponse { data: T; meta: SkiMeta; } interface SkiAreasOptions { /** `CA` or `US`. */ country?: "CA" | "US"; /** Subdivision code without the country prefix: a province or territory (`BC`, `QC`) or a state (`VT`). */ region?: string; activity?: SkiActivity; /** [west, south, east, north] in degrees; matches on the area's representative point. */ bbox?: [number, number, number, number]; /** Name search, accent- and case-insensitive ("mont sainte anne" finds "Mont-Sainte-Anne"). */ q?: string; signal?: AbortSignal; } /** A point on a lift in 3D: [lng, lat, metres above sea level]. */ type SkiPoint3d = [number, number, number]; /** One lift, ready to draw in 3D. */ interface SkiLift3d { /** The OSM way, as `way-123`: the same id `features()` and the tiles give the lift. */ id: string; /** Null when the lift has no name in OpenStreetMap. */ name: string | null; /** The OSM `aerialway=*` value: `chair_lift`, `gondola`, `t-bar`, ... */ aerialway: string; /** The two ends, on the ground. */ stations: [SkiPoint3d, SkiPoint3d]; /** Each at the top of its tower. */ pylons: SkiPoint3d[]; /** The cable line, sag included. */ cable: SkiPoint3d[]; } /** * The `data` of `GET /ski/areas/{id}/lifts-3d`: one area's lifts with heights. `meta.data_version` * is the ski release. A known area with no lifts has `lifts: []`. */ interface SkiLifts3d { schema: "unmap.ski-lifts-3d.v1"; area_id: string; /** The terrain release the heights were sampled from. Draw on the same one. */ terrain_release: string; lifts: SkiLift3d[]; } /** A [lng, lat] position in WGS84 degrees. */ type SkiLngLat = [number, number]; /** A run or lift's own OpenStreetMap geometry. An area run (an OSM polygon, such as a bowl) is a polygon. */ type SkiFeatureGeometry = { type: "LineString"; coordinates: SkiLngLat[]; } | { type: "MultiLineString"; coordinates: SkiLngLat[][]; } | { type: "Polygon"; coordinates: SkiLngLat[][]; } | { type: "MultiPolygon"; coordinates: SkiLngLat[][][]; }; /** * One run or lift with a stable id. Geometry and identifiers only: nothing here says whether it * is open, groomed or safe. Every key is present; the other kind's fields are null. */ interface SkiFeature { /** * The OSM element, `way-123` or `relation-456`. The same in every release while the element * exists, and the `id` property of the `runs` and `lifts` tile features. Compare it as a string; * `osm` carries its parts. */ id: string; kind: "run" | "lift"; name: string | null; /** Runs: OSM `piste:type` (`downhill`, `nordic`, `skitour`, `sled`). Null on a lift. */ piste_type: string | null; /** Runs: OSM `piste:difficulty`, or `park` for a terrain park. Null when OSM has none, and on a lift. */ difficulty: string | null; /** Lifts: OSM `aerialway` (`chair_lift`, `gondola`, ...). Null on a run. */ aerialway: string | null; geometry: SkiFeatureGeometry; /** Horizontal length in metres along the line; for an area run, its greatest extent. */ length_m: number; osm: { type: "way" | "relation"; id: number; }; source: string; licence: string; } /** * The `data` of `GET /ski/areas/{id}/features`: every run and lift of one area, lifts first, then * runs, each by id. `data_version` is the ski release. A known area with nothing mapped has * `features: []`. */ interface SkiFeatures { schema: "unmap.ski-features.v1"; area_id: string; data_version: string; features: SkiFeature[]; } interface SkiOptions { key: string; gateway?: string; fetch?: typeof fetch; /** Retry policy for `429`, `502`, `503` and transport failures. `false` disables it. See `RetryPolicy` in `@unmap/core`. */ retry?: RetryPolicy | false; } /** * A ski failure. * * Extends `UnmapError`. `code` is the gateway's: `addon_required`, `dev_only` or * `usage_limit_reached` on a 403 (with `addon`, the SKU that unlocks it), `not_found` for an * unknown id, `bad_request` for a filter the gateway refused, `service_unavailable` when no ski * release is published. */ declare class SkiError extends UnmapError { /** The add-on SKU that unlocks the data, on a 403. */ readonly addon?: string | undefined; constructor(status: number, message: string, code?: string, retryAfterSeconds?: number, /** The add-on SKU that unlocks the data, on a 403. */ addon?: string | undefined); } /** Canadian ski areas. Needs the Ski add-on. */ declare class Ski { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: SkiOptions); /** Every ski area, or those matching the filters, sorted by id. */ areas(opts?: SkiAreasOptions): Promise>; /** One ski area, by its id or any of its `previous_ids`. Throws `SkiError` 404 `not_found` for an unknown id. */ area(id: string, opts?: { signal?: AbortSignal; }): Promise>; /** One area's lifts in 3D: stations, pylons and cable with heights. Throws `SkiError` 404 `not_found` for an unknown id. */ lifts3d(id: string, opts?: { signal?: AbortSignal; }): Promise>; /** * One area's runs and lifts, each with a stable OSM-derived id, its name, kind and geometry. * Throws `SkiError` 404 `not_found` for an unknown id. */ features(id: string, opts?: { signal?: AbortSignal; }): Promise>; private get; } /** * Modelled urban noise (`/noise/point`), behind the Urban Noise add-on. * * const { data, meta } = await unmap.noise.point({ lat: 51.054, lng: -114.0884 }); * data.lden; // 49.3 dB, day-evening-night * data.label; // "Quiet" * * Canada's 41 census metropolitan areas, from St. John's to Nanaimo. A point outside them throws * `NoiseError` 422 `outside_coverage`, with the covered areas in `cities`. * * The levels are computed from OpenStreetMap, so the data is ODbL: show `meta.attribution` * ("© OpenStreetMap contributors; noise model: PickYourPlace") wherever you show it. They are * modelled, not measured: screening data, not a compliance assessment. * * A key without the add-on gets `NoiseError` 403 `addon_required` (or `dev_only` / * `usage_limit_reached` on the dev plan), with the SKU that unlocks it in `addon`. */ type NoiseLabel = "Quiet" | "Moderate" | "Noisy" | "Very noisy" | "Severe"; type NoiseSource = "road" | "rail" | "aircraft" | "commercial"; /** 1 counted traffic and measured building heights, 2 counted traffic (or trains, or open aircraft contours), 3 default traffic. */ type NoiseInputTier = 1 | 2 | 3; /** One H3 hexagon's modelled noise, as the gateway returns it (`apps/gateway/src/noise.ts`). */ interface NoisePoint { /** H3 index of the hexagon. */ h3: string; /** H3 resolution: 11, about 25 m across. */ resolution: number; /** * The census metropolitan area the hexagon is in, by slug: `calgary`, `ottawa-gatineau`, * `quebec-city`, … (one of the 41 a 422 `outside_coverage` lists). */ city: string; /** * How good the model's inputs were here: 1 counted traffic and measured building heights * (Calgary only), 2 counted traffic, counted trains or open aircraft contours, 3 traffic * defaulted by road class. Null where no source is modelled. Absent from releases before the * national one. */ input_tier?: NoiseInputTier | null; /** Day-evening-night level, dB (EU Lden). Null where no modelled source is in range: never 0 dB. */ lden: number | null; /** Night level, 23:00 to 07:00, dB. */ lnight: number | null; /** 0 to 100, anchored to the WHO 2018 Environmental Noise Guidelines; 100 is quiet. */ score: number | null; /** 100 minus the score. */ risk: number | null; /** 80 and up Quiet, 60 Moderate, 40 Noisy, 20 Very noisy, below 20 Severe. */ label: NoiseLabel | null; /** Lden above 53 dB (day) and Lnight above 45 dB (night), the WHO 2018 road-traffic levels. */ exceeds_who: { day: boolean | null; night: boolean | null; }; dominant_source: NoiseSource | null; /** Each source's level at the hexagon, dB; null where that source is not modelled in range. */ sources_db: Record; /** Present only when `lden` is null: "no modelled source within range". */ note?: string; } /** The provenance every noise response carries. `data_version` is the release that answered. */ interface NoiseMeta { source?: string; source_updated_at?: string | null; source_version?: string; content_hash?: string | null; unmap_updated_at: string; data_version?: string; status: "current" | "stale" | "partial" | "unknown"; /** "© OpenStreetMap contributors; noise model: PickYourPlace". Display it with the data. */ attribution: string; /** "ODbL-1.0". */ licence: string; } interface NoiseResponse { data: T; meta: NoiseMeta; } /** A census metropolitan area Urban Noise covers, as a 422 `outside_coverage` lists them. */ interface NoiseCity { slug: string; name: { en: string; fr: string; }; /** [west, south, east, north]. */ bbox: [number, number, number, number]; } interface NoisePointOptions { lat: number; lng: number; signal?: AbortSignal; } interface NoiseOptions { key: string; gateway?: string; fetch?: typeof fetch; /** Retry policy for `429`, `502`, `503` and transport failures. `false` disables it. See `RetryPolicy` in `@unmap/core`. */ retry?: RetryPolicy | false; } /** * A noise failure. * * Extends `UnmapError`. `code` is the gateway's: `addon_required`, `dev_only` or * `usage_limit_reached` on a 403 (with `addon`, the SKU that unlocks it), `outside_coverage` on a * 422 (with `cities`, the covered metropolitan areas), `bad_request` for a coordinate the gateway refused, * `service_unavailable` while no release is served. */ declare class NoiseError extends UnmapError { /** The add-on SKU that unlocks the data, on a 403. */ readonly addon?: string | undefined; /** The covered metropolitan areas, on a 422 `outside_coverage`. */ readonly cities?: NoiseCity[] | undefined; constructor(status: number, message: string, code?: string, retryAfterSeconds?: number, /** The add-on SKU that unlocks the data, on a 403. */ addon?: string | undefined, /** The covered metropolitan areas, on a 422 `outside_coverage`. */ cities?: NoiseCity[] | undefined); } /** Modelled urban noise for Canada's 41 census metropolitan areas. Needs the Urban Noise add-on. */ declare class Noise { private readonly key; private readonly base; private readonly fetchImpl; private readonly retry; constructor(opts: NoiseOptions); /** * The modelled noise of the hexagon (about 25 m) at a point. Throws `NoiseError` 422 * `outside_coverage` outside the 41 metropolitan areas, and 400 for a coordinate outside WGS84, which is * checked here before any request is made. */ point(opts: NoisePointOptions): Promise>; } interface UnmapOptions { key: string; gateway?: string; /** Override the fetch implementation (tests, non-global environments). */ fetch?: typeof fetch; /** * Retry policy shared by every client on this instance. `false` disables it. * * On by default for `429`, `502`, `503` and transport failures. `Retry-After` is on a `429` * other than `billing_required`, and on a container `503`. A `502` has none. A wait longer * than `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` * instead, because a cold land container asks for 60 and parking a request handler * for a minute is a worse surprise than an error. Feedback submissions are never retried: * they create a record and carry no idempotency key. */ retry?: RetryPolicy | false; /** If provided, a map is mounted in this container. */ container?: string | HTMLElement; style?: string; /** "light" or "dark", light by default. Applies to a bare style name; a `