@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
@@ -1,786 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
7
- // TODO: Remove this entire file, as it is deprecated in favor of i18n-queryParams within
8
- // the SettingsSelector package
9
- // This is only used within stories
10
- import cloneDeep from "lodash.clonedeep";
11
- import React from "react";
12
- import { Wheelchair } from "@styled-icons/foundation/Wheelchair";
13
- import { isTransit, isAccessMode, isCar, hasTransit, hasBike, hasMicromobility } from "./itinerary";
14
- import { getItem } from "./storage";
15
- import { getCurrentDate, getCurrentTime } from "./time";
16
- /**
17
- * name: the default name of the parameter used for internal reference and API calls
18
- *
19
- * routingTypes: array of routing type(s) (ITINERARY, PROFILE, or both) this param applies to
20
- *
21
- * applicable: an optional function (accepting the current full query as a
22
- * parameter) indicating whether this query parameter is applicable to the query.
23
- * (Applicability is assumed if this function is not provided.)
24
- *
25
- * default: the default value for this parameter. The default can be also be a
26
- * function that gets executed when accessing the default value.
27
- *
28
- * itineraryRewrite: an optional function for translating the key and/or value
29
- * for ITINERARY mode only (e.g. 'to' is rewritten as 'toPlace'). Accepts the
30
- * initial internal value as a function parameter.
31
- *
32
- * profileRewrite: an optional function for translating the value for PROFILE mode
33
- *
34
- * label: a text label for for onscreen display. May either be a text string or a
35
- * function (accepting the current full query as a parameter) returning a string
36
- *
37
- * selector: the default type of UI selector to use in the form. Can be one of:
38
- * - DROPDOWN: a standard drop-down menu selector
39
- *
40
- * options: an array of text/value pairs used with a dropdown selector
41
- *
42
- * TODO: validation system for rewrite functions and/or better user documentation
43
- * TODO: alphabetize below list
44
- */
45
- // FIXME: Use for parsing URL values?
46
- // const stringToLocation = string => {
47
- // const split = string.split(',')
48
- // return split.length === 2
49
- // ? {lat: split[0], lon: split[1]}
50
- // : {lat: null, lon: null}
51
- // }
52
-
53
- /**
54
- * Format location object as string for use in fromPlace or toPlace query param.
55
- */
56
-
57
- export function formatPlace(location, alternateName) {
58
- if (!location) return null;
59
- var name = location.name || "".concat(alternateName ? "".concat(alternateName, " ") : "", "(").concat(location.lat, ",").concat(location.lon, ")"); // This string is not language-specific
60
-
61
- return "".concat(name, "::").concat(location.lat, ",").concat(location.lon);
62
- } // Load stored default query settings from local storage
63
-
64
- var storedSettings = getItem("defaultQuery", {});
65
- var queryParams = [{
66
- /* from - the trip origin. stored internally as a location (lat/lon/name) object */
67
- name: "from",
68
- routingTypes: ["ITINERARY", "PROFILE"],
69
- "default": null,
70
- itineraryRewrite: function itineraryRewrite(value) {
71
- return {
72
- fromPlace: formatPlace(value)
73
- };
74
- },
75
- profileRewrite: function profileRewrite(value) {
76
- return {
77
- from: {
78
- lat: value.lat,
79
- lon: value.lon
80
- }
81
- };
82
- } // FIXME: Use for parsing URL values?
83
- // fromURL: stringToLocation
84
-
85
- }, {
86
- /* to - the trip destination. stored internally as a location (lat/lon/name) object */
87
- name: "to",
88
- routingTypes: ["ITINERARY", "PROFILE"],
89
- "default": null,
90
- itineraryRewrite: function itineraryRewrite(value) {
91
- return {
92
- toPlace: formatPlace(value)
93
- };
94
- },
95
- profileRewrite: function profileRewrite(value) {
96
- return {
97
- to: {
98
- lat: value.lat,
99
- lon: value.lon
100
- }
101
- };
102
- } // FIXME: Use for parsing URL values?
103
- // fromURL: stringToLocation
104
-
105
- }, {
106
- /* date - the date of travel, in MM-DD-YYYY format */
107
- name: "date",
108
- routingTypes: ["ITINERARY", "PROFILE"],
109
- "default": getCurrentDate
110
- }, {
111
- /* time - the arrival/departure time for an itinerary trip, in HH:mm format */
112
- name: "time",
113
- routingTypes: ["ITINERARY"],
114
- "default": getCurrentTime
115
- }, {
116
- /* departArrive - whether this is a depart-at, arrive-by, or leave-now trip */
117
- name: "departArrive",
118
- routingTypes: ["ITINERARY"],
119
- "default": "NOW",
120
- itineraryRewrite: function itineraryRewrite(value) {
121
- return {
122
- arriveBy: value === "ARRIVE"
123
- };
124
- }
125
- }, {
126
- /* startTime - the start time for a profile trip, in HH:mm format */
127
- name: "startTime",
128
- routingTypes: ["PROFILE"],
129
- "default": "07:00"
130
- }, {
131
- /* endTime - the end time for a profile trip, in HH:mm format */
132
- name: "endTime",
133
- routingTypes: ["PROFILE"],
134
- "default": "09:00"
135
- }, {
136
- /* mode - the allowed modes for a trip, as a comma-separated list */
137
- name: "mode",
138
- routingTypes: ["ITINERARY", "PROFILE"],
139
- "default": "WALK,TRANSIT",
140
- // TODO: make this dependent on routingType?
141
- profileRewrite: function profileRewrite(value) {
142
- var accessModes = [];
143
- var directModes = [];
144
- var transitModes = [];
145
-
146
- if (value && value.length > 0) {
147
- value.split(",").forEach(function (m) {
148
- if (isTransit(m)) transitModes.push(m);
149
-
150
- if (isAccessMode(m)) {
151
- accessModes.push(m); // TODO: make configurable whether direct-driving is considered
152
-
153
- if (!isCar(m)) directModes.push(m);
154
- }
155
- });
156
- }
157
-
158
- return {
159
- accessModes: accessModes,
160
- directModes: directModes,
161
- transitModes: transitModes
162
- };
163
- }
164
- }, {
165
- /* showIntermediateStops - whether response should include intermediate stops for transit legs */
166
- name: "showIntermediateStops",
167
- routingTypes: ["ITINERARY"],
168
- "default": true
169
- }, {
170
- /* maxWalkDistance - the maximum distance in meters the user will walk to transit. */
171
- name: "maxWalkDistance",
172
- routingTypes: ["ITINERARY"],
173
- applicable: function applicable(query) {
174
- return (
175
- /* Since this query variable isn't in this list, it's not included in the generated query
176
- * It does however allow us to determine if we should show the OTP1 max walk distance
177
- * dropdown or the OTP2 walk reluctance slider
178
- */
179
- !query.otp2 && query.mode && hasTransit(query.mode) && query.mode.indexOf("WALK") !== -1
180
- );
181
- },
182
- "default": 1609,
183
- // 1 mi.
184
- selector: "DROPDOWN",
185
- label: "Maximum Walk",
186
- options: [{
187
- text: "1/10 mile",
188
- value: 160.9
189
- }, {
190
- text: "1/4 mile",
191
- value: 402.3
192
- }, {
193
- text: "1/2 mile",
194
- value: 804.7
195
- }, {
196
- text: "3/4 mile",
197
- value: 1207
198
- }, {
199
- text: "1 mile",
200
- value: 1609
201
- }, {
202
- text: "2 miles",
203
- value: 3219
204
- }, {
205
- text: "5 miles",
206
- value: 8047
207
- }]
208
- }, {
209
- /* maxBikeDistance - the maximum distance in meters the user will bike. Not
210
- * actually an OTP parameter (maxWalkDistance doubles for biking) but we
211
- * store it separately internally in order to allow different default values,
212
- * options, etc. Translated to 'maxWalkDistance' via the rewrite function.
213
- */
214
- name: "maxBikeDistance",
215
- routingTypes: ["ITINERARY"],
216
- applicable: function applicable(query) {
217
- return query.mode && hasTransit(query.mode) && query.mode.indexOf("BICYCLE") !== -1;
218
- },
219
- "default": 4828,
220
- // 3 mi.
221
- selector: "DROPDOWN",
222
- label: "Maximum Bike",
223
- options: [{
224
- text: "1/4 mile",
225
- value: 402.3
226
- }, {
227
- text: "1/2 mile",
228
- value: 804.7
229
- }, {
230
- text: "3/4 mile",
231
- value: 1207
232
- }, {
233
- text: "1 mile",
234
- value: 1609
235
- }, {
236
- text: "2 miles",
237
- value: 3219
238
- }, {
239
- text: "3 miles",
240
- value: 4828
241
- }, {
242
- text: "5 miles",
243
- value: 8047
244
- }, {
245
- text: "10 miles",
246
- value: 16093
247
- }, {
248
- text: "20 miles",
249
- value: 32187
250
- }, {
251
- text: "30 miles",
252
- value: 48280
253
- }],
254
- itineraryRewrite: function itineraryRewrite(value) {
255
- return {
256
- maxWalkDistance: value,
257
- // ensures that the value is repopulated when loaded from URL params
258
- maxBikeDistance: value
259
- };
260
- }
261
- }, {
262
- /* optimize -- how to optimize a trip (non-bike, non-micromobility trips) */
263
- name: "optimize",
264
- // This parameter doesn't seem to do anything
265
- applicable: function applicable() {
266
- return false;
267
- },
268
- routingTypes: ["ITINERARY"],
269
- "default": "QUICK",
270
- selector: "DROPDOWN",
271
- label: "Optimize for",
272
- options: [{
273
- text: "Speed",
274
- value: "QUICK"
275
- }, {
276
- text: "Fewest Transfers",
277
- value: "TRANSFERS"
278
- }]
279
- }, {
280
- /* optimizeBike -- how to optimize an bike-based trip */
281
- name: "optimizeBike",
282
- applicable: function applicable(query) {
283
- return !query.otp2 && hasBike(query.mode);
284
- },
285
- routingTypes: ["ITINERARY"],
286
- "default": "SAFE",
287
- selector: "DROPDOWN",
288
- label: "Optimize for",
289
- options: function options() {
290
- var opts = [{
291
- text: "Speed",
292
- value: "QUICK"
293
- }, {
294
- text: "Bike-Friendly Trip",
295
- value: "SAFE"
296
- }, {
297
- text: "Flat Trip",
298
- value: "FLAT"
299
- }];
300
- return opts;
301
- },
302
- itineraryRewrite: function itineraryRewrite(value) {
303
- return {
304
- optimize: value
305
- };
306
- }
307
- }, {
308
- /* maxWalkTime -- the maximum time the user will spend walking in minutes */
309
- name: "maxWalkTime",
310
- routingTypes: ["PROFILE"],
311
- "default": 15,
312
- selector: "DROPDOWN",
313
- label: "Max Walk Time",
314
- applicable: function applicable(query) {
315
- return query.mode && hasTransit(query.mode) && query.mode.indexOf("WALK") !== -1;
316
- },
317
- options: [{
318
- text: "5 minutes",
319
- value: 5
320
- }, {
321
- text: "10 minutes",
322
- value: 10
323
- }, {
324
- text: "15 minutes",
325
- value: 15
326
- }, {
327
- text: "20 minutes",
328
- value: 20
329
- }, {
330
- text: "30 minutes",
331
- value: 30
332
- }, {
333
- text: "45 minutes",
334
- value: 45
335
- }, {
336
- text: "1 hour",
337
- value: 60
338
- }]
339
- }, {
340
- name: "walkReluctance",
341
- routingTypes: ["ITINERARY", "PROFILE"],
342
- selector: "SLIDER",
343
- low: 1,
344
- high: 10,
345
- step: 0.5,
346
- label: "walk reluctance",
347
- labelLow: "More Walking",
348
- labelHigh: "More Transit",
349
- applicable: function applicable(query) {
350
- return (
351
- /* Since this query variable isn't in this list, it's not included in the generated query
352
- * It does however allow us to determine if we should show the OTP1 max walk distance
353
- * dropdown or the OTP2 walk reluctance slider
354
- */
355
- !!query.otp2 && query.mode && query.mode.indexOf("WALK") !== -1
356
- );
357
- }
358
- }, {
359
- /* maxBikeTime -- the maximum time the user will spend biking in minutes */
360
- name: "maxBikeTime",
361
- routingTypes: ["PROFILE"],
362
- "default": 20,
363
- selector: "DROPDOWN",
364
- label: "Max Bike Time",
365
- applicable: function applicable(query) {
366
- return query.mode && hasTransit(query.mode) && query.mode.indexOf("BICYCLE") !== -1;
367
- },
368
- options: [{
369
- text: "5 minutes",
370
- value: 5
371
- }, {
372
- text: "10 minutes",
373
- value: 10
374
- }, {
375
- text: "15 minutes",
376
- value: 15
377
- }, {
378
- text: "20 minutes",
379
- value: 20
380
- }, {
381
- text: "30 minutes",
382
- value: 30
383
- }, {
384
- text: "45 minutes",
385
- value: 45
386
- }, {
387
- text: "1 hour",
388
- value: 60
389
- }]
390
- }, {
391
- /* bikeSpeed -- the user's bikeSpeed speed in m/s */
392
- name: "bikeSpeed",
393
- routingTypes: ["ITINERARY", "PROFILE"],
394
- "default": 3.58,
395
- selector: "DROPDOWN",
396
- label: "Bicycle Speed",
397
- applicable: function applicable(query) {
398
- return query.mode && query.mode.indexOf("BICYCLE") !== -1;
399
- },
400
- options: [{
401
- text: "6 MPH",
402
- value: 2.68
403
- }, {
404
- text: "8 MPH",
405
- value: 3.58
406
- }, {
407
- text: "10 MPH",
408
- value: 4.47
409
- }, {
410
- text: "12 MPH",
411
- value: 5.36
412
- }]
413
- }, {
414
- /* maxEScooterDistance - the maximum distance in meters the user will ride
415
- * an E-scooter. Not actually an OTP parameter (maxWalkDistance doubles for
416
- * any non-transit mode except for car) but we store it separately
417
- * internally in order to allow different default values, options, etc.
418
- * Translated to 'maxWalkDistance' via the rewrite function.
419
- */
420
- name: "maxEScooterDistance",
421
- routingTypes: ["ITINERARY"],
422
- applicable: function applicable(query) {
423
- return query.mode && hasTransit(query.mode) && hasMicromobility(query.mode);
424
- },
425
- "default": 4828,
426
- // 3 mi.
427
- selector: "DROPDOWN",
428
- label: "Maximum E-scooter Distance",
429
- options: [{
430
- text: "1/4 mile",
431
- value: 402.3
432
- }, {
433
- text: "1/2 mile",
434
- value: 804.7
435
- }, {
436
- text: "3/4 mile",
437
- value: 1207
438
- }, {
439
- text: "1 mile",
440
- value: 1609
441
- }, {
442
- text: "2 miles",
443
- value: 3219
444
- }, {
445
- text: "3 miles",
446
- value: 4828
447
- }, {
448
- text: "5 miles",
449
- value: 8047
450
- }, {
451
- text: "10 miles",
452
- value: 16093
453
- }, {
454
- text: "20 miles",
455
- value: 32187
456
- }, {
457
- text: "30 miles",
458
- value: 48280
459
- }],
460
- itineraryRewrite: function itineraryRewrite(value) {
461
- return {
462
- maxWalkDistance: value,
463
- // ensures that the value is repopulated when loaded from URL params
464
- maxEScooterDistance: value
465
- };
466
- }
467
- }, {
468
- /* bikeSpeed -- the user's bikeSpeed speed in m/s */
469
- name: "watts",
470
- routingTypes: ["ITINERARY", "PROFILE"],
471
- "default": 250,
472
- selector: "DROPDOWN",
473
- label: "E-scooter Power",
474
- // this configuration should only be allowed for personal E-scooters as these
475
- // settings will be defined by the vehicle type of an E-scooter being rented
476
- applicable: function applicable(query) {
477
- return query.mode && query.mode.indexOf("MICROMOBILITY") !== -1 && query.mode.indexOf("MICROMOBILITY_RENT") === -1 && query.mode.indexOf("SCOOTER") === -1;
478
- },
479
- options: [{
480
- text: "Kid's hoverboard (6mph)",
481
- value: 125
482
- }, {
483
- text: "Entry-level scooter (11mph)",
484
- value: 250
485
- }, {
486
- text: "Robust E-scooter (18mph)",
487
- value: 500
488
- }, {
489
- text: "Powerful E-scooter (24mph)",
490
- value: 1500
491
- }],
492
- // rewrite a few other values to add some baseline assumptions about the
493
- // vehicle
494
- itineraryRewrite: function itineraryRewrite(value) {
495
- var watts = value; // the maximum cruising and downhill speed. Units in m/s
496
-
497
- var maximumMicromobilitySpeed;
498
- var weight; // see https://en.wikipedia.org/wiki/Human_body_weight#Average_weight_around_the_world
499
- // estimate is for an average North American human with clothes and stuff
500
- // units are in kg
501
-
502
- var TYPICAL_RIDER_WEIGHT = 90;
503
-
504
- switch (watts) {
505
- case 125:
506
- // exemplar: Swagtron Turbo 5 hoverboard (https://swagtron.com/product/recertified-swagtron-turbo-five-hoverboard-classic/)
507
- maximumMicromobilitySpeed = 2.8; // ~= 6mph
508
-
509
- weight = TYPICAL_RIDER_WEIGHT + 9;
510
- break;
511
-
512
- case 250:
513
- // exemplar: Xiaomi M365 (https://www.gearbest.com/skateboard/pp_596618.html)
514
- maximumMicromobilitySpeed = 5; // ~= 11.5mph
515
-
516
- weight = TYPICAL_RIDER_WEIGHT + 12.5;
517
- break;
518
-
519
- case 500:
520
- // exemplar: Razor EcoSmart Metro (https://www.amazon.com/Razor-EcoSmart-Metro-Electric-Scooter/dp/B002ZDAEIS?SubscriptionId=AKIAJMXJ2YFJTEDLQMUQ&tag=digitren08-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B002ZDAEIS&ascsubtag=15599460143449ocb)
521
- maximumMicromobilitySpeed = 8; // ~= 18mph
522
-
523
- weight = TYPICAL_RIDER_WEIGHT + 30;
524
- break;
525
-
526
- case 1000:
527
- // exemplar: Boosted Rev (https://boostedboards.com/vehicles/scooters/boosted-rev)
528
- maximumMicromobilitySpeed = 11; // ~= 24mph
529
-
530
- weight = TYPICAL_RIDER_WEIGHT + 21;
531
- break;
532
-
533
- default:
534
- break;
535
- }
536
-
537
- return {
538
- maximumMicromobilitySpeed: maximumMicromobilitySpeed,
539
- watts: watts,
540
- weight: weight
541
- };
542
- }
543
- }, {
544
- /* ignoreRealtimeUpdates -- if true, do not use realtime updates in routing */
545
- name: "ignoreRealtimeUpdates",
546
- routingTypes: ["ITINERARY"],
547
- "default": false
548
- }, {
549
- /* companies -- tnc companies to query */
550
- name: "companies",
551
- routingTypes: ["ITINERARY"]
552
- }, {
553
- /* wheelchair -- whether the user requires a wheelchair-accessible trip */
554
- name: "wheelchair",
555
- routingTypes: ["ITINERARY", "PROFILE"],
556
- "default": false,
557
- selector: "CHECKBOX",
558
- label: "Prefer Wheelchair Accessible Routes",
559
- icon: /*#__PURE__*/React.createElement(Wheelchair, null),
560
- applicable: function applicable(query, config) {
561
- if (!query.mode || !config.modes) return false;
562
- var configModes = (config.modes.accessModes || []).concat(config.modes.transitModes || []);
563
- return query.mode.split(",").some(function (mode) {
564
- var configMode = configModes.find(function (m) {
565
- return m.mode === mode;
566
- });
567
- if (!configMode || !configMode.showWheelchairSetting) return false;
568
- if (configMode.company && (!query.companies || !query.companies.split(",").includes(configMode.company))) return false;
569
- return true;
570
- });
571
- }
572
- }, {
573
- name: "bannedRoutes",
574
- routingTypes: ["ITINERARY"]
575
- }, {
576
- name: "numItineraries",
577
- routingTypes: ["ITINERARY"],
578
- "default": 3
579
- }, {
580
- name: "intermediatePlaces",
581
- "default": [],
582
- routingTypes: ["ITINERARY"],
583
- itineraryRewrite: function itineraryRewrite(places) {
584
- return Array.isArray(places) && places.length > 0 ? {
585
- intermediatePlaces: places.map(function (place) {
586
- return formatPlace(place);
587
- })
588
- } : undefined;
589
- }
590
- }, {
591
- // Time penalty in seconds the requester is willing to accept in order to
592
- // complete journey on preferred route. I.e., number of seconds that we are
593
- // willing to wait for the preferred route.
594
- name: "otherThanPreferredRoutesPenalty",
595
- "default": 15 * 60,
596
- // 15 minutes
597
- routingTypes: ["ITINERARY"]
598
- }, // Below are less commonly used query params included so that in case they are
599
- // passed in a query parameter they do not get filtered out from the ultimate
600
- // API request.
601
- {
602
- name: "preferredRoutes",
603
- routingTypes: ["ITINERARY"]
604
- }, {
605
- name: "maxPreTransitTime",
606
- routingTypes: ["ITINERARY"]
607
- }, {
608
- name: "waitReluctance",
609
- routingTypes: ["ITINERARY"]
610
- }, {
611
- name: "driveDistanceReluctance",
612
- routingTypes: ["ITINERARY"]
613
- }, {
614
- name: "driveTimeReluctance",
615
- routingTypes: ["ITINERARY"]
616
- }, {
617
- name: "waitAtBeginningFactor",
618
- routingTypes: ["ITINERARY"]
619
- }, {
620
- name: "bikeSwitchTime",
621
- routingTypes: ["ITINERARY"]
622
- }, {
623
- name: "bikeSwitchCost",
624
- routingTypes: ["ITINERARY"]
625
- }, {
626
- name: "minTransferTime",
627
- routingTypes: ["ITINERARY"]
628
- }, {
629
- name: "preferredAgencies",
630
- routingTypes: ["ITINERARY"]
631
- }, {
632
- name: "unpreferredRoutes",
633
- routingTypes: ["ITINERARY"]
634
- }, {
635
- name: "unpreferredAgencies",
636
- routingTypes: ["ITINERARY"]
637
- }, {
638
- name: "walkBoardCost",
639
- routingTypes: ["ITINERARY"]
640
- }, {
641
- name: "bikeBoardCost",
642
- routingTypes: ["ITINERARY"]
643
- }, {
644
- name: "whiteListedRoutes",
645
- routingTypes: ["ITINERARY"]
646
- }, {
647
- name: "bannedAgencies",
648
- routingTypes: ["ITINERARY"]
649
- }, {
650
- name: "whiteListedAgencies",
651
- routingTypes: ["ITINERARY"]
652
- }, {
653
- name: "bannedTrips",
654
- routingTypes: ["ITINERARY"]
655
- }, {
656
- name: "bannedStops",
657
- routingTypes: ["ITINERARY"]
658
- }, {
659
- name: "bannedStopsHard",
660
- routingTypes: ["ITINERARY"]
661
- }, {
662
- name: "transferPenalty",
663
- routingTypes: ["ITINERARY"]
664
- }, {
665
- name: "nonpreferredTransferPenalty",
666
- routingTypes: ["ITINERARY"]
667
- }, {
668
- name: "maxTransfers",
669
- routingTypes: ["ITINERARY"]
670
- }, {
671
- name: "batch",
672
- routingTypes: ["ITINERARY"]
673
- }, {
674
- name: "startTransitStopId",
675
- routingTypes: ["ITINERARY"]
676
- }, {
677
- name: "startTransitTripId",
678
- routingTypes: ["ITINERARY"]
679
- }, {
680
- name: "clampInitialWait",
681
- routingTypes: ["ITINERARY"]
682
- }, {
683
- name: "reverseOptimizeOnTheFly",
684
- routingTypes: ["ITINERARY"]
685
- }, {
686
- name: "boardSlack",
687
- routingTypes: ["ITINERARY"]
688
- }, {
689
- name: "alightSlack",
690
- routingTypes: ["ITINERARY"]
691
- }, {
692
- name: "locale",
693
- routingTypes: ["ITINERARY"]
694
- }, {
695
- name: "disableRemainingWeightHeuristic",
696
- routingTypes: ["ITINERARY"]
697
- }, {
698
- name: "flexFlagStopBufferSize",
699
- routingTypes: ["ITINERARY"]
700
- }, {
701
- name: "flexUseReservationServices",
702
- routingTypes: ["ITINERARY"]
703
- }, {
704
- name: "flexUseEligibilityServices",
705
- routingTypes: ["ITINERARY"]
706
- }, {
707
- name: "flexIgnoreDrtAdvanceBookMin",
708
- routingTypes: ["ITINERARY"]
709
- }, {
710
- name: "maxHours",
711
- routingTypes: ["ITINERARY"]
712
- }, {
713
- name: "useRequestedDateTimeInMaxHours",
714
- routingTypes: ["ITINERARY"]
715
- }, {
716
- name: "disableAlertFiltering",
717
- routingTypes: ["ITINERARY"]
718
- }, {
719
- name: "geoidElevation",
720
- routingTypes: ["ITINERARY"]
721
- }, {
722
- name: "invalidDateStrategy",
723
- routingTypes: ["ITINERARY"]
724
- }, {
725
- name: "minTransitDistance",
726
- routingTypes: ["ITINERARY"]
727
- }, {
728
- name: "searchTimeout",
729
- routingTypes: ["ITINERARY"]
730
- }, {
731
- name: "pathComparator",
732
- routingTypes: ["ITINERARY"]
733
- }, {
734
- name: "onlyTransitTrips",
735
- routingTypes: ["ITINERARY"]
736
- }, {
737
- name: "minimumMicromobilitySpeed",
738
- routingTypes: ["ITINERARY"]
739
- }]; // Iterate over stored settings and update query param defaults.
740
- // FIXME: this does not get updated if the user defaults are cleared
741
-
742
- queryParams.forEach(function (param) {
743
- if (param.name in storedSettings) {
744
- param["default"] = storedSettings[param.name];
745
- param.userDefaultOverride = true;
746
- }
747
- });
748
- export default queryParams;
749
- /**
750
- * You can customize the queryParams labels and options, and labels and values for each option.
751
- * @param customizations The optional customizations to apply: an object whose fields
752
- * correspond to the items in queryParams with the corresponding name,
753
- * the value for those fields being an object which fields (label, options...)
754
- * will override the originals.
755
- * Example:
756
- * {
757
- * // Matches the name param
758
- * maxWalkDistance: {
759
- * // Any fields that should be overridden go here
760
- * options: [
761
- * // ...new options
762
- * ],
763
- * default: 500,
764
- * label: "max walk dist"
765
- * }
766
- * }
767
- * @returns A copy of the default queryParams that has the given customizations applied.
768
- * If no customizations parameter is provided, returns the queryParams object itself.
769
- */
770
-
771
- export function getCustomQueryParams(customizations) {
772
- if (!customizations) return queryParams;
773
- var clonedParams = cloneDeep(queryParams);
774
- Object.keys(customizations).forEach(function (k) {
775
- // Merge fields into the cloned object
776
- var paramIndex = clonedParams.findIndex(function (param) {
777
- return param.name === k;
778
- });
779
-
780
- if (paramIndex !== -1) {
781
- clonedParams[paramIndex] = _objectSpread(_objectSpread({}, clonedParams[paramIndex]), customizations[k]);
782
- }
783
- });
784
- return clonedParams;
785
- }
786
- //# sourceMappingURL=query-params.js.map