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