minotor 3.0.1 → 4.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 (82) 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 +8 -3
  6. package/README.md +35 -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 +2130 -909
  11. package/dist/cli.mjs.map +1 -1
  12. package/dist/gtfs/trips.d.ts +7 -1
  13. package/dist/gtfs/utils.d.ts +1 -1
  14. package/dist/parser.cjs.js +1236 -755
  15. package/dist/parser.cjs.js.map +1 -1
  16. package/dist/parser.d.ts +4 -2
  17. package/dist/parser.esm.js +1236 -755
  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 +3 -2
  36. package/dist/timetable/route.d.ts +157 -0
  37. package/dist/timetable/time.d.ts +21 -0
  38. package/dist/timetable/timetable.d.ts +42 -62
  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 +25 -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 +56 -74
  52. package/src/gtfs/parser.ts +49 -9
  53. package/src/gtfs/profiles/ch.ts +1 -1
  54. package/src/gtfs/routes.ts +4 -4
  55. package/src/gtfs/services.ts +15 -2
  56. package/src/gtfs/stops.ts +7 -3
  57. package/src/gtfs/transfers.ts +6 -3
  58. package/src/gtfs/trips.ts +206 -108
  59. package/src/gtfs/utils.ts +13 -2
  60. package/src/parser.ts +4 -2
  61. package/src/router.ts +17 -11
  62. package/src/routing/__tests__/result.test.ts +392 -0
  63. package/src/routing/__tests__/router.test.ts +94 -137
  64. package/src/routing/query.ts +28 -7
  65. package/src/routing/result.ts +10 -5
  66. package/src/routing/route.ts +95 -9
  67. package/src/routing/router.ts +82 -66
  68. package/src/stops/__tests__/io.test.ts +1 -1
  69. package/src/stops/__tests__/stopFinder.test.ts +1 -1
  70. package/src/stops/proto/stops.ts +4 -4
  71. package/src/stops/stopsIndex.ts +3 -3
  72. package/src/timetable/__tests__/io.test.ts +16 -23
  73. package/src/timetable/__tests__/route.test.ts +325 -0
  74. package/src/timetable/__tests__/time.test.ts +494 -0
  75. package/src/timetable/__tests__/timetable.test.ts +60 -75
  76. package/src/timetable/io.ts +32 -26
  77. package/src/timetable/proto/timetable.proto +3 -2
  78. package/src/timetable/proto/timetable.ts +15 -14
  79. package/src/timetable/route.ts +361 -0
  80. package/src/timetable/time.ts +40 -8
  81. package/src/timetable/timetable.ts +75 -166
  82. package/tsconfig.build.json +1 -1
package/.cspell.json CHANGED
@@ -30,7 +30,18 @@
30
30
  "Klosters",
31
31
  "Engadin",
32
32
  "isochrone",
33
- "Delling"
33
+ "Delling",
34
+ "Moléson",
35
+ "Bulle",
36
+ "Gruyères",
37
+ "gare",
38
+ "funi",
39
+ "Francey",
40
+ "téléphérique",
41
+ "Moritz",
42
+ "Haut",
43
+ "Rhin",
44
+ "Olten"
34
45
  ],
35
46
  "flagWords": [],
