@opentripplanner/core-utils 9.0.0-alpha.3 → 9.0.0-alpha.30

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/query-gen.js CHANGED
@@ -1,13 +1,47 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
 
3
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
5
 
5
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; }
6
7
 
7
- /* eslint-disable @typescript-eslint/no-unused-vars */
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: "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: "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: "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: "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: "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: "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: 1587, 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\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\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}\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}\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\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}\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\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 PlanQuery = { 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: "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: [] }, { 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: "intermediatePlaces" }, value: { kind: "Variable", name: { kind: "Name", value: "intermediatePlaces" } } }, { 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: "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: 4347, 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 $intermediatePlaces: [InputCoordinates] \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 intermediatePlaces: $intermediatePlaces\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 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
+ /**
12
+ * Mode Settings can contain additional modes to add to the query,
13
+ * this function extracts those additional modes from the settings
14
+ * and returns them in an array.
15
+ * @param modeSettings List of mode settings with values populated
16
+ * @returns Additional transport modes to add to query
17
+ */
18
+ export function extractAdditionalModes(modeSettings, enabledModes) {
19
+ return modeSettings.reduce(function (prev, cur) {
20
+ // First, ensure that the mode associated with this setting is even enabled
21
+ if (!enabledModes.map(function (m) {
22
+ return m.mode;
23
+ }).includes(cur.applicableMode)) {
24
+ return prev;
25
+ } // In checkboxes (or submode checkboxes), mode must be enabled and have a transport mode in it
26
+
27
+
28
+ if ((cur.type === "CHECKBOX" || cur.type === "SUBMODE") && cur.addTransportMode && cur.value) {
29
+ return [].concat(_toConsumableArray(prev), [cur.addTransportMode]);
30
+ }
31
+
32
+ if (cur.type === "DROPDOWN") {
33
+ var transportMode = cur.options.find(function (o) {
34
+ return o.value === cur.value;
35
+ }).addTransportMode;
36
+
37
+ if (transportMode) {
38
+ return [].concat(_toConsumableArray(prev), [transportMode]);
39
+ }
40
+ }
41
+
42
+ return prev;
43
+ }, []);
44
+ }
11
45
  /**
12
46
  * Generates every possible mathematical subset of the input TransportModes.
13
47
  * Uses code from:
@@ -15,6 +49,7 @@ var PlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition",
15
49
  * @param array Array of input transport modes
16
50
  * @returns 2D array representing every possible subset of transport modes from input
17
51
  */
52
+
18
53
  function combinations(array) {
19
54
  if (!array) return [];
20
55
  return (// eslint-disable-next-line no-bitwise
@@ -26,6 +61,11 @@ function combinations(array) {
26
61
  })
27
62
  );
28
63
  }
64
+ /**
65
+ * This constant maps all the transport mode to a broader mode type,
66
+ * which is used to determine the valid combinations of modes used in query generation.
67
+ */
68
+
29
69
 
30
70
  export var SIMPLIFICATIONS = {
31
71
  AIRPLANE: "TRANSIT",
@@ -44,92 +84,125 @@ export var SIMPLIFICATIONS = {
44
84
  TRAM: "TRANSIT",
45
85
  TRANSIT: "TRANSIT",
46
86
  WALK: "WALK"
47
- };
87
+ }; // Inclusion of "TRANSIT" alone automatically implies "WALK" in OTP
88
+
89
+ var VALID_COMBOS = [["WALK"], ["PERSONAL"], ["TRANSIT", "SHARED"], ["WALK", "SHARED"], ["TRANSIT"], ["TRANSIT", "PERSONAL"], ["TRANSIT", "CAR"]];
90
+ var BANNED_TOGETHER = ["SCOOTER", "BICYCLE", "CAR"];
48
91
  export var TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
49
92
  return SIMPLIFICATIONS[mode] === "TRANSIT" && mode !== "TRANSIT";
50
93
  });
51
94
  export var TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
52
95
  return SIMPLIFICATIONS[mode] === "TRANSIT";
53
96
  });
