minotor 3.0.1 → 3.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.
Files changed (81) hide show
  1. package/.cspell.json +12 -1
  2. package/.gitattributes +3 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +3 -0
  4. package/.github/workflows/minotor.yml +17 -1
  5. package/CHANGELOG.md +2 -2
  6. package/README.md +34 -14
  7. package/dist/__e2e__/router.test.d.ts +1 -0
  8. package/dist/cli/perf.d.ts +28 -0
  9. package/dist/cli/utils.d.ts +6 -2
  10. package/dist/cli.mjs +1967 -823
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/gtfs/trips.d.ts +1 -0
  13. package/dist/gtfs/utils.d.ts +1 -1
  14. package/dist/parser.cjs.js +1030 -627
  15. package/dist/parser.cjs.js.map +1 -1
  16. package/dist/parser.d.ts +4 -2
  17. package/dist/parser.esm.js +1030 -627
  18. package/dist/parser.esm.js.map +1 -1
  19. package/dist/router.cjs.js +1 -1
  20. package/dist/router.cjs.js.map +1 -1
  21. package/dist/router.d.ts +10 -5
  22. package/dist/router.esm.js +1 -1
  23. package/dist/router.esm.js.map +1 -1
  24. package/dist/router.umd.js +1 -1
  25. package/dist/router.umd.js.map +1 -1
  26. package/dist/routing/__tests__/result.test.d.ts +1 -0
  27. package/dist/routing/query.d.ts +27 -6
  28. package/dist/routing/result.d.ts +1 -1
  29. package/dist/routing/route.d.ts +47 -2
  30. package/dist/routing/router.d.ts +15 -1
  31. package/dist/stops/stopsIndex.d.ts +3 -3
  32. package/dist/timetable/__tests__/route.test.d.ts +1 -0
  33. package/dist/timetable/__tests__/time.test.d.ts +1 -0
  34. package/dist/timetable/io.d.ts +7 -1
  35. package/dist/timetable/proto/timetable.d.ts +1 -1
  36. package/dist/timetable/route.d.ts +155 -0
  37. package/dist/timetable/time.d.ts +21 -0
  38. package/dist/timetable/timetable.d.ts +41 -61
  39. package/package.json +36 -34
  40. package/src/__e2e__/benchmark.json +22 -0
  41. package/src/__e2e__/router.test.ts +209 -0
  42. package/src/__e2e__/timetable/stops.bin +3 -0
  43. package/src/__e2e__/timetable/timetable.bin +3 -0
  44. package/src/cli/minotor.ts +51 -1
  45. package/src/cli/perf.ts +136 -0
  46. package/src/cli/repl.ts +26 -13
  47. package/src/cli/utils.ts +6 -28
  48. package/src/gtfs/__tests__/parser.test.ts +12 -15
  49. package/src/gtfs/__tests__/services.test.ts +1 -0
  50. package/src/gtfs/__tests__/transfers.test.ts +0 -1
  51. package/src/gtfs/__tests__/trips.test.ts +67 -74
  52. package/src/gtfs/profiles/ch.ts +1 -1
  53. package/src/gtfs/routes.ts +4 -4
  54. package/src/gtfs/services.ts +15 -2
  55. package/src/gtfs/stops.ts +7 -3
  56. package/src/gtfs/transfers.ts +6 -3
  57. package/src/gtfs/trips.ts +33 -16
  58. package/src/gtfs/utils.ts +13 -2
  59. package/src/parser.ts +4 -2
  60. package/src/router.ts +17 -11
  61. package/src/routing/__tests__/result.test.ts +392 -0
  62. package/src/routing/__tests__/router.test.ts +94 -137
  63. package/src/routing/query.ts +28 -7
  64. package/src/routing/result.ts +10 -5
  65. package/src/routing/route.ts +95 -9
  66. package/src/routing/router.ts +82 -66
  67. package/src/stops/__tests__/io.test.ts +1 -1
  68. package/src/stops/__tests__/stopFinder.test.ts +1 -1
  69. package/src/stops/proto/stops.ts +4 -4
  70. package/src/stops/stopsIndex.ts +3 -3
  71. package/src/timetable/__tests__/io.test.ts +16 -23
  72. package/src/timetable/__tests__/route.test.ts +317 -0
  73. package/src/timetable/__tests__/time.test.ts +494 -0
  74. package/src/timetable/__tests__/timetable.test.ts +64 -75
  75. package/src/timetable/io.ts +32 -26
  76. package/src/timetable/proto/timetable.proto +1 -1
  77. package/src/timetable/proto/timetable.ts +13 -13
  78. package/src/timetable/route.ts +347 -0
  79. package/src/timetable/time.ts +40 -8
  80. package/src/timetable/timetable.ts +74 -165
  81. package/tsconfig.build.json +1 -1
