minotor 9.0.0 → 9.0.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.
package/dist/cli.mjs CHANGED
@@ -13,6 +13,58 @@ import require$$5, { Transform } from 'stream';
13
13
  import { performance as performance$1 } from 'perf_hooks';
14
14
  import repl from 'node:repl';
15
15
 
16
+ /******************************************************************************
17
+ Copyright (c) Microsoft Corporation.
18
+
19
+ Permission to use, copy, modify, and/or distribute this software for any
20
+ purpose with or without fee is hereby granted.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
+ PERFORMANCE OF THIS SOFTWARE.
29
+ ***************************************************************************** */
30
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
31
+
32
+
33
+ function __awaiter(thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ }
42
+
43
+ function __values(o) {
44
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
45
+ if (m) return m.call(o);
46
+ if (o && typeof o.length === "number") return {
47
+ next: function () {
48
+ if (o && i >= o.length) o = void 0;
49
+ return { value: o && o[i++], done: !o };
50
+ }
51
+ };
52
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
53
+ }
54
+
55
+ function __asyncValues(o) {
56
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
57
+ var m = o[Symbol.asyncIterator], i;
58
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
59
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
60
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
61
+ }
62
+
63
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
64
+ var e = new Error(message);
65
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
66
+ };
67
+
16
68
  function getDefaultExportFromCjs (x) {
17
69
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
18
70
  }
@@ -15812,13 +15864,14 @@ const Stop = {
15812
15864
  sourceStopId: isSet$1(object.sourceStopId) ? globalThis.String(object.sourceStopId) : "",
15813
15865
  lat: isSet$1(object.lat) ? globalThis.Number(object.lat) : undefined,
15814
15866
  lon: isSet$1(object.lon) ? globalThis.Number(object.lon) : undefined,
15815
- children: globalThis.Array.isArray(object?.children) ? object.children.map((e) => globalThis.Number(e)) : [],
15867
+ children: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.children) ? object.children.map((e) => globalThis.Number(e)) : [],
15816
15868
  parent: isSet$1(object.parent) ? globalThis.Number(object.parent) : undefined,
15817
15869
  locationType: isSet$1(object.locationType) ? locationTypeFromJSON(object.locationType) : 0,
15818
15870
  platform: isSet$1(object.platform) ? globalThis.String(object.platform) : undefined,
15819
15871
  };
15820
15872
  },
