@mapbox/mcp-server 0.12.6 → 0.12.7
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/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.d.ts +3 -2
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.js +5 -3
- package/dist/commonjs/resources/ui-apps/DirectionsAppUIResource.js.map +1 -1
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.d.ts +20 -8
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.d.ts.map +1 -1
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.js +198 -18
- package/dist/commonjs/resources/ui-apps/directionsAppHtml.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.d.ts.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.js +6 -2
- package/dist/commonjs/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js +52 -109
- package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.d.ts +29 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.d.ts.map +1 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.js +63 -0
- package/dist/commonjs/tools/directions-tool/buildDirectionsRequestUrl.js.map +1 -0
- package/dist/commonjs/version.json +3 -3
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.d.ts +3 -2
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.js +5 -3
- package/dist/esm/resources/ui-apps/DirectionsAppUIResource.js.map +1 -1
- package/dist/esm/resources/ui-apps/directionsAppHtml.d.ts +20 -8
- package/dist/esm/resources/ui-apps/directionsAppHtml.d.ts.map +1 -1
- package/dist/esm/resources/ui-apps/directionsAppHtml.js +198 -18
- package/dist/esm/resources/ui-apps/directionsAppHtml.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.d.ts.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.js +6 -2
- package/dist/esm/tools/directions-tool/DirectionsTool.input.schema.js.map +1 -1
- package/dist/esm/tools/directions-tool/DirectionsTool.js +52 -109
- package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.d.ts +29 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.d.ts.map +1 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.js +60 -0
- package/dist/esm/tools/directions-tool/buildDirectionsRequestUrl.js.map +1 -0
- package/dist/esm/version.json +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface DirectionsRequestInput {
|
|
2
|
+
coordinates: {
|
|
3
|
+
longitude: number;
|
|
4
|
+
latitude: number;
|
|
5
|
+
}[];
|
|
6
|
+
routing_profile: string;
|
|
7
|
+
geometries: 'none' | 'geojson';
|
|
8
|
+
alternatives: boolean;
|
|
9
|
+
exclude?: string;
|
|
10
|
+
depart_at?: string;
|
|
11
|
+
arrive_by?: string;
|
|
12
|
+
max_height?: number;
|
|
13
|
+
max_width?: number;
|
|
14
|
+
max_weight?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the Mapbox Directions v5 request URL for a given input. Shared by
|
|
18
|
+
* DirectionsTool.execute() (server-side) and hand-mirrored by the
|
|
19
|
+
* self-fetching map preview iframe (directionsAppHtml.ts) — the parity test
|
|
20
|
+
* in test/tools/directions-tool/directionsUrlParity.test.ts keeps the two
|
|
21
|
+
* implementations in sync.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildDirectionsRequestUrl(params: {
|
|
24
|
+
input: DirectionsRequestInput;
|
|
25
|
+
accessToken: string;
|
|
26
|
+
apiEndpoint: string;
|
|
27
|
+
geometriesOverride?: 'none' | 'geojson';
|
|
28
|
+
}): string;
|
|
29
|
+
//# sourceMappingURL=buildDirectionsRequestUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDirectionsRequestUrl.d.ts","sourceRoot":"","sources":["../../../../src/tools/directions-tool/buildDirectionsRequestUrl.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC,GAAG,MAAM,CA+CT"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Mapbox, Inc.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { formatIsoDateTime } from '../../utils/dateUtils.js';
|
|
4
|
+
function encodeExclude(value) {
|
|
5
|
+
return value
|
|
6
|
+
.replace(/,/g, '%2C')
|
|
7
|
+
.replace(/\(/g, '%28')
|
|
8
|
+
.replace(/\)/g, '%29')
|
|
9
|
+
.replace(/ /g, '%20');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Build the Mapbox Directions v5 request URL for a given input. Shared by
|
|
13
|
+
* DirectionsTool.execute() (server-side) and hand-mirrored by the
|
|
14
|
+
* self-fetching map preview iframe (directionsAppHtml.ts) — the parity test
|
|
15
|
+
* in test/tools/directions-tool/directionsUrlParity.test.ts keeps the two
|
|
16
|
+
* implementations in sync.
|
|
17
|
+
*/
|
|
18
|
+
export function buildDirectionsRequestUrl(params) {
|
|
19
|
+
const { input, accessToken, apiEndpoint, geometriesOverride } = params;
|
|
20
|
+
const geometries = geometriesOverride ?? input.geometries;
|
|
21
|
+
const joined = input.coordinates
|
|
22
|
+
.map(({ longitude, latitude }) => `${longitude},${latitude}`)
|
|
23
|
+
.join(';');
|
|
24
|
+
const encodedCoords = encodeURIComponent(joined);
|
|
25
|
+
const queryParams = new URLSearchParams();
|
|
26
|
+
queryParams.append('access_token', accessToken);
|
|
27
|
+
if (geometries !== 'none') {
|
|
28
|
+
queryParams.append('geometries', geometries);
|
|
29
|
+
}
|
|
30
|
+
queryParams.append('alternatives', input.alternatives.toString());
|
|
31
|
+
if (input.routing_profile === 'mapbox/driving-traffic') {
|
|
32
|
+
queryParams.append('annotations', 'distance,congestion,speed');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
queryParams.append('annotations', 'distance,speed');
|
|
36
|
+
}
|
|
37
|
+
queryParams.append('overview', 'full');
|
|
38
|
+
if (input.depart_at) {
|
|
39
|
+
queryParams.append('depart_at', formatIsoDateTime(input.depart_at));
|
|
40
|
+
}
|
|
41
|
+
else if (input.arrive_by) {
|
|
42
|
+
queryParams.append('arrive_by', formatIsoDateTime(input.arrive_by));
|
|
43
|
+
}
|
|
44
|
+
if (input.max_height !== undefined) {
|
|
45
|
+
queryParams.append('max_height', input.max_height.toString());
|
|
46
|
+
}
|
|
47
|
+
if (input.max_width !== undefined) {
|
|
48
|
+
queryParams.append('max_width', input.max_width.toString());
|
|
49
|
+
}
|
|
50
|
+
if (input.max_weight !== undefined) {
|
|
51
|
+
queryParams.append('max_weight', input.max_weight.toString());
|
|
52
|
+
}
|
|
53
|
+
queryParams.append('steps', 'true');
|
|
54
|
+
let queryString = queryParams.toString();
|
|
55
|
+
if (input.exclude) {
|
|
56
|
+
queryString += `&exclude=${encodeExclude(input.exclude)}`;
|
|
57
|
+
}
|
|
58
|
+
return `${apiEndpoint}directions/v5/${input.routing_profile}/${encodedCoords}?${queryString}`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=buildDirectionsRequestUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildDirectionsRequestUrl.js","sourceRoot":"","sources":["../../../../src/tools/directions-tool/buildDirectionsRequestUrl.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAe7D,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAKzC;IACC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;IACvE,MAAM,UAAU,GAAG,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC;IAE1D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW;SAC7B,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE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