@opentripplanner/core-utils 12.0.2 → 13.0.0-alpha.2

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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/esm/graphql.d.js.map +1 -1
  4. package/esm/index.js.map +1 -1
  5. package/esm/itinerary.js +78 -114
  6. package/esm/itinerary.js.map +1 -1
  7. package/esm/map.js +3 -3
  8. package/esm/map.js.map +1 -1
  9. package/esm/otpSchema.json +12 -0
  10. package/esm/profile.js +18 -19
  11. package/esm/profile.js.map +1 -1
  12. package/esm/query-gen.js +35 -45
  13. package/esm/query-gen.js.map +1 -1
  14. package/esm/query.js +139 -191
  15. package/esm/query.js.map +1 -1
  16. package/esm/route.js +74 -97
  17. package/esm/route.js.map +1 -1
  18. package/esm/storage.js +10 -7
  19. package/esm/storage.js.map +1 -1
  20. package/esm/suspense.js +1 -3
  21. package/esm/suspense.js.map +1 -1
  22. package/esm/time.js +13 -17
  23. package/esm/time.js.map +1 -1
  24. package/esm/ui.js +0 -5
  25. package/esm/ui.js.map +1 -1
  26. package/lib/graphql.d.js.map +1 -1
  27. package/lib/index.js +3 -19
  28. package/lib/index.js.map +1 -1
  29. package/lib/itinerary.d.ts.map +1 -1
  30. package/lib/itinerary.js +151 -247
  31. package/lib/itinerary.js.map +1 -1
  32. package/lib/map.d.ts +1 -1
  33. package/lib/map.d.ts.map +1 -1
  34. package/lib/map.js +9 -20
  35. package/lib/map.js.map +1 -1
  36. package/lib/otpSchema.json +12 -0
  37. package/lib/profile.js +19 -21
  38. package/lib/profile.js.map +1 -1
  39. package/lib/query-gen.d.ts +4 -4
  40. package/lib/query-gen.d.ts.map +1 -1
  41. package/lib/query-gen.js +35 -47
  42. package/lib/query-gen.js.map +1 -1
  43. package/lib/query-params.jsx +893 -0
  44. package/lib/query.js +72 -122
  45. package/lib/query.js.map +1 -1
  46. package/lib/route.js +73 -101
  47. package/lib/route.js.map +1 -1
  48. package/lib/storage.d.ts.map +1 -1
  49. package/lib/storage.js +12 -13
  50. package/lib/storage.js.map +1 -1
  51. package/lib/suspense.d.ts +1 -1
  52. package/lib/suspense.d.ts.map +1 -1
  53. package/lib/suspense.js +3 -9
  54. package/lib/suspense.js.map +1 -1
  55. package/lib/time.js +21 -44
  56. package/lib/time.js.map +1 -1
  57. package/lib/ui.js +1 -8
  58. package/lib/ui.js.map +1 -1
  59. package/package.json +7 -8
  60. package/src/core-utils.story.tsx +1 -1
  61. package/src/itinerary.ts +2 -0
  62. package/src/otpSchema.json +12 -0
  63. package/src/profile.js +1 -1
  64. package/src/query-gen.ts +1 -1
  65. package/src/query-params.jsx +893 -0
  66. package/src/query.js +4 -1
  67. package/src/storage.ts +9 -5
  68. package/tsconfig.tsbuildinfo +1 -1
  69. package/esm/query-params.js +0 -786
  70. package/esm/query-params.js.map +0 -1
  71. package/lib/query-params.js +0 -756
  72. package/lib/query-params.js.map +0 -1
  73. /package/{src/query-params.js → esm/query-params.jsx} +0 -0
package/lib/query.js CHANGED
@@ -1,128 +1,115 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.getQueryParamProperty = getQueryParamProperty;
7
+ exports.defaultParams = void 0;
9
8
  exports.ensureSingleAccessMode = ensureSingleAccessMode;
10
- exports.getUrlParams = getUrlParams;
9
+ exports.expandOtpFlexMode = expandOtpFlexMode;
10
+ exports.getDefaultQuery = getDefaultQuery;
11
11
  exports.getOtpUrlParams = getOtpUrlParams;
12
+ exports.getQueryParamProperty = getQueryParamProperty;
13
+ exports.getRoutingParams = getRoutingParams;
12
14
  exports.getTripOptionsFromQuery = getTripOptionsFromQuery;
13
- exports.getDefaultQuery = getDefaultQuery;
14
- exports.reduceOtpFlexModes = reduceOtpFlexModes;
15
- exports.expandOtpFlexMode = expandOtpFlexMode;
15
+ exports.getUrlParams = getUrlParams;
16
16
  exports.isNotDefaultQuery = isNotDefaultQuery;
17
17
  exports.parseLocationString = parseLocationString;
18
18
  exports.planParamsToQuery = planParamsToQuery;
19
19
  exports.planParamsToQueryAsync = planParamsToQueryAsync;
20
- exports.getRoutingParams = getRoutingParams;
21
- exports.defaultParams = void 0;
22
-
20
+ exports.reduceOtpFlexModes = reduceOtpFlexModes;
23
21
  var _dateFns = require("date-fns");
24
-
25
22
  var _lib = _interopRequireDefault(require("@opentripplanner/geocoder/lib"));
26
-
27
23
  var _qs = _interopRequireDefault(require("qs"));
28
-
29
24
  var _itinerary = require("./itinerary");
30
-
31
25
  var _map = require("./map");
32
-
33
26
  var _queryParams = _interopRequireDefault(require("./query-params"));
34
-
35
27
  var _time = require("./time");
36
-
37
28
  /* The list of default parameters considered in the settings panel */
38
- const defaultParams = ["wheelchair", "maxWalkDistance", "walkReluctance", "maxWalkTime", "maxBikeDistance", "maxBikeTime", "bikeSpeed", "optimize", "optimizeBike", "maxEScooterDistance", "watts"];
29
+
30
+ const defaultParams = exports.defaultParams = ["wheelchair", "maxWalkDistance", "walkReluctance", "maxWalkTime", "maxBikeDistance", "maxBikeTime", "bikeSpeed", "optimize", "optimizeBike", "maxEScooterDistance", "watts"];
31
+
39
32
  /**
40
33
  * List of time formats to parse when reading query params.
41
34
  */
42
-
43
- exports.defaultParams = defaultParams;
44
35
  const TIME_FORMATS = ["HH:mm:ss", "HH:mm", "H:mm", "h:mm:ss a", "h:mm:ssa", "h:mm a", "h:mma", "h:mm", "HHmm", "hmm", "ha"];
36
+
45
37
  /* A function to retrieve a property value from an entry in the query-params
46
38
  * table, checking for either a static value or a function */
47
39
 
48
40
  function getQueryParamProperty(paramInfo, property, query) {
49
41
  return typeof paramInfo[property] === "function" ? paramInfo[property](query) : paramInfo[property];
50
42
  }
51
-
52
43
  function ensureSingleAccessMode(queryModes) {
53
44
  // Count the number of access modes
54
- const accessCount = queryModes.filter(m => (0, _itinerary.isAccessMode)(m)).length; // If multiple access modes are specified, keep only the first one
45
+ const accessCount = queryModes.filter(m => (0, _itinerary.isAccessMode)(m)).length;
55
46
 
47
+ // If multiple access modes are specified, keep only the first one
56
48
  if (accessCount > 1) {
57
49
  const firstAccess = queryModes.find(m => (0, _itinerary.isAccessMode)(m));
58
- queryModes = queryModes.filter(m => !(0, _itinerary.isAccessMode)(m) || m === firstAccess); // If no access modes are specified, add 'WALK' as the default
50
+ queryModes = queryModes.filter(m => !(0, _itinerary.isAccessMode)(m) || m === firstAccess);
51
+
52
+ // If no access modes are specified, add 'WALK' as the default
59
53
  } else if (accessCount === 0) {
60
54
  queryModes.push("WALK");
61
55
  }
62
-
63
56
  return queryModes;
64
57
  }
