@chaosity/location-client 0.5.0 → 0.6.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 +14 -0
- package/dist/adapters/GeoPlaces.d.ts +1 -1
- package/dist/auth/TokenProvider.js +3 -3
- package/dist/cjs/adapters/GeoPlaces.d.ts +64 -0
- package/dist/cjs/adapters/GeoPlaces.js +213 -0
- package/dist/cjs/auth/TokenProvider.d.ts +64 -0
- package/dist/cjs/auth/TokenProvider.js +144 -0
- package/dist/cjs/auth/tokenRefresh.d.ts +37 -0
- package/dist/cjs/auth/tokenRefresh.js +58 -0
- package/dist/cjs/client/GeoPlacesClient.d.ts +39 -0
- package/dist/cjs/client/GeoPlacesClient.js +68 -0
- package/dist/cjs/errors/LocationServiceException.d.ts +44 -0
- package/dist/cjs/errors/LocationServiceException.js +60 -0
- package/dist/cjs/index.d.ts +24 -0
- package/dist/cjs/index.js +72 -0
- package/dist/cjs/maps/Utils.d.ts +2 -0
- package/dist/cjs/maps/Utils.js +8 -0
- package/dist/cjs/maps/createTransformRequest.d.ts +10 -0
- package/dist/cjs/maps/createTransformRequest.js +43 -0
- package/dist/cjs/maps/mapEnums.d.ts +102 -0
- package/dist/cjs/maps/mapEnums.js +103 -0
- package/dist/cjs/maps/mapLanguage.d.ts +43 -0
- package/dist/cjs/maps/mapLanguage.js +75 -0
- package/dist/cjs/maps/mapPoi.d.ts +44 -0
- package/dist/cjs/maps/mapPoi.js +64 -0
- package/dist/cjs/maps/mapStyle.d.ts +77 -0
- package/dist/cjs/maps/mapStyle.js +111 -0
- package/dist/cjs/maps/staticMap.d.ts +85 -0
- package/dist/cjs/maps/staticMap.js +81 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/server/LocationServiceConnector.d.ts +55 -0
- package/dist/cjs/server/LocationServiceConnector.js +91 -0
- package/dist/cjs/server/getClientConfig.d.ts +40 -0
- package/dist/cjs/server/getClientConfig.js +130 -0
- package/dist/cjs/server/index.d.ts +6 -0
- package/dist/cjs/server/index.js +9 -0
- package/dist/cjs/transport/endpoints.d.ts +2 -0
- package/dist/cjs/transport/endpoints.js +34 -0
- package/dist/cjs/transport/errors.d.ts +19 -0
- package/dist/cjs/transport/errors.js +104 -0
- package/dist/cjs/transport/http.d.ts +24 -0
- package/dist/cjs/transport/http.js +142 -0
- package/dist/cjs/types/index.d.ts +34 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/utils/roundPosition.d.ts +66 -0
- package/dist/cjs/utils/roundPosition.js +109 -0
- package/dist/cjs/utils/tokenClaims.d.ts +55 -0
- package/dist/cjs/utils/tokenClaims.js +61 -0
- package/dist/client/GeoPlacesClient.d.ts +3 -3
- package/dist/client/GeoPlacesClient.js +4 -4
- package/dist/index.d.ts +22 -22
- package/dist/index.js +12 -12
- package/dist/maps/Utils.d.ts +1 -1
- package/dist/maps/Utils.js +1 -1
- package/dist/maps/createTransformRequest.js +1 -1
- package/dist/maps/mapLanguage.d.ts +31 -7
- package/dist/maps/mapLanguage.js +50 -20
- package/dist/maps/mapStyle.d.ts +1 -1
- package/dist/maps/mapStyle.js +17 -16
- package/dist/maps/staticMap.d.ts +1 -1
- package/dist/maps/staticMap.js +12 -4
- package/dist/server/LocationServiceConnector.d.ts +2 -2
- package/dist/server/LocationServiceConnector.js +6 -6
- package/dist/server/getClientConfig.d.ts +1 -1
- package/dist/server/getClientConfig.js +2 -2
- package/dist/server/index.d.ts +6 -6
- package/dist/server/index.js +3 -3
- package/dist/transport/endpoints.d.ts +1 -1
- package/dist/transport/endpoints.js +1 -1
- package/dist/transport/errors.d.ts +1 -1
- package/dist/transport/errors.js +1 -1
- package/dist/transport/http.js +2 -2
- package/package.json +33 -11
package/dist/maps/staticMap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseErrorResponse } from '../transport/errors';
|
|
1
|
+
import { parseErrorResponse } from '../transport/errors.js';
|
|
2
2
|
/**
|
|
3
3
|
* The Accept header this request must send.
|
|
4
4
|
*
|
|
@@ -9,6 +9,8 @@ import { parseErrorResponse } from '../transport/errors';
|
|
|
9
9
|
export function staticMapAccept(style) {
|
|
10
10
|
return style === 'Standard' ? 'image/png' : 'image/jpeg';
|
|
11
11
|
}
|
|
12
|
+
/** A coordinate as the API accepts it: at most six decimals, no float noise. */
|
|
13
|
+
const coord = (n) => String(Number(n.toFixed(6)));
|
|
12
14
|
/** Build the request URL without fetching it. */
|
|
13
15
|
export function buildStaticMapUrl(apiUrl, options) {
|
|
14
16
|
const { width, height, center, boundingBox, boundedPositions, fileName = 'map', ...rest } = options;
|
|
@@ -19,12 +21,18 @@ export function buildStaticMapUrl(apiUrl, options) {
|
|
|
19
21
|
// Positions go over the wire as comma-separated numbers. api#35 records that
|
|
20
22
|
// passing arrays straight through worked only by accidental stringification;
|
|
21
23
|
// doing it explicitly here means the shape is ours, not JavaScript's default.
|
|
24
|
+
//
|
|
25
|
+
// Each number is rounded to six decimals (#29). The API caps a coordinate at
|
|
26
|
+
// fourteen decimals, and a value straight from `map.getCenter()` routinely
|
|
27
|
+
// has fifteen or sixteen — so the obvious "render what the user is looking
|
|
28
|
+
// at" was a 400 blaming the FORMAT. Six decimals is ~10 cm, more than a
|
|
29
|
+
// raster render can show.
|
|
22
30
|
if (center)
|
|
23
|
-
params.set('center', center.join(','));
|
|
31
|
+
params.set('center', center.map(coord).join(','));
|
|
24
32
|
if (boundingBox)
|
|
25
|
-
params.set('bounding-box', boundingBox.join(','));
|
|
33
|
+
params.set('bounding-box', boundingBox.map(coord).join(','));
|
|
26
34
|
if (boundedPositions) {
|
|
27
|
-
params.set('bounded-positions', boundedPositions.flat().join(','));
|
|
35
|
+
params.set('bounded-positions', boundedPositions.flat().map(coord).join(','));
|
|
28
36
|
}
|
|
29
37
|
// The API accepts kebab-case on the wire and camelCase for older callers;
|
|
30
38
|
// kebab is the documented form, so emit that.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RequestOptions } from '../transport/http';
|
|
2
|
-
import type { AppConfigClaims } from '../utils/tokenClaims';
|
|
1
|
+
import type { RequestOptions } from '../transport/http.js';
|
|
2
|
+
import type { AppConfigClaims } from '../utils/tokenClaims.js';
|
|
3
3
|
export interface ConnectorConfig {
|
|
4
4
|
apiUrl?: string;
|
|
5
5
|
token?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
-
import { LocationServiceException } from '../errors/LocationServiceException';
|
|
3
|
-
import { resolveEndpoint } from '../transport/endpoints';
|
|
4
|
-
import { requestJson } from '../transport/http';
|
|
5
|
-
import { roundPositionFields } from '../utils/roundPosition';
|
|
6
|
-
import { readAppConfigClaims } from '../utils/tokenClaims';
|
|
7
|
-
import { getClientConfig } from './getClientConfig';
|
|
2
|
+
import { LocationServiceException } from '../errors/LocationServiceException.js';
|
|
3
|
+
import { resolveEndpoint } from '../transport/endpoints.js';
|
|
4
|
+
import { requestJson } from '../transport/http.js';
|
|
5
|
+
import { roundPositionFields } from '../utils/roundPosition.js';
|
|
6
|
+
import { readAppConfigClaims } from '../utils/tokenClaims.js';
|
|
7
|
+
import { getClientConfig } from './getClientConfig.js';
|
|
8
8
|
const log = debug('location-client:connector');
|
|
9
9
|
/**
|
|
10
10
|
* LocationServiceConnector — server-side connector for the Location Service API.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import { TokenProvider } from '../auth/TokenProvider';
|
|
4
|
-
import { LocationServiceException } from '../errors/LocationServiceException';
|
|
3
|
+
import { TokenProvider } from '../auth/TokenProvider.js';
|
|
4
|
+
import { LocationServiceException } from '../errors/LocationServiceException.js';
|
|
5
5
|
const log = debug('location-client:clientConfig');
|
|
6
6
|
// Singleton instance to prevent race conditions
|
|
7
7
|
let tokenProviderInstance = null;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { TokenProvider } from '../auth/TokenProvider';
|
|
2
|
-
export type { TokenProviderConfig, TokenResponse } from '../auth/TokenProvider';
|
|
3
|
-
export { getClientConfig } from './getClientConfig';
|
|
4
|
-
export type { ServerAuthConfig, ServerClientConfig } from './getClientConfig';
|
|
5
|
-
export { LocationServiceConnector } from './LocationServiceConnector';
|
|
6
|
-
export type { ConnectorConfig, SendOptions } from './LocationServiceConnector';
|
|
1
|
+
export { TokenProvider } from '../auth/TokenProvider.js';
|
|
2
|
+
export type { TokenProviderConfig, TokenResponse, } from '../auth/TokenProvider.js';
|
|
3
|
+
export { getClientConfig } from './getClientConfig.js';
|
|
4
|
+
export type { ServerAuthConfig, ServerClientConfig } from './getClientConfig.js';
|
|
5
|
+
export { LocationServiceConnector } from './LocationServiceConnector.js';
|
|
6
|
+
export type { ConnectorConfig, SendOptions, } from './LocationServiceConnector.js';
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { TokenProvider } from '../auth/TokenProvider';
|
|
2
|
-
export { getClientConfig } from './getClientConfig';
|
|
3
|
-
export { LocationServiceConnector } from './LocationServiceConnector';
|
|
1
|
+
export { TokenProvider } from '../auth/TokenProvider.js';
|
|
2
|
+
export { getClientConfig } from './getClientConfig.js';
|
|
3
|
+
export { LocationServiceConnector } from './LocationServiceConnector.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { GeoPlacesCommand } from '../types';
|
|
1
|
+
import type { GeoPlacesCommand } from '../types/index.js';
|
|
2
2
|
export declare function resolveEndpoint(command: GeoPlacesCommand): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AutocompleteCommand, GeocodeCommand, GetPlaceCommand, ReverseGeocodeCommand, SearchNearbyCommand, SearchTextCommand, SuggestCommand, } from '@aws-sdk/client-geo-places';
|
|
2
|
-
import { LocationServiceException } from '../errors/LocationServiceException';
|
|
2
|
+
import { LocationServiceException } from '../errors/LocationServiceException.js';
|
|
3
3
|
/**
|
|
4
4
|
* Command class -> API path.
|
|
5
5
|
*
|
package/dist/transport/errors.js
CHANGED
package/dist/transport/http.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
-
import { LocationServiceException } from '../errors/LocationServiceException';
|
|
3
|
-
import { parseErrorResponse, parseRetryAfter } from './errors';
|
|
2
|
+
import { LocationServiceException } from '../errors/LocationServiceException.js';
|
|
3
|
+
import { parseErrorResponse, parseRetryAfter } from './errors.js';
|
|
4
4
|
const log = debug('location-client:transport');
|
|
5
5
|
/** Per-attempt timeout. Sits well under the API's own 25 s Lambda ceiling. */
|
|
6
6
|
export const DEFAULT_TIMEOUT_MS = 10000;
|
package/package.json
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaosity/location-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Client library for Chaosity Location Service with AWS Location Service compatibility",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/cjs/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/index.js"
|
|
17
|
+
}
|
|
12
18
|
},
|
|
13
19
|
"./server": {
|
|
14
|
-
"
|
|
15
|
-
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/server/index.d.ts",
|
|
22
|
+
"default": "./dist/server/index.js"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/cjs/server/index.d.ts",
|
|
26
|
+
"default": "./dist/cjs/server/index.js"
|
|
27
|
+
}
|
|
16
28
|
}
|
|
17
29
|
},
|
|
18
30
|
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
31
|
+
"build": "tsc && tsc -p tsconfig.cjs.json && node scripts/finish-cjs.mjs",
|
|
20
32
|
"dev": "tsc --watch",
|
|
21
33
|
"lint": "eslint . && prettier --check .",
|
|
22
34
|
"lint:fix": "eslint --fix . && prettier --write .",
|
|
23
35
|
"format": "prettier --write .",
|
|
24
36
|
"test": "vitest run",
|
|
25
37
|
"test:watch": "vitest",
|
|
26
|
-
"prepublishOnly": "npm run build",
|
|
27
|
-
"prepare": "husky"
|
|
38
|
+
"prepublishOnly": "npm run build && npm run smoke",
|
|
39
|
+
"prepare": "husky",
|
|
40
|
+
"smoke": "node scripts/smoke.mjs"
|
|
28
41
|
},
|
|
29
42
|
"keywords": [
|
|
30
43
|
"aws",
|
|
@@ -47,19 +60,23 @@
|
|
|
47
60
|
"dependencies": {
|
|
48
61
|
"@aws-sdk/client-geo-places": "^3.0.0",
|
|
49
62
|
"@aws/amazon-location-utilities-datatypes": "^1.0.0",
|
|
50
|
-
"@maplibre/maplibre-gl-geocoder": "^1.9.4",
|
|
51
63
|
"debug": "^4.4.3"
|
|
52
64
|
},
|
|
53
65
|
"peerDependencies": {
|
|
66
|
+
"@maplibre/maplibre-gl-geocoder": "^1.9.4",
|
|
54
67
|
"maplibre-gl": "^5.0.0"
|
|
55
68
|
},
|
|
56
69
|
"peerDependenciesMeta": {
|
|
70
|
+
"@maplibre/maplibre-gl-geocoder": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
57
73
|
"maplibre-gl": {
|
|
58
74
|
"optional": true
|
|
59
75
|
}
|
|
60
76
|
},
|
|
61
77
|
"devDependencies": {
|
|
62
78
|
"@eslint/js": "^10.0.1",
|
|
79
|
+
"@maplibre/maplibre-gl-geocoder": "^1.9.4",
|
|
63
80
|
"@types/debug": "^4.1.12",
|
|
64
81
|
"@types/node": "^25.0.3",
|
|
65
82
|
"@vitest/coverage-v8": "^3.0.0",
|
|
@@ -79,5 +96,10 @@
|
|
|
79
96
|
"dist",
|
|
80
97
|
"README.md",
|
|
81
98
|
"LICENSE"
|
|
82
|
-
]
|
|
99
|
+
],
|
|
100
|
+
"module": "dist/index.js",
|
|
101
|
+
"sideEffects": false,
|
|
102
|
+
"engines": {
|
|
103
|
+
"node": ">=20"
|
|
104
|
+
}
|
|
83
105
|
}
|