54
- export function generateCombinations(params) {
55
- var VALID_COMBOS = [["WALK"], ["PERSONAL"], ["TRANSIT", "SHARED"], ["WALK", "SHARED"], ["TRANSIT"], ["TRANSIT", "PERSONAL"], ["TRANSIT", "CAR"]];
56
- var BANNED_TOGETHER = ["SCOOTER", "BICYCLE"]; // List of the transit submodes that are included in the input params
57
-
58
- var queryTransitSubmodes = params.modes.filter(function (mode) {
59
- return TRANSIT_SUBMODES.includes(mode.mode);
60
- }).map(function (mode) {
61
- return mode.mode;
62
- });
63
- return combinations(params.modes).filter(function (combo) {
64
- if (combo.length === 0) return false; // All current qualifiers currently simplify to "SHARED"
65
97
 
66
- var simplifiedModes = Array.from(new Set(combo.map(function (c) {
67
- return c.qualifier ? "SHARED" : SIMPLIFICATIONS[c.mode];
68
- }))); // Ensure that if we have one transit mode, then we include ALL transit modes
98
+ function isCombinationValid(combo, queryTransitSubmodes) {
99
+ if (combo.length === 0) return false; // All current qualifiers currently simplify to "SHARED"
69
100
 
70
- if (simplifiedModes.includes("TRANSIT")) {
71
- var flatModes = combo.map(function (m) {
72
- return m.mode;
73
- });
101
+ var simplifiedModes = Array.from(new Set(combo.map(function (c) {
102
+ return c.qualifier ? "SHARED" : SIMPLIFICATIONS[c.mode];
103
+ }))); // Ensure that if we have one transit mode, then we include ALL transit modes
74
104
 
75
- if (combo.reduce(function (prev, cur) {
76
- if (queryTransitSubmodes.includes(cur.mode)) {
77
- return prev - 1;
78
- }
105
+ if (simplifiedModes.includes("TRANSIT")) {
106
+ // Don't allow TRANSIT along with any other submodes
107
+ if (queryTransitSubmodes.length && combo.find(function (c) {
108
+ return c.mode === "TRANSIT";
109
+ })) {
110
+ return false;
111
+ }
79
112
 
80
- return prev;
81
- }, queryTransitSubmodes.length) !== 0) {
82
- return false;
113
+ if (combo.reduce(function (prev, cur) {
114
+ if (queryTransitSubmodes.includes(cur.mode)) {
115
+ return prev - 1;
83
116
  }
84
- } // OTP doesn't support multiple non-walk modes
85
117
 
118
+ return prev;
119
+ }, queryTransitSubmodes.length) !== 0) {
120
+ return false;
121
+ } // Continue to the other checks
86
122
 
87
- if (BANNED_TOGETHER.every(function (m) {
88
- return combo.find(function (c) {
89
- return c.mode === m;
90
- });
91
- })) return false;
92
- return !!VALID_COMBOS.find(function (vc) {
93
- return simplifiedModes.every(function (m) {
94
- return vc.includes(m);
95
- }) && vc.every(function (m) {
96
- return simplifiedModes.includes(m);
97
- });
123
+ } // OTP doesn't support multiple non-walk modes
124
+
125
+
126
+ if (BANNED_TOGETHER.filter(function (m) {
127
+ return combo.find(function (c) {
128
+ return c.mode === m;
98
129
  });
99
- }) // create new filter that removes subTransit modes from appearing on their own
100
- // ONLY IF there's multiple of them!
101
- .map(function (combo) {
102
- return _objectSpread(_objectSpread({}, params), {}, {
103
- modes: combo
130
+ }).length > 1) {
131
+ return false;
132
+ }
133
+
134
+ return !!VALID_COMBOS.find(function (vc) {
135
+ return simplifiedModes.every(function (m) {
136
+ return vc.includes(m);
137
+ }) && vc.every(function (m) {
138
+ return simplifiedModes.includes(m);
104
139
  });
105
140
  });
106
- } // eslint-disable-next-line import/prefer-default-export
141
+ }
142
+ /**
143
+ * Generates a list of queries for OTP to get a comprehensive
144
+ * set of results based on the modes input.
145
+ * @param params OTP Query Params
146
+ * @returns Set of parameters to generate queries
147
+ */
107
148
 
108
- export function generateOtp2Query(params) {
109
- var to = params.to,
110
- from = params.from,
111
- modeSettings = params.modeSettings; // This extracts the values from the mode settings to key value pairs
112
149
 
150
+ export function generateCombinations(params) {
151
+ var completeModeList = [].concat(_toConsumableArray(extractAdditionalModes(params.modeSettings, params.modes)), _toConsumableArray(params.modes)); // List of the transit *submodes* that are included in the input params
152
+
153
+ var queryTransitSubmodes = completeModeList.filter(function (mode) {
154
+ return TRANSIT_SUBMODES.includes(mode.mode);
155
+ }).map(function (mode) {
156
+ return mode.mode;
157
+ });
158
+ return combinations(completeModeList).filter(function (combo) {
159
+ return isCombinationValid(combo, queryTransitSubmodes);
160
+ }).map(function (combo) {
161
+ return _objectSpread(_objectSpread({}, params), {}, {
162
+ modes: combo
163
+ });
164
+ });
165
+ }
166
+ export function generateOtp2Query(_ref) {
167
+ var arriveBy = _ref.arriveBy,
168
+ banned = _ref.banned,
169
+ date = _ref.date,
170
+ from = _ref.from,
171
+ modes = _ref.modes,
172
+ modeSettings = _ref.modeSettings,
173
+ numItineraries = _ref.numItineraries,
174
+ preferred = _ref.preferred,
175
+ time = _ref.time,
176
+ to = _ref.to;
177
+ // This extracts the values from the mode settings to key value pairs
113
178
  var modeSettingValues = modeSettings.reduce(function (prev, cur) {
179
+ if (cur.type === "SLIDER" && cur.inverseKey) {
180
+ prev[cur.inverseKey] = cur.high - cur.value + cur.low;
181
+ }
182
+
114
183
  prev[cur.key] = cur.value;
115
184
  return prev;
116
185
  }, {});
117
- var walkReluctance = modeSettingValues.walkReluctance,
118
- wheelchair = modeSettingValues.wheelchair,
119
- bikeReluctance = modeSettingValues.bikeReluctance,
186
+ var bikeReluctance = modeSettingValues.bikeReluctance,
120
187
  carReluctance = modeSettingValues.carReluctance,
121
- allowBikeRental = modeSettingValues.allowBikeRental;
188
+ walkReluctance = modeSettingValues.walkReluctance,
189
+ wheelchair = modeSettingValues.wheelchair;
122
190
  return {
123
191
  query: print(PlanQuery),
124
192
  variables: {
125
- fromPlace: [from.lat, from.lon].join(","),
126
- toPlace: [to.lat, to.lon].join(","),
127
- modes: params.modes,
128
- allowBikeRental: allowBikeRental,
129
- walkReluctance: walkReluctance,
130
- wheelchair: wheelchair,
193
+ arriveBy: arriveBy,
194
+ banned: banned,
131
195
  bikeReluctance: bikeReluctance,
132
- carReluctance: carReluctance
196
+ carReluctance: carReluctance,
197
+ date: date,
198
+ fromPlace: "".concat(from.name, "::").concat(from.lat, ",").concat(from.lon, "}"),
199
+ modes: modes,
200
+ numItineraries: numItineraries,
201
+ preferred: preferred,
202
+ time: time,
203
+ toPlace: "".concat(to.name, "::").concat(to.lat, ",").concat(to.lon, "}"),
204
+ walkReluctance: walkReluctance,
205
+ wheelchair: wheelchair
133
206
  }
134
207
  };
135
208
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query-gen.ts"],"names":["print","combinations","array","Array","length","fill","map","e1","i","filter","e2","j","SIMPLIFICATIONS","AIRPLANE","BICYCLE","BUS","CABLE_CAR","CAR","FERRY","FLEX","FUNICULAR","GONDOLA","RAIL","SCOOTER","SUBWAY","TRAM","TRANSIT","WALK","TRANSIT_SUBMODES","Object","keys","mode","TRANSIT_SUBMODES_AND_TRANSIT","generateCombinations","params","VALID_COMBOS","BANNED_TOGETHER","queryTransitSubmodes","modes","includes","combo","simplifiedModes","from","Set","c","qualifier","flatModes","m","reduce","prev","cur","every","find","vc","generateOtp2Query","to","modeSettings","modeSettingValues","key","value","walkReluctance","wheelchair","bikeReluctance","carReluctance","allowBikeRental","query","PlanQuery","variables","fromPlace","lat","lon","join","toPlace"],"mappings":";;;;;;AAAA;AACA,SAASA,KAAT,QAAsB,SAAtB;;;AAgBA;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,KAGGC,GAHH,CAGO,UAACC,EAAD,EAAKC,CAAL;AAAA,aAAWN,KAAK,CAACO,MAAN,CAAa,UAACC,EAAD,EAAKC,CAAL;AAAA,eAAWH,CAAC,GAAI,KAAKG,CAArB;AAAA,OAAb,CAAX;AAAA,KAHP;AAFF;AAOD;;AACD,OAAO,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,QAAQ,EAAE,SADmB;AAE7BC,EAAAA,OAAO,EAAE,UAFoB;AAG7BC,EAAAA,GAAG,EAAE,SAHwB;AAI7BC,EAAAA,SAAS,EAAE,SAJkB;AAK7B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AAEjE,KAAK,CAACkE,SAAD,CADP;AAELC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAE,CAAC1B,IAAI,CAAC2B,GAAN,EAAW3B,IAAI,CAAC4B,GAAhB,EAAqBC,IAArB,CAA0B,GAA1B,CADF;AAETC,MAAAA,OAAO,EAAE,CAACjB,EAAE,CAACc,GAAJ,EAASd,EAAE,CAACe,GAAZ,EAAiBC,IAAjB,CAAsB,GAAtB,CAFA;AAGTjC,MAAAA,KAAK,EAAEJ,MAAM,CAACI,KAHL;AAIT0B,MAAAA,eAAe,EAAfA,eAJS;AAKTJ,MAAAA,cAAc,EAAdA,cALS;AAMTC,MAAAA,UAAU,EAAVA,UANS;AAOTC,MAAAA,cAAc,EAAdA,cAPS;AAQTC,MAAAA,aAAa,EAAbA;AARS;AAFN,GAAP;AAaD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\nimport { LonLatOutput } from \"@conveyal/lonlat\";\nimport PlanQuery from \"./planQuery.graphql\";\n\ntype OTPQueryParams = {\n to: LonLatOutput;\n from: LonLatOutput;\n modes: Array<TransportMode>;\n modeSettings: ModeSetting[];\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}\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\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\nexport function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {\n const VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n ];\n\n const BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\"];\n\n // List of the transit submodes that are included in the input params\n const queryTransitSubmodes = params.modes\n .filter(mode => TRANSIT_SUBMODES.includes(mode.mode))\n .map(mode => mode.mode);\n\n return (\n combinations(params.modes)\n .filter(combo => {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(\n combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode]))\n )\n );\n\n // Ensure that if we have one transit mode, then we include ALL transit modes\n if (simplifiedModes.includes(\"TRANSIT\")) {\n const flatModes = combo.map(m => m.mode);\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 }\n\n // OTP doesn't support multiple non-walk modes\n if (BANNED_TOGETHER.every(m => combo.find(c => c.mode === m)))\n 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 // create new filter that removes subTransit modes from appearing on their own\n // ONLY IF there's multiple of them!\n .map(combo => ({ ...params, modes: combo }))\n );\n}\n\n// eslint-disable-next-line import/prefer-default-export\nexport function generateOtp2Query(params: OTPQueryParams): any {\n const { to, from, modeSettings } = params;\n\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 walkReluctance,\n wheelchair,\n bikeReluctance,\n carReluctance,\n allowBikeRental\n } = modeSettingValues;\n\n return {\n query: print(PlanQuery),\n variables: {\n fromPlace: [from.lat, from.lon].join(\",\"),\n toPlace: [to.lat, to.lon].join(\",\"),\n modes: params.modes,\n allowBikeRental,\n walkReluctance,\n wheelchair,\n bikeReluctance,\n carReluctance\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","modeSettingValues","inverseKey","high","low","key","bikeReluctance","carReluctance","walkReluctance","wheelchair","query","PlanQuery","variables","fromP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AA,MAAM,EAANA,MAFS;AAGTW,MAAAA,cAAc,EAAdA,cAHS;AAITC,MAAAA,aAAa,EAAbA,aAJS;AAKTX,MAAAA,IAAI,EAAJA,IALS;AAMTiB,MAAAA,SAAS,YAAK9B,IAAI,CAAC+B,IAAV,eAAmB/B,IAAI,CAACgC,GAAxB,cAA+BhC,IAAI,CAACiC,GAApC,MANA;AAOTxB,MAAAA,KAAK,EAALA,KAPS;AAQTK,MAAAA,cAAc,EAAdA,cARS;AASTC,MAAAA,SAAS,EAATA,SATS;AAUTC,MAAAA,IAAI,EAAJA,IAVS;AAWTkB,MAAAA,OAAO,YAAKjB,EAAE,CAACc,IAAR,eAAiBd,EAAE,CAACe,GAApB,cAA2Bf,EAAE,CAACgB,GAA9B,MAXE;AAYTR,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 PlanQuery 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 (or submode 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\nexport function generateOtp2Query({\n arriveBy,\n banned,\n date,\n from,\n modes,\n modeSettings,\n numItineraries,\n preferred,\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 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"}
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const RouteColorTester: {
7
+ (): JSX.Element;
8
+ parameters: {
9
+ a11y: {
10
+ config: {
11
+ rules: {
12
+ id: string;
13
+ reviewOnFail: boolean;
14
+ }[];
15
+ };
16
+ };
17
+ storyshots: {
18
+ disable: boolean;
19
+ };
20
+ };
21
+ };
22
+ //# sourceMappingURL=core-utils.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-utils.story.d.ts","sourceRoot":"","sources":["../src/core-utils.story.tsx"],"names":[],"mappings":";;;;AAIA,wBAEE;AA2BF,eAAO,MAAM,gBAAgB;QAAO,WAAW;;;;;;;;;;;;;;CAkB9C,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.RouteColorTester = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const route_1 = require("./route");
33
+ exports.default = {
34
+ title: "core-utils"
35
+ };
36
+ const ColorBlock = styled_components_1.default.div `
37
+ background: ${props => props.bg};
38
+ color: ${props => props.fg};
39
+ padding: 10px;
40
+ `;
41
+ const ColorBlockWrapper = styled_components_1.default.div `
42
+ display: flex;
43
+ flex-direction: row;
44
+ gap: 10px;
45
+ `;
46
+ const ColorPair = ({ fg, bg }) => {
47
+ return (react_1.default.createElement(ColorBlockWrapper, null,
48
+ react_1.default.createElement(ColorBlock, { fg: fg, bg: bg }, "Provided color pair"),
49
+ react_1.default.createElement(ColorBlock, { fg: (0, route_1.getMostReadableTextColor)(bg, fg), bg: bg }, "Corrected color pair")));
50
+ };
51
+ const RouteColorTester = () => {
52
+ const [fg, setFg] = (0, react_1.useState)("#333333");
53
+ const [bg, setBg] = (0, react_1.useState)("#cbeb55");
54
+ return (react_1.default.createElement(react_1.default.Fragment, null,
55
+ react_1.default.createElement(ColorPair, { bg: bg, fg: fg }),
56
+ react_1.default.createElement("label", null,
57
+ "Foreground Color",
58
+ react_1.default.createElement("input", { onChange: e => setFg(e.target.value), type: "color", value: fg })),
59
+ react_1.default.createElement("label", null,
60
+ "Background Color",
61
+ react_1.default.createElement("input", { onChange: e => setBg(e.target.value), type: "color", value: bg }))));
62
+ };
63
+ exports.RouteColorTester = RouteColorTester;
64
+ // Disable color contrast checking for the uncorrected color pairs.
65
+ exports.RouteColorTester.parameters = {
66
+ a11y: { config: { rules: [{ id: "color-contrast", reviewOnFail: true }] } },
67
+ storyshots: { disable: true }
68
+ };
69
+ //# sourceMappingURL=core-utils.story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-utils.story.js","sourceRoot":"","sources":["../src/core-utils.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,0EAAuC;AACvC,mCAAmD;AAEnD,kBAAe;IACb,KAAK,EAAE,YAAY;CACpB,CAAC;AAEF,MAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,CAA4B;gBACzC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;WACtB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;;CAE3B,CAAC;AAEF,MAAM,iBAAiB,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;CAInC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAA8B,EAAE,EAAE;IAC3D,OAAO,CACL,8BAAC,iBAA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ary, LatLngArray, Leg, Money, Place, Step, Stop, TncFare } from "@opentripplanner/types";
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;
@@ -67,7 +68,7 @@ export declare function toSentenceCase(str: string): string;
67
68
  * Derive the company string based on mode and network associated with leg.
68
69
  */
69
70
  export declare function getCompanyFromLeg(leg: Leg): string;
70
- export declare function getItineraryBounds(itinerary: Itinerary): LatLngArray[];
71
+ export declare function getItineraryBounds(itinerary: ItineraryOnlyLegsRequired): LatLngArray[];
71
72
  /**
72
73
  * Return a coords object that encloses the given leg's geometry.
73
74
  */
@@ -96,9 +97,9 @@ export declare function getCompanyForNetwork(networkString: string, companies?:
96
97
  * @param {Array<object>} [companies=[]] An optional list of the companies config.
97
98
  * @return {string} A label for use in presentation on a website.
98
99
  */
99
- export declare function getCompaniesLabelFromNetworks(networks: string[], companies?: Company[]): string;
100
+ export declare function getCompaniesLabelFromNetworks(networks: string | string[], companies?: Company[]): string;
100
101
  export declare function getTNCLocation(leg: Leg, type: string): string;
101
- export declare function calculatePhysicalActivity(itinerary: Itinerary): {
102
+ export declare function calculatePhysicalActivity(itinerary: ItineraryOnlyLegsRequired): {
102
103
  bikeDuration: number;
103
104
  caloriesBurned: number;
104
105
  walkDuration: number;
@@ -108,22 +109,14 @@ export declare function calculatePhysicalActivity(itinerary: Itinerary): {
108
109
  * these values and currency info.
109
110
  * It is assumed that the same currency is used for all TNC legs.
110
111
  */
111
- export declare function calculateTncFares(itinerary: Itinerary): TncFare;
112
+ export declare function calculateTncFares(itinerary: ItineraryOnlyLegsRequired): TncFare;
112
113
  /**
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
- /**
121
- * @param {itinerary} itinerary OTP trip itinierary
122
- * @param {carbonIntensity} carbonIntensity carbon intensity by mode in grams/meter
114
+ * @param {itinerary} itinerary OTP trip itinierary, only legs is required.
115
+ * @param {carbonIntensity} carbonIntensity carbon intensity by mode in grams/meter
123
116
  * @param {units} units units to be used in return value
124
117
  * @return Amount of carbon in chosen unit
125
118
  */
126
- export declare function calculateEmissions(itinerary: Itinerary, carbonIntensity?: Record<string, number>, units?: string): number;
119
+ export declare function calculateEmissions(itinerary: ItineraryOnlyLegsRequired, carbonIntensity?: Record<string, number>, units?: MassUnitOption): number;
127
120
  /**
128
121
  * Returns the user-facing stop id to display for a stop or place, using the following priority:
129
122
  * 1. stop code,
@@ -131,4 +124,23 @@ export declare function calculateEmissions(itinerary: Itinerary, carbonIntensity
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;
127
+ /**
128
+ * Extracts useful data from the fare products on a leg, such as the leg cost and transfer info.
129
+ * @param leg Leg with fare products (must have used getLegsWithFares)
130
+ * @param category Rider category
131
+ * @param container Fare container (cash, electronic)
132
+ * @returns Object containing price as well as the transfer discount amount, if a transfer was used.
133
+ */
134
+ export declare function getLegCost(leg: Leg, mediumId: string, riderCategoryId: string): {
135
+ price: Money;
136
+ transferAmount?: Money | undefined;
137
+ };
138
+ /**
139
+ * Returns the total itinerary cost for a given set of legs.
140
+ * @param legs Itinerary legs with fare products (must have used getLegsWithFares)
141
+ * @param category Rider category (youth, regular, senior)
142
+ * @param container Fare container (cash, electronic)
143
+ * @returns Money object for the total itinerary cost.
144
+ */
145
+ export declare function getItineraryCost(legs: Leg[], category: string, container: string): Money;
134
146
  //# sourceMappingURL=itinerary.d.ts.map