minotor 5.0.1 → 6.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +8 -3
  2. package/dist/cli.mjs +207 -596
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/gtfs/parser.d.ts +4 -10
  5. package/dist/gtfs/routes.d.ts +16 -2
  6. package/dist/gtfs/stops.d.ts +3 -13
  7. package/dist/gtfs/transfers.d.ts +2 -2
  8. package/dist/gtfs/trips.d.ts +12 -8
  9. package/dist/parser.cjs.js +201 -593
  10. package/dist/parser.cjs.js.map +1 -1
  11. package/dist/parser.esm.js +201 -593
  12. package/dist/parser.esm.js.map +1 -1
  13. package/dist/router.cjs.js +1 -1
  14. package/dist/router.cjs.js.map +1 -1
  15. package/dist/router.esm.js +1 -1
  16. package/dist/router.esm.js.map +1 -1
  17. package/dist/router.umd.js +1 -1
  18. package/dist/router.umd.js.map +1 -1
  19. package/dist/stops/io.d.ts +3 -3
  20. package/dist/stops/proto/stops.d.ts +1 -8
  21. package/dist/stops/stops.d.ts +0 -4
  22. package/dist/stops/stopsIndex.d.ts +3 -3
  23. package/dist/timetable/io.d.ts +6 -6
  24. package/dist/timetable/proto/timetable.d.ts +5 -27
  25. package/dist/timetable/timetable.d.ts +17 -9
  26. package/package.json +1 -1
  27. package/src/__e2e__/timetable/stops.bin +2 -2
  28. package/src/__e2e__/timetable/timetable.bin +2 -2
  29. package/src/cli/minotor.ts +3 -4
  30. package/src/gtfs/__tests__/parser.test.ts +5 -6
  31. package/src/gtfs/__tests__/routes.test.ts +0 -3
  32. package/src/gtfs/__tests__/stops.test.ts +1 -124
  33. package/src/gtfs/__tests__/transfers.test.ts +7 -7
  34. package/src/gtfs/__tests__/trips.test.ts +74 -45
  35. package/src/gtfs/parser.ts +32 -49
  36. package/src/gtfs/routes.ts +43 -5
  37. package/src/gtfs/stops.ts +2 -44
  38. package/src/gtfs/transfers.ts +2 -2
  39. package/src/gtfs/trips.ts +57 -40
  40. package/src/routing/__tests__/result.test.ts +48 -48
  41. package/src/routing/__tests__/router.test.ts +279 -363
  42. package/src/routing/router.ts +3 -1
  43. package/src/stops/__tests__/io.test.ts +25 -31
  44. package/src/stops/__tests__/stopFinder.test.ts +82 -103
  45. package/src/stops/io.ts +8 -17
  46. package/src/stops/proto/stops.proto +3 -3
  47. package/src/stops/proto/stops.ts +16 -120
  48. package/src/stops/stops.ts +0 -4
  49. package/src/stops/stopsIndex.ts +20 -26
  50. package/src/timetable/__tests__/io.test.ts +44 -54
  51. package/src/timetable/__tests__/route.test.ts +11 -11
  52. package/src/timetable/__tests__/timetable.test.ts +29 -37
  53. package/src/timetable/io.ts +38 -66
  54. package/src/timetable/proto/timetable.proto +6 -13
  55. package/src/timetable/proto/timetable.ts +43 -385
  56. package/src/timetable/timetable.ts +43 -28
@@ -12,20 +12,14 @@ export declare class GtfsParser {
12
12
  * Parses a GTFS feed to extract all the data relevant to a given day in a transit-planner friendly format.
13
13
  *
14
14
  * @param date The active date.
15
- * @param gtfsPath A path to the zipped GTFS feed.
16
- * @param gtfsProfile The GTFS profile configuration.
17
- * @returns An object containing the timetable and stops map.
15
+ * @returns The parsed timetable.
18
16
  */
19
- parse(date: Date): Promise<{
20
- timetable: Timetable;
21
- stopsIndex: StopsIndex;
22
- }>;
17
+ parseTimetable(date: Date): Promise<Timetable>;
23
18
  /**
24
19
  * Parses a GTFS feed to extract all stops.
25
20
  *
26
- * @param gtfsPath A path the zipped GTFS feed.
27
- * @param gtfsProfile The GTFS profile configuration.
28
- * @returns An object containing the timetable and stops map.
21
+ * @param activeStops The set of active stop IDs to include in the index.
22
+ * @returns An index of stops.
29
23
  */
30
24
  parseStops(): Promise<StopsIndex>;
31
25
  }
