@chaosity/location-client 0.8.0 → 0.10.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.
Files changed (54) hide show
  1. package/README.md +264 -42
  2. package/dist/adapters/GeoPlaces.d.ts +30 -3
  3. package/dist/adapters/GeoPlaces.js +5 -1
  4. package/dist/cjs/adapters/GeoPlaces.d.ts +30 -3
  5. package/dist/cjs/adapters/GeoPlaces.js +5 -4
  6. package/dist/cjs/client/GeoPlacesClient.d.ts +16 -4
  7. package/dist/cjs/client/GeoPlacesClient.js +24 -10
  8. package/dist/cjs/client/commands.d.ts +159 -0
  9. package/dist/cjs/client/commands.js +108 -0
  10. package/dist/cjs/errors/LocationServiceException.d.ts +28 -1
  11. package/dist/cjs/errors/LocationServiceException.js +31 -2
  12. package/dist/cjs/index.d.ts +5 -3
  13. package/dist/cjs/index.js +17 -1
  14. package/dist/cjs/maps/mapEnums.d.ts +82 -4
  15. package/dist/cjs/maps/mapEnums.js +98 -5
  16. package/dist/cjs/maps/mapStyle.d.ts +87 -10
  17. package/dist/cjs/maps/mapStyle.js +28 -5
  18. package/dist/cjs/maps/staticMap.d.ts +40 -0
  19. package/dist/cjs/maps/staticMap.js +4 -0
  20. package/dist/cjs/server/LocationServiceConnector.d.ts +23 -5
  21. package/dist/cjs/server/LocationServiceConnector.js +32 -14
  22. package/dist/cjs/transport/endpoints.js +3 -0
  23. package/dist/cjs/transport/http.d.ts +2 -2
  24. package/dist/cjs/transport/http.js +2 -2
  25. package/dist/cjs/types/index.d.ts +6 -5
  26. package/dist/cjs/utils/tokenClaims.d.ts +37 -13
  27. package/dist/cjs/utils/tokenClaims.js +36 -14
  28. package/dist/client/GeoPlacesClient.d.ts +16 -4
  29. package/dist/client/GeoPlacesClient.js +24 -10
  30. package/dist/client/commands.d.ts +159 -0
  31. package/dist/client/commands.js +97 -0
  32. package/dist/errors/LocationServiceException.d.ts +28 -1
  33. package/dist/errors/LocationServiceException.js +30 -1
  34. package/dist/index.d.ts +5 -3
  35. package/dist/index.js +7 -2
  36. package/dist/maps/mapEnums.d.ts +82 -4
  37. package/dist/maps/mapEnums.js +97 -4
  38. package/dist/maps/mapStyle.d.ts +87 -10
  39. package/dist/maps/mapStyle.js +28 -5
  40. package/dist/maps/staticMap.d.ts +40 -0
  41. package/dist/maps/staticMap.js +4 -0
  42. package/dist/server/LocationServiceConnector.d.ts +23 -5
  43. package/dist/server/LocationServiceConnector.js +32 -14
  44. package/dist/transport/endpoints.js +3 -0
  45. package/dist/transport/http.d.ts +2 -2
  46. package/dist/transport/http.js +2 -2
  47. package/dist/types/index.d.ts +6 -5
  48. package/dist/utils/tokenClaims.d.ts +37 -13
  49. package/dist/utils/tokenClaims.js +36 -14
  50. package/package.json +1 -1
  51. package/dist/cjs/utils/roundPosition.d.ts +0 -66
  52. package/dist/cjs/utils/roundPosition.js +0 -109
  53. package/dist/utils/roundPosition.d.ts +0 -66
  54. package/dist/utils/roundPosition.js +0 -104
package/dist/index.js CHANGED
@@ -5,9 +5,14 @@ export { DEFAULT_MAX_ATTEMPTS, DEFAULT_OVERALL_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, }
5
5
  // Token refresh policy — shared by the server provider and the React provider
6
6
  export { TOKEN_REFRESH_BUFFER_SECONDS, readTokenExpiry, } from './auth/tokenRefresh.js';
7
7
  // Errors
8
- export { LocationServiceException } from './errors/LocationServiceException.js';
8
+ export { FEATURE_NOT_ENTITLED, LocationServiceException, } from './errors/LocationServiceException.js';
9
9
  // Re-export AWS SDK commands and types
10
10
  export * from '@aws-sdk/client-geo-places';
11
+ // …except the seven Places commands and their inputs, which take neither
12
+ // IntendedUse nor Key: the service strips both from every request (#40). A
13
+ // named export wins over the `export *` above, as GeoPlacesClient's does.
14
+ // VerifyAddressCommand is this package's own: its route has no SDK command (#54).
15
+ export { AutocompleteCommand, GeocodeCommand, GetPlaceCommand, ReverseGeocodeCommand, SearchNearbyCommand, SearchTextCommand, SuggestCommand, VerifyAddressCommand, } from './client/commands.js';
11
16
  // Re-export AWS Location Utilities (data type conversions)
