mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
fix(client): narrow the route profile and Valhalla answer types, keep the stop check reading the whole log
The built-in profile check returned the open profile key and the run request returned an unnarrowed answer, both of which the client typecheck refused. The new road trip tests asserted with non-null assertions where optional calls do. The graceful stop step piped docker logs into grep -q under pipefail, so grep leaving early after its match could fail the step with SIGPIPE although the server had logged SIGTERM.
This commit is contained in:
@@ -217,7 +217,12 @@ export function parsePluginProfile(profile: string): { pluginId: string; profile
|
||||
|
||||
/** One of the three profiles both engines know, or null for a plugin's own. */
|
||||
function builtInProfile(profile: RouteProfileKey): 'driving' | 'walking' | 'cycling' | null {
|
||||
return profile === 'driving' || profile === 'walking' || profile === 'cycling' ? profile : null
|
||||
switch (profile) {
|
||||
case 'driving': return 'driving'
|
||||
case 'walking': return 'walking'
|
||||
case 'cycling': return 'cycling'
|
||||
default: return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -738,7 +738,8 @@ async function requestRun(
|
||||
): Promise<Omit<ValhallaRun, 'snapped'> | ValhallaNoPath | TooSlow | null> {
|
||||
const body = routeBody(waypoints, profile, avoid, costingOptions, searchFilter)
|
||||
const data = await postRoute(base, body, signal, publicFallback)
|
||||
if (data === NO_PATH || tooSlow(data)) return data
|
||||
if (data === NO_PATH) return NO_PATH
|
||||
if (tooSlow(data)) return data
|
||||
return data === null ? null : runFrom(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user