@chaosity/location-client 0.9.0 → 0.11.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 (50) hide show
  1. package/README.md +307 -37
  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 +18 -4
  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 +25 -5
  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 +29 -3
  27. package/dist/cjs/utils/tokenClaims.js +28 -3
  28. package/dist/client/GeoPlacesClient.d.ts +16 -4
  29. package/dist/client/GeoPlacesClient.js +18 -4
  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 +25 -5
  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 +29 -3
  49. package/dist/utils/tokenClaims.js +28 -3
  50. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import type { RequestOptions } from '../transport/http.js';
2
2
  import type { ClientConfig } from '../types/index.js';
3
3
  import type { AppConfigClaims } from '../utils/tokenClaims.js';
4
+ import type { VerifyAddressResponse } from './commands.js';
4
5
  export type SendOptions = RequestOptions;
5
6
  /**
6
7
  * GeoPlacesClient — AWS Location Service compatible client with custom auth.
@@ -18,17 +19,19 @@ export declare class GeoPlacesClient {
18
19
  constructor(config: ClientConfig);
19
20
  /**
20
21
  * This application's own configuration, as carried on the access token
21
- * (api#65) — today, the countries it is scoped to.
22
+ * (api#65): the routes it may call, the domain its requests must come from,
23
+ * and the countries it is scoped to (#40).
22
24
  *
23
25
  * Provided so an application can SHOW its own settings: populate a country
24
26
  * selector with the markets it actually serves, label a settings screen,
25
27
  * and so on. Being a few minutes stale is cosmetic for that.
26
28
  *
27
29
  * It is not an entitlement check. See AppConfigClaims for why acting on
28
- * `countries` client-side makes requests fail that would otherwise succeed.
30
+ * any of it client-side makes requests fail that would otherwise succeed.
29
31
  *
30
- * Returns `{}` when the token carries no application config, which is the
31
- * case until one is configured in the portal.
32
+ * Every token the API issues carries `allowedResources` and `allowedDomain`;
33
+ * `countries` only once a scope is configured in the portal. Returns `{}`
34
+ * for a token carrying none of them.
32
35
  */
33
36
  getAppConfig(): AppConfigClaims;
34
37
  /** Prefer the getToken callback (live ref) over a static token string. */
@@ -46,5 +49,14 @@ export declare class GeoPlacesClient {
46
49
  * retry loop. Every failure throws LocationServiceException.
47
50
  */
48
51
  send<TInput, TOutput>(command: TInput, options?: SendOptions): Promise<TOutput>;
52
+ /**
53
+ * Verify a PlaceId: `send(new VerifyAddressCommand({ PlaceId }))`, typed
54
+ * (#54). Resolves the full place record plus `verified`, and resolves a
55
+ * `verified: false` too — see VerifyAddressResponse for what may be stored.
56
+ *
57
+ * Billed per call, whether or not the address verifies: call it once per
58
+ * chosen PlaceId, at submit, never per keystroke.
59
+ */
60
+ verifyAddress(placeId: string, options?: SendOptions): Promise<VerifyAddressResponse>;
49
61
  private dispatch;
50
62
  }
@@ -9,6 +9,7 @@ const endpoints_js_1 = require("../transport/endpoints.js");
9
9
  const errors_js_1 = require("../transport/errors.js");
10
10
  const http_js_1 = require("../transport/http.js");
11
11
  const tokenClaims_js_1 = require("../utils/tokenClaims.js");
12
+ const commands_js_1 = require("./commands.js");
12
13
  const log = (0, debug_1.default)('location-client:api');
13
14
  /**
14
15
  * GeoPlacesClient — AWS Location Service compatible client with custom auth.
@@ -25,17 +26,19 @@ class GeoPlacesClient {
25
26
  }
26
27
  /**
27
28
  * This application's own configuration, as carried on the access token
28
- * (api#65) — today, the countries it is scoped to.
29
+ * (api#65): the routes it may call, the domain its requests must come from,
30
+ * and the countries it is scoped to (#40).
29
31
  *
30
32
  * Provided so an application can SHOW its own settings: populate a country
31
33
  * selector with the markets it actually serves, label a settings screen,
32
34
  * and so on. Being a few minutes stale is cosmetic for that.
33
35
  *
34
36
  * It is not an entitlement check. See AppConfigClaims for why acting on
35
- * `countries` client-side makes requests fail that would otherwise succeed.
37
+ * any of it client-side makes requests fail that would otherwise succeed.
36
38
  *
37
- * Returns `{}` when the token carries no application config, which is the
38
- * case until one is configured in the portal.
39
+ * Every token the API issues carries `allowedResources` and `allowedDomain`;
40
+ * `countries` only once a scope is configured in the portal. Returns `{}`
41
+ * for a token carrying none of them.
39
42
  */
