diff --git a/changelog.d/1804-route-steps-export.md b/changelog.d/1804-route-steps-export.md new file mode 100644 index 0000000000..1a46ffe2f1 --- /dev/null +++ b/changelog.d/1804-route-steps-export.md @@ -0,0 +1,3 @@ +- `gods-eye-view/sources/places` also exports `normalizeOsrmSteps`, so a route + proxy outside Core's dev server can serve the same turn-by-turn steps the + Directions layer asks for with `steps=1`. diff --git a/docs/CODE-BOUNDARIES.md b/docs/CODE-BOUNDARIES.md index 44d598cac2..2852bea0ae 100644 --- a/docs/CODE-BOUNDARIES.md +++ b/docs/CODE-BOUNDARIES.md @@ -150,7 +150,8 @@ Google credentials are resolved on each request; the default uses the existing server-key precedence, and callers may supply `resolveApiKey`. `gods-eye-view/sources/places` exports portable response projections for Google -place results and OSRM route results/profile aliases. These functions own no +place results and OSRM route results/profile aliases, and the turn-by-turn +steps (`normalizeOsrmSteps`) Core's `/api/route` serves with `steps=1`. These functions own no credentials, requests, caches, environment loading, or rendering. Callers retain input validation and upstream-response acceptance. The boundary check builds this entry independently and rejects Node imports. diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index e30b88c068..82eb04879a 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -423,7 +423,11 @@ }, "place-payloads": { "exports": ["./sources/places"], - "modules": ["src/data/placeProviderPayloads.js"], + "modules": [ + "src/data/placeProviderPayloads.js", + "src/data/routeSteps.js", + "src/data/distanceFormat.js" + ], "external": [] }, "space-providers": { diff --git a/src/data/placeProviderPayloads.js b/src/data/placeProviderPayloads.js index 8adf935a91..a0d7690899 100644 --- a/src/data/placeProviderPayloads.js +++ b/src/data/placeProviderPayloads.js @@ -1,3 +1,7 @@ +// Turn-by-turn steps for a route, as Core's own /api/route serves them with +// steps=1; a hosted route proxy projects the same OSRM answer. +export { normalizeOsrmSteps } from './routeSteps.js'; + function placeContextPriority(types) { const typeSet = new Set(types); if (typeSet.has('historical_landmark') || typeSet.has('monument')) return 100; diff --git a/src/tooling/placeProviders.test.mjs b/src/tooling/placeProviders.test.mjs index 06553f7bc3..f68532c795 100644 --- a/src/tooling/placeProviders.test.mjs +++ b/src/tooling/placeProviders.test.mjs @@ -11,7 +11,11 @@ import { _routeInflightCountForTest, _setRouteUpstreamIntervalForTest, } from '../../server/providers/places/routes.js'; -import { ROUTE_STEPS_MAX } from '../../src/data/routeSteps.js'; +import { + ROUTE_STEPS_MAX, + normalizeOsrmSteps, +} from '../../src/data/routeSteps.js'; +import * as placePayloads from '../../src/data/placeProviderPayloads.js'; import { projectNearbyPlaces, projectTextSearchPlaces, @@ -465,6 +469,10 @@ test('identical concurrent route requests make one upstream call', async (t) => ); }); +test('the place payloads entry serves the same route steps the dev proxy does', () => { + assert.equal(placePayloads.normalizeOsrmSteps, normalizeOsrmSteps); +}); + test('a pathological maneuver count is bounded before it reaches the browser', async (t) => { _resetRouteUpstreamForTest(); const request = install(installRouteMiddleware);