minotor 9.1.0 → 9.2.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,13 +1,6 @@
1
- # [9.1.0](https://github.com/aubryio/minotor/compare/v9.0.2...v9.1.0) (2026-01-05)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * address rate limiting issues in CI build ([#57](https://github.com/aubryio/minotor/issues/57)) ([efb06a6](https://github.com/aubryio/minotor/commit/efb06a68bd57ccd36da0faab852653de6be9b5b1))
7
- * configure actions to work with trusted npm publisher ([e515e5b](https://github.com/aubryio/minotor/commit/e515e5b0dfcef3c479134f431db71f687ca278a1))
8
- * fix security issues in dependencies and npm ([#56](https://github.com/aubryio/minotor/issues/56)) ([b5e2802](https://github.com/aubryio/minotor/commit/b5e2802366f63e9710bc5a5ca3cc1d02a7f109fa))
1
+ # [9.2.0](https://github.com/aubryio/minotor/compare/v9.1.0...v9.2.0) (2026-01-08)
9
2
 
10
3
 
11
4
  ### Features
12
5
 
13
- * **stopsindex:** add a stop iterator ([#55](https://github.com/aubryio/minotor/issues/55)) ([54f6717](https://github.com/aubryio/minotor/commit/54f6717b3ac1c00ef453c3534ffc2e6d8c1fc7c7))
6
+ * allow to query best routes by stop ids directly ([#58](https://github.com/aubryio/minotor/issues/58)) ([9cd71aa](https://github.com/aubryio/minotor/commit/9cd71aa7f856e0bfcc895dc5b28b43b27154da3b))
package/dist/cli.mjs CHANGED
@@ -21463,6 +21463,26 @@ class Result {
21463
21463
  this.stopsIndex = stopsIndex;
21464
21464
  this.timetable = timetable;
21465
21465
  }
21466
+ /**
21467
+ * Reconstructs the best route to a stop by StopId.
21468
+ * (to any stop reachable in less time / transfers than the destination(s) of the query)
21469
+ *
21470
+ * @param to The destination stop by StopId.
21471
+ * @returns a route to the destination stop if it exists.
21472
+ */
21473
+ bestRouteToStopId(to) {
21474
+ var _a;
21475
+ const sourceStopIds = to instanceof Set
21476
+ ? new Set(Array.from(to)
21477
+ .map((stopId) => { var _a; return (_a = this.stopsIndex.findStopById(stopId)) === null || _a === void 0 ? void 0 : _a.sourceStopId; })
21478
+ .filter((sourceId) => sourceId !== undefined))
21479
+ : (_a = this.stopsIndex.findStopById(to)) === null || _a === void 0 ? void 0 : _a.sourceStopId;
21480
+ if (sourceStopIds === undefined ||
21481
+ (sourceStopIds instanceof Set && sourceStopIds.size === 0)) {
21482
+ return undefined;
21483
+ }
21484
+ return this.bestRoute(sourceStopIds);
21485
+ }
21466
21486
  /**
21467
21487
  * Reconstructs the best route to a stop.
21468
21488
  * (to any stop reachable in less time / transfers than the destination(s) of the query)
@@ -21477,17 +21497,19 @@ class Result {
21477
21497
  : to
21478
21498
  ? [to]
21479
21499
  : Array.from(this.query.to);
21480
- const destinations = destinationList.flatMap((destination) => this.stopsIndex.equivalentStops(destination));
21481
21500
  // find the first reached destination
21482
21501
  let fastestDestination = undefined;
21483
21502
  let fastestTime = undefined;
21484
- for (const destination of destinations) {
21485
- const arrivalTime = this.routingState.earliestArrivals.get(destination.id);
21486
- if (arrivalTime !== undefined) {
21487
- if (fastestTime === undefined ||
21488
- arrivalTime.arrival.isBefore(fastestTime.arrival)) {
21489
- fastestDestination = destination.id;
21490
- fastestTime = arrivalTime;
21503
+ for (const sourceDestination of destinationList) {
21504
+ const equivalentStops = this.stopsIndex.equivalentStops(sourceDestination);
21505
+ for (const destination of equivalentStops) {
21506
+ const arrivalTime = this.routingState.earliestArrivals.get(destination.id);
21507
+ if (arrivalTime !== undefined) {
21508
+ if (fastestTime === undefined ||
21509
+ arrivalTime.arrival.isBefore(fastestTime.arrival)) {
21510
+ fastestDestination = destination.id;
21511
+ fastestTime = arrivalTime;
21512
+ }
21491
21513
  }
21492
21514
  }
21493
21515
  }