@unmap/sdk 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # @unmap/sdk
2
2
 
3
- One key, the whole [unmap](https://unmap.dev) platform: a MapLibre GL map, a geocoder, and a
4
- router behind a single `um_live_` or `um_test_` key. Canadian-first, privacy-first.
3
+ One key, the whole [unmap](https://unmap.dev) platform: a worldwide MapLibre GL basemap, Canadian
4
+ geocoding and routing, and the rest of the API behind a single `um_live_` or `um_test_` key.
5
+ The basemap supports 41 upstream Protomaps label-language tags; geocoding and routing remain
6
+ Canada-scoped. Canadian-built, privacy-first.
5
7
 
6
8
  ```bash
7
9
  npm i @unmap/sdk
@@ -14,7 +16,8 @@ import 'maplibre-gl/dist/maplibre-gl.css'
14
16
  const map = new Unmap({ key: 'um_live_...', container: '#map', center: [-114.07, 51.05] })
15
17
  ```
16
18
 
17
- That is the whole Hello World: a Calgary basemap in the `#map` element. Without a `container`
19
+ That is the whole Hello World: a worldwide basemap initially centered on Calgary in the `#map`
20
+ element. Without a `container`
18
21
  you still get the geocoder and router:
19
22
 
20
23
  ```ts
@@ -26,20 +29,46 @@ await unmap.router.route([-114.07, 51.05], [-113.99, 51.05], { mode: 'bicycle' }
26
29
  await unmap.router.isochrone([-114.07, 51.05], { minutes: [10, 20] })
27
30
  ```
28
31
 
32
+ The SDK also carries the departure-time transit contract:
33
+
34
+ ```ts
35
+ await unmap.router.route(from, to, { mode: 'transit', departAt: new Date() })
36
+ ```
37
+
38
+ Production answers TTC trips. The type requires `departAt`; there is no `arriveBy`, transit
39
+ matrix, or realtime claim. Other static feeds stay schedule-only.
40
+
41
+ Static transit data has its own release gate and client:
42
+
43
+ ```ts
44
+ const stops = await unmap.transit.nearbyStops([-79.3832, 43.6532], { radius: 800 })
45
+ const departures = stops.data[0]
46
+ ? await unmap.transit.departures(stops.data[0].id, { at: new Date(), window: 60 })
47
+ : undefined
48
+
49
+ await unmap.transit.agencies()
50
+ await unmap.transit.getStop('um:transit:stop:ttc:1234')
51
+ await unmap.transit.getRoute('um:transit:route:ttc:1')
52
+ ```
53
+
54
+ Those methods return `{ data, meta }`, where `meta` carries source, freshness and attribution.
55
+ They return a retryable `503` until a versioned GTFS release is enabled. Departures are scheduled,
56
+ including service after midnight and `calendar_dates.txt` exceptions; they are not realtime.
57
+
29
58
  ## Without a build step
30
59
 
31
60
  The same SDK loads from a script tag, with MapLibre already inside it:
32
61
 
33
62
  ```html
34
- <link rel="stylesheet" href="https://cdn.unmap.dev/sdk/0.12.0/unmap.css">
63
+ <link rel="stylesheet" href="https://cdn.unmap.dev/sdk/0.14.0/unmap.css">
35
64
  <div id="map" style="height: 400px"></div>
36
- <script src="https://cdn.unmap.dev/sdk/0.12.0/unmap.js"></script>
65
+ <script src="https://cdn.unmap.dev/sdk/0.14.0/unmap.js"></script>
37
66
  <script>
38
67
  unmap.createMap({ key: 'um_live_...', container: '#map', center: [-114.07, 51.05] })
39
68
  </script>
40
69
  ```
41
70
 
42
- Everything above is on the `unmap` global: `unmap.Unmap`, `unmap.Geocoder`, `unmap.Router`, `unmap.maplibregl`. Pin the exact version in production; `/sdk/0.12/` follows patches and `/sdk/latest/` follows everything.
71
+ Everything above is on the `unmap` global: `unmap.Unmap`, `unmap.Geocoder`, `unmap.Router`, `unmap.maplibregl`. Pin the exact version in production; `/sdk/0.14/` follows patches and `/sdk/latest/` follows everything.
43
72
 
44
73
  ## Options
45
74
 
@@ -51,7 +80,7 @@ Everything above is on the `unmap` global: `unmap.Unmap`, `unmap.Geocoder`, `unm
51
80
  | `style` | `string` | `base` (default), `muted`, `outdoor`, `blueprint`, `blush`, `orchid`, `canopy`, `lagoon`, `tropic`, `sunset`, `bold`, `pastel`, or a full style URL. |
52
81
  | `flavor` | `string` | Older spelling of `style`: a style name, read only when `style` is omitted. |
53
82
  | `mode` | `string` | `light` or `dark`. Selects the mode of the named style. |
54
- | `lang` | `string` | Label language, e.g. `fr`. Omit to follow the browser's `Accept-Language`. |
83
+ | `lang` | `string` | Basemap label language. Supports the 41 Protomaps language tags (including `ja`, `ko`, `zh-Hans`, and `zh-Hant`); omit to follow the browser's `Accept-Language`. |
55
84
  | `theme` | `string` | A theme code (`u…` or `ut1.`) from [unmap.dev/create](https://unmap.dev/create). |
56
85
  | `center` | `[lng, lat]` | Initial centre. |
57
86
  | `zoom` | `number` | Initial zoom. |
@@ -59,8 +88,9 @@ Everything above is on the `unmap` global: `unmap.Unmap`, `unmap.Geocoder`, `unm
59
88
  | `controls` | `boolean \| { position }` | Zoom and compass buttons. `true` by default; `false` for a bare canvas. |
60
89
 
61
90
  The instance exposes `.map` (MapLibre GL `Map`, only with a `container`), `.geocoder`
62
- (`@unmap/geocoding`), and `.router` (`@unmap/routing`). Everything from those two packages and
63
- from `@unmap/maps` is re-exported here, including `maplibregl` for markers and popups.
91
+ (`@unmap/geocoding`), `.router` (`@unmap/routing`), `.transit`, `.places`, `.roads`, `.feedback`
92
+ and `.elevation`. Everything from the packages and `@unmap/maps` is re-exported here, including
93
+ `maplibregl` for markers and popups.
64
94
 
65
95
  ## Stylesheet
66
96
 
@@ -76,12 +106,12 @@ reliably resolve inside a bundler's module graph. Bundler users make a one-time
76
106
  call after copying `maplibre-gl-worker.mjs` and `maplibre-gl-shared.mjs` into their own `public/`.
77
107
  Skip it and the map never finishes loading, with no error thrown and no failed request — see
78
108
  [@unmap/maps](https://www.npmjs.com/package/@unmap/maps#web-worker) for the script and the call, or
79
- [the quickstart](https://unmap.dev/docs/quickstart#if-the-map-never-finishes-loading).
109
+ [the quickstart](https://unmap.dev/docs/start/quickstart#if-the-map-never-finishes-loading).
80
110
 
81
111
  ## Docs
82
112
 
83
- - [Quickstart](https://unmap.dev/docs/quickstart) and [Overview](https://unmap.dev/docs/overview)
84
- - [Tiles & Styles](https://unmap.dev/docs/tiles-and-styles), [Geocoding API](https://unmap.dev/docs/geocoding-api), [Routing API](https://unmap.dev/docs/routing-api)
85
- - [Errors](https://unmap.dev/docs/errors) and [Plans & Limits](https://unmap.dev/docs/plans-and-limits)
113
+ - [Quickstart](https://unmap.dev/docs/start/quickstart) and [Overview](https://unmap.dev/docs/start/overview)
114
+ - [Tiles & Styles](https://unmap.dev/docs/apis/maps), [Geocoding API](https://unmap.dev/docs/apis/geocoding), [Routing API](https://unmap.dev/docs/apis/routing), [Transit API](https://unmap.dev/docs/apis/transit)
115
+ - [Errors](https://unmap.dev/docs/reference/errors) and [Plans & Limits](https://unmap.dev/docs/reference/plans)
86
116
 
87
- Documentation en français : [unmap.dev/fr/docs](https://unmap.dev/fr/docs/quickstart).
117
+ Documentation en français : [unmap.dev/fr/docs](https://unmap.dev/fr/docs/start/quickstart).
package/dist/index.d.ts CHANGED
@@ -1,17 +1,540 @@
1
1
  import { Map, MapProfile, UnmapMapOptions, UnmapControlsOptions } from '@unmap/maps';
2
2
  export { DEMO_CITIES, DemoCity, Map, MapProfile, Projection, STYLE_NAMES, StyleInput, StyleName, UnmapControlsOptions, UnmapMapOptions, createMap, maplibregl, unmapStyle } from '@unmap/maps';
3
- import { Geocoder, QueryOptions, QueryResponse, IdentifyOptions, IdentifyResponse } from '@unmap/geocoding';
3
+ import { Geocoder, Places, QueryOptions, QueryResponse, IdentifyOptions, IdentifyResponse } from '@unmap/geocoding';
4
4
  export * from '@unmap/geocoding';
5
+ import { RetryPolicy, UnmapError } from '@unmap/core';
6
+ export { RetryPolicy, UnmapError, parseRetryAfter } from '@unmap/core';
5
7
  import { Router } from '@unmap/routing';
6
8
  export * from '@unmap/routing';
7
9
  import { Elevation } from '@unmap/elevation';
8
10
  export * from '@unmap/elevation';
9
11
 
12
+ /**
13
+ * Typed clients for road events (`/incidents`, `/closures`, `/road-conditions`) and for data
14
+ * correction (`POST /feedback`).
15
+ *
16
+ * These live in `@unmap/sdk` rather than in packages of their own. A twelfth and thirteenth npm
17
+ * package would each need an entry in the changesets fixed group and a trusted publisher
18
+ * configured on npmjs.com, which is founder work, and neither has a framework wrapper the way
19
+ * geocoding and routing do. If a customer ever wants roads without the rest of the SDK, that is
20
+ * the moment to split it out.
21
+ */
22
+ type RoadEventType = "closure" | "incident" | "construction" | "weather" | "restriction" | "ferry" | "hazard" | "special_event" | "unknown";
23
+ type RoadCondition = "dry" | "wet" | "snow" | "ice" | "packed_snow" | "reduced_visibility" | "travel_not_recommended" | "closed" | "unknown";
24
+ type RoadSeverity = "minor" | "major" | "unknown";
25
+ interface AffectedRoad {
26
+ name: string;
27
+ direction: "north" | "south" | "east" | "west" | "both" | "unknown";
28
+ /** True only when the publisher says closed. Never inferred from the description. */
29
+ closed: boolean;
30
+ from?: string;
31
+ to?: string;
32
+ condition: RoadCondition;
33
+ }
34
+ interface RoadEvent {
35
+ /** `um:road:<jurisdiction>:<publisher id>`. */
36
+ id: string;
37
+ /** The publisher's own id, so a report can be taken back to them. */
38
+ source_id: string;
39
+ /** ISO 3166-2, e.g. `CA-BC`. */
40
+ jurisdiction: string;
41
+ type: RoadEventType;
42
+ /** The publisher's own subtype strings, untranslated. */
43
+ subtypes: string[];
44
+ status: "active" | "planned" | "archived";
45
+ severity: RoadSeverity;
46
+ /**
47
+ * The publisher's description, verbatim.
48
+ *
49
+ * Believe this over `type` when they disagree: our categories are a lossy projection of someone
50
+ * else's taxonomy, and the sentence a driver needs is in the prose.
51
+ */
52
+ description: string;
53
+ headline?: string;
54
+ /** The worst surface condition across this event's roads. */
55
+ condition: RoadCondition;
56
+ roads: AffectedRoad[];
57
+ /** GeoJSON Point or LineString, WGS84. */
58
+ geometry: {
59
+ type: string;
60
+ coordinates: unknown;
61
+ } | null;
62
+ starts_at: string | null;
63
+ ends_at: string | null;
64
+ source_updated_at: string | null;
65
+ unmap_updated_at: string;
66
+ source: string;
67
+ }
68
+ interface RoadEventsResponse {
69
+ data: RoadEvent[];
70
+ meta: {
71
+ status: "current" | "stale" | "partial" | "unknown";
72
+ attribution: string;
73
+ unmap_updated_at: string;
74
+ /**
75
+ * Jurisdictions that could not be reached, each with a reason.
76
+ *
77
+ * **Check this.** On `/closures` an empty `data` reads as "nothing is shut" to someone
78
+ * deciding whether to drive, and that is a very different answer from "we could not reach
79
+ * British Columbia".
80
+ */
81
+ unavailable?: {
82
+ jurisdiction: string;
83
+ reason: string;
84
+ }[];
85
+ };
86
+ }
87
+ interface RoadEventQuery {
88
+ /** Comma-separated ISO 3166-2 codes, or an array. An uncovered code is a 400, not an empty list. */
89
+ jurisdiction?: string | readonly string[];
90
+ bbox?: [number, number, number, number];
91
+ near?: [number, number];
92
+ /** Metres from `near`. Default 25000, max 500000. */
93
+ radius?: number;
94
+ type?: RoadEventType | readonly RoadEventType[];
95
+ severity?: RoadSeverity | readonly RoadSeverity[];
96
+ status?: "active" | "planned" | "archived";
97
+ /** ISO 8601. Only events the publisher changed at or after this time. */
98
+ updated_since?: string;
99
+ /** 1 to 500, default 100. Applied AFTER the endpoint's own narrowing. */
100
+ limit?: number;
101
+ signal?: AbortSignal;
102
+ }
103
+ interface RoadsOptions {
104
+ key: string;
105
+ gateway?: string;
106
+ fetch?: typeof fetch;
107
+ /**
108
+ * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.
109
+ *
110
+ * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container
111
+ * `503`. A `502` has none: routing uses `routing_failed`, and `/elevation` uses
112
+ * `upstream_error`. With no header the client backs off itself. A wait longer than
113
+ * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead.
114
+ * See `RetryPolicy` in `@unmap/core`.
115
+ */
116
+ retry?: RetryPolicy | false;
117
+ }
118
+ /**
119
+ * A road events failure.
120
+ *
121
+ * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside
122
+ * every other unmap client's errors. `instanceof RoadsError` keeps working, and `status` and `code`
123
+ * are still where they were; `retryAfterSeconds` is new and comes from the header.
124
+ */
125
+ declare class RoadsError extends UnmapError {
126
+ constructor(status: number, message: string, code?: string, retryAfterSeconds?: number);
127
+ }
128
+ /**
129
+ * Canadian road events.
130
+ *
131
+ * const { data, meta } = await unmap.roads.closures({ jurisdiction: "CA-BC" });
132
+ *
133
+ * A 503 means every requested jurisdiction was unreachable; the body still carries
134
+ * `meta.unavailable`, so the thrown error is the exception rather than the information. Prefer
135
+ * reading `meta.unavailable` on a 200 over treating an empty list as good news.
136
+ */
137
+ declare class Roads {
138
+ private readonly key;
139
+ private readonly base;
140
+ private readonly fetchImpl;
141
+ private readonly retry;
142
+ constructor(opts: RoadsOptions);
143
+ /** Every current road event. */
144
+ incidents(query?: RoadEventQuery): Promise<RoadEventsResponse>;
145
+ /** The subset where a road is actually shut. Narrowed before `limit` is applied. */
146
+ closures(query?: RoadEventQuery): Promise<RoadEventsResponse>;
147
+ /**
148
+ * The subset carrying a surface condition.
149
+ *
150
+ * Thin for British Columbia by design: its feed reports lane availability rather than the
151
+ * surface, so unmap answers `unknown` instead of inferring a dry road from open lanes.
152
+ */
153
+ conditions(query?: RoadEventQuery): Promise<RoadEventsResponse>;
154
+ private request;
155
+ }
156
+ type FeedbackProduct = "tiles" | "terrain" | "names" | "geocoding" | "places" | "routing" | "layers" | "transit" | "roads" | "ev";
157
+ 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";
158
+ interface FeedbackReport {
159
+ product: FeedbackProduct;
160
+ category: FeedbackCategory;
161
+ /** Up to 2000 characters, stored exactly as written. One of this or `resultId` is required. */
162
+ description?: string;
163
+ /** The unmap id of the result being reported. */
164
+ resultId?: string;
165
+ /**
166
+ * The request being reported.
167
+ *
168
+ * **Only send this with the reporter's explicit agreement.** The gateway refuses it without
169
+ * `include_context: true`, which this sets whenever `context` is present, and that flag is
170
+ * meant to record a person's choice rather than a client default. unmap redacts query strings
171
+ * from its own logs; a client that attached them here would undo that.
172
+ */
173
+ context?: unknown;
174
+ signal?: AbortSignal;
175
+ }
176
+ interface FeedbackReceipt {
177
+ /** Quote this in a follow-up. */
178
+ id: string;
179
+ status: string;
180
+ created_at: string;
181
+ /** Whether a request context was actually kept. `false` when none was offered. */
182
+ context_stored: boolean;
183
+ }
184
+ /**
185
+ * Report wrong data.
186
+ *
187
+ * await unmap.feedback.submit({
188
+ * product: "geocoding",
189
+ * category: "incorrect_location",
190
+ * description: "17 Ave SW returns a street in Edmonton.",
191
+ * });
192
+ *
193
+ * Authenticated like everything else and **never metered**: telling us our data is wrong does not
194
+ * cost a call. At most 200 reports per account per day.
195
+ */
196
+ declare class Feedback {
197
+ private readonly key;
198
+ private readonly base;
199
+ private readonly fetchImpl;
200
+ constructor(opts: RoadsOptions);
201
+ submit(report: FeedbackReport): Promise<FeedbackReceipt>;
202
+ /** A report about one place. `product` and `result_id` come from the path. */
203
+ aboutPlace(placeId: string, report: Omit<FeedbackReport, "product" | "resultId">): Promise<FeedbackReceipt>;
204
+ private post;
205
+ }
206
+
207
+ type TransitMetaStatus = "current" | "stale" | "partial" | "unknown";
208
+ interface TransitMeta {
209
+ /** Static GTFS is scheduled data. Realtime will use a different value and updated_at. */
210
+ schedule_type: "scheduled";
211
+ source?: string;
212
+ source_updated_at?: string | null;
213
+ source_version?: string;
214
+ content_hash?: string | null;
215
+ sources?: readonly {
216
+ id: string;
217
+ source: string;
218
+ source_url: string;
219
+ attribution: string;
220
+ source_updated_at: string | null;
221
+ source_version: string;
222
+ content_hash: string | null;
223
+ status: "current" | "stale" | "unknown";
224
+ }[];
225
+ unmap_updated_at: string;
226
+ data_version?: string;
227
+ status: TransitMetaStatus;
228
+ attribution: string;
229
+ }
230
+ interface TransitResponse<T> {
231
+ data: T;
232
+ meta: TransitMeta;
233
+ }
234
+ interface TransitAgency {
235
+ id: string;
236
+ feed: string;
237
+ name: string;
238
+ url?: string;
239
+ timezone: string;
240
+ lang?: string;
241
+ phone?: string;
242
+ fare_url?: string;
243
+ }
244
+ interface TransitStop {
245
+ id: string;
246
+ feed: string;
247
+ name: string;
248
+ coordinates: [number, number];
249
+ code?: string;
250
+ description?: string;
251
+ zone_id?: string;
252
+ parent_station_id?: string;
253
+ wheelchair_boarding?: 0 | 1 | 2;
254
+ route_ids: string[];
255
+ /** Metres from the requested point. Present only on nearbyStops. */
256
+ distance?: number;
257
+ }
258
+ interface TransitRoute {
259
+ id: string;
260
+ feed: string;
261
+ agency_id: string;
262
+ short_name?: string;
263
+ long_name?: string;
264
+ description?: string;
265
+ route_type: number;
266
+ colour?: string;
267
+ text_colour?: string;
268
+ url?: string;
269
+ }
270
+ interface TransitDeparture {
271
+ stop_id: string;
272
+ route_id: string;
273
+ trip_id: string;
274
+ headsign?: string;
275
+ arrival: string;
276
+ departure: string;
277
+ stop_sequence: number;
278
+ /** 2 = phone agency; 3 = coordinate with driver. Omitted for ordinary pickup. */
279
+ pickup_type?: 2 | 3;
280
+ schedule_type: "scheduled";
281
+ }
282
+ interface NearbyStopsOptions {
283
+ /** Metres. Default 1000, range 50 to 10000. */
284
+ radius?: number;
285
+ /** Default 20, maximum 100. */
286
+ limit?: number;
287
+ signal?: AbortSignal;
288
+ }
289
+ interface DepartureOptions {
290
+ /** An instant. Date values serialize to ISO; strings must include Z or an offset. Default now. */
291
+ at?: Date | string;
292
+ /** Minutes after at. Default 60, maximum 240. */
293
+ window?: number;
294
+ /** Default 50, maximum 200. */
295
+ limit?: number;
296
+ signal?: AbortSignal;
297
+ }
298
+ interface TransitOptions {
299
+ key: string;
300
+ gateway?: string;
301
+ fetch?: typeof fetch;
302
+ /**
303
+ * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.
304
+ *
305
+ * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container
306
+ * `503`. A `502` has none: routing uses `routing_failed`, and `/elevation` uses
307
+ * `upstream_error`. With no header the client backs off itself. A wait longer than
308
+ * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead.
309
+ * See `RetryPolicy` in `@unmap/core`.
310
+ */
311
+ retry?: RetryPolicy | false;
312
+ }
313
+ /**
314
+ * A transit failure.
315
+ *
316
+ * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside
317
+ * every other unmap client's errors. `instanceof TransitError` keeps working, and `status` and `code`
318
+ * are still where they were; `retryAfterSeconds` is new and comes from the header.
319
+ */
320
+ declare class TransitError extends UnmapError {
321
+ constructor(status: number, message: string, code?: string, retryAfterSeconds?: number);
322
+ }
323
+ /** Static Canadian GTFS data. Scheduled departures ship before realtime. */
324
+ declare class Transit {
325
+ private readonly key;
326
+ private readonly base;
327
+ private readonly fetchImpl;
328
+ private readonly retry;
329
+ constructor(opts: TransitOptions);
330
+ agencies(signal?: AbortSignal): Promise<TransitResponse<TransitAgency[]>>;
331
+ nearbyStops(near: [number, number], options?: NearbyStopsOptions): Promise<TransitResponse<TransitStop[]>>;
332
+ getStop(id: string, signal?: AbortSignal): Promise<TransitResponse<TransitStop>>;
333
+ getRoute(id: string, signal?: AbortSignal): Promise<TransitResponse<TransitRoute>>;
334
+ departures(id: string, options?: DepartureOptions): Promise<TransitResponse<TransitDeparture[]>>;
335
+ private get;
336
+ }
337
+
338
+ /** Freshness of a capability or a source. `unknown` means no cadence was declared. */
339
+ type CoverageFreshness = "current" | "stale" | "unknown";
340
+ interface CoverageSource {
341
+ id: string;
342
+ provider: string;
343
+ /** Bilingual, like every human-readable field in this document. */
344
+ dataset_name: {
345
+ en: string;
346
+ fr: string;
347
+ };
348
+ canonical_url: string;
349
+ licence: {
350
+ en: string;
351
+ fr: string;
352
+ };
353
+ licence_url: string;
354
+ attribution: string;
355
+ jurisdiction: string[];
356
+ /** ISO 8601 duration, e.g. `P1D`. */
357
+ refresh_interval: string;
358
+ last_checked_at: string;
359
+ last_success_at: string;
360
+ source_version: string;
361
+ content_hash: string | null;
362
+ freshness: CoverageFreshness;
363
+ stale_after: string | null;
364
+ coverage: string;
365
+ known_gaps: {
366
+ en: string;
367
+ fr: string;
368
+ };
369
+ quality_status: string;
370
+ }
371
+ interface CoverageCapability {
372
+ /** `tiles`, `geocoding`, `routing`, `places`, `transit`, `roads`, and so on. */
373
+ id: string;
374
+ display_name: {
375
+ en: string;
376
+ fr: string;
377
+ };
378
+ /** `planned` is published as honestly as `live`: a capability absent from the page reads as "not our problem". */
379
+ availability: "live" | "planned";
380
+ /** The endpoints that serve it. Empty while planned. */
381
+ endpoints: string[];
382
+ coverage: {
383
+ en: string;
384
+ fr: string;
385
+ };
386
+ /** Written to be accurate rather than flattering. Read this before promising coverage to a user. */
387
+ known_gaps: {
388
+ en: string;
389
+ fr: string;
390
+ };
391
+ /** ISO 3166-2 subdivisions, or `CA` for national. */
392
+ jurisdictions: string[];
393
+ freshness: CoverageFreshness;
394
+ sources: CoverageSource[];
395
+ }
396
+ interface CoverageDocument {
397
+ generated_at: string;
398
+ freshness_basis: string;
399
+ capabilities: CoverageCapability[];
400
+ jurisdictions: unknown;
401
+ }
402
+ declare class CoverageError extends UnmapError {
403
+ constructor(status: number, message: string, code?: string, retryAfterSeconds?: number);
404
+ }
405
+ interface CoverageOptions {
406
+ gateway?: string;
407
+ /** Override the fetch implementation (tests, non-global environments). */
408
+ fetch?: typeof fetch;
409
+ retry?: RetryPolicy | false;
410
+ }
411
+ /** Where unmap works. Takes no key: the endpoint is unauthenticated and unmetered. */
412
+ declare class Coverage {
413
+ private readonly base;
414
+ private readonly fetchImpl;
415
+ private readonly retry;
416
+ constructor(opts?: CoverageOptions);
417
+ /** The whole document. Cached an hour at the edge, so polling it is cheap. */
418
+ get(opts?: {
419
+ signal?: AbortSignal;
420
+ }): Promise<CoverageDocument>;
421
+ /**
422
+ * One capability by id, or `undefined` when the document does not describe it.
423
+ *
424
+ * const transit = await unmap.coverage.capability("transit");
425
+ * if (!transit?.jurisdictions.includes("CA-ON")) return "not available here yet";
426
+ */
427
+ capability(id: string, opts?: {
428
+ signal?: AbortSignal;
429
+ }): Promise<CoverageCapability | undefined>;
430
+ }
431
+
432
+ interface TimezoneResult {
433
+ timezone: string | null;
434
+ offset: string | null;
435
+ offsetSeconds: number | null;
436
+ dst: boolean | null;
437
+ }
438
+ interface TimezoneLookupOptions {
439
+ /** Instant the offset is evaluated at. Omit it for the current time. */
440
+ at?: Date;
441
+ signal?: AbortSignal;
442
+ }
443
+ declare class TimezoneError extends UnmapError {
444
+ constructor(status: number, message: string, code?: string, retryAfterSeconds?: number);
445
+ }
446
+ interface TimezoneOptions {
447
+ key: string;
448
+ gateway?: string;
449
+ fetch?: typeof fetch;
450
+ retry?: RetryPolicy | false;
451
+ }
452
+ /**
453
+ * IANA timezone for a coordinate.
454
+ *
455
+ * const zone = await unmap.timezone.lookup([-114.0719, 51.0447]);
456
+ *
457
+ * The coordinate is `[longitude, latitude]`, the same order as the rest of the SDK.
458
+ * `at` selects the offset. It does not change which zone the coordinate falls in.
459
+ */
460
+ declare class Timezone {
461
+ private readonly key;
462
+ private readonly base;
463
+ private readonly fetchImpl;
464
+ private readonly retry;
465
+ constructor(opts: TimezoneOptions);
466
+ lookup(coordinate: [number, number], opts?: TimezoneLookupOptions): Promise<TimezoneResult>;
467
+ }
468
+
469
+ interface GeolocationOptions {
470
+ key: string;
471
+ gateway?: string;
472
+ fetch?: typeof fetch;
473
+ /**
474
+ * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.
475
+ *
476
+ * On by default. A wait longer than `maxDelayMs` (10 s) is not slept through; the error
477
+ * carries `retryAfterSeconds` instead.
478
+ */
479
+ retry?: RetryPolicy | false;
480
+ }
481
+ interface IpGeolocationResult {
482
+ ip: string | null;
483
+ location: {
484
+ lat: number | null;
485
+ lng: number | null;
486
+ };
487
+ city: string | null;
488
+ region: string | null;
489
+ regionCode: string | null;
490
+ postalCode: string | null;
491
+ country: string | null;
492
+ continent: string | null;
493
+ timezone: string | null;
494
+ network: {
495
+ asn: number | null;
496
+ organization: string | null;
497
+ };
498
+ precision: "approximate";
499
+ }
500
+ declare class GeolocationError extends UnmapError {
501
+ constructor(status: number, message: string, code?: string, retryAfterSeconds?: number);
502
+ }
503
+ /** Typed client for `GET /ip`. One call, one metered request, on the shared pool. */
504
+ declare class Geolocation {
505
+ private readonly key;
506
+ private readonly base;
507
+ private readonly fetchImpl;
508
+ private readonly retry;
509
+ constructor(opts: GeolocationOptions);
510
+ /**
511
+ * Approximate country, region, city, coordinates, and timezone of this request.
512
+ *
513
+ * const location = await unmap.geolocation.ip();
514
+ *
515
+ * A field the network did not identify is `null`. The call still resolves.
516
+ */
517
+ ip(opts?: {
518
+ signal?: AbortSignal;
519
+ }): Promise<IpGeolocationResult>;
520
+ }
521
+
10
522
  interface UnmapOptions {
11
523
  key: string;
12
524
  gateway?: string;
13
525
  /** Override the fetch implementation (tests, non-global environments). */
14
526
  fetch?: typeof fetch;
527
+ /**
528
+ * Retry policy shared by every client on this instance. `false` disables it.
529
+ *
530
+ * On by default for `429`, `502`, `503` and transport failures. `Retry-After` is on a `429`
531
+ * other than `billing_required`, and on a container `503`. A `502` has none. A wait longer
532
+ * than `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds`
533
+ * instead, because a cold land or energy container asks for 60 and parking a request handler
534
+ * for a minute is a worse surprise than an error. Feedback submissions are never retried:
535
+ * they create a record and carry no idempotency key.
536
+ */
537
+ retry?: RetryPolicy | false;
15
538
  /** If provided, a map is mounted in this container. */
16
539
  container?: string | HTMLElement;
17
540
  style?: string;
@@ -34,8 +557,8 @@ interface UnmapOptions {
34
557
  controls?: boolean | UnmapControlsOptions;
35
558
  }
36
559
  /**
37
- * One Stripe-style key, the whole platform. With a `container` you get a rendered map;
38
- * `geocoder`, `router` and `elevation` are always available.
560
+ * One Stripe-style key, the whole platform. With a `container` you get a rendered map.
561
+ * `geocoder`, `router`, `elevation`, `timezone`, and `geolocation` are always available.
39
562
  *
40
563
  * const map = new Unmap({ key: "um_live_...", container: "#map", center: [-75.69, 45.42] });
41
564
  */
@@ -43,6 +566,26 @@ declare class Unmap {
43
566
  readonly geocoder: Geocoder;
44
567
  readonly router: Router;
45
568
  readonly elevation: Elevation;
569
+ /** IANA timezone and the UTC offset at an instant. One call, anywhere. */
570
+ readonly timezone: Timezone;
571
+ /** Canadian points of interest. Same corpus as the geocoder, in the Place shape. */
572
+ readonly places: Places;
573
+ /** Closures, incidents, construction and road conditions. */
574
+ readonly roads: Roads;
575
+ /** Report wrong data. Never metered. */
576
+ readonly feedback: Feedback;
577
+ /** Scheduled public-transit agencies, stops, routes and departures. */
578
+ readonly transit: Transit;
579
+ /**
580
+ * Where each capability actually works. Unauthenticated and unmetered, so checking costs
581
+ * nothing: read it before promising a user an answer, because transit routing is one agency
582
+ * and road events are one province.
583
+ */
584
+ readonly coverage: Coverage;
585
+ /**
586
+ * Approximate location of the current request. Not device GPS. One call on the shared pool.
587
+ */
588
+ readonly geolocation: Geolocation;
46
589
  readonly data: {
47
590
  query(opts: QueryOptions): Promise<QueryResponse>;
48
591
  };
@@ -52,4 +595,4 @@ declare class Unmap {
52
595
  identify(opts: IdentifyOptions): Promise<IdentifyResponse>;
53
596
  }
54
597
 
55
- export { Unmap, type UnmapOptions };
598
+ export { type AffectedRoad, Coverage, type CoverageCapability, type CoverageDocument, CoverageError, type CoverageFreshness, type CoverageOptions, type CoverageSource, type DepartureOptions, Feedback, type FeedbackCategory, type FeedbackProduct, type FeedbackReceipt, type FeedbackReport, Geolocation, GeolocationError, type GeolocationOptions, type IpGeolocationResult, type NearbyStopsOptions, type RoadCondition, type RoadEvent, type RoadEventQuery, type RoadEventType, type RoadEventsResponse, type RoadSeverity, Roads, RoadsError, type RoadsOptions, Timezone, TimezoneError, type TimezoneLookupOptions, type TimezoneOptions, type TimezoneResult, Transit, type TransitAgency, type TransitDeparture, TransitError, type TransitMeta, type TransitMetaStatus, type TransitOptions, type TransitResponse, type TransitRoute, type TransitStop, Unmap, type UnmapOptions };
package/dist/index.js CHANGED
@@ -2,23 +2,381 @@
2
2
  import {
3
3
  createMap
4
4
  } from "@unmap/maps";
5
- import { Geocoder } from "@unmap/geocoding";
5
+ import { Geocoder, Places } from "@unmap/geocoding";
6
+
7
+ // src/roads.ts
8
+ import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter } from "@unmap/core";
9
+ var RoadsError = class extends UnmapError {
10
+ constructor(status, message, code, retryAfterSeconds) {
11
+ super(status, message, code, retryAfterSeconds);
12
+ this.name = "RoadsError";
13
+ }
14
+ };
15
+ function list(value) {
16
+ if (value === void 0) return void 0;
17
+ return Array.isArray(value) ? value.join(",") : String(value);
18
+ }
19
+ async function errorFrom(res, path, name) {
20
+ const fallback = `${name} ${res.status} on ${path}`;
21
+ let body;
22
+ try {
23
+ body = await res.json();
24
+ } catch {
25
+ body = void 0;
26
+ }
27
+ const reason = typeof body?.error === "string" ? body.error : void 0;
28
+ const code = typeof body?.code === "string" ? body.code : void 0;
29
+ const retryAfter = parseRetryAfter(res.headers?.get("retry-after") ?? null) ?? void 0;
30
+ return new RoadsError(res.status, reason ? `${reason} (${fallback})` : fallback, code, retryAfter);
31
+ }
32
+ var Roads = class {
33
+ key;
34
+ base;
35
+ fetchImpl;
36
+ retry;
37
+ constructor(opts) {
38
+ this.retry = opts.retry;
39
+ this.key = opts.key;
40
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\/+$/, "");
41
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
42
+ }
43
+ /** Every current road event. */
44
+ incidents(query = {}) {
45
+ return this.request("/incidents", query);
46
+ }
47
+ /** The subset where a road is actually shut. Narrowed before `limit` is applied. */
48
+ closures(query = {}) {
49
+ return this.request("/closures", query);
50
+ }
51
+ /**
52
+ * The subset carrying a surface condition.
53
+ *
54
+ * Thin for British Columbia by design: its feed reports lane availability rather than the
55
+ * surface, so unmap answers `unknown` instead of inferring a dry road from open lanes.
56
+ */
57
+ conditions(query = {}) {
58
+ return this.request("/road-conditions", query);
59
+ }
60
+ async request(path, query) {
61
+ const q = new URLSearchParams({ key: this.key });
62
+ const params = {
63
+ jurisdiction: list(query.jurisdiction),
64
+ bbox: query.bbox?.join(","),
65
+ near: query.near?.join(","),
66
+ radius: query.radius != null ? String(query.radius) : void 0,
67
+ type: list(query.type),
68
+ severity: list(query.severity),
69
+ status: query.status,
70
+ updated_since: query.updated_since,
71
+ limit: query.limit != null ? String(query.limit) : void 0
72
+ };
73
+ for (const [k, v] of Object.entries(params)) if (v != null && v !== "") q.set(k, v);
74
+ const res = await fetchWithRetry(
75
+ this.fetchImpl,
76
+ `${this.base}${path}?${q}`,
77
+ { signal: query.signal, headers: { accept: "application/json" } },
78
+ this.retry
79
+ );
80
+ if (!res.ok) throw await errorFrom(res, path, "roads");
81
+ return await res.json();
82
+ }
83
+ };
84
+ var Feedback = class {
85
+ key;
86
+ base;
87
+ fetchImpl;
88
+ constructor(opts) {
89
+ this.key = opts.key;
90
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\/+$/, "");
91
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
92
+ }
93
+ submit(report) {
94
+ return this.post("/feedback", {
95
+ product: report.product,
96
+ category: report.category,
97
+ ...report.description ? { description: report.description } : {},
98
+ ...report.resultId ? { result_id: report.resultId } : {},
99
+ ...report.context !== void 0 ? { include_context: true, context: report.context } : {}
100
+ }, report.signal);
101
+ }
102
+ /** A report about one place. `product` and `result_id` come from the path. */
103
+ aboutPlace(placeId, report) {
104
+ return this.post(`/places/${encodeURIComponent(placeId)}/feedback`, {
105
+ category: report.category,
106
+ ...report.description ? { description: report.description } : {},
107
+ ...report.context !== void 0 ? { include_context: true, context: report.context } : {}
108
+ }, report.signal);
109
+ }
110
+ async post(path, body, signal) {
111
+ const res = await this.fetchImpl(`${this.base}${path}`, {
112
+ method: "POST",
113
+ signal,
114
+ headers: { "content-type": "application/json", authorization: `Bearer ${this.key}` },
115
+ body: JSON.stringify(body)
116
+ });
117
+ if (!res.ok) throw await errorFrom(res, path, "feedback");
118
+ return await res.json();
119
+ }
120
+ };
121
+
122
+ // src/transit.ts
123
+ import { DEFAULT_GATEWAY as DEFAULT_GATEWAY2, UnmapError as UnmapError2, fetchWithRetry as fetchWithRetry2, parseRetryAfter as parseRetryAfter2 } from "@unmap/core";
124
+ var TransitError = class extends UnmapError2 {
125
+ constructor(status, message, code, retryAfterSeconds) {
126
+ super(status, message, code, retryAfterSeconds);
127
+ this.name = "TransitError";
128
+ }
129
+ };
130
+ async function errorFrom2(res, path) {
131
+ let body = {};
132
+ try {
133
+ body = await res.json();
134
+ } catch {
135
+ }
136
+ const message = typeof body.error === "string" ? body.error : `transit ${res.status} on ${path}`;
137
+ const code = typeof body.code === "string" ? body.code : void 0;
138
+ const retryAfter = parseRetryAfter2(res.headers?.get("retry-after") ?? null) ?? void 0;
139
+ return new TransitError(res.status, message, code, retryAfter);
140
+ }
141
+ var Transit = class {
142
+ key;
143
+ base;
144
+ fetchImpl;
145
+ retry;
146
+ constructor(opts) {
147
+ this.retry = opts.retry;
148
+ this.key = opts.key;
149
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY2).replace(/\/+$/, "");
150
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
151
+ }
152
+ agencies(signal) {
153
+ return this.get("/transit/agencies", void 0, signal);
154
+ }
155
+ nearbyStops(near, options = {}) {
156
+ return this.get("/transit/stops", {
157
+ near: near.join(","),
158
+ radius: options.radius,
159
+ limit: options.limit
160
+ }, options.signal);
161
+ }
162
+ getStop(id, signal) {
163
+ return this.get(`/transit/stops/${encodeURIComponent(id)}`, void 0, signal);
164
+ }
165
+ getRoute(id, signal) {
166
+ return this.get(`/transit/routes/${encodeURIComponent(id)}`, void 0, signal);
167
+ }
168
+ departures(id, options = {}) {
169
+ return this.get(`/transit/stops/${encodeURIComponent(id)}/departures`, {
170
+ at: options.at instanceof Date ? options.at.toISOString() : options.at,
171
+ window: options.window,
172
+ limit: options.limit
173
+ }, options.signal);
174
+ }
175
+ async get(path, values, signal) {
176
+ const query = new URLSearchParams({ key: this.key });
177
+ for (const [name, value] of Object.entries(values ?? {})) {
178
+ if (value !== void 0) query.set(name, String(value));
179
+ }
180
+ const response = await fetchWithRetry2(
181
+ this.fetchImpl,
182
+ `${this.base}${path}?${query}`,
183
+ { signal, headers: { accept: "application/json" } },
184
+ this.retry
185
+ );
186
+ if (!response.ok) throw await errorFrom2(response, path);
187
+ return await response.json();
188
+ }
189
+ };
190
+
191
+ // src/coverage.ts
192
+ import { DEFAULT_GATEWAY as DEFAULT_GATEWAY3, UnmapError as UnmapError3, fetchWithRetry as fetchWithRetry3, parseRetryAfter as parseRetryAfter3 } from "@unmap/core";
193
+ var COVERAGE_PATH = "/coverage.json";
194
+ var CoverageError = class extends UnmapError3 {
195
+ constructor(status, message, code, retryAfterSeconds) {
196
+ super(status, message, code, retryAfterSeconds);
197
+ this.name = "CoverageError";
198
+ }
199
+ };
200
+ var Coverage = class {
201
+ base;
202
+ fetchImpl;
203
+ retry;
204
+ constructor(opts = {}) {
205
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY3).replace(/\/+$/, "");
206
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
207
+ this.retry = opts.retry;
208
+ }
209
+ /** The whole document. Cached an hour at the edge, so polling it is cheap. */
210
+ async get(opts = {}) {
211
+ const res = await fetchWithRetry3(
212
+ this.fetchImpl,
213
+ `${this.base}${COVERAGE_PATH}`,
214
+ { signal: opts.signal, headers: { accept: "application/json" } },
215
+ this.retry
216
+ );
217
+ if (!res.ok) {
218
+ const retryAfter = parseRetryAfter3(res.headers?.get?.("retry-after") ?? null) ?? void 0;
219
+ throw new CoverageError(res.status, `coverage ${res.status}`, void 0, retryAfter);
220
+ }
221
+ return await res.json();
222
+ }
223
+ /**
224
+ * One capability by id, or `undefined` when the document does not describe it.
225
+ *
226
+ * const transit = await unmap.coverage.capability("transit");
227
+ * if (!transit?.jurisdictions.includes("CA-ON")) return "not available here yet";
228
+ */
229
+ async capability(id, opts = {}) {
230
+ const doc = await this.get(opts);
231
+ return doc.capabilities.find((c) => c.id === id);
232
+ }
233
+ };
234
+
235
+ // src/timezone.ts
236
+ import { DEFAULT_GATEWAY as DEFAULT_GATEWAY4, UnmapError as UnmapError4, fetchWithRetry as fetchWithRetry4, parseRetryAfter as parseRetryAfter4 } from "@unmap/core";
237
+ var TIMEZONE_PATH = "/timezone";
238
+ var TimezoneError = class extends UnmapError4 {
239
+ constructor(status, message, code, retryAfterSeconds) {
240
+ super(status, message, code, retryAfterSeconds);
241
+ this.name = "TimezoneError";
242
+ }
243
+ };
244
+ var Timezone = class {
245
+ key;
246
+ base;
247
+ fetchImpl;
248
+ retry;
249
+ constructor(opts) {
250
+ this.retry = opts.retry;
251
+ this.key = opts.key;
252
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY4).replace(/\/+$/, "");
253
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
254
+ }
255
+ async lookup(coordinate, opts = {}) {
256
+ const [lon, lat] = coordinate;
257
+ const q = new URLSearchParams({ key: this.key, lon: String(lon), lat: String(lat) });
258
+ if (opts.at) q.set("at", opts.at.toISOString());
259
+ const res = await fetchWithRetry4(
260
+ this.fetchImpl,
261
+ `${this.base}${TIMEZONE_PATH}?${q}`,
262
+ { signal: opts.signal, headers: { accept: "application/json" } },
263
+ this.retry
264
+ );
265
+ if (!res.ok) throw await errorFrom3(res);
266
+ return await res.json();
267
+ }
268
+ };
269
+ async function errorFrom3(res) {
270
+ const retryAfter = parseRetryAfter4(res.headers?.get?.("retry-after") ?? null) ?? void 0;
271
+ let message = res.statusText || `timezone ${res.status}`;
272
+ let code;
273
+ try {
274
+ const body = await res.json();
275
+ if (typeof body.error === "string" && body.error) message = body.error;
276
+ if (typeof body.code === "string") code = body.code;
277
+ } catch {
278
+ }
279
+ return new TimezoneError(res.status, message, code, retryAfter);
280
+ }
281
+
282
+ // src/geolocation.ts
283
+ import { DEFAULT_GATEWAY as DEFAULT_GATEWAY5, UnmapError as UnmapError5, fetchWithRetry as fetchWithRetry5, parseRetryAfter as parseRetryAfter5 } from "@unmap/core";
284
+ var IP_PATH = "/ip";
285
+ var GeolocationError = class extends UnmapError5 {
286
+ constructor(status, message, code, retryAfterSeconds) {
287
+ super(status, message, code, retryAfterSeconds);
288
+ this.name = "GeolocationError";
289
+ }
290
+ };
291
+ var Geolocation = class {
292
+ key;
293
+ base;
294
+ fetchImpl;
295
+ retry;
296
+ constructor(opts) {
297
+ this.key = opts.key;
298
+ this.base = (opts.gateway ?? DEFAULT_GATEWAY5).replace(/\/+$/, "");
299
+ this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
300
+ this.retry = opts.retry;
301
+ }
302
+ /**
303
+ * Approximate country, region, city, coordinates, and timezone of this request.
304
+ *
305
+ * const location = await unmap.geolocation.ip();
306
+ *
307
+ * A field the network did not identify is `null`. The call still resolves.
308
+ */
309
+ async ip(opts = {}) {
310
+ const q = new URLSearchParams({ key: this.key });
311
+ const res = await fetchWithRetry5(
312
+ this.fetchImpl,
313
+ `${this.base}${IP_PATH}?${q}`,
314
+ { signal: opts.signal, headers: { accept: "application/json" } },
315
+ this.retry
316
+ );
317
+ if (!res.ok) throw await errorFrom4(res);
318
+ return await res.json();
319
+ }
320
+ };
321
+ async function errorFrom4(res) {
322
+ const fallback = `geolocation ${res.status}`;
323
+ let body;
324
+ try {
325
+ body = await res.json();
326
+ } catch {
327
+ body = void 0;
328
+ }
329
+ const reason = typeof body?.error === "string" ? body.error : void 0;
330
+ const code = typeof body?.code === "string" ? body.code : void 0;
331
+ const retryAfter = parseRetryAfter5(res.headers?.get("retry-after") ?? null) ?? void 0;
332
+ return new GeolocationError(res.status, reason ? `${reason} (${fallback})` : fallback, code, retryAfter);
333
+ }
334
+
335
+ // src/index.ts
6
336
  import { Router } from "@unmap/routing";
7
337
  import { Elevation } from "@unmap/elevation";
8
338
  export * from "@unmap/geocoding";
9
339
  export * from "@unmap/routing";
10
340
  export * from "@unmap/elevation";
11
341
  import { createMap as createMap2, unmapStyle, DEMO_CITIES, STYLE_NAMES, maplibregl } from "@unmap/maps";
342
+ import { UnmapError as UnmapError6, parseRetryAfter as parseRetryAfter6 } from "@unmap/core";
12
343
  var Unmap = class {
13
344
  geocoder;
14
345
  router;
15
346
  elevation;
347
+ /** IANA timezone and the UTC offset at an instant. One call, anywhere. */
348
+ timezone;
349
+ /** Canadian points of interest. Same corpus as the geocoder, in the Place shape. */
350
+ places;
351
+ /** Closures, incidents, construction and road conditions. */
352
+ roads;
353
+ /** Report wrong data. Never metered. */
354
+ feedback;
355
+ /** Scheduled public-transit agencies, stops, routes and departures. */
356
+ transit;
357
+ /**
358
+ * Where each capability actually works. Unauthenticated and unmetered, so checking costs
359
+ * nothing: read it before promising a user an answer, because transit routing is one agency
360
+ * and road events are one province.
361
+ */
362
+ coverage;
363
+ /**
364
+ * Approximate location of the current request. Not device GPS. One call on the shared pool.
365
+ */
366
+ geolocation;
16
367
  data;
17
368
  map;
18
369
  constructor(opts) {
19
370
  this.geocoder = new Geocoder(opts);
20
371
  this.router = new Router(opts);
21
372
  this.elevation = new Elevation(opts);
373
+ this.timezone = new Timezone(opts);
374
+ this.places = new Places(opts);
375
+ this.roads = new Roads(opts);
376
+ this.feedback = new Feedback(opts);
377
+ this.transit = new Transit(opts);
378
+ this.coverage = new Coverage(opts);
379
+ this.geolocation = new Geolocation(opts);
22
380
  this.data = { query: (queryOpts) => this.geocoder.queryLayer(queryOpts) };
23
381
  if (opts.container) {
24
382
  this.map = createMap({ ...opts, container: opts.container });
@@ -30,11 +388,24 @@ var Unmap = class {
30
388
  }
31
389
  };
32
390
  export {
391
+ Coverage,
392
+ CoverageError,
33
393
  DEMO_CITIES,
394
+ Feedback,
395
+ Geolocation,
396
+ GeolocationError,
397
+ Roads,
398
+ RoadsError,
34
399
  STYLE_NAMES,
400
+ Timezone,
401
+ TimezoneError,
402
+ Transit,
403
+ TransitError,
35
404
  Unmap,
405
+ UnmapError6 as UnmapError,
36
406
  createMap2 as createMap,
37
407
  maplibregl,
408
+ parseRetryAfter6 as parseRetryAfter,
38
409
  unmapStyle
39
410
  };
40
411
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n createMap,\n type Map as MaplibreMap,\n type MapProfile,\n type UnmapControlsOptions,\n type UnmapMapOptions,\n} from \"@unmap/maps\";\nimport { Geocoder, type IdentifyOptions, type IdentifyResponse, type QueryOptions, type QueryResponse } from \"@unmap/geocoding\";\nimport { Router } from \"@unmap/routing\";\nimport { Elevation } from \"@unmap/elevation\";\n\nexport * from \"@unmap/geocoding\";\nexport * from \"@unmap/routing\";\nexport * from \"@unmap/elevation\";\nexport { createMap, unmapStyle, DEMO_CITIES, STYLE_NAMES, maplibregl } from \"@unmap/maps\";\nexport type {\n Map,\n UnmapMapOptions,\n UnmapControlsOptions,\n DemoCity,\n StyleName,\n StyleInput,\n Projection,\n MapProfile,\n} from \"@unmap/maps\";\n\nexport interface UnmapOptions {\n key: string;\n gateway?: string;\n /** Override the fetch implementation (tests, non-global environments). */\n fetch?: typeof fetch;\n /** If provided, a map is mounted in this container. */\n container?: string | HTMLElement;\n style?: string;\n flavor?: string;\n /** \"light\" or \"dark\". Selects the mode half of the named style. */\n mode?: string;\n /** Label language, e.g. \"fr\". Omit to follow the request's Accept-Language. */\n lang?: string;\n /** Compact `ut1.` theme code from unmap.dev/create. Wins over the path style on the gateway. */\n theme?: string;\n /** Catalog layer ids composed onto the style (`municipalities`, `survey.dls`, …). */\n overlays?: readonly string[];\n /** Composition preset. Not a style. Explicit overlays replace the profile list. */\n profile?: MapProfile;\n /** `\"globe\"` or `\"mercator\"`. See `@unmap/maps` `UnmapMapOptions.projection`. */\n projection?: UnmapMapOptions[\"projection\"];\n center?: [number, number];\n zoom?: number;\n /** On-map controls. `true` (the default) adds zoom and compass buttons; `false` adds none. */\n controls?: boolean | UnmapControlsOptions;\n}\n\n/**\n * One Stripe-style key, the whole platform. With a `container` you get a rendered map;\n * `geocoder`, `router` and `elevation` are always available.\n *\n * const map = new Unmap({ key: \"um_live_...\", container: \"#map\", center: [-75.69, 45.42] });\n */\nexport class Unmap {\n readonly geocoder: Geocoder;\n readonly router: Router;\n readonly elevation: Elevation;\n readonly data: { query(opts: QueryOptions): Promise<QueryResponse> };\n readonly map?: MaplibreMap;\n\n constructor(opts: UnmapOptions) {\n this.geocoder = new Geocoder(opts);\n this.router = new Router(opts);\n this.elevation = new Elevation(opts);\n this.data = { query: (queryOpts) => this.geocoder.queryLayer(queryOpts) };\n if (opts.container) {\n this.map = createMap({ ...opts, container: opts.container } as UnmapMapOptions);\n }\n }\n\n /** Which catalog features contain a point. See `Geocoder.identify`. */\n identify(opts: IdentifyOptions): Promise<IdentifyResponse> {\n return this.geocoder.identify(opts);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAKK;AACP,SAAS,gBAAoG;AAC7G,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAE1B,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,aAAAA,YAAW,YAAY,aAAa,aAAa,kBAAkB;AA6CrE,IAAM,QAAN,MAAY;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAoB;AAC9B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,SAAS,IAAI,OAAO,IAAI;AAC7B,SAAK,YAAY,IAAI,UAAU,IAAI;AACnC,SAAK,OAAO,EAAE,OAAO,CAAC,cAAc,KAAK,SAAS,WAAW,SAAS,EAAE;AACxE,QAAI,KAAK,WAAW;AAClB,WAAK,MAAM,UAAU,EAAE,GAAG,MAAM,WAAW,KAAK,UAAU,CAAoB;AAAA,IAChF;AAAA,EACF;AAAA;AAAA,EAGA,SAAS,MAAkD;AACzD,WAAO,KAAK,SAAS,SAAS,IAAI;AAAA,EACpC;AACF;","names":["createMap"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/roads.ts","../src/transit.ts","../src/coverage.ts","../src/timezone.ts","../src/geolocation.ts"],"sourcesContent":["import {\n createMap,\n type Map as MaplibreMap,\n type MapProfile,\n type UnmapControlsOptions,\n type UnmapMapOptions,\n} from \"@unmap/maps\";\nimport { Geocoder, Places, type IdentifyOptions, type IdentifyResponse, type QueryOptions, type QueryResponse } from \"@unmap/geocoding\";\nimport { Feedback, Roads } from \"./roads\";\nimport { Transit } from \"./transit\";\nimport { Coverage } from \"./coverage\";\nimport { Timezone } from \"./timezone\";\nimport { Geolocation } from \"./geolocation\";\nimport { Router } from \"@unmap/routing\";\nimport { Elevation } from \"@unmap/elevation\";\nimport type { RetryPolicy } from \"@unmap/core\";\n\nexport * from \"@unmap/geocoding\";\nexport * from \"@unmap/routing\";\nexport * from \"@unmap/elevation\";\nexport * from \"./roads\";\nexport * from \"./transit\";\nexport * from \"./coverage\";\nexport * from \"./timezone\";\nexport * from \"./geolocation\";\nexport { createMap, unmapStyle, DEMO_CITIES, STYLE_NAMES, maplibregl } from \"@unmap/maps\";\nexport type {\n Map,\n UnmapMapOptions,\n UnmapControlsOptions,\n DemoCity,\n StyleName,\n StyleInput,\n Projection,\n MapProfile,\n} from \"@unmap/maps\";\n\nexport interface UnmapOptions {\n key: string;\n gateway?: string;\n /** Override the fetch implementation (tests, non-global environments). */\n fetch?: typeof fetch;\n /**\n * Retry policy shared by every client on this instance. `false` disables it.\n *\n * On by default for `429`, `502`, `503` and transport failures. `Retry-After` is on a `429`\n * other than `billing_required`, and on a container `503`. A `502` has none. A wait longer\n * than `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds`\n * instead, because a cold land or energy container asks for 60 and parking a request handler\n * for a minute is a worse surprise than an error. Feedback submissions are never retried:\n * they create a record and carry no idempotency key.\n */\n retry?: RetryPolicy | false;\n /** If provided, a map is mounted in this container. */\n container?: string | HTMLElement;\n style?: string;\n flavor?: string;\n /** \"light\" or \"dark\". Selects the mode half of the named style. */\n mode?: string;\n /** Label language, e.g. \"fr\". Omit to follow the request's Accept-Language. */\n lang?: string;\n /** Compact `ut1.` theme code from unmap.dev/create. Wins over the path style on the gateway. */\n theme?: string;\n /** Catalog layer ids composed onto the style (`municipalities`, `survey.dls`, …). */\n overlays?: readonly string[];\n /** Composition preset. Not a style. Explicit overlays replace the profile list. */\n profile?: MapProfile;\n /** `\"globe\"` or `\"mercator\"`. See `@unmap/maps` `UnmapMapOptions.projection`. */\n projection?: UnmapMapOptions[\"projection\"];\n center?: [number, number];\n zoom?: number;\n /** On-map controls. `true` (the default) adds zoom and compass buttons; `false` adds none. */\n controls?: boolean | UnmapControlsOptions;\n}\n\n/**\n * One Stripe-style key, the whole platform. With a `container` you get a rendered map.\n * `geocoder`, `router`, `elevation`, `timezone`, and `geolocation` are always available.\n *\n * const map = new Unmap({ key: \"um_live_...\", container: \"#map\", center: [-75.69, 45.42] });\n */\nexport class Unmap {\n readonly geocoder: Geocoder;\n readonly router: Router;\n readonly elevation: Elevation;\n /** IANA timezone and the UTC offset at an instant. One call, anywhere. */\n readonly timezone: Timezone;\n /** Canadian points of interest. Same corpus as the geocoder, in the Place shape. */\n readonly places: Places;\n /** Closures, incidents, construction and road conditions. */\n readonly roads: Roads;\n /** Report wrong data. Never metered. */\n readonly feedback: Feedback;\n /** Scheduled public-transit agencies, stops, routes and departures. */\n readonly transit: Transit;\n /**\n * Where each capability actually works. Unauthenticated and unmetered, so checking costs\n * nothing: read it before promising a user an answer, because transit routing is one agency\n * and road events are one province.\n */\n readonly coverage: Coverage;\n /**\n * Approximate location of the current request. Not device GPS. One call on the shared pool.\n */\n readonly geolocation: Geolocation;\n readonly data: { query(opts: QueryOptions): Promise<QueryResponse> };\n readonly map?: MaplibreMap;\n\n constructor(opts: UnmapOptions) {\n this.geocoder = new Geocoder(opts);\n this.router = new Router(opts);\n this.elevation = new Elevation(opts);\n this.timezone = new Timezone(opts);\n this.places = new Places(opts);\n this.roads = new Roads(opts);\n this.feedback = new Feedback(opts);\n this.transit = new Transit(opts);\n this.coverage = new Coverage(opts);\n this.geolocation = new Geolocation(opts);\n this.data = { query: (queryOpts) => this.geocoder.queryLayer(queryOpts) };\n if (opts.container) {\n this.map = createMap({ ...opts, container: opts.container } as UnmapMapOptions);\n }\n }\n\n /** Which catalog features contain a point. See `Geocoder.identify`. */\n identify(opts: IdentifyOptions): Promise<IdentifyResponse> {\n return this.geocoder.identify(opts);\n }\n}\n\n// The shared error type and retry policy, re-exported so a caller who installed only this\n// package can `catch (e) { if (e instanceof UnmapError) }` without adding @unmap/core.\nexport { UnmapError, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n","import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n\n/**\n * Typed clients for road events (`/incidents`, `/closures`, `/road-conditions`) and for data\n * correction (`POST /feedback`).\n *\n * These live in `@unmap/sdk` rather than in packages of their own. A twelfth and thirteenth npm\n * package would each need an entry in the changesets fixed group and a trusted publisher\n * configured on npmjs.com, which is founder work, and neither has a framework wrapper the way\n * geocoding and routing do. If a customer ever wants roads without the rest of the SDK, that is\n * the moment to split it out.\n */\n\nexport type RoadEventType =\n | \"closure\"\n | \"incident\"\n | \"construction\"\n | \"weather\"\n | \"restriction\"\n | \"ferry\"\n | \"hazard\"\n | \"special_event\"\n | \"unknown\";\n\nexport type RoadCondition =\n | \"dry\"\n | \"wet\"\n | \"snow\"\n | \"ice\"\n | \"packed_snow\"\n | \"reduced_visibility\"\n | \"travel_not_recommended\"\n | \"closed\"\n | \"unknown\";\n\nexport type RoadSeverity = \"minor\" | \"major\" | \"unknown\";\n\nexport interface AffectedRoad {\n name: string;\n direction: \"north\" | \"south\" | \"east\" | \"west\" | \"both\" | \"unknown\";\n /** True only when the publisher says closed. Never inferred from the description. */\n closed: boolean;\n from?: string;\n to?: string;\n condition: RoadCondition;\n}\n\nexport interface RoadEvent {\n /** `um:road:<jurisdiction>:<publisher id>`. */\n id: string;\n /** The publisher's own id, so a report can be taken back to them. */\n source_id: string;\n /** ISO 3166-2, e.g. `CA-BC`. */\n jurisdiction: string;\n type: RoadEventType;\n /** The publisher's own subtype strings, untranslated. */\n subtypes: string[];\n status: \"active\" | \"planned\" | \"archived\";\n severity: RoadSeverity;\n /**\n * The publisher's description, verbatim.\n *\n * Believe this over `type` when they disagree: our categories are a lossy projection of someone\n * else's taxonomy, and the sentence a driver needs is in the prose.\n */\n description: string;\n headline?: string;\n /** The worst surface condition across this event's roads. */\n condition: RoadCondition;\n roads: AffectedRoad[];\n /** GeoJSON Point or LineString, WGS84. */\n geometry: { type: string; coordinates: unknown } | null;\n starts_at: string | null;\n ends_at: string | null;\n source_updated_at: string | null;\n unmap_updated_at: string;\n source: string;\n}\n\nexport interface RoadEventsResponse {\n data: RoadEvent[];\n meta: {\n status: \"current\" | \"stale\" | \"partial\" | \"unknown\";\n attribution: string;\n unmap_updated_at: string;\n /**\n * Jurisdictions that could not be reached, each with a reason.\n *\n * **Check this.** On `/closures` an empty `data` reads as \"nothing is shut\" to someone\n * deciding whether to drive, and that is a very different answer from \"we could not reach\n * British Columbia\".\n */\n unavailable?: { jurisdiction: string; reason: string }[];\n };\n}\n\nexport interface RoadEventQuery {\n /** Comma-separated ISO 3166-2 codes, or an array. An uncovered code is a 400, not an empty list. */\n jurisdiction?: string | readonly string[];\n bbox?: [number, number, number, number];\n near?: [number, number];\n /** Metres from `near`. Default 25000, max 500000. */\n radius?: number;\n type?: RoadEventType | readonly RoadEventType[];\n severity?: RoadSeverity | readonly RoadSeverity[];\n status?: \"active\" | \"planned\" | \"archived\";\n /** ISO 8601. Only events the publisher changed at or after this time. */\n updated_since?: string;\n /** 1 to 500, default 100. Applied AFTER the endpoint's own narrowing. */\n limit?: number;\n signal?: AbortSignal;\n}\n\nexport interface RoadsOptions {\n key: string;\n gateway?: string;\n fetch?: typeof fetch;\n /**\n * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.\n *\n * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container\n * `503`. A `502` has none: routing uses `routing_failed`, and `/elevation` uses\n * `upstream_error`. With no header the client backs off itself. A wait longer than\n * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead.\n * See `RetryPolicy` in `@unmap/core`.\n */\n retry?: RetryPolicy | false;\n}\n\n/**\n * A road events failure.\n *\n * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside\n * every other unmap client's errors. `instanceof RoadsError` keeps working, and `status` and `code`\n * are still where they were; `retryAfterSeconds` is new and comes from the header.\n */\nexport class RoadsError extends UnmapError {\n constructor(status: number, message: string, code?: string, retryAfterSeconds?: number) {\n super(status, message, code, retryAfterSeconds);\n this.name = \"RoadsError\";\n }\n}\n\nfunction list(value: string | readonly string[] | undefined): string | undefined {\n if (value === undefined) return undefined;\n return Array.isArray(value) ? value.join(\",\") : String(value);\n}\n\nasync function errorFrom(res: Response, path: string, name: string): Promise<RoadsError> {\n const fallback = `${name} ${res.status} on ${path}`;\n let body: { error?: unknown; code?: unknown } | undefined;\n try {\n body = (await res.json()) as { error?: unknown; code?: unknown };\n } catch {\n body = undefined;\n }\n const reason = typeof body?.error === \"string\" ? body.error : undefined;\n const code = typeof body?.code === \"string\" ? body.code : undefined;\n const retryAfter = parseRetryAfter(res.headers?.get(\"retry-after\") ?? null) ?? undefined;\n return new RoadsError(res.status, reason ? `${reason} (${fallback})` : fallback, code, retryAfter);\n}\n\n/**\n * Canadian road events.\n *\n * const { data, meta } = await unmap.roads.closures({ jurisdiction: \"CA-BC\" });\n *\n * A 503 means every requested jurisdiction was unreachable; the body still carries\n * `meta.unavailable`, so the thrown error is the exception rather than the information. Prefer\n * reading `meta.unavailable` on a 200 over treating an empty list as good news.\n */\nexport class Roads {\n private readonly key: string;\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n private readonly retry: RetryPolicy | false | undefined;\n\n constructor(opts: RoadsOptions) {\n this.retry = opts.retry;\n this.key = opts.key;\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n /** Every current road event. */\n incidents(query: RoadEventQuery = {}): Promise<RoadEventsResponse> {\n return this.request(\"/incidents\", query);\n }\n\n /** The subset where a road is actually shut. Narrowed before `limit` is applied. */\n closures(query: RoadEventQuery = {}): Promise<RoadEventsResponse> {\n return this.request(\"/closures\", query);\n }\n\n /**\n * The subset carrying a surface condition.\n *\n * Thin for British Columbia by design: its feed reports lane availability rather than the\n * surface, so unmap answers `unknown` instead of inferring a dry road from open lanes.\n */\n conditions(query: RoadEventQuery = {}): Promise<RoadEventsResponse> {\n return this.request(\"/road-conditions\", query);\n }\n\n private async request(path: string, query: RoadEventQuery): Promise<RoadEventsResponse> {\n const q = new URLSearchParams({ key: this.key });\n const params: Record<string, string | undefined> = {\n jurisdiction: list(query.jurisdiction),\n bbox: query.bbox?.join(\",\"),\n near: query.near?.join(\",\"),\n radius: query.radius != null ? String(query.radius) : undefined,\n type: list(query.type),\n severity: list(query.severity),\n status: query.status,\n updated_since: query.updated_since,\n limit: query.limit != null ? String(query.limit) : undefined,\n };\n for (const [k, v] of Object.entries(params)) if (v != null && v !== \"\") q.set(k, v);\n\n const res = await fetchWithRetry(\n this.fetchImpl,\n `${this.base}${path}?${q}`,\n { signal: query.signal, headers: { accept: \"application/json\" } },\n this.retry,\n );\n if (!res.ok) throw await errorFrom(res, path, \"roads\");\n return (await res.json()) as RoadEventsResponse;\n }\n}\n\n// ---------------------------------------------------------------------------------------------\n// Feedback\n// ---------------------------------------------------------------------------------------------\n\nexport type FeedbackProduct =\n | \"tiles\"\n | \"terrain\"\n | \"names\"\n | \"geocoding\"\n | \"places\"\n | \"routing\"\n | \"layers\"\n | \"transit\"\n | \"roads\"\n | \"ev\";\n\nexport type FeedbackCategory =\n | \"incorrect_location\"\n | \"incorrect_address\"\n | \"missing_place\"\n | \"wrong_place_name\"\n | \"wrong_category\"\n | \"bad_route\"\n | \"missing_road_closure\"\n | \"incorrect_road_condition\"\n | \"incorrect_transit_result\"\n | \"other\";\n\nexport interface FeedbackReport {\n product: FeedbackProduct;\n category: FeedbackCategory;\n /** Up to 2000 characters, stored exactly as written. One of this or `resultId` is required. */\n description?: string;\n /** The unmap id of the result being reported. */\n resultId?: string;\n /**\n * The request being reported.\n *\n * **Only send this with the reporter's explicit agreement.** The gateway refuses it without\n * `include_context: true`, which this sets whenever `context` is present, and that flag is\n * meant to record a person's choice rather than a client default. unmap redacts query strings\n * from its own logs; a client that attached them here would undo that.\n */\n context?: unknown;\n signal?: AbortSignal;\n}\n\nexport interface FeedbackReceipt {\n /** Quote this in a follow-up. */\n id: string;\n status: string;\n created_at: string;\n /** Whether a request context was actually kept. `false` when none was offered. */\n context_stored: boolean;\n}\n\n/**\n * Report wrong data.\n *\n * await unmap.feedback.submit({\n * product: \"geocoding\",\n * category: \"incorrect_location\",\n * description: \"17 Ave SW returns a street in Edmonton.\",\n * });\n *\n * Authenticated like everything else and **never metered**: telling us our data is wrong does not\n * cost a call. At most 200 reports per account per day.\n */\nexport class Feedback {\n private readonly key: string;\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n\n constructor(opts: RoadsOptions) {\n this.key = opts.key;\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n submit(report: FeedbackReport): Promise<FeedbackReceipt> {\n return this.post(\"/feedback\", {\n product: report.product,\n category: report.category,\n ...(report.description ? { description: report.description } : {}),\n ...(report.resultId ? { result_id: report.resultId } : {}),\n ...(report.context !== undefined ? { include_context: true, context: report.context } : {}),\n }, report.signal);\n }\n\n /** A report about one place. `product` and `result_id` come from the path. */\n aboutPlace(\n placeId: string,\n report: Omit<FeedbackReport, \"product\" | \"resultId\">,\n ): Promise<FeedbackReceipt> {\n return this.post(`/places/${encodeURIComponent(placeId)}/feedback`, {\n category: report.category,\n ...(report.description ? { description: report.description } : {}),\n ...(report.context !== undefined ? { include_context: true, context: report.context } : {}),\n }, report.signal);\n }\n\n private async post(path: string, body: unknown, signal?: AbortSignal): Promise<FeedbackReceipt> {\n // Deliberately NOT routed through `fetchWithRetry`, unlike every read on this client.\n //\n // A feedback submission creates a record and carries no idempotency key, so a retry after a\n // timeout or a 503 risks filing the same report twice. Retrying a read costs a round trip;\n // retrying this costs the quality programme a duplicate, and the caller is the only one who\n // knows whether their report already landed.\n const res = await this.fetchImpl(`${this.base}${path}`, {\n method: \"POST\",\n signal,\n headers: { \"content-type\": \"application/json\", authorization: `Bearer ${this.key}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await errorFrom(res, path, \"feedback\");\n return (await res.json()) as FeedbackReceipt;\n }\n}\n","import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n\nexport type TransitMetaStatus = \"current\" | \"stale\" | \"partial\" | \"unknown\";\n\nexport interface TransitMeta {\n /** Static GTFS is scheduled data. Realtime will use a different value and updated_at. */\n schedule_type: \"scheduled\";\n source?: string;\n source_updated_at?: string | null;\n source_version?: string;\n content_hash?: string | null;\n sources?: readonly {\n id: string;\n source: string;\n source_url: string;\n attribution: string;\n source_updated_at: string | null;\n source_version: string;\n content_hash: string | null;\n status: \"current\" | \"stale\" | \"unknown\";\n }[];\n unmap_updated_at: string;\n data_version?: string;\n status: TransitMetaStatus;\n attribution: string;\n}\n\nexport interface TransitResponse<T> {\n data: T;\n meta: TransitMeta;\n}\n\nexport interface TransitAgency {\n id: string;\n feed: string;\n name: string;\n url?: string;\n timezone: string;\n lang?: string;\n phone?: string;\n fare_url?: string;\n}\n\nexport interface TransitStop {\n id: string;\n feed: string;\n name: string;\n coordinates: [number, number];\n code?: string;\n description?: string;\n zone_id?: string;\n parent_station_id?: string;\n wheelchair_boarding?: 0 | 1 | 2;\n route_ids: string[];\n /** Metres from the requested point. Present only on nearbyStops. */\n distance?: number;\n}\n\nexport interface TransitRoute {\n id: string;\n feed: string;\n agency_id: string;\n short_name?: string;\n long_name?: string;\n description?: string;\n route_type: number;\n colour?: string;\n text_colour?: string;\n url?: string;\n}\n\nexport interface TransitDeparture {\n stop_id: string;\n route_id: string;\n trip_id: string;\n headsign?: string;\n arrival: string;\n departure: string;\n stop_sequence: number;\n /** 2 = phone agency; 3 = coordinate with driver. Omitted for ordinary pickup. */\n pickup_type?: 2 | 3;\n schedule_type: \"scheduled\";\n}\n\nexport interface NearbyStopsOptions {\n /** Metres. Default 1000, range 50 to 10000. */\n radius?: number;\n /** Default 20, maximum 100. */\n limit?: number;\n signal?: AbortSignal;\n}\n\nexport interface DepartureOptions {\n /** An instant. Date values serialize to ISO; strings must include Z or an offset. Default now. */\n at?: Date | string;\n /** Minutes after at. Default 60, maximum 240. */\n window?: number;\n /** Default 50, maximum 200. */\n limit?: number;\n signal?: AbortSignal;\n}\n\nexport interface TransitOptions {\n key: string;\n gateway?: string;\n fetch?: typeof fetch;\n /**\n * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.\n *\n * On by default. `Retry-After` is on a `429` other than `billing_required`, and on a container\n * `503`. A `502` has none: routing uses `routing_failed`, and `/elevation` uses\n * `upstream_error`. With no header the client backs off itself. A wait longer than\n * `maxDelayMs` (10 s) is not slept through; the error carries `retryAfterSeconds` instead.\n * See `RetryPolicy` in `@unmap/core`.\n */\n retry?: RetryPolicy | false;\n}\n\n/**\n * A transit failure.\n *\n * Extends `UnmapError`, so `catch (e) { if (e instanceof UnmapError) }` catches this alongside\n * every other unmap client's errors. `instanceof TransitError` keeps working, and `status` and `code`\n * are still where they were; `retryAfterSeconds` is new and comes from the header.\n */\nexport class TransitError extends UnmapError {\n constructor(status: number, message: string, code?: string, retryAfterSeconds?: number) {\n super(status, message, code, retryAfterSeconds);\n this.name = \"TransitError\";\n }\n}\n\n/**\n * The gateway's error body, as a `TransitError`.\n *\n * Named rather than inline since 2026-09-20: `fetchWithRetry` needs to inspect the failure to\n * decide whether to wait, and the throw needs to build the same error. Two copies of this would\n * be two chances for the retry predicate and the thrown error to disagree.\n */\nasync function errorFrom(res: Response, path: string): Promise<TransitError> {\n let body: { error?: unknown; code?: unknown } = {};\n try {\n body = (await res.json()) as typeof body;\n } catch {\n /* use the bounded fallback */\n }\n const message = typeof body.error === \"string\" ? body.error : `transit ${res.status} on ${path}`;\n const code = typeof body.code === \"string\" ? body.code : undefined;\n const retryAfter = parseRetryAfter(res.headers?.get(\"retry-after\") ?? null) ?? undefined;\n return new TransitError(res.status, message, code, retryAfter);\n}\n\n/** Static Canadian GTFS data. Scheduled departures ship before realtime. */\nexport class Transit {\n private readonly key: string;\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n private readonly retry: RetryPolicy | false | undefined;\n\n constructor(opts: TransitOptions) {\n this.retry = opts.retry;\n this.key = opts.key;\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n agencies(signal?: AbortSignal): Promise<TransitResponse<TransitAgency[]>> {\n return this.get(\"/transit/agencies\", undefined, signal);\n }\n\n nearbyStops(near: [number, number], options: NearbyStopsOptions = {}): Promise<TransitResponse<TransitStop[]>> {\n return this.get(\"/transit/stops\", {\n near: near.join(\",\"),\n radius: options.radius,\n limit: options.limit,\n }, options.signal);\n }\n\n getStop(id: string, signal?: AbortSignal): Promise<TransitResponse<TransitStop>> {\n return this.get(`/transit/stops/${encodeURIComponent(id)}`, undefined, signal);\n }\n\n getRoute(id: string, signal?: AbortSignal): Promise<TransitResponse<TransitRoute>> {\n return this.get(`/transit/routes/${encodeURIComponent(id)}`, undefined, signal);\n }\n\n departures(id: string, options: DepartureOptions = {}): Promise<TransitResponse<TransitDeparture[]>> {\n return this.get(`/transit/stops/${encodeURIComponent(id)}/departures`, {\n at: options.at instanceof Date ? options.at.toISOString() : options.at,\n window: options.window,\n limit: options.limit,\n }, options.signal);\n }\n\n private async get<T>(\n path: string,\n values?: Record<string, string | number | undefined>,\n signal?: AbortSignal,\n ): Promise<TransitResponse<T>> {\n const query = new URLSearchParams({ key: this.key });\n for (const [name, value] of Object.entries(values ?? {})) {\n if (value !== undefined) query.set(name, String(value));\n }\n const response = await fetchWithRetry(\n this.fetchImpl,\n `${this.base}${path}?${query}`,\n { signal, headers: { accept: \"application/json\" } },\n this.retry,\n );\n if (!response.ok) throw await errorFrom(response, path);\n return await response.json() as TransitResponse<T>;\n }\n}\n","import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n\n/**\n * `GET /coverage.json` — where each capability actually works, and where it does not.\n *\n * The document is generated from the gateway's source registry rather than written by hand, so\n * it cannot claim a capability with no registered source behind it. It is also the only place\n * that answers \"is transit routing live in this city\" before you promise a user an answer:\n * routing is one agency, road events are one province, and Places coverage is OpenStreetMap's,\n * which is thin outside cities.\n *\n * Unauthenticated and unmetered on the gateway, which is why this client takes no key: a\n * developer deciding whether to use unmap has no key yet, and a customer checking whether a gap\n * has closed should not pay a call to be told it has not.\n */\n\n/** The one path this client calls. A literal so the gateway's SDK-parity audit can see it. */\nconst COVERAGE_PATH = \"/coverage.json\";\n\n/** Freshness of a capability or a source. `unknown` means no cadence was declared. */\nexport type CoverageFreshness = \"current\" | \"stale\" | \"unknown\";\n\nexport interface CoverageSource {\n id: string;\n provider: string;\n /** Bilingual, like every human-readable field in this document. */\n dataset_name: { en: string; fr: string };\n canonical_url: string;\n licence: { en: string; fr: string };\n licence_url: string;\n attribution: string;\n jurisdiction: string[];\n /** ISO 8601 duration, e.g. `P1D`. */\n refresh_interval: string;\n last_checked_at: string;\n last_success_at: string;\n source_version: string;\n content_hash: string | null;\n freshness: CoverageFreshness;\n stale_after: string | null;\n coverage: string;\n known_gaps: { en: string; fr: string };\n quality_status: string;\n}\n\nexport interface CoverageCapability {\n /** `tiles`, `geocoding`, `routing`, `places`, `transit`, `roads`, and so on. */\n id: string;\n display_name: { en: string; fr: string };\n /** `planned` is published as honestly as `live`: a capability absent from the page reads as \"not our problem\". */\n availability: \"live\" | \"planned\";\n /** The endpoints that serve it. Empty while planned. */\n endpoints: string[];\n coverage: { en: string; fr: string };\n /** Written to be accurate rather than flattering. Read this before promising coverage to a user. */\n known_gaps: { en: string; fr: string };\n /** ISO 3166-2 subdivisions, or `CA` for national. */\n jurisdictions: string[];\n freshness: CoverageFreshness;\n sources: CoverageSource[];\n}\n\nexport interface CoverageDocument {\n generated_at: string;\n freshness_basis: string;\n capabilities: CoverageCapability[];\n jurisdictions: unknown;\n}\n\nexport class CoverageError extends UnmapError {\n constructor(status: number, message: string, code?: string, retryAfterSeconds?: number) {\n super(status, message, code, retryAfterSeconds);\n this.name = \"CoverageError\";\n }\n}\n\nexport interface CoverageOptions {\n gateway?: string;\n /** Override the fetch implementation (tests, non-global environments). */\n fetch?: typeof fetch;\n retry?: RetryPolicy | false;\n}\n\n/** Where unmap works. Takes no key: the endpoint is unauthenticated and unmetered. */\nexport class Coverage {\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n private readonly retry: RetryPolicy | false | undefined;\n\n constructor(opts: CoverageOptions = {}) {\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n this.retry = opts.retry;\n }\n\n /** The whole document. Cached an hour at the edge, so polling it is cheap. */\n async get(opts: { signal?: AbortSignal } = {}): Promise<CoverageDocument> {\n const res = await fetchWithRetry(\n this.fetchImpl,\n `${this.base}${COVERAGE_PATH}`,\n { signal: opts.signal, headers: { accept: \"application/json\" } },\n this.retry,\n );\n if (!res.ok) {\n const retryAfter = parseRetryAfter(res.headers?.get?.(\"retry-after\") ?? null) ?? undefined;\n throw new CoverageError(res.status, `coverage ${res.status}`, undefined, retryAfter);\n }\n return (await res.json()) as CoverageDocument;\n }\n\n /**\n * One capability by id, or `undefined` when the document does not describe it.\n *\n * const transit = await unmap.coverage.capability(\"transit\");\n * if (!transit?.jurisdictions.includes(\"CA-ON\")) return \"not available here yet\";\n */\n async capability(id: string, opts: { signal?: AbortSignal } = {}): Promise<CoverageCapability | undefined> {\n const doc = await this.get(opts);\n return doc.capabilities.find((c) => c.id === id);\n }\n}\n","import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n\n/** The one path this client calls. A literal so the gateway's SDK-parity audit can see it. */\nconst TIMEZONE_PATH = \"/timezone\";\n\nexport interface TimezoneResult {\n timezone: string | null;\n offset: string | null;\n offsetSeconds: number | null;\n dst: boolean | null;\n}\n\nexport interface TimezoneLookupOptions {\n /** Instant the offset is evaluated at. Omit it for the current time. */\n at?: Date;\n signal?: AbortSignal;\n}\n\nexport class TimezoneError extends UnmapError {\n constructor(status: number, message: string, code?: string, retryAfterSeconds?: number) {\n super(status, message, code, retryAfterSeconds);\n this.name = \"TimezoneError\";\n }\n}\n\nexport interface TimezoneOptions {\n key: string;\n gateway?: string;\n fetch?: typeof fetch;\n retry?: RetryPolicy | false;\n}\n\n/**\n * IANA timezone for a coordinate.\n *\n * const zone = await unmap.timezone.lookup([-114.0719, 51.0447]);\n *\n * The coordinate is `[longitude, latitude]`, the same order as the rest of the SDK.\n * `at` selects the offset. It does not change which zone the coordinate falls in.\n */\nexport class Timezone {\n private readonly key: string;\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n private readonly retry: RetryPolicy | false | undefined;\n\n constructor(opts: TimezoneOptions) {\n this.retry = opts.retry;\n this.key = opts.key;\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n async lookup(coordinate: [number, number], opts: TimezoneLookupOptions = {}): Promise<TimezoneResult> {\n const [lon, lat] = coordinate;\n const q = new URLSearchParams({ key: this.key, lon: String(lon), lat: String(lat) });\n if (opts.at) q.set(\"at\", opts.at.toISOString());\n const res = await fetchWithRetry(\n this.fetchImpl,\n `${this.base}${TIMEZONE_PATH}?${q}`,\n { signal: opts.signal, headers: { accept: \"application/json\" } },\n this.retry,\n );\n if (!res.ok) throw await errorFrom(res);\n return (await res.json()) as TimezoneResult;\n }\n}\n\nasync function errorFrom(res: Response): Promise<TimezoneError> {\n const retryAfter = parseRetryAfter(res.headers?.get?.(\"retry-after\") ?? null) ?? undefined;\n let message = res.statusText || `timezone ${res.status}`;\n let code: string | undefined;\n try {\n const body = (await res.json()) as { error?: unknown; code?: unknown };\n if (typeof body.error === \"string\" && body.error) message = body.error;\n if (typeof body.code === \"string\") code = body.code;\n } catch {\n /* a non-JSON failure still carries the status */\n }\n return new TimezoneError(res.status, message, code, retryAfter);\n}\n","import { DEFAULT_GATEWAY, UnmapError, fetchWithRetry, parseRetryAfter, type RetryPolicy } from \"@unmap/core\";\n\n/**\n * Approximate location of the current request (`GET /ip`).\n *\n * This is the network the request arrived on, not a device fix and not a lookup of an\n * address you choose. `precision` is always `\"approximate\"`.\n */\n\n/** The one path this client calls. A literal so the gateway's SDK-parity audit can see it. */\nconst IP_PATH = \"/ip\";\n\nexport interface GeolocationOptions {\n key: string;\n gateway?: string;\n fetch?: typeof fetch;\n /**\n * Retry policy for `429`, `502`, `503` and transport failures. `false` disables it.\n *\n * On by default. A wait longer than `maxDelayMs` (10 s) is not slept through; the error\n * carries `retryAfterSeconds` instead.\n */\n retry?: RetryPolicy | false;\n}\n\nexport interface IpGeolocationResult {\n ip: string | null;\n location: {\n lat: number | null;\n lng: number | null;\n };\n city: string | null;\n region: string | null;\n regionCode: string | null;\n postalCode: string | null;\n country: string | null;\n continent: string | null;\n timezone: string | null;\n network: {\n asn: number | null;\n organization: string | null;\n };\n precision: \"approximate\";\n}\n\nexport class GeolocationError extends UnmapError {\n constructor(status: number, message: string, code?: string, retryAfterSeconds?: number) {\n super(status, message, code, retryAfterSeconds);\n this.name = \"GeolocationError\";\n }\n}\n\n/** Typed client for `GET /ip`. One call, one metered request, on the shared pool. */\nexport class Geolocation {\n private readonly key: string;\n private readonly base: string;\n private readonly fetchImpl: typeof fetch;\n private readonly retry: RetryPolicy | false | undefined;\n\n constructor(opts: GeolocationOptions) {\n this.key = opts.key;\n this.base = (opts.gateway ?? DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);\n this.retry = opts.retry;\n }\n\n /**\n * Approximate country, region, city, coordinates, and timezone of this request.\n *\n * const location = await unmap.geolocation.ip();\n *\n * A field the network did not identify is `null`. The call still resolves.\n */\n async ip(opts: { signal?: AbortSignal } = {}): Promise<IpGeolocationResult> {\n const q = new URLSearchParams({ key: this.key });\n const res = await fetchWithRetry(\n this.fetchImpl,\n `${this.base}${IP_PATH}?${q}`,\n { signal: opts.signal, headers: { accept: \"application/json\" } },\n this.retry,\n );\n if (!res.ok) throw await errorFrom(res);\n return (await res.json()) as IpGeolocationResult;\n }\n}\n\nasync function errorFrom(res: { status: number; headers?: Headers; json(): Promise<unknown> }): Promise<GeolocationError> {\n const fallback = `geolocation ${res.status}`;\n let body: { error?: unknown; code?: unknown } | undefined;\n try {\n body = (await res.json()) as { error?: unknown; code?: unknown };\n } catch {\n body = undefined;\n }\n const reason = typeof body?.error === \"string\" ? body.error : undefined;\n const code = typeof body?.code === \"string\" ? body.code : undefined;\n const retryAfter = parseRetryAfter(res.headers?.get(\"retry-after\") ?? null) ?? undefined;\n return new GeolocationError(res.status, reason ? `${reason} (${fallback})` : fallback, code, retryAfter);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAKK;AACP,SAAS,UAAU,cAAkG;;;ACPrH,SAAS,iBAAiB,YAAY,gBAAgB,uBAAyC;AAwIxF,IAAM,aAAN,cAAyB,WAAW;AAAA,EACzC,YAAY,QAAgB,SAAiB,MAAe,mBAA4B;AACtF,UAAM,QAAQ,SAAS,MAAM,iBAAiB;AAC9C,SAAK,OAAO;AAAA,EACd;AACF;AAEA,SAAS,KAAK,OAAmE;AAC/E,MAAI,UAAU,OAAW,QAAO;AAChC,SAAO,MA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,wBAAyC;AApDvD,IAAM,QAAN,MAAY;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAoB;AAC9B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,SAAS,IAAI,OAAO,IAAI;AAC7B,SAAK,YAAY,IAAI,UAAU,IAAI;AACnC,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,SAAS,IAAI,OAAO,IAAI;AAC7B,SAAK,QAAQ,IAAI,MAAM,IAAI;AAC3B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,UAAU,IAAI,QAAQ,IAAI;AAC/B,SAAK,WAAW,IAAI,SAAS,IAAI;AACjC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,OAAO,EAAE,OAAO,CAAC,cAAc,KAAK,SAAS,WAAW,SAAS,EAAE;AACxE,QAAI,KAAK,WAAW;AAClB,WAAK,MAAM,UAAU,EAAE,GAAG,MAAM,WAAW,KAAK,UAAU,CAAoB;AAAA,IAChF;AAAA,EACF;AAAA;AAAA,EAGA,SAAS,MAAkD;AACzD,WAAO,KAAK,SAAS,SAAS,IAAI;AAAA,EACpC;AACF;","names":["DEFAULT_GATEWAY","UnmapError","fetchWithRetry","parseRetryAfter","errorFrom","DEFAULT_GATEWAY","UnmapError","fetchWithRetry","parseRetryAfter","DEFAULT_GATEWAY","UnmapError","fetchWithRetry","parseRetryAfter","errorFrom","DEFAULT_GATEWAY","UnmapError","fetchWithRetry","parseRetryAfter","errorFrom","createMap","UnmapError","parseRetryAfter"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unmap/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "One key, the whole unmap platform: map + geocoder + router",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  "routing",
13
13
  "sdk"
14
14
  ],
15
- "homepage": "https://unmap.dev/docs/quickstart",
15
+ "homepage": "https://unmap.dev/docs/start/quickstart",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/unmap-dev/unmap.git",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "maplibre-gl": "^6.7.0",
43
- "@unmap/core": "0.12.0",
44
- "@unmap/elevation": "0.12.0",
45
- "@unmap/geocoding": "0.12.0",
46
- "@unmap/maps": "0.12.0",
47
- "@unmap/routing": "0.12.0"
43
+ "@unmap/core": "0.14.0",
44
+ "@unmap/elevation": "0.14.0",
45
+ "@unmap/geocoding": "0.14.0",
46
+ "@unmap/maps": "0.14.0",
47
+ "@unmap/routing": "0.14.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.3.0",