@mapbox/mcp-server 0.2.0-issue.11.2 → 0.2.1-dev.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 +4 -82
- package/dist/index.js +0 -0
- package/dist/tools/MapboxApiBasedTool.d.ts +0 -7
- package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/tools/MapboxApiBasedTool.js +2 -24
- package/dist/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts +6 -55
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.js +19 -47
- package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.test.js +10 -90
- package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.d.ts +14 -4
- package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.js +55 -31
- package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.test.js +160 -115
- package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +9 -55
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +21 -44
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +10 -90
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts +3 -18
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.js +3 -6
- package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.test.js +7 -8
- package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.d.ts +3 -18
- 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 +115 -128
- package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +9 -73
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.js +22 -53
- package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js +10 -90
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +2 -5
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +3 -13
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +7 -70
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +6 -36
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js +9 -12
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +47 -48
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -1
- package/dist/utils/requestUtils.d.ts.map +1 -1
- package/dist/utils/requestUtils.js +2 -31
- package/dist/utils/requestUtils.js.map +1 -1
- package/dist/utils/requestUtils.test-helpers.d.ts.map +1 -1
- package/dist/utils/requestUtils.test-helpers.js +1 -5
- package/dist/utils/requestUtils.test-helpers.js.map +1 -1
- package/dist/version.json +4 -4
- package/package.json +2 -2
- package/dist/tools/MapboxApiBasedTool.test.d.ts +0 -2
- package/dist/tools/MapboxApiBasedTool.test.d.ts.map +0 -1
- package/dist/tools/MapboxApiBasedTool.test.js +0 -143
- package/dist/tools/MapboxApiBasedTool.test.js.map +0 -1
- package/dist/tools/directions-tool/cleanResponseData.d.ts +0 -11
- package/dist/tools/directions-tool/cleanResponseData.d.ts.map +0 -1
- package/dist/tools/directions-tool/cleanResponseData.js +0 -175
- package/dist/tools/directions-tool/cleanResponseData.js.map +0 -1
- package/dist/tools/directions-tool/cleanResponseData.test.d.ts +0 -2
- package/dist/tools/directions-tool/cleanResponseData.test.d.ts.map +0 -1
- package/dist/tools/directions-tool/cleanResponseData.test.js +0 -295
- package/dist/tools/directions-tool/cleanResponseData.test.js.map +0 -1
- package/dist/tools/directions-tool/formatIsoDateTime.d.ts +0 -8
- package/dist/tools/directions-tool/formatIsoDateTime.d.ts.map +0 -1
- package/dist/tools/directions-tool/formatIsoDateTime.js +0 -17
- package/dist/tools/directions-tool/formatIsoDateTime.js.map +0 -1
- package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts +0 -2
- package/dist/tools/directions-tool/formatIsoDateTime.test.d.ts.map +0 -1
- package/dist/tools/directions-tool/formatIsoDateTime.test.js +0 -26
- package/dist/tools/directions-tool/formatIsoDateTime.test.js.map +0 -1
- package/dist/utils/requestUtils.test.d.ts +0 -2
- package/dist/utils/requestUtils.test.d.ts.map +0 -1
- package/dist/utils/requestUtils.test.js +0 -115
- package/dist/utils/requestUtils.test.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
process.env.MAPBOX_ACCESS_TOKEN =
|
|
2
|
-
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature';
|
|
1
|
+
process.env.MAPBOX_ACCESS_TOKEN = 'test-token';
|
|
3
2
|
import { cleanup } from '../../utils/requestUtils.js';
|
|
4
3
|
import { setupFetch, assertHeadersSent } from '../../utils/requestUtils.test-helpers.js';
|
|
5
4
|
import { MatrixTool } from './MatrixTool.js';
|
|
@@ -62,8 +61,8 @@ describe('MatrixTool', () => {
|
|
|
62
61
|
const mockFetch = setupFetch();
|
|
63
62
|
await new MatrixTool().run({
|
|
64
63
|
coordinates: [
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
[-74.102094, 40.692815],
|
|
65
|
+
[-74.1022094, 40.792815]
|
|
67
66
|
],
|
|
68
67
|
profile: 'walking'
|
|
69
68
|
});
|
|
@@ -76,9 +75,9 @@ describe('MatrixTool', () => {
|
|
|
76
75
|
const tool = new MatrixTool();
|
|
77
76
|
const result = await tool.run({
|
|
78
77
|
coordinates: [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
[-122.42, 37.78],
|
|
79
|
+
[-122.45, 37.91],
|
|
80
|
+
[-122.48, 37.73]
|
|
82
81
|
],
|
|
83
82
|
profile: 'driving'
|
|
84
83
|
});
|
|
@@ -87,7 +86,7 @@ describe('MatrixTool', () => {
|
|
|
87
86
|
// Check that URL contains correct profile and coordinates
|
|
88
87
|
const url = mockFetch.mock.calls[0][0];
|
|
89
88
|
expect(url).toContain('directions-matrix/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73');
|
|
90
|
-
expect(url).toContain('access_token=
|
|
89
|
+
expect(url).toContain('access_token=test-token');
|
|
91
90
|
assertHeadersSent(mockFetch);
|
|
92
91
|
});
|
|
93
92
|
it('properly includes annotations parameter when specified', async () => {
|
|
@@ -97,8 +96,8 @@ describe('MatrixTool', () => {
|
|
|
97
96
|
const tool = new MatrixTool();
|
|
98
97
|
await tool.run({
|
|
99
98
|
coordinates: [
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
[-122.42, 37.78],
|
|
100
|
+
[-122.45, 37.91]
|
|
102
101
|
],
|
|
103
102
|
profile: 'driving',
|
|
104
103
|
annotations: 'duration,distance'
|
|
@@ -113,9 +112,9 @@ describe('MatrixTool', () => {
|
|
|
113
112
|
const tool = new MatrixTool();
|
|
114
113
|
await tool.run({
|
|
115
114
|
coordinates: [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
[-122.42, 37.78],
|
|
116
|
+
[-122.45, 37.91],
|
|
117
|
+
[-122.48, 37.73]
|
|
119
118
|
],
|
|
120
119
|
profile: 'driving',
|
|
121
120
|
approaches: 'curb;unrestricted;curb'
|
|
@@ -130,8 +129,8 @@ describe('MatrixTool', () => {
|
|
|
130
129
|
const tool = new MatrixTool();
|
|
131
130
|
await tool.run({
|
|
132
131
|
coordinates: [
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
[-122.42, 37.78],
|
|
133
|
+
[-122.45, 37.91]
|
|
135
134
|
],
|
|
136
135
|
profile: 'driving',
|
|
137
136
|
bearings: '45,90;120,45'
|
|
@@ -146,9 +145,9 @@ describe('MatrixTool', () => {
|
|
|
146
145
|
const tool = new MatrixTool();
|
|
147
146
|
await tool.run({
|
|
148
147
|
coordinates: [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
[-122.42, 37.78],
|
|
149
|
+
[-122.45, 37.91],
|
|
150
|
+
[-122.48, 37.73]
|
|
152
151
|
],
|
|
153
152
|
profile: 'cycling',
|
|
154
153
|
destinations: '0;2'
|
|
@@ -163,9 +162,9 @@ describe('MatrixTool', () => {
|
|
|
163
162
|
const tool = new MatrixTool();
|
|
164
163
|
await tool.run({
|
|
165
164
|
coordinates: [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
[-122.42, 37.78],
|
|
166
|
+
[-122.45, 37.91],
|
|
167
|
+
[-122.48, 37.73]
|
|
169
168
|
],
|
|
170
169
|
profile: 'walking',
|
|
171
170
|
sources: '1'
|
|
@@ -180,9 +179,9 @@ describe('MatrixTool', () => {
|
|
|
180
179
|
const tool = new MatrixTool();
|
|
181
180
|
const result = await tool.run({
|
|
182
181
|
coordinates: [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
[-122.42, 37.78],
|
|
183
|
+
[-122.45, 37.91],
|
|
184
|
+
[-122.48, 37.73]
|
|
186
185
|
],
|
|
187
186
|
profile: 'driving',
|
|
188
187
|
annotations: 'distance,duration',
|
|
@@ -208,8 +207,8 @@ describe('MatrixTool', () => {
|
|
|
208
207
|
const tool = new MatrixTool();
|
|
209
208
|
const result = await tool.run({
|
|
210
209
|
coordinates: [
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
[-122.42, 37.78],
|
|
211
|
+
[-122.45, 37.91]
|
|
213
212
|
],
|
|
214
213
|
profile: 'walking'
|
|
215
214
|
});
|
|
@@ -223,7 +222,7 @@ describe('MatrixTool', () => {
|
|
|
223
222
|
it('validates driving-traffic profile coordinate limit', async () => {
|
|
224
223
|
const mockFetch = setupFetch();
|
|
225
224
|
const tool = new MatrixTool();
|
|
226
|
-
const coordinates = Array(11).fill(
|
|
225
|
+
const coordinates = Array(11).fill([-122.42, 37.78]);
|
|
227
226
|
const result = await tool.run({
|
|
228
227
|
coordinates,
|
|
229
228
|
profile: 'driving-traffic'
|
|
@@ -247,23 +246,20 @@ describe('MatrixTool', () => {
|
|
|
247
246
|
});
|
|
248
247
|
it('validates coordinates - minimum count', async () => {
|
|
249
248
|
const result = await tool.run({
|
|
250
|
-
coordinates: [
|
|
249
|
+
coordinates: [[-122.42, 37.78]],
|
|
251
250
|
profile: 'driving'
|
|
252
251
|
});
|
|
253
252
|
expect(result.is_error).toBe(true);
|
|
254
253
|
// Test direct error message using Zod validation from schema
|
|
255
254
|
await expect(async () => {
|
|
256
255
|
await tool['inputSchema'].parseAsync({
|
|
257
|
-
coordinates: [
|
|
256
|
+
coordinates: [[-122.42, 37.78]],
|
|
258
257
|
profile: 'driving'
|
|
259
258
|
});
|
|
260
259
|
}).rejects.toThrow('At least two coordinate pairs are required.');
|
|
261
260
|
});
|
|
262
261
|
it('validates coordinates - maximum count for regular profiles', async () => {
|
|
263
|
-
const coordinates = Array(26).fill(
|
|
264
|
-
longitude: -122.42,
|
|
265
|
-
latitude: 37.78
|
|
266
|
-
});
|
|
262
|
+
const coordinates = Array(26).fill([-122.42, 37.78]);
|
|
267
263
|
const result = await tool.run({
|
|
268
264
|
coordinates,
|
|
269
265
|
profile: 'driving'
|
|
@@ -280,8 +276,8 @@ describe('MatrixTool', () => {
|
|
|
280
276
|
it('validates coordinate bounds', async () => {
|
|
281
277
|
const invalidLongitude = await tool.run({
|
|
282
278
|
coordinates: [
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
[-190, 37.78],
|
|
280
|
+
[-122.45, 37.91]
|
|
285
281
|
],
|
|
286
282
|
profile: 'driving'
|
|
287
283
|
});
|
|
@@ -290,16 +286,16 @@ describe('MatrixTool', () => {
|
|
|
290
286
|
await expect(async () => {
|
|
291
287
|
await tool['inputSchema'].parseAsync({
|
|
292
288
|
coordinates: [
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
[-190, 37.78],
|
|
290
|
+
[-122.45, 37.91]
|
|
295
291
|
],
|
|
296
292
|
profile: 'driving'
|
|
297
293
|
});
|
|
298
294
|
}).rejects.toThrow('Longitude must be between -180 and 180 degrees');
|
|
299
295
|
const invalidLatitude = await tool.run({
|
|
300
296
|
coordinates: [
|
|
301
|
-
|
|
302
|
-
|
|
297
|
+
[-122.42, 37.78],
|
|
298
|
+
[-122.45, 95]
|
|
303
299
|
],
|
|
304
300
|
profile: 'driving'
|
|
305
301
|
});
|
|
@@ -308,8 +304,8 @@ describe('MatrixTool', () => {
|
|
|
308
304
|
await expect(async () => {
|
|
309
305
|
await tool['inputSchema'].parseAsync({
|
|
310
306
|
coordinates: [
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
[-122.42, 37.78],
|
|
308
|
+
[-122.45, 95]
|
|
313
309
|
],
|
|
314
310
|
profile: 'driving'
|
|
315
311
|
});
|
|
@@ -318,9 +314,9 @@ describe('MatrixTool', () => {
|
|
|
318
314
|
it('validates approaches parameter length', async () => {
|
|
319
315
|
const result = await tool.run({
|
|
320
316
|
coordinates: [
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
[-122.42, 37.78],
|
|
318
|
+
[-122.45, 37.91],
|
|
319
|
+
[-122.48, 37.73]
|
|
324
320
|
],
|
|
325
321
|
profile: 'driving',
|
|
326
322
|
approaches: 'curb;unrestricted' // Only 2 for 3 coordinates
|
|
@@ -330,9 +326,9 @@ describe('MatrixTool', () => {
|
|
|
330
326
|
await expect(async () => {
|
|
331
327
|
await tool['execute']({
|
|
332
328
|
coordinates: [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
[-122.42, 37.78],
|
|
330
|
+
[-122.45, 37.91],
|
|
331
|
+
[-122.48, 37.73]
|
|
336
332
|
],
|
|
337
333
|
profile: 'driving',
|
|
338
334
|
approaches: 'curb;unrestricted'
|
|
@@ -342,8 +338,8 @@ describe('MatrixTool', () => {
|
|
|
342
338
|
it('validates approaches parameter values', async () => {
|
|
343
339
|
const result = await tool.run({
|
|
344
340
|
coordinates: [
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
[-122.42, 37.78],
|
|
342
|
+
[-122.45, 37.91]
|
|
347
343
|
],
|
|
348
344
|
profile: 'driving',
|
|
349
345
|
approaches: 'curb;invalid' // 'invalid' is not allowed
|
|
@@ -353,8 +349,8 @@ describe('MatrixTool', () => {
|
|
|
353
349
|
await expect(async () => {
|
|
354
350
|
await tool['execute']({
|
|
355
351
|
coordinates: [
|
|
356
|
-
|
|
357
|
-
|
|
352
|
+
[-122.42, 37.78],
|
|
353
|
+
[-122.45, 37.91]
|
|
358
354
|
],
|
|
359
355
|
profile: 'driving',
|
|
360
356
|
approaches: 'curb;invalid'
|
|
@@ -364,9 +360,9 @@ describe('MatrixTool', () => {
|
|
|
364
360
|
it('validates bearings parameter length', async () => {
|
|
365
361
|
const result = await tool.run({
|
|
366
362
|
coordinates: [
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
363
|
+
[-122.42, 37.78],
|
|
364
|
+
[-122.45, 37.91],
|
|
365
|
+
[-122.48, 37.73]
|
|
370
366
|
],
|
|
371
367
|
profile: 'driving',
|
|
372
368
|
bearings: '45,90;120,45' // Only 2 for 3 coordinates
|
|
@@ -376,9 +372,9 @@ describe('MatrixTool', () => {
|
|
|
376
372
|
await expect(async () => {
|
|
377
373
|
await tool['execute']({
|
|
378
374
|
coordinates: [
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
375
|
+
[-122.42, 37.78],
|
|
376
|
+
[-122.45, 37.91],
|
|
377
|
+
[-122.48, 37.73]
|
|
382
378
|
],
|
|
383
379
|
profile: 'driving',
|
|
384
380
|
bearings: '45,90;120,45'
|
|
@@ -388,8 +384,8 @@ describe('MatrixTool', () => {
|
|
|
388
384
|
it('validates bearings parameter format', async () => {
|
|
389
385
|
const result = await tool.run({
|
|
390
386
|
coordinates: [
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
[-122.42, 37.78],
|
|
388
|
+
[-122.45, 37.91]
|
|
393
389
|
],
|
|
394
390
|
profile: 'driving',
|
|
395
391
|
bearings: '45,90;invalid'
|
|
@@ -399,8 +395,8 @@ describe('MatrixTool', () => {
|
|
|
399
395
|
await expect(async () => {
|
|
400
396
|
await tool['execute']({
|
|
401
397
|
coordinates: [
|
|
402
|
-
|
|
403
|
-
|
|
398
|
+
[-122.42, 37.78],
|
|
399
|
+
[-122.45, 37.91]
|
|
404
400
|
],
|
|
405
401
|
profile: 'driving',
|
|
406
402
|
bearings: '45,90;invalid'
|
|
@@ -410,8 +406,8 @@ describe('MatrixTool', () => {
|
|
|
410
406
|
it('validates bearings parameter angle range', async () => {
|
|
411
407
|
const result = await tool.run({
|
|
412
408
|
coordinates: [
|
|
413
|
-
|
|
414
|
-
|
|
409
|
+
[-122.42, 37.78],
|
|
410
|
+
[-122.45, 37.91]
|
|
415
411
|
],
|
|
416
412
|
profile: 'driving',
|
|
417
413
|
bearings: '400,90;120,45' // 400 is > 360
|
|
@@ -421,8 +417,8 @@ describe('MatrixTool', () => {
|
|
|
421
417
|
await expect(async () => {
|
|
422
418
|
await tool['execute']({
|
|
423
419
|
coordinates: [
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
[-122.42, 37.78],
|
|
421
|
+
[-122.45, 37.91]
|
|
426
422
|
],
|
|
427
423
|
profile: 'driving',
|
|
428
424
|
bearings: '400,90;120,45'
|
|
@@ -432,8 +428,8 @@ describe('MatrixTool', () => {
|
|
|
432
428
|
it('validates bearings parameter degrees range', async () => {
|
|
433
429
|
const result = await tool.run({
|
|
434
430
|
coordinates: [
|
|
435
|
-
|
|
436
|
-
|
|
431
|
+
[-122.42, 37.78],
|
|
432
|
+
[-122.45, 37.91]
|
|
437
433
|
],
|
|
438
434
|
profile: 'driving',
|
|
439
435
|
bearings: '45,200;120,45' // 200 is > 180
|
|
@@ -443,8 +439,8 @@ describe('MatrixTool', () => {
|
|
|
443
439
|
await expect(async () => {
|
|
444
440
|
await tool['execute']({
|
|
445
441
|
coordinates: [
|
|
446
|
-
|
|
447
|
-
|
|
442
|
+
[-122.42, 37.78],
|
|
443
|
+
[-122.45, 37.91]
|
|
448
444
|
],
|
|
449
445
|
profile: 'driving',
|
|
450
446
|
bearings: '45,200;120,45'
|
|
@@ -454,8 +450,8 @@ describe('MatrixTool', () => {
|
|
|
454
450
|
it('validates sources parameter indices', async () => {
|
|
455
451
|
const result = await tool.run({
|
|
456
452
|
coordinates: [
|
|
457
|
-
|
|
458
|
-
|
|
453
|
+
[-122.42, 37.78],
|
|
454
|
+
[-122.45, 37.91]
|
|
459
455
|
],
|
|
460
456
|
profile: 'driving',
|
|
461
457
|
sources: '0;2' // 2 is out of bounds
|
|
@@ -465,8 +461,8 @@ describe('MatrixTool', () => {
|
|
|
465
461
|
await expect(async () => {
|
|
466
462
|
await tool['execute']({
|
|
467
463
|
coordinates: [
|
|
468
|
-
|
|
469
|
-
|
|
464
|
+
[-122.42, 37.78],
|
|
465
|
+
[-122.45, 37.91]
|
|
470
466
|
],
|
|
471
467
|
profile: 'driving',
|
|
472
468
|
sources: '0;2'
|
|
@@ -476,8 +472,8 @@ describe('MatrixTool', () => {
|
|
|
476
472
|
it('validates destinations parameter indices', async () => {
|
|
477
473
|
const result = await tool.run({
|
|
478
474
|
coordinates: [
|
|
479
|
-
|
|
480
|
-
|
|
475
|
+
[-122.42, 37.78],
|
|
476
|
+
[-122.45, 37.91]
|
|
481
477
|
],
|
|
482
478
|
profile: 'driving',
|
|
483
479
|
destinations: '3' // 3 is out of bounds
|
|
@@ -487,8 +483,8 @@ describe('MatrixTool', () => {
|
|
|
487
483
|
await expect(async () => {
|
|
488
484
|
await tool['execute']({
|
|
489
485
|
coordinates: [
|
|
490
|
-
|
|
491
|
-
|
|
486
|
+
[-122.42, 37.78],
|
|
487
|
+
[-122.45, 37.91]
|
|
492
488
|
],
|
|
493
489
|
profile: 'driving',
|
|
494
490
|
destinations: '3'
|
|
@@ -498,8 +494,8 @@ describe('MatrixTool', () => {
|
|
|
498
494
|
it('validates destinations parameter index negative', async () => {
|
|
499
495
|
const result = await tool.run({
|
|
500
496
|
coordinates: [
|
|
501
|
-
|
|
502
|
-
|
|
497
|
+
[-122.42, 37.78],
|
|
498
|
+
[-122.45, 37.91]
|
|
503
499
|
],
|
|
504
500
|
profile: 'driving',
|
|
505
501
|
destinations: '-1'
|
|
@@ -509,8 +505,8 @@ describe('MatrixTool', () => {
|
|
|
509
505
|
await expect(async () => {
|
|
510
506
|
await tool['execute']({
|
|
511
507
|
coordinates: [
|
|
512
|
-
|
|
513
|
-
|
|
508
|
+
[-122.42, 37.78],
|
|
509
|
+
[-122.45, 37.91]
|
|
514
510
|
],
|
|
515
511
|
profile: 'driving',
|
|
516
512
|
destinations: '-1'
|
|
@@ -523,8 +519,8 @@ describe('MatrixTool', () => {
|
|
|
523
519
|
});
|
|
524
520
|
await tool.run({
|
|
525
521
|
coordinates: [
|
|
526
|
-
|
|
527
|
-
|
|
522
|
+
[-122.42, 37.78],
|
|
523
|
+
[-122.45, 37.91]
|
|
528
524
|
],
|
|
529
525
|
profile: 'driving',
|
|
530
526
|
sources: 'all'
|
|
@@ -538,8 +534,8 @@ describe('MatrixTool', () => {
|
|
|
538
534
|
});
|
|
539
535
|
await tool.run({
|
|
540
536
|
coordinates: [
|
|
541
|
-
|
|
542
|
-
|
|
537
|
+
[-122.42, 37.78],
|
|
538
|
+
[-122.45, 37.91]
|
|
543
539
|
],
|
|
544
540
|
profile: 'driving',
|
|
545
541
|
destinations: 'all'
|
|
@@ -560,9 +556,9 @@ describe('MatrixTool', () => {
|
|
|
560
556
|
});
|
|
561
557
|
const result = await tool.run({
|
|
562
558
|
coordinates: [
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
559
|
+
[-122.42, 37.78],
|
|
560
|
+
[-122.46, 37.9],
|
|
561
|
+
[-122.48, 37.73]
|
|
566
562
|
],
|
|
567
563
|
profile: 'driving',
|
|
568
564
|
approaches: 'curb;;unrestricted'
|
|
@@ -577,9 +573,9 @@ describe('MatrixTool', () => {
|
|
|
577
573
|
});
|
|
578
574
|
const result = await tool.run({
|
|
579
575
|
coordinates: [
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
576
|
+
[-122.42, 37.78],
|
|
577
|
+
[-122.46, 37.9],
|
|
578
|
+
[-122.45, 37.91]
|
|
583
579
|
],
|
|
584
580
|
profile: 'driving',
|
|
585
581
|
bearings: '45,90;;120,45'
|
|
@@ -594,9 +590,9 @@ describe('MatrixTool', () => {
|
|
|
594
590
|
});
|
|
595
591
|
const resultWithSuccess1 = await tool.run({
|
|
596
592
|
coordinates: [
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
593
|
+
[-122.42, 37.78],
|
|
594
|
+
[-122.45, 37.91],
|
|
595
|
+
[-122.48, 37.73]
|
|
600
596
|
],
|
|
601
597
|
profile: 'driving',
|
|
602
598
|
approaches: 'curb;;unrestricted'
|
|
@@ -604,8 +600,8 @@ describe('MatrixTool', () => {
|
|
|
604
600
|
expect(resultWithSuccess1.is_error).toBe(false);
|
|
605
601
|
const resultWithSuccess2 = await tool.run({
|
|
606
602
|
coordinates: [
|
|
607
|
-
|
|
608
|
-
|
|
603
|
+
[-122.42, 37.78],
|
|
604
|
+
[-122.45, 37.91]
|
|
609
605
|
],
|
|
610
606
|
profile: 'driving',
|
|
611
607
|
approaches: 'curb;'
|
|
@@ -618,9 +614,9 @@ describe('MatrixTool', () => {
|
|
|
618
614
|
});
|
|
619
615
|
const result = await tool.run({
|
|
620
616
|
coordinates: [
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
617
|
+
[-122.42, 37.78],
|
|
618
|
+
[-122.45, 37.91],
|
|
619
|
+
[-122.48, 37.73]
|
|
624
620
|
],
|
|
625
621
|
profile: 'driving',
|
|
626
622
|
sources: '1',
|
|
@@ -632,9 +628,9 @@ describe('MatrixTool', () => {
|
|
|
632
628
|
await expect(async () => {
|
|
633
629
|
await tool['execute']({
|
|
634
630
|
coordinates: [
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
631
|
+
[-122.42, 37.78],
|
|
632
|
+
[-122.45, 37.91],
|
|
633
|
+
[-122.48, 37.73]
|
|
638
634
|
],
|
|
639
635
|
profile: 'driving',
|
|
640
636
|
sources: '1',
|
|
@@ -648,8 +644,8 @@ describe('MatrixTool', () => {
|
|
|
648
644
|
});
|
|
649
645
|
await tool.run({
|
|
650
646
|
coordinates: [
|
|
651
|
-
|
|
652
|
-
|
|
647
|
+
[-122.42, 37.78],
|
|
648
|
+
[-122.45, 37.91]
|
|
653
649
|
],
|
|
654
650
|
profile: 'driving',
|
|
655
651
|
sources: '0',
|
|
@@ -665,8 +661,8 @@ describe('MatrixTool', () => {
|
|
|
665
661
|
});
|
|
666
662
|
await tool.run({
|
|
667
663
|
coordinates: [
|
|
668
|
-
|
|
669
|
-
|
|
664
|
+
[-122.42, 37.78],
|
|
665
|
+
[-122.45, 37.91]
|
|
670
666
|
],
|
|
671
667
|
profile: 'driving',
|
|
672
668
|
annotations: 'duration,distance'
|
|
@@ -678,8 +674,8 @@ describe('MatrixTool', () => {
|
|
|
678
674
|
});
|
|
679
675
|
await tool.run({
|
|
680
676
|
coordinates: [
|
|
681
|
-
|
|
682
|
-
|
|
677
|
+
[-122.42, 37.78],
|
|
678
|
+
[-122.45, 37.91]
|
|
683
679
|
],
|
|
684
680
|
profile: 'driving',
|
|
685
681
|
annotations: 'distance,duration'
|
|
@@ -698,10 +694,7 @@ describe('MatrixTool', () => {
|
|
|
698
694
|
const mockFetch = setupFetch({
|
|
699
695
|
json: () => Promise.resolve(sampleMatrixResponse)
|
|
700
696
|
});
|
|
701
|
-
const coordinates = Array.from({ length: 25 }, (_, i) =>
|
|
702
|
-
longitude: -122.42 + i * 0.01,
|
|
703
|
-
latitude: 37.78 + i * 0.01
|
|
704
|
-
}));
|
|
697
|
+
const coordinates = Array.from({ length: 25 }, (_, i) => [-122.42 + i * 0.01, 37.78 + i * 0.01]);
|
|
705
698
|
const result = await tool.run({
|
|
706
699
|
coordinates,
|
|
707
700
|
profile: 'driving'
|
|
@@ -713,10 +706,7 @@ describe('MatrixTool', () => {
|
|
|
713
706
|
const mockFetch = setupFetch({
|
|
714
707
|
json: () => Promise.resolve(sampleMatrixResponse)
|
|
715
708
|
});
|
|
716
|
-
const coordinates = Array.from({ length: 10 }, (_, i) =>
|
|
717
|
-
longitude: -122.42 + i * 0.01,
|
|
718
|
-
latitude: 37.78 + i * 0.01
|
|
719
|
-
}));
|
|
709
|
+
const coordinates = Array.from({ length: 10 }, (_, i) => [-122.42 + i * 0.01, 37.78 + i * 0.01]);
|
|
720
710
|
const result = await tool.run({
|
|
721
711
|
coordinates,
|
|
722
712
|
profile: 'driving-traffic'
|
|
@@ -726,10 +716,7 @@ describe('MatrixTool', () => {
|
|
|
726
716
|
});
|
|
727
717
|
it('rejects 11 coordinates for driving-traffic profile', async () => {
|
|
728
718
|
const mockFetch = setupFetch();
|
|
729
|
-
const coordinates = Array.from({ length: 11 }, (_, i) =>
|
|
730
|
-
longitude: -122.42 + i * 0.01,
|
|
731
|
-
latitude: 37.78 + i * 0.01
|
|
732
|
-
}));
|
|
719
|
+
const coordinates = Array.from({ length: 11 }, (_, i) => [-122.42 + i * 0.01, 37.78 + i * 0.01]);
|
|
733
720
|
const result = await tool.run({
|
|
734
721
|
coordinates,
|
|
735
722
|
profile: 'driving-traffic'
|
|
@@ -757,8 +744,8 @@ describe('MatrixTool', () => {
|
|
|
757
744
|
});
|
|
758
745
|
const result = await tool.run({
|
|
759
746
|
coordinates: [
|
|
760
|
-
|
|
761
|
-
|
|
747
|
+
[-122.42, 37.78],
|
|
748
|
+
[-122.45, 37.91]
|
|
762
749
|
],
|
|
763
750
|
profile: 'driving-traffic'
|
|
764
751
|
});
|
|
@@ -772,8 +759,8 @@ describe('MatrixTool', () => {
|
|
|
772
759
|
});
|
|
773
760
|
const result = await tool.run({
|
|
774
761
|
coordinates: [
|
|
775
|
-
|
|
776
|
-
|
|
762
|
+
[-122.42, 37.78],
|
|
763
|
+
[-122.45, 37.91]
|
|
777
764
|
],
|
|
778
765
|
profile: 'driving'
|
|
779
766
|
});
|
|
@@ -787,8 +774,8 @@ describe('MatrixTool', () => {
|
|
|
787
774
|
});
|
|
788
775
|
const result = await tool.run({
|
|
789
776
|
coordinates: [
|
|
790
|
-
|
|
791
|
-
|
|
777
|
+
[-122.42, 37.78],
|
|
778
|
+
[-122.45, 37.91]
|
|
792
779
|
],
|
|
793
780
|
profile: 'walking'
|
|
794
781
|
});
|
|
@@ -802,8 +789,8 @@ describe('MatrixTool', () => {
|
|
|
802
789
|
});
|
|
803
790
|
const result = await tool.run({
|
|
804
791
|
coordinates: [
|
|
805
|
-
|
|
806
|
-
|
|
792
|
+
[-122.42, 37.78],
|
|
793
|
+
[-122.45, 37.91]
|
|
807
794
|
],
|
|
808
795
|
profile: 'cycling'
|
|
809
796
|
});
|