15821
15873
  toJSON(message) {
15874
+ var _a;
15822
15875
  const obj = {};
15823
15876
  if (message.name !== "") {
15824
15877
  obj.name = message.name;
@@ -15832,7 +15885,7 @@ const Stop = {
15832
15885
  if (message.lon !== undefined) {
15833
15886
  obj.lon = message.lon;
15834
15887
  }
15835
- if (message.children?.length) {
15888
+ if ((_a = message.children) === null || _a === void 0 ? void 0 : _a.length) {
15836
15889
  obj.children = message.children.map((e) => Math.round(e));
15837
15890
  }
15838
15891
  if (message.parent !== undefined) {
@@ -15847,18 +15900,19 @@ const Stop = {
15847
15900
  return obj;
15848
15901
  },
15849
15902
  create(base) {
15850
- return Stop.fromPartial(base ?? {});
15903
+ return Stop.fromPartial(base !== null && base !== void 0 ? base : {});
15851
15904
  },
15852
15905
  fromPartial(object) {
15906
+ var _a, _b, _c, _d, _e, _f, _g, _h;
15853
15907
  const message = createBaseStop();
15854
- message.name = object.name ?? "";
15855
- message.sourceStopId = object.sourceStopId ?? "";
15856
- message.lat = object.lat ?? undefined;
15857
- message.lon = object.lon ?? undefined;
15858
- message.children = object.children?.map((e) => e) || [];
15859
- message.parent = object.parent ?? undefined;
15860
- message.locationType = object.locationType ?? 0;
15861
- message.platform = object.platform ?? undefined;
15908
+ message.name = (_a = object.name) !== null && _a !== void 0 ? _a : "";
15909
+ message.sourceStopId = (_b = object.sourceStopId) !== null && _b !== void 0 ? _b : "";
15910
+ message.lat = (_c = object.lat) !== null && _c !== void 0 ? _c : undefined;
15911
+ message.lon = (_d = object.lon) !== null && _d !== void 0 ? _d : undefined;
15912
+ message.children = ((_e = object.children) === null || _e === void 0 ? void 0 : _e.map((e) => e)) || [];
15913
+ message.parent = (_f = object.parent) !== null && _f !== void 0 ? _f : undefined;
15914
+ message.locationType = (_g = object.locationType) !== null && _g !== void 0 ? _g : 0;
15915
+ message.platform = (_h = object.platform) !== null && _h !== void 0 ? _h : undefined;
15862
15916
  return message;
15863
15917
  },
15864
15918
  };
@@ -15907,26 +15961,28 @@ const StopsMap = {
15907
15961
  fromJSON(object) {
15908
15962
  return {
15909
15963
  version: isSet$1(object.version) ? globalThis.String(object.version) : "",
15910
- stops: globalThis.Array.isArray(object?.stops) ? object.stops.map((e) => Stop.fromJSON(e)) : [],
15964
+ stops: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stops) ? object.stops.map((e) => Stop.fromJSON(e)) : [],
15911
15965
  };
15912
15966
  },
15913
15967
  toJSON(message) {
15968
+ var _a;
15914
15969
  const obj = {};
15915
15970
  if (message.version !== "") {
15916
15971
  obj.version = message.version;
15917
15972
  }
15918
- if (message.stops?.length) {
15973
+ if ((_a = message.stops) === null || _a === void 0 ? void 0 : _a.length) {
15919
15974
  obj.stops = message.stops.map((e) => Stop.toJSON(e));
15920
15975
  }
15921
15976
  return obj;
15922
15977
  },
15923
15978
  create(base) {
15924
- return StopsMap.fromPartial(base ?? {});
15979
+ return StopsMap.fromPartial(base !== null && base !== void 0 ? base : {});
15925
15980
  },
15926
15981
  fromPartial(object) {
15982
+ var _a, _b;
15927
15983
  const message = createBaseStopsMap();
15928
- message.version = object.version ?? "";
15929
- message.stops = object.stops?.map((e) => Stop.fromPartial(e)) || [];
15984
+ message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
15985
+ message.stops = ((_b = object.stops) === null || _b === void 0 ? void 0 : _b.map((e) => Stop.fromPartial(e))) || [];
15930
15986
  return message;
15931
15987
  },
15932
15988
  };
@@ -16010,12 +16066,8 @@ const serializeLocationType = (locationType) => {
16010
16066
  * to efficiently find stops based on user queries.
16011
16067
  */
16012
16068
  class StopsIndex {
16013
- stops;
16014
- sourceStopsMap;
16015
- textIndex;
16016
- geoIndex;
16017
- stopPoints;
16018
16069
  constructor(stops) {
16070
+ var _a;
16019
16071
  this.stops = stops;
16020
16072
  this.sourceStopsMap = new Map();
16021
16073
  const stopsSet = new Map();
@@ -16024,7 +16076,7 @@ class StopsIndex {
16024
16076
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16025
16077
  const stop = stops[id];
16026
16078
  this.sourceStopsMap.set(stop.sourceStopId, id);
16027
- const effectiveStopId = stop.parent ?? id;
16079
+ const effectiveStopId = (_a = stop.parent) !== null && _a !== void 0 ? _a : id;
16028
16080
  if (!stopsSet.has(effectiveStopId)) {
16029
16081
  stopsSet.set(effectiveStopId, {
16030
16082
  id: effectiveStopId,
@@ -16139,6 +16191,7 @@ class StopsIndex {
16139
16191
  * Find ids of all sibling stops.
16140
16192
  */
16141
16193
  equivalentStops(sourceId) {
16194
+ var _a, _b;
16142
16195
  const id = this.sourceStopsMap.get(sourceId);
16143
16196
  if (id === undefined) {
16144
16197
  return [];
@@ -16148,14 +16201,13 @@ class StopsIndex {
16148
16201
  return [];
16149
16202
  }
16150
16203
  const equivalentStops = stop.parent
16151
- ? (this.stops[stop.parent]?.children ?? [])
16204
+ ? ((_b = (_a = this.stops[stop.parent]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [])
16152
16205
  : stop.children;
16153
16206
  return Array.from(new Set([id, ...equivalentStops])).map((stopId) => this.stops[stopId]);
16154
16207
  }
16155
16208
  }
16156
16209
 
16157
16210
  class Duration {
16158
- totalSeconds;
16159
16211
  constructor(totalSeconds) {
16160
16212
  this.totalSeconds = totalSeconds;
16161
16213
  }
@@ -16458,14 +16510,15 @@ const Route$2 = {
16458
16510
  return obj;
16459
16511
  },
16460
16512
  create(base) {
16461
- return Route$2.fromPartial(base ?? {});
16513
+ return Route$2.fromPartial(base !== null && base !== void 0 ? base : {});
16462
16514
  },
16463
16515
  fromPartial(object) {
16516
+ var _a, _b, _c, _d;
16464
16517
  const message = createBaseRoute();
16465
- message.stopTimes = object.stopTimes ?? new Uint8Array(0);
16466
- message.pickUpDropOffTypes = object.pickUpDropOffTypes ?? new Uint8Array(0);
16467
- message.stops = object.stops ?? new Uint8Array(0);
16468
- message.serviceRouteId = object.serviceRouteId ?? 0;
16518
+ message.stopTimes = (_a = object.stopTimes) !== null && _a !== void 0 ? _a : new Uint8Array(0);
16519
+ message.pickUpDropOffTypes = (_b = object.pickUpDropOffTypes) !== null && _b !== void 0 ? _b : new Uint8Array(0);
16520
+ message.stops = (_c = object.stops) !== null && _c !== void 0 ? _c : new Uint8Array(0);
16521
+ message.serviceRouteId = (_d = object.serviceRouteId) !== null && _d !== void 0 ? _d : 0;
16469
16522
  return message;
16470
16523
  },
16471
16524
  };
@@ -16542,13 +16595,14 @@ const Transfer = {
16542
16595
  return obj;
16543
16596
  },
16544
16597
  create(base) {
16545
- return Transfer.fromPartial(base ?? {});
16598
+ return Transfer.fromPartial(base !== null && base !== void 0 ? base : {});
16546
16599
  },
16547
16600
  fromPartial(object) {
16601
+ var _a, _b, _c;
16548
16602
  const message = createBaseTransfer();
16549
- message.destination = object.destination ?? 0;
16550
- message.type = object.type ?? 0;
16551
- message.minTransferTime = object.minTransferTime ?? undefined;
16603
+ message.destination = (_a = object.destination) !== null && _a !== void 0 ? _a : 0;
16604
+ message.type = (_b = object.type) !== null && _b !== void 0 ? _b : 0;
16605
+ message.minTransferTime = (_c = object.minTransferTime) !== null && _c !== void 0 ? _c : undefined;
16552
16606
  return message;
16553
16607
  },
16554
16608
  };
@@ -16625,13 +16679,14 @@ const TripBoarding = {
16625
16679
  return obj;
16626
16680
  },
16627
16681
  create(base) {
16628
- return TripBoarding.fromPartial(base ?? {});
16682
+ return TripBoarding.fromPartial(base !== null && base !== void 0 ? base : {});
16629
16683
  },
16630
16684
  fromPartial(object) {
16685
+ var _a, _b, _c;
16631
16686
  const message = createBaseTripBoarding();
16632
- message.hopOnStopIndex = object.hopOnStopIndex ?? 0;
16633
- message.routeId = object.routeId ?? 0;
16634
- message.tripIndex = object.tripIndex ?? 0;
16687
+ message.hopOnStopIndex = (_a = object.hopOnStopIndex) !== null && _a !== void 0 ? _a : 0;
16688
+ message.routeId = (_b = object.routeId) !== null && _b !== void 0 ? _b : 0;
16689
+ message.tripIndex = (_c = object.tripIndex) !== null && _c !== void 0 ? _c : 0;
16635
16690
  return message;
16636
16691
  },
16637
16692
  };
@@ -16702,12 +16757,13 @@ const TripContinuationEntry = {
16702
16757
  originStopIndex: isSet(object.originStopIndex) ? globalThis.Number(object.originStopIndex) : 0,
16703
16758
  originRouteId: isSet(object.originRouteId) ? globalThis.Number(object.originRouteId) : 0,
16704
16759
  originTripIndex: isSet(object.originTripIndex) ? globalThis.Number(object.originTripIndex) : 0,
16705
- continuations: globalThis.Array.isArray(object?.continuations)
16760
+ continuations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.continuations)
16706
16761
  ? object.continuations.map((e) => TripBoarding.fromJSON(e))
16707
16762
  : [],
16708
16763
  };
16709
16764
  },
16710
16765
  toJSON(message) {
16766
+ var _a;
16711
16767
  const obj = {};
16712
16768
  if (message.originStopIndex !== 0) {
16713
16769
  obj.originStopIndex = Math.round(message.originStopIndex);
@@ -16718,20 +16774,21 @@ const TripContinuationEntry = {
16718
16774
  if (message.originTripIndex !== 0) {
16719
16775
  obj.originTripIndex = Math.round(message.originTripIndex);
16720
16776
  }
16721
- if (message.continuations?.length) {
16777
+ if ((_a = message.continuations) === null || _a === void 0 ? void 0 : _a.length) {
16722
16778
  obj.continuations = message.continuations.map((e) => TripBoarding.toJSON(e));
16723
16779
  }
16724
16780
  return obj;
16725
16781
  },
16726
16782
  create(base) {
16727
- return TripContinuationEntry.fromPartial(base ?? {});
16783
+ return TripContinuationEntry.fromPartial(base !== null && base !== void 0 ? base : {});
16728
16784
  },
16729
16785
  fromPartial(object) {
16786
+ var _a, _b, _c, _d;
16730
16787
  const message = createBaseTripContinuationEntry();
16731
- message.originStopIndex = object.originStopIndex ?? 0;
16732
- message.originRouteId = object.originRouteId ?? 0;
16733
- message.originTripIndex = object.originTripIndex ?? 0;
16734
- message.continuations = object.continuations?.map((e) => TripBoarding.fromPartial(e)) || [];
16788
+ message.originStopIndex = (_a = object.originStopIndex) !== null && _a !== void 0 ? _a : 0;
16789
+ message.originRouteId = (_b = object.originRouteId) !== null && _b !== void 0 ? _b : 0;
16790
+ message.originTripIndex = (_c = object.originTripIndex) !== null && _c !== void 0 ? _c : 0;
16791
+ message.continuations = ((_d = object.continuations) === null || _d === void 0 ? void 0 : _d.map((e) => TripBoarding.fromPartial(e))) || [];
16735
16792
  return message;
16736
16793
  },
16737
16794
  };
@@ -16788,29 +16845,31 @@ const StopAdjacency = {
16788
16845
  },
16789
16846
  fromJSON(object) {
16790
16847
  return {
16791
- routes: globalThis.Array.isArray(object?.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
16792
- transfers: globalThis.Array.isArray(object?.transfers)
16848
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
16849
+ transfers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.transfers)
16793
16850
  ? object.transfers.map((e) => Transfer.fromJSON(e))
16794
16851
  : [],
16795
16852
  };
16796
16853
  },
16797
16854
  toJSON(message) {
16855
+ var _a, _b;
16798
16856
  const obj = {};
16799
- if (message.routes?.length) {
16857
+ if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
16800
16858
  obj.routes = message.routes.map((e) => Math.round(e));
16801
16859
  }
16802
- if (message.transfers?.length) {
16860
+ if ((_b = message.transfers) === null || _b === void 0 ? void 0 : _b.length) {
16803
16861
  obj.transfers = message.transfers.map((e) => Transfer.toJSON(e));
16804
16862
  }
16805
16863
  return obj;
16806
16864
  },
16807
16865
  create(base) {
16808
- return StopAdjacency.fromPartial(base ?? {});
16866
+ return StopAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
16809
16867
  },
16810
16868
  fromPartial(object) {
16869
+ var _a, _b;
16811
16870
  const message = createBaseStopAdjacency();
16812
- message.routes = object.routes?.map((e) => e) || [];
16813
- message.transfers = object.transfers?.map((e) => Transfer.fromPartial(e)) || [];
16871
+ message.routes = ((_a = object.routes) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
16872
+ message.transfers = ((_b = object.transfers) === null || _b === void 0 ? void 0 : _b.map((e) => Transfer.fromPartial(e))) || [];
16814
16873
  return message;
16815
16874
  },
16816
16875
  };
@@ -16879,10 +16938,11 @@ const ServiceRoute = {
16879
16938
  return {
16880
16939
  type: isSet(object.type) ? routeTypeFromJSON(object.type) : 0,
16881
16940
  name: isSet(object.name) ? globalThis.String(object.name) : "",
16882
- routes: globalThis.Array.isArray(object?.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
16941
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
16883
16942
  };
16884
16943
  },
16885
16944
  toJSON(message) {
16945
+ var _a;
16886
16946
  const obj = {};
16887
16947
  if (message.type !== 0) {
16888
16948
  obj.type = routeTypeToJSON(message.type);
@@ -16890,19 +16950,20 @@ const ServiceRoute = {
16890
16950
  if (message.name !== "") {
16891
16951
  obj.name = message.name;
16892
16952
  }
16893
- if (message.routes?.length) {
16953
+ if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
16894
16954
  obj.routes = message.routes.map((e) => Math.round(e));
16895
16955
  }
16896
16956
  return obj;
16897
16957
  },
16898
16958
  create(base) {
16899
- return ServiceRoute.fromPartial(base ?? {});
16959
+ return ServiceRoute.fromPartial(base !== null && base !== void 0 ? base : {});
16900
16960
  },
16901
16961
  fromPartial(object) {
16962
+ var _a, _b, _c;
16902
16963
  const message = createBaseServiceRoute();
16903
- message.type = object.type ?? 0;
16904
- message.name = object.name ?? "";
16905
- message.routes = object.routes?.map((e) => e) || [];
16964
+ message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
16965
+ message.name = (_b = object.name) !== null && _b !== void 0 ? _b : "";
16966
+ message.routes = ((_c = object.routes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
16906
16967
  return message;
16907
16968
  },
16908
16969
  };
@@ -16981,49 +17042,51 @@ const Timetable$1 = {
16981
17042
  fromJSON(object) {
16982
17043
  return {
16983
17044
  version: isSet(object.version) ? globalThis.String(object.version) : "",
16984
- stopsAdjacency: globalThis.Array.isArray(object?.stopsAdjacency)
17045
+ stopsAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stopsAdjacency)
16985
17046
  ? object.stopsAdjacency.map((e) => StopAdjacency.fromJSON(e))
16986
17047
  : [],
16987
- routesAdjacency: globalThis.Array.isArray(object?.routesAdjacency)
17048
+ routesAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routesAdjacency)
16988
17049
  ? object.routesAdjacency.map((e) => Route$2.fromJSON(e))
16989
17050
  : [],
16990
- serviceRoutes: globalThis.Array.isArray(object?.serviceRoutes)
17051
+ serviceRoutes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.serviceRoutes)
16991
17052
  ? object.serviceRoutes.map((e) => ServiceRoute.fromJSON(e))
16992
17053
  : [],
16993
- tripContinuations: globalThis.Array.isArray(object?.tripContinuations)
17054
+ tripContinuations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.tripContinuations)
16994
17055
  ? object.tripContinuations.map((e) => TripContinuationEntry.fromJSON(e))
16995
17056
  : [],
16996
17057
  };
16997
17058
  },
16998
17059
  toJSON(message) {
17060
+ var _a, _b, _c, _d;
16999
17061
  const obj = {};
17000
17062
  if (message.version !== "") {
17001
17063
  obj.version = message.version;
17002
17064
  }
17003
- if (message.stopsAdjacency?.length) {
17065
+ if ((_a = message.stopsAdjacency) === null || _a === void 0 ? void 0 : _a.length) {
17004
17066
  obj.stopsAdjacency = message.stopsAdjacency.map((e) => StopAdjacency.toJSON(e));
17005
17067
  }
17006
- if (message.routesAdjacency?.length) {
17068
+ if ((_b = message.routesAdjacency) === null || _b === void 0 ? void 0 : _b.length) {
17007
17069
  obj.routesAdjacency = message.routesAdjacency.map((e) => Route$2.toJSON(e));
17008
17070
  }
17009
- if (message.serviceRoutes?.length) {
17071
+ if ((_c = message.serviceRoutes) === null || _c === void 0 ? void 0 : _c.length) {
17010
17072
  obj.serviceRoutes = message.serviceRoutes.map((e) => ServiceRoute.toJSON(e));
17011
17073
  }
17012
- if (message.tripContinuations?.length) {
17074
+ if ((_d = message.tripContinuations) === null || _d === void 0 ? void 0 : _d.length) {
17013
17075
  obj.tripContinuations = message.tripContinuations.map((e) => TripContinuationEntry.toJSON(e));
17014
17076
  }
17015
17077
  return obj;
17016
17078
  },
17017
17079
  create(base) {
17018
- return Timetable$1.fromPartial(base ?? {});
17080
+ return Timetable$1.fromPartial(base !== null && base !== void 0 ? base : {});
17019
17081
  },
17020
17082
  fromPartial(object) {
17083
+ var _a, _b, _c, _d, _e;
17021
17084
  const message = createBaseTimetable();
17022
- message.version = object.version ?? "";
17023
- message.stopsAdjacency = object.stopsAdjacency?.map((e) => StopAdjacency.fromPartial(e)) || [];
17024
- message.routesAdjacency = object.routesAdjacency?.map((e) => Route$2.fromPartial(e)) || [];
17025
- message.serviceRoutes = object.serviceRoutes?.map((e) => ServiceRoute.fromPartial(e)) || [];
17026
- message.tripContinuations = object.tripContinuations?.map((e) => TripContinuationEntry.fromPartial(e)) || [];
17085
+ message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
17086
+ message.stopsAdjacency = ((_b = object.stopsAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => StopAdjacency.fromPartial(e))) || [];
17087
+ message.routesAdjacency = ((_c = object.routesAdjacency) === null || _c === void 0 ? void 0 : _c.map((e) => Route$2.fromPartial(e))) || [];
17088
+ message.serviceRoutes = ((_d = object.serviceRoutes) === null || _d === void 0 ? void 0 : _d.map((e) => ServiceRoute.fromPartial(e))) || [];
17089
+ message.tripContinuations = ((_e = object.tripContinuations) === null || _e === void 0 ? void 0 : _e.map((e) => TripContinuationEntry.fromPartial(e))) || [];
17027
17090
  return message;
17028
17091
  },
17029
17092
  };
@@ -17060,11 +17123,6 @@ function isSet(value) {
17060
17123
  * A class representing a time as minutes since midnight.
17061
17124
  */
17062
17125
  class Time {
17063
- /*
17064
- * Number of minutes since midnight.
17065
- Note that this value can go beyond 3600 to model services overlapping with the next day.
17066
- */
17067
- minutesSinceMidnight;
17068
17126
  /**
17069
17127
  * Gets the infinity time as a Time instance.
17070
17128
  * This represents a time that is conceptually beyond any real possible time.
@@ -17317,51 +17375,6 @@ const toPickupDropOffType = (numericalType) => {
17317
17375
  * A route identifies all trips of a given service route sharing the same list of stops.
17318
17376
  */
17319
17377
  let Route$1 = class Route {
17320
- id;
17321
- /**
17322
- * Arrivals and departures encoded as minutes from midnight.
17323
- * Format: [arrival1, departure1, arrival2, departure2, etc.]
17324
- */
17325
- stopTimes;
17326
- /**
17327
- * PickUp and DropOff types represented as a 2-bit encoded Uint8Array.
17328
- * Values (2 bits each):
17329
- * 0: REGULAR
17330
- * 1: NOT_AVAILABLE
17331
- * 2: MUST_PHONE_AGENCY
17332
- * 3: MUST_COORDINATE_WITH_DRIVER
17333
- *
17334
- * Encoding format: Each byte contains 2 pickup/drop-off pairs (4 bits each)
17335
- * Bit layout per byte: [pickup_1 (2 bits)][drop_off_1 (2 bits)][pickup_0 (2 bits)][drop_off_0 (2 bits)]
17336
- * Example: For stops 0 and 1 in a trip, one byte encodes all 4 values
17337
- */
17338
- pickUpDropOffTypes;
17339
- /**
17340
- * A binary array of stopIds in the route.
17341
- * [stop1, stop2, stop3,...]
17342
- */
17343
- stops;
17344
- /**
17345
- * A reverse mapping of each stop with their index in the route:
17346
- * {
17347
- * 4: 0,
17348
- * 5: 1,
17349
- * ...
17350
- * }
17351
- */
17352
- stopIndices;
17353
- /**
17354
- * The identifier of the route as a service shown to users.
17355
- */
17356
- serviceRouteId;
17357
- /**
17358
- * The total number of stops in the route.
17359
- */
17360
- nbStops;
17361
- /**
17362
- * The total number of trips in the route.
17363
- */
17364
- nbTrips;
17365
17378
  constructor(id, stopTimes, pickUpDropOffTypes, stops, serviceRouteId) {
17366
17379
  this.id = id;
17367
17380
  this.stopTimes = stopTimes;
@@ -17390,6 +17403,7 @@ let Route$1 = class Route {
17390
17403
  * @returns The new route.
17391
17404
  */
17392
17405
  static of(params) {
17406
+ var _a, _b;
17393
17407
  const { id, serviceRouteId, trips } = params;
17394
17408
  if (trips.length === 0) {
17395
17409
  throw new Error('At least one trip must be provided');
@@ -17436,8 +17450,8 @@ let Route$1 = class Route {
17436
17450
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17437
17451
  const stop = trip.stops[stopIndex];
17438
17452
  const globalIndex = tripIndex * numStops + stopIndex;
17439
- const pickUp = stop.pickUpType ?? REGULAR;
17440
- const dropOff = stop.dropOffType ?? REGULAR;
17453
+ const pickUp = (_a = stop.pickUpType) !== null && _a !== void 0 ? _a : REGULAR;
17454
+ const dropOff = (_b = stop.dropOffType) !== null && _b !== void 0 ? _b : REGULAR;
17441
17455
  const byteIndex = Math.floor(globalIndex / 2);
17442
17456
  const isSecondPair = globalIndex % 2 === 1;
17443
17457
  if (isSecondPair) {
@@ -17597,7 +17611,7 @@ let Route$1 = class Route {
17597
17611
  }
17598
17612
  if (lb === -1)
17599
17613
  return undefined;
17600
- for (let t = lb; t < (beforeTrip ?? this.nbTrips); t++) {
17614
+ for (let t = lb; t < (beforeTrip !== null && beforeTrip !== void 0 ? beforeTrip : this.nbTrips); t++) {
17601
17615
  const pickup = this.pickUpTypeFrom(stopIndex, t);
17602
17616
  if (pickup !== 'NOT_AVAILABLE') {
17603
17617
  return t;
@@ -17632,12 +17646,12 @@ let Route$1 = class Route {
17632
17646
  };
17633
17647
 
17634
17648
  // Each value uses 20 bits, allowing values from 0 to 1,048,575 (2^20 - 1)
17635
- const VALUE_MASK = (1n << 20n) - 1n; // 0xFFFFF
17636
- const MAX_VALUE = 1_048_575; // 2^20 - 1
17649
+ const VALUE_MASK = (BigInt(1) << BigInt(20)) - BigInt(1); // 0xFFFFF
17650
+ const MAX_VALUE = 1048575; // 2^20 - 1
17637
17651
  // Bit positions for each value in the 60-bit bigint
17638
- const TRIP_INDEX_SHIFT = 0n;
17639
- const ROUTE_ID_SHIFT = 20n;
17640
- const STOP_INDEX_SHIFT = 40n;
17652
+ const TRIP_INDEX_SHIFT = BigInt(0);
17653
+ const ROUTE_ID_SHIFT = BigInt(20);
17654
+ const STOP_INDEX_SHIFT = BigInt(40);
17641
17655
  /**
17642
17656
  * Validates that a value fits within 20 bits (0 to 1,048,575)
17643
17657
  * @param value - The value to validate
@@ -17745,13 +17759,9 @@ const serializeStopsAdjacency = (stopsAdjacency) => {
17745
17759
  return stopsAdjacency.map((value) => {
17746
17760
  return {
17747
17761
  transfers: value.transfers
17748
- ? value.transfers.map((transfer) => ({
17749
- destination: transfer.destination,
17750
- type: serializeTransferType(transfer.type),
17751
- ...(transfer.minTransferTime !== undefined && {
17752
- minTransferTime: transfer.minTransferTime.toSeconds(),
17753
- }),
17754
- }))
17762
+ ? value.transfers.map((transfer) => (Object.assign({ destination: transfer.destination, type: serializeTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
17763
+ minTransferTime: transfer.minTransferTime.toSeconds(),
17764
+ }))))
17755
17765
  : [],
17756
17766
  routes: value.routes,
17757
17767
  };
@@ -17788,13 +17798,9 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
17788
17798
  for (let j = 0; j < value.transfers.length; j++) {
17789
17799
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17790
17800
  const transfer = value.transfers[j];
17791
- const newTransfer = {
17792
- destination: transfer.destination,
17793
- type: parseTransferType(transfer.type),
17794
- ...(transfer.minTransferTime !== undefined && {
17795
- minTransferTime: Duration.fromSeconds(transfer.minTransferTime),
17796
- }),
17797
- };
17801
+ const newTransfer = Object.assign({ destination: transfer.destination, type: parseTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
17802
+ minTransferTime: Duration.fromSeconds(transfer.minTransferTime),
17803
+ }));
17798
17804
  transfers.push(newTransfer);
17799
17805
  }
17800
17806
  const stopAdjacency = {
@@ -17959,11 +17965,6 @@ const CURRENT_VERSION = '0.0.9';
17959
17965
  * The internal transit timetable format.
17960
17966
  */
17961
17967
  class Timetable {
17962
- stopsAdjacency;
17963
- routesAdjacency;
17964
- serviceRoutes;
17965
- tripContinuations;
17966
- activeStops;
17967
17968
  constructor(stopsAdjacency, routesAdjacency, routes, tripContinuations) {
17968
17969
  this.stopsAdjacency = stopsAdjacency;
17969
17970
  this.routesAdjacency = routesAdjacency;
@@ -18052,7 +18053,8 @@ class Timetable {
18052
18053
  * @returns An array of trip continuation options available at the stop for the specified trip.
18053
18054
  */
18054
18055
  getContinuousTrips(stopIndex, routeId, tripIndex) {
18055
- const tripContinuations = this.tripContinuations?.get(encode(stopIndex, routeId, tripIndex));
18056
+ var _a;
18057
+ const tripContinuations = (_a = this.tripContinuations) === null || _a === void 0 ? void 0 : _a.get(encode(stopIndex, routeId, tripIndex));
18056
18058
  if (!tripContinuations) {
18057
18059
  return EMPTY_TRIP_CONTINUATIONS;
18058
18060
  }
@@ -20100,22 +20102,35 @@ const parseCsv = (stream, numericColumns = []) => {
20100
20102
  * @param profile A configuration object defining the specificities of the GTFS feed.
20101
20103
  * @returns A map of all the valid routes.
20102
20104
  */
20103
- const parseRoutes = async (routesStream, profile = standardProfile) => {
20105
+ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStream_1, ...args_1], void 0, function* (routesStream, profile = standardProfile) {
20106
+ var _a, e_1, _b, _c;
20104
20107
  const routes = new Map();
20105
- for await (const rawLine of parseCsv(routesStream, ['route_type'])) {
20106
- const line = rawLine;
20107
- const routeType = profile.routeTypeParser(line.route_type);
20108
- if (routeType === undefined) {
20109
- log.info(`Unsupported route type ${line.route_type} for route ${line.route_id}.`);
20110
- continue;
20108
+ try {
20109
+ for (var _d = true, _e = __asyncValues(parseCsv(routesStream, ['route_type'])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20110
+ _c = _f.value;
20111
+ _d = false;
20112
+ const rawLine = _c;
20113
+ const line = rawLine;
20114
+ const routeType = profile.routeTypeParser(line.route_type);
20115
+ if (routeType === undefined) {
20116
+ log.info(`Unsupported route type ${line.route_type} for route ${line.route_id}.`);
20117
+ continue;
20118
+ }
20119
+ routes.set(line.route_id, {
20120
+ name: line.route_short_name,
20121
+ type: routeType,
20122
+ });
20111
20123
  }
20112
- routes.set(line.route_id, {
20113
- name: line.route_short_name,
20114
- type: routeType,
20115
- });
20124
+ }
20125
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20126
+ finally {
20127
+ try {
20128
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20129
+ }
20130
+ finally { if (e_1) throw e_1.error; }
20116
20131
  }
20117
20132
  return routes;
20118
- };
20133
+ });
20119
20134
  /**
20120
20135
  * Creates an array of ServiceRoute objects by combining GTFS route data with service route mappings.
20121
20136
  *
@@ -20178,33 +20193,46 @@ const weekdays = {
20178
20193
  * @param date The active date.
20179
20194
  * @param calendarStream A readable stream for the GTFS calendar.txt file.
20180
20195
  */
20181
- const parseCalendar = async (calendarStream, serviceIds, date) => {
20196
+ const parseCalendar = (calendarStream, serviceIds, date) => __awaiter(void 0, void 0, void 0, function* () {
20197
+ var _a, e_1, _b, _c;
20182
20198
  const activeDate = toGtfsDate(date);
20183
20199
  const weekday = date.weekday;
20184
20200
  const weekdayIndex = weekdays[weekday];
20185
- for await (const rawLine of parseCsv(calendarStream, [
20186
- 'monday',
20187
- 'tuesday',
20188
- 'wednesday',
20189
- 'thursday',
20190
- 'friday',
20191
- 'saturday',
20192
- 'sunday',
20193
- 'start_date',
20194
- 'end_date',
20195
- ])) {
20196
- const line = rawLine;
20197
- if (activeDate < line.start_date || activeDate > line.end_date) {
20198
- // If the service is not valid on this date
20199
- continue;
20201
+ try {
20202
+ for (var _d = true, _e = __asyncValues(parseCsv(calendarStream, [
20203
+ 'monday',
20204
+ 'tuesday',
20205
+ 'wednesday',
20206
+ 'thursday',
20207
+ 'friday',
20208
+ 'saturday',
20209
+ 'sunday',
20210
+ 'start_date',
20211
+ 'end_date',
20212
+ ])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20213
+ _c = _f.value;
20214
+ _d = false;
20215
+ const rawLine = _c;
20216
+ const line = rawLine;
20217
+ if (activeDate < line.start_date || activeDate > line.end_date) {
20218
+ // If the service is not valid on this date
20219
+ continue;
20220
+ }
20221
+ if (line[weekdayIndex] !== 1) {
20222
+ // If the service is not valid on this week day
20223
+ continue;
20224
+ }
20225
+ serviceIds.add(line['service_id']);
20200
20226
  }
20201
- if (line[weekdayIndex] !== 1) {
20202
- // If the service is not valid on this week day
20203
- continue;
20227
+ }
20228
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20229
+ finally {
20230
+ try {
20231
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20204
20232
  }
20205
- serviceIds.add(line['service_id']);
20233
+ finally { if (e_1) throw e_1.error; }
20206
20234
  }
20207
- };
20235
+ });
20208
20236
  /**
20209
20237
  * Parses a gtfs calendar_dates.txt file and finds the service ids valid at a given date.
20210
20238
  *
@@ -20212,24 +20240,39 @@ const parseCalendar = async (calendarStream, serviceIds, date) => {
20212
20240
  * @param date The active date, in the format "YYYYMMDD".
20213
20241
  * @param calendarDatesStream A readable stream for the GTFS calendar_dates.txt file.
20214
20242
  */
20215
- const parseCalendarDates = async (calendarDatesStream, serviceIds, date) => {
20243
+ const parseCalendarDates = (calendarDatesStream, serviceIds, date) => __awaiter(void 0, void 0, void 0, function* () {
20244
+ var _a, e_2, _b, _c;
20216
20245
  const activeDate = toGtfsDate(date);
20217
- for await (const rawLine of parseCsv(calendarDatesStream, [
20218
- 'date',
20219
- 'exception_type',
20220
- ])) {
20221
- const line = rawLine;
20222
- if (line.date !== activeDate) ;
20223
- else if (line.exception_type === 2 && serviceIds.has(line.service_id)) {
20224
- // Service has been removed for the specified date.
20225
- serviceIds.delete(line.service_id);
20246
+ try {
20247
+ for (var _d = true, _e = __asyncValues(parseCsv(calendarDatesStream, [
20248
+ 'date',
20249
+ 'exception_type',
20250
+ ])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20251
+ _c = _f.value;
20252
+ _d = false;
20253
+ const rawLine = _c;
20254
+ const line = rawLine;
20255
+ if (line.date !== activeDate) {
20256
+ // No rule on the active date
20257
+ }
20258
+ else if (line.exception_type === 2 && serviceIds.has(line.service_id)) {
20259
+ // Service has been removed for the specified date.
20260
+ serviceIds.delete(line.service_id);
20261
+ }
20262
+ else if (line.exception_type === 1) {
20263
+ // Service is present on the active date
20264
+ serviceIds.add(line.service_id);
20265
+ }
20226
20266
  }
20227
- else if (line.exception_type === 1) {
20228
- // Service is present on the active date
20229
- serviceIds.add(line.service_id);
20267
+ }
20268
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
20269
+ finally {
20270
+ try {
20271
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20230
20272
  }
20273
+ finally { if (e_2) throw e_2.error; }
20231
20274
  }
20232
- };
20275
+ });
20233
20276
 
20234
20277
  /**
20235
20278
  * Parses the stops.txt file from a GTFS feed.
@@ -20237,30 +20280,33 @@ const parseCalendarDates = async (calendarDatesStream, serviceIds, date) => {
20237
20280
  * @param stopsStream The readable stream containing the stops data.
20238
20281
  * @return A mapping of stop IDs to corresponding stop details.
20239
20282
  */
20240
- const parseStops = async (stopsStream) => {
20283
+ const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function* () {
20284
+ var _a, e_1, _b, _c;
20241
20285
  const parsedStops = new Map();
20242
20286
  let i = 0;
20243
- for await (const rawLine of parseCsv(stopsStream, [
20244
- 'stop_lat',
20245
- 'stop_lon',
20246
- 'location_type',
20247
- ])) {
20248
- const line = rawLine;
20249
- const stop = {
20250
- id: i,
20251
- sourceStopId: line.stop_id,
20252
- name: line.stop_name,
20253
- lat: line.stop_lat,
20254
- lon: line.stop_lon,
20255
- locationType: line.location_type
20256
- ? parseGtfsLocationType(line.location_type)
20257
- : 'SIMPLE_STOP_OR_PLATFORM',
20258
- ...(line.platform_code && { platform: line.platform_code }),
20259
- children: [],
20260
- ...(line.parent_station && { parentSourceId: line.parent_station }),
20261
- };
20262
- parsedStops.set(line.stop_id, stop);
20263
- i = i + 1;
20287
+ try {
20288
+ for (var _d = true, _e = __asyncValues(parseCsv(stopsStream, [
20289
+ 'stop_lat',
20290
+ 'stop_lon',
20291
+ 'location_type',
20292
+ ])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20293
+ _c = _f.value;
20294
+ _d = false;
20295
+ const rawLine = _c;
20296
+ const line = rawLine;
20297
+ const stop = Object.assign(Object.assign(Object.assign({ id: i, sourceStopId: line.stop_id, name: line.stop_name, lat: line.stop_lat, lon: line.stop_lon, locationType: line.location_type
20298
+ ? parseGtfsLocationType(line.location_type)
20299
+ : 'SIMPLE_STOP_OR_PLATFORM' }, (line.platform_code && { platform: line.platform_code })), { children: [] }), (line.parent_station && { parentSourceId: line.parent_station }));
20300
+ parsedStops.set(line.stop_id, stop);
20301
+ i = i + 1;
20302
+ }
20303
+ }
20304
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20305
+ finally {
20306
+ try {
20307
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20308
+ }
20309
+ finally { if (e_1) throw e_1.error; }
20264
20310
  }
20265
20311
  for (const [sourceStopId, stop] of parsedStops) {
20266
20312
  if (stop.parentSourceId) {
@@ -20274,7 +20320,7 @@ const parseStops = async (stopsStream) => {
20274
20320
  }
20275
20321
  }
20276
20322
  return parsedStops;
20277
- };
20323
+ });
20278
20324
  const parseGtfsLocationType = (gtfsLocationType) => {
20279
20325
  switch (gtfsLocationType) {
20280
20326
  case 0:
@@ -20297,73 +20343,82 @@ const parseGtfsLocationType = (gtfsLocationType) => {
20297
20343
  * @param stopsStream The readable stream containing the stops data.
20298
20344
  * @return A mapping of stop IDs to corresponding stop details.
20299
20345
  */
20300
- const parseTransfers = async (transfersStream, stopsMap) => {
20346
+ const parseTransfers = (transfersStream, stopsMap) => __awaiter(void 0, void 0, void 0, function* () {
20347
+ var _a, e_1, _b, _c;
20301
20348
  const transfers = new Map();
20302
20349
  const tripContinuations = [];
20303
- for await (const rawLine of parseCsv(transfersStream, [
20304
- 'transfer_type',
20305
- 'min_transfer_time',
20306
- ])) {
20307
- const transferEntry = rawLine;
20308
- if (transferEntry.transfer_type === 3 ||
20309
- transferEntry.transfer_type === 5) {
20310
- continue;
20311
- }
20312
- if (!transferEntry.from_stop_id || !transferEntry.to_stop_id) {
20313
- console.warn(`Missing transfer origin or destination stop.`);
20314
- continue;
20315
- }
20316
- const fromStop = stopsMap.get(transferEntry.from_stop_id);
20317
- const toStop = stopsMap.get(transferEntry.to_stop_id);
20318
- if (!fromStop || !toStop) {
20319
- console.warn(`Transfer references non-existent stop(s): from_stop_id=${transferEntry.from_stop_id}, to_stop_id=${transferEntry.to_stop_id}`);
20320
- continue;
20321
- }
20322
- if (transferEntry.transfer_type === 4) {
20323
- if (transferEntry.from_trip_id === undefined ||
20324
- transferEntry.from_trip_id === '' ||
20325
- transferEntry.to_trip_id === undefined ||
20326
- transferEntry.to_trip_id === '') {
20327
- console.warn(`Unsupported in-seat transfer, missing from_trip_id and/or to_trip_id.`);
20350
+ try {
20351
+ for (var _d = true, _e = __asyncValues(parseCsv(transfersStream, [
20352
+ 'transfer_type',
20353
+ 'min_transfer_time',
20354
+ ])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20355
+ _c = _f.value;
20356
+ _d = false;
20357
+ const rawLine = _c;
20358
+ const transferEntry = rawLine;
20359
+ if (transferEntry.transfer_type === 3 ||
20360
+ transferEntry.transfer_type === 5) {
20328
20361
  continue;
20329
20362
  }
20330
- const tripBoardingEntry = {
20331
- fromStop: fromStop.id,
20332
- fromTrip: transferEntry.from_trip_id,
20333
- toStop: toStop.id,
20334
- toTrip: transferEntry.to_trip_id,
20335
- };
20336
- tripContinuations.push(tripBoardingEntry);
20337
- continue;
20338
- }
20339
- if (transferEntry.from_trip_id && transferEntry.to_trip_id) {
20340
- console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between trips ${transferEntry.from_trip_id} and ${transferEntry.to_trip_id}.`);
20341
- continue;
20342
- }
20343
- if (transferEntry.from_route_id && transferEntry.to_route_id) {
20344
- console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between routes ${transferEntry.from_route_id} and ${transferEntry.to_route_id}.`);
20345
- continue;
20363
+ if (!transferEntry.from_stop_id || !transferEntry.to_stop_id) {
20364
+ console.warn(`Missing transfer origin or destination stop.`);
20365
+ continue;
20366
+ }
20367
+ const fromStop = stopsMap.get(transferEntry.from_stop_id);
20368
+ const toStop = stopsMap.get(transferEntry.to_stop_id);
20369
+ if (!fromStop || !toStop) {
20370
+ console.warn(`Transfer references non-existent stop(s): from_stop_id=${transferEntry.from_stop_id}, to_stop_id=${transferEntry.to_stop_id}`);
20371
+ continue;
20372
+ }
20373
+ if (transferEntry.transfer_type === 4) {
20374
+ if (transferEntry.from_trip_id === undefined ||
20375
+ transferEntry.from_trip_id === '' ||
20376
+ transferEntry.to_trip_id === undefined ||
20377
+ transferEntry.to_trip_id === '') {
20378
+ console.warn(`Unsupported in-seat transfer, missing from_trip_id and/or to_trip_id.`);
20379
+ continue;
20380
+ }
20381
+ const tripBoardingEntry = {
20382
+ fromStop: fromStop.id,
20383
+ fromTrip: transferEntry.from_trip_id,
20384
+ toStop: toStop.id,
20385
+ toTrip: transferEntry.to_trip_id,
20386
+ };
20387
+ tripContinuations.push(tripBoardingEntry);
20388
+ continue;
20389
+ }
20390
+ if (transferEntry.from_trip_id && transferEntry.to_trip_id) {
20391
+ console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between trips ${transferEntry.from_trip_id} and ${transferEntry.to_trip_id}.`);
20392
+ continue;
20393
+ }
20394
+ if (transferEntry.from_route_id && transferEntry.to_route_id) {
20395
+ console.warn(`Unsupported transfer of type ${transferEntry.transfer_type} between routes ${transferEntry.from_route_id} and ${transferEntry.to_route_id}.`);
20396
+ continue;
20397
+ }
20398
+ if (transferEntry.transfer_type === 2 &&
20399
+ transferEntry.min_transfer_time === undefined) {
20400
+ console.info(`Missing minimum transfer time between ${transferEntry.from_stop_id} and ${transferEntry.to_stop_id}.`);
20401
+ }
20402
+ const transfer = Object.assign({ destination: toStop.id, type: parseGtfsTransferType(transferEntry.transfer_type) }, (transferEntry.min_transfer_time !== undefined && {
20403
+ minTransferTime: Duration.fromSeconds(transferEntry.min_transfer_time),
20404
+ }));
20405
+ const fromStopTransfers = transfers.get(fromStop.id) || [];
20406
+ fromStopTransfers.push(transfer);
20407
+ transfers.set(fromStop.id, fromStopTransfers);
20346
20408
  }
20347
- if (transferEntry.transfer_type === 2 &&
20348
- transferEntry.min_transfer_time === undefined) {
20349
- console.info(`Missing minimum transfer time between ${transferEntry.from_stop_id} and ${transferEntry.to_stop_id}.`);
20409
+ }
20410
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20411
+ finally {
20412
+ try {
20413
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20350
20414
  }
20351
- const transfer = {
20352
- destination: toStop.id,
20353
- type: parseGtfsTransferType(transferEntry.transfer_type),
20354
- ...(transferEntry.min_transfer_time !== undefined && {
20355
- minTransferTime: Duration.fromSeconds(transferEntry.min_transfer_time),
20356
- }),
20357
- };
20358
- const fromStopTransfers = transfers.get(fromStop.id) || [];
20359
- fromStopTransfers.push(transfer);
20360
- transfers.set(fromStop.id, fromStopTransfers);
20415
+ finally { if (e_1) throw e_1.error; }
20361
20416
  }
20362
20417
  return {
20363
20418
  transfers,
20364
20419
  tripContinuations,
20365
20420
  };
20366
- };
20421
+ });
20367
20422
  /**
20368
20423
  * Disambiguates stops involved in a transfer.
20369
20424
  *
@@ -20556,22 +20611,35 @@ const finalizeRouteFromBuilder = (builder) => {
20556
20611
  * @param serviceRoutes A mapping of route IDs to route details.
20557
20612
  * @returns A mapping of trip IDs to corresponding route IDs.
20558
20613
  */
20559
- const parseTrips = async (tripsStream, serviceIds, validGtfsRoutes) => {
20614
+ const parseTrips = (tripsStream, serviceIds, validGtfsRoutes) => __awaiter(void 0, void 0, void 0, function* () {
20615
+ var _a, e_1, _b, _c;
20560
20616
  const trips = new Map();
20561
- for await (const rawLine of parseCsv(tripsStream, ['stop_sequence'])) {
20562
- const line = rawLine;
20563
- if (!serviceIds.has(line.service_id)) {
20564
- // The trip doesn't correspond to an active service
20565
- continue;
20617
+ try {
20618
+ for (var _d = true, _e = __asyncValues(parseCsv(tripsStream, ['stop_sequence'])), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
20619
+ _c = _f.value;
20620
+ _d = false;
20621
+ const rawLine = _c;
20622
+ const line = rawLine;
20623
+ if (!serviceIds.has(line.service_id)) {
20624
+ // The trip doesn't correspond to an active service
20625
+ continue;
20626
+ }
20627
+ if (!validGtfsRoutes.has(line.route_id)) {
20628
+ // The trip doesn't correspond to a supported route
20629
+ continue;
20630
+ }
20631
+ trips.set(line.trip_id, line.route_id);
20566
20632
  }
20567
- if (!validGtfsRoutes.has(line.route_id)) {
20568
- // The trip doesn't correspond to a supported route
20569
- continue;
20633
+ }
20634
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
20635
+ finally {
20636
+ try {
20637
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
20570
20638
  }
20571
- trips.set(line.trip_id, line.route_id);
20639
+ finally { if (e_1) throw e_1.error; }
20572
20640
  }
20573
20641
  return trips;
20574
- };
20642
+ });
20575
20643
  const buildStopsAdjacencyStructure = (serviceRoutes, routes, transfersMap, nbStops, activeStops) => {
20576
20644
  const stopsAdjacency = new Array(nbStops);
20577
20645
  for (let i = 0; i < nbStops; i++) {
@@ -20623,7 +20691,9 @@ const buildStopsAdjacencyStructure = (serviceRoutes, routes, transfersMap, nbSto
20623
20691
  * @param activeStopIds A set of valid stop IDs.
20624
20692
  * @returns A mapping of route IDs to route details. The routes returned correspond to the set of trips from GTFS that share the same stop list.
20625
20693
  */
20626
- const parseStopTimes = async (stopTimesStream, stopsMap, activeTripIds, activeStopIds) => {
20694
+ const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds) => __awaiter(void 0, void 0, void 0, function* () {
20695
+ var _a, e_2, _b, _c;
20696
+ var _d, _e;
20627
20697
  /**
20628
20698
  * Adds a trip to the appropriate route builder
20629
20699
  */
@@ -20691,43 +20761,55 @@ const parseStopTimes = async (stopTimesStream, stopsMap, activeTripIds, activeSt
20691
20761
  let pickUpTypes = [];
20692
20762
  let dropOffTypes = [];
20693
20763
  let currentTripId = undefined;
20694
- for await (const rawLine of parseCsv(stopTimesStream, ['stop_sequence'])) {
20695
- const line = rawLine;
20696
- if (line.trip_id === currentTripId && line.stop_sequence <= previousSeq) {
20697
- console.warn(`Stop sequences not increasing for trip ${line.trip_id}: ${line.stop_sequence} > ${previousSeq}.`);
20698
- continue;
20699
- }
20700
- if (!line.arrival_time && !line.departure_time) {
20701
- console.warn(`Missing arrival or departure time for ${line.trip_id} at stop ${line.stop_id}.`);
20702
- continue;
20703
- }
20704
- if (line.pickup_type === '1' && line.drop_off_type === '1') {
20705
- // Warning: could potentially lead to issues if there is an in-seat transfer
20706
- // at this stop - it can be not boardable nor alightable but still useful for an in-seat transfer.
20707
- // This doesn't seem to happen in practice for now so keeping this condition to save memory.
20708
- continue;
20709
- }
20710
- if (currentTripId && line.trip_id !== currentTripId && stops.length > 0) {
20711
- addTrip(currentTripId);
20712
- }
20713
- currentTripId = line.trip_id;
20714
- const stopData = stopsMap.get(line.stop_id);
20715
- if (!stopData) {
20716
- console.warn(`Unknown stop ID: ${line.stop_id}`);
20717
- continue;
20764
+ try {
20765
+ for (var _f = true, _g = __asyncValues(parseCsv(stopTimesStream, ['stop_sequence'])), _h; _h = yield _g.next(), _a = _h.done, !_a; _f = true) {
20766
+ _c = _h.value;
20767
+ _f = false;
20768
+ const rawLine = _c;
20769
+ const line = rawLine;
20770
+ if (line.trip_id === currentTripId && line.stop_sequence <= previousSeq) {
20771
+ console.warn(`Stop sequences not increasing for trip ${line.trip_id}: ${line.stop_sequence} > ${previousSeq}.`);
20772
+ continue;
20773
+ }
20774
+ if (!line.arrival_time && !line.departure_time) {
20775
+ console.warn(`Missing arrival or departure time for ${line.trip_id} at stop ${line.stop_id}.`);
20776
+ continue;
20777
+ }
20778
+ if (line.pickup_type === '1' && line.drop_off_type === '1') {
20779
+ // Warning: could potentially lead to issues if there is an in-seat transfer
20780
+ // at this stop - it can be not boardable nor alightable but still useful for an in-seat transfer.
20781
+ // This doesn't seem to happen in practice for now so keeping this condition to save memory.
20782
+ continue;
20783
+ }
20784
+ if (currentTripId && line.trip_id !== currentTripId && stops.length > 0) {
20785
+ addTrip(currentTripId);
20786
+ }
20787
+ currentTripId = line.trip_id;
20788
+ const stopData = stopsMap.get(line.stop_id);
20789
+ if (!stopData) {
20790
+ console.warn(`Unknown stop ID: ${line.stop_id}`);
20791
+ continue;
20792
+ }
20793
+ stops.push(stopData.id);
20794
+ const departure = (_d = line.departure_time) !== null && _d !== void 0 ? _d : line.arrival_time;
20795
+ const arrival = (_e = line.arrival_time) !== null && _e !== void 0 ? _e : line.departure_time;
20796
+ if (!arrival || !departure) {
20797
+ console.warn(`Missing time data for ${line.trip_id} at stop ${line.stop_id}`);
20798
+ continue;
20799
+ }
20800
+ arrivalTimes.push(toTime(arrival).toMinutes());
20801
+ departureTimes.push(toTime(departure).toMinutes());
20802
+ pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
20803
+ dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
20804
+ previousSeq = line.stop_sequence;
20718
20805
  }
20719
- stops.push(stopData.id);
20720
- const departure = line.departure_time ?? line.arrival_time;
20721
- const arrival = line.arrival_time ?? line.departure_time;
20722
- if (!arrival || !departure) {
20723
- console.warn(`Missing time data for ${line.trip_id} at stop ${line.stop_id}`);
20724
- continue;
20806
+ }
20807
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
20808
+ finally {
20809
+ try {
20810
+ if (!_f && !_a && (_b = _g.return)) yield _b.call(_g);
20725
20811
  }
20726
- arrivalTimes.push(toTime(arrival).toMinutes());
20727
- departureTimes.push(toTime(departure).toMinutes());
20728
- pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
20729
- dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
20730
- previousSeq = line.stop_sequence;
20812
+ finally { if (e_2) throw e_2.error; }
20731
20813
  }
20732
20814
  if (currentTripId) {
20733
20815
  addTrip(currentTripId);
@@ -20746,7 +20828,7 @@ const parseStopTimes = async (stopTimesStream, stopsMap, activeTripIds, activeSt
20746
20828
  });
20747
20829
  }
20748
20830
  return { routes: routesAdjacency, serviceRoutesMap, tripsMapping };
20749
- };
20831
+ });
20750
20832
  const parsePickupDropOffType = (gtfsType) => {
20751
20833
  switch (gtfsType) {
20752
20834
  default:
@@ -20770,8 +20852,6 @@ const STOP_TIMES_FILE = 'stop_times.txt';
20770
20852
  const STOPS_FILE = 'stops.txt';
20771
20853
  const TRANSFERS_FILE = 'transfers.txt';
20772
20854
  class GtfsParser {
20773
- path;
20774
- profile;
20775
20855
  constructor(path, profile = standardProfile) {
20776
20856
  // TODO: support input from multiple sources
20777
20857
  this.path = path;
@@ -20783,81 +20863,83 @@ class GtfsParser {
20783
20863
  * @param date The active date.
20784
20864
  * @returns The parsed timetable.
20785
20865
  */
20786
- async parseTimetable(date) {
20787
- log.setLevel('INFO');
20788
- const zip = new StreamZip.async({ file: this.path });
20789
- const entries = await zip.entries();
20790
- const datetime = DateTime.fromJSDate(date);
20791
- const activeServiceIds = new Set();
20792
- const activeStopIds = new Set();
20793
- log.info(`Parsing ${STOPS_FILE}`);
20794
- const stopsStart = performance.now();
20795
- const stopsStream = await zip.stream(STOPS_FILE);
20796
- const parsedStops = await parseStops(stopsStream);
20797
- const stopsEnd = performance.now();
20798
- log.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
20799
- if (entries[CALENDAR_FILE]) {
20800
- log.info(`Parsing ${CALENDAR_FILE}`);
20801
- const calendarStart = performance.now();
20802
- const calendarStream = await zip.stream(CALENDAR_FILE);
20803
- await parseCalendar(calendarStream, activeServiceIds, datetime);
20804
- const calendarEnd = performance.now();
20805
- log.info(`${activeServiceIds.size} valid services. (${(calendarEnd - calendarStart).toFixed(2)}ms)`);
20806
- }
20807
- if (entries[CALENDAR_DATES_FILE]) {
20808
- log.info(`Parsing ${CALENDAR_DATES_FILE}`);
20809
- const calendarDatesStart = performance.now();
20810
- const calendarDatesStream = await zip.stream(CALENDAR_DATES_FILE);
20811
- await parseCalendarDates(calendarDatesStream, activeServiceIds, datetime);
20812
- const calendarDatesEnd = performance.now();
20813
- log.info(`${activeServiceIds.size} valid services. (${(calendarDatesEnd - calendarDatesStart).toFixed(2)}ms)`);
20814
- }
20815
- log.info(`Parsing ${ROUTES_FILE}`);
20816
- const routesStart = performance.now();
20817
- const routesStream = await zip.stream(ROUTES_FILE);
20818
- const validGtfsRoutes = await parseRoutes(routesStream, this.profile);
20819
- const routesEnd = performance.now();
20820
- log.info(`${validGtfsRoutes.size} valid GTFS routes. (${(routesEnd - routesStart).toFixed(2)}ms)`);
20821
- log.info(`Parsing ${TRIPS_FILE}`);
20822
- const tripsStart = performance.now();
20823
- const tripsStream = await zip.stream(TRIPS_FILE);
20824
- const trips = await parseTrips(tripsStream, activeServiceIds, validGtfsRoutes);
20825
- const tripsEnd = performance.now();
20826
- log.info(`${trips.size} valid trips. (${(tripsEnd - tripsStart).toFixed(2)}ms)`);
20827
- let transfers = new Map();
20828
- let tripContinuationsMap = [];
20829
- if (entries[TRANSFERS_FILE]) {
20830
- log.info(`Parsing ${TRANSFERS_FILE}`);
20831
- const transfersStart = performance.now();
20832
- const transfersStream = await zip.stream(TRANSFERS_FILE);
20833
- const { transfers: parsedTransfers, tripContinuations: parsedTripContinuations, } = await parseTransfers(transfersStream, parsedStops);
20834
- transfers = parsedTransfers;
20835
- tripContinuationsMap = parsedTripContinuations;
20836
- const transfersEnd = performance.now();
20837
- log.info(`${transfers.size} valid transfers and ${tripContinuationsMap.length} trip continuations. (${(transfersEnd - transfersStart).toFixed(2)}ms)`);
20838
- }
20839
- log.info(`Parsing ${STOP_TIMES_FILE}`);
20840
- const stopTimesStart = performance.now();
20841
- const stopTimesStream = await zip.stream(STOP_TIMES_FILE);
20842
- const { routes, serviceRoutesMap, tripsMapping } = await parseStopTimes(stopTimesStream, parsedStops, trips, activeStopIds);
20843
- const serviceRoutes = indexRoutes(validGtfsRoutes, serviceRoutesMap);
20844
- const stopTimesEnd = performance.now();
20845
- log.info(`${routes.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
20846
- log.info('Building stops adjacency structure');
20847
- const stopsAdjacencyStart = performance.now();
20848
- const stopsAdjacency = buildStopsAdjacencyStructure(serviceRoutes, routes, transfers, parsedStops.size, activeStopIds);
20849
- const stopsAdjacencyEnd = performance.now();
20850
- log.info(`${stopsAdjacency.length} valid stops in the structure. (${(stopsAdjacencyEnd - stopsAdjacencyStart).toFixed(2)}ms)`);
20851
- await zip.close();
20852
- // temporary timetable for building continuations
20853
- const timetable = new Timetable(stopsAdjacency, routes, serviceRoutes);
20854
- log.info('Building in-seat trip continuations');
20855
- const tripContinuationsStart = performance.now();
20856
- const tripContinuations = buildTripContinuations(tripsMapping, tripContinuationsMap, timetable, activeStopIds);
20857
- const tripContinuationsEnd = performance.now();
20858
- log.info(`${tripContinuations.size} in-seat trip continuations origins created. (${(tripContinuationsEnd - tripContinuationsStart).toFixed(2)}ms)`);
20859
- log.info('Parsing complete.');
20860
- return new Timetable(stopsAdjacency, routes, serviceRoutes, tripContinuations);
20866
+ parseTimetable(date) {
20867
+ return __awaiter(this, void 0, void 0, function* () {
20868
+ log.setLevel('INFO');
20869
+ const zip = new StreamZip.async({ file: this.path });
20870
+ const entries = yield zip.entries();
20871
+ const datetime = DateTime.fromJSDate(date);
20872
+ const activeServiceIds = new Set();
20873
+ const activeStopIds = new Set();
20874
+ log.info(`Parsing ${STOPS_FILE}`);
20875
+ const stopsStart = performance.now();
20876
+ const stopsStream = yield zip.stream(STOPS_FILE);
20877
+ const parsedStops = yield parseStops(stopsStream);
20878
+ const stopsEnd = performance.now();
20879
+ log.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
20880
+ if (entries[CALENDAR_FILE]) {
20881
+ log.info(`Parsing ${CALENDAR_FILE}`);
20882
+ const calendarStart = performance.now();
20883
+ const calendarStream = yield zip.stream(CALENDAR_FILE);
20884
+ yield parseCalendar(calendarStream, activeServiceIds, datetime);
20885
+ const calendarEnd = performance.now();
20886
+ log.info(`${activeServiceIds.size} valid services. (${(calendarEnd - calendarStart).toFixed(2)}ms)`);
20887
+ }
20888
+ if (entries[CALENDAR_DATES_FILE]) {
20889
+ log.info(`Parsing ${CALENDAR_DATES_FILE}`);
20890
+ const calendarDatesStart = performance.now();
20891
+ const calendarDatesStream = yield zip.stream(CALENDAR_DATES_FILE);
20892
+ yield parseCalendarDates(calendarDatesStream, activeServiceIds, datetime);
20893
+ const calendarDatesEnd = performance.now();
20894
+ log.info(`${activeServiceIds.size} valid services. (${(calendarDatesEnd - calendarDatesStart).toFixed(2)}ms)`);
20895
+ }
20896
+ log.info(`Parsing ${ROUTES_FILE}`);
20897
+ const routesStart = performance.now();
20898
+ const routesStream = yield zip.stream(ROUTES_FILE);
20899
+ const validGtfsRoutes = yield parseRoutes(routesStream, this.profile);
20900
+ const routesEnd = performance.now();
20901
+ log.info(`${validGtfsRoutes.size} valid GTFS routes. (${(routesEnd - routesStart).toFixed(2)}ms)`);
20902
+ log.info(`Parsing ${TRIPS_FILE}`);
20903
+ const tripsStart = performance.now();
20904
+ const tripsStream = yield zip.stream(TRIPS_FILE);
20905
+ const trips = yield parseTrips(tripsStream, activeServiceIds, validGtfsRoutes);
20906
+ const tripsEnd = performance.now();
20907
+ log.info(`${trips.size} valid trips. (${(tripsEnd - tripsStart).toFixed(2)}ms)`);
20908
+ let transfers = new Map();
20909
+ let tripContinuationsMap = [];
20910
+ if (entries[TRANSFERS_FILE]) {
20911
+ log.info(`Parsing ${TRANSFERS_FILE}`);
20912
+ const transfersStart = performance.now();
20913
+ const transfersStream = yield zip.stream(TRANSFERS_FILE);
20914
+ const { transfers: parsedTransfers, tripContinuations: parsedTripContinuations, } = yield parseTransfers(transfersStream, parsedStops);
20915
+ transfers = parsedTransfers;
20916
+ tripContinuationsMap = parsedTripContinuations;
20917
+ const transfersEnd = performance.now();
20918
+ log.info(`${transfers.size} valid transfers and ${tripContinuationsMap.length} trip continuations. (${(transfersEnd - transfersStart).toFixed(2)}ms)`);
20919
+ }
20920
+ log.info(`Parsing ${STOP_TIMES_FILE}`);
20921
+ const stopTimesStart = performance.now();
20922
+ const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
20923
+ const { routes, serviceRoutesMap, tripsMapping } = yield parseStopTimes(stopTimesStream, parsedStops, trips, activeStopIds);
20924
+ const serviceRoutes = indexRoutes(validGtfsRoutes, serviceRoutesMap);
20925
+ const stopTimesEnd = performance.now();
20926
+ log.info(`${routes.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
20927
+ log.info('Building stops adjacency structure');
20928
+ const stopsAdjacencyStart = performance.now();
20929
+ const stopsAdjacency = buildStopsAdjacencyStructure(serviceRoutes, routes, transfers, parsedStops.size, activeStopIds);
20930
+ const stopsAdjacencyEnd = performance.now();
20931
+ log.info(`${stopsAdjacency.length} valid stops in the structure. (${(stopsAdjacencyEnd - stopsAdjacencyStart).toFixed(2)}ms)`);
20932
+ yield zip.close();
20933
+ // temporary timetable for building continuations
20934
+ const timetable = new Timetable(stopsAdjacency, routes, serviceRoutes);
20935
+ log.info('Building in-seat trip continuations');
20936
+ const tripContinuationsStart = performance.now();
20937
+ const tripContinuations = buildTripContinuations(tripsMapping, tripContinuationsMap, timetable, activeStopIds);
20938
+ const tripContinuationsEnd = performance.now();
20939
+ log.info(`${tripContinuations.size} in-seat trip continuations origins created. (${(tripContinuationsEnd - tripContinuationsStart).toFixed(2)}ms)`);
20940
+ log.info('Parsing complete.');
20941
+ return new Timetable(stopsAdjacency, routes, serviceRoutes, tripContinuations);
20942
+ });
20861
20943
  }
20862
20944
  /**
20863
20945
  * Parses a GTFS feed to extract all stops.
@@ -20865,16 +20947,18 @@ class GtfsParser {
20865
20947
  * @param activeStops The set of active stop IDs to include in the index.
20866
20948
  * @returns An index of stops.
20867
20949
  */
20868
- async parseStops() {
20869
- const zip = new StreamZip.async({ file: this.path });
20870
- log.info(`Parsing ${STOPS_FILE}`);
20871
- const stopsStart = performance.now();
20872
- const stopsStream = await zip.stream(STOPS_FILE);
20873
- const stops = await parseStops(stopsStream);
20874
- const stopsEnd = performance.now();
20875
- log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
20876
- await zip.close();
20877
- return new StopsIndex(Array.from(stops.values()));
20950
+ parseStops() {
20951
+ return __awaiter(this, void 0, void 0, function* () {
20952
+ const zip = new StreamZip.async({ file: this.path });
20953
+ log.info(`Parsing ${STOPS_FILE}`);
20954
+ const stopsStart = performance.now();
20955
+ const stopsStream = yield zip.stream(STOPS_FILE);
20956
+ const stops = yield parseStops(stopsStream);
20957
+ const stopsEnd = performance.now();
20958
+ log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
20959
+ yield zip.close();
20960
+ return new StopsIndex(Array.from(stops.values()));
20961
+ });
20878
20962
  }
20879
20963
  }
20880
20964
 
@@ -20928,27 +21012,27 @@ const chGtfsProfile = {
20928
21012
  };
20929
21013
 
20930
21014
  class Plotter {
20931
- result;
20932
- ROUND_COLORS = [
20933
- '#60a5fa', // Round 1
20934
- '#ff9800', // Round 2
20935
- '#14b8a6', // Round 3
20936
- '#fb7185', // Round 4
20937
- '#ffdf00', // Round 5
20938
- '#b600ff', // Round 6
20939
- '#ee82ee', // Round 7+
20940
- ];
20941
21015
  constructor(result) {
21016
+ this.ROUND_COLORS = [
21017
+ '#60a5fa', // Round 1
21018
+ '#ff9800', // Round 2
21019
+ '#14b8a6', // Round 3
21020
+ '#fb7185', // Round 4
21021
+ '#ffdf00', // Round 5
21022
+ '#b600ff', // Round 6
21023
+ '#ee82ee', // Round 7+
21024
+ ];
20942
21025
  this.result = result;
20943
21026
  }
20944
21027
  /**
20945
21028
  * Gets the color for a round based on the specified palette.
20946
21029
  */
20947
21030
  getRoundColor(round) {
21031
+ var _a;
20948
21032
  if (round === 0)
20949
21033
  return '#888888';
20950
21034
  const colorIndex = Math.min(round - 1, this.ROUND_COLORS.length - 1);
20951
- return this.ROUND_COLORS[colorIndex] ?? '#ee82ee';
21035
+ return (_a = this.ROUND_COLORS[colorIndex]) !== null && _a !== void 0 ? _a : '#ee82ee';
20952
21036
  }
20953
21037
  /**
20954
21038
  * Escapes special characters in DOT strings to prevent syntax errors.
@@ -20965,7 +21049,8 @@ class Plotter {
20965
21049
  * Determines station type (origin/destination) information.
20966
21050
  */
20967
21051
  getStationInfo(stopId) {
20968
- const isOrigin = this.result.routingState.graph[0]?.has(stopId) ?? false;
21052
+ var _a, _b;
21053
+ const isOrigin = (_b = (_a = this.result.routingState.graph[0]) === null || _a === void 0 ? void 0 : _a.has(stopId)) !== null && _b !== void 0 ? _b : false;
20969
21054
  const isDestination = this.result.routingState.destinations.includes(stopId);
20970
21055
  return { isOrigin, isDestination };
20971
21056
  }
@@ -21012,6 +21097,7 @@ class Plotter {
21012
21097
  * Creates a vehicle edge with route information oval in the middle.
21013
21098
  */
21014
21099
  createVehicleEdge(edge, round) {
21100
+ var _a;
21015
21101
  const fromNodeId = `s_${edge.from}`;
21016
21102
  const toNodeId = `s_${edge.to}`;
21017
21103
  const roundColor = this.getRoundColor(round);
@@ -21020,8 +21106,8 @@ class Plotter {
21020
21106
  const serviceRouteInfo = route
21021
21107
  ? this.result.timetable.getServiceRouteInfo(route)
21022
21108
  : null;
21023
- const routeName = serviceRouteInfo?.name ?? `Route ${String(edge.routeId)}`;
21024
- const routeType = serviceRouteInfo?.type || 'UNKNOWN';
21109
+ const routeName = (_a = serviceRouteInfo === null || serviceRouteInfo === void 0 ? void 0 : serviceRouteInfo.name) !== null && _a !== void 0 ? _a : `Route ${String(edge.routeId)}`;
21110
+ const routeType = (serviceRouteInfo === null || serviceRouteInfo === void 0 ? void 0 : serviceRouteInfo.type) || 'UNKNOWN';
21025
21111
  const departureTime = route
21026
21112
  ? route.departureFrom(edge.from, edge.tripIndex).toString()
21027
21113
  : 'N/A';
@@ -21040,11 +21126,12 @@ class Plotter {
21040
21126
  * Creates a transfer edge with transfer information oval in the middle.
21041
21127
  */
21042
21128
  createTransferEdge(edge, round) {
21129
+ var _a;
21043
21130
  const fromNodeId = `s_${edge.from}`;
21044
21131
  const toNodeId = `s_${edge.to}`;
21045
21132
  const roundColor = this.getRoundColor(round);
21046
21133
  const transferOvalId = `e_${edge.from}_${edge.to}_${round}`;
21047
- const transferTime = edge.minTransferTime?.toString() || 'N/A';
21134
+ const transferTime = ((_a = edge.minTransferTime) === null || _a === void 0 ? void 0 : _a.toString()) || 'N/A';
21048
21135
  const escapedTransferTime = this.escapeDotString(transferTime);
21049
21136
  const ovalLabel = `Transfer\\n${escapedTransferTime}`;
21050
21137
  return [
@@ -21057,6 +21144,7 @@ class Plotter {
21057
21144
  * Creates a continuation edge to visually link trip continuations.
21058
21145
  */
21059
21146
  createContinuationEdge(fromEdge, toEdge, round) {
21147
+ var _a, _b;
21060
21148
  const fromStationId = `s_${fromEdge.to}`;
21061
21149
  const toStationId = `s_${toEdge.from}`;
21062
21150
  const roundColor = this.getRoundColor(round);
@@ -21069,10 +21157,10 @@ class Plotter {
21069
21157
  const toServiceRouteInfo = toRoute
21070
21158
  ? this.result.timetable.getServiceRouteInfo(toRoute)
21071
21159
  : null;
21072
- const fromRouteName = fromServiceRouteInfo?.name ?? `Route ${String(fromEdge.routeId)}`;
21073
- const toRouteName = toServiceRouteInfo?.name ?? `Route ${String(toEdge.routeId)}`;
21074
- const fromRouteType = fromServiceRouteInfo?.type || 'UNKNOWN';
21075
- const toRouteType = toServiceRouteInfo?.type || 'UNKNOWN';
21160
+ const fromRouteName = (_a = fromServiceRouteInfo === null || fromServiceRouteInfo === void 0 ? void 0 : fromServiceRouteInfo.name) !== null && _a !== void 0 ? _a : `Route ${String(fromEdge.routeId)}`;
21161
+ const toRouteName = (_b = toServiceRouteInfo === null || toServiceRouteInfo === void 0 ? void 0 : toServiceRouteInfo.name) !== null && _b !== void 0 ? _b : `Route ${String(toEdge.routeId)}`;
21162
+ const fromRouteType = (fromServiceRouteInfo === null || fromServiceRouteInfo === void 0 ? void 0 : fromServiceRouteInfo.type) || 'UNKNOWN';
21163
+ const toRouteType = (toServiceRouteInfo === null || toServiceRouteInfo === void 0 ? void 0 : toServiceRouteInfo.type) || 'UNKNOWN';
21076
21164
  const fromArrivalTime = fromEdge.arrival.toString();
21077
21165
  const toDepartureTime = toRoute
21078
21166
  ? toRoute.departureFrom(toEdge.from, toEdge.tripIndex).toString()
@@ -21167,85 +21255,79 @@ class Plotter {
21167
21255
  }
21168
21256
 
21169
21257
  class Query {
21170
- from;
21171
- to;
21172
- departureTime;
21173
- lastDepartureTime;
21174
- options;
21175
21258
  constructor(builder) {
21176
21259
  this.from = builder.fromValue;
21177
21260
  this.to = builder.toValue;
21178
21261
  this.departureTime = builder.departureTimeValue;
21179
21262
  this.options = builder.optionsValue;
21180
21263
  }
21181
- static Builder = class {
21182
- fromValue;
21183
- toValue = new Set();
21184
- departureTimeValue;
21264
+ }
21265
+ Query.Builder = class {
21266
+ constructor() {
21267
+ this.toValue = new Set();
21185
21268
  // lastDepartureTimeValue?: Date;
21186
21269
  // via: StopId[] = [];
21187
- optionsValue = {
21270
+ this.optionsValue = {
21188
21271
  maxTransfers: 5,
21189
21272
  minTransferTime: Duration.fromSeconds(120),
21190
21273
  transportModes: ALL_TRANSPORT_MODES,
21191
21274
  };
21192
- /**
21193
- * Sets the starting stop.
21194
- */
21195
- from(from) {
21196
- this.fromValue = from;
21197
- return this;
21198
- }
21199
- /**
21200
- * Sets the destination stops(s), routing will stop when all the provided stops are reached.
21201
- */
21202
- to(to) {
21203
- this.toValue = to instanceof Set ? to : new Set([to]);
21204
- return this;
21205
- }
21206
- /**
21207
- * Sets the departure time for the query.
21208
- * Note that the router will favor routes that depart shortly after the provided departure time,
21209
- * even if a later route might arrive at the same time.
21210
- * Range queries will allow to specify a range of departure times in the future.
21211
- */
21212
- departureTime(departureTime) {
21213
- this.departureTimeValue = departureTime;
21214
- return this;
21215
- }
21216
- /**
21217
- * Sets the maximum number of transfers allowed.
21218
- */
21219
- maxTransfers(maxTransfers) {
21220
- this.optionsValue.maxTransfers = maxTransfers;
21221
- return this;
21222
- }
21223
- /**
21224
- * Sets the minimum transfer time to use when no transfer time is provided in the data.
21225
- */
21226
- minTransferTime(minTransferTime) {
21227
- this.optionsValue.minTransferTime = minTransferTime;
21228
- return this;
21229
- }
21230
- /**
21231
- * Sets the transport modes to consider.
21232
- */
21233
- transportModes(transportModes) {
21234
- this.optionsValue.transportModes = transportModes;
21235
- return this;
21236
- }
21237
- build() {
21238
- return new Query(this);
21239
- }
21240
- };
21241
- }
21275
+ }
21276
+ /**
21277
+ * Sets the starting stop.
21278
+ */
21279
+ from(from) {
21280
+ this.fromValue = from;
21281
+ return this;
21282
+ }
21283
+ /**
21284
+ * Sets the destination stops(s), routing will stop when all the provided stops are reached.
21285
+ */
21286
+ to(to) {
21287
+ this.toValue = to instanceof Set ? to : new Set([to]);
21288
+ return this;
21289
+ }
21290
+ /**
21291
+ * Sets the departure time for the query.
21292
+ * Note that the router will favor routes that depart shortly after the provided departure time,
21293
+ * even if a later route might arrive at the same time.
21294
+ * Range queries will allow to specify a range of departure times in the future.
21295
+ */
21296
+ departureTime(departureTime) {
21297
+ this.departureTimeValue = departureTime;
21298
+ return this;
21299
+ }
21300
+ /**
21301
+ * Sets the maximum number of transfers allowed.
21302
+ */
21303
+ maxTransfers(maxTransfers) {
21304
+ this.optionsValue.maxTransfers = maxTransfers;
21305
+ return this;
21306
+ }
21307
+ /**
21308
+ * Sets the minimum transfer time to use when no transfer time is provided in the data.
21309
+ */
21310
+ minTransferTime(minTransferTime) {
21311
+ this.optionsValue.minTransferTime = minTransferTime;
21312
+ return this;
21313
+ }
21314
+ /**
21315
+ * Sets the transport modes to consider.
21316
+ */
21317
+ transportModes(transportModes) {
21318
+ this.optionsValue.transportModes = transportModes;
21319
+ return this;
21320
+ }
21321
+ build() {
21322
+ return new Query(this);
21323
+ }
21324
+ };
21242
21325
 
21243
21326
  /**
21244
21327
  * Represents a resolved route consisting of multiple legs,
21245
21328
  * which can be either vehicle legs or transfer legs.
21246
21329
  */
21247
21330
  class Route {
21248
- legs;
21249
21331
  constructor(legs) {
21250
21332
  this.legs = legs;
21251
21333
  }
@@ -21315,10 +21397,11 @@ class Route {
21315
21397
  toString() {
21316
21398
  return this.legs
21317
21399
  .map((leg, index) => {
21400
+ var _a;
21318
21401
  const fromStop = `From: ${leg.from.name}${leg.from.platform ? ` (Pl. ${leg.from.platform})` : ''}`;
21319
21402
  const toStop = `To: ${leg.to.name}${leg.to.platform ? ` (Pl. ${leg.to.platform})` : ''}`;
21320
21403
  const transferDetails = 'minTransferTime' in leg
21321
- ? `Minimum Transfer Time: ${leg.minTransferTime?.toString()}`
21404
+ ? `Minimum Transfer Time: ${(_a = leg.minTransferTime) === null || _a === void 0 ? void 0 : _a.toString()}`
21322
21405
  : '';
21323
21406
  const travelDetails = 'route' in leg && 'departureTime' in leg && 'arrivalTime' in leg
21324
21407
  ? `Route: ${leg.route.type} ${leg.route.name}, Departure: ${leg.departureTime.toString()}, Arrival: ${leg.arrivalTime.toString()}`
@@ -21354,14 +21437,9 @@ class Route {
21354
21437
  };
21355
21438
  }
21356
21439
  else {
21357
- return {
21358
- from: leg.from.sourceStopId,
21359
- to: leg.to.sourceStopId,
21360
- type: leg.type,
21361
- ...(leg.minTransferTime !== undefined && {
21362
- minTransferTime: leg.minTransferTime.toString(),
21363
- }),
21364
- };
21440
+ return Object.assign({ from: leg.from.sourceStopId, to: leg.to.sourceStopId, type: leg.type }, (leg.minTransferTime !== undefined && {
21441
+ minTransferTime: leg.minTransferTime.toString(),
21442
+ }));
21365
21443
  }
21366
21444
  });
21367
21445
  return jsonLegs;
@@ -21369,10 +21447,6 @@ class Route {
21369
21447
  }
21370
21448
 
21371
21449
  class Result {
21372
- query;
21373
- routingState;
21374
- stopsIndex;
21375
- timetable;
21376
21450
  constructor(query, routingState, stopsIndex, timetable) {
21377
21451
  this.query = query;
21378
21452
  this.routingState = routingState;
@@ -21387,6 +21461,7 @@ class Result {
21387
21461
  * @returns a route to the destination stop if it exists.
21388
21462
  */
21389
21463
  bestRoute(to) {
21464
+ var _a;
21390
21465
  const destinationList = to instanceof Set
21391
21466
  ? Array.from(to)
21392
21467
  : to
@@ -21413,7 +21488,7 @@ class Result {
21413
21488
  let currentStop = fastestDestination;
21414
21489
  let round = fastestTime.legNumber;
21415
21490
  while (round > 0) {
21416
- const edge = this.routingState.graph[round]?.get(currentStop);
21491
+ const edge = (_a = this.routingState.graph[round]) === null || _a === void 0 ? void 0 : _a.get(currentStop);
21417
21492
  if (!edge) {
21418
21493
  throw new Error(`No edge arriving at stop ${currentStop} at round ${round}`);
21419
21494
  }
@@ -21498,6 +21573,7 @@ class Result {
21498
21573
  * @returns The arrival time if the target stop is reachable, otherwise undefined.
21499
21574
  */
21500
21575
  arrivalAt(stop, maxTransfers) {
21576
+ var _a;
21501
21577
  const equivalentStops = this.stopsIndex.equivalentStops(stop);
21502
21578
  let earliestArrival = undefined;
21503
21579
  for (const equivalentStop of equivalentStops) {
@@ -21509,7 +21585,7 @@ class Result {
21509
21585
  // We have no guarantee that the stop was visited in the last round,
21510
21586
  // so we need to check all rounds if it's not found in the last one.
21511
21587
  for (let i = maxTransfers + 1; i >= 0; i--) {
21512
- const arrivalEdge = this.routingState.graph[i]?.get(equivalentStop.id);
21588
+ const arrivalEdge = (_a = this.routingState.graph[i]) === null || _a === void 0 ? void 0 : _a.get(equivalentStop.id);
21513
21589
  if (arrivalEdge !== undefined) {
21514
21590
  arrivalTime = {
21515
21591
  arrival: arrivalEdge.arrival,
@@ -21538,8 +21614,6 @@ const UNREACHED = Time.infinity();
21538
21614
  * https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf
21539
21615
  */
21540
21616
  class Router {
21541
- timetable;
21542
- stopsIndex;
21543
21617
  constructor(timetable, stopsIndex) {
21544
21618
  this.timetable = timetable;
21545
21619
  this.stopsIndex = stopsIndex;
@@ -21675,6 +21749,7 @@ class Router {
21675
21749
  * @param routingState The current routing state containing arrival times and marked stops
21676
21750
  */
21677
21751
  scanRoute(route, hopOnStopIndex, round, routingState, tripContinuation) {
21752
+ var _a, _b, _c;
21678
21753
  const newlyMarkedStops = new Set();
21679
21754
  let activeTrip = tripContinuation
21680
21755
  ? {
@@ -21694,7 +21769,7 @@ class Router {
21694
21769
  if (activeTrip !== undefined) {
21695
21770
  const arrivalTime = route.arrivalAt(currentStopIndex, activeTrip.tripIndex);
21696
21771
  const dropOffType = route.dropOffTypeAt(currentStopIndex, activeTrip.tripIndex);
21697
- const earliestArrivalAtCurrentStop = routingState.earliestArrivals.get(currentStop)?.arrival ?? UNREACHED;
21772
+ const earliestArrivalAtCurrentStop = (_b = (_a = routingState.earliestArrivals.get(currentStop)) === null || _a === void 0 ? void 0 : _a.arrival) !== null && _b !== void 0 ? _b : UNREACHED;
21698
21773
  if (dropOffType !== 'NOT_AVAILABLE' &&
21699
21774
  arrivalTime.isBefore(earliestArrivalAtCurrentStop) &&
21700
21775
  arrivalTime.isBefore(earliestArrivalAtAnyDestination)) {
@@ -21723,7 +21798,7 @@ class Router {
21723
21798
  }
21724
21799
  // check if we can board an earlier trip at the current stop
21725
21800
  // if there was no current trip, find the first one reachable
21726
- const earliestArrivalOnPreviousRound = edgesAtPreviousRound.get(currentStop)?.arrival;
21801
+ const earliestArrivalOnPreviousRound = (_c = edgesAtPreviousRound.get(currentStop)) === null || _c === void 0 ? void 0 : _c.arrival;
21727
21802
  // TODO if the last edge is not a transfer, and if there is no trip continuation of type 1 (guaranteed)
21728
21803
  // Add the minTransferTime to make sure there's at least 2 minutes to transfer.
21729
21804
  // If platforms are collapsed, make sure to apply the station level transfer time
@@ -21732,7 +21807,7 @@ class Router {
21732
21807
  (activeTrip === undefined ||
21733
21808
  earliestArrivalOnPreviousRound.isBefore(route.departureFrom(currentStopIndex, activeTrip.tripIndex)) ||
21734
21809
  earliestArrivalOnPreviousRound.equals(route.departureFrom(currentStopIndex, activeTrip.tripIndex)))) {
21735
- const earliestTrip = route.findEarliestTrip(currentStopIndex, earliestArrivalOnPreviousRound, activeTrip?.tripIndex);
21810
+ const earliestTrip = route.findEarliestTrip(currentStopIndex, earliestArrivalOnPreviousRound, activeTrip === null || activeTrip === void 0 ? void 0 : activeTrip.tripIndex);
21736
21811
  if (earliestTrip !== undefined) {
21737
21812
  activeTrip = {
21738
21813
  routeId: route.id,
@@ -21755,6 +21830,7 @@ class Router {
21755
21830
  * @param routingState The current routing state containing arrival times and marked stops
21756
21831
  */
21757
21832
  considerTransfers(query, round, markedStops, routingState) {
21833
+ var _a, _b;
21758
21834
  const { options } = query;
21759
21835
  const arrivalsAtCurrentRound = routingState.graph[round];
21760
21836
  const newlyMarkedStops = new Set();
@@ -21778,8 +21854,7 @@ class Router {
21778
21854
  transferTime = options.minTransferTime;
21779
21855
  }
21780
21856
  const arrivalAfterTransfer = currentArrival.arrival.plus(transferTime);
21781
- const originalArrival = arrivalsAtCurrentRound.get(transfer.destination)?.arrival ??
21782
- UNREACHED;
21857
+ const originalArrival = (_b = (_a = routingState.earliestArrivals.get(transfer.destination)) === null || _a === void 0 ? void 0 : _a.arrival) !== null && _b !== void 0 ? _b : UNREACHED;
21783
21858
  if (arrivalAfterTransfer.isBefore(originalArrival)) {
21784
21859
  arrivalsAtCurrentRound.set(transfer.destination, {
21785
21860
  arrival: arrivalAfterTransfer,
@@ -21806,10 +21881,11 @@ class Router {
21806
21881
  * @returns The earliest arrival time among the provided destinations.
21807
21882
  */
21808
21883
  earliestArrivalAtAnyStop(earliestArrivals, destinations) {
21884
+ var _a, _b;
21809
21885
  let earliestArrivalAtAnyDestination = UNREACHED;
21810
21886
  for (let i = 0; i < destinations.length; i++) {
21811
21887
  const destination = destinations[i];
21812
- const arrival = earliestArrivals.get(destination)?.arrival ?? UNREACHED;
21888
+ const arrival = (_b = (_a = earliestArrivals.get(destination)) === null || _a === void 0 ? void 0 : _a.arrival) !== null && _b !== void 0 ? _b : UNREACHED;
21813
21889
  earliestArrivalAtAnyDestination = Time.min(earliestArrivalAtAnyDestination, arrival);
21814
21890
  }
21815
21891
  return earliestArrivalAtAnyDestination;
@@ -22217,14 +22293,15 @@ const startRepl = (stopsPath, timetablePath) => {
22217
22293
  if (transfers.length > 0) {
22218
22294
  console.log('\n--- Transfers ---');
22219
22295
  transfers.forEach((transfer, index) => {
22296
+ var _a, _b;
22220
22297
  const destStop = stopsIndex.findStopById(transfer.destination);
22221
- const platform = destStop?.platform
22298
+ const platform = (destStop === null || destStop === void 0 ? void 0 : destStop.platform)
22222
22299
  ? ` (Pl. ${destStop.platform})`
22223
22300
  : '';
22224
22301
  const minTime = transfer.minTransferTime
22225
22302
  ? ` (min: ${Math.floor(transfer.minTransferTime.toSeconds() / 60)}min)`
22226
22303
  : '';
22227
- console.log(`${index + 1}. ${transfer.type} to ${destStop?.name ?? 'Unknown'}${platform} (${transfer.destination}, ${destStop?.sourceStopId ?? 'N/A'})${minTime}`);
22304
+ console.log(`${index + 1}. ${transfer.type} to ${(_a = destStop === null || destStop === void 0 ? void 0 : destStop.name) !== null && _a !== void 0 ? _a : 'Unknown'}${platform} (${transfer.destination}, ${(_b = destStop === null || destStop === void 0 ? void 0 : destStop.sourceStopId) !== null && _b !== void 0 ? _b : 'N/A'})${minTime}`);
22228
22305
  });
22229
22306
  }
22230
22307
  let totalContinuations = 0;
@@ -22264,10 +22341,10 @@ const startRepl = (stopsPath, timetablePath) => {
22264
22341
  console.log();
22265
22342
  };
22266
22343
  if (type === 'route') {
22267
- inspectRoute(idStr ?? '');
22344
+ inspectRoute(idStr !== null && idStr !== void 0 ? idStr : '');
22268
22345
  }
22269
22346
  else {
22270
- inspectStop(idStr ?? '');
22347
+ inspectStop(idStr !== null && idStr !== void 0 ? idStr : '');
22271
22348
  }
22272
22349
  this.displayPrompt();
22273
22350
  },
@@ -22291,7 +22368,7 @@ program
22291
22368
  .option('-s, --stopsOutputPath <path>', 'Path to output stops file', '/tmp/stops')
22292
22369
  .option('-p, --profileName <name>', 'Profile name for GTFS config', 'CH')
22293
22370
  .option('-v, --verbose', 'Verbose mode', false)
22294
- .action(async (gtfsPath, options) => {
22371
+ .action((gtfsPath, options) => __awaiter(void 0, void 0, void 0, function* () {
22295
22372
  if (options.verbose) {
22296
22373
  log.setDefaultLevel(log.levels.INFO);
22297
22374
  }
@@ -22299,11 +22376,11 @@ program
22299
22376
  log.setDefaultLevel(log.levels.ERROR);
22300
22377
  }
22301
22378
  const parser = new GtfsParser(gtfsPath, profiles[options.profileName]);
22302
- const stopsIndex = await parser.parseStops();
22379
+ const stopsIndex = yield parser.parseStops();
22303
22380
  fs.writeFileSync(options.stopsOutputPath, stopsIndex.serialize());
22304
- const timetable = await parser.parseTimetable(new Date(options.date));
22381
+ const timetable = yield parser.parseTimetable(new Date(options.date));
22305
22382
  fs.writeFileSync(options.timetableOutputPath, timetable.serialize());
22306
- });
22383
+ }));
22307
22384
  program
22308
22385
  .command('parse-stops')
22309
22386
  .description('Parse a GTFS feed and output a stops file.')
@@ -22311,7 +22388,7 @@ program
22311
22388
  .option('-s, --outputPath <path>', 'Path to output stops file', '/tmp/stops')
22312
22389
  .option('-p, --profileName <name>', 'Profile name for GTFS config', 'CH')
22313
22390
  .option('-v, --verbose', 'Verbose mode', false)
22314
- .action(async (gtfsPath, options) => {
22391
+ .action((gtfsPath, options) => __awaiter(void 0, void 0, void 0, function* () {
22315
22392
  if (options.verbose) {
22316
22393
  log.setDefaultLevel(log.levels.INFO);
22317
22394
  }
@@ -22319,9 +22396,9 @@ program
22319
22396
  log.setDefaultLevel(log.levels.ERROR);
22320
22397
  }
22321
22398
  const parser = new GtfsParser(gtfsPath, profiles[options.profileName]);
22322
- const stopsIndex = await parser.parseStops();
22399
+ const stopsIndex = yield parser.parseStops();
22323
22400
  fs.writeFileSync(options.stopsOutputPath, stopsIndex.serialize());
22324
- });
22401
+ }));
22325
22402
  program
22326
22403
  .command('repl')
22327
22404
  .description('Find stops matching a textual query')