@@ -0,0 +1 @@
1
+ export {};
@@ -4,31 +4,52 @@ import { Time } from '../timetable/time.js';
4
4
  import { RouteType } from '../timetable/timetable.js';
5
5
  export declare class Query {
6
6
  from: SourceStopId;
7
- to: SourceStopId[];
7
+ to: Set<SourceStopId>;
8
8
  departureTime: Time;
9
9
  lastDepartureTime?: Time;
10
10
  options: {
11
11
  maxTransfers: number;
12
12
  minTransferTime: Duration;
13
- transportModes: RouteType[];
13
+ transportModes: Set<RouteType>;
14
14
  };
15
15
  constructor(builder: typeof Query.Builder.prototype);
16
16
  static Builder: {
17
17
  new (): {
18
18
  fromValue: SourceStopId;
19
- toValue: SourceStopId[];
19
+ toValue: Set<SourceStopId>;
20
20
  departureTimeValue: Time;
21
21
  optionsValue: {
22
22
  maxTransfers: number;
23
23
  minTransferTime: Duration;
24
- transportModes: RouteType[];
24
+ transportModes: Set<RouteType>;
25
25
  };
26
+ /**
27
+ * Sets the starting stop.
28
+ */
26
29
  from(from: SourceStopId): /*elided*/ any;
27
- to(to: SourceStopId | SourceStopId[]): /*elided*/ any;
30
+ /**
31
+ * Sets the destination stops(s), routing will stop when all the provided stops are reached.
32
+ */
33
+ to(to: SourceStopId | Set<SourceStopId>): /*elided*/ any;
34
+ /**
35
+ * Sets the departure time for the query.
36
+ * Note that the router will favor routes that depart shortly after the provided departure time,
37
+ * even if a later route might arrive at the same time.
38
+ * Range queries will allow to specify a range of departure times in the future.
39
+ */
28
40
  departureTime(departureTime: Time): /*elided*/ any;
41
+ /**
42
+ * Sets the maximum number of transfers allowed.
43
+ */
29
44
  maxTransfers(maxTransfers: number): /*elided*/ any;
45
+ /**
46
+ * Sets the minimum transfer time to use when no transfer time is provided in the data.
47
+ */
30
48
  minTransferTime(minTransferTime: Duration): /*elided*/ any;
31
- transportModes(transportModes: RouteType[]): /*elided*/ any;
49
+ /**
50
+ * Sets the transport modes to consider.
51
+ */
52
+ transportModes(transportModes: Set<RouteType>): /*elided*/ any;
32
53
  build(): Query;
33
54
  };
34
55
  };
@@ -16,7 +16,7 @@ export declare class Result {
16
16
  * @param to The destination stop. Defaults to the destination of the original query.
17
17
  * @returns a route to the destination stop if it exists.
18
18
  */
19
- bestRoute(to?: SourceStopId | SourceStopId[]): Route | undefined;
19
+ bestRoute(to?: SourceStopId | Set<SourceStopId>): Route | undefined;
20
20
  /**
21
21
  * Returns the arrival time at any stop reachable in less time / transfers than the destination(s) of the query)
22
22
  *
@@ -1,7 +1,18 @@
1
- import { Stop } from '../stops/stops.js';
1
+ import { SourceStopId, Stop } from '../stops/stops.js';
2
2
  import { Duration } from '../timetable/duration.js';
3
3
  import { Time } from '../timetable/time.js';
4
4
  import { ServiceRoute, TransferType } from '../timetable/timetable.js';
5
+ export type JsonLeg = {
6
+ from: SourceStopId;
7
+ to: SourceStopId;
8
+ } & ({
9
+ departure: string;
10
+ arrival: string;
11
+ route: ServiceRoute;
12
+ } | {
13
+ type: TransferType;
14
+ minTransferTime?: string;
15
+ });
5
16
  export type PickUpDropOffType = 'REGULAR' | 'NOT_AVAILABLE' | 'MUST_PHONE_AGENCY' | 'MUST_COORDINATE_WITH_DRIVER';
6
17
  export type BaseLeg = {
7
18
  from: Stop;
@@ -17,11 +28,45 @@ export type VehicleLeg = BaseLeg & {
17
28
  arrivalTime: Time;
18
29
  };
19
30
  export type Leg = Transfer | VehicleLeg;
31
+ /**
32
+ * Represents a resolved route consisting of multiple legs,
33
+ * which can be either vehicle legs or transfer legs.
34
+ */
20
35
  export declare class Route {
21
36
  legs: Leg[];
22
37
  constructor(legs: Leg[]);
38
+ /**
39
+ * Calculates the departure time of the route.
40
+ *
41
+ * @returns The departure time of the route.
42
+ * @throws If no vehicle leg is found in the route.
43
+ */
23
44
  departureTime(): Time;
45
+ /**
46
+ * Calculates the arrival time of the route.
47
+ *
48
+ * @returns The arrival time of the route.
49
+ * @throws If no vehicle leg is found in the route.
50
+ */
24
51
  arrivalTime(): Time;
52
+ /**
53
+ * Calculates the total duration of the route.
54
+ *
55
+ * @returns The total duration of the route.
56
+ */
25
57
  totalDuration(): Duration;
26
- print(): string;
58
+ /**
59
+ * Generates a human-readable string representation of the route.
60
+ *
61
+ * @returns A formatted string describing each leg of the route.
62
+ */
63
+ toString(): string;
64
+ /**
65
+ * Generates a concise JSON representation of the route.
66
+ * This is particularly useful for generating regression tests
67
+ * to verify the correctness of route calculations.
68
+ *
69
+ * @returns A JSON representation of the route.
70
+ */
71
+ asJson(): JsonLeg[];
27
72
  }
@@ -9,10 +9,16 @@ export type TripLeg = ReachingTime & {
9
9
  leg?: Leg;
10
10
  };
11
11
  export type ReachingTime = {
12
- time: Time;
12
+ arrival: Time;
13
13
  legNumber: number;
14
14
  origin: StopId;
15
15
  };
16
+ /**
17
+ * A public transportation network router utilizing the RAPTOR algorithm for
18
+ * efficient journey planning and routing. For more information on the RAPTOR
19
+ * algorithm, refer to its detailed explanation in the research paper:
20
+ * https://www.microsoft.com/en-us/research/wp-content/uploads/2012/01/raptor_alenex.pdf
21
+ */
16
22
  export declare class Router {
17
23
  private readonly timetable;
18
24
  private readonly stopsIndex;
@@ -23,6 +29,14 @@ export declare class Router {
23
29
  * stops that can be reached through these transfers.
24
30
  */
25
31
  private considerTransfers;
32
+ /**
33
+ * Finds the earliest arrival time at any stop from a given set of destinations.
34
+ *
35
+ * @param earliestArrivals A map of stops to their earliest reaching times.
36
+ * @param destinations An array of destination stops to evaluate.
37
+ * @returns The earliest arrival time among the provided destinations.
38
+ */
39
+ private earliestArrivalAtAnyStop;
26
40
  /**
27
41
  * The main Raptor algorithm implementation.
28
42
  *
@@ -14,14 +14,14 @@ export declare class StopsIndex {
14
14
  /**
15
15
  * Deserializes a binary representation of the stops.
16
16
  *
17
- * @param {Uint8Array} data - The binary data to deserialize.
18
- * @returns {StopsMap} - The deserialized StopFinder.
17
+ * @param data - The binary data to deserialize.
18
+ * @returns The deserialized StopFinder.
19
19
  */
20
20
  static fromData(data: Uint8Array): StopsIndex;
21
21
  /**
22
22
  * Serializes the stops into a binary protobuf.
23
23
  *
24
- * @returns {Uint8Array} - The serialized binary data.
24
+ * @returns The serialized binary data.
25
25
  */
26
26
  serialize(): Uint8Array;
27
27
  /**
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,11 @@
1
1
  import { RoutesAdjacency as ProtoRoutesAdjacency, ServiceRoutesMap as ProtoServiceRoutesMap, StopsAdjacency as ProtoStopsAdjacency } from './proto/timetable.js';
2
- import { RoutesAdjacency, ServiceRoutesMap, StopsAdjacency } from './timetable.js';
2
+ import { RoutesAdjacency, ServiceRouteId, ServiceRoutesMap, StopsAdjacency } from './timetable.js';
3
+ export type SerializedRoute = {
4
+ stopTimes: Uint16Array;
5
+ pickUpDropOffTypes: Uint8Array;
6
+ stops: Uint32Array;
7
+ serviceRouteId: ServiceRouteId;
8
+ };
3
9
  export declare const serializeStopsAdjacency: (stopsAdjacency: StopsAdjacency) => ProtoStopsAdjacency;
4
10
  export declare const serializeRoutesAdjacency: (routesAdjacency: RoutesAdjacency) => ProtoRoutesAdjacency;
5
11
  export declare const serializeServiceRoutesMap: (serviceRoutesMap: ServiceRoutesMap) => ProtoServiceRoutesMap;
@@ -26,7 +26,7 @@ export declare function routeTypeFromJSON(object: any): RouteType;
26
26
  export declare function routeTypeToJSON(object: RouteType): string;
27
27
  export interface Route {
28
28
  /**
29
- * Arrivals and departures encoded as a 32 bit uint array.
29
+ * Arrivals and departures encoded as a 16 bit uint array.
30
30
  * Format: [arrival1, departure1, arrival2, departure2, etc.]
31
31
  */
32
32
  stopTimes: Uint8Array;
@@ -0,0 +1,155 @@
1
+ import { StopId } from '../stops/stops.js';
2
+ import { SerializedRoute } from './io.js';
3
+ import { Time } from './time.js';
4
+ import { ServiceRouteId } from './timetable.js';
5
+ /**
6
+ * An internal identifier for routes.
7
+ * Not to mix with the ServiceRouteId which corresponds to the GTFS RouteId.
8
+ * This one is used for identifying groups of trips
9
+ * from a service route sharing the same list of stops.
10
+ */
11
+ export type RouteId = string;
12
+ /**
13
+ * Details about the pickup and drop-off modalities at each stop in each trip of a route.
14
+ */
15
+ export type PickUpDropOffType = 'REGULAR' | 'NOT_AVAILABLE' | 'MUST_PHONE_AGENCY' | 'MUST_COORDINATE_WITH_DRIVER';
16
+ export declare const REGULAR = 0;
17
+ export declare const NOT_AVAILABLE = 1;
18
+ export declare const MUST_PHONE_AGENCY = 2;
19
+ export declare const MUST_COORDINATE_WITH_DRIVER = 3;
20
+ export type TripIndex = number;
21
+ /**
22
+ * A route identifies all trips of a given service route sharing the same list of stops.
23
+ */
24
+ export declare class Route {
25
+ /**
26
+ * Arrivals and departures encoded as minutes from midnight.
27
+ * Format: [arrival1, departure1, arrival2, departure2, etc.]
28
+ */
29
+ private readonly stopTimes;
30
+ /**
31
+ * PickUp and DropOff types represented as a binary Uint8Array.
32
+ * Values:
33
+ * 0: REGULAR
34
+ * 1: NOT_AVAILABLE
35
+ * 2: MUST_PHONE_AGENCY
36
+ * 3: MUST_COORDINATE_WITH_DRIVER
37
+ * Format: [pickupTypeStop1, dropOffTypeStop1, pickupTypeStop2, dropOffTypeStop2, etc.]
38
+ * TODO: Encode 4 values instead of 1 in 8 bits.
39
+ */
40
+ private readonly pickUpDropOffTypes;
41
+ /**
42
+ * A binary array of stopIds in the route.
43
+ * [stop1, stop2, stop3,...]
44
+ */
45
+ private readonly stops;
46
+ /**
47
+ * A reverse mapping of each stop with their index in the route:
48
+ * {
49
+ * 4: 0,
50
+ * 5: 1,
51
+ * ...
52
+ * }
53
+ */
54
+ private readonly stopIndices;
55
+ /**
56
+ * The identifier of the route as a service shown to users.
57
+ */
58
+ private readonly serviceRouteId;
59
+ /**
60
+ * The total number of stops in the route.
61
+ */
62
+ private readonly nbStops;
63
+ /**
64
+ * The total number of trips in the route.
65
+ */
66
+ private readonly nbTrips;
67
+ constructor(stopTimes: Uint16Array, pickUpDropOffTypes: Uint8Array, stops: Uint32Array, serviceRouteId: ServiceRouteId);
68
+ /**
69
+ * Serializes the Route into binary arrays.
70
+ *
71
+ * @returns The serialized binary data.
72
+ */
73
+ serialize(): SerializedRoute;
74
+ /**
75
+ * Checks if stop A is before stop B in the route.
76
+ *
77
+ * @param stopA - The StopId of the first stop.
78
+ * @param stopB - The StopId of the second stop.
79
+ * @returns True if stop A is before stop B, false otherwise.
80
+ */
81
+ isBefore(stopA: StopId, stopB: StopId): boolean;
82
+ /**
83
+ * Retrieves the number of stops in the route.
84
+ *
85
+ * @returns The total number of stops in the route.
86
+ */
87
+ getNbStops(): number;
88
+ /**
89
+ * Finds the ServiceRouteId of the route. It corresponds the identifier
90
+ * of the service shown to the end user as a route.
91
+ *
92
+ * @returns The ServiceRouteId of the route.
93
+ */
94
+ serviceRoute(): ServiceRouteId;
95
+ /**
96
+ * Retrieves the arrival time at a specific stop for a given trip.
97
+ *
98
+ * @param stopId - The identifier of the stop.
99
+ * @param tripIndex - The index of the trip.
100
+ * @returns The arrival time at the specified stop and trip as a Time object.
101
+ */
102
+ arrivalAt(stopId: StopId, tripIndex: TripIndex): Time;
103
+ /**
104
+ * Retrieves the departure time at a specific stop for a given trip.
105
+ *
106
+ * @param stopId - The identifier of the stop.
107
+ * @param tripIndex - The index of the trip.
108
+ * @returns The departure time at the specified stop and trip as a Time object.
109
+ */
110
+ departureFrom(stopId: StopId, tripIndex: TripIndex): Time;
111
+ /**
112
+ * Retrieves the pick-up type for a specific stop and trip.
113
+ *
114
+ * @param stopId - The identifier of the stop.
115
+ * @param tripIndex - The index of the trip.
116
+ * @returns The pick-up type at the specified stop and trip.
117
+ */
118
+ pickUpTypeFrom(stopId: StopId, tripIndex: TripIndex): PickUpDropOffType;
119
+ /**
120
+ * Retrieves the drop-off type for a specific stop and trip.
121
+ *
122
+ * @param stopId - The identifier of the stop.
123
+ * @param tripIndex - The index of the trip.
124
+ * @returns The drop-off type at the specified stop and trip.
125
+ */
126
+ dropOffTypeAt(stopId: StopId, tripIndex: TripIndex): PickUpDropOffType;
127
+ /**
128
+ * Iterates over the stops in the route, starting from an optional specified stop.
129
+ * If no start stop is provided, the iteration begins from the first stop in the route.
130
+ *
131
+ * @param [startStopId] - (Optional) The StopId of the stop to start the iteration from.
132
+ * @returns An IterableIterator of StopIds, starting from the specified stop or the first stop.
133
+ * @throws An error if the specified start stop is not found in the route.
134
+ */
135
+ stopsIterator(startStopId?: StopId): IterableIterator<StopId>;
136
+ /**
137
+ * Finds the earliest trip that can be taken from a specific stop on a given route,
138
+ * optionally constrained by a latest trip index and a time before which the trip
139
+ * should not depart.
140
+ * *
141
+ * @param stopId - The StopId of the stop where the trip should be found.
142
+ * @param [after=Time.origin()] - The earliest time after which the trip should depart.
143
+ * If not provided, searches all available trips.
144
+ * @param [beforeTrip] - (Optional) The index of the trip before which the search should be constrained.
145
+ * If not provided, searches all available trips.
146
+ * @returns The index of the earliest trip meeting the criteria, or undefined if no such trip is found.
147
+ */
148
+ findEarliestTrip(stopId: StopId, after?: Time, beforeTrip?: TripIndex): TripIndex | undefined;
149
+ /**
150
+ * Retrieves the index of a stop within the route.
151
+ * @param stopId The StopId of the stop to locate in the route.
152
+ * @returns The index of the stop in the route.
153
+ */
154
+ private stopIndex;
155
+ }
@@ -104,4 +104,25 @@ export declare class Time {
104
104
  * @returns A Time instance representing the minimum time.
105
105
  */
106
106
  static min(...times: Time[]): Time;
107
+ /**
108
+ * Determines if the current Time instance is after another Time instance.
109
+ *
110
+ * @param otherTime - A Time instance to compare against.
111
+ * @returns True if the current Time instance is after the other Time instance, otherwise false.
112
+ */
113
+ isAfter(otherTime: Time): boolean;
114
+ /**
115
+ * Determines if the current Time instance is before another Time instance.
116
+ *
117
+ * @param otherTime - A Time instance to compare against.
118
+ * @returns True if the current Time instance is before the other Time instance, otherwise false.
119
+ */
120
+ isBefore(otherTime: Time): boolean;
121
+ /**
122
+ * Determines if the current Time instance is equal to another Time instance.
123
+ *
124
+ * @param otherTime - A Time instance to compare against.
125
+ * @returns True if the current Time instance is equal to the other Time instance, otherwise false.
126
+ */
127
+ equals(otherTime: Time): boolean;
107
128
  }
@@ -1,47 +1,6 @@
1
1
  import { StopId } from '../stops/stops.js';
2
2
  import { Duration } from './duration.js';
3
- import { Time } from './time.js';
4
- export type RouteId = string;
5
- export declare const REGULAR = 0;
6
- export declare const NOT_AVAILABLE = 1;
7
- export declare const MUST_PHONE_AGENCY = 2;
8
- export declare const MUST_COORDINATE_WITH_DRIVER = 3;
9
- export type PickUpDropOffType = 0 | 1 | 2 | 3;
10
- export type Route = {
11
- /**
12
- * Arrivals and departures encoded as minutes from midnight.
13
- * Format: [arrival1, departure1, arrival2, departure2, etc.]
14
- */
15
- stopTimes: Uint16Array;
16
- /**
17
- * PickUp and DropOff types represented as a binary Uint8Array.
18
- * Values:
19
- * 0: REGULAR
20
- * 1: NOT_AVAILABLE
21
- * 2: MUST_PHONE_AGENCY
22
- * 3: MUST_COORDINATE_WITH_DRIVER
23
- * Format: [pickupTypeStop1, dropOffTypeStop1, pickupTypeStop2, dropOffTypeStop2, etc.]
24
- */
25
- pickUpDropOffTypes: Uint8Array;
26
- /**
27
- * A binary array of stopIds in the route.
28
- * [stop1, stop2, stop3,...]
29
- */
30
- stops: Uint32Array;
31
- /**
32
- * A reverse mapping of each stop with their index in the route:
33
- * {
34
- * 4: 0,
35
- * 5: 1,
36
- * ...
37
- * }
38
- */
39
- stopIndices: Map<StopId, number>;
40
- /**
41
- * The identifier of the route as a service shown to users.
42
- */
43
- serviceRouteId: ServiceRouteId;
44
- };
3
+ import { Route, RouteId } from './route.js';
45
4
  export type RoutesAdjacency = Map<RouteId, Route>;
46
5
  export type TransferType = 'RECOMMENDED' | 'GUARANTEED' | 'REQUIRES_MINIMAL_TIME' | 'IN_SEAT';
47
6
  export type Transfer = {
@@ -60,12 +19,10 @@ export type ServiceRoute = {
60
19
  name: string;
61
20
  };
62
21
  export type ServiceRoutesMap = Map<ServiceRouteId, ServiceRoute>;
63
- type TripIndex = number;
64
- export declare const ALL_TRANSPORT_MODES: RouteType[];
22
+ export declare const ALL_TRANSPORT_MODES: Set<RouteType>;
65
23
  export declare const CURRENT_VERSION = "0.0.3";
66
24
  /**
67
- * The internal transit timetable format
68
- * reuses some GTFS concepts for the sake of simplicity for now.
25
+ * The internal transit timetable format.
69
26
  */
70
27
  export declare class Timetable {
71
28
  private readonly stopsAdjacency;
@@ -73,34 +30,57 @@ export declare class Timetable {
73
30
  private readonly routes;
74
31
  constructor(stopsAdjacency: StopsAdjacency, routesAdjacency: RoutesAdjacency, routes: ServiceRoutesMap);
75
32
  /**
76
- * Serializes the Timetable into a binary protobuf.
33
+ * Serializes the Timetable into a binary array.
77
34
  *
78
- * @returns {Uint8Array} - The serialized binary data.
35
+ * @returns The serialized binary data.
79
36
  */
80
37
  serialize(): Uint8Array;
81
38
  /**
82
39
  * Deserializes a binary protobuf into a Timetable object.
83
40
  *
84
- * @param {Uint8Array} data - The binary data to deserialize.
85
- * @returns {Timetable} - The deserialized Timetable object.
41
+ * @param data - The binary data to deserialize.
42
+ * @returns The deserialized Timetable object.
86
43
  */
87
44
  static fromData(data: Uint8Array): Timetable;
88
- getRoutesThroughStop(stopId: StopId): RouteId[];
45
+ /**
46
+ * Retrieves the route associated with the given route ID.
47
+ *
48
+ * @param routeId - The ID of the route to be retrieved.
49
+ * @returns The route corresponding to the provided ID,
50
+ * or undefined if no such route exists.
51
+ */
89
52
  getRoute(routeId: RouteId): Route | undefined;
53
+ /**
54
+ * Retrieves all transfer options available at the specified stop.
55
+ *
56
+ * @param stopId - The ID of the stop to get transfers for.
57
+ * @returns An array of transfer options available at the stop.
58
+ */
90
59
  getTransfers(stopId: StopId): Transfer[];
60
+ /**
61
+ * Retrieves the service route associated with the given route.
62
+ * A service route refers to a collection of trips that are displayed
63
+ * to riders as a single service.
64
+ *
65
+ * @param route - The route for which the service route is to be retrieved.
66
+ * @returns The service route corresponding to the provided route.
67
+ */
68
+ getServiceRoute(route: Route): ServiceRoute;
69
+ /**
70
+ * Finds all routes passing through a stop.
71
+ *
72
+ * @param stopId - The ID of the stop to find routes for.
73
+ * @returns An array of routes passing through the specified stop.
74
+ */
75
+ routesPassingThrough(stopId: StopId): Route[];
91
76
  /**
92
77
  * Finds routes that are reachable from a set of stop IDs.
93
78
  * Also identifies the first stop available to hop on each route among
94
79
  * the input stops.
80
+ *
81
+ * @param fromStops - The set of stop IDs to find reachable routes from.
82
+ * @param transportModes - The set of transport modes to consider for reachable routes.
83
+ * @returns A map of reachable routes to the first stop available to hop on each route.
95
84
  */
96
- findReachableRoutes(fromStops: Set<StopId>, transportModes?: RouteType[]): Map<RouteId, StopId>;
97
- getServiceRouteFromRouteId(routeId: RouteId): ServiceRoute | undefined;
98
- getServiceRoute(serviceRouteId: ServiceRouteId): ServiceRoute | undefined;
99
- /**
100
- * Finds the earliest trip that can be taken from a specific stop on a given route,
101
- * optionally constrained by a latest trip index and a time before which the trip
102
- * should not depart.
103
- */
104
- findEarliestTrip(route: Route, stopId: StopId, beforeTrip?: TripIndex, after?: Time): TripIndex | undefined;
85
+ findReachableRoutes(fromStops: Set<StopId>, transportModes?: Set<RouteType>): Map<Route, StopId>;
105
86
  }
106
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minotor",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A lightweight client-side transit routing library.",
5
5
  "keywords": [
6
6
  "minotor",
@@ -42,12 +42,12 @@
42
42
  }
43
43
  },
44
44
  "engines": {
45
- "node": ">=21.1.0",
46
- "npm": ">=10.9.1"
45
+ "node": ">=22.18.0",
46
+ "npm": ">=11.5.2"
47
47
  },
48
48
  "volta": {
49
- "node": "21.1.0",
50
- "npm": "10.9.1"
49
+ "node": "22.18.0",
50
+ "npm": "11.5.2"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -63,53 +63,55 @@
63
63
  "lint:check": "eslint src",
64
64
  "format:check": "prettier . --check",
65
65
  "format": "prettier --write .",
66
- "test": "tsx --test src/**/*.test.ts",
66
+ "test": "tsx --test src/**/__tests__/*.test.ts",
67
+ "e2e": "tsx --test src/__e2e__/*.test.ts",
68
+ "perf": "tsx src/cli/minotor perf -s src/__e2e__/timetable/stops.bin -t src/__e2e__/timetable/timetable.bin src/__e2e__/benchmark.json",
69
+ "repl": "tsx src/cli/minotor repl -s src/__e2e__/timetable/stops.bin -t src/__e2e__/timetable/timetable.bin",
67
70
  "test:watch": "tsx --watch --test src/**/*.test.ts",
68
- "test:coverage": "c8 -x 'src/**/proto/*.ts' -x 'src/**/__tests__/*.ts' --check-coverage --lines=85 tsx --test src/**/*.test.ts",
71
+ "test:coverage": "c8 -x 'src/**/proto/*.ts' -x 'src/**/__tests__/*.ts' --check-coverage --lines=85 tsx --test src/**/__tests__/*.test.ts",
69
72
  "spell:check": "cspell \"{README.md,.github/*.md,src/**/*.ts}\" -u",
70
73
  "cz": "cz",
71
74
  "semantic-release": "semantic-release"
72
75
  },
73
76
  "devDependencies": {
74
- "@eslint/js": "^9.0.0",
75
- "@rollup/plugin-commonjs": "^28.0.1",
76
- "@rollup/plugin-node-resolve": "^15.3.0",
77
+ "@eslint/js": "^9.34.0",
78
+ "@rollup/plugin-commonjs": "^28.0.6",
79
+ "@rollup/plugin-node-resolve": "^16.0.1",
77
80
  "@rollup/plugin-terser": "^0.4.4",
78
- "@rollup/plugin-typescript": "^12.1.1",
81
+ "@rollup/plugin-typescript": "^12.1.4",
79
82
  "@ryansonshine/commitizen": "^4.2.8",
80
83
  "@ryansonshine/cz-conventional-changelog": "^3.3.4",
81
84
  "@semantic-release/changelog": "^6.0.3",
82
- "@semantic-release/commit-analyzer": "^13.0.0",
83
- "@semantic-release/github": "^11.0.1",
84
- "@semantic-release/npm": "^12.0.1",
85
- "@semantic-release/release-notes-generator": "^14.0.1",
86
- "@types/eslint__js": "^8.42.3",
85
+ "@semantic-release/commit-analyzer": "^13.0.1",
86
+ "@semantic-release/github": "^11.0.4",
87
+ "@semantic-release/npm": "^12.0.2",
88
+ "@semantic-release/release-notes-generator": "^14.0.3",
87
89
  "@types/geokdbush": "^1.1.5",
88
- "@types/luxon": "^3.4.2",
89
- "@types/node": "^22.9.0",
90
- "c8": "^10.1.2",
91
- "cspell": "^8.16.0",
92
- "eslint": "^9.15.0",
93
- "eslint-config-prettier": "^9.1.0",
90
+ "@types/luxon": "^3.7.1",
91
+ "@types/node": "^24.3.0",
92
+ "c8": "^10.1.3",
93
+ "cspell": "^9.2.0",
94
+ "eslint": "^9.34.0",
95
+ "eslint-config-prettier": "^10.1.8",
94
96
  "eslint-plugin-simple-import-sort": "^12.1.1",
95
- "prettier": "^3.3.3",
97
+ "prettier": "^3.6.2",
96
98
  "rimraf": "^6.0.1",
97
- "rollup": "^4.27.2",
98
- "semantic-release": "^24.2.0",
99
- "ts-proto": "^2.2.7",
100
- "tsx": "^4.19.2",
101
- "typescript": "^5.6.3",
102
- "typescript-eslint": "^8.14.0"
99
+ "rollup": "^4.49.0",
100
+ "semantic-release": "^24.2.7",
101
+ "ts-proto": "^2.7.7",
102
+ "tsx": "^4.20.5",
103
+ "typescript": "^5.9.2",
104
+ "typescript-eslint": "^8.41.0"
103
105
  },
104
106
  "dependencies": {
105
- "@bufbuild/protobuf": "^2.5.0",
106
- "commander": "^12.1.0",
107
- "csv-parse": "^5.5.6",
107
+ "@bufbuild/protobuf": "^2.7.0",
108
+ "commander": "^14.0.0",
109
+ "csv-parse": "^6.1.0",
108
110
  "geokdbush": "^2.0.1",
109
111
  "kdbush": "^4.0.2",
110
112
  "loglevel": "^1.9.2",
111
- "luxon": "^3.5.0",
113
+ "luxon": "^3.7.1",
112
114
  "node-stream-zip": "^1.15.0",
113
- "slimsearch": "^2.2.1"
115
+ "slimsearch": "^2.2.2"
114
116
  }
115
117
  }