@opentripplanner/core-utils 8.1.1 → 8.2.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/graphql.d.js +2 -0
- package/esm/graphql.d.js.map +1 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/query-gen.js +190 -0
- package/esm/query-gen.js.map +1 -0
- package/lib/core-utils.story.d.ts +22 -0
- package/lib/core-utils.story.d.ts.map +1 -0
- package/lib/core-utils.story.js +69 -0
- package/lib/core-utils.story.js.map +1 -0
- package/lib/graphql.d.js +2 -0
- package/lib/graphql.d.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/query-gen.d.ts +57 -0
- package/lib/query-gen.d.ts.map +1 -0
- package/lib/query-gen.js +168 -0
- package/lib/query-gen.js.map +1 -0
- package/package.json +4 -3
- package/src/__tests__/query-params.ts +279 -0
- package/src/graphql.d.ts +7 -0
- package/src/index.ts +2 -0
- package/src/planQuery.graphql +146 -0
- package/src/query-gen.ts +209 -0
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/query-params.js +0 -93
- /package/src/__tests__/__snapshots__/{query-params.js.snap → query-params.ts.snap} +0 -0
package/esm/graphql.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"graphql.d.js"}
|
package/esm/index.js
CHANGED
|
@@ -7,11 +7,13 @@ import * as route from "./route";
|
|
|
7
7
|
import * as storage from "./storage";
|
|
8
8
|
import * as time from "./time";
|
|
9
9
|
import * as ui from "./ui";
|
|
10
|
+
import * as queryGen from "./query-gen";
|
|
10
11
|
var core = {
|
|
11
12
|
itinerary: itinerary,
|
|
12
13
|
map: map,
|
|
13
14
|
profile: profile,
|
|
14
15
|
query: query,
|
|
16
|
+
queryGen: queryGen,
|
|
15
17
|
queryParams: queryParams,
|
|
16
18
|
route: route,
|
|
17
19
|
storage: storage,
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["itinerary","map","profile","query","queryParams","route","storage","time","ui","core"],"mappings":"AAAA,OAAO,KAAKA,SAAZ,MAA2B,aAA3B;AACA,OAAO,KAAKC,GAAZ,MAAqB,OAArB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,KAAZ,MAAuB,SAAvB;AACA,OAAO,KAAKC,WAAZ,MAA6B,gBAA7B;AACA,OAAO,KAAKC,KAAZ,MAAuB,SAAvB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,IAAZ,MAAsB,QAAtB;AACA,OAAO,KAAKC,EAAZ,MAAoB,MAApB;AAEA,IAAMC,IAAI,GAAG;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["itinerary","map","profile","query","queryParams","route","storage","time","ui","queryGen","core"],"mappings":"AAAA,OAAO,KAAKA,SAAZ,MAA2B,aAA3B;AACA,OAAO,KAAKC,GAAZ,MAAqB,OAArB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,KAAZ,MAAuB,SAAvB;AACA,OAAO,KAAKC,WAAZ,MAA6B,gBAA7B;AACA,OAAO,KAAKC,KAAZ,MAAuB,SAAvB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,IAAZ,MAAsB,QAAtB;AACA,OAAO,KAAKC,EAAZ,MAAoB,MAApB;AACA,OAAO,KAAKC,QAAZ,MAA0B,aAA1B;AAEA,IAAMC,IAAI,GAAG;AACXV,EAAAA,SAAS,EAATA,SADW;AAEXC,EAAAA,GAAG,EAAHA,GAFW;AAGXC,EAAAA,OAAO,EAAPA,OAHW;AAIXC,EAAAA,KAAK,EAALA,KAJW;AAKXM,EAAAA,QAAQ,EAARA,QALW;AAMXL,EAAAA,WAAW,EAAXA,WANW;AAOXC,EAAAA,KAAK,EAALA,KAPW;AAQXC,EAAAA,OAAO,EAAPA,OARW;AASXC,EAAAA,IAAI,EAAJA,IATW;AAUXC,EAAAA,EAAE,EAAFA;AAVW,CAAb;AAaA,eAAeE,IAAf","sourcesContent":["import * as itinerary from \"./itinerary\";\nimport * as map from \"./map\";\nimport * as profile from \"./profile\";\nimport * as query from \"./query\";\nimport * as queryParams from \"./query-params\";\nimport * as route from \"./route\";\nimport * as storage from \"./storage\";\nimport * as time from \"./time\";\nimport * as ui from \"./ui\";\nimport * as queryGen from \"./query-gen\";\n\nconst core = {\n itinerary,\n map,\n profile,\n query,\n queryGen,\n queryParams,\n route,\n storage,\n time,\n ui\n};\n\nexport default core;\n"],"file":"index.js"}
|
package/esm/query-gen.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
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; }
|
|
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; }
|
|
7
|
+
|
|
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 } } } };
|
|
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, mode must be enabled and have a transport mode in it
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (cur.type === "CHECKBOX" && 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
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Generates every possible mathematical subset of the input TransportModes.
|
|
47
|
+
* Uses code from:
|
|
48
|
+
* https://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array
|
|
49
|
+
* @param array Array of input transport modes
|
|
50
|
+
* @returns 2D array representing every possible subset of transport modes from input
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function combinations(array) {
|
|
54
|
+
if (!array) return [];
|
|
55
|
+
return (// eslint-disable-next-line no-bitwise
|
|
56
|
+
new Array(1 << array.length).fill(null) // eslint-disable-next-line no-bitwise
|
|
57
|
+
.map(function (e1, i) {
|
|
58
|
+
return array.filter(function (e2, j) {
|
|
59
|
+
return i & 1 << j;
|
|
60
|
+
});
|
|
61
|
+
})
|
|
62
|
+
);
|
|
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
|
+
|
|
69
|
+
|
|
70
|
+
export var SIMPLIFICATIONS = {
|
|
71
|
+
AIRPLANE: "TRANSIT",
|
|
72
|
+
BICYCLE: "PERSONAL",
|
|
73
|
+
BUS: "TRANSIT",
|
|
74
|
+
CABLE_CAR: "TRANSIT",
|
|
75
|
+
CAR: "CAR",
|
|
76
|
+
FERRY: "TRANSIT",
|
|
77
|
+
FLEX: "SHARED",
|
|
78
|
+
// TODO: this allows FLEX+WALK. Is this reasonable?
|
|
79
|
+
FUNICULAR: "TRANSIT",
|
|
80
|
+
GONDOLA: "TRANSIT",
|
|
81
|
+
RAIL: "TRANSIT",
|
|
82
|
+
SCOOTER: "PERSONAL",
|
|
83
|
+
SUBWAY: "TRANSIT",
|
|
84
|
+
TRAM: "TRANSIT",
|
|
85
|
+
TRANSIT: "TRANSIT",
|
|
86
|
+
WALK: "WALK"
|
|
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"];
|
|
91
|
+
export var TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
|
|
92
|
+
return SIMPLIFICATIONS[mode] === "TRANSIT" && mode !== "TRANSIT";
|
|
93
|
+
});
|
|
94
|
+
export var TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
|
|
95
|
+
return SIMPLIFICATIONS[mode] === "TRANSIT";
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
function isCombinationValid(combo, queryTransitSubmodes) {
|
|
99
|
+
if (combo.length === 0) return false; // All current qualifiers currently simplify to "SHARED"
|
|
100
|
+
|
|
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
|
|
104
|
+
|
|
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
|
+
}
|
|
112
|
+
|
|
113
|
+
if (combo.reduce(function (prev, cur) {
|
|
114
|
+
if (queryTransitSubmodes.includes(cur.mode)) {
|
|
115
|
+
return prev - 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return prev;
|
|
119
|
+
}, queryTransitSubmodes.length) !== 0) {
|
|
120
|
+
return false;
|
|
121
|
+
} // Continue to the other checks
|
|
122
|
+
|
|
123
|
+
} // OTP doesn't support multiple non-walk modes
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if (BANNED_TOGETHER.every(function (m) {
|
|
127
|
+
return combo.find(function (c) {
|
|
128
|
+
return c.mode === m;
|
|
129
|
+
});
|
|
130
|
+
})) return false;
|
|
131
|
+
return !!VALID_COMBOS.find(function (vc) {
|
|
132
|
+
return simplifiedModes.every(function (m) {
|
|
133
|
+
return vc.includes(m);
|
|
134
|
+
}) && vc.every(function (m) {
|
|
135
|
+
return simplifiedModes.includes(m);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generates a list of queries for OTP to get a comprehensive
|
|
141
|
+
* set of results based on the modes input.
|
|
142
|
+
* @param params OTP Query Params
|
|
143
|
+
* @returns Set of parameters to generate queries
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
export function generateCombinations(params) {
|
|
148
|
+
var completeModeList = [].concat(_toConsumableArray(extractAdditionalModes(params.modeSettings, params.modes)), _toConsumableArray(params.modes)); // List of the transit *submodes* that are included in the input params
|
|
149
|
+
|
|
150
|
+
var queryTransitSubmodes = completeModeList.filter(function (mode) {
|
|
151
|
+
return TRANSIT_SUBMODES.includes(mode.mode);
|
|
152
|
+
}).map(function (mode) {
|
|
153
|
+
return mode.mode;
|
|
154
|
+
});
|
|
155
|
+
return combinations(completeModeList).filter(function (combo) {
|
|
156
|
+
return isCombinationValid(combo, queryTransitSubmodes);
|
|
157
|
+
}).map(function (combo) {
|
|
158
|
+
return _objectSpread(_objectSpread({}, params), {}, {
|
|
159
|
+
modes: combo
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export function generateOtp2Query(_ref) {
|
|
164
|
+
var from = _ref.from,
|
|
165
|
+
modeSettings = _ref.modeSettings,
|
|
166
|
+
modes = _ref.modes,
|
|
167
|
+
to = _ref.to;
|
|
168
|
+
// This extracts the values from the mode settings to key value pairs
|
|
169
|
+
var modeSettingValues = modeSettings.reduce(function (prev, cur) {
|
|
170
|
+
prev[cur.key] = cur.value;
|
|
171
|
+
return prev;
|
|
172
|
+
}, {});
|
|
173
|
+
var bikeReluctance = modeSettingValues.bikeReluctance,
|
|
174
|
+
carReluctance = modeSettingValues.carReluctance,
|
|
175
|
+
walkReluctance = modeSettingValues.walkReluctance,
|
|
176
|
+
wheelchair = modeSettingValues.wheelchair;
|
|
177
|
+
return {
|
|
178
|
+
query: print(PlanQuery),
|
|
179
|
+
variables: {
|
|
180
|
+
bikeReluctance: bikeReluctance,
|
|
181
|
+
carReluctance: carReluctance,
|
|
182
|
+
fromPlace: "".concat(from.name, "::").concat(from.lat, ",").concat(from.lon, "}"),
|
|
183
|
+
modes: modes,
|
|
184
|
+
toPlace: "".concat(to.name, "::").concat(to.lat, ",").concat(to.lon, "}"),
|
|
185
|
+
walkReluctance: walkReluctance,
|
|
186
|
+
wheelchair: wheelchair
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=query-gen.js.map
|
|
@@ -0,0 +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","to","modeSettingValues","key","bikeReluctance","carReluctance","walkReluctance","wheelchair","query","PlanQuery","variables","fromPlace","name","lat","lon","toPlace"],"mappings":"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","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 from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\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 from,\n modeSettings,\n modes,\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 bikeReluctance,\n carReluctance,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\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,iBAAiB;QAChB,8BAAC,UAAU,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,0BAEb;QACb,8BAAC,UAAU,IAAC,EAAE,EAAE,IAAA,gCAAwB,EAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,2BAE3C,CACK,CACrB,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,gBAAgB,GAAG,GAAgB,EAAE;IAChD,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IACxC,OAAO,CACL;QACE,8BAAC,SAAS,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAc;QAEvC;;YAEE,yCAAO,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,GAAI,CACjE;QAER;;YAEE,yCAAO,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,GAAI,CACjE,CACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,gBAAgB,oBAkB3B;AACF,kEAAkE;AAClE,wBAAgB,CAAC,UAAU,GAAG;IAC5B,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;IAC3E,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;CAC9B,CAAC"}
|
package/lib/graphql.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"graphql.d.js"}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ import * as route from "./route";
|
|
|
4
4
|
import * as storage from "./storage";
|
|
5
5
|
import * as time from "./time";
|
|
6
6
|
import * as ui from "./ui";
|
|
7
|
+
import * as queryGen from "./query-gen";
|
|
7
8
|
declare const core: {
|
|
8
9
|
itinerary: typeof itinerary;
|
|
9
10
|
map: typeof map;
|
|
10
11
|
profile: any;
|
|
11
12
|
query: any;
|
|
13
|
+
queryGen: typeof queryGen;
|
|
12
14
|
queryParams: any;
|
|
13
15
|
route: typeof route;
|
|
14
16
|
storage: typeof storage;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAI7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAI7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,IAAI;;;;;;;;;;;CAWT,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,8 @@ var time = _interopRequireWildcard(require("./time"));
|
|
|
23
23
|
|
|
24
24
|
var ui = _interopRequireWildcard(require("./ui"));
|
|
25
25
|
|
|
26
|
+
var queryGen = _interopRequireWildcard(require("./query-gen"));
|
|
27
|
+
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -32,6 +34,7 @@ const core = {
|
|
|
32
34
|
map,
|
|
33
35
|
profile,
|
|
34
36
|
query,
|
|
37
|
+
queryGen,
|
|
35
38
|
queryParams,
|
|
36
39
|
route,
|
|
37
40
|
storage,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["core","itinerary","map","profile","query","queryParams","route","storage","time","ui"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,IAAI,GAAG;AACXC,EAAAA,SADW;AAEXC,EAAAA,GAFW;AAGXC,EAAAA,OAHW;AAIXC,EAAAA,KAJW;AAKXC,EAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["core","itinerary","map","profile","query","queryGen","queryParams","route","storage","time","ui"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,IAAI,GAAG;AACXC,EAAAA,SADW;AAEXC,EAAAA,GAFW;AAGXC,EAAAA,OAHW;AAIXC,EAAAA,KAJW;AAKXC,EAAAA,QALW;AAMXC,EAAAA,WANW;AAOXC,EAAAA,KAPW;AAQXC,EAAAA,OARW;AASXC,EAAAA,IATW;AAUXC,EAAAA;AAVW,CAAb;eAaeV,I","sourcesContent":["import * as itinerary from \"./itinerary\";\nimport * as map from \"./map\";\nimport * as profile from \"./profile\";\nimport * as query from \"./query\";\nimport * as queryParams from \"./query-params\";\nimport * as route from \"./route\";\nimport * as storage from \"./storage\";\nimport * as time from \"./time\";\nimport * as ui from \"./ui\";\nimport * as queryGen from \"./query-gen\";\n\nconst core = {\n itinerary,\n map,\n profile,\n query,\n queryGen,\n queryParams,\n route,\n storage,\n time,\n ui\n};\n\nexport default core;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { LonLatOutput } from "@conveyal/lonlat";
|
|
2
|
+
import { ModeSetting, TransportMode } from "@opentripplanner/types";
|
|
3
|
+
declare type OTPQueryParams = {
|
|
4
|
+
from: LonLatOutput & {
|
|
5
|
+
name?: string;
|
|
6
|
+
};
|
|
7
|
+
modes: TransportMode[];
|
|
8
|
+
modeSettings: ModeSetting[];
|
|
9
|
+
to: LonLatOutput & {
|
|
10
|
+
name?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare type GraphQLQuery = {
|
|
14
|
+
query: string;
|
|
15
|
+
variables: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Mode Settings can contain additional modes to add to the query,
|
|
19
|
+
* this function extracts those additional modes from the settings
|
|
20
|
+
* and returns them in an array.
|
|
21
|
+
* @param modeSettings List of mode settings with values populated
|
|
22
|
+
* @returns Additional transport modes to add to query
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractAdditionalModes(modeSettings: ModeSetting[], enabledModes: TransportMode[]): TransportMode[];
|
|
25
|
+
/**
|
|
26
|
+
* This constant maps all the transport mode to a broader mode type,
|
|
27
|
+
* which is used to determine the valid combinations of modes used in query generation.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SIMPLIFICATIONS: {
|
|
30
|
+
AIRPLANE: string;
|
|
31
|
+
BICYCLE: string;
|
|
32
|
+
BUS: string;
|
|
33
|
+
CABLE_CAR: string;
|
|
34
|
+
CAR: string;
|
|
35
|
+
FERRY: string;
|
|
36
|
+
FLEX: string;
|
|
37
|
+
FUNICULAR: string;
|
|
38
|
+
GONDOLA: string;
|
|
39
|
+
RAIL: string;
|
|
40
|
+
SCOOTER: string;
|
|
41
|
+
SUBWAY: string;
|
|
42
|
+
TRAM: string;
|
|
43
|
+
TRANSIT: string;
|
|
44
|
+
WALK: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const TRANSIT_SUBMODES: string[];
|
|
47
|
+
export declare const TRANSIT_SUBMODES_AND_TRANSIT: string[];
|
|
48
|
+
/**
|
|
49
|
+
* Generates a list of queries for OTP to get a comprehensive
|
|
50
|
+
* set of results based on the modes input.
|
|
51
|
+
* @param params OTP Query Params
|
|
52
|
+
* @returns Set of parameters to generate queries
|
|
53
|
+
*/
|
|
54
|
+
export declare function generateCombinations(params: OTPQueryParams): OTPQueryParams[];
|
|
55
|
+
export declare function generateOtp2Query({ from, modeSettings, modes, to }: OTPQueryParams): GraphQLQuery;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=query-gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-gen.d.ts","sourceRoot":"","sources":["../src/query-gen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,WAAW,EAEX,aAAa,EACd,MAAM,wBAAwB,CAAC;AAIhC,aAAK,cAAc,GAAG;IACpB,IAAI,EAAE,YAAY,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,EAAE,EAAE,YAAY,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,WAAW,EAAE,EAC3B,YAAY,EAAE,aAAa,EAAE,GAC5B,aAAa,EAAE,CAoBjB;AAoBD;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;CAgB3B,CAAC;AAeF,eAAO,MAAM,gBAAgB,UAE5B,CAAC;AACF,eAAO,MAAM,4BAA4B,UAExC,CAAC;AA2CF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,EAAE,CAc7E;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,EAAE,EACH,EAAE,cAAc,GAAG,YAAY,CA0B/B"}
|