12
17
  export * from '@aws/amazon-location-utilities-datatypes';
13
18
  // Adapters (Custom - for MapLibre integration)
@@ -20,6 +25,6 @@ export { buildMapStyleUrl, fetchMapStyle } from './maps/mapStyle.js';
20
25
  export { buildStaticMapUrl, fetchStaticMap, staticMapAccept, } from './maps/staticMap.js';
21
26
  // Accepted values for every map parameter, as VALUES so a picker can be built
22
27
  // from them, plus the matching types. Case sensitive — see mapEnums.ts.
23
- export { BUILDINGS, COLOR_SCHEMES, CONTOUR_DENSITIES, LABEL_SIZES, MAP_FEATURE_MODES, MAP_STYLES, SCALE_BAR_UNITS, SPRITE_VARIANTS, STATIC_MAP_STYLES, TERRAINS, TRAFFIC_MODES, TRAVEL_MODES, } from './maps/mapEnums.js';
28
+ export { BUILDINGS, COLOR_SCHEMES, CONTOUR_DENSITIES, LABEL_SIZES, MAP_FEATURE_MODES, MAP_STYLES, POI_DENSITIES, SCALE_BAR_UNITS, SPRITE_VARIANTS, STATIC_MAP_STYLES, STYLE_POI_CATEGORIES, TERRAINS, TRAFFIC_MODES, TRAVEL_MODES, } from './maps/mapEnums.js';
24
29
  export { transformRequest } from './maps/Utils.js';
25
30
  // Server-only utilities are available via '@chaosity/location-client/server'
@@ -40,8 +40,26 @@
40
40
  * client-side mirror and every value below was additionally confirmed against
41
41
  * the live geo-maps API on 2026-08-26. If the API starts rejecting something
42
42
  * listed here, its generated list is the authority.