65
-
66
58
  function getUrlParams() {
67
- return _qs.default.parse(window.location.href.split("?")[1]);
59
+ if (window) {
60
+ return _qs.default.parse(window.location.href.split("?")[1]);
61
+ }
62
+ return undefined;
68
63
  }
69
-
70
64
  function getOtpUrlParams() {
71
65
  return Object.keys(getUrlParams()).filter(key => !key.startsWith("ui_"));
72
66
  }
73
-
74
67
  function getTripOptionsFromQuery(query, keepPlace = false) {
75
- const options = { ...query
76
- }; // Delete time/date options and from/to
77
-
68
+ const options = {
69
+ ...query
70
+ };
71
+ // Delete time/date options and from/to
78
72
  delete options.time;
79
73
  delete options.departArrive;
80
74
  delete options.date;
81
-
82
75
  if (!keepPlace) {
83
76
  delete options.from;
84
77
  delete options.to;
85
78
  }
86
-
87
79
  return options;
88
80
  }
81
+
89
82
  /**
90
83
  * Gets the query param's default value that is either a constant or by
91
84
  * executing the default value function.
92
85
  */
93
-
94
-
95
86
  function getDefaultQueryParamValue(param) {
96
87
  return typeof param.default === "function" ? param.default() : param.default;
97
88
  }
89
+
98
90
  /**
99
91
  * Get the default query to OTP based on the given config.
100
92
  */
101
-
102
-
103
93
  function getDefaultQuery(config = null) {
104
94
  const defaultQuery = {
105
95
  routingType: "ITINERARY"
106
96
  };
107
-
108
97
  _queryParams.default.filter(qp => "default" in qp).forEach(qp => {
109
98
  defaultQuery[qp.name] = getDefaultQueryParamValue(qp);
110
99
  });
111
-
112
100
  if (config) {
113
101
  if (config.routingTypes && config.routingTypes.length > 0) {
114
102
  defaultQuery.routingType = config.routingTypes[0].key;
115
103
  }
116
-
117
104
  if (config.defaultQueryParams) {
118
105
  Object.keys(config.defaultQueryParams).forEach(key => {
119
106
  defaultQuery[key] = config.defaultQueryParams[key];
120
107
  });
121
108
  }
122
109
  }
123
-
124
110
  return defaultQuery;
125
111
  }
112
+
126
113
  /**
127
114
  * Determine if the specified query param applies to the given query (based on
128
115
  * routing type and the param's own applicable function).
@@ -131,50 +118,44 @@ function getDefaultQuery(config = null) {
131
118
  * @param config OTP config
132
119
  * @return {Boolean}
133
120
  */
134
-
135
-
136
121
  function isParamApplicable(paramInfo, query, config) {
137
122
  const {
138
123
  applicable,
139
124
  routingTypes
140
125
  } = paramInfo;
141
126
  if (!routingTypes.includes(query.routingType)) return false;
142
-
143
127
  if (typeof applicable === "function" && !applicable(query, config)) {
144
128
  return false;
145
129
  }
146
-
147
130
  return true;
148
131
  }
132
+
149
133
  /**
150
134
  * Helper method which replaces OTP flex modes with single FLEX mode that's
151
135
  * more useful and easier to work with.
152
136
  */
153
-
154
-
155
137
  function reduceOtpFlexModes(modes, enabled = true) {
156
138
  if (!enabled) return modes;
157
139
  return modes.reduce((prev, cur) => {
158
- const newModes = prev; // Add the current mode if it is not a flex mode
159
-
140
+ const newModes = prev;
141
+ // Add the current mode if it is not a flex mode
160
142
  if (!cur.includes("FLEX")) {
161
- newModes.push(cur); // If it is a flex mode, do not add it but rather add the custom flex mode
143
+ newModes.push(cur);
144
+ // If it is a flex mode, do not add it but rather add the custom flex mode
162
145
  // if not already present
163
146
  } else if (!newModes.includes("FLEX")) {
164
147
  newModes.push("FLEX");
165
148
  }
166
-
167
149
  return newModes;
168
150
  }, []);
169
151
  }
152
+
170
153
  /**
171
154
  * Helper method to process a mode string, replacing all instances of FLEX
172
155
  * with the full set of FLEX modes used by otp-2
173
156
  * @param {*} mode a mode String, not an array
174
157
  * @returns a mode String, not an array (with flex modes expanded)
175
158
  */
176
-
177
-
178
159
  function expandOtpFlexMode(mode) {
179
160
  const modes = reduceOtpFlexModes(mode.split(","));
180
161
  return modes.map(m => {
@@ -182,26 +163,20 @@ function expandOtpFlexMode(mode) {
182
163
  if (m === "FLEX_EGRESS" || m === "FLEX_ACCESS" || m === "FLEX_DIRECT") {
183
164
  if (mode.includes("FLEX")) return "";
184
165
  }
185
-
186
166
  if (m === "FLEX") {
187
167
  return "FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT";
188
168
  }
189
-
190
169
  return m;
191
170
  }).join(",");
192
171
  }
172
+
193
173
  /**
194
174
  * Determines whether the specified query differs from the default query, i.e.,
195
175
  * whether the user has modified any trip options (including mode) from their
196
176
  * default values.
197
177
  */
198
-
199
-
200
178
  function isNotDefaultQuery(query, config) {
201
- var _config$modes;
202
-
203
- const activeModes = reduceOtpFlexModes(query.mode.split(",").sort(), (_config$modes = config.modes) === null || _config$modes === void 0 ? void 0 : _config$modes.mergeFlex);
204
-
179
+ const activeModes = reduceOtpFlexModes(query.mode.split(",").sort(), config.modes?.mergeFlex);
205
180
  if (activeModes.length !== 2 || activeModes[0] !== "TRANSIT" || activeModes[1] !== "WALK") {
206
181
  // Default mode is TRANSIT,WALK. If general TRANSIT is not used, check
207
182
  // against available transit modes in config.
@@ -210,25 +185,21 @@ function isNotDefaultQuery(query, config) {
210
185
  return value === defaultModes[index];
211
186
  });
212
187
  if (!modesEqual) return true;
213
- } // If modes are equal, check the remaining params.
214
-
215
-
188
+ }
189
+ // If modes are equal, check the remaining params.
216
190
  const defaultQuery = getDefaultQuery(config);
217
-
218
191
  for (let i = 0; i < defaultParams.length; i++) {
219
192
  const param = defaultParams[i];
220
-
221
- const paramInfo = _queryParams.default.find(qp => qp.name === param); // If the parameter applies to the query and does not match the default
193
+ const paramInfo = _queryParams.default.find(qp => qp.name === param);
194
+ // If the parameter applies to the query and does not match the default
222
195
  // value, the query is not default.
223
-
224
-
225
196
  if (isParamApplicable(paramInfo, query, config) && query[param] !== defaultQuery[param]) {
226
197
  return true;
227
198
  }
228
199
  }
229
-
230
200
  return false;
231
201
  }
202
+
232
203
  /**
233
204
  * Geocode utility for returning the first result for the provided place name text.
234
205
  * @param {string} text - text to search
@@ -236,24 +207,21 @@ function isNotDefaultQuery(query, config) {
236
207
  * @param {string} geocoderMethod - an alternate geocoder api method to use. Defaults to `search`
237
208
  * @return {Location}
238
209
  */
239
-
240
-
241
210
  async function getFirstGeocodeResult(text, geocoderConfig, geocoderMethod = "search") {
242
- const geocoder = (0, _lib.default)(geocoderConfig); // Attempt to geocode search text and return first result if found.
211
+ const geocoder = (0, _lib.default)(geocoderConfig);
212
+ // Attempt to geocode search text and return first result if found.
243
213
  // TODO: Import geocoder from @opentripplanner
244
-
245
214
  return geocoder[geocoderMethod]({
246
215
  text
247
216
  }).then(result => {
248
217
  const firstResult = result.features && result.features[0];
249
-
250
218
  if (firstResult) {
251
219
  return geocoder.getLocationFromGeocodedFeature(firstResult);
252
220
  }
253
-
254
221
  return null;
255
222
  });
256
223
  }
