@mapbox/mcp-server 0.1.1-dev.2 → 0.2.0-dev.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/README.md +4 -0
- package/dist/tools/MapboxApiBasedTool.d.ts +7 -0
- package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/tools/MapboxApiBasedTool.js +24 -2
- package/dist/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/tools/MapboxApiBasedTool.test.d.ts +2 -0
- package/dist/tools/MapboxApiBasedTool.test.d.ts.map +1 -0
- package/dist/tools/MapboxApiBasedTool.test.js +143 -0
- package/dist/tools/MapboxApiBasedTool.test.js.map +1 -0
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts +55 -6
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.js +47 -19
- package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.test.js +90 -10
- package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.d.ts +18 -3
- package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.js +6 -6
- package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.test.js +122 -118
- package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +55 -9
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +44 -21
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +90 -10
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts +18 -3
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.js +6 -3
- package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.test.js +8 -7
- package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.d.ts +18 -3
- package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.js +6 -6
- package/dist/tools/matrix-tool/MatrixTool.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.test.js +128 -115
- package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +73 -9
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.js +53 -22
- package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js +90 -10
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +5 -2
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +13 -3
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +70 -7
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +36 -6
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js +12 -9
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +48 -47
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
process.env.MAPBOX_ACCESS_TOKEN =
|
|
1
|
+
process.env.MAPBOX_ACCESS_TOKEN =
|
|
2
|
+
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature';
|
|
2
3
|
import { cleanup } from '../../utils/requestUtils.js';
|
|
3
4
|
import { setupFetch, assertHeadersSent } from '../../utils/requestUtils.test-helpers.js';
|
|
4
5
|
import { DirectionsTool } from './DirectionsTool.js';
|
|
@@ -11,8 +12,8 @@ describe('DirectionsTool', () => {
|
|
|
11
12
|
const mockFetch = setupFetch();
|
|
12
13
|
await new DirectionsTool().run({
|
|
13
14
|
coordinates: [
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
{ longitude: -74.102094, latitude: 40.692815 },
|
|
16
|
+
{ longitude: -74.1022094, latitude: 40.792815 }
|
|
16
17
|
]
|
|
17
18
|
});
|
|
18
19
|
assertHeadersSent(mockFetch);
|
|
@@ -21,8 +22,8 @@ describe('DirectionsTool', () => {
|
|
|
21
22
|
const mockFetch = setupFetch();
|
|
22
23
|
await new DirectionsTool().run({
|
|
23
24
|
coordinates: [
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
26
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
26
27
|
]
|
|
27
28
|
});
|
|
28
29
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -35,9 +36,9 @@ describe('DirectionsTool', () => {
|
|
|
35
36
|
const mockFetch = setupFetch();
|
|
36
37
|
await new DirectionsTool().run({
|
|
37
38
|
coordinates: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
{ longitude: -122.42, latitude: 37.78 },
|
|
40
|
+
{ longitude: -122.4, latitude: 37.79 },
|
|
41
|
+
{ longitude: -122.39, latitude: 37.77 }
|
|
41
42
|
],
|
|
42
43
|
routing_profile: 'walking',
|
|
43
44
|
geometries: 'geojson',
|
|
@@ -59,8 +60,8 @@ describe('DirectionsTool', () => {
|
|
|
59
60
|
const mockFetch = setupFetch();
|
|
60
61
|
await new DirectionsTool().run({
|
|
61
62
|
coordinates: [
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
{ longitude: -118.24, latitude: 34.05 },
|
|
64
|
+
{ longitude: -118.3, latitude: 34.02 }
|
|
64
65
|
]
|
|
65
66
|
});
|
|
66
67
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -75,8 +76,8 @@ describe('DirectionsTool', () => {
|
|
|
75
76
|
const mockFetch = setupFetch();
|
|
76
77
|
await new DirectionsTool().run({
|
|
77
78
|
coordinates: [
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
{ longitude: -74.0, latitude: 40.7 },
|
|
80
|
+
{ longitude: -73.9, latitude: 40.8 }
|
|
80
81
|
],
|
|
81
82
|
exclude: 'toll,point(-73.95 40.75)'
|
|
82
83
|
});
|
|
@@ -96,8 +97,8 @@ describe('DirectionsTool', () => {
|
|
|
96
97
|
});
|
|
97
98
|
const result = await new DirectionsTool().run({
|
|
98
99
|
coordinates: [
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
101
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
101
102
|
]
|
|
102
103
|
});
|
|
103
104
|
expect(result.is_error).toBe(true);
|
|
@@ -111,7 +112,7 @@ describe('DirectionsTool', () => {
|
|
|
111
112
|
const tool = new DirectionsTool();
|
|
112
113
|
// Test with only one coordinate (invalid)
|
|
113
114
|
await expect(tool.run({
|
|
114
|
-
coordinates: [
|
|
115
|
+
coordinates: [{ longitude: -73.989, latitude: 40.733 }]
|
|
115
116
|
})).resolves.toMatchObject({
|
|
116
117
|
is_error: true
|
|
117
118
|
});
|
|
@@ -125,7 +126,10 @@ describe('DirectionsTool', () => {
|
|
|
125
126
|
it('validates coordinates constraints - maximum allowed', async () => {
|
|
126
127
|
const tool = new DirectionsTool();
|
|
127
128
|
// Create an array of 26 coordinates (one more than allowed)
|
|
128
|
-
const tooManyCoords = Array(26).fill(
|
|
129
|
+
const tooManyCoords = Array(26).fill({
|
|
130
|
+
longitude: -73.989,
|
|
131
|
+
latitude: 40.733
|
|
132
|
+
});
|
|
129
133
|
await expect(tool.run({
|
|
130
134
|
coordinates: tooManyCoords
|
|
131
135
|
})).resolves.toMatchObject({
|
|
@@ -136,8 +140,8 @@ describe('DirectionsTool', () => {
|
|
|
136
140
|
const mockFetch = setupFetch();
|
|
137
141
|
await new DirectionsTool().run({
|
|
138
142
|
coordinates: [
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
144
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
141
145
|
]
|
|
142
146
|
});
|
|
143
147
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -149,14 +153,14 @@ describe('DirectionsTool', () => {
|
|
|
149
153
|
// Create an array of exactly 25 coordinates (maximum allowed)
|
|
150
154
|
const maxCoords = Array(25)
|
|
151
155
|
.fill(0)
|
|
152
|
-
.map((_, i) =>
|
|
156
|
+
.map((_, i) => ({ longitude: -74 + i * 0.01, latitude: 40 + i * 0.01 }));
|
|
153
157
|
await new DirectionsTool().run({
|
|
154
158
|
coordinates: maxCoords
|
|
155
159
|
});
|
|
156
160
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
157
161
|
// Check that all coordinates are properly encoded
|
|
158
162
|
for (let i = 0; i < maxCoords.length; i++) {
|
|
159
|
-
const
|
|
163
|
+
const { longitude: lng, latitude: lat } = maxCoords[i];
|
|
160
164
|
const semicolon = i < 24 ? '%3B' : '';
|
|
161
165
|
const expectedCoord = `${lng}%2C${lat}` + semicolon;
|
|
162
166
|
expect(calledUrl).toContain(expectedCoord);
|
|
@@ -168,8 +172,8 @@ describe('DirectionsTool', () => {
|
|
|
168
172
|
const mockFetch = setupFetch();
|
|
169
173
|
await new DirectionsTool().run({
|
|
170
174
|
coordinates: [
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
176
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
173
177
|
],
|
|
174
178
|
routing_profile: 'walking',
|
|
175
179
|
walking_speed: 2.5
|
|
@@ -182,8 +186,8 @@ describe('DirectionsTool', () => {
|
|
|
182
186
|
const mockFetch = setupFetch();
|
|
183
187
|
await new DirectionsTool().run({
|
|
184
188
|
coordinates: [
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
190
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
187
191
|
],
|
|
188
192
|
routing_profile: 'walking',
|
|
189
193
|
walkway_bias: 0.8
|
|
@@ -197,8 +201,8 @@ describe('DirectionsTool', () => {
|
|
|
197
201
|
// Test with driving profile
|
|
198
202
|
await expect(tool.run({
|
|
199
203
|
coordinates: [
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
205
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
202
206
|
],
|
|
203
207
|
routing_profile: 'driving',
|
|
204
208
|
walking_speed: 2.0
|
|
@@ -208,8 +212,8 @@ describe('DirectionsTool', () => {
|
|
|
208
212
|
// Test with cycling profile
|
|
209
213
|
await expect(tool.run({
|
|
210
214
|
coordinates: [
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
216
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
213
217
|
],
|
|
214
218
|
routing_profile: 'cycling',
|
|
215
219
|
walking_speed: 2.0
|
|
@@ -222,8 +226,8 @@ describe('DirectionsTool', () => {
|
|
|
222
226
|
// Test with driving-traffic profile
|
|
223
227
|
await expect(tool.run({
|
|
224
228
|
coordinates: [
|
|
225
|
-
|
|
226
|
-
|
|
229
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
230
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
227
231
|
],
|
|
228
232
|
routing_profile: 'driving-traffic',
|
|
229
233
|
walkway_bias: 0.5
|
|
@@ -233,8 +237,8 @@ describe('DirectionsTool', () => {
|
|
|
233
237
|
// Test with cycling profile
|
|
234
238
|
await expect(tool.run({
|
|
235
239
|
coordinates: [
|
|
236
|
-
|
|
237
|
-
|
|
240
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
241
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
238
242
|
],
|
|
239
243
|
routing_profile: 'cycling',
|
|
240
244
|
walkway_bias: -0.8
|
|
@@ -247,8 +251,8 @@ describe('DirectionsTool', () => {
|
|
|
247
251
|
// Test with value below minimum (0.14 m/s)
|
|
248
252
|
await expect(tool.run({
|
|
249
253
|
coordinates: [
|
|
250
|
-
|
|
251
|
-
|
|
254
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
255
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
252
256
|
],
|
|
253
257
|
routing_profile: 'walking',
|
|
254
258
|
walking_speed: 0.1
|
|
@@ -258,8 +262,8 @@ describe('DirectionsTool', () => {
|
|
|
258
262
|
// Test with value above maximum (6.94 m/s)
|
|
259
263
|
await expect(tool.run({
|
|
260
264
|
coordinates: [
|
|
261
|
-
|
|
262
|
-
|
|
265
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
266
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
263
267
|
],
|
|
264
268
|
routing_profile: 'walking',
|
|
265
269
|
walking_speed: 7.5
|
|
@@ -270,8 +274,8 @@ describe('DirectionsTool', () => {
|
|
|
270
274
|
const mockFetch = setupFetch();
|
|
271
275
|
await tool.run({
|
|
272
276
|
coordinates: [
|
|
273
|
-
|
|
274
|
-
|
|
277
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
278
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
275
279
|
],
|
|
276
280
|
routing_profile: 'walking',
|
|
277
281
|
walking_speed: 3.0
|
|
@@ -284,8 +288,8 @@ describe('DirectionsTool', () => {
|
|
|
284
288
|
// Test with value below minimum (-1)
|
|
285
289
|
await expect(tool.run({
|
|
286
290
|
coordinates: [
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
292
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
289
293
|
],
|
|
290
294
|
routing_profile: 'walking',
|
|
291
295
|
walkway_bias: -1.5
|
|
@@ -295,8 +299,8 @@ describe('DirectionsTool', () => {
|
|
|
295
299
|
// Test with value above maximum (1)
|
|
296
300
|
await expect(tool.run({
|
|
297
301
|
coordinates: [
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
303
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
300
304
|
],
|
|
301
305
|
routing_profile: 'walking',
|
|
302
306
|
walkway_bias: 1.2
|
|
@@ -307,8 +311,8 @@ describe('DirectionsTool', () => {
|
|
|
307
311
|
const mockFetch = setupFetch();
|
|
308
312
|
await tool.run({
|
|
309
313
|
coordinates: [
|
|
310
|
-
|
|
311
|
-
|
|
314
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
315
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
312
316
|
],
|
|
313
317
|
routing_profile: 'walking',
|
|
314
318
|
walkway_bias: -0.5
|
|
@@ -324,8 +328,8 @@ describe('DirectionsTool', () => {
|
|
|
324
328
|
// Test with driving profile
|
|
325
329
|
await expect(tool.run({
|
|
326
330
|
coordinates: [
|
|
327
|
-
|
|
328
|
-
|
|
331
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
332
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
329
333
|
],
|
|
330
334
|
routing_profile: 'driving',
|
|
331
335
|
exclude: 'toll,motorway,unpaved'
|
|
@@ -335,8 +339,8 @@ describe('DirectionsTool', () => {
|
|
|
335
339
|
// Test with driving-traffic profile
|
|
336
340
|
await expect(tool.run({
|
|
337
341
|
coordinates: [
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
343
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
340
344
|
],
|
|
341
345
|
routing_profile: 'driving-traffic',
|
|
342
346
|
exclude: 'tunnel,country_border,state_border'
|
|
@@ -349,8 +353,8 @@ describe('DirectionsTool', () => {
|
|
|
349
353
|
// Test with walking profile
|
|
350
354
|
await expect(tool.run({
|
|
351
355
|
coordinates: [
|
|
352
|
-
|
|
353
|
-
|
|
356
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
357
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
354
358
|
],
|
|
355
359
|
routing_profile: 'walking',
|
|
356
360
|
exclude: 'toll'
|
|
@@ -360,8 +364,8 @@ describe('DirectionsTool', () => {
|
|
|
360
364
|
// Test with cycling profile
|
|
361
365
|
await expect(tool.run({
|
|
362
366
|
coordinates: [
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
368
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
365
369
|
],
|
|
366
370
|
routing_profile: 'cycling',
|
|
367
371
|
exclude: 'motorway'
|
|
@@ -375,8 +379,8 @@ describe('DirectionsTool', () => {
|
|
|
375
379
|
// Test with driving profile
|
|
376
380
|
await expect(tool.run({
|
|
377
381
|
coordinates: [
|
|
378
|
-
|
|
379
|
-
|
|
382
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
383
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
380
384
|
],
|
|
381
385
|
routing_profile: 'driving',
|
|
382
386
|
exclude: 'ferry'
|
|
@@ -386,8 +390,8 @@ describe('DirectionsTool', () => {
|
|
|
386
390
|
// Test with walking profile
|
|
387
391
|
await expect(tool.run({
|
|
388
392
|
coordinates: [
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
394
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
391
395
|
],
|
|
392
396
|
routing_profile: 'walking',
|
|
393
397
|
exclude: 'ferry'
|
|
@@ -397,8 +401,8 @@ describe('DirectionsTool', () => {
|
|
|
397
401
|
// Test with cycling profile
|
|
398
402
|
await expect(tool.run({
|
|
399
403
|
coordinates: [
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
405
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
402
406
|
],
|
|
403
407
|
routing_profile: 'cycling',
|
|
404
408
|
exclude: 'cash_only_tolls'
|
|
@@ -412,8 +416,8 @@ describe('DirectionsTool', () => {
|
|
|
412
416
|
// Test with driving profile - should work
|
|
413
417
|
await expect(tool.run({
|
|
414
418
|
coordinates: [
|
|
415
|
-
|
|
416
|
-
|
|
419
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
420
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
417
421
|
],
|
|
418
422
|
routing_profile: 'driving',
|
|
419
423
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -423,8 +427,8 @@ describe('DirectionsTool', () => {
|
|
|
423
427
|
// Test with walking profile - should fail
|
|
424
428
|
await expect(tool.run({
|
|
425
429
|
coordinates: [
|
|
426
|
-
|
|
427
|
-
|
|
430
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
431
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
428
432
|
],
|
|
429
433
|
routing_profile: 'walking',
|
|
430
434
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -434,8 +438,8 @@ describe('DirectionsTool', () => {
|
|
|
434
438
|
// Test with cycling profile - should fail
|
|
435
439
|
await expect(tool.run({
|
|
436
440
|
coordinates: [
|
|
437
|
-
|
|
438
|
-
|
|
441
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
442
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
439
443
|
],
|
|
440
444
|
routing_profile: 'cycling',
|
|
441
445
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -449,8 +453,8 @@ describe('DirectionsTool', () => {
|
|
|
449
453
|
// All valid exclusions for driving profile
|
|
450
454
|
await expect(tool.run({
|
|
451
455
|
coordinates: [
|
|
452
|
-
|
|
453
|
-
|
|
456
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
457
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
454
458
|
],
|
|
455
459
|
routing_profile: 'driving',
|
|
456
460
|
exclude: 'toll,motorway,ferry,cash_only_tolls,point(-73.95 40.75)'
|
|
@@ -460,8 +464,8 @@ describe('DirectionsTool', () => {
|
|
|
460
464
|
// Mixed valid and invalid exclusions (ferry is valid for walking, toll is not)
|
|
461
465
|
await expect(tool.run({
|
|
462
466
|
coordinates: [
|
|
463
|
-
|
|
464
|
-
|
|
467
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
468
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
465
469
|
],
|
|
466
470
|
routing_profile: 'walking',
|
|
467
471
|
exclude: 'ferry,toll'
|
|
@@ -471,8 +475,8 @@ describe('DirectionsTool', () => {
|
|
|
471
475
|
// All valid exclusions for cycling profile
|
|
472
476
|
await expect(tool.run({
|
|
473
477
|
coordinates: [
|
|
474
|
-
|
|
475
|
-
|
|
478
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
479
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
476
480
|
],
|
|
477
481
|
routing_profile: 'cycling',
|
|
478
482
|
exclude: 'ferry,cash_only_tolls'
|
|
@@ -489,8 +493,8 @@ describe('DirectionsTool', () => {
|
|
|
489
493
|
// Test with driving profile
|
|
490
494
|
await expect(tool.run({
|
|
491
495
|
coordinates: [
|
|
492
|
-
|
|
493
|
-
|
|
496
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
497
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
494
498
|
],
|
|
495
499
|
routing_profile: 'driving',
|
|
496
500
|
depart_at: validDateTime
|
|
@@ -502,8 +506,8 @@ describe('DirectionsTool', () => {
|
|
|
502
506
|
// Test with driving-traffic profile
|
|
503
507
|
await expect(tool.run({
|
|
504
508
|
coordinates: [
|
|
505
|
-
|
|
506
|
-
|
|
509
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
510
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
507
511
|
],
|
|
508
512
|
routing_profile: 'driving-traffic',
|
|
509
513
|
depart_at: validDateTime
|
|
@@ -520,8 +524,8 @@ describe('DirectionsTool', () => {
|
|
|
520
524
|
// Test with driving profile
|
|
521
525
|
await expect(tool.run({
|
|
522
526
|
coordinates: [
|
|
523
|
-
|
|
524
|
-
|
|
527
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
528
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
525
529
|
],
|
|
526
530
|
routing_profile: 'driving',
|
|
527
531
|
max_height: 4.5,
|
|
@@ -537,8 +541,8 @@ describe('DirectionsTool', () => {
|
|
|
537
541
|
// Test with driving-traffic profile
|
|
538
542
|
await expect(tool.run({
|
|
539
543
|
coordinates: [
|
|
540
|
-
|
|
541
|
-
|
|
544
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
545
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
542
546
|
],
|
|
543
547
|
routing_profile: 'driving-traffic',
|
|
544
548
|
max_height: 3.2
|
|
@@ -553,8 +557,8 @@ describe('DirectionsTool', () => {
|
|
|
553
557
|
// Test with walking profile
|
|
554
558
|
await expect(tool.run({
|
|
555
559
|
coordinates: [
|
|
556
|
-
|
|
557
|
-
|
|
560
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
561
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
558
562
|
],
|
|
559
563
|
routing_profile: 'walking',
|
|
560
564
|
max_height: 4.5
|
|
@@ -564,8 +568,8 @@ describe('DirectionsTool', () => {
|
|
|
564
568
|
// Test with cycling profile
|
|
565
569
|
await expect(tool.run({
|
|
566
570
|
coordinates: [
|
|
567
|
-
|
|
568
|
-
|
|
571
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
572
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
569
573
|
],
|
|
570
574
|
routing_profile: 'cycling',
|
|
571
575
|
max_width: 2.0
|
|
@@ -578,8 +582,8 @@ describe('DirectionsTool', () => {
|
|
|
578
582
|
// Test invalid height (too high)
|
|
579
583
|
await expect(tool.run({
|
|
580
584
|
coordinates: [
|
|
581
|
-
|
|
582
|
-
|
|
585
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
586
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
583
587
|
],
|
|
584
588
|
routing_profile: 'driving',
|
|
585
589
|
max_height: 15.0
|
|
@@ -589,8 +593,8 @@ describe('DirectionsTool', () => {
|
|
|
589
593
|
// Test invalid width (negative)
|
|
590
594
|
await expect(tool.run({
|
|
591
595
|
coordinates: [
|
|
592
|
-
|
|
593
|
-
|
|
596
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
597
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
594
598
|
],
|
|
595
599
|
routing_profile: 'driving',
|
|
596
600
|
max_width: -1.0
|
|
@@ -600,8 +604,8 @@ describe('DirectionsTool', () => {
|
|
|
600
604
|
// Test invalid weight (too heavy)
|
|
601
605
|
await expect(tool.run({
|
|
602
606
|
coordinates: [
|
|
603
|
-
|
|
604
|
-
|
|
607
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
608
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
605
609
|
],
|
|
606
610
|
routing_profile: 'driving',
|
|
607
611
|
max_weight: 150.0
|
|
@@ -616,8 +620,8 @@ describe('DirectionsTool', () => {
|
|
|
616
620
|
// Test with walking profile
|
|
617
621
|
await expect(tool.run({
|
|
618
622
|
coordinates: [
|
|
619
|
-
|
|
620
|
-
|
|
623
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
624
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
621
625
|
],
|
|
622
626
|
routing_profile: 'walking',
|
|
623
627
|
depart_at: validDateTime
|
|
@@ -627,8 +631,8 @@ describe('DirectionsTool', () => {
|
|
|
627
631
|
// Test with cycling profile
|
|
628
632
|
await expect(tool.run({
|
|
629
633
|
coordinates: [
|
|
630
|
-
|
|
631
|
-
|
|
634
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
635
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
632
636
|
],
|
|
633
637
|
routing_profile: 'cycling',
|
|
634
638
|
depart_at: validDateTime
|
|
@@ -640,8 +644,8 @@ describe('DirectionsTool', () => {
|
|
|
640
644
|
const mockFetch = setupFetch();
|
|
641
645
|
const tool = new DirectionsTool();
|
|
642
646
|
const baseCoordinates = [
|
|
643
|
-
|
|
644
|
-
|
|
647
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
648
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
645
649
|
];
|
|
646
650
|
// Format 1: YYYY-MM-DDThh:mm:ssZ
|
|
647
651
|
await expect(tool.run({
|
|
@@ -668,8 +672,8 @@ describe('DirectionsTool', () => {
|
|
|
668
672
|
it('rejects invalid date-time formats', async () => {
|
|
669
673
|
const tool = new DirectionsTool();
|
|
670
674
|
const baseCoordinates = [
|
|
671
|
-
|
|
672
|
-
|
|
675
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
676
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
673
677
|
];
|
|
674
678
|
// Invalid format examples
|
|
675
679
|
const invalidFormats = [
|
|
@@ -695,8 +699,8 @@ describe('DirectionsTool', () => {
|
|
|
695
699
|
it('rejects dates with invalid components', async () => {
|
|
696
700
|
const tool = new DirectionsTool();
|
|
697
701
|
const baseCoordinates = [
|
|
698
|
-
|
|
699
|
-
|
|
702
|
+
{ longitude: -73.989, latitude: 40.733 },
|
|
703
|
+
{ longitude: -73.979, latitude: 40.743 }
|
|
700
704
|
];
|
|
701
705
|
// Invalid time components
|
|
702
706
|
const invalidDates = [
|
|
@@ -723,8 +727,8 @@ describe('DirectionsTool', () => {
|
|
|
723
727
|
// Test with driving profile - should work
|
|
724
728
|
await new DirectionsTool().run({
|
|
725
729
|
coordinates: [
|
|
726
|
-
|
|
727
|
-
|
|
730
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
731
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
728
732
|
],
|
|
729
733
|
routing_profile: 'driving',
|
|
730
734
|
arrive_by: validDateTime
|
|
@@ -738,8 +742,8 @@ describe('DirectionsTool', () => {
|
|
|
738
742
|
// Test with driving-traffic profile
|
|
739
743
|
const result1 = await new DirectionsTool().run({
|
|
740
744
|
coordinates: [
|
|
741
|
-
|
|
742
|
-
|
|
745
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
746
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
743
747
|
],
|
|
744
748
|
routing_profile: 'driving-traffic',
|
|
745
749
|
arrive_by: validDateTime
|
|
@@ -748,8 +752,8 @@ describe('DirectionsTool', () => {
|
|
|
748
752
|
// Test with walking profile
|
|
749
753
|
const result2 = await new DirectionsTool().run({
|
|
750
754
|
coordinates: [
|
|
751
|
-
|
|
752
|
-
|
|
755
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
756
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
753
757
|
],
|
|
754
758
|
routing_profile: 'walking',
|
|
755
759
|
arrive_by: validDateTime
|
|
@@ -758,8 +762,8 @@ describe('DirectionsTool', () => {
|
|
|
758
762
|
// Test with cycling profile
|
|
759
763
|
const result3 = await new DirectionsTool().run({
|
|
760
764
|
coordinates: [
|
|
761
|
-
|
|
762
|
-
|
|
765
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
766
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
763
767
|
],
|
|
764
768
|
routing_profile: 'cycling',
|
|
765
769
|
arrive_by: validDateTime
|
|
@@ -769,8 +773,8 @@ describe('DirectionsTool', () => {
|
|
|
769
773
|
it('rejects when both arrive_by and depart_at are provided', async () => {
|
|
770
774
|
const result = await new DirectionsTool().run({
|
|
771
775
|
coordinates: [
|
|
772
|
-
|
|
773
|
-
|
|
776
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
777
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
774
778
|
],
|
|
775
779
|
routing_profile: 'driving',
|
|
776
780
|
depart_at: '2025-06-05T09:30:00Z',
|
|
@@ -783,8 +787,8 @@ describe('DirectionsTool', () => {
|
|
|
783
787
|
// Test with Z format
|
|
784
788
|
await new DirectionsTool().run({
|
|
785
789
|
coordinates: [
|
|
786
|
-
|
|
787
|
-
|
|
790
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
791
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
788
792
|
],
|
|
789
793
|
routing_profile: 'driving',
|
|
790
794
|
arrive_by: '2025-06-05T10:30:00Z'
|
|
@@ -794,8 +798,8 @@ describe('DirectionsTool', () => {
|
|
|
794
798
|
// Test with timezone offset format
|
|
795
799
|
await new DirectionsTool().run({
|
|
796
800
|
coordinates: [
|
|
797
|
-
|
|
798
|
-
|
|
801
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
802
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
799
803
|
],
|
|
800
804
|
routing_profile: 'driving',
|
|
801
805
|
arrive_by: '2025-06-05T10:30:00+02:00'
|
|
@@ -805,8 +809,8 @@ describe('DirectionsTool', () => {
|
|
|
805
809
|
// Test with simple time format (no seconds, no timezone)
|
|
806
810
|
await new DirectionsTool().run({
|
|
807
811
|
coordinates: [
|
|
808
|
-
|
|
809
|
-
|
|
812
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
813
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
810
814
|
],
|
|
811
815
|
routing_profile: 'driving',
|
|
812
816
|
arrive_by: '2025-06-05T10:30'
|
|
@@ -832,8 +836,8 @@ describe('DirectionsTool', () => {
|
|
|
832
836
|
for (const format of invalidFormats) {
|
|
833
837
|
const result = await new DirectionsTool().run({
|
|
834
838
|
coordinates: [
|
|
835
|
-
|
|
836
|
-
|
|
839
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
840
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
837
841
|
],
|
|
838
842
|
routing_profile: 'driving',
|
|
839
843
|
arrive_by: format
|
|
@@ -853,8 +857,8 @@ describe('DirectionsTool', () => {
|
|
|
853
857
|
for (const date of invalidDates) {
|
|
854
858
|
const result = await new DirectionsTool().run({
|
|
855
859
|
coordinates: [
|
|
856
|
-
|
|
857
|
-
|
|
860
|
+
{ longitude: -74.1, latitude: 40.7 },
|
|
861
|
+
{ longitude: -74.2, latitude: 40.8 }
|
|
858
862
|
],
|
|
859
863
|
routing_profile: 'driving',
|
|
860
864
|
arrive_by: date
|