40
43
  getAppConfig() {
41
44
  return (0, tokenClaims_js_1.readAppConfigClaims)(this.currentToken());
@@ -98,6 +101,17 @@ class GeoPlacesClient {
98
101
  return await this.dispatch(url, fresh, cmd, options);
99
102
  }
100
103
  }
104
+ /**
105
+ * Verify a PlaceId: `send(new VerifyAddressCommand({ PlaceId }))`, typed
106
+ * (#54). Resolves the full place record plus `verified`, and resolves a
107
+ * `verified: false` too — see VerifyAddressResponse for what may be stored.
108
+ *
109
+ * Billed per call, whether or not the address verifies: call it once per
110
+ * chosen PlaceId, at submit, never per keystroke.
111
+ */
112
+ verifyAddress(placeId, options) {
113
+ return this.send(new commands_js_1.VerifyAddressCommand({ PlaceId: placeId }), options);
114
+ }
101
115
  dispatch(url, token, cmd, options) {
102
116
  // The caller's input goes out as the caller wrote it. `BiasPosition` used
103
117
  // to be rounded here to a grid sized by a token claim, so nearby callers
@@ -0,0 +1,159 @@
1
+ import type { GetPlaceResponse, AutocompleteCommandInput as SdkAutocompleteCommandInput, AutocompleteRequest as SdkAutocompleteRequest, GeocodeCommandInput as SdkGeocodeCommandInput, GeocodeRequest as SdkGeocodeRequest, GetPlaceCommandInput as SdkGetPlaceCommandInput, GetPlaceRequest as SdkGetPlaceRequest, ReverseGeocodeCommandInput as SdkReverseGeocodeCommandInput, ReverseGeocodeRequest as SdkReverseGeocodeRequest, SearchNearbyCommandInput as SdkSearchNearbyCommandInput, SearchNearbyRequest as SdkSearchNearbyRequest, SearchTextCommandInput as SdkSearchTextCommandInput, SearchTextRequest as SdkSearchTextRequest, SuggestCommandInput as SdkSuggestCommandInput, SuggestRequest as SdkSuggestRequest } from '@aws-sdk/client-geo-places';
2
+ import { AutocompleteCommand as SdkAutocompleteCommand, GeocodeCommand as SdkGeocodeCommand, GetPlaceCommand as SdkGetPlaceCommand, ReverseGeocodeCommand as SdkReverseGeocodeCommand, SearchNearbyCommand as SdkSearchNearbyCommand, SearchTextCommand as SdkSearchTextCommand, SuggestCommand as SdkSuggestCommand } from '@aws-sdk/client-geo-places';
3
+ /**
4
+ * Request fields the Location Service removes from every request (#40).
5
+ *
6
+ * `IntendedUse` chooses the price bucket the service pays, and `Key` is an
7
+ * Amazon Location API key that would bill someone else's account, so neither
8
+ * ever reaches Amazon. The SDK's inputs declare both, and this package used to
9
+ * re-export those commands as they were: `IntendedUse: 'Storage'` compiled,
10
+ * was sent, was stripped, and came back as a result with no storage rights.
11
+ *
12
+ * So the root exports every Places command as a subclass whose constructor
13
+ * takes the input WITHOUT these fields. Narrowing only the input types would
14
+ * not have been enough — the SDK's constructor references the SDK's own type,
15
+ * so `new SearchTextCommand({ IntendedUse })` would still have compiled.
16
+ *
17
+ * Types only. Nothing is removed at runtime: a request body is the caller's
18
+ * input, unchanged, and the service does the stripping. A caller who casts
19
+ * past the type still sends the field and still has it ignored.
20
+ *
21
+ * `test/places-commands.test.ts` reads the command list from the SDK itself,
22
+ * so a command the SDK adds fails there until it is narrowed here.
23
+ */
24
+ export type NeverForwarded = 'IntendedUse' | 'Key';
25
+ export type AutocompleteRequest = Omit<SdkAutocompleteRequest, NeverForwarded>;
26
+ export type AutocompleteCommandInput = Omit<SdkAutocompleteCommandInput, NeverForwarded>;
27
+ export declare class AutocompleteCommand extends SdkAutocompleteCommand {
28
+ constructor(input: AutocompleteCommandInput);
29
+ }
30
+ export type GeocodeRequest = Omit<SdkGeocodeRequest, NeverForwarded>;
31
+ export type GeocodeCommandInput = Omit<SdkGeocodeCommandInput, NeverForwarded>;
32
+ /**
33
+ * Accepts rich place data, a plan feature: on a plan without it these
34
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
35
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
36
+ *
37
+ * @planFeature rich place data — Access, TimeZone
38
+ */
39
+ export declare class GeocodeCommand extends SdkGeocodeCommand {
40
+ constructor(input: GeocodeCommandInput);
41
+ }
42
+ export type GetPlaceRequest = Omit<SdkGetPlaceRequest, NeverForwarded>;
43
+ export type GetPlaceCommandInput = Omit<SdkGetPlaceCommandInput, NeverForwarded>;
44
+ /**
45
+ * Accepts rich place data, a plan feature: on a plan without it these
46
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
47
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
48
+ *
49
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
50
+ */
51
+ export declare class GetPlaceCommand extends SdkGetPlaceCommand {
52
+ constructor(input: GetPlaceCommandInput);
53
+ }
54
+ export type ReverseGeocodeRequest = Omit<SdkReverseGeocodeRequest, NeverForwarded>;
55
+ export type ReverseGeocodeCommandInput = Omit<SdkReverseGeocodeCommandInput, NeverForwarded>;
56
+ /**
57
+ * Accepts rich place data, a plan feature: on a plan without it these
58
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
59
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
60
+ *
61
+ * @planFeature rich place data — Access, TimeZone
62
+ */
63
+ export declare class ReverseGeocodeCommand extends SdkReverseGeocodeCommand {
64
+ constructor(input: ReverseGeocodeCommandInput);
65
+ }
66
+ export type SearchNearbyRequest = Omit<SdkSearchNearbyRequest, NeverForwarded>;
67
+ export type SearchNearbyCommandInput = Omit<SdkSearchNearbyCommandInput, NeverForwarded>;
68
+ /**
69
+ * Accepts rich place data, a plan feature: on a plan without it these
70
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
71
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
72
+ *
73
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
74
+ */
75
+ export declare class SearchNearbyCommand extends SdkSearchNearbyCommand {
76
+ constructor(input: SearchNearbyCommandInput);
77
+ }
78
+ export type SearchTextRequest = Omit<SdkSearchTextRequest, NeverForwarded>;
79
+ export type SearchTextCommandInput = Omit<SdkSearchTextCommandInput, NeverForwarded>;
80
+ /**
81
+ * Accepts rich place data, a plan feature: on a plan without it these
82
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
83
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
84
+ *
85
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
86
+ */
87
+ export declare class SearchTextCommand extends SdkSearchTextCommand {
88
+ constructor(input: SearchTextCommandInput);
89
+ }
90
+ export type SuggestRequest = Omit<SdkSuggestRequest, NeverForwarded>;
91
+ export type SuggestCommandInput = Omit<SdkSuggestCommandInput, NeverForwarded>;
92
+ /**
93
+ * Accepts rich place data, a plan feature: on a plan without it these
94
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
95
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
96
+ *
97
+ * @planFeature rich place data — Access, Phonemes, TimeZone
98
+ */
99
+ export declare class SuggestCommand extends SdkSuggestCommand {
100
+ constructor(input: SuggestCommandInput);
101
+ }
102
+ /**
103
+ * A PlaceId, and nothing else: the service forwards `PlaceId` alone to this
104
+ * route, so `Language`, `PoliticalView` and `AdditionalFeatures` would be
105
+ * dropped rather than honoured. The type refuses them instead (#54).
106
+ */
107
+ export interface VerifyAddressCommandInput {
108
+ /**
109
+ * From an autocomplete, suggestion, geocode or place result — including a
110
+ * unit's, from a place's `SecondaryAddresses`.
111
+ */
112
+ PlaceId: string;
113
+ }
114
+ /**
115
+ * The answer to a verify: the record `GetPlaceCommand` returns — the
116
+ * building's units in `SecondaryAddresses` included, `$metadata` not — plus
117
+ * `verified`.
118
+ *
119
+ * `verified` is true for a `PointAddress`, or a `SecondaryAddress` (a unit),
120
+ * and false for anything else: an interpolated address, a street, a locality,
121
+ * a point of interest. A `false` is still a 200 and still billed, so it
122
+ * resolves; it never throws.
123
+ *
124
+ * This is the one Places result an integrator may store, except a place in
125
+ * Japan, which may not be stored at all. Every other Places result is for
126
+ * display.
127
+ *
128
+ * Keep the PlaceId you sent beside it. The answer's own `PlaceId` can differ,
129
+ * and for a unit it does: the service fails that one on every Places route,
130
+ * while the one you sent verifies again.
131
+ */
132
+ export type VerifyAddressResponse = Omit<GetPlaceResponse, 'PricingBucket'> & {
133
+ /**
134
+ * The bucket the stored record belongs to (`Stored`), not what this call
135
+ * was billed at. Every verify is billed on its own meter, whether the
136
+ * service answered it from its store or not.
137
+ */
138
+ PricingBucket: string | undefined;
139
+ /** `PointAddress` or `SecondaryAddress`: the address is verified. */
140
+ verified: boolean;
141
+ };
142
+ /**
143
+ * `POST /address/verify` (#54): resolve one PlaceId to the full place record
144
+ * plus `verified`. `GeoPlacesClient.verifyAddress` and
145
+ * `LocationServiceConnector.verifyAddress` send this.
146
+ *
147
+ * Billed per call, whether or not the address verifies. Send it once per
148
+ * chosen PlaceId — at submit — never per keystroke. A repeat verify of the
149
+ * same PlaceId may be answered from the service's own store, and is billed
150
+ * all the same.
151
+ *
152
+ * Not an SDK command: the route has none. It extends nothing on purpose —
153
+ * `ENDPOINTS` matches by `instanceof`, so a subclass of `GetPlaceCommand`
154
+ * would match that entry and go to `/address/place`.
155
+ */
156
+ export declare class VerifyAddressCommand {
157
+ readonly input: VerifyAddressCommandInput;
158
+ constructor(input: VerifyAddressCommandInput);
159
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerifyAddressCommand = exports.SuggestCommand = exports.SearchTextCommand = exports.SearchNearbyCommand = exports.ReverseGeocodeCommand = exports.GetPlaceCommand = exports.GeocodeCommand = exports.AutocompleteCommand = void 0;
4
+ const client_geo_places_1 = require("@aws-sdk/client-geo-places");
5
+ class AutocompleteCommand extends client_geo_places_1.AutocompleteCommand {
6
+ constructor(input) {
7
+ super(input);
8
+ }
9
+ }
10
+ exports.AutocompleteCommand = AutocompleteCommand;
11
+ /**
12
+ * Accepts rich place data, a plan feature: on a plan without it these
13
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
14
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
15
+ *
16
+ * @planFeature rich place data — Access, TimeZone
17
+ */
18
+ class GeocodeCommand extends client_geo_places_1.GeocodeCommand {
19
+ constructor(input) {
20
+ super(input);
21
+ }
22
+ }
23
+ exports.GeocodeCommand = GeocodeCommand;
24
+ /**
25
+ * Accepts rich place data, a plan feature: on a plan without it these
26
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
27
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
28
+ *
29
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
30
+ */
31
+ class GetPlaceCommand extends client_geo_places_1.GetPlaceCommand {
32
+ constructor(input) {
33
+ super(input);
34
+ }
35
+ }
36
+ exports.GetPlaceCommand = GetPlaceCommand;
37
+ /**
38
+ * Accepts rich place data, a plan feature: on a plan without it these
39
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
40
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
41
+ *
42
+ * @planFeature rich place data — Access, TimeZone
43
+ */
44
+ class ReverseGeocodeCommand extends client_geo_places_1.ReverseGeocodeCommand {
45
+ constructor(input) {
46
+ super(input);
47
+ }
48
+ }
49
+ exports.ReverseGeocodeCommand = ReverseGeocodeCommand;
50
+ /**
51
+ * Accepts rich place data, a plan feature: on a plan without it these
52
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
53
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
54
+ *
55
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
56
+ */
57
+ class SearchNearbyCommand extends client_geo_places_1.SearchNearbyCommand {
58
+ constructor(input) {
59
+ super(input);
60
+ }
61
+ }
62
+ exports.SearchNearbyCommand = SearchNearbyCommand;
63
+ /**
64
+ * Accepts rich place data, a plan feature: on a plan without it these
65
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
66
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
67
+ *
68
+ * @planFeature rich place data — Access, Contact, Phonemes, TimeZone
69
+ */
70
+ class SearchTextCommand extends client_geo_places_1.SearchTextCommand {
71
+ constructor(input) {
72
+ super(input);
73
+ }
74
+ }
75
+ exports.SearchTextCommand = SearchTextCommand;
76
+ /**
77
+ * Accepts rich place data, a plan feature: on a plan without it these
78
+ * `AdditionalFeatures` are refused 403 `FeatureNotEntitledException`
79
+ * (`isFeatureNotEntitled` on the error; see `FEATURE_NOT_ENTITLED`).
80
+ *
81
+ * @planFeature rich place data — Access, Phonemes, TimeZone
82
+ */
83
+ class SuggestCommand extends client_geo_places_1.SuggestCommand {
84
+ constructor(input) {
85
+ super(input);
86
+ }
87
+ }
88
+ exports.SuggestCommand = SuggestCommand;
89
+ /**
90
+ * `POST /address/verify` (#54): resolve one PlaceId to the full place record
91
+ * plus `verified`. `GeoPlacesClient.verifyAddress` and
92
+ * `LocationServiceConnector.verifyAddress` send this.
93
+ *
94
+ * Billed per call, whether or not the address verifies. Send it once per
95
+ * chosen PlaceId — at submit — never per keystroke. A repeat verify of the
96
+ * same PlaceId may be answered from the service's own store, and is billed
97
+ * all the same.
98
+ *
99
+ * Not an SDK command: the route has none. It extends nothing on purpose —
100
+ * `ENDPOINTS` matches by `instanceof`, so a subclass of `GetPlaceCommand`
101
+ * would match that entry and go to `/address/place`.
102
+ */
103
+ class VerifyAddressCommand {
104
+ constructor(input) {
105
+ this.input = input;
106
+ }
107
+ }
108
+ exports.VerifyAddressCommand = VerifyAddressCommand;
@@ -1,3 +1,17 @@
1
+ /**
2
+ * The code of a 403 for an option the application's plan does not include
3
+ * (#55): a map feature such as `satellite` or `terrain`, or rich place data.
4
+ * The options that can earn it are tagged `@planFeature` in their
5
+ * documentation.
6
+ *
7
+ * The service refuses before calling upstream, so the refusal is not billed,
8
+ * and its message names each refused feature and the option that asked for
9
+ * it. It never names a plan: which plan includes which feature can change
10
+ * without a release of this package — see https://chaosity.cloud/pricing.
11
+ * Nothing in the token lists the features either, so this 403 is the first a
12
+ * caller hears of it; there is no check to make beforehand.
13
+ */
14
+ export declare const FEATURE_NOT_ENTITLED = "FeatureNotEntitledException";
1
15
  export interface LocationServiceExceptionOptions {
2
16
  message: string;
3
17
  code: string;
@@ -36,8 +50,21 @@ export declare class LocationServiceException extends Error {
36
50
  get isRetryable(): boolean;
37
51
  get isThrottling(): boolean;
38
52
  get isValidation(): boolean;
39
- /** Credentials or entitlements — the caller must act, retrying will not help. */
53
+ /**
54
+ * Any 401 or 403 — the caller must act, and retrying will not help.
55
+ *
56
+ * That is several failures with different remedies: bad or expired
57
+ * credentials, an `Origin` the application does not allow, a route its plan
58
+ * does not include, an option its plan does not include. Branch on `code`,
59
+ * or on `isFeatureNotEntitled` for the last, to tell them apart.
60
+ */
40
61
  get isAuth(): boolean;
62
+ /**
63
+ * The application's plan does not include an option this request asked for
64
+ * (`FEATURE_NOT_ENTITLED`). The message names the feature; drop the option,
65
+ * or move the application to a plan that includes it.
66
+ */
67
+ get isFeatureNotEntitled(): boolean;
41
68
  get isAborted(): boolean;
42
69
  get isTimeout(): boolean;
43
70
  toString(): string;
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocationServiceException = void 0;
3
+ exports.LocationServiceException = exports.FEATURE_NOT_ENTITLED = void 0;
4
+ /**
5
+ * The code of a 403 for an option the application's plan does not include
6
+ * (#55): a map feature such as `satellite` or `terrain`, or rich place data.
7
+ * The options that can earn it are tagged `@planFeature` in their
8
+ * documentation.
9
+ *
10
+ * The service refuses before calling upstream, so the refusal is not billed,
11
+ * and its message names each refused feature and the option that asked for
12
+ * it. It never names a plan: which plan includes which feature can change
13
+ * without a release of this package — see https://chaosity.cloud/pricing.
14
+ * Nothing in the token lists the features either, so this 403 is the first a
15
+ * caller hears of it; there is no check to make beforehand.
16
+ */
17
+ exports.FEATURE_NOT_ENTITLED = 'FeatureNotEntitledException';
4
18
  /**
5
19
  * The single error type this package throws.
6
20
  *
@@ -40,10 +54,25 @@ class LocationServiceException extends Error {
40
54
  get isValidation() {
41
55
  return this.code === 'ValidationException' || this.statusCode === 400;
42
56
  }
43
- /** Credentials or entitlements — the caller must act, retrying will not help. */
57
+ /**
58
+ * Any 401 or 403 — the caller must act, and retrying will not help.
59
+ *
60
+ * That is several failures with different remedies: bad or expired
61
+ * credentials, an `Origin` the application does not allow, a route its plan
62
+ * does not include, an option its plan does not include. Branch on `code`,
63
+ * or on `isFeatureNotEntitled` for the last, to tell them apart.
64
+ */
44
65
  get isAuth() {
45
66
  return this.statusCode === 401 || this.statusCode === 403;
46
67
  }
68
+ /**
69
+ * The application's plan does not include an option this request asked for
70
+ * (`FEATURE_NOT_ENTITLED`). The message names the feature; drop the option,
71
+ * or move the application to a plan that includes it.
72
+ */
73
+ get isFeatureNotEntitled() {
74
+ return this.code === exports.FEATURE_NOT_ENTITLED;
75
+ }
47
76
  get isAborted() {
48
77
  return this.code === 'AbortedException';
49
78
  }
@@ -3,9 +3,11 @@ export type { SendOptions } from './client/GeoPlacesClient.js';
3
3
  export { DEFAULT_MAX_ATTEMPTS, DEFAULT_OVERALL_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, } from './transport/http.js';
4
4
  export type { RequestOptions } from './transport/http.js';
5
5
  export { TOKEN_REFRESH_BUFFER_SECONDS, readTokenExpiry, } from './auth/tokenRefresh.js';
6
- export { LocationServiceException } from './errors/LocationServiceException.js';
6
+ export { FEATURE_NOT_ENTITLED, LocationServiceException, } from './errors/LocationServiceException.js';
7
7
  export type { LocationServiceExceptionOptions } from './errors/LocationServiceException.js';
8
8
  export * from '@aws-sdk/client-geo-places';
9
+ export { AutocompleteCommand, GeocodeCommand, GetPlaceCommand, ReverseGeocodeCommand, SearchNearbyCommand, SearchTextCommand, SuggestCommand, VerifyAddressCommand, } from './client/commands.js';
10
+ export type { AutocompleteCommandInput, AutocompleteRequest, GeocodeCommandInput, GeocodeRequest, GetPlaceCommandInput, GetPlaceRequest, NeverForwarded, ReverseGeocodeCommandInput, ReverseGeocodeRequest, SearchNearbyCommandInput, SearchNearbyRequest, SearchTextCommandInput, SearchTextRequest, SuggestCommandInput, SuggestRequest, VerifyAddressCommandInput, VerifyAddressResponse, } from './client/commands.js';
9
11
  export * from '@aws/amazon-location-utilities-datatypes';
10
12
  export { GeoPlaces } from './adapters/GeoPlaces.js';
11
13
  export type { GeoPlacesDetailOptions, GeoPlacesOptions, } from './adapters/GeoPlaces.js';
@@ -17,8 +19,8 @@ export { buildMapStyleUrl, fetchMapStyle } from './maps/mapStyle.js';
17
19
  export type { MapStyleOptions } from './maps/mapStyle.js';
18
20
  export { buildStaticMapUrl, fetchStaticMap, staticMapAccept, } from './maps/staticMap.js';
19
21
  export type { StaticMapFileName, StaticMapOptions } from './maps/staticMap.js';
20
- 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';
21
- export type { Buildings, ColorScheme, ContourDensity, LabelSize, MapFeatureMode, MapStyle, ScaleBarUnit, SpriteVariant, StaticMapStyle, Terrain, TrafficMode, TravelMode, } from './maps/mapEnums.js';
22
+ 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';
23
+ export type { Buildings, ColorScheme, ContourDensity, LabelSize, MapFeatureMode, MapStyle, PoiDensity, ScaleBarUnit, SpriteVariant, StaticMapStyle, StylePoiCategory, Terrain, TrafficMode, TravelMode, } from './maps/mapEnums.js';
22
24
  export { transformRequest } from './maps/Utils.js';
23
25
  export type { ClientConfig, GeoPlacesCommand, MapLike } from './types/index.js';
24
26
  export type { AppConfigClaims } from './utils/tokenClaims.js';
package/dist/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.transformRequest = exports.TRAVEL_MODES = exports.TRAFFIC_MODES = exports.TERRAINS = exports.STATIC_MAP_STYLES = exports.SPRITE_VARIANTS = exports.SCALE_BAR_UNITS = exports.MAP_STYLES = exports.MAP_FEATURE_MODES = exports.LABEL_SIZES = exports.CONTOUR_DENSITIES = exports.COLOR_SCHEMES = exports.BUILDINGS = exports.staticMapAccept = exports.fetchStaticMap = exports.buildStaticMapUrl = exports.fetchMapStyle = exports.buildMapStyleUrl = exports.setPoiVisibility = exports.setAllPoiVisibility = exports.POI_CATEGORIES = exports.applyMapLanguage = exports.createTransformRequest = exports.GeoPlaces = exports.LocationServiceException = exports.readTokenExpiry = exports.TOKEN_REFRESH_BUFFER_SECONDS = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_OVERALL_TIMEOUT_MS = exports.DEFAULT_MAX_ATTEMPTS = exports.GeoPlacesClient = void 0;
17
+ exports.transformRequest = exports.TRAVEL_MODES = exports.TRAFFIC_MODES = exports.TERRAINS = exports.STYLE_POI_CATEGORIES = exports.STATIC_MAP_STYLES = exports.SPRITE_VARIANTS = exports.SCALE_BAR_UNITS = exports.POI_DENSITIES = exports.MAP_STYLES = exports.MAP_FEATURE_MODES = exports.LABEL_SIZES = exports.CONTOUR_DENSITIES = exports.COLOR_SCHEMES = exports.BUILDINGS = exports.staticMapAccept = exports.fetchStaticMap = exports.buildStaticMapUrl = exports.fetchMapStyle = exports.buildMapStyleUrl = exports.setPoiVisibility = exports.setAllPoiVisibility = exports.POI_CATEGORIES = exports.applyMapLanguage = exports.createTransformRequest = exports.GeoPlaces = exports.VerifyAddressCommand = exports.SuggestCommand = exports.SearchTextCommand = exports.SearchNearbyCommand = exports.ReverseGeocodeCommand = exports.GetPlaceCommand = exports.GeocodeCommand = exports.AutocompleteCommand = exports.LocationServiceException = exports.FEATURE_NOT_ENTITLED = exports.readTokenExpiry = exports.TOKEN_REFRESH_BUFFER_SECONDS = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_OVERALL_TIMEOUT_MS = exports.DEFAULT_MAX_ATTEMPTS = exports.GeoPlacesClient = void 0;
18
18
  // Client (Custom - uses our auth instead of AWS SigV4)
19
19
  var GeoPlacesClient_js_1 = require("./client/GeoPlacesClient.js");
20
20
  Object.defineProperty(exports, "GeoPlacesClient", { enumerable: true, get: function () { return GeoPlacesClient_js_1.GeoPlacesClient; } });
@@ -29,9 +29,23 @@ Object.defineProperty(exports, "TOKEN_REFRESH_BUFFER_SECONDS", { enumerable: tru
29
29
  Object.defineProperty(exports, "readTokenExpiry", { enumerable: true, get: function () { return tokenRefresh_js_1.readTokenExpiry; } });
30
30
  // Errors
31
31
  var LocationServiceException_js_1 = require("./errors/LocationServiceException.js");
32
+ Object.defineProperty(exports, "FEATURE_NOT_ENTITLED", { enumerable: true, get: function () { return LocationServiceException_js_1.FEATURE_NOT_ENTITLED; } });
32
33
  Object.defineProperty(exports, "LocationServiceException", { enumerable: true, get: function () { return LocationServiceException_js_1.LocationServiceException; } });
33
34
  // Re-export AWS SDK commands and types
34
35
  __exportStar(require("@aws-sdk/client-geo-places"), exports);
36
+ // …except the seven Places commands and their inputs, which take neither
37
+ // IntendedUse nor Key: the service strips both from every request (#40). A
38
+ // named export wins over the `export *` above, as GeoPlacesClient's does.
39
+ // VerifyAddressCommand is this package's own: its route has no SDK command (#54).
40
+ var commands_js_1 = require("./client/commands.js");
41
+ Object.defineProperty(exports, "AutocompleteCommand", { enumerable: true, get: function () { return commands_js_1.AutocompleteCommand; } });
42
+ Object.defineProperty(exports, "GeocodeCommand", { enumerable: true, get: function () { return commands_js_1.GeocodeCommand; } });
43
+ Object.defineProperty(exports, "GetPlaceCommand", { enumerable: true, get: function () { return commands_js_1.GetPlaceCommand; } });
44
+ Object.defineProperty(exports, "ReverseGeocodeCommand", { enumerable: true, get: function () { return commands_js_1.ReverseGeocodeCommand; } });
45
+ Object.defineProperty(exports, "SearchNearbyCommand", { enumerable: true, get: function () { return commands_js_1.SearchNearbyCommand; } });
46
+ Object.defineProperty(exports, "SearchTextCommand", { enumerable: true, get: function () { return commands_js_1.SearchTextCommand; } });
47
+ Object.defineProperty(exports, "SuggestCommand", { enumerable: true, get: function () { return commands_js_1.SuggestCommand; } });
48
+ Object.defineProperty(exports, "VerifyAddressCommand", { enumerable: true, get: function () { return commands_js_1.VerifyAddressCommand; } });
35
49
  // Re-export AWS Location Utilities (data type conversions)
36
50
  __exportStar(require("@aws/amazon-location-utilities-datatypes"), exports);
37
51
  // Adapters (Custom - for MapLibre integration)
@@ -62,9 +76,11 @@ Object.defineProperty(exports, "CONTOUR_DENSITIES", { enumerable: true, get: fun
62
76
  Object.defineProperty(exports, "LABEL_SIZES", { enumerable: true, get: function () { return mapEnums_js_1.LABEL_SIZES; } });
63
77
  Object.defineProperty(exports, "MAP_FEATURE_MODES", { enumerable: true, get: function () { return mapEnums_js_1.MAP_FEATURE_MODES; } });
64
78
  Object.defineProperty(exports, "MAP_STYLES", { enumerable: true, get: function () { return mapEnums_js_1.MAP_STYLES; } });
79
+ Object.defineProperty(exports, "POI_DENSITIES", { enumerable: true, get: function () { return mapEnums_js_1.POI_DENSITIES; } });
65
80
  Object.defineProperty(exports, "SCALE_BAR_UNITS", { enumerable: true, get: function () { return mapEnums_js_1.SCALE_BAR_UNITS; } });
66
81
  Object.defineProperty(exports, "SPRITE_VARIANTS", { enumerable: true, get: function () { return mapEnums_js_1.SPRITE_VARIANTS; } });
67
82
  Object.defineProperty(exports, "STATIC_MAP_STYLES", { enumerable: true, get: function () { return mapEnums_js_1.STATIC_MAP_STYLES; } });
83
+ Object.defineProperty(exports, "STYLE_POI_CATEGORIES", { enumerable: true, get: function () { return mapEnums_js_1.STYLE_POI_CATEGORIES; } });
68
84
  Object.defineProperty(exports, "TERRAINS", { enumerable: true, get: function () { return mapEnums_js_1.TERRAINS; } });
69
85
  Object.defineProperty(exports, "TRAFFIC_MODES", { enumerable: true, get: function () { return mapEnums_js_1.TRAFFIC_MODES; } });
70
86
  Object.defineProperty(exports, "TRAVEL_MODES", { enumerable: true, get: function () { return mapEnums_js_1.TRAVEL_MODES; } });
@@ -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];