minotor 11.5.2 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
- ## [11.5.2](https://github.com/aubryio/minotor/compare/v11.5.1...v11.5.2) (2026-10-19)
1
+ # [12.0.0](https://github.com/aubryio/minotor/compare/v11.5.2...v12.0.0) (2026-10-20)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Code Refactoring
5
5
 
6
- * dependencies updates. ([#78](https://github.com/aubryio/minotor/issues/78)) ([db983ef](https://github.com/aubryio/minotor/commit/db983ef559f52c0827a20b61ebc80c338db54165))
6
+ * use numeric types rather than strings across the api ([#79](https://github.com/aubryio/minotor/issues/79)) ([80c395b](https://github.com/aubryio/minotor/commit/80c395bcc7db1523e7f267ef1803591fca181386))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * Route types, pick-up and drop-off types and transfer types are now numerical rather
12
+ than strings in the API.
package/README.md CHANGED
@@ -136,7 +136,7 @@ Query options:
136
136
  | `minTransferTime` | `2 min` | Fallback minimum transfer time |
137
137
  | `maxDuration` | unlimited | Maximum total journey duration from the query departure time |
138
138
  | `maxInitialWaitingTime` | unlimited | Maximum wait for the first vehicle after arriving at the boarding stop |
139
- | `transportModes` | all | Restrict to a subset of GTFS route types |
139
+ | `transportModes` | all | Restrict to a subset of `RouteTypes` values |
140
140
 
141
141
  #### Range query (browser or Node.js)
142
142
 
package/dist/cli.mjs CHANGED
@@ -22642,13 +22642,13 @@ class Route {
22642
22642
  const fromStop = `From: ${leg.from.name}${leg.from.platform ? ` (Pl. ${leg.from.platform})` : ''}`;
22643
22643
  const toStop = `To: ${leg.to.name}${leg.to.platform ? ` (Pl. ${leg.to.platform})` : ''}`;
22644
22644
  const transferDetails = 'type' in leg && !('route' in leg)
22645
- ? `Transfer: ${leg.type}${leg.minTransferTime ? `, Minimum Transfer Time: ${durationToString(leg.minTransferTime)}` : ''}`
22645
+ ? `Transfer: ${transferTypeToString(leg.type)}${leg.minTransferTime ? `, Minimum Transfer Time: ${durationToString(leg.minTransferTime)}` : ''}`
22646
22646
  : '';
22647
22647
  const accessDetails = 'duration' in leg
22648
22648
  ? `Access duration: ${durationToString(leg.duration)}`
22649
22649
  : '';
22650
22650
  const travelDetails = 'route' in leg && 'departureTime' in leg && 'arrivalTime' in leg
22651
- ? `Route: ${leg.route.type} ${leg.route.name}, Departure: ${timeToString(leg.departureTime)}, Arrival: ${timeToString(leg.arrivalTime)}`
22651
+ ? `Route: ${routeTypeToString(leg.route.type)} ${leg.route.name}, Departure: ${timeToString(leg.departureTime)}, Arrival: ${timeToString(leg.arrivalTime)}`
22652
22652
  : '';
22653
22653
  return [
22654
22654
  `Leg ${index + 1}:`,
@@ -22665,30 +22665,6 @@ class Route {
22665
22665
  }
22666
22666
  }
22667
22667
 
22668
- /**
22669
- * Details about the pickup and drop-off modalities at each stop in each trip of a route.
22670
- */
22671
- const pickUpDropOffTypeMap = [
22672
- 'REGULAR',
22673
- 'NOT_AVAILABLE',
22674
- 'MUST_PHONE_AGENCY',
22675
- 'MUST_COORDINATE_WITH_DRIVER',
22676
- ];
22677
- /**
22678
- * Converts a numerical representation of a pick-up/drop-off type
22679
- * into its corresponding string representation.
22680
- *
22681
- * @param numericalType - The numerical value representing the pick-up/drop-off type.
22682
- * @returns The corresponding PickUpDropOffTypeString as a string.
22683
- * @throws An error if the numerical type is invalid.
22684
- */
22685
- const toPickupDropOffType = (rawType) => {
22686
- const type = pickUpDropOffTypeMap[rawType];
22687
- if (!type) {
22688
- throw new Error(`Invalid pickup/drop-off type ${rawType}`);
22689
- }
22690
- return type;
22691
- };
22692
22668
  class Result {
22693
22669
  constructor(destinations, routingState, stopsIndex, timetable) {
22694
22670
  this.destinations = destinations;
@@ -22838,7 +22814,7 @@ class Result {
22838
22814
  buildServiceRouteInfo(route) {
22839
22815
  const serviceRouteInfo = this.timetable.getServiceRouteInfo(route);
22840
22816
  return {
22841
- type: routeTypeToString(serviceRouteInfo.type),
22817
+ type: serviceRouteInfo.type,
22842
22818
  name: serviceRouteInfo.name,
22843
22819
  };
22844
22820
  }
@@ -22872,8 +22848,8 @@ class Result {
22872
22848
  route: this.buildServiceRouteInfo(firstRoute),
22873
22849
  departureTime: firstRoute.departureFrom(firstEdge.stopIndex, firstEdge.tripIndex),
22874
22850
  arrivalTime: lastEdge.arrival,
22875
- pickUpType: toPickupDropOffType(firstRoute.pickUpTypeFrom(firstEdge.stopIndex, firstEdge.tripIndex)),
22876
- dropOffType: toPickupDropOffType(lastRoute.dropOffTypeAt(lastEdge.hopOffStopIndex, lastEdge.tripIndex)),
22851
+ pickUpType: firstRoute.pickUpTypeFrom(firstEdge.stopIndex, firstEdge.tripIndex),
22852
+ dropOffType: lastRoute.dropOffTypeAt(lastEdge.hopOffStopIndex, lastEdge.tripIndex),
22877
22853
  };
22878
22854
  }
22879
22855
  /**
@@ -22889,7 +22865,7 @@ class Result {
22889
22865
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22890
22866
  to: this.stopsIndex.findStopById(edge.to),
22891
22867
  minTransferTime: edge.minTransferTime,
22892
- type: transferTypeToString(edge.type),
22868
+ type: edge.type,
22893
22869
  };
22894
22870
  }
22895
22871
  /**
@@ -22926,7 +22902,7 @@ class Result {
22926
22902
  from: this.stopsIndex.findStopById(fromStopId),
22927
22903
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22928
22904
  to: this.stopsIndex.findStopById(toStopId),
22929
- type: transferTypeToString(TransferTypes.GUARANTEED),
22905
+ type: TransferTypes.GUARANTEED,
22930
22906
  };
22931
22907
  }
22932
22908
  /**
@@ -24729,7 +24705,7 @@ const startRepl = (stopsPath, timetablePath) => {
24729
24705
  }
24730
24706
  const serviceRouteInfo = timetable.getServiceRouteInfo(route);
24731
24707
  const routeName = serviceRouteInfo.name;
24732
- const routeType = serviceRouteInfo.type;
24708
+ const routeType = routeTypeToString(serviceRouteInfo.type);
24733
24709
  console.log(`\n=== Route ${routeId} ===`);
24734
24710
  console.log(`Service Route: ${routeName}`);
24735
24711
  console.log(`Type: ${routeType}`);
@@ -24809,7 +24785,7 @@ const startRepl = (stopsPath, timetablePath) => {
24809
24785
  console.log('\n--- Routes ---');
24810
24786
  routes.forEach((route, index) => {
24811
24787
  const serviceRouteInfo = timetable.getServiceRouteInfo(route);
24812
- console.log(`${index + 1}. Route ${route.id}: ${serviceRouteInfo.name} (${serviceRouteInfo.type})`);
24788
+ console.log(`${index + 1}. Route ${route.id}: ${serviceRouteInfo.name} (${routeTypeToString(serviceRouteInfo.type)})`);
24813
24789
  });
24814
24790
  }
24815
24791
  const transfers = timetable.getTransfers(stop.id);
@@ -24825,7 +24801,7 @@ const startRepl = (stopsPath, timetablePath) => {
24825
24801
  const minTime = transfer.minTransferTime
24826
24802
  ? ` (min: ${transfer.minTransferTime}min)`
24827
24803
  : '';
24828
- 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}`);
24804
+ console.log(`${index + 1}. ${transferTypeToString(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}`);
24829
24805
  });
24830
24806
  }
24831
24807
  let totalContinuations = 0;