224
+
257
225
  /**
258
226
  * OTP allows passing a location in the form '123 Main St::lat,lon', so we check
259
227
  * for the double colon and parse the coordinates accordingly.
@@ -261,8 +229,6 @@ async function getFirstGeocodeResult(text, geocoderConfig, geocoderMethod = "sea
261
229
  * @return {Location} - location or null if the value is falsey or the parsed
262
230
  * coordinates do not result in both a lat and lon
263
231
  */
264
-
265
-
266
232
  function parseLocationString(value) {
267
233
  if (!value) return null;
268
234
  const parts = value.split("::");
@@ -274,6 +240,7 @@ function parseLocationString(value) {
274
240
  lon: coordinates[1] || null
275
241
  } : null;
276
242
  }
243
+
277
244
  /**
278
245
  * Convert a string query param for a from or to place into a location. If
279
246
  * coordinates not provided and geocoder config is present, use the first
@@ -282,27 +249,22 @@ function parseLocationString(value) {
282
249
  * @param {Object} [geocoderConfig=null]
283
250
  * @return {Location}
284
251
  */
285
-
286
-
287
252
  async function queryParamToLocation(value, geocoderConfig) {
288
253
  let location = parseLocationString(value);
289
-
290
254
  if (!location && value && geocoderConfig) {
291
255
  // If a valid location was not found, but the place name text exists,
292
256
  // attempt to geocode the name.
293
257
  location = await getFirstGeocodeResult(value, geocoderConfig, geocoderConfig.autoMethod);
294
258
  }
295
-
296
259
  return location;
297
260
  }
261
+
298
262
  /**
299
263
  * Create a otp query based on a the url params.
300
264
  *
301
265
  * @param {Object} params An object representing the parsed querystring of url
302
266
  * params.
303
267
  */
304
-
305
-
306
268
  function planParamsToQuery(params) {
307
269
  const query = {};
308
270
  Object.keys(params).forEach(key => {
@@ -310,19 +272,15 @@ function planParamsToQuery(params) {
310
272
  case "fromPlace":
311
273
  query.from = parseLocationString(params.fromPlace);
312
274
  break;
313
-
314
275
  case "toPlace":
315
276
  query.to = parseLocationString(params.toPlace);
316
277
  break;
317
-
318
278
  case "arriveBy":
319
279
  query.departArrive = params.arriveBy === "true" ? "ARRIVE" : params.arriveBy === "false" ? "DEPART" : "NOW";
320
280
  break;
321
-
322
281
  case "date":
323
282
  query.date = params.date || (0, _time.getCurrentDate)();
324
283
  break;
325
-
326
284
  case "time":
327
285
  {
328
286
  // Match one of the supported time formats
@@ -330,19 +288,17 @@ function planParamsToQuery(params) {
330
288
  query.time = matchedTimeFormat ? (0, _dateFns.format)((0, _dateFns.parse)(params.time, matchedTimeFormat, new Date()), _time.OTP_API_TIME_FORMAT) : (0, _time.getCurrentTime)();
331
289
  }
332
290
  break;
333
-
334
291
  case "intermediatePlaces":
335
292
  // If query has intermediate places, ensure that they are parsed
336
293
  // as locations.
337
294
  query.intermediatePlaces = params.intermediatePlaces ? params.intermediatePlaces.map(parseLocationString) : [];
338
295
  break;
339
-
340
296
  default:
341
297
  {
342
- const maybeNumber = Number(params[key]); // If the param value is an empty string literal and is not a number,
298
+ const maybeNumber = Number(params[key]);
299
+ // If the param value is an empty string literal and is not a number,
343
300
  // use string value. Else, use parsed number value.
344
301
  // See https://github.com/opentripplanner/otp-ui/issues/50
345
-
346
302
  query[key] = params[key] === "" || Number.isNaN(maybeNumber) ? params[key] : maybeNumber;
347
303
  break;
348
304
  }
@@ -350,6 +306,7 @@ function planParamsToQuery(params) {
350
306
  });
351
307
  return query;
352
308
  }
309
+
353
310
  /**
354
311
  * Async method to create a otp query based on a the url params. This provides
355
312
  * the same functionality as planParamsToQuery, except that it will also attempt
@@ -359,23 +316,20 @@ function planParamsToQuery(params) {
359
316
  * params.
360
317
  * @param config the config in the otp-rr store.
361
318
  */
362
-
363
-
364
319
  async function planParamsToQueryAsync(params, config = {}) {
365
320
  // Construct query from plan params.
366
- const query = planParamsToQuery(params); // Attempt to geocode from and to params if the string parsing does not return
321
+ const query = planParamsToQuery(params);
322
+ // Attempt to geocode from and to params if the string parsing does not return
367
323
  // valid locations.
368
-
369
324
  if (!query.from) {
370
325
  query.from = await queryParamToLocation(params.fromPlace, config.geocoder);
371
326
  }
372
-
373
327
  if (!query.to) {
374
328
  query.to = await queryParamToLocation(params.toPlace, config.geocoder);
375
329
  }
376
-
377
330
  return query;
378
331
  }
332
+
379
333
  /**
380
334
  * Create an object that can be used as a querystring in making an OTP
381
335
  * PlannerResource request.
@@ -389,15 +343,12 @@ async function planParamsToQueryAsync(params, config = {}) {
389
343
  * @param {boolean} ignoreRealtimeUpdates If true, will create a request that
390
344
  * does not use realtime data.
391
345
  */
392
-
393
-
394
346
  function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {
395
- var _config$modes2;
396
-
397
347
  const routingType = currentQuery.routingType;
398
348
  const isItinerary = routingType === "ITINERARY";
399
- let params = {}; // Start with the universe of OTP parameters defined in query-params.js:
349
+ let params = {};
400
350
 
351
+ // Start with the universe of OTP parameters defined in query-params.js:
401
352
  _queryParams.default.filter(qp => {
402
353
  // A given parameter is included in the request if all of the following:
403
354
  // 1. Must apply to the active routing type (ITINERARY or PROFILE)
@@ -411,61 +362,60 @@ function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {
411
362
  params = Object.assign(params, rewriteFunction ? rewriteFunction(currentQuery[qp.name]) : {
412
363
  [qp.name]: currentQuery[qp.name]
413
364
  });
414
- }); // Additional processing specific to ITINERARY mode
415
-
365
+ });
416
366
 
367
+ // Additional processing specific to ITINERARY mode
417
368
  if (isItinerary) {
418
369
  // override ignoreRealtimeUpdates if provided
419
370
  if (typeof ignoreRealtimeUpdates === "boolean") {
420
371
  params.ignoreRealtimeUpdates = ignoreRealtimeUpdates;
421
- } // check date/time validity; ignore both if either is invalid
422
-
372
+ }
423
373
 
374
+ // check date/time validity; ignore both if either is invalid
424
375
  const dateValid = (0, _dateFns.isMatch)(params.date, _time.OTP_API_DATE_FORMAT);
425
376
  const timeValid = (0, _dateFns.isMatch)(params.time, _time.OTP_API_TIME_FORMAT);
426
-
427
377
  if (!dateValid || !timeValid) {
428
378
  delete params.time;
429
379
  delete params.date;
430
- } // temp: set additional parameters for CAR_HAIL or CAR_RENT trips
431
-
380
+ }
432
381
 
382
+ // temp: set additional parameters for CAR_HAIL or CAR_RENT trips
433
383
  if (params.mode && (params.mode.includes("CAR_HAIL") || params.mode.includes("CAR_RENT"))) {
434
- params.minTransitDistance = "50%"; // increase search timeout because these queries can take a while
435
-
384
+ params.minTransitDistance = "50%";
385
+ // increase search timeout because these queries can take a while
436
386
  params.searchTimeout = 10000;
437
- } // set onlyTransitTrips for car rental searches
438
-
387
+ }
439
388
 
389
+ // set onlyTransitTrips for car rental searches
440
390
  if (params.mode && params.mode.includes("CAR_RENT")) {
441
391
  params.onlyTransitTrips = true;
442
- } // Additional processing specific to PROFILE mode
392
+ }
443
393
 