@@ -1,6 +1,12 @@
1
- import { ServiceRoutesMap } from '../timetable/timetable.js';
1
+ import { RouteType } from '../router.js';
2
+ import { ServiceRoute, ServiceRouteId } from '../timetable/timetable.js';
2
3
  import { GtfsProfile } from './parser.js';
3
4
  export type GtfsRouteType = number;
5
+ export type GtfsRouteId = string;
6
+ export type GtfsRoutesMap = Map<GtfsRouteId, {
7
+ name: string;
8
+ type: RouteType;
9
+ }>;
4
10
  /**
5
11
  * Parses a GTFS routes.txt file and returns a map of all the valid routes.
6
12
  *
@@ -8,4 +14,12 @@ export type GtfsRouteType = number;
8
14
  * @param profile A configuration object defining the specificities of the GTFS feed.
9
15
  * @returns A map of all the valid routes.
10
16
  */
11
- export declare const parseRoutes: (routesStream: NodeJS.ReadableStream, profile?: GtfsProfile) => Promise<ServiceRoutesMap>;
17
+ export declare const parseRoutes: (routesStream: NodeJS.ReadableStream, profile?: GtfsProfile) => Promise<GtfsRoutesMap>;
18
+ /**
19
+ * Creates an array of ServiceRoute objects by combining GTFS route data with service route mappings.
20
+ *
21
+ * @param gtfsRoutesMap A map containing GTFS route information indexed by route ID
22
+ * @param serviceRoutesMap A map linking GTFS route IDs to service route IDs
23
+ * @returns An array of ServiceRoute objects with route information
24
+ */
25
+ export declare const indexRoutes: (gtfsRoutesMap: GtfsRoutesMap, serviceRoutesMap: Map<GtfsRouteId, ServiceRouteId>) => ServiceRoute[];
@@ -1,4 +1,4 @@
1
- import { Latitude, Longitude, Platform, SourceStopId, Stop, StopId, StopsMap } from '../stops/stops.js';
1
+ import { Latitude, Longitude, Platform, SourceStopId, Stop } from '../stops/stops.js';
2
2
  export type GtfsLocationType = 0 | 1 | 2 | 3 | 4;