43
+ *
44
+ * SOME VALUES ARE PLAN FEATURES
45
+ *
46
+ * A list tagged `@planFeature <feature>` holds values the application's plan
47
+ * must include — every value, or only the ones named after the dash (#55). A
48
+ * value the plan lacks is refused 403 `FeatureNotEntitledException`, naming
49
+ * the feature, so a picker built from `MAP_STYLES` offers Satellite to an
50
+ * application that will be refused it. Leave those out of a picker, or mark
51
+ * them. Which plan includes which feature is not this file's to say — it can
52
+ * change without a release: see https://chaosity.cloud/pricing. A list with no
53
+ * tag is open to every plan.
54
+ */
55
+ /**
56
+ * Map styles for the style descriptor.
57
+ *
58
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
59
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
60
+ *
61
+ * @planFeature satellite — Hybrid, Satellite
43
62
  */
44
- /** Map styles for the style descriptor. */
45
63
  export declare const MAP_STYLES: readonly ["Hybrid", "Monochrome", "Satellite", "Standard"];
46
64
  export type MapStyle = (typeof MAP_STYLES)[number];
47
65
  /**
@@ -49,16 +67,38 @@ export type MapStyle = (typeof MAP_STYLES)[number];
49
67
  *
50
68
  * `/maps/static/*` takes only Satellite and Standard. Passing Hybrid or
51
69
  * Monochrome there is a 400, so the two lists are not interchangeable.
70
+ *
71
+ * A static map with no `style` is a Satellite render, so it needs the
72
+ * `satellite` feature as well.
73
+ *
74
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
75
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
76
+ *
77
+ * @planFeature satellite — Satellite
52
78
  */
53
79
  export declare const STATIC_MAP_STYLES: readonly ["Satellite", "Standard"];
54
80
  export type StaticMapStyle = (typeof STATIC_MAP_STYLES)[number];
55
81
  /** Light or dark cartography. Not applicable to the raster styles. */
56
82
  export declare const COLOR_SCHEMES: readonly ["Dark", "Light"];
57
83
  export type ColorScheme = (typeof COLOR_SCHEMES)[number];
58
- /** Terrain overlay. `Hillshade` is shaded relief; `Terrain3D` is elevation. */
84
+ /**
85
+ * Terrain overlay. `Hillshade` is shaded relief; `Terrain3D` is elevation.
86
+ *
87
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
88
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
89
+ *
90
+ * @planFeature terrain
91
+ */
59
92
  export declare const TERRAINS: readonly ["Hillshade", "Terrain3D"];
60
93
  export type Terrain = (typeof TERRAINS)[number];
61
- /** 3D building extrusions. One value today, kept a list for when that changes. */
94
+ /**
95
+ * 3D building extrusions. A list, like the others, for when Amazon adds a value.
96
+ *
97
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
98
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
99
+ *
100
+ * @planFeature buildings
101
+ */
62
102
  export declare const BUILDINGS: readonly ["Buildings3D"];
63
103
  export type Buildings = (typeof BUILDINGS)[number];
64
104
  /**
@@ -67,6 +107,11 @@ export type Buildings = (typeof BUILDINGS)[number];
67
107
  * All three work. An earlier version of this library documented `Medium` as
68
108
  * "the only value currently supported by the AWS SDK", which was wrong — `High`
69
109
  * and `Low` were both confirmed against the live API on 2026-08-26.
110
+ *
111
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
112
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
113
+ *
114
+ * @planFeature contours
70
115
  */
71
116
  export declare const CONTOUR_DENSITIES: readonly ["High", "Low", "Medium"];
72
117
  export type ContourDensity = (typeof CONTOUR_DENSITIES)[number];
@@ -75,10 +120,22 @@ export type ContourDensity = (typeof CONTOUR_DENSITIES)[number];
75
120
  *
76
121
  * `Congestion` was previously missing from this library's types, so it could
77
122
  * not be requested from TypeScript even though the API accepts it.
123
+ *
124
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
125
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
126
+ *
127
+ * @planFeature traffic
78
128
  */
79
129
  export declare const TRAFFIC_MODES: readonly ["All", "Congestion"];
80
130
  export type TrafficMode = (typeof TRAFFIC_MODES)[number];
81
- /** Routing overlays. Sent as a comma-separated list; each entry is checked. */
131
+ /**
132
+ * Routing overlays. Sent as a comma-separated list; each entry is checked.
133
+ *
134
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
135
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
136
+ *
137
+ * @planFeature travel-modes
138
+ */
82
139
  export declare const TRAVEL_MODES: readonly ["Transit", "Truck"];
83
140
  export type TravelMode = (typeof TRAVEL_MODES)[number];
84
141
  /** Sprite sheet variant. One value today. */
@@ -100,3 +157,24 @@ export type ScaleBarUnit = (typeof SCALE_BAR_UNITS)[number];
100
157
  */
101
158
  export declare const MAP_FEATURE_MODES: readonly ["Disabled", "Enabled"];
102
159
  export type MapFeatureMode = (typeof MAP_FEATURE_MODES)[number];
160
+ /**
161
+ * How many points of interest the style descriptor draws (#40). `Off` removes
162
+ * the poi layers outright; the others thin them out or add more.
163
+ *
164
+ * Standard and Hybrid accept it; Monochrome and Satellite answer 400 naming
165
+ * the parameter, as they do for `STYLE_POI_CATEGORIES`. That is the API's rule
166
+ * to answer, like every combination rule above.
167
+ */
168
+ export declare const POI_DENSITIES: readonly ["Default", "Dense", "Off", "Sparse", "VeryDense", "VerySparse"];
169
+ export type PoiDensity = (typeof POI_DENSITIES)[number];
170
+ /**
171
+ * The categories of point of interest a style descriptor can be limited to
172
+ * (#40). Sent as a comma-separated list; only the named categories are drawn.
173
+ *
174
+ * Not `PoiCategory`: that name is already this package's type for
175
+ * `setPoiVisibility`'s layer groups, which hide categories on a map already
176
+ * loaded. This one asks the API for a descriptor that draws only these — the
177
+ * SDK's name qualified the way `TRAFFIC_MODES` and `SPRITE_VARIANTS` are.
178
+ */
179
+ export declare const STYLE_POI_CATEGORIES: readonly ["Accommodations", "BusinessAndServices", "Entertainment", "FacilitiesAndBuildings", "FoodAndDrink", "LeisureAndOutdoor", "Shopping", "SightsAndMuseums", "Transportation"];
180
+ export type StylePoiCategory = (typeof STYLE_POI_CATEGORIES)[number];
@@ -40,8 +40,26 @@
40
40
  * client-side mirror and every value below was additionally confirmed against
41
41
  * the live geo-maps API on 2026-08-26. If the API starts rejecting something
42
42
  * listed here, its generated list is the authority.
43
+ *
44
+ * SOME VALUES ARE PLAN FEATURES
45
+ *
46
+ * A list tagged `@planFeature <feature>` holds values the application's plan
47
+ * must include — every value, or only the ones named after the dash (#55). A
48
+ * value the plan lacks is refused 403 `FeatureNotEntitledException`, naming
49
+ * the feature, so a picker built from `MAP_STYLES` offers Satellite to an
50
+ * application that will be refused it. Leave those out of a picker, or mark
51
+ * them. Which plan includes which feature is not this file's to say — it can
52
+ * change without a release: see https://chaosity.cloud/pricing. A list with no
53
+ * tag is open to every plan.
54
+ */
55
+ /**
56
+ * Map styles for the style descriptor.
57
+ *
58
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
59
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
60
+ *
61
+ * @planFeature satellite — Hybrid, Satellite
43
62
  */
44
- /** Map styles for the style descriptor. */
45
63
  export const MAP_STYLES = [
46
64
  'Hybrid',
47
65
  'Monochrome',
@@ -53,13 +71,35 @@ export const MAP_STYLES = [
53
71
  *
54
72
  * `/maps/static/*` takes only Satellite and Standard. Passing Hybrid or
55
73
  * Monochrome there is a 400, so the two lists are not interchangeable.
74
+ *
75
+ * A static map with no `style` is a Satellite render, so it needs the
76
+ * `satellite` feature as well.
77
+ *
78
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
79
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
80
+ *
81
+ * @planFeature satellite — Satellite
56
82
  */
57
83
  export const STATIC_MAP_STYLES = ['Satellite', 'Standard'];
58
84
  /** Light or dark cartography. Not applicable to the raster styles. */
59
85
  export const COLOR_SCHEMES = ['Dark', 'Light'];
60
- /** Terrain overlay. `Hillshade` is shaded relief; `Terrain3D` is elevation. */
86
+ /**
87
+ * Terrain overlay. `Hillshade` is shaded relief; `Terrain3D` is elevation.
88
+ *
89
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
90
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
91
+ *
92
+ * @planFeature terrain
93
+ */
61
94
  export const TERRAINS = ['Hillshade', 'Terrain3D'];
62
- /** 3D building extrusions. One value today, kept a list for when that changes. */
95
+ /**
96
+ * 3D building extrusions. A list, like the others, for when Amazon adds a value.
97
+ *
98
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
99
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
100
+ *
101
+ * @planFeature buildings
102
+ */
63
103
  export const BUILDINGS = ['Buildings3D'];
64
104
  /**
65
105
  * Elevation contour line density.
@@ -67,6 +107,11 @@ export const BUILDINGS = ['Buildings3D'];
67
107
  * All three work. An earlier version of this library documented `Medium` as
68
108
  * "the only value currently supported by the AWS SDK", which was wrong — `High`
69
109
  * and `Low` were both confirmed against the live API on 2026-08-26.
110
+ *
111
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
112
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
113
+ *
114
+ * @planFeature contours
70
115
  */
71
116
  export const CONTOUR_DENSITIES = ['High', 'Low', 'Medium'];
72
117
  /**
@@ -74,9 +119,21 @@ export const CONTOUR_DENSITIES = ['High', 'Low', 'Medium'];
74
119
  *
75
120
  * `Congestion` was previously missing from this library's types, so it could
76
121
  * not be requested from TypeScript even though the API accepts it.
122
+ *
123
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
124
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
125
+ *
126
+ * @planFeature traffic
77
127
  */
78
128
  export const TRAFFIC_MODES = ['All', 'Congestion'];
79
- /** Routing overlays. Sent as a comma-separated list; each entry is checked. */
129
+ /**
130
+ * Routing overlays. Sent as a comma-separated list; each entry is checked.
131
+ *
132
+ * Refused on a plan without it: 403 `FeatureNotEntitledException`, see
133
+ * `FEATURE_NOT_ENTITLED` and the note at the top of this file.
134
+ *
135
+ * @planFeature travel-modes
136
+ */
80
137
  export const TRAVEL_MODES = ['Transit', 'Truck'];
81
138
  /** Sprite sheet variant. One value today. */
82
139
  export const SPRITE_VARIANTS = ['Default'];
@@ -98,3 +155,39 @@ export const SCALE_BAR_UNITS = [
98
155
  * `setPoiVisibility` instead.
99
156
  */
100
157
  export const MAP_FEATURE_MODES = ['Disabled', 'Enabled'];
158
+ /**
159
+ * How many points of interest the style descriptor draws (#40). `Off` removes
160
+ * the poi layers outright; the others thin them out or add more.
161
+ *
162
+ * Standard and Hybrid accept it; Monochrome and Satellite answer 400 naming
163
+ * the parameter, as they do for `STYLE_POI_CATEGORIES`. That is the API's rule
164
+ * to answer, like every combination rule above.
165
+ */
166
+ export const POI_DENSITIES = [
167
+ 'Default',
168
+ 'Dense',
169
+ 'Off',
170
+ 'Sparse',
171
+ 'VeryDense',
172
+ 'VerySparse',
173
+ ];
174
+ /**
175
+ * The categories of point of interest a style descriptor can be limited to
176
+ * (#40). Sent as a comma-separated list; only the named categories are drawn.
177
+ *
178
+ * Not `PoiCategory`: that name is already this package's type for
179
+ * `setPoiVisibility`'s layer groups, which hide categories on a map already
180
+ * loaded. This one asks the API for a descriptor that draws only these — the
181
+ * SDK's name qualified the way `TRAFFIC_MODES` and `SPRITE_VARIANTS` are.
182
+ */
183
+ export const STYLE_POI_CATEGORIES = [
184
+ 'Accommodations',
185
+ 'BusinessAndServices',
186
+ 'Entertainment',
187
+ 'FacilitiesAndBuildings',
188
+ 'FoodAndDrink',
189
+ 'LeisureAndOutdoor',
190
+ 'Shopping',
191
+ 'SightsAndMuseums',
192
+ 'Transportation',
193
+ ];
@@ -1,6 +1,6 @@
1
1
  import type { StyleSpecification } from 'maplibre-gl';
2
2
  import type { RequestOptions } from '../transport/http.js';
3
- import type { Buildings, ColorScheme, ContourDensity, MapStyle, Terrain, TrafficMode, TravelMode } from './mapEnums.js';
3
+ import type { Buildings, ColorScheme, ContourDensity, MapStyle, PoiDensity, StylePoiCategory, Terrain, TrafficMode, TravelMode } from './mapEnums.js';
4
4
  /**
5
5
  * Options for building an AWS Location Service map style URL.
6
6
  * All parameters map directly to query parameters supported by the style descriptor endpoint.
@@ -8,15 +8,46 @@ import type { Buildings, ColorScheme, ContourDensity, MapStyle, Terrain, Traffic
8
8
  * Values are CASE SENSITIVE — the API rejects a wrong-cased one with a 400 that
9
9
  * names the right spelling. Import the arrays from `mapEnums` to build pickers
10
10
  * rather than typing the values, and the case is right by construction.
11
+ *
12
+ * The options tagged `@planFeature` are PLAN FEATURES, each tag naming its
13
+ * feature (#55). An application whose plan does not include one is
14
+ * refused 403 `FeatureNotEntitledException` — `isFeatureNotEntitled` on the
15
+ * error — before anything is drawn, and the message names the feature and the
16
+ * option that asked for it. `colorScheme`, `poiDensity` and `poiCategories`
17
+ * are open to every plan, as are the Standard and Monochrome styles. Which plan
18
+ * includes which feature is not this package's to say, since it can change
19
+ * without a release: see https://chaosity.cloud/pricing.
11
20
  */
12
21
  export interface MapStyleOptions {
13
22
  /** Color scheme for the map (default: Light). Not applicable to Satellite/Hybrid styles. */
14
23
  colorScheme?: ColorScheme;
15
- /** ISO 3166-1 alpha-3 country code for political boundary perspective (e.g. 'IND', 'TUR'). */
24
+ /**
25
+ * ISO 3166-1 alpha-3 country code for political boundary perspective
26
+ * (e.g. 'IND', 'TUR').
27
+ *
28
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
29
+ * `FEATURE_NOT_ENTITLED`).
30
+ *
31
+ * @planFeature political-view
32
+ */
16
33
  politicalView?: string;
17
- /** Terrain overlay type. */
34
+ /**
35
+ * Terrain overlay type.
36
+ *
37
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
38
+ * `FEATURE_NOT_ENTITLED`).
39
+ *
40
+ * @planFeature terrain
41
+ */
18
42
  terrain?: Terrain;
19
- /** Enable 3D building extrusions. */
43
+ /**
44
+ * Enable 3D building extrusions.
45
+ *
46
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
47
+ * `FEATURE_NOT_ENTITLED`).
48
+ *
49
+ * @planFeature buildings
50
+ */
20
51
  buildings?: Buildings;
21
52
  /**
22
53
  * Elevation contour line density.
@@ -24,6 +55,11 @@ export interface MapStyleOptions {
24
55
  * All of High, Low and Medium work. This was previously typed as `'Medium'`
25
56
  * alone, documented as "the only value currently supported by the AWS SDK",
26
57
  * which was wrong — the other two were confirmed against the live API.
58
+ *
59
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
60
+ * `FEATURE_NOT_ENTITLED`).
61
+ *
62
+ * @planFeature contours
27
63
  */
28
64
  contourDensity?: ContourDensity;
29
65
  /**
@@ -34,21 +70,48 @@ export interface MapStyleOptions {
34
70
  *
35
71
  * Valid on its own, but NOT with every style: `Satellite` + `All` answers
36
72
  * 400 "Traffic is not supported for style." Amazon owns that rule.
73
+ *
74
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
75
+ * `FEATURE_NOT_ENTITLED`).
76
+ *
77
+ * @planFeature traffic
37
78
  */
38
79
  traffic?: TrafficMode;
39
- /** Travel mode overlays for routing-specific features. */
80
+ /**
81
+ * Travel mode overlays for routing-specific features.
82
+ *
83
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
84
+ * `FEATURE_NOT_ENTITLED`).
85
+ *
86
+ * @planFeature travel-modes
87
+ */
40
88
  travelModes?: TravelMode[];
89
+ /**
90
+ * How many points of interest to draw; `Off` draws none. Standard and
91
+ * Hybrid only — Monochrome and Satellite answer 400.
92
+ */
93
+ poiDensity?: PoiDensity;
94
+ /**
95
+ * Draw only these categories of point of interest. Standard and Hybrid
96
+ * only, like `poiDensity`.
97
+ */
98
+ poiCategories?: StylePoiCategory[];
41
99
  }
42
100
  /**
43
101
  * Build a map style descriptor URL for the Location Service API.
44
102
  *
103
+ * MapLibre fetches this URL itself, so a refusal of it never reaches this
104
+ * package's error type — see `fetchMapStyle` for what it looks like instead.
105
+ *
45
106
  * @param apiUrl - Base URL of the Location Service API
46
- * @param mapStyle - Map style name (e.g. 'Standard', 'Monochrome', 'Satellite', 'Hybrid')
47
- * @param options - Optional style parameters
107
+ * @param mapStyle - Map style name: 'Standard' or 'Monochrome', or 'Satellite'
108
+ * or 'Hybrid', which need the `satellite` plan feature (see `MAP_STYLES`)
109
+ * @param options - Optional style parameters; those tagged `@planFeature` need
110
+ * that feature of the application's plan
48
111
  * @returns Full style descriptor URL
49
112
  *
50
113
  * @example
51
- * const url = buildMapStyleUrl(API_URL, 'Standard', { colorScheme: 'Dark', terrain: 'Hillshade' })
114
+ * const url = buildMapStyleUrl(API_URL, 'Standard', { colorScheme: 'Dark' })
52
115
  * map.setStyle(url)
53
116
  */
54
117
  export declare function buildMapStyleUrl(apiUrl: string, mapStyle: MapStyle, options?: MapStyleOptions): string;
@@ -63,10 +126,24 @@ export declare function buildMapStyleUrl(apiUrl: string, mapStyle: MapStyle, opt
63
126
  * `map.setStyle()`. Tile, glyph, and sprite requests still go through `transformRequest`
64
127
  * for authentication — this only pre-processes the descriptor itself.
65
128
  *
129
+ * A REFUSED OPTION. This is the path that surfaces a plan refusal as this
130
+ * package's error: an option tagged `@planFeature` that the application's plan
131
+ * does not include rejects with a `LocationServiceException` whose
132
+ * `isFeatureNotEntitled` is true (code `FeatureNotEntitledException`, status
133
+ * 403), and whose message names the feature and the option. What MapLibre
134
+ * fetches for itself — a URL from `buildMapStyleUrl` handed to `setStyle`, and
135
+ * the tiles — is refused the same way when it asks for a feature the plan
136
+ * lacks, but the refusal arrives as a MapLibre `error` event instead:
137
+ * `event.error.status` is 403, and `event.error.body` is a `Blob` holding the
138
+ * same `{ message, code }` JSON.
139
+ *
66
140
  * @param apiUrl - Base URL of the Location Service API
67
- * @param mapStyle - Map style name (e.g. 'Standard', 'Monochrome', 'Satellite', 'Hybrid')
141
+ * @param mapStyle - Map style name: 'Standard' or 'Monochrome', or 'Satellite'
142
+ * or 'Hybrid', which need the `satellite` plan feature (see `MAP_STYLES`)
68
143
  * @param getToken - Callback returning the current auth token
69
- * @param options - Style options; `language` is applied to the descriptor, all others become URL params
144
+ * @param options - Style options; `language` is applied to the descriptor, all
145
+ * others become URL params. Those tagged `@planFeature` need that feature of
146
+ * the application's plan
70
147
  * @param request - Transport options: `signal` to cancel, `timeoutMs`, `overallTimeoutMs`, `retry`
71
148
  * @returns Modified MapLibre StyleSpecification object
72
149
  *
@@ -4,13 +4,18 @@ import { labelsByName, languageExpression } from './mapLanguage.js';
4
4
  /**
5
5
  * Build a map style descriptor URL for the Location Service API.
6
6
  *
7
+ * MapLibre fetches this URL itself, so a refusal of it never reaches this
8
+ * package's error type — see `fetchMapStyle` for what it looks like instead.
9
+ *
7
10
  * @param apiUrl - Base URL of the Location Service API
8
- * @param mapStyle - Map style name (e.g. 'Standard', 'Monochrome', 'Satellite', 'Hybrid')
9
- * @param options - Optional style parameters
11
+ * @param mapStyle - Map style name: 'Standard' or 'Monochrome', or 'Satellite'
12
+ * or 'Hybrid', which need the `satellite` plan feature (see `MAP_STYLES`)
13
+ * @param options - Optional style parameters; those tagged `@planFeature` need
14
+ * that feature of the application's plan
10
15
  * @returns Full style descriptor URL
11
16
  *
12
17
  * @example
13
- * const url = buildMapStyleUrl(API_URL, 'Standard', { colorScheme: 'Dark', terrain: 'Hillshade' })
18
+ * const url = buildMapStyleUrl(API_URL, 'Standard', { colorScheme: 'Dark' })
14
19
  * map.setStyle(url)
15
20
  */
16
21
  export function buildMapStyleUrl(apiUrl, mapStyle, options = {}) {
@@ -29,6 +34,10 @@ export function buildMapStyleUrl(apiUrl, mapStyle, options = {}) {
29
34
  params.set('traffic', options.traffic);
30
35
  if (options.travelModes?.length)
31
36
  params.set('travel-modes', options.travelModes.join(','));
37
+ if (options.poiDensity)
38
+ params.set('poi-density', options.poiDensity);
39
+ if (options.poiCategories?.length)
40
+ params.set('poi-categories', options.poiCategories.join(','));
32
41
  const qs = params.toString();
33
42
  return `${apiUrl}/maps/${mapStyle}/descriptor${qs ? `?${qs}` : ''}`;
34
43
  }
@@ -43,10 +52,24 @@ export function buildMapStyleUrl(apiUrl, mapStyle, options = {}) {
43
52
  * `map.setStyle()`. Tile, glyph, and sprite requests still go through `transformRequest`
44
53
  * for authentication — this only pre-processes the descriptor itself.
45
54
  *
55
+ * A REFUSED OPTION. This is the path that surfaces a plan refusal as this
56
+ * package's error: an option tagged `@planFeature` that the application's plan
57
+ * does not include rejects with a `LocationServiceException` whose
58
+ * `isFeatureNotEntitled` is true (code `FeatureNotEntitledException`, status
59
+ * 403), and whose message names the feature and the option. What MapLibre
60
+ * fetches for itself — a URL from `buildMapStyleUrl` handed to `setStyle`, and
61
+ * the tiles — is refused the same way when it asks for a feature the plan
62
+ * lacks, but the refusal arrives as a MapLibre `error` event instead:
63
+ * `event.error.status` is 403, and `event.error.body` is a `Blob` holding the
64
+ * same `{ message, code }` JSON.
65
+ *
46
66
  * @param apiUrl - Base URL of the Location Service API
47
- * @param mapStyle - Map style name (e.g. 'Standard', 'Monochrome', 'Satellite', 'Hybrid')
67
+ * @param mapStyle - Map style name: 'Standard' or 'Monochrome', or 'Satellite'
68
+ * or 'Hybrid', which need the `satellite` plan feature (see `MAP_STYLES`)
48
69
  * @param getToken - Callback returning the current auth token
49
- * @param options - Style options; `language` is applied to the descriptor, all others become URL params
70
+ * @param options - Style options; `language` is applied to the descriptor, all
71
+ * others become URL params. Those tagged `@planFeature` need that feature of
72
+ * the application's plan
50
73
  * @param request - Transport options: `signal` to cancel, `timeoutMs`, `overallTimeoutMs`, `retry`
51
74
  * @returns Modified MapLibre StyleSpecification object
52
75
  *
@@ -31,6 +31,17 @@ import type { ColorScheme, LabelSize, MapFeatureMode, ScaleBarUnit, StaticMapSty
31
31
  */
32
32
  /** `map`, or `map@2x` for a retina render. There is no file extension. */
33
33
  export type StaticMapFileName = 'map' | 'map@2x';
34
+ /**
35
+ * Render options for `buildStaticMapUrl` and `fetchStaticMap`.
36
+ *
37
+ * The options tagged `@planFeature` are PLAN FEATURES (#55): a Satellite
38
+ * `style` — which is also what an omitted `style` renders — needs `satellite`,
39
+ * and `politicalView` needs `political-view`. An application whose plan does
40
+ * not include one is refused 403 `FeatureNotEntitledException` —
41
+ * `isFeatureNotEntitled` on the error — and the message names the feature and
42
+ * the option. Every other option is open to every plan. Which plan includes
43
+ * which feature: https://chaosity.cloud/pricing.
44
+ */
34
45
  export interface StaticMapOptions {
35
46
  /** Pixels, 64-1500. */
36
47
  width: number;
@@ -46,6 +57,16 @@ export interface StaticMapOptions {
46
57
  radius?: number;
47
58
  padding?: number;
48
59
  cropLabels?: boolean;
60
+ /**
61
+ * `Standard` or `Satellite`. Omitted, the render is Satellite — the
62
+ * service's default — so pass `'Standard'` for a render every plan may
63
+ * request.
64
+ *
65
+ * Satellite is refused on a plan without it: 403
66
+ * `FeatureNotEntitledException` (see `FEATURE_NOT_ENTITLED`).
67
+ *
68
+ * @planFeature satellite — Satellite
69
+ */
49
70
  style?: StaticMapStyle;
50
71
  colorScheme?: ColorScheme;
51
72
  labelSize?: LabelSize;
@@ -58,6 +79,21 @@ export interface StaticMapOptions {
58
79
  scaleBarUnit?: ScaleBarUnit;
59
80
  /** Defaults to `map`. */
60
81
  fileName?: StaticMapFileName;
82
+ /**
83
+ * ISO 3166-1 alpha-3 country whose view of disputed borders to draw.
84
+ *
85
+ * Refused on a plan without it: 403 `FeatureNotEntitledException` (see
86
+ * `FEATURE_NOT_ENTITLED`).
87
+ *
88
+ * @planFeature political-view
89
+ */
90
+ politicalView?: string;
91
+ /** Label language, a BCP-47 tag such as `fr` or `zh-Hant`. */
92
+ language?: string;
93
+ /** Markers and lines in Amazon Location's compact overlay syntax. */
94
+ compactOverlay?: string;
95
+ /** A GeoJSON FeatureCollection to draw, as JSON text. */
96
+ geoJsonOverlay?: string;
61
97
  }
62
98
  /**
63
99
  * The Accept header this request must send.
@@ -72,6 +108,10 @@ export declare function buildStaticMapUrl(apiUrl: string, options: StaticMapOpti
72
108
  /**
73
109
  * Fetch a static map as a Blob.
74
110
  *
111
+ * A refused plan feature — a Satellite `style`, the default when none is
112
+ * given, or a `politicalView` — rejects with a `LocationServiceException`
113
+ * whose `isFeatureNotEntitled` is true, as `fetchMapStyle` does.
114
+ *
75
115
  * @param apiUrl Base URL of the Location Service API
76
116
  * @param options Render options; exactly one of center / boundingBox / boundedPositions
77
117
  * @param getToken Callback returning the current auth token
@@ -48,6 +48,10 @@ export function buildStaticMapUrl(apiUrl, options) {
48
48
  /**
49
49
  * Fetch a static map as a Blob.
50
50
  *
51
+ * A refused plan feature — a Satellite `style`, the default when none is
52
+ * given, or a `politicalView` — rejects with a `LocationServiceException`
53
+ * whose `isFeatureNotEntitled` is true, as `fetchMapStyle` does.
54
+ *
51
55
  * @param apiUrl Base URL of the Location Service API
52
56
  * @param options Render options; exactly one of center / boundingBox / boundedPositions
53
57
  * @param getToken Callback returning the current auth token
@@ -1,3 +1,4 @@
1
+ import type { VerifyAddressResponse } from '../client/commands.js';
1
2
  import type { RequestOptions } from '../transport/http.js';
2
3
  import type { AppConfigClaims } from '../utils/tokenClaims.js';
3
4
  export interface ConnectorConfig {
@@ -56,7 +57,13 @@ export interface SendOptions extends RequestOptions {
56
57
  * ```typescript
57
58
  * // Credentials and apiUrl from the environment, Origin supplied here
58
59
  * const connector = new LocationServiceConnector({ origin: 'https://app.example.com' })
59
- * const result = await connector.send(new SearchTextCommand({ QueryText: 'Space Needle' }))
60
+ * const result = await connector.send(
61
+ * new SearchTextCommand({
62
+ * QueryText: 'Space Needle',
63
+ * // SearchText takes exactly one of BiasPosition, Filter.BoundingBox or Filter.Circle.
64
+ * BiasPosition: [-122.3493, 47.6205],
65
+ * }),
66
+ * )
60
67
  * ```
61
68
  */
62
69
  export declare class LocationServiceConnector {
@@ -77,17 +84,19 @@ export declare class LocationServiceConnector {
77
84
  private buildSource;
78
85
  /**
79
86
  * This application's own configuration, as carried on the access token
80
- * (api#65) — bias precision, and the countries it is scoped to.
87
+ * (api#65): the routes it may call, the domain its requests must come from,
88
+ * and the countries it is scoped to (#40).
81
89
  *
82
90
  * Provided so an application can SHOW its own settings: populate a country
83
91
  * selector with the markets it actually serves, label a settings screen, and
84
92
  * so on. Being a few minutes stale is cosmetic for that.
85
93
  *
86
94
  * It is not an entitlement check. See AppConfigClaims for why acting on
87
- * `countries` client-side makes requests fail that would otherwise succeed.
95
+ * any of it client-side makes requests fail that would otherwise succeed.
88
96
  *
89
- * Returns `{}` when the token carries no application config, which is the
90
- * case until one is configured in the portal.
97
+ * Every token the API issues carries `allowedResources` and `allowedDomain`;
98
+ * `countries` only once a scope is configured in the portal. Returns `{}`
99
+ * for a token carrying none of them.
91
100
  */
92
101
  getAppConfig(): Promise<AppConfigClaims>;
93
102
  /**
@@ -99,6 +108,15 @@ export declare class LocationServiceConnector {
99
108
  */
100
109
  private effectiveOrigin;
101
110
  send<TInput, TOutput>(command: TInput, options?: SendOptions): Promise<TOutput>;
111
+ /**
112
+ * Verify a PlaceId: `send(new VerifyAddressCommand({ PlaceId }))`, typed
113
+ * (#54). Resolves the full place record plus `verified`, and resolves a
114
+ * `verified: false` too — see VerifyAddressResponse for what may be stored.
115
+ *
116
+ * Billed per call, whether or not the address verifies: call it once per
117
+ * chosen PlaceId, never per keystroke.
118
+ */
119
+ verifyAddress(placeId: string, options?: SendOptions): Promise<VerifyAddressResponse>;
102
120
  private dispatchWithRetry;
103
121
  private dispatch;
104
122
  }