394
+ // Additional processing specific to PROFILE mode
444
395
  } else {
445
396
  // check start and end time validity; ignore both if either is invalid
446
397
  const startTimeValid = (0, _dateFns.isMatch)(params.startTime, _time.OTP_API_TIME_FORMAT);
447
398
  const endTimeValid = (0, _dateFns.isMatch)(params.endTime, _time.OTP_API_TIME_FORMAT);
448
-
449
399
  if (!startTimeValid || !endTimeValid) {
450
400
  delete params.startTimeValid;
451
401
  delete params.endTimeValid;
452
402
  }
453
- } // TODO: check that valid from/to locations are provided
454
- // hack to add walking to driving/TNC trips
403
+ }
455
404
 
405
+ // TODO: check that valid from/to locations are provided
456
406
 
407
+ // hack to add walking to driving/TNC trips
457
408
  if ((0, _itinerary.hasCar)(params.mode)) {
458
409
  params.mode += ",WALK";
459
- } // Replace FLEX placeholder with OTP flex modes
460
- // Explicit false check allows avoiding a breaking change -- undefined is true
461
-
410
+ }
462
411
 
463
- if (params.mode && ((_config$modes2 = config.modes) === null || _config$modes2 === void 0 ? void 0 : _config$modes2.mergeFlex) !== false) {
412
+ // Replace FLEX placeholder with OTP flex modes
413
+ // Explicit false check allows avoiding a breaking change -- undefined is true
414
+ if (params.mode && config.modes?.mergeFlex !== false) {
464
415
  // Ensure query is in reduced format to avoid replacing twice
465
416
  const reducedMode = reduceOtpFlexModes(params.mode.split(",")).join(",");
466
417
  params.mode = expandOtpFlexMode(reducedMode);
467
418
  }
468
-
469
419
  return params;
470
420
  }
471
421
  //# sourceMappingURL=query.js.map
