@opentripplanner/core-utils 9.0.0-alpha.8 → 9.0.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/esm/itinerary.js +91 -61
- package/esm/itinerary.js.map +1 -1
- package/esm/query-gen.js +27 -6
- package/esm/query-gen.js.map +1 -1
- package/lib/itinerary.d.ts +6 -18
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +95 -60
- package/lib/itinerary.js.map +1 -1
- package/lib/query-gen.d.ts +24 -3
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +26 -6
- package/lib/query-gen.js.map +1 -1
- package/package.json +4 -3
- package/src/__tests__/__mocks__/fare-products-itinerary.json +1283 -0
- package/src/__tests__/__mocks__/tnc-itinerary.json +34 -18
- package/src/__tests__/itinerary.js +74 -28
- package/src/__tests__/query-params.ts +24 -0
- package/src/itinerary.ts +97 -69
- package/src/otpSchema.json +10781 -0
- package/src/planQuery.graphql +222 -132
- package/src/query-gen.ts +57 -16
- package/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/__snapshots__/itinerary.js.snap +0 -5
package/esm/query-gen.js
CHANGED
|
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
7
|
|
|
8
8
|
import { print } from "graphql";
|
|
9
|
-
var PlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "PlanQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "toPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "modes" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "TransportMode" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "date" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "intermediatePlaces" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "InputCoordinates" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "preferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputPreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "toPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "toPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "transportModes" }, value: { kind: "Variable", name: { kind: "Name", value: "modes" } } }, { kind: "Argument", name: { kind: "Name", value: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }, { kind: "Argument", name: { kind: "Name", value: "bikeReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "carReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "intermediatePlaces" }, value: { kind: "Variable", name: { kind: "Name", value: "intermediatePlaces" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "waitingTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "walkTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realtimeState" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "transitLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "trip" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "timezone" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "legGeometry" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "length" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "points" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "intermediateStops" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopCode" }, name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopId" }, name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locationType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "from" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "Field", name: { kind: "Name", value: "to" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "Field", name: { kind: "Name", value: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "relativeDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "absoluteDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stayOn" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "streetName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "elevationProfile" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevation" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 2445, source: { body: "query PlanQuery(\n\t$fromPlace: String!,\n\t$toPlace: String!,\n\t$modes: [TransportMode],\n\t$time: String,\n\t$date: String,\n\t$wheelchair: Boolean,\n\t$bikeReluctance: Float,\n\t$carReluctance: Float,\n\t$walkReluctance: Float,\n\t$arriveBy: Boolean,\n\t$intermediatePlaces: [InputCoordinates],\n\t$preferred: InputPreferred,\n\t$unpreferred: InputUnpreferred,\n\t$banned: InputBanned,\n) {\n\tplan(\n\t\tfromPlace: $fromPlace\n\t\ttoPlace: $toPlace\n\t\ttransportModes: $modes\n\t\t# Currently only supporting EN locale, used for times and text\n\t\tlocale: \"en\",\n\t\ttime: $time,\n\t\tdate: $date,\n\t\twheelchair: $wheelchair,\n\t\tbikeReluctance: $bikeReluctance,\n\t\tcarReluctance: $carReluctance,\n\t\twalkReluctance: $walkReluctance,\n\t\tarriveBy: $arriveBy,\n\t\tintermediatePlaces: $intermediatePlaces,\n\t\tpreferred: $preferred,\n\t\tunpreferred: $unpreferred,\n\t\tbanned: $banned,\n\t) {\n\t\titineraries {\n\t\t\tduration\n\t\t\tendTime\n\t\t\tstartTime\n\t\t\twaitingTime\n\t\t\twalkTime\n\t\t\tlegs {\n\t\t\t\tdistance\n\t\t\t\tduration\n\t\t\t\tendTime\n\t\t\t\tmode\n\t\t\t\trealTime\n\t\t\t\trealtimeState\t\n\t\t\t\tstartTime\n\t\t\t\ttransitLeg\n\t\t\t\ttrip {\n\t\t\t\t\tid\n\t\t\t\t\tgtfsId\n\t\t\t\t}\n\t\t\t\tagency {\n\t\t\t\t\tname\n\t\t\t\t\tid\n\t\t\t\t\ttimezone\n\t\t\t\t\turl\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tlegGeometry {\n\t\t\t\t\tlength\n\t\t\t\t\tpoints\n\t\t\t\t}\n\t\t\t\tintermediateStops {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tstopCode: code\n\t\t\t\t\tstopId: id\n\t\t\t\t\tlocationType\n\t\t\t\t}\n\t\t\t\troute {\n\t\t\t\t\tshortName\n\t\t\t\t\tcolor\n\t\t\t\t\ttextColor\n\t\t\t\t\tid\n\t\t\t\t\ttype\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tfrom {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tto {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsteps {\n\t\t\t\t\tdistance\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n relativeDirection\n absoluteDirection\n stayOn\n streetName\n area\n alerts{\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t\televationProfile {\n\t\t\t\t\t\tdistance\n\t\t\t\t\t\televation\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
9
|
+
var DefaultPlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "Plan" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "toPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "modes" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "TransportMode" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "date" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "preferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputPreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }, { kind: "Argument", name: { kind: "Name", value: "bikeReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "carReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "numItineraries" }, value: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "toPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "toPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "transportModes" }, value: { kind: "Variable", name: { kind: "Name", value: "modes" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "timezone" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "arrivalDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "departureDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "dropoffType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "fareProducts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "product" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "medium" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "price" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "digits" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "riderCategory" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "Field", name: { kind: "Name", value: "from" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "interlineWithPreviousLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "intermediateStops" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locationType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopCode" }, name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopId" }, name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "legGeometry" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "length" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "points" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "pickupBookingInfo" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "earliestBookingTime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "daysPrior" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "pickupType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realtimeState" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentedBike" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rideHailingEstimate" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrival" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "maxPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "minPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "provider" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "longName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "absoluteDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevationProfile" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevation" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "relativeDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stayOn" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "streetName" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "to" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "transitLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "trip" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrivalStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "departureStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "tripHeadsign" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "waitingTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "walkTime" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "routingErrors" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "inputField" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 4527, source: { body: "query Plan(\n $fromPlace: String! \n $toPlace: String! \n $modes: [TransportMode]\n $time: String\n $date: String\n $wheelchair: Boolean\n $bikeReluctance: Float\n $carReluctance: Float\n $walkReluctance: Float\n $arriveBy: Boolean\n $preferred: InputPreferred\n $unpreferred: InputUnpreferred\n $banned: InputBanned\n $numItineraries: Int\n) {\n plan(\n arriveBy: $arriveBy\n banned: $banned\n bikeReluctance: $bikeReluctance\n carReluctance: $carReluctance\n date: $date\n fromPlace: $fromPlace\n # Currently only supporting EN locale, used for times and text\n locale: \"en\"\n numItineraries: $numItineraries\n preferred: $preferred\n time: $time\n toPlace: $toPlace\n transportModes: $modes\n unpreferred: $unpreferred\n walkReluctance: $walkReluctance\n wheelchair: $wheelchair\n ) {\n itineraries {\n accessibilityScore\n duration\n endTime\n legs {\n accessibilityScore\n agency {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n id\n name\n timezone\n url\n }\n arrivalDelay\n departureDelay\n distance\n dropoffType\n duration\n endTime\n fareProducts {\n id\n product {\n id\n medium {\n id\n name\n }\n name\n price {\n amount\n currency {\n code\n digits\n }\n }\n riderCategory {\n id\n name\n }\n }\n }\n from {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n }\n vertexType\n }\n interlineWithPreviousLeg\n intermediateStops {\n lat\n locationType\n lon\n name\n stopCode: code\n stopId: id\n }\n legGeometry {\n length\n points\n }\n mode\n pickupBookingInfo {\n earliestBookingTime {\n daysPrior\n }\n }\n pickupType\n realTime\n realtimeState\n rentedBike\n rideHailingEstimate {\n arrival\n maxPrice {\n amount\n currency {\n code\n }\n }\n minPrice {\n amount\n currency {\n code\n }\n }\n provider {\n id\n }\n }\n route {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n color\n id\n longName\n shortName\n textColor\n type\n }\n startTime\n steps {\n absoluteDirection\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n area\n distance\n elevationProfile {\n distance\n elevation\n }\n lat\n lon\n relativeDirection\n stayOn\n streetName\n }\n to {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n }\n vertexType\n }\n transitLeg\n trip {\n arrivalStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n departureStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n\n gtfsId\n id\n tripHeadsign\n }\n }\n startTime\n waitingTime\n walkTime\n }\n routingErrors {\n code\n description\n inputField\n }\n }\n}", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Mode Settings can contain additional modes to add to the query,
|
|
@@ -25,7 +25,7 @@ export function extractAdditionalModes(modeSettings, enabledModes) {
|
|
|
25
25
|
} // In checkboxes, mode must be enabled and have a transport mode in it
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
if (cur.type === "CHECKBOX" && cur.addTransportMode && cur.value) {
|
|
28
|
+
if ((cur.type === "CHECKBOX" || cur.type === "SUBMODE") && cur.addTransportMode && cur.value) {
|
|
29
29
|
return [].concat(_toConsumableArray(prev), [cur.addTransportMode]);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -87,7 +87,7 @@ export var SIMPLIFICATIONS = {
|
|
|
87
87
|
}; // Inclusion of "TRANSIT" alone automatically implies "WALK" in OTP
|
|
88
88
|
|
|
89
89
|
var VALID_COMBOS = [["WALK"], ["PERSONAL"], ["TRANSIT", "SHARED"], ["WALK", "SHARED"], ["TRANSIT"], ["TRANSIT", "PERSONAL"], ["TRANSIT", "CAR"]];
|
|
90
|
-
var BANNED_TOGETHER = ["SCOOTER", "BICYCLE"];
|
|
90
|
+
var BANNED_TOGETHER = ["SCOOTER", "BICYCLE", "CAR"];
|
|
91
91
|
export var TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
|
|
92
92
|
return SIMPLIFICATIONS[mode] === "TRANSIT" && mode !== "TRANSIT";
|
|
93
93
|
});
|
|
@@ -123,11 +123,14 @@ function isCombinationValid(combo, queryTransitSubmodes) {
|
|
|
123
123
|
} // OTP doesn't support multiple non-walk modes
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
if (BANNED_TOGETHER.
|
|
126
|
+
if (BANNED_TOGETHER.filter(function (m) {
|
|
127
127
|
return combo.find(function (c) {
|
|
128
128
|
return c.mode === m;
|
|
129
129
|
});
|
|
130
|
-
}))
|
|
130
|
+
}).length > 1) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
131
134
|
return !!VALID_COMBOS.find(function (vc) {
|
|
132
135
|
return simplifiedModes.every(function (m) {
|
|
133
136
|
return vc.includes(m);
|
|
@@ -160,16 +163,31 @@ export function generateCombinations(params) {
|
|
|
160
163
|
});
|
|
161
164
|
});
|
|
162
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Generates a query for OTP GraphQL API based on parameters.
|
|
168
|
+
* @param param0 OTP2 Parameters for the query
|
|
169
|
+
* @param planQuery Override the default query for OTP
|
|
170
|
+
* @returns A fully formed query+variables ready to be sent to GraphQL backend
|
|
171
|
+
*/
|
|
172
|
+
|
|
163
173
|
export function generateOtp2Query(_ref) {
|
|
164
174
|
var arriveBy = _ref.arriveBy,
|
|
175
|
+
banned = _ref.banned,
|
|
165
176
|
date = _ref.date,
|
|
166
177
|
from = _ref.from,
|
|
167
178
|
modes = _ref.modes,
|
|
168
179
|
modeSettings = _ref.modeSettings,
|
|
180
|
+
numItineraries = _ref.numItineraries,
|
|
181
|
+
preferred = _ref.preferred,
|
|
169
182
|
time = _ref.time,
|
|
170
183
|
to = _ref.to;
|
|
184
|
+
var planQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DefaultPlanQuery;
|
|
171
185
|
// This extracts the values from the mode settings to key value pairs
|
|
172
186
|
var modeSettingValues = modeSettings.reduce(function (prev, cur) {
|
|
187
|
+
if (cur.type === "SLIDER" && cur.inverseKey) {
|
|
188
|
+
prev[cur.inverseKey] = cur.high - cur.value + cur.low;
|
|
189
|
+
}
|
|
190
|
+
|
|
173
191
|
prev[cur.key] = cur.value;
|
|
174
192
|
return prev;
|
|
175
193
|
}, {});
|
|
@@ -178,14 +196,17 @@ export function generateOtp2Query(_ref) {
|
|
|
178
196
|
walkReluctance = modeSettingValues.walkReluctance,
|
|
179
197
|
wheelchair = modeSettingValues.wheelchair;
|
|
180
198
|
return {
|
|
181
|
-
query: print(
|
|
199
|
+
query: print(planQuery),
|
|
182
200
|
variables: {
|
|
183
201
|
arriveBy: arriveBy,
|
|
202
|
+
banned: banned,
|
|
184
203
|
bikeReluctance: bikeReluctance,
|
|
185
204
|
carReluctance: carReluctance,
|
|
186
205
|
date: date,
|
|
187
206
|
fromPlace: "".concat(from.name, "::").concat(from.lat, ",").concat(from.lon, "}"),
|
|
188
207
|
modes: modes,
|
|
208
|
+
numItineraries: numItineraries,
|
|
209
|
+
preferred: preferred,
|
|
189
210
|
time: time,
|
|
190
211
|
toPlace: "".concat(to.name, "::").concat(to.lat, ",").concat(to.lon, "}"),
|
|
191
212
|
walkReluctance: walkReluctance,
|
package/esm/query-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query-gen.ts"],"names":["print","extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","transportMode","options","find","o","combinations","array","Array","length","fill","e1","i","filter","e2","j","SIMPLIFICATIONS","AIRPLANE","BICYCLE","BUS","CABLE_CAR","CAR","FERRY","FLEX","FUNICULAR","GONDOLA","RAIL","SCOOTER","SUBWAY","TRAM","TRANSIT","WALK","VALID_COMBOS","BANNED_TOGETHER","TRANSIT_SUBMODES","Object","keys","TRANSIT_SUBMODES_AND_TRANSIT","isCombinationValid","combo","queryTransitSubmodes","simplifiedModes","from","Set","c","qualifier","every","vc","generateCombinations","params","completeModeList","modes","generateOtp2Query","arriveBy","date","time","to","modeSettingValues","key","bikeReluctance","carReluctance","walkReluctance","wheelchair","query","PlanQuery","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;AACA,SAASA,KAAT,QAAsB,SAAtB;;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAT,CACLC,YADK,EAELC,YAFK,EAGY;AACjB,SAAOD,YAAY,CAACE,MAAb,CAAqC,UAACC,IAAD,EAAOC,GAAP,EAAe;AACzD;AACA,QAAI,CAACH,YAAY,CAACI,GAAb,CAAiB,UAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,IAAN;AAAA,KAAlB,EAA8BC,QAA9B,CAAuCJ,GAAG,CAACK,cAA3C,CAAL,EAAiE;AAC/D,aAAON,IAAP;AACD,KAJwD,CAMzD;;;AACA,QAAIC,GAAG,CAACM,IAAJ,KAAa,UAAb,IAA2BN,GAAG,CAACO,gBAA/B,IAAmDP,GAAG,CAACQ,KAA3D,EAAkE;AAChE,0CAAWT,IAAX,IAAiBC,GAAG,CAACO,gBAArB;AACD;;AACD,QAAIP,GAAG,CAACM,IAAJ,KAAa,UAAjB,EAA6B;AAC3B,UAAMG,aAAa,GAAGT,GAAG,CAACU,OAAJ,CAAYC,IAAZ,CAAiB,UAAAC,CAAC;AAAA,eAAIA,CAAC,CAACJ,KAAF,KAAYR,GAAG,CAACQ,KAApB;AAAA,OAAlB,EACnBD,gBADH;;AAEA,UAAIE,aAAJ,EAAmB;AACjB,4CAAWV,IAAX,IAAiBU,aAAjB;AACD;AACF;;AACD,WAAOV,IAAP;AACD,GAlBM,EAkBJ,EAlBI,CAAP;AAmBD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASc,YAAT,CAAsBC,KAAtB,EAAiE;AAC/D,MAAI,CAACA,KAAL,EAAY,OAAO,EAAP;AACZ,SACE;AACA,QAAIC,KAAJ,CAAU,KAAKD,KAAK,CAACE,MAArB,EACGC,IADH,CACQ,IADR,EAEE;AAFF,KAGGhB,GAHH,CAGO,UAACiB,EAAD,EAAKC,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cAAc,EAAdA,cATS;AAUTC,MAAAA,UAAU,EAAVA;AAVS;AAFN,GAAP;AAeD","sourcesContent":["import { LonLatOutput } from \"@conveyal/lonlat\";\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\n\nimport PlanQuery from \"./planQuery.graphql\";\n\ntype OTPQueryParams = {\n arriveBy: boolean;\n date: string;\n from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\n time: string;\n to: LonLatOutput & { name?: string };\n};\n\ntype GraphQLQuery = {\n query: string;\n variables: Record<string, unknown>;\n};\n\n/**\n * Mode Settings can contain additional modes to add to the query,\n * this function extracts those additional modes from the settings\n * and returns them in an array.\n * @param modeSettings List of mode settings with values populated\n * @returns Additional transport modes to add to query\n */\nexport function extractAdditionalModes(\n modeSettings: ModeSetting[],\n enabledModes: TransportMode[]\n): TransportMode[] {\n return modeSettings.reduce<TransportMode[]>((prev, cur) => {\n // First, ensure that the mode associated with this setting is even enabled\n if (!enabledModes.map(m => m.mode).includes(cur.applicableMode)) {\n return prev;\n }\n\n // In checkboxes, mode must be enabled and have a transport mode in it\n if (cur.type === \"CHECKBOX\" && cur.addTransportMode && cur.value) {\n return [...prev, cur.addTransportMode];\n }\n if (cur.type === \"DROPDOWN\") {\n const transportMode = cur.options.find(o => o.value === cur.value)\n .addTransportMode;\n if (transportMode) {\n return [...prev, transportMode];\n }\n }\n return prev;\n }, []);\n}\n\n/**\n * Generates every possible mathematical subset of the input TransportModes.\n * Uses code from:\n * https://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array\n * @param array Array of input transport modes\n * @returns 2D array representing every possible subset of transport modes from input\n */\nfunction combinations(array: TransportMode[]): TransportMode[][] {\n if (!array) return [];\n return (\n // eslint-disable-next-line no-bitwise\n new Array(1 << array.length)\n .fill(null)\n // eslint-disable-next-line no-bitwise\n .map((e1, i) => array.filter((e2, j) => i & (1 << j)))\n );\n}\n\n/**\n * This constant maps all the transport mode to a broader mode type,\n * which is used to determine the valid combinations of modes used in query generation.\n */\nexport const SIMPLIFICATIONS = {\n AIRPLANE: \"TRANSIT\",\n BICYCLE: \"PERSONAL\",\n BUS: \"TRANSIT\",\n CABLE_CAR: \"TRANSIT\",\n CAR: \"CAR\",\n FERRY: \"TRANSIT\",\n FLEX: \"SHARED\", // TODO: this allows FLEX+WALK. Is this reasonable?\n FUNICULAR: \"TRANSIT\",\n GONDOLA: \"TRANSIT\",\n RAIL: \"TRANSIT\",\n SCOOTER: \"PERSONAL\",\n SUBWAY: \"TRANSIT\",\n TRAM: \"TRANSIT\",\n TRANSIT: \"TRANSIT\",\n WALK: \"WALK\"\n};\n\n// Inclusion of \"TRANSIT\" alone automatically implies \"WALK\" in OTP\nconst VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n];\n\nconst BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\"];\n\nexport const TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\" && mode !== \"TRANSIT\"\n);\nexport const TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\"\n);\n\nfunction isCombinationValid(\n combo: TransportMode[],\n queryTransitSubmodes: string[]\n): boolean {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode])))\n );\n\n // Ensure that if we have one transit mode, then we include ALL transit modes\n if (simplifiedModes.includes(\"TRANSIT\")) {\n // Don't allow TRANSIT along with any other submodes\n if (queryTransitSubmodes.length && combo.find(c => c.mode === \"TRANSIT\")) {\n return false;\n }\n\n if (\n combo.reduce((prev, cur) => {\n if (queryTransitSubmodes.includes(cur.mode)) {\n return prev - 1;\n }\n return prev;\n }, queryTransitSubmodes.length) !== 0\n ) {\n return false;\n }\n // Continue to the other checks\n }\n\n // OTP doesn't support multiple non-walk modes\n if (BANNED_TOGETHER.every(m => combo.find(c => c.mode === m))) return false;\n\n return !!VALID_COMBOS.find(\n vc =>\n simplifiedModes.every(m => vc.includes(m)) &&\n vc.every(m => simplifiedModes.includes(m))\n );\n}\n\n/**\n * Generates a list of queries for OTP to get a comprehensive\n * set of results based on the modes input.\n * @param params OTP Query Params\n * @returns Set of parameters to generate queries\n */\nexport function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {\n const completeModeList = [\n ...extractAdditionalModes(params.modeSettings, params.modes),\n ...params.modes\n ];\n\n // List of the transit *submodes* that are included in the input params\n const queryTransitSubmodes = completeModeList\n .filter(mode => TRANSIT_SUBMODES.includes(mode.mode))\n .map(mode => mode.mode);\n\n return combinations(completeModeList)\n .filter(combo => isCombinationValid(combo, queryTransitSubmodes))\n .map(combo => ({ ...params, modes: combo }));\n}\n\nexport function generateOtp2Query({\n arriveBy,\n date,\n from,\n modes,\n modeSettings,\n time,\n to\n}: OTPQueryParams): GraphQLQuery {\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n prev[cur.key] = cur.value;\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n bikeReluctance,\n carReluctance,\n walkReluctance,\n wheelchair\n } = modeSettingValues;\n\n return {\n query: print(PlanQuery),\n variables: {\n arriveBy,\n bikeReluctance,\n carReluctance,\n date,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\n time,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n walkReluctance,\n wheelchair\n }\n };\n}\n"],"file":"query-gen.js"}
|
|
1
|
+
{"version":3,"sources":["../src/query-gen.ts"],"names":["print","extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","transportMode","options","find","o","combinations","array","Array","length","fill","e1","i","filter","e2","j","SIMPLIFICATIONS","AIRPLANE","BICYCLE","BUS","CABLE_CAR","CAR","FERRY","FLEX","FUNICULAR","GONDOLA","RAIL","SCOOTER","SUBWAY","TRAM","TRANSIT","WALK","VALID_COMBOS","BANNED_TOGETHER","TRANSIT_SUBMODES","Object","keys","TRANSIT_SUBMODES_AND_TRANSIT","isCombinationValid","combo","queryTransitSubmodes","simplifiedModes","from","Set","c","qualifier","vc","every","generateCombinations","params","completeModeList","modes","generateOtp2Query","arriveBy","banned","date","numItineraries","preferred","time","to","planQuery","DefaultPlanQuery","modeSettingValues","inverseKey","high","low","key","bikeReluctance","carReluctance","walkReluctance","wheelchair","query","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;AACA,SAASA,KAAT,QAAsB,SAAtB;;;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAT,CACLC,YADK,EAELC,YAFK,EAGY;AACjB,SAAOD,YAAY,CAACE,MAAb,CAAqC,UAACC,IAAD,EAAOC,GAAP,EAAe;AACzD;AACA,QAAI,CAACH,YAAY,CAACI,GAAb,CAAiB,UAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,IAAN;AAAA,KAAlB,EAA8BC,QAA9B,CAAuCJ,GAAG,CAACK,cAA3C,CAAL,EAAiE;AAC/D,aAAON,IAAP;AACD,KAJwD,CAMzD;;;AACA,QACE,CAACC,GAAG,CAACM,IAAJ,KAAa,UAAb,IAA2BN,GAAG,CAACM,IAAJ,KAAa,SAAzC,KACAN,GAAG,CAACO,gBADJ,IAEAP,GAAG,CAACQ,KAHN,EAIE;AACA,0CAAWT,IAAX,IAAiBC,GAAG,CAACO,gBAArB;AACD;;AACD,QAAIP,GAAG,CAACM,IAAJ,KAAa,UAAjB,EAA6B;AAC3B,UAAMG,aAAa,GAAGT,GAAG,C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AWvE,GAAG,CAACQ,KAAf,GAAuBR,GAAG,CAACwE,GAAlD;AACD;;AACDzE,IAAAA,IAAI,CAACC,GAAG,CAACyE,GAAL,CAAJ,GAAgBzE,GAAG,CAACQ,KAApB;AACA,WAAOT,IAAP;AACD,GANyB,EAMvB,EANuB,CAA1B;AAQA,MACE2E,cADF,GAKIL,iBALJ,CACEK,cADF;AAAA,MAEEC,aAFF,GAKIN,iBALJ,CAEEM,aAFF;AAAA,MAGEC,cAHF,GAKIP,iBALJ,CAGEO,cAHF;AAAA,MAIEC,UAJF,GAKIR,iBALJ,CAIEQ,UAJF;AAOA,SAAO;AACLC,IAAAA,KAAK,EAAEpF,KAAK,CAACyE,SAAD,CADP;AAELY,IAAAA,SAAS,EAAE;AACTnB,MAAAA,QAAQ,EAARA,QADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTa,MAAAA,cAAc,EAAdA,cAHS;AAITC,MAAAA,aAAa,EAAbA,aAJS;AAKTb,MAAAA,IAAI,EAAJA,IALS;AAMTkB,MAAAA,SAAS,YAAK/B,IAAI,CAACgC,IAAV,eAAmBhC,IAAI,CAACiC,GAAxB,cAA+BjC,IAAI,CAACkC,GAApC,MANA;AAOTzB,MAAAA,KAAK,EAALA,KAPS;AAQTK,MAAAA,cAAc,EAAdA,cARS;AASTC,MAAAA,SAAS,EAATA,SATS;AAUTC,MAAAA,IAAI,EAAJA,IAVS;AAWTmB,MAAAA,OAAO,YAAKlB,EAAE,CAACe,IAAR,eAAiBf,EAAE,CAACgB,GAApB,cAA2BhB,EAAE,CAACiB,GAA9B,MAXE;AAYTP,MAAAA,cAAc,EAAdA,cAZS;AAaTC,MAAAA,UAAU,EAAVA;AAbS;AAFN,GAAP;AAkBD","sourcesContent":["import { LonLatOutput } from \"@conveyal/lonlat\";\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\n\nimport DefaultPlanQuery from \"./planQuery.graphql\";\n\ntype InputBanned = {\n routes?: string;\n agencies?: string;\n trips?: string;\n stops?: string;\n stopsHard?: string;\n};\n\ntype InputPreferred = {\n routes?: string;\n agencies?: string;\n unpreferredCost?: string;\n};\n\ntype OTPQueryParams = {\n arriveBy: boolean;\n date?: string;\n from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\n time?: string;\n numItineraries?: number;\n to: LonLatOutput & { name?: string };\n banned?: InputBanned;\n preferred?: InputPreferred;\n};\n\ntype GraphQLQuery = {\n query: string;\n variables: Record<string, unknown>;\n};\n\n/**\n * Mode Settings can contain additional modes to add to the query,\n * this function extracts those additional modes from the settings\n * and returns them in an array.\n * @param modeSettings List of mode settings with values populated\n * @returns Additional transport modes to add to query\n */\nexport function extractAdditionalModes(\n modeSettings: ModeSetting[],\n enabledModes: TransportMode[]\n): TransportMode[] {\n return modeSettings.reduce<TransportMode[]>((prev, cur) => {\n // First, ensure that the mode associated with this setting is even enabled\n if (!enabledModes.map(m => m.mode).includes(cur.applicableMode)) {\n return prev;\n }\n\n // In checkboxes, mode must be enabled and have a transport mode in it\n if (\n (cur.type === \"CHECKBOX\" || cur.type === \"SUBMODE\") &&\n cur.addTransportMode &&\n cur.value\n ) {\n return [...prev, cur.addTransportMode];\n }\n if (cur.type === \"DROPDOWN\") {\n const transportMode = cur.options.find(o => o.value === cur.value)\n .addTransportMode;\n if (transportMode) {\n return [...prev, transportMode];\n }\n }\n return prev;\n }, []);\n}\n\n/**\n * Generates every possible mathematical subset of the input TransportModes.\n * Uses code from:\n * https://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array\n * @param array Array of input transport modes\n * @returns 2D array representing every possible subset of transport modes from input\n */\nfunction combinations(array: TransportMode[]): TransportMode[][] {\n if (!array) return [];\n return (\n // eslint-disable-next-line no-bitwise\n new Array(1 << array.length)\n .fill(null)\n // eslint-disable-next-line no-bitwise\n .map((e1, i) => array.filter((e2, j) => i & (1 << j)))\n );\n}\n\n/**\n * This constant maps all the transport mode to a broader mode type,\n * which is used to determine the valid combinations of modes used in query generation.\n */\nexport const SIMPLIFICATIONS = {\n AIRPLANE: \"TRANSIT\",\n BICYCLE: \"PERSONAL\",\n BUS: \"TRANSIT\",\n CABLE_CAR: \"TRANSIT\",\n CAR: \"CAR\",\n FERRY: \"TRANSIT\",\n FLEX: \"SHARED\", // TODO: this allows FLEX+WALK. Is this reasonable?\n FUNICULAR: \"TRANSIT\",\n GONDOLA: \"TRANSIT\",\n RAIL: \"TRANSIT\",\n SCOOTER: \"PERSONAL\",\n SUBWAY: \"TRANSIT\",\n TRAM: \"TRANSIT\",\n TRANSIT: \"TRANSIT\",\n WALK: \"WALK\"\n};\n\n// Inclusion of \"TRANSIT\" alone automatically implies \"WALK\" in OTP\nconst VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n];\n\nconst BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\", \"CAR\"];\n\nexport const TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\" && mode !== \"TRANSIT\"\n);\nexport const TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\"\n);\n\nfunction isCombinationValid(\n combo: TransportMode[],\n queryTransitSubmodes: string[]\n): boolean {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode])))\n );\n\n // Ensure that if we have one transit mode, then we include ALL transit modes\n if (simplifiedModes.includes(\"TRANSIT\")) {\n // Don't allow TRANSIT along with any other submodes\n if (queryTransitSubmodes.length && combo.find(c => c.mode === \"TRANSIT\")) {\n return false;\n }\n\n if (\n combo.reduce((prev, cur) => {\n if (queryTransitSubmodes.includes(cur.mode)) {\n return prev - 1;\n }\n return prev;\n }, queryTransitSubmodes.length) !== 0\n ) {\n return false;\n }\n // Continue to the other checks\n }\n\n // OTP doesn't support multiple non-walk modes\n if (BANNED_TOGETHER.filter(m => combo.find(c => c.mode === m)).length > 1) {\n return false;\n }\n\n return !!VALID_COMBOS.find(\n vc =>\n simplifiedModes.every(m => vc.includes(m)) &&\n vc.every(m => simplifiedModes.includes(m))\n );\n}\n\n/**\n * Generates a list of queries for OTP to get a comprehensive\n * set of results based on the modes input.\n * @param params OTP Query Params\n * @returns Set of parameters to generate queries\n */\nexport function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {\n const completeModeList = [\n ...extractAdditionalModes(params.modeSettings, params.modes),\n ...params.modes\n ];\n\n // List of the transit *submodes* that are included in the input params\n const queryTransitSubmodes = completeModeList\n .filter(mode => TRANSIT_SUBMODES.includes(mode.mode))\n .map(mode => mode.mode);\n\n return combinations(completeModeList)\n .filter(combo => isCombinationValid(combo, queryTransitSubmodes))\n .map(combo => ({ ...params, modes: combo }));\n}\n\n/**\n * Generates a query for OTP GraphQL API based on parameters.\n * @param param0 OTP2 Parameters for the query\n * @param planQuery Override the default query for OTP\n * @returns A fully formed query+variables ready to be sent to GraphQL backend\n */\nexport function generateOtp2Query(\n {\n arriveBy,\n banned,\n date,\n from,\n modes,\n modeSettings,\n numItineraries,\n preferred,\n time,\n to\n }: OTPQueryParams,\n planQuery = DefaultPlanQuery\n): GraphQLQuery {\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n if (cur.type === \"SLIDER\" && cur.inverseKey) {\n prev[cur.inverseKey] = cur.high - cur.value + cur.low;\n }\n prev[cur.key] = cur.value;\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n bikeReluctance,\n carReluctance,\n walkReluctance,\n wheelchair\n } = modeSettingValues;\n\n return {\n query: print(planQuery),\n variables: {\n arriveBy,\n banned,\n bikeReluctance,\n carReluctance,\n date,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\n numItineraries,\n preferred,\n time,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n walkReluctance,\n wheelchair\n }\n };\n}\n"],"file":"query-gen.js"}
|
package/lib/itinerary.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Company, Config, ElevationProfile, FlexBookingInfo,
|
|
1
|
+
import { Company, Config, ElevationProfile, FlexBookingInfo, ItineraryOnlyLegsRequired, LatLngArray, Leg, MassUnitOption, Money, Place, Step, Stop, TncFare } from "@opentripplanner/types";
|
|
2
2
|
export declare const transitModes: string[];
|
|
3
3
|
/**
|
|
4
4
|
* @param {config} config OTP-RR configuration object
|
|
@@ -25,6 +25,7 @@ export declare function isCoordinationRequired(leg: Leg): boolean;
|
|
|
25
25
|
export declare function isFlex(leg: Leg): boolean;
|
|
26
26
|
export declare function isAdvanceBookingRequired(info: FlexBookingInfo): boolean;
|
|
27
27
|
export declare function legDropoffRequiresAdvanceBooking(leg: Leg): boolean;
|
|
28
|
+
export declare function isRideshareLeg(leg: Leg): boolean;
|
|
28
29
|
export declare function isWalk(mode: string): boolean;
|
|
29
30
|
export declare function isBicycle(mode: string): boolean;
|
|
30
31
|
export declare function isBicycleRent(mode: string): boolean;
|
|
@@ -109,14 +110,6 @@ export declare function calculatePhysicalActivity(itinerary: ItineraryOnlyLegsRe
|
|
|
109
110
|
* It is assumed that the same currency is used for all TNC legs.
|
|
110
111
|
*/
|
|
111
112
|
export declare function calculateTncFares(itinerary: ItineraryOnlyLegsRequired): TncFare;
|
|
112
|
-
/**
|
|
113
|
-
* For a given fare component (either total fare or component parts), returns
|
|
114
|
-
* an object with the fare value (in cents).
|
|
115
|
-
*/
|
|
116
|
-
export declare function getTransitFare(fareComponent: Money): {
|
|
117
|
-
currencyCode: string;
|
|
118
|
-
transitFare: number;
|
|
119
|
-
};
|
|
120
113
|
/**
|
|
121
114
|
* @param {itinerary} itinerary OTP trip itinierary, only legs is required.
|
|
122
115
|
* @param {carbonIntensity} carbonIntensity carbon intensity by mode in grams/meter
|
|
@@ -131,12 +124,6 @@ export declare function calculateEmissions(itinerary: ItineraryOnlyLegsRequired,
|
|
|
131
124
|
* 3. stop id, whether null or not (this is the fallback case).
|
|
132
125
|
*/
|
|
133
126
|
export declare function getDisplayedStopId(placeOrStop: Place | Stop): string;
|
|
134
|
-
/**
|
|
135
|
-
* Adds the fare product info to each leg in an itinerary, from the itinerary's fare property
|
|
136
|
-
* @param itinerary Itinerary with legProducts in fare object
|
|
137
|
-
* @returns Itinerary with legs that have fare products attached to them
|
|
138
|
-
*/
|
|
139
|
-
export declare function getLegsWithFares(itinerary: Itinerary): Leg[];
|
|
140
127
|
/**
|
|
141
128
|
* Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.
|
|
142
129
|
* @param leg Leg with fare products (must have used getLegsWithFares)
|
|
@@ -144,9 +131,9 @@ export declare function getLegsWithFares(itinerary: Itinerary): Leg[];
|
|
|
144
131
|
* @param container Fare container (cash, electronic)
|
|
145
132
|
* @returns Object containing price as well as the transfer discount amount, if a transfer was used.
|
|
146
133
|
*/
|
|
147
|
-
export declare function getLegCost(leg: Leg,
|
|
134
|
+
export declare function getLegCost(leg: Leg, mediumId: string, riderCategoryId: string): {
|
|
148
135
|
price?: Money;
|
|
149
|
-
transferAmount?:
|
|
136
|
+
transferAmount?: Money | undefined;
|
|
150
137
|
};
|
|
151
138
|
/**
|
|
152
139
|
* Returns the total itinerary cost for a given set of legs.
|
|
@@ -155,5 +142,6 @@ export declare function getLegCost(leg: Leg, category: string, container: string
|
|
|
155
142
|
* @param container Fare container (cash, electronic)
|
|
156
143
|
* @returns Money object for the total itinerary cost.
|
|
157
144
|
*/
|
|
158
|
-
export declare function getItineraryCost(legs: Leg[],
|
|
145
|
+
export declare function getItineraryCost(legs: Leg[], mediumId: string, riderCategoryId: string): Money | undefined;
|
|
146
|
+
export declare const convertGraphQLResponseToLegacy: (leg: any) => any;
|
|
159
147
|
//# sourceMappingURL=itinerary.d.ts.map
|
package/lib/itinerary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../src/itinerary.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../src/itinerary.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,GAAG,EACH,cAAc,EACd,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACR,MAAM,wBAAwB,CAAC;AAIhC,eAAO,MAAM,YAAY,UAOxB,CAAC;AAEF;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAOxD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEvD;AACD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAKxD;AACD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAExC;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAEvE;AACD,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAElE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEhD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI5C;AAED,wBA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E,KAAK,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,CAmBvD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,GAAG,EAAE,EACX,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,KAAK,GAAG,SAAS,CAanB;AAiBD,eAAO,MAAM,8BAA8B,QAAS,GAAG,KAAG,GA4BxD,CAAC"}
|
package/lib/itinerary.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.isCoordinationRequired = isCoordinationRequired;
|
|
|
12
12
|
exports.isFlex = isFlex;
|
|
13
13
|
exports.isAdvanceBookingRequired = isAdvanceBookingRequired;
|
|
14
14
|
exports.legDropoffRequiresAdvanceBooking = legDropoffRequiresAdvanceBooking;
|
|
15
|
+
exports.isRideshareLeg = isRideshareLeg;
|
|
15
16
|
exports.isWalk = isWalk;
|
|
16
17
|
exports.isBicycle = isBicycle;
|
|
17
18
|
exports.isBicycleRent = isBicycleRent;
|
|
@@ -38,13 +39,11 @@ exports.getCompaniesLabelFromNetworks = getCompaniesLabelFromNetworks;
|
|
|
38
39
|
exports.getTNCLocation = getTNCLocation;
|
|
39
40
|
exports.calculatePhysicalActivity = calculatePhysicalActivity;
|
|
40
41
|
exports.calculateTncFares = calculateTncFares;
|
|
41
|
-
exports.getTransitFare = getTransitFare;
|
|
42
42
|
exports.calculateEmissions = calculateEmissions;
|
|
43
43
|
exports.getDisplayedStopId = getDisplayedStopId;
|
|
44
|
-
exports.getLegsWithFares = getLegsWithFares;
|
|
45
44
|
exports.getLegCost = getLegCost;
|
|
46
45
|
exports.getItineraryCost = getItineraryCost;
|
|
47
|
-
exports.transitModes = void 0;
|
|
46
|
+
exports.convertGraphQLResponseToLegacy = exports.transitModes = void 0;
|
|
48
47
|
|
|
49
48
|
var _polyline = _interopRequireDefault(require("@mapbox/polyline"));
|
|
50
49
|
|
|
@@ -107,6 +106,12 @@ function legDropoffRequiresAdvanceBooking(leg) {
|
|
|
107
106
|
return isAdvanceBookingRequired(leg.dropOffBookingInfo);
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
function isRideshareLeg(leg) {
|
|
110
|
+
var _leg$rideHailingEstim, _leg$rideHailingEstim2;
|
|
111
|
+
|
|
112
|
+
return !!((_leg$rideHailingEstim = leg.rideHailingEstimate) !== null && _leg$rideHailingEstim !== void 0 && (_leg$rideHailingEstim2 = _leg$rideHailingEstim.provider) !== null && _leg$rideHailingEstim2 !== void 0 && _leg$rideHailingEstim2.id);
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
function isWalk(mode) {
|
|
111
116
|
if (!mode) return false;
|
|
112
117
|
return mode === "WALK";
|
|
@@ -225,21 +230,25 @@ function getCompanyFromLeg(leg) {
|
|
|
225
230
|
rentedBike,
|
|
226
231
|
rentedCar,
|
|
227
232
|
rentedVehicle,
|
|
228
|
-
|
|
233
|
+
rideHailingEstimate
|
|
229
234
|
} = leg;
|
|
230
235
|
|
|
231
236
|
if (mode === "CAR" && rentedCar) {
|
|
232
237
|
return from.networks[0];
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
if (mode === "CAR" &&
|
|
236
|
-
return
|
|
240
|
+
if (mode === "CAR" && rideHailingEstimate) {
|
|
241
|
+
return rideHailingEstimate.provider.id;
|
|
237
242
|
}
|
|
238
243
|
|
|
239
244
|
if (mode === "BICYCLE" && rentedBike && from.networks) {
|
|
240
245
|
return from.networks[0];
|
|
241
246
|
}
|
|
242
247
|
|
|
248
|
+
if (from.rentalVehicle) {
|
|
249
|
+
return from.rentalVehicle.network;
|
|
250
|
+
}
|
|
251
|
+
|
|
243
252
|
if ((mode === "MICROMOBILITY" || mode === "SCOOTER") && rentedVehicle && from.networks) {
|
|
244
253
|
return from.networks[0];
|
|
245
254
|
}
|
|
@@ -454,22 +463,21 @@ function calculatePhysicalActivity(itinerary) {
|
|
|
454
463
|
|
|
455
464
|
|
|
456
465
|
function calculateTncFares(itinerary) {
|
|
457
|
-
return itinerary.legs.filter(leg => leg.mode === "CAR" && leg.
|
|
466
|
+
return itinerary.legs.filter(leg => leg.mode === "CAR" && leg.rideHailingEstimate).reduce(({
|
|
458
467
|
maxTNCFare,
|
|
459
468
|
minTNCFare
|
|
460
469
|
}, {
|
|
461
|
-
|
|
470
|
+
rideHailingEstimate
|
|
462
471
|
}) => {
|
|
463
472
|
const {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
} = tncData;
|
|
473
|
+
minPrice,
|
|
474
|
+
maxPrice
|
|
475
|
+
} = rideHailingEstimate;
|
|
468
476
|
return {
|
|
469
477
|
// Assumes a single currency for entire itinerary.
|
|
470
|
-
currencyCode: currency,
|
|
471
|
-
maxTNCFare: maxTNCFare +
|
|
472
|
-
minTNCFare: minTNCFare +
|
|
478
|
+
currencyCode: minPrice.currency.code,
|
|
479
|
+
maxTNCFare: maxTNCFare + maxPrice.amount,
|
|
480
|
+
minTNCFare: minTNCFare + minPrice.amount
|
|
473
481
|
};
|
|
474
482
|
}, {
|
|
475
483
|
currencyCode: null,
|
|
@@ -477,21 +485,6 @@ function calculateTncFares(itinerary) {
|
|
|
477
485
|
minTNCFare: 0
|
|
478
486
|
});
|
|
479
487
|
}
|
|
480
|
-
/**
|
|
481
|
-
* For a given fare component (either total fare or component parts), returns
|
|
482
|
-
* an object with the fare value (in cents).
|
|
483
|
-
*/
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
function getTransitFare(fareComponent) {
|
|
487
|
-
return fareComponent ? {
|
|
488
|
-
currencyCode: fareComponent.currency.currencyCode,
|
|
489
|
-
transitFare: fareComponent.cents
|
|
490
|
-
} : {
|
|
491
|
-
currencyCode: "USD",
|
|
492
|
-
transitFare: 0
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
488
|
/**
|
|
496
489
|
* Sources:
|
|
497
490
|
* - https://www.itf-oecd.org/sites/default/files/docs/environmental-performance-new-mobility.pdf
|
|
@@ -581,26 +574,6 @@ function getDisplayedStopId(placeOrStop) {
|
|
|
581
574
|
|
|
582
575
|
return stopCode || ((_stopId = stopId) === null || _stopId === void 0 ? void 0 : _stopId.split(":")[1]) || stopId;
|
|
583
576
|
}
|
|
584
|
-
/**
|
|
585
|
-
* Adds the fare product info to each leg in an itinerary, from the itinerary's fare property
|
|
586
|
-
* @param itinerary Itinerary with legProducts in fare object
|
|
587
|
-
* @returns Itinerary with legs that have fare products attached to them
|
|
588
|
-
*/
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
function getLegsWithFares(itinerary) {
|
|
592
|
-
return itinerary.legs.map((leg, i) => {
|
|
593
|
-
var _itinerary$fare, _itinerary$fare$legPr;
|
|
594
|
-
|
|
595
|
-
return { ...leg,
|
|
596
|
-
fareProducts: (_itinerary$fare = itinerary.fare) === null || _itinerary$fare === void 0 ? void 0 : (_itinerary$fare$legPr = _itinerary$fare.legProducts) === null || _itinerary$fare$legPr === void 0 ? void 0 : _itinerary$fare$legPr.filter(lp => {
|
|
597
|
-
var _lp$legIndices;
|
|
598
|
-
|
|
599
|
-
return lp === null || lp === void 0 ? void 0 : (_lp$legIndices = lp.legIndices) === null || _lp$legIndices === void 0 ? void 0 : _lp$legIndices.includes(i);
|
|
600
|
-
}).flatMap(lp => lp.products)
|
|
601
|
-
};
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
577
|
/**
|
|
605
578
|
* Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.
|
|
606
579
|
* @param leg Leg with fare products (must have used getLegsWithFares)
|
|
@@ -610,18 +583,22 @@ function getLegsWithFares(itinerary) {
|
|
|
610
583
|
*/
|
|
611
584
|
|
|
612
585
|
|
|
613
|
-
function getLegCost(leg,
|
|
614
|
-
var _relevantFareProducts,
|
|
586
|
+
function getLegCost(leg, mediumId, riderCategoryId) {
|
|
587
|
+
var _relevantFareProducts, _relevantFareProducts2;
|
|
615
588
|
|
|
616
589
|
if (!leg.fareProducts) return {
|
|
617
590
|
price: undefined
|
|
618
591
|
};
|
|
619
|
-
const relevantFareProducts = leg.fareProducts.filter(
|
|
620
|
-
|
|
621
|
-
|
|
592
|
+
const relevantFareProducts = leg.fareProducts.filter(({
|
|
593
|
+
product
|
|
594
|
+
}) => {
|
|
595
|
+
return product.riderCategory.id === riderCategoryId && product.medium.id === mediumId;
|
|
596
|
+
});
|
|
597
|
+
const totalCost = (_relevantFareProducts = relevantFareProducts.find(fp => fp.product.name === "rideCost")) === null || _relevantFareProducts === void 0 ? void 0 : (_relevantFareProducts2 = _relevantFareProducts.product) === null || _relevantFareProducts2 === void 0 ? void 0 : _relevantFareProducts2.price;
|
|
598
|
+
const transferFareProduct = relevantFareProducts.find(fp => fp.product.name === "transfer");
|
|
622
599
|
return {
|
|
623
600
|
price: totalCost,
|
|
624
|
-
transferAmount: transferFareProduct === null || transferFareProduct === void 0 ? void 0 :
|
|
601
|
+
transferAmount: transferFareProduct === null || transferFareProduct === void 0 ? void 0 : transferFareProduct.product.price
|
|
625
602
|
};
|
|
626
603
|
}
|
|
627
604
|
/**
|
|
@@ -633,17 +610,75 @@ function getLegCost(leg, category, container) {
|
|
|
633
610
|
*/
|
|
634
611
|
|
|
635
612
|
|
|
636
|
-
function getItineraryCost(legs,
|
|
637
|
-
|
|
613
|
+
function getItineraryCost(legs, mediumId, riderCategoryId) {
|
|
614
|
+
const legCosts = legs.filter(leg => {
|
|
615
|
+
var _leg$fareProducts;
|
|
616
|
+
|
|
617
|
+
return ((_leg$fareProducts = leg.fareProducts) === null || _leg$fareProducts === void 0 ? void 0 : _leg$fareProducts.length) > 0;
|
|
618
|
+
}).map(leg => getLegCost(leg, mediumId, riderCategoryId).price).filter(cost => cost !== undefined);
|
|
619
|
+
if (legCosts.length === 0) return undefined;
|
|
620
|
+
return legCosts.reduce((prev, cur) => {
|
|
638
621
|
var _prev$currency;
|
|
639
622
|
|
|
640
623
|
return {
|
|
641
|
-
|
|
624
|
+
amount: prev.amount + (cur === null || cur === void 0 ? void 0 : cur.amount) || 0,
|
|
642
625
|
currency: (_prev$currency = prev.currency) !== null && _prev$currency !== void 0 ? _prev$currency : cur === null || cur === void 0 ? void 0 : cur.currency
|
|
643
626
|
};
|
|
644
627
|
}, {
|
|
645
|
-
|
|
628
|
+
amount: 0,
|
|
646
629
|
currency: null
|
|
647
630
|
});
|
|
648
631
|
}
|
|
632
|
+
|
|
633
|
+
const pickupDropoffTypeToOtp1 = otp2Type => {
|
|
634
|
+
switch (otp2Type) {
|
|
635
|
+
case "COORDINATE_WITH_DRIVER":
|
|
636
|
+
return "coordinateWithDriver";
|
|
637
|
+
|
|
638
|
+
case "CALL_AGENCY":
|
|
639
|
+
return "mustPhone";
|
|
640
|
+
|
|
641
|
+
case "SCHEDULED":
|
|
642
|
+
return "scheduled";
|
|
643
|
+
|
|
644
|
+
case "NONE":
|
|
645
|
+
return "none";
|
|
646
|
+
|
|
647
|
+
default:
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
const convertGraphQLResponseToLegacy = leg => {
|
|
653
|
+
var _leg$agency, _leg$agency2, _leg$agency3, _leg$from$stop, _leg$from$stop2, _leg$route, _leg$route2, _leg$route3, _leg$route4, _leg$route5, _leg$route6, _leg$to$stop, _leg$to$stop2, _leg$trip, _leg$trip2;
|
|
654
|
+
|
|
655
|
+
return { ...leg,
|
|
656
|
+
agencyBrandingUrl: (_leg$agency = leg.agency) === null || _leg$agency === void 0 ? void 0 : _leg$agency.url,
|
|
657
|
+
agencyName: (_leg$agency2 = leg.agency) === null || _leg$agency2 === void 0 ? void 0 : _leg$agency2.name,
|
|
658
|
+
agencyUrl: (_leg$agency3 = leg.agency) === null || _leg$agency3 === void 0 ? void 0 : _leg$agency3.url,
|
|
659
|
+
alightRule: pickupDropoffTypeToOtp1(leg.dropoffType),
|
|
660
|
+
boardRule: pickupDropoffTypeToOtp1(leg.pickupType),
|
|
661
|
+
dropOffBookingInfo: {
|
|
662
|
+
latestBookingTime: leg.dropOffBookingInfo
|
|
663
|
+
},
|
|
664
|
+
from: { ...leg.from,
|
|
665
|
+
stopCode: (_leg$from$stop = leg.from.stop) === null || _leg$from$stop === void 0 ? void 0 : _leg$from$stop.code,
|
|
666
|
+
stopId: (_leg$from$stop2 = leg.from.stop) === null || _leg$from$stop2 === void 0 ? void 0 : _leg$from$stop2.gtfsId
|
|
667
|
+
},
|
|
668
|
+
route: (_leg$route = leg.route) === null || _leg$route === void 0 ? void 0 : _leg$route.shortName,
|
|
669
|
+
routeColor: (_leg$route2 = leg.route) === null || _leg$route2 === void 0 ? void 0 : _leg$route2.color,
|
|
670
|
+
routeId: (_leg$route3 = leg.route) === null || _leg$route3 === void 0 ? void 0 : _leg$route3.id,
|
|
671
|
+
routeLongName: (_leg$route4 = leg.route) === null || _leg$route4 === void 0 ? void 0 : _leg$route4.longName,
|
|
672
|
+
routeShortName: (_leg$route5 = leg.route) === null || _leg$route5 === void 0 ? void 0 : _leg$route5.shortName,
|
|
673
|
+
routeTextColor: (_leg$route6 = leg.route) === null || _leg$route6 === void 0 ? void 0 : _leg$route6.textColor,
|
|
674
|
+
to: { ...leg.to,
|
|
675
|
+
stopCode: (_leg$to$stop = leg.to.stop) === null || _leg$to$stop === void 0 ? void 0 : _leg$to$stop.code,
|
|
676
|
+
stopId: (_leg$to$stop2 = leg.to.stop) === null || _leg$to$stop2 === void 0 ? void 0 : _leg$to$stop2.gtfsId
|
|
677
|
+
},
|
|
678
|
+
tripHeadsign: (_leg$trip = leg.trip) === null || _leg$trip === void 0 ? void 0 : _leg$trip.tripHeadsign,
|
|
679
|
+
tripId: (_leg$trip2 = leg.trip) === null || _leg$trip2 === void 0 ? void 0 : _leg$trip2.gtfsId
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
exports.convertGraphQLResponseToLegacy = convertGraphQLResponseToLegacy;
|
|
649
684
|
//# sourceMappingURL=itinerary.js.map
|