diff --git a/src/schemas/shared.ts b/src/schemas/shared.ts index 1e273fc..cd49390 100644 --- a/src/schemas/shared.ts +++ b/src/schemas/shared.ts @@ -38,3 +38,14 @@ export const bboxSchema = z.object({ maxLongitude: z.number().min(-180).max(180), maxLatitude: z.number().min(-90).max(90) }); + +/** + * Zod schema for Mapbox routing profiles. + * Uses the fully-qualified format (e.g., 'mapbox/driving-traffic'). + */ +export const profileSchema = z.enum([ + 'mapbox/driving-traffic', + 'mapbox/driving', + 'mapbox/walking', + 'mapbox/cycling' +]); diff --git a/src/tools/directions-tool/DirectionsTool.input.schema.ts b/src/tools/directions-tool/DirectionsTool.input.schema.ts index d6c1b4a..cf820ee 100644 --- a/src/tools/directions-tool/DirectionsTool.input.schema.ts +++ b/src/tools/directions-tool/DirectionsTool.input.schema.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { z } from 'zod'; -import { coordinateSchema } from '../../schemas/shared.js'; +import { coordinateSchema, profileSchema } from '../../schemas/shared.js'; /** * Validates ISO 8601 date-time formats used by Mapbox Directions API @@ -127,16 +127,15 @@ export const DirectionsInputSchema = z.object({ 'Must include at least 2 coordinate pairs (starting and ending points). ' + 'Up to 25 coordinates total are supported.' ), - routing_profile: z - .enum(['driving-traffic', 'driving', 'walking', 'cycling']) + routing_profile: profileSchema .optional() - .default('driving-traffic') + .default('mapbox/driving-traffic') .describe( 'Routing profile for different modes of transport. Options: \n' + - '- driving-traffic (default): automotive with current traffic conditions\n' + - '- driving: automotive based on typical traffic\n' + - '- walking: pedestrian/hiking\n' + - '- cycling: bicycle' + '- mapbox/driving-traffic (default): automotive with current traffic conditions\n' + + '- mapbox/driving: automotive based on typical traffic\n' + + '- mapbox/walking: pedestrian/hiking\n' + + '- mapbox/cycling: bicycle' ), geometries: z .enum(['none', 'geojson']) diff --git a/src/tools/directions-tool/DirectionsTool.ts b/src/tools/directions-tool/DirectionsTool.ts index c5f1c5d..16fa0bc 100644 --- a/src/tools/directions-tool/DirectionsTool.ts +++ b/src/tools/directions-tool/DirectionsTool.ts @@ -56,8 +56,8 @@ export class DirectionsTool extends MapboxApiBasedTool< ]; const isDrivingProfile = - input.routing_profile === 'driving-traffic' || - input.routing_profile === 'driving'; + input.routing_profile === 'mapbox/driving-traffic' || + input.routing_profile === 'mapbox/driving'; const items = input.exclude.split(',').map((item) => item.trim()); for (const item of items) { @@ -112,8 +112,8 @@ export class DirectionsTool extends MapboxApiBasedTool< } const isDrivingProfile = - input.routing_profile === 'driving-traffic' || - input.routing_profile === 'driving'; + input.routing_profile === 'mapbox/driving-traffic' || + input.routing_profile === 'mapbox/driving'; // Validate depart_at is only used with driving profiles if (input.depart_at && !isDrivingProfile) { @@ -129,7 +129,7 @@ export class DirectionsTool extends MapboxApiBasedTool< } // Validate arrive_by is only used with driving profile (not driving-traffic) - if (input.arrive_by && input.routing_profile !== 'driving') { + if (input.arrive_by && input.routing_profile !== 'mapbox/driving') { return { content: [ { @@ -187,7 +187,7 @@ export class DirectionsTool extends MapboxApiBasedTool< queryParams.append('alternatives', input.alternatives.toString()); // Add annotations parameter - if (input.routing_profile === 'driving-traffic') { + if (input.routing_profile === 'mapbox/driving-traffic') { // congestion is available only when driving queryParams.append('annotations', 'distance,congestion,speed'); } else { @@ -236,7 +236,7 @@ export class DirectionsTool extends MapboxApiBasedTool< queryString += `&exclude=${excludeEncoded}`; } - const url = `${MapboxApiBasedTool.mapboxApiEndpoint}directions/v5/mapbox/${input.routing_profile}/${encodedCoords}?${queryString}`; + const url = `${MapboxApiBasedTool.mapboxApiEndpoint}directions/v5/${input.routing_profile}/${encodedCoords}?${queryString}`; const response = await this.httpRequest(url); diff --git a/src/tools/directions-tool/cleanResponseData.ts b/src/tools/directions-tool/cleanResponseData.ts index c6e8279..6cbefbb 100644 --- a/src/tools/directions-tool/cleanResponseData.ts +++ b/src/tools/directions-tool/cleanResponseData.ts @@ -83,11 +83,10 @@ interface RawDirectionsResponse { } // Cleaned response types (after cleaning) -interface CleanedRoute - extends Omit< - RawRoute, - 'legs' | 'weight_name' | 'weight' | 'duration_typical' | 'weight_typical' - > { +interface CleanedRoute extends Omit< + RawRoute, + 'legs' | 'weight_name' | 'weight' | 'duration_typical' | 'weight_typical' +> { leg_summaries?: string[]; intersecting_admins?: string[]; notifications_summary?: string[]; @@ -116,11 +115,10 @@ interface CleanedWaypoint extends Omit { snap_distance?: number; } -interface CleanedDirectionsResponse - extends Omit< - RawDirectionsResponse, - 'uuid' | 'code' | 'waypoints' | 'routes' - > { +interface CleanedDirectionsResponse extends Omit< + RawDirectionsResponse, + 'uuid' | 'code' | 'waypoints' | 'routes' +> { waypoints?: CleanedWaypoint[]; routes?: CleanedRoute[]; } diff --git a/src/tools/matrix-tool/MatrixTool.input.schema.ts b/src/tools/matrix-tool/MatrixTool.input.schema.ts index c418e8e..98f6ee5 100644 --- a/src/tools/matrix-tool/MatrixTool.input.schema.ts +++ b/src/tools/matrix-tool/MatrixTool.input.schema.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { z } from 'zod'; -import { coordinateSchema } from '../../schemas/shared.js'; +import { coordinateSchema, profileSchema } from '../../schemas/shared.js'; export const MatrixInputSchema = z.object({ coordinates: z @@ -17,15 +17,13 @@ export const MatrixInputSchema = z.object({ 'Must include at least 2 coordinate pairs. ' + 'Up to 25 coordinates total are supported for most profiles (10 for driving-traffic).' ), - profile: z - .enum(['driving-traffic', 'driving', 'walking', 'cycling']) - .describe( - 'Routing profile for different modes of transport. Options: \n' + - '- driving-traffic: automotive with current traffic conditions (limited to 10 coordinates)\n' + - '- driving: automotive based on typical traffic\n' + - '- walking: pedestrian/hiking\n' + - '- cycling: bicycle' - ), + profile: profileSchema.describe( + 'Routing profile for different modes of transport. Options: \n' + + '- mapbox/driving-traffic (default): automotive with current traffic conditions (limited to 10 coordinates)\n' + + '- mapbox/driving: automotive based on typical traffic\n' + + '- mapbox/walking: pedestrian/hiking\n' + + '- mapbox/cycling: bicycle' + ), annotations: z .enum(['duration', 'distance', 'duration,distance', 'distance,duration']) .optional() diff --git a/src/tools/matrix-tool/MatrixTool.ts b/src/tools/matrix-tool/MatrixTool.ts index 37945bf..b381549 100644 --- a/src/tools/matrix-tool/MatrixTool.ts +++ b/src/tools/matrix-tool/MatrixTool.ts @@ -42,7 +42,10 @@ export class MatrixTool extends MapboxApiBasedTool< accessToken: string ): Promise { // Validate input based on profile type - if (input.profile === 'driving-traffic' && input.coordinates.length > 10) { + if ( + input.profile === 'mapbox/driving-traffic' && + input.coordinates.length > 10 + ) { return { content: [ { @@ -273,7 +276,7 @@ export class MatrixTool extends MapboxApiBasedTool< } // Construct the URL for the Matrix API request - const url = `${MapboxApiBasedTool.mapboxApiEndpoint}directions-matrix/v1/mapbox/${input.profile}/${joined}?${queryParams.toString()}`; + const url = `${MapboxApiBasedTool.mapboxApiEndpoint}directions-matrix/v1/${input.profile}/${joined}?${queryParams.toString()}`; // Make the request const response = await this.httpRequest(url); diff --git a/src/tools/resource-reader-tool/ResourceReaderTool.ts b/src/tools/resource-reader-tool/ResourceReaderTool.ts index 7430de5..dc71c56 100644 --- a/src/tools/resource-reader-tool/ResourceReaderTool.ts +++ b/src/tools/resource-reader-tool/ResourceReaderTool.ts @@ -159,9 +159,8 @@ export class ResourceReaderTool extends BaseTool< * Lists all available resource URIs for error messages */ private async listAvailableResources(): Promise { - const { getAllResources } = await import( - '../../resources/resourceRegistry.js' - ); + const { getAllResources } = + await import('../../resources/resourceRegistry.js'); const resources = getAllResources(); return resources.map((r: { uri: string }) => r.uri).join(', '); } diff --git a/src/utils/tracing.ts b/src/utils/tracing.ts index b6d1d99..a7a677b 100644 --- a/src/utils/tracing.ts +++ b/src/utils/tracing.ts @@ -181,9 +181,8 @@ export async function initializeTracing(): Promise { // Console exporter for development (avoid in stdio transport) if (process.env.OTEL_EXPORTER_CONSOLE_ENABLED === 'true') { - const { ConsoleSpanExporter } = await import( - '@opentelemetry/sdk-trace-base' - ); + const { ConsoleSpanExporter } = + await import('@opentelemetry/sdk-trace-base'); exporters.push(new ConsoleSpanExporter()); } diff --git a/test/tools/directions-tool/DirectionsTool.test.ts b/test/tools/directions-tool/DirectionsTool.test.ts index 913c530..888d088 100644 --- a/test/tools/directions-tool/DirectionsTool.test.ts +++ b/test/tools/directions-tool/DirectionsTool.test.ts @@ -63,7 +63,7 @@ describe('DirectionsTool', () => { { longitude: -122.4, latitude: 37.79 }, { longitude: -122.39, latitude: 37.77 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', geometries: 'geojson', alternatives: true, exclude: 'ferry' @@ -259,7 +259,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', exclude: 'toll,motorway,unpaved' }) ).resolves.not.toMatchObject({ @@ -273,7 +273,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving-traffic', + routing_profile: 'mapbox/driving-traffic', exclude: 'tunnel,country_border,state_border' }) ).resolves.not.toMatchObject({ @@ -292,7 +292,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', exclude: 'toll' }) ).resolves.toMatchObject({ @@ -306,7 +306,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', exclude: 'motorway' }) ).resolves.toMatchObject({ @@ -325,7 +325,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', exclude: 'ferry' }) ).resolves.not.toMatchObject({ @@ -339,7 +339,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', exclude: 'ferry' }) ).resolves.not.toMatchObject({ @@ -353,7 +353,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', exclude: 'cash_only_tolls' }) ).resolves.not.toMatchObject({ @@ -372,7 +372,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', exclude: 'point(-73.95 40.75)' }) ).resolves.not.toMatchObject({ @@ -386,7 +386,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', exclude: 'point(-73.95 40.75)' }) ).resolves.toMatchObject({ @@ -400,7 +400,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', exclude: 'point(-73.95 40.75)' }) ).resolves.toMatchObject({ @@ -419,7 +419,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', exclude: 'toll,motorway,ferry,cash_only_tolls,point(-73.95 40.75)' }) ).resolves.not.toMatchObject({ @@ -433,7 +433,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', exclude: 'ferry,toll' }) ).resolves.toMatchObject({ @@ -447,7 +447,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', exclude: 'ferry,cash_only_tolls' }) ).resolves.not.toMatchObject({ @@ -469,7 +469,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', depart_at: validDateTime }) ).resolves.not.toMatchObject({ @@ -488,7 +488,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving-traffic', + routing_profile: 'mapbox/driving-traffic', depart_at: validDateTime }) ).resolves.not.toMatchObject({ @@ -513,7 +513,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', max_height: 4.5, max_width: 2.5, max_weight: 7.8 @@ -534,7 +534,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving-traffic', + routing_profile: 'mapbox/driving-traffic', max_height: 3.2 }) ).resolves.not.toMatchObject({ @@ -556,7 +556,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', max_height: 4.5 }) ).resolves.toMatchObject({ @@ -570,7 +570,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', max_width: 2.0 }) ).resolves.toMatchObject({ @@ -589,7 +589,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', max_height: 15.0 }) ).resolves.toMatchObject({ @@ -603,7 +603,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', max_width: -1.0 }) ).resolves.toMatchObject({ @@ -617,7 +617,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', max_weight: 150.0 }) ).resolves.toMatchObject({ @@ -638,7 +638,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', depart_at: validDateTime }) ).resolves.toMatchObject({ @@ -652,7 +652,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', depart_at: validDateTime }) ).resolves.toMatchObject({ @@ -803,7 +803,7 @@ describe('DirectionsTool', () => { { longitude: -73.989, latitude: 40.733 }, { longitude: -73.979, latitude: 40.743 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: dateTimeWithSeconds }) ).resolves.not.toMatchObject({ @@ -832,7 +832,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: validDateTime }); @@ -854,7 +854,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving-traffic', + routing_profile: 'mapbox/driving-traffic', arrive_by: validDateTime }); @@ -866,7 +866,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'walking', + routing_profile: 'mapbox/walking', arrive_by: validDateTime }); @@ -878,7 +878,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'cycling', + routing_profile: 'mapbox/cycling', arrive_by: validDateTime }); @@ -892,7 +892,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', depart_at: '2025-06-05T09:30:00Z', arrive_by: '2025-06-05T10:30:00Z' }); @@ -908,7 +908,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: '2025-06-05T10:30:00Z' }); @@ -921,7 +921,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: '2025-06-05T10:30:00+02:00' }); @@ -934,7 +934,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: '2025-06-05T10:30' }); @@ -968,7 +968,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: format }); @@ -993,7 +993,7 @@ describe('DirectionsTool', () => { { longitude: -74.1, latitude: 40.7 }, { longitude: -74.2, latitude: 40.8 } ], - routing_profile: 'driving', + routing_profile: 'mapbox/driving', arrive_by: date }); diff --git a/test/tools/matrix-tool/MatrixTool.test.ts b/test/tools/matrix-tool/MatrixTool.test.ts index 7af4427..34ad4c5 100644 --- a/test/tools/matrix-tool/MatrixTool.test.ts +++ b/test/tools/matrix-tool/MatrixTool.test.ts @@ -76,7 +76,7 @@ describe('MatrixTool', () => { { longitude: -74.102094, latitude: 40.692815 }, { longitude: -74.1022094, latitude: 40.792815 } ], - profile: 'walking' + profile: 'mapbox/walking' }); assertHeadersSent(mockHttpRequest); @@ -94,7 +94,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving' + profile: 'mapbox/driving' }); expect(result.isError).toBe(false); @@ -121,7 +121,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', annotations: 'duration,distance' }); @@ -141,7 +141,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;unrestricted;curb' }); @@ -160,7 +160,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;120,45' }); @@ -180,7 +180,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'cycling', + profile: 'mapbox/cycling', destinations: '0;2' }); @@ -200,7 +200,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'walking', + profile: 'mapbox/walking', sources: '1' }); @@ -220,7 +220,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', annotations: 'distance,duration', approaches: 'curb;unrestricted;curb', bearings: '45,90;120,45;180,90', @@ -250,7 +250,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'walking' + profile: 'mapbox/walking' }); expect(result.isError).toBe(true); @@ -270,7 +270,7 @@ describe('MatrixTool', () => { const result = await tool.run({ coordinates, - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }); expect(result.isError).toBe(true); @@ -280,7 +280,7 @@ describe('MatrixTool', () => { const errorResult = await tool['execute']( { coordinates, - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' ); @@ -306,7 +306,7 @@ describe('MatrixTool', () => { it('validates coordinates - minimum count', async () => { const result = await tool.run({ coordinates: [{ longitude: -122.42, latitude: 37.78 }], - profile: 'driving' + profile: 'mapbox/driving' }); expect(result.isError).toBe(true); @@ -315,7 +315,7 @@ describe('MatrixTool', () => { await expect(async () => { await tool['inputSchema'].parseAsync({ coordinates: [{ longitude: -122.42, latitude: 37.78 }], - profile: 'driving' + profile: 'mapbox/driving' }); }).rejects.toThrow('At least two coordinate pairs are required.'); }); @@ -327,7 +327,7 @@ describe('MatrixTool', () => { }); const result = await tool.run({ coordinates, - profile: 'driving' + profile: 'mapbox/driving' }); expect(result.isError).toBe(true); @@ -336,7 +336,7 @@ describe('MatrixTool', () => { await expect(async () => { await tool['inputSchema'].parseAsync({ coordinates, - profile: 'driving' + profile: 'mapbox/driving' }); }).rejects.toThrow( 'Up to 25 coordinate pairs are supported for most profiles (10 for driving-traffic).' @@ -349,7 +349,7 @@ describe('MatrixTool', () => { { longitude: -190, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving' + profile: 'mapbox/driving' }); expect(invalidLongitude.isError).toBe(true); @@ -358,7 +358,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 95 } ], - profile: 'driving' + profile: 'mapbox/driving' }); expect(invalidLatitude.isError).toBe(true); @@ -369,7 +369,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 95 } ], - profile: 'driving' + profile: 'mapbox/driving' }); }).rejects.toThrow('Latitude must be between -90 and 90 degrees'); }); @@ -381,7 +381,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;unrestricted' // Only 2 for 3 coordinates }); @@ -395,7 +395,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;unrestricted' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -416,7 +416,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;invalid' // 'invalid' is not allowed }); @@ -429,7 +429,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;invalid' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -451,7 +451,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;120,45' // Only 2 for 3 coordinates }); @@ -465,7 +465,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;120,45' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -486,7 +486,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;invalid' }); @@ -499,7 +499,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;invalid' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -520,7 +520,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '400,90;120,45' // 400 is > 360 }); @@ -533,7 +533,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '400,90;120,45' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -554,7 +554,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,200;120,45' // 200 is > 180 }); @@ -567,7 +567,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,200;120,45' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -588,7 +588,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: '0;2' // 2 is out of bounds }); @@ -601,7 +601,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: '0;2' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -622,7 +622,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', destinations: '3' // 3 is out of bounds }); @@ -635,7 +635,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', destinations: '3' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -656,7 +656,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', destinations: '-1' }); @@ -669,7 +669,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', destinations: '-1' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' @@ -696,7 +696,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: 'all' }); @@ -716,7 +716,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', destinations: 'all' }); @@ -738,7 +738,7 @@ describe('MatrixTool', () => { { longitude: -122.46, latitude: 37.9 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;;unrestricted' }); @@ -760,7 +760,7 @@ describe('MatrixTool', () => { { longitude: -122.46, latitude: 37.9 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', bearings: '45,90;;120,45' }); @@ -782,7 +782,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;;unrestricted' }); @@ -793,7 +793,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', approaches: 'curb;' }); @@ -811,7 +811,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: '1', destinations: '2' }); @@ -826,7 +826,7 @@ describe('MatrixTool', () => { { longitude: -122.45, latitude: 37.91 }, { longitude: -122.48, latitude: 37.73 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: '1', destinations: '2' }, @@ -852,7 +852,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', sources: '0', destinations: '1' }); @@ -872,7 +872,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', annotations: 'duration,distance' }); const url1 = mockHttpRequest1.mock.calls[0][0]; @@ -888,7 +888,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving', + profile: 'mapbox/driving', annotations: 'distance,duration' }); const url2 = mockHttpRequest2.mock.calls[0][0]; @@ -913,7 +913,7 @@ describe('MatrixTool', () => { ); const result = await tool.run({ coordinates, - profile: 'driving' + profile: 'mapbox/driving' }); expect(result.isError).toBe(false); expect(mockHttpRequest).toHaveBeenCalled(); @@ -933,7 +933,7 @@ describe('MatrixTool', () => { ); const result = await tool.run({ coordinates, - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }); expect(result.isError).toBe(false); expect(mockHttpRequest).toHaveBeenCalled(); @@ -951,7 +951,7 @@ describe('MatrixTool', () => { ); const result = await tool.run({ coordinates, - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }); expect(result.isError).toBe(true); expect(mockHttpRequest).not.toHaveBeenCalled(); @@ -960,7 +960,7 @@ describe('MatrixTool', () => { const trafficErrorResult = await tool['execute']( { coordinates, - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }, 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature' ); @@ -988,7 +988,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving-traffic' + profile: 'mapbox/driving-traffic' }); expect(result.isError).toBe(false); @@ -1008,7 +1008,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'driving' + profile: 'mapbox/driving' }); expect(result.isError).toBe(false); @@ -1028,7 +1028,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'walking' + profile: 'mapbox/walking' }); expect(result.isError).toBe(false); @@ -1048,7 +1048,7 @@ describe('MatrixTool', () => { { longitude: -122.42, latitude: 37.78 }, { longitude: -122.45, latitude: 37.91 } ], - profile: 'cycling' + profile: 'mapbox/cycling' }); expect(result.isError).toBe(false);