36
47
  "ignorePaths": [
package/.gitattributes ADDED
@@ -0,0 +1,3 @@
1
+ src/__e2e__/timetable/stops.bin filter=lfs diff=lfs merge=lfs -text
2
+ src/__e2e__/timetable/timetable.bin filter=lfs diff=lfs merge=lfs -text
3
+ src/__e2e__/timetable/*.bin filter=lfs diff=lfs merge=lfs -text
@@ -2,3 +2,6 @@ Fixes # (issue)
2
2
 
3
3
  Please provide a concise description of your changes, and the motivation for making them.
4
4
  If relevant, include links to related issues or pull requests.
5
+
6
+ - [ ] If the timetable or stops format changed, I re-generated `src/__e2e__/timetable/stops.bin` and `src/__e2e__/timetable/timetable.bin` based on the latest Swiss GTFS for the next Monday (and adjusted e2e tests results accordingly if needed).
7
+ - [ ] I ran the performance tests and confirmed that no regression was introduced.
@@ -67,9 +67,25 @@ jobs:
67
67
  - name: ⚡ Tests
68
68
  run: npm run test:coverage
69
69
 
70
+ e2e:
71
+ name: 🏁 End-to-end tests
72
+ runs-on: ubuntu-latest
73
+ steps:
74
+ - uses: actions/checkout@v3
75
+ with:
76
+ lfs: true
77
+ - name: Checkout LFS objects
78
+ run: git lfs pull
79
+ - uses: actions/setup-node@v3
80
+ with:
81
+ node-version: '21.1.0'
82
+ - uses: bahmutov/npm-install@v1
83
+ - name: 🏁 End-to-end tests
84
+ run: npm run e2e
85
+
70
86
  build-and-release:
71
87
  name: 🚀 Build & release
72
- needs: [format, lint, audit, spell, type, test]
88
+ needs: [format, lint, audit, spell, type, test, e2e]
73
89
  runs-on: ubuntu-latest
74
90
  steps:
75
91
  - uses: actions/checkout@v3
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
- ## [3.0.1](https://github.com/aubryio/minotor/compare/v3.0.0...v3.0.1) (2025-06-03)
1
+ # [4.0.0](https://github.com/aubryio/minotor/compare/v3.0.2...v4.0.0) (2025-09-13)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Performance Improvements
5
5
 
6
- * do not pin point lib version for the repl ([#18](https://github.com/aubryio/minotor/issues/18)) ([2cef9e7](https://github.com/aubryio/minotor/commit/2cef9e7488f09743aba52e2ebb0ae52bead476c6))
6
+ * encode boarding flags on 2 bits only ([b373d0c](https://github.com/aubryio/minotor/commit/b373d0c606ca6ead53e9138d5ca31d2928e2415b))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * Timetable format 0.0.4 introduced to use 2 bits instead of 8 for boarding flags.
package/README.md CHANGED
@@ -61,8 +61,9 @@ const parser = new GtfsParser('gtfs-feed.zip', chGtfsProfile);
61
61
  const { timetable, stopsIndex } = await parser.parse(new Date());
62
62
  ```
63
63
 
64
- Note that this operation can take a few minutes for large GTFS feeds.
65
- See comments in the code for more options.
64
+ Note that times are only represented at the minute level so they can fit on 16 bits.
65
+
66
+ This operation can take a few minutes for large GTFS feeds.
66
67
 
67
68
  #### Stop Search (Browser or Node.js)
68
69
 
@@ -127,11 +128,21 @@ Query routes (`minotor> .route -h for more options`):
127
128
 
128
129
  ## Development
129
130
 
131
+ ### Requirements
132
+
133
+ Make sure you have a working [node](https://nodejs.org) environment.
134
+
135
+ `protoc` also needs to be available on the build system.
136
+
137
+ Ubuntu: `sudo apt install -y protobuf-compiler` |
138
+ Fedora: `sudo dnf install -y protobuf-compiler` |
139
+ MacOS: `brew install protobuf`
140
+
130
141
  ### Debugging
131
142
 
132
143
  It is possible to plot the router graph to debug the algorithm:
133
144
 
134
- `minotor repl`
145
+ Using the npm script `repl`, or `minotor repl` if the project is installed globally.
135
146
 
136
147
  `minotor> .plot from <stationId> to <stationId> at <HH:mm> [with <N> transfers] [to <graph.dot>]`
137
148
 
@@ -139,15 +150,20 @@ It is possible to plot the router graph to debug the algorithm:
139
150
 
140
151
  ### Build
141
152
 
142
- Make sure you have a working node setup as well as a protobuf compiler.
143
-
144
153
  - `build`: builds the project in the `dist/` directory
145
154
  - `clean`: removes the `dist/` directory
146
155
 
147
- ### Tests
156
+ ### Unit Tests
157
+
158
+ - `test`: runs unit tests
159
+ - `test:coverage`: runs unit test runner with coverage reports
160
+
161
+ ### End-to-End Tests
148
162
 
149
- - `test`: runs test runner
150
- - `test:coverage`: runs test runner with coverage reports
163
+ - `e2e`: runs end-to-end tests, using a real data from a day in the Swiss GTFS dataset
164
+ - `perf`: runs a basic performance test, using a real data from a day in the Swiss GTFS dataset
165
+
166
+ Note that performance tests are not included in the CI pipeline and must be run manually.
151
167
 
152
168
  ### Formatting & linting
153
169
 
@@ -163,15 +179,20 @@ Releases are automatically published to npm when merging to the `main` or `beta`
163
179
 
164
180
  ## Roadmap
165
181
 
166
- The project is under active development. Here are some of the features that are planned:
182
+ The project is under active development. Here are some of the features that are planned (ordered by priority).
183
+ Contact [the author](https://aubry.io/) for feature requests.
167
184
 
168
- - Load multiple GTFS archives at once
185
+ - Route/Trip-based transfer support
186
+ - Favor shorter trips with less transfers in case of tie
187
+ - Arrive-by support
169
188
  - Range queries
170
189
  - Transfer preferences
190
+ - Route/Trip metadata support
191
+ - Routing filters based on metadata e.g. bicycle support, wheelchair access
192
+ - More routing options (slower/faster transfers, etc.)
193
+ - Improved stop search (sort by stop importance)
194
+ - Real-time timetable support (tripId/routeId mapping)
171
195
  - Support for exporting a calendar range as opposed to a single day
172
196
  - Support for GTFS `frequencies.txt`
173
- - Support for more types of transfers
197
+ - Load multiple GTFS archives at once
174
198
  - NeTEx support
175
- - Higher level timetable API for cleaner router code
176
- - RT-GTFS Support (adding tripId support)
177
- - More extensive testing
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import { Query, Router, StopsIndex } from '../router.js';
2
+ type PerformanceResult = {
3
+ task: Query;
4
+ meanTimeMs: number;
5
+ meanMemoryMb: number;
6
+ };
7
+ /**
8
+ *
9
+ * @param filePath
10
+ * @returns
11
+ */
12
+ export declare const loadQueriesFromJson: (filePath: string) => Query[];
13
+ /**
14
+ *
15
+ * @param router
16
+ * @param stopsIndex
17
+ * @param tasks
18
+ * @param iterations
19
+ * @returns
20
+ */
21
+ export declare const testRouterPerformance: (router: Router, stopsIndex: StopsIndex, tasks: Query[], iterations: number) => PerformanceResult[];
22
+ /**
23
+ *
24
+ * @param results
25
+ * @returns
26
+ */
27
+ export declare const prettyPrintPerformanceResults: (results: PerformanceResult[]) => void;
28
+ export {};
@@ -1,3 +1,7 @@
1
- import { Result, Route } from '../router.js';
2
- export declare const prettyPrintRoute: (route: Route) => void;
1
+ import { Result } from '../router.js';
2
+ /**
3
+ * Plots the graph of the result to a dot file.
4
+ * @param result - The result object to plot.
5
+ * @param filePath - The path where the dot file will be saved.
6
+ */
3
7
  export declare const plotGraphToDotFile: (result: Result, filePath: string) => void;