package/lib/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query.js"],"names":["defaultParams","TIME_FORMATS","getQueryParamProperty","paramInfo","property","query","ensureSingleAccessMode","queryModes","accessCount","filter","m","length","firstAccess","find","push","getUrlParams","qs","parse","window","location","href","split","getOtpUrlParams","Object","keys","key","startsWith","getTripOptionsFromQuery","keepPlace","options","time","departArrive","date","from","to","getDefaultQueryParamValue","param","default","getDefaultQuery","config","defaultQuery","routingType","queryParams","qp","forEach","name","routingTypes","defaultQueryParams","isParamApplicable","applicable","includes","reduceOtpFlexModes","modes","enabled","reduce","prev","cur","newModes","expandOtpFlexMode","mode","map","join","isNotDefaultQuery","activeModes","sort","mergeFlex","defaultModes","concat","modesEqual","every","value","index","i","getFirstGeocodeResult","text","geocoderConfig","geocoderMethod","geocoder","then","result","firstResult","features","getLocationFromGeocodedFeature","parseLocationString","parts","coordinates","lat","lon","queryParamToLocation","autoMethod","planParamsToQuery","params","fromPlace","toPlace","arriveBy","matchedTimeFormat","timeFormat","Date","OTP_API_TIME_FORMAT","intermediatePlaces","maybeNumber","Number","isNaN","planParamsToQueryAsync","getRoutingParams","currentQuery","ignoreRealtimeUpdates","isItinerary","indexOf","rewriteFunction","itineraryRewrite","profileRewrite","assign","dateValid","OTP_API_DATE_FORMAT","timeValid","minTransitDistance","searchTimeout","onlyTransitTrips","startTimeValid","startTime","endTimeValid","endTime","reducedMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAOA;AAEO,MAAMA,aAAa,GAAG,CAC3B,YAD2B,EAE3B,iBAF2B,EAG3B,gBAH2B,EAI3B,aAJ2B,EAK3B,iBAL2B,EAM3B,aAN2B,EAO3B,WAP2B,EAQ3B,UAR2B,EAS3B,cAT2B,EAU3B,qBAV2B,EAW3B,OAX2B,CAAtB;AAcP;AACA;AACA;;;AACA,MAAMC,YAAY,GAAG,CACnB,UADmB,EAEnB,OAFmB,EAGnB,MAHmB,EAInB,WAJmB,EAKnB,UALmB,EAMnB,QANmB,EAOnB,OAPmB,EAQnB,MARmB,EASnB,MATmB,EAUnB,KAVmB,EAWnB,IAXmB,CAArB;AAcA;AACA;;AAEO,SAASC,qBAAT,CAA+BC,SAA/B,EAA0CC,QAA1C,EAAoDC,KAApD,EAA2D;AAChE,SAAO,OAAOF,SAAS,CAACC,QAAD,CAAhB,KAA+B,UAA/B,GACHD,SAAS,CAACC,QAAD,CAAT,CAAoBC,KAApB,CADG,GAEHF,SAAS,CAACC,QAAD,CAFb;AAGD;;AAEM,SAASE,sBAAT,CAAgCC,UAAhC,EAA4C;AACjD;AACA,QAAMC,WAAW,GAAGD,UAAU,CAACE,MAAX,CAAkBC,CAAC,IAAI,6BAAaA,CAAb,CAAvB,EAAwCC,MAA5D,CAFiD,CAIjD;;AACA,MAAIH,WAAW,GAAG,CA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D;AACA,UAAM0D,WAAW,GAAGxE,kBAAkB,CAACwC,MAAM,CAAChC,IAAP,CAAYtC,KAAZ,CAAkB,GAAlB,CAAD,CAAlB,CAA2CwC,IAA3C,CAAgD,GAAhD,CAApB;AACA8B,IAAAA,MAAM,CAAChC,IAAP,GAAcD,iBAAiB,CAACiE,WAAD,CAA/B;AACD;;AAED,SAAOhC,MAAP;AACD","sourcesContent":["import { format, isMatch, parse } from \"date-fns\";\nimport getGeocoder from \"@opentripplanner/geocoder/lib\";\nimport qs from \"qs\";\n\nimport { getTransitModes, hasCar, isAccessMode } from \"./itinerary\";\nimport { coordsToString, stringToCoords } from \"./map\";\nimport queryParams from \"./query-params\";\nimport {\n getCurrentTime,\n getCurrentDate,\n OTP_API_DATE_FORMAT,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n/* The list of default parameters considered in the settings panel */\n\nexport const defaultParams = [\n \"wheelchair\",\n \"maxWalkDistance\",\n \"walkReluctance\",\n \"maxWalkTime\",\n \"maxBikeDistance\",\n \"maxBikeTime\",\n \"bikeSpeed\",\n \"optimize\",\n \"optimizeBike\",\n \"maxEScooterDistance\",\n \"watts\"\n];\n\n/**\n * List of time formats to parse when reading query params.\n */\nconst TIME_FORMATS = [\n \"HH:mm:ss\",\n \"HH:mm\",\n \"H:mm\",\n \"h:mm:ss a\",\n \"h:mm:ssa\",\n \"h:mm a\",\n \"h:mma\",\n \"h:mm\",\n \"HHmm\",\n \"hmm\",\n \"ha\"\n];\n\n/* A function to retrieve a property value from an entry in the query-params\n * table, checking for either a static value or a function */\n\nexport function getQueryParamProperty(paramInfo, property, query) {\n return typeof paramInfo[property] === \"function\"\n ? paramInfo[property](query)\n : paramInfo[property];\n}\n\nexport function ensureSingleAccessMode(queryModes) {\n // Count the number of access modes\n const accessCount = queryModes.filter(m => isAccessMode(m)).length;\n\n // If multiple access modes are specified, keep only the first one\n if (accessCount > 1) {\n const firstAccess = queryModes.find(m => isAccessMode(m));\n queryModes = queryModes.filter(m => !isAccessMode(m) || m === firstAccess);\n\n // If no access modes are specified, add 'WALK' as the default\n } else if (accessCount === 0) {\n queryModes.push(\"WALK\");\n }\n\n return queryModes;\n}\n\nexport function getUrlParams() {\n return qs.parse(window.location.href.split(\"?\")[1]);\n}\n\nexport function getOtpUrlParams() {\n return Object.keys(getUrlParams()).filter(key => !key.startsWith(\"ui_\"));\n}\n\nexport function getTripOptionsFromQuery(query, keepPlace = false) {\n const options = { ...query };\n // Delete time/date options and from/to\n delete options.time;\n delete options.departArrive;\n delete options.date;\n if (!keepPlace) {\n delete options.from;\n delete options.to;\n }\n return options;\n}\n\n/**\n * Gets the query param's default value that is either a constant or by\n * executing the default value function.\n */\nfunction getDefaultQueryParamValue(param) {\n return typeof param.default === \"function\" ? param.default() : param.default;\n}\n\n/**\n * Get the default query to OTP based on the given config.\n */\nexport function getDefaultQuery(config = null) {\n const defaultQuery = { routingType: \"ITINERARY\" };\n queryParams\n .filter(qp => \"default\" in qp)\n .forEach(qp => {\n defaultQuery[qp.name] = getDefaultQueryParamValue(qp);\n });\n if (config) {\n if (config.routingTypes && config.routingTypes.length > 0) {\n defaultQuery.routingType = config.routingTypes[0].key;\n }\n if (config.defaultQueryParams) {\n Object.keys(config.defaultQueryParams).forEach(key => {\n defaultQuery[key] = config.defaultQueryParams[key];\n });\n }\n }\n return defaultQuery;\n}\n\n/**\n * Determine if the specified query param applies to the given query (based on\n * routing type and the param's own applicable function).\n * @param paramInfo an entry from query-params.js\n * @param query the query against which to check if the param applies\n * @param config OTP config\n * @return {Boolean}\n */\nfunction isParamApplicable(paramInfo, query, config) {\n const { applicable, routingTypes } = paramInfo;\n if (!routingTypes.includes(query.routingType)) return false;\n if (typeof applicable === \"function\" && !applicable(query, config)) {\n return false;\n }\n return true;\n}\n\n/**\n * Helper method which replaces OTP flex modes with single FLEX mode that's\n * more useful and easier to work with.\n */\nexport function reduceOtpFlexModes(modes, enabled = true) {\n if (!enabled) return modes;\n\n return modes.reduce((prev, cur) => {\n const newModes = prev;\n // Add the current mode if it is not a flex mode\n if (!cur.includes(\"FLEX\")) {\n newModes.push(cur);\n // If it is a flex mode, do not add it but rather add the custom flex mode\n // if not already present\n } else if (!newModes.includes(\"FLEX\")) {\n newModes.push(\"FLEX\");\n }\n return newModes;\n }, []);\n}\n\n/**\n * Helper method to process a mode string, replacing all instances of FLEX\n * with the full set of FLEX modes used by otp-2\n * @param {*} mode a mode String, not an array\n * @returns a mode String, not an array (with flex modes expanded)\n */\nexport function expandOtpFlexMode(mode) {\n const modes = reduceOtpFlexModes(mode.split(\",\"));\n return modes\n .map(m => {\n // If both the expanded and shrunk modes are included, remove the expanded one\n if (m === \"FLEX_EGRESS\" || m === \"FLEX_ACCESS\" || m === \"FLEX_DIRECT\") {\n if (mode.includes(\"FLEX\")) return \"\";\n }\n if (m === \"FLEX\") {\n return \"FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT\";\n }\n return m;\n })\n .join(\",\");\n}\n\n/**\n * Determines whether the specified query differs from the default query, i.e.,\n * whether the user has modified any trip options (including mode) from their\n * default values.\n */\nexport function isNotDefaultQuery(query, config) {\n const activeModes = reduceOtpFlexModes(\n query.mode.split(\",\").sort(),\n config.modes?.mergeFlex\n );\n if (\n activeModes.length !== 2 ||\n activeModes[0] !== \"TRANSIT\" ||\n activeModes[1] !== \"WALK\"\n ) {\n // Default mode is TRANSIT,WALK. If general TRANSIT is not used, check\n // against available transit modes in config.\n const defaultModes = getTransitModes(config)\n .concat([\"WALK\"])\n .sort();\n const modesEqual =\n activeModes.length === defaultModes.length &&\n activeModes.every((value, index) => {\n return value === defaultModes[index];\n });\n if (!modesEqual) return true;\n }\n // If modes are equal, check the remaining params.\n const defaultQuery = getDefaultQuery(config);\n for (let i = 0; i < defaultParams.length; i++) {\n const param = defaultParams[i];\n const paramInfo = queryParams.find(qp => qp.name === param);\n // If the parameter applies to the query and does not match the default\n // value, the query is not default.\n if (\n isParamApplicable(paramInfo, query, config) &&\n query[param] !== defaultQuery[param]\n ) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Geocode utility for returning the first result for the provided place name text.\n * @param {string} text - text to search\n * @param {Object} geocoderConfig\n * @param {string} geocoderMethod - an alternate geocoder api method to use. Defaults to `search`\n * @return {Location}\n */\nasync function getFirstGeocodeResult(\n text,\n geocoderConfig,\n geocoderMethod = \"search\"\n) {\n const geocoder = getGeocoder(geocoderConfig);\n // Attempt to geocode search text and return first result if found.\n // TODO: Import geocoder from @opentripplanner\n return geocoder[geocoderMethod]({ text }).then(result => {\n const firstResult = result.features && result.features[0];\n if (firstResult) {\n return geocoder.getLocationFromGeocodedFeature(firstResult);\n }\n return null;\n });\n}\n\n/**\n * OTP allows passing a location in the form '123 Main St::lat,lon', so we check\n * for the double colon and parse the coordinates accordingly.\n * @param {string} value - query param for place described above\n * @return {Location} - location or null if the value is falsey or the parsed\n * coordinates do not result in both a lat and lon\n */\nexport function parseLocationString(value) {\n if (!value) return null;\n const parts = value.split(\"::\");\n const coordinates = parts[1]\n ? stringToCoords(parts[1])\n : stringToCoords(parts[0]);\n const name = parts[1] ? parts[0] : coordsToString(coordinates);\n return coordinates.length === 2\n ? {\n name: name || null,\n lat: coordinates[0] || null,\n lon: coordinates[1] || null\n }\n : null;\n}\n\n/**\n * Convert a string query param for a from or to place into a location. If\n * coordinates not provided and geocoder config is present, use the first\n * geocoded result.\n * @param {string} value\n * @param {Object} [geocoderConfig=null]\n * @return {Location}\n */\nasync function queryParamToLocation(value, geocoderConfig) {\n let location = parseLocationString(value);\n if (!location && value && geocoderConfig) {\n // If a valid location was not found, but the place name text exists,\n // attempt to geocode the name.\n location = await getFirstGeocodeResult(\n value,\n geocoderConfig,\n geocoderConfig.autoMethod\n );\n }\n return location;\n}\n\n/**\n * Create a otp query based on a the url params.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n */\nexport function planParamsToQuery(params) {\n const query = {};\n Object.keys(params).forEach(key => {\n switch (key) {\n case \"fromPlace\":\n query.from = parseLocationString(params.fromPlace);\n break;\n case \"toPlace\":\n query.to = parseLocationString(params.toPlace);\n break;\n case \"arriveBy\":\n query.departArrive =\n params.arriveBy === \"true\"\n ? \"ARRIVE\"\n : params.arriveBy === \"false\"\n ? \"DEPART\"\n : \"NOW\";\n break;\n case \"date\":\n query.date = params.date || getCurrentDate();\n break;\n case \"time\":\n {\n // Match one of the supported time formats\n const matchedTimeFormat = TIME_FORMATS.find(timeFormat =>\n isMatch(params.time, timeFormat)\n );\n query.time = matchedTimeFormat\n ? format(\n parse(params.time, matchedTimeFormat, new Date()),\n OTP_API_TIME_FORMAT\n )\n : getCurrentTime();\n }\n break;\n case \"intermediatePlaces\":\n // If query has intermediate places, ensure that they are parsed\n // as locations.\n query.intermediatePlaces = params.intermediatePlaces\n ? params.intermediatePlaces.map(parseLocationString)\n : [];\n break;\n default: {\n const maybeNumber = Number(params[key]);\n // If the param value is an empty string literal and is not a number,\n // use string value. Else, use parsed number value.\n // See https://github.com/opentripplanner/otp-ui/issues/50\n query[key] =\n params[key] === \"\" || Number.isNaN(maybeNumber)\n ? params[key]\n : maybeNumber;\n break;\n }\n }\n });\n return query;\n}\n\n/**\n * Async method to create a otp query based on a the url params. This provides\n * the same functionality as planParamsToQuery, except that it will also attempt\n * to geocode the input from and to strings if no lat/lng values were provided.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n * @param config the config in the otp-rr store.\n */\nexport async function planParamsToQueryAsync(params, config = {}) {\n // Construct query from plan params.\n const query = planParamsToQuery(params);\n // Attempt to geocode from and to params if the string parsing does not return\n // valid locations.\n if (!query.from) {\n query.from = await queryParamToLocation(params.fromPlace, config.geocoder);\n }\n if (!query.to) {\n query.to = await queryParamToLocation(params.toPlace, config.geocoder);\n }\n return query;\n}\n\n/**\n * Create an object that can be used as a querystring in making an OTP\n * PlannerResource request.\n *\n * See http://otp-docs.ibi-transit.com/api/resource_PlannerResource.html\n *\n * @param {Object} config The OTP application config. See types#configType\n * @param {Object} currentQuery The current query parameters as saved in the\n * application state. This method does some extra logic on top of this data\n * in order to create a request suitable for OTP. See __tests__/query.js#L14 for more.\n * @param {boolean} ignoreRealtimeUpdates If true, will create a request that\n * does not use realtime data.\n */\nexport function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {\n const routingType = currentQuery.routingType;\n const isItinerary = routingType === \"ITINERARY\";\n let params = {};\n\n // Start with the universe of OTP parameters defined in query-params.js:\n queryParams\n .filter(qp => {\n // A given parameter is included in the request if all of the following:\n // 1. Must apply to the active routing type (ITINERARY or PROFILE)\n // 2. Must be included in the current user-defined query\n // 3. Must pass the parameter's applicability test, if one is specified\n return (\n qp.routingTypes.indexOf(routingType) !== -1 &&\n qp.name in currentQuery &&\n (typeof qp.applicable !== \"function\" ||\n qp.applicable(currentQuery, config))\n );\n })\n .forEach(qp => {\n // Translate the applicable parameters according to their rewrite\n // functions (if provided)\n const rewriteFunction = isItinerary\n ? qp.itineraryRewrite\n : qp.profileRewrite;\n params = Object.assign(\n params,\n rewriteFunction\n ? rewriteFunction(currentQuery[qp.name])\n : { [qp.name]: currentQuery[qp.name] }\n );\n });\n\n // Additional processing specific to ITINERARY mode\n if (isItinerary) {\n // override ignoreRealtimeUpdates if provided\n if (typeof ignoreRealtimeUpdates === \"boolean\") {\n params.ignoreRealtimeUpdates = ignoreRealtimeUpdates;\n }\n\n // check date/time validity; ignore both if either is invalid\n const dateValid = isMatch(params.date, OTP_API_DATE_FORMAT);\n const timeValid = isMatch(params.time, OTP_API_TIME_FORMAT);\n\n if (!dateValid || !timeValid) {\n delete params.time;\n delete params.date;\n }\n\n // temp: set additional parameters for CAR_HAIL or CAR_RENT trips\n if (\n params.mode &&\n (params.mode.includes(\"CAR_HAIL\") || params.mode.includes(\"CAR_RENT\"))\n ) {\n params.minTransitDistance = \"50%\";\n // increase search timeout because these queries can take a while\n params.searchTimeout = 10000;\n }\n\n // set onlyTransitTrips for car rental searches\n if (params.mode && params.mode.includes(\"CAR_RENT\")) {\n params.onlyTransitTrips = true;\n }\n\n // Additional processing specific to PROFILE mode\n } else {\n // check start and end time validity; ignore both if either is invalid\n const startTimeValid = isMatch(params.startTime, OTP_API_TIME_FORMAT);\n const endTimeValid = isMatch(params.endTime, OTP_API_TIME_FORMAT);\n\n if (!startTimeValid || !endTimeValid) {\n delete params.startTimeValid;\n delete params.endTimeValid;\n }\n }\n\n // TODO: check that valid from/to locations are provided\n\n // hack to add walking to driving/TNC trips\n if (hasCar(params.mode)) {\n params.mode += \",WALK\";\n }\n\n // Replace FLEX placeholder with OTP flex modes\n // Explicit false check allows avoiding a breaking change -- undefined is true\n if (params.mode && config.modes?.mergeFlex !== false) {\n // Ensure query is in reduced format to avoid replacing twice\n const reducedMode = reduceOtpFlexModes(params.mode.split(\",\")).join(\",\");\n params.mode = expandOtpFlexMode(reducedMode);\n }\n\n return params;\n}\n"],"file":"query.js"}
1
+ {"version":3,"file":"query.js","names":["_dateFns","require","_lib","_interopRequireDefault","_qs","_itinerary","_map","_queryParams","_time","defaultParams","exports","TIME_FORMATS","getQueryParamProperty","paramInfo","property","query","ensureSingleAccessMode","queryModes","accessCount","filter","m","isAccessMode","length","firstAccess","find","push","getUrlParams","window","qs","parse","location","href","split","undefined","getOtpUrlParams","Object","keys","key","startsWith","getTripOptionsFromQuery","keepPlace","options","time","departArrive","date","from","to","getDefaultQueryParamValue","param","default","getDefaultQuery","config","defaultQuery","routingType","queryParams","qp","forEach","name","routingTypes","defaultQueryParams","isParamApplicable","applicable","includes","reduceOtpFlexModes","modes","enabled","reduce","prev","cur","newModes","expandOtpFlexMode","mode","map","join","isNotDefaultQuery","activeModes","sort","mergeFlex","defaultModes","getTransitModes","concat","modesEqual","every","value","index","i","getFirstGeocodeResult","text","geocoderConfig","geocoderMethod","geocoder","getGeocoder","then","result","firstResult","features","getLocationFromGeocodedFeature","parseLocationString","parts","coordinates","stringToCoords","coordsToString","lat","lon","queryParamToLocation","autoMethod","planParamsToQuery","params","fromPlace","toPlace","arriveBy","getCurrentDate","matchedTimeFormat","timeFormat","isMatch","format","Date","OTP_API_TIME_FORMAT","getCurrentTime","intermediatePlaces","maybeNumber","Number","isNaN","planParamsToQueryAsync","getRoutingParams","currentQuery","ignoreRealtimeUpdates","isItinerary","indexOf","rewriteFunction","itineraryRewrite","profileRewrite","assign","dateValid","OTP_API_DATE_FORMAT","timeValid","minTransitDistance","searchTimeout","onlyTransitTrips","startTimeValid","startTime","endTimeValid","endTime","hasCar","reducedMode"],"sources":["../src/query.js"],"sourcesContent":["import { format, isMatch, parse } from \"date-fns\";\nimport getGeocoder from \"@opentripplanner/geocoder/lib\";\nimport qs from \"qs\";\n\nimport { getTransitModes, hasCar, isAccessMode } from \"./itinerary\";\nimport { coordsToString, stringToCoords } from \"./map\";\nimport queryParams from \"./query-params\";\nimport {\n getCurrentTime,\n getCurrentDate,\n OTP_API_DATE_FORMAT,\n OTP_API_TIME_FORMAT\n} from \"./time\";\n\n/* The list of default parameters considered in the settings panel */\n\nexport const defaultParams = [\n \"wheelchair\",\n \"maxWalkDistance\",\n \"walkReluctance\",\n \"maxWalkTime\",\n \"maxBikeDistance\",\n \"maxBikeTime\",\n \"bikeSpeed\",\n \"optimize\",\n \"optimizeBike\",\n \"maxEScooterDistance\",\n \"watts\"\n];\n\n/**\n * List of time formats to parse when reading query params.\n */\nconst TIME_FORMATS = [\n \"HH:mm:ss\",\n \"HH:mm\",\n \"H:mm\",\n \"h:mm:ss a\",\n \"h:mm:ssa\",\n \"h:mm a\",\n \"h:mma\",\n \"h:mm\",\n \"HHmm\",\n \"hmm\",\n \"ha\"\n];\n\n/* A function to retrieve a property value from an entry in the query-params\n * table, checking for either a static value or a function */\n\nexport function getQueryParamProperty(paramInfo, property, query) {\n return typeof paramInfo[property] === \"function\"\n ? paramInfo[property](query)\n : paramInfo[property];\n}\n\nexport function ensureSingleAccessMode(queryModes) {\n // Count the number of access modes\n const accessCount = queryModes.filter(m => isAccessMode(m)).length;\n\n // If multiple access modes are specified, keep only the first one\n if (accessCount > 1) {\n const firstAccess = queryModes.find(m => isAccessMode(m));\n queryModes = queryModes.filter(m => !isAccessMode(m) || m === firstAccess);\n\n // If no access modes are specified, add 'WALK' as the default\n } else if (accessCount === 0) {\n queryModes.push(\"WALK\");\n }\n\n return queryModes;\n}\n\nexport function getUrlParams() {\n if (window) {\n return qs.parse(window.location.href.split(\"?\")[1]);\n }\n return undefined;\n}\n\nexport function getOtpUrlParams() {\n return Object.keys(getUrlParams()).filter(key => !key.startsWith(\"ui_\"));\n}\n\nexport function getTripOptionsFromQuery(query, keepPlace = false) {\n const options = { ...query };\n // Delete time/date options and from/to\n delete options.time;\n delete options.departArrive;\n delete options.date;\n if (!keepPlace) {\n delete options.from;\n delete options.to;\n }\n return options;\n}\n\n/**\n * Gets the query param's default value that is either a constant or by\n * executing the default value function.\n */\nfunction getDefaultQueryParamValue(param) {\n return typeof param.default === \"function\" ? param.default() : param.default;\n}\n\n/**\n * Get the default query to OTP based on the given config.\n */\nexport function getDefaultQuery(config = null) {\n const defaultQuery = { routingType: \"ITINERARY\" };\n queryParams\n .filter(qp => \"default\" in qp)\n .forEach(qp => {\n defaultQuery[qp.name] = getDefaultQueryParamValue(qp);\n });\n if (config) {\n if (config.routingTypes && config.routingTypes.length > 0) {\n defaultQuery.routingType = config.routingTypes[0].key;\n }\n if (config.defaultQueryParams) {\n Object.keys(config.defaultQueryParams).forEach(key => {\n defaultQuery[key] = config.defaultQueryParams[key];\n });\n }\n }\n return defaultQuery;\n}\n\n/**\n * Determine if the specified query param applies to the given query (based on\n * routing type and the param's own applicable function).\n * @param paramInfo an entry from query-params.js\n * @param query the query against which to check if the param applies\n * @param config OTP config\n * @return {Boolean}\n */\nfunction isParamApplicable(paramInfo, query, config) {\n const { applicable, routingTypes } = paramInfo;\n if (!routingTypes.includes(query.routingType)) return false;\n if (typeof applicable === \"function\" && !applicable(query, config)) {\n return false;\n }\n return true;\n}\n\n/**\n * Helper method which replaces OTP flex modes with single FLEX mode that's\n * more useful and easier to work with.\n */\nexport function reduceOtpFlexModes(modes, enabled = true) {\n if (!enabled) return modes;\n\n return modes.reduce((prev, cur) => {\n const newModes = prev;\n // Add the current mode if it is not a flex mode\n if (!cur.includes(\"FLEX\")) {\n newModes.push(cur);\n // If it is a flex mode, do not add it but rather add the custom flex mode\n // if not already present\n } else if (!newModes.includes(\"FLEX\")) {\n newModes.push(\"FLEX\");\n }\n return newModes;\n }, []);\n}\n\n/**\n * Helper method to process a mode string, replacing all instances of FLEX\n * with the full set of FLEX modes used by otp-2\n * @param {*} mode a mode String, not an array\n * @returns a mode String, not an array (with flex modes expanded)\n */\nexport function expandOtpFlexMode(mode) {\n const modes = reduceOtpFlexModes(mode.split(\",\"));\n return modes\n .map(m => {\n // If both the expanded and shrunk modes are included, remove the expanded one\n if (m === \"FLEX_EGRESS\" || m === \"FLEX_ACCESS\" || m === \"FLEX_DIRECT\") {\n if (mode.includes(\"FLEX\")) return \"\";\n }\n if (m === \"FLEX\") {\n return \"FLEX_EGRESS,FLEX_ACCESS,FLEX_DIRECT\";\n }\n return m;\n })\n .join(\",\");\n}\n\n/**\n * Determines whether the specified query differs from the default query, i.e.,\n * whether the user has modified any trip options (including mode) from their\n * default values.\n */\nexport function isNotDefaultQuery(query, config) {\n const activeModes = reduceOtpFlexModes(\n query.mode.split(\",\").sort(),\n config.modes?.mergeFlex\n );\n if (\n activeModes.length !== 2 ||\n activeModes[0] !== \"TRANSIT\" ||\n activeModes[1] !== \"WALK\"\n ) {\n // Default mode is TRANSIT,WALK. If general TRANSIT is not used, check\n // against available transit modes in config.\n const defaultModes = getTransitModes(config)\n .concat([\"WALK\"])\n .sort();\n const modesEqual =\n activeModes.length === defaultModes.length &&\n activeModes.every((value, index) => {\n return value === defaultModes[index];\n });\n if (!modesEqual) return true;\n }\n // If modes are equal, check the remaining params.\n const defaultQuery = getDefaultQuery(config);\n for (let i = 0; i < defaultParams.length; i++) {\n const param = defaultParams[i];\n const paramInfo = queryParams.find(qp => qp.name === param);\n // If the parameter applies to the query and does not match the default\n // value, the query is not default.\n if (\n isParamApplicable(paramInfo, query, config) &&\n query[param] !== defaultQuery[param]\n ) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Geocode utility for returning the first result for the provided place name text.\n * @param {string} text - text to search\n * @param {Object} geocoderConfig\n * @param {string} geocoderMethod - an alternate geocoder api method to use. Defaults to `search`\n * @return {Location}\n */\nasync function getFirstGeocodeResult(\n text,\n geocoderConfig,\n geocoderMethod = \"search\"\n) {\n const geocoder = getGeocoder(geocoderConfig);\n // Attempt to geocode search text and return first result if found.\n // TODO: Import geocoder from @opentripplanner\n return geocoder[geocoderMethod]({ text }).then(result => {\n const firstResult = result.features && result.features[0];\n if (firstResult) {\n return geocoder.getLocationFromGeocodedFeature(firstResult);\n }\n return null;\n });\n}\n\n/**\n * OTP allows passing a location in the form '123 Main St::lat,lon', so we check\n * for the double colon and parse the coordinates accordingly.\n * @param {string} value - query param for place described above\n * @return {Location} - location or null if the value is falsey or the parsed\n * coordinates do not result in both a lat and lon\n */\nexport function parseLocationString(value) {\n if (!value) return null;\n const parts = value.split(\"::\");\n const coordinates = parts[1]\n ? stringToCoords(parts[1])\n : stringToCoords(parts[0]);\n const name = parts[1] ? parts[0] : coordsToString(coordinates);\n return coordinates.length === 2\n ? {\n name: name || null,\n lat: coordinates[0] || null,\n lon: coordinates[1] || null\n }\n : null;\n}\n\n/**\n * Convert a string query param for a from or to place into a location. If\n * coordinates not provided and geocoder config is present, use the first\n * geocoded result.\n * @param {string} value\n * @param {Object} [geocoderConfig=null]\n * @return {Location}\n */\nasync function queryParamToLocation(value, geocoderConfig) {\n let location = parseLocationString(value);\n if (!location && value && geocoderConfig) {\n // If a valid location was not found, but the place name text exists,\n // attempt to geocode the name.\n location = await getFirstGeocodeResult(\n value,\n geocoderConfig,\n geocoderConfig.autoMethod\n );\n }\n return location;\n}\n\n/**\n * Create a otp query based on a the url params.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n */\nexport function planParamsToQuery(params) {\n const query = {};\n Object.keys(params).forEach(key => {\n switch (key) {\n case \"fromPlace\":\n query.from = parseLocationString(params.fromPlace);\n break;\n case \"toPlace\":\n query.to = parseLocationString(params.toPlace);\n break;\n case \"arriveBy\":\n query.departArrive =\n params.arriveBy === \"true\"\n ? \"ARRIVE\"\n : params.arriveBy === \"false\"\n ? \"DEPART\"\n : \"NOW\";\n break;\n case \"date\":\n query.date = params.date || getCurrentDate();\n break;\n case \"time\":\n {\n // Match one of the supported time formats\n const matchedTimeFormat = TIME_FORMATS.find(timeFormat =>\n isMatch(params.time, timeFormat)\n );\n query.time = matchedTimeFormat\n ? format(\n parse(params.time, matchedTimeFormat, new Date()),\n OTP_API_TIME_FORMAT\n )\n : getCurrentTime();\n }\n break;\n case \"intermediatePlaces\":\n // If query has intermediate places, ensure that they are parsed\n // as locations.\n query.intermediatePlaces = params.intermediatePlaces\n ? params.intermediatePlaces.map(parseLocationString)\n : [];\n break;\n default: {\n const maybeNumber = Number(params[key]);\n // If the param value is an empty string literal and is not a number,\n // use string value. Else, use parsed number value.\n // See https://github.com/opentripplanner/otp-ui/issues/50\n query[key] =\n params[key] === \"\" || Number.isNaN(maybeNumber)\n ? params[key]\n : maybeNumber;\n break;\n }\n }\n });\n return query;\n}\n\n/**\n * Async method to create a otp query based on a the url params. This provides\n * the same functionality as planParamsToQuery, except that it will also attempt\n * to geocode the input from and to strings if no lat/lng values were provided.\n *\n * @param {Object} params An object representing the parsed querystring of url\n * params.\n * @param config the config in the otp-rr store.\n */\nexport async function planParamsToQueryAsync(params, config = {}) {\n // Construct query from plan params.\n const query = planParamsToQuery(params);\n // Attempt to geocode from and to params if the string parsing does not return\n // valid locations.\n if (!query.from) {\n query.from = await queryParamToLocation(params.fromPlace, config.geocoder);\n }\n if (!query.to) {\n query.to = await queryParamToLocation(params.toPlace, config.geocoder);\n }\n return query;\n}\n\n/**\n * Create an object that can be used as a querystring in making an OTP\n * PlannerResource request.\n *\n * See http://otp-docs.ibi-transit.com/api/resource_PlannerResource.html\n *\n * @param {Object} config The OTP application config. See types#configType\n * @param {Object} currentQuery The current query parameters as saved in the\n * application state. This method does some extra logic on top of this data\n * in order to create a request suitable for OTP. See __tests__/query.js#L14 for more.\n * @param {boolean} ignoreRealtimeUpdates If true, will create a request that\n * does not use realtime data.\n */\nexport function getRoutingParams(config, currentQuery, ignoreRealtimeUpdates) {\n const routingType = currentQuery.routingType;\n const isItinerary = routingType === \"ITINERARY\";\n let params = {};\n\n // Start with the universe of OTP parameters defined in query-params.js:\n queryParams\n .filter(qp => {\n // A given parameter is included in the request if all of the following:\n // 1. Must apply to the active routing type (ITINERARY or PROFILE)\n // 2. Must be included in the current user-defined query\n // 3. Must pass the parameter's applicability test, if one is specified\n return (\n qp.routingTypes.indexOf(routingType) !== -1 &&\n qp.name in currentQuery &&\n (typeof qp.applicable !== \"function\" ||\n qp.applicable(currentQuery, config))\n );\n })\n .forEach(qp => {\n // Translate the applicable parameters according to their rewrite\n // functions (if provided)\n const rewriteFunction = isItinerary\n ? qp.itineraryRewrite\n : qp.profileRewrite;\n params = Object.assign(\n params,\n rewriteFunction\n ? rewriteFunction(currentQuery[qp.name])\n : { [qp.name]: currentQuery[qp.name] }\n );\n });\n\n // Additional processing specific to ITINERARY mode\n if (isItinerary) {\n // override ignoreRealtimeUpdates if provided\n if (typeof ignoreRealtimeUpdates === \"boolean\") {\n params.ignoreRealtimeUpdates = ignoreRealtimeUpdates;\n }\n\n // check date/time validity; ignore both if either is invalid\n const dateValid = isMatch(params.date, OTP_API_DATE_FORMAT);\n const timeValid = isMatch(params.time, OTP_API_TIME_FORMAT);\n\n if (!dateValid || !timeValid) {\n delete params.time;\n delete params.date;\n }\n\n // temp: set additional parameters for CAR_HAIL or CAR_RENT trips\n if (\n params.mode &&\n (params.mode.includes(\"CAR_HAIL\") || params.mode.includes(\"CAR_RENT\"))\n ) {\n params.minTransitDistance = \"50%\";\n // increase search timeout because these queries can take a while\n params.searchTimeout = 10000;\n }\n\n // set onlyTransitTrips for car rental searches\n if (params.mode && params.mode.includes(\"CAR_RENT\")) {\n params.onlyTransitTrips = true;\n }\n\n // Additional processing specific to PROFILE mode\n } else {\n // check start and end time validity; ignore both if either is invalid\n const startTimeValid = isMatch(params.startTime, OTP_API_TIME_FORMAT);\n const endTimeValid = isMatch(params.endTime, OTP_API_TIME_FORMAT);\n\n if (!startTimeValid || !endTimeValid) {\n delete params.startTimeValid;\n delete params.endTimeValid;\n }\n }\n\n // TODO: check that valid from/to locations are provided\n\n // hack to add walking to driving/TNC trips\n if (hasCar(params.mode)) {\n params.mode += \",WALK\";\n }\n\n // Replace FLEX placeholder with OTP flex modes\n // Explicit false check allows avoiding a breaking change -- undefined is true\n if (params.mode && config.modes?.mergeFlex !== false) {\n // Ensure query is in reduced format to avoid replacing twice\n const reducedMode = reduceOtpFlexModes(params.mode.split(\",\")).join(\",\");\n params.mode = expandOtpFlexMode(reducedMode);\n }\n\n return params;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAOA;;AAEO,MAAMQ,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,CAC3B,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,OAAO,CACR;;AAED;AACA;AACA;AACA,MAAME,YAAY,GAAG,CACnB,UAAU,EACV,OAAO,EACP,MAAM,EACN,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,CACL;;AA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