3
3
  export type StopEntry = {
4
4
  stop_id: SourceStopId;
@@ -12,22 +12,12 @@ export type StopEntry = {
12
12
  type ParsedStop = Stop & {
13
13
  parentSourceId?: SourceStopId;
14
14
  };
15
- export type ParsedStopsMap = Map<SourceStopId, ParsedStop>;
15
+ export type GtfsStopsMap = Map<SourceStopId, ParsedStop>;
16
16
  /**
17
17
  * Parses the stops.txt file from a GTFS feed.
18
18
  *
19
19
  * @param stopsStream The readable stream containing the stops data.
20
20
  * @return A mapping of stop IDs to corresponding stop details.
21
21
  */
22
- export declare const parseStops: (stopsStream: NodeJS.ReadableStream) => Promise<ParsedStopsMap>;
23
- /**
24
- * Builds the final stop map indexed by internal IDs.
25
- * Excludes all stops that do not have at least one valid stopId
26
- * as a child, a parent, or being valid itself.
27
- *
28
- * @param parsedStops - The map of parsed stops.
29
- * @param validStops - A set of valid stop IDs.
30
- * @returns A map of stops indexed by internal IDs.
31
- */
32
- export declare const indexStops: (parsedStops: ParsedStopsMap, validStops?: Set<StopId>) => StopsMap;
22
+ export declare const parseStops: (stopsStream: NodeJS.ReadableStream) => Promise<GtfsStopsMap>;
33
23
  export {};
@@ -1,6 +1,6 @@
1
1
  import { SourceStopId, StopId } from '../stops/stops.js';
2
2
  import { ServiceRouteId, Transfer } from '../timetable/timetable.js';
3
- import { ParsedStopsMap } from './stops.js';
3
+ import { GtfsStopsMap } from './stops.js';
4
4
  import { TripId } from './trips.js';
5
5
  export type GtfsTransferType = 0 | 1 | 2 | 3 | 4 | 5;
6
6
  export type TransfersMap = Map<StopId, Transfer[]>;
@@ -20,4 +20,4 @@ export type TransferEntry = {
20
20
  * @param stopsStream The readable stream containing the stops data.
21
21
  * @return A mapping of stop IDs to corresponding stop details.
22
22
  */
23
- export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: ParsedStopsMap) => Promise<TransfersMap>;
23
+ export declare const parseTransfers: (transfersStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap) => Promise<TransfersMap>;
@@ -1,11 +1,12 @@
1
1
  import { StopId } from '../stops/stops.js';
2
2
  import { Route } from '../timetable/route.js';
3
- import { ServiceRouteId, ServiceRoutesMap, StopsAdjacency } from '../timetable/timetable.js';
3
+ import { ServiceRoute, ServiceRouteId, StopAdjacency } from '../timetable/timetable.js';
4
+ import { GtfsRouteId, GtfsRoutesMap } from './routes.js';
4
5
  import { ServiceIds } from './services.js';
5
- import { ParsedStopsMap } from './stops.js';
6
+ import { GtfsStopsMap } from './stops.js';
6
7
  import { TransfersMap } from './transfers.js';
7
8
  export type TripId = string;
8
- export type TripIdsMap = Map<TripId, ServiceRouteId>;
9
+ export type TripIdsMap = Map<TripId, GtfsRouteId>;
9
10
  export type GtfsPickupDropOffType = '' | '0' | '1' | '2' | '3';
10
11
  export type SerializedPickUpDropOffType = 0 | 1 | 2 | 3;
11
12
  /**
@@ -21,15 +22,18 @@ export declare const encodePickUpDropOffTypes: (pickUpTypes: SerializedPickUpDro
21
22
  * @param serviceRoutes A mapping of route IDs to route details.
22
23
  * @returns A mapping of trip IDs to corresponding route IDs.
23
24
  */
24
- export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, serviceRoutes: ServiceRoutesMap) => Promise<TripIdsMap>;
25
- export declare const buildStopsAdjacencyStructure: (validStops: Set<StopId>, serviceRoutes: ServiceRoutesMap, routes: Route[], transfersMap: TransfersMap) => StopsAdjacency;
25
+ export declare const parseTrips: (tripsStream: NodeJS.ReadableStream, serviceIds: ServiceIds, validGtfsRoutes: GtfsRoutesMap) => Promise<TripIdsMap>;
26
+ export declare const buildStopsAdjacencyStructure: (serviceRoutes: ServiceRoute[], routes: Route[], transfersMap: TransfersMap, nbStops: number, activeStops: Set<StopId>) => StopAdjacency[];
26
27
  /**
27
28
  * Parses the stop_times.txt data from a GTFS feed.
28
29
  *
29
30
  * @param stopTimesStream The readable stream containing the stop times data.
30
31
  * @param stopsMap A map of parsed stops from the GTFS feed.
31
- * @param validTripIds A map of valid trip IDs to corresponding route IDs.
32
- * @param validStopIds A set of valid stop IDs.
32
+ * @param activeTripIds A map of valid trip IDs to corresponding route IDs.
33
+ * @param activeStopIds A set of valid stop IDs.
33
34
  * @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.
34
35
  */
35
- export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, stopsMap: ParsedStopsMap, validTripIds: TripIdsMap, validStopIds: Set<StopId>) => Promise<Route[]>;
36
+ export declare const parseStopTimes: (stopTimesStream: NodeJS.ReadableStream, stopsMap: GtfsStopsMap, activeTripIds: TripIdsMap, activeStopIds: Set<StopId>) => Promise<{
37
+ routes: Route[];
38
+ serviceRoutesMap: Map<GtfsRouteId, ServiceRouteId>;
39
+ }>;