gtfs 3.8.0 → 4.0.1

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 (90) hide show
  1. package/@types/index.d.ts +130 -137
  2. package/@types/tests.ts +18 -13
  3. package/CHANGELOG.md +18 -0
  4. package/README.md +233 -212
  5. package/config-sample-rtupdates.json +6 -18
  6. package/lib/advancedQuery.js +8 -17
  7. package/lib/db.js +35 -59
  8. package/lib/export.js +16 -10
  9. package/lib/gtfs/agencies.js +8 -6
  10. package/lib/gtfs/areas.js +8 -11
  11. package/lib/gtfs/attributions.js +8 -6
  12. package/lib/gtfs/calendar-dates.js +8 -6
  13. package/lib/gtfs/calendars.js +8 -6
  14. package/lib/gtfs/fare-attributes.js +8 -6
  15. package/lib/gtfs/fare-leg-rules.js +8 -6
  16. package/lib/gtfs/fare-products.js +8 -6
  17. package/lib/gtfs/fare-rules.js +8 -6
  18. package/lib/gtfs/fare-transfer-rules.js +8 -6
  19. package/lib/gtfs/feed-info.js +8 -6
  20. package/lib/gtfs/frequencies.js +8 -6
  21. package/lib/gtfs/levels.js +8 -11
  22. package/lib/gtfs/pathways.js +8 -6
  23. package/lib/gtfs/routes.js +8 -11
  24. package/lib/gtfs/shapes.js +34 -39
  25. package/lib/gtfs/stop-areas.js +8 -6
  26. package/lib/gtfs/stop-times.js +8 -6
  27. package/lib/gtfs/stops.js +27 -33
  28. package/lib/gtfs/transfers.js +8 -6
  29. package/lib/gtfs/translations.js +8 -6
  30. package/lib/gtfs/trips.js +8 -11
  31. package/lib/gtfs-realtime/service-alerts.js +9 -7
  32. package/lib/gtfs-realtime/stop-times-updates.js +9 -7
  33. package/lib/gtfs-realtime/trip-updates.js +9 -7
  34. package/lib/gtfs-realtime/vehicle-positions.js +9 -7
  35. package/lib/gtfs-ride/board-alights.js +8 -6
  36. package/lib/gtfs-ride/ride-feed-infos.js +8 -6
  37. package/lib/gtfs-ride/rider-trips.js +8 -6
  38. package/lib/gtfs-ride/riderships.js +8 -6
  39. package/lib/gtfs-ride/trip-capacities.js +8 -6
  40. package/lib/gtfs.js +3 -9
  41. package/lib/import.js +213 -273
  42. package/lib/non-standard/directions.js +8 -6
  43. package/lib/non-standard/stop-attributes.js +8 -6
  44. package/lib/non-standard/timetable-notes-references.js +8 -6
  45. package/lib/non-standard/timetable-notes.js +8 -6
  46. package/lib/non-standard/timetable-pages.js +8 -6
  47. package/lib/non-standard/timetable-stop-order.js +8 -6
  48. package/lib/non-standard/timetables.js +8 -6
  49. package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
  50. package/package.json +4 -4
  51. package/test/mocha/advanced-query.js +9 -15
  52. package/test/mocha/export-gtfs.js +5 -6
  53. package/test/mocha/fare-transfer-rules.js +32 -0
  54. package/test/mocha/get-agencies.js +13 -19
  55. package/test/mocha/get-areas.js +27 -0
  56. package/test/mocha/get-attributions.js +7 -13
  57. package/test/mocha/get-board-alights.js +7 -13
  58. package/test/mocha/get-calendar-dates.js +11 -17
  59. package/test/mocha/get-calendars.js +11 -17
  60. package/test/mocha/get-directions.js +7 -13
  61. package/test/mocha/get-fare-attributes.js +9 -15
  62. package/test/mocha/get-fare-leg-rules.js +27 -0
  63. package/test/mocha/get-fare-products.js +27 -0
  64. package/test/mocha/get-fare-rules.js +9 -15
  65. package/test/mocha/get-feed-info.js +7 -13
  66. package/test/mocha/get-frequencies.js +7 -13
  67. package/test/mocha/get-levels.js +7 -7
  68. package/test/mocha/get-pathways.js +7 -13
  69. package/test/mocha/get-ride-feed-infos.js +7 -13
  70. package/test/mocha/get-rider-trips.js +7 -13
  71. package/test/mocha/get-riderships.js +7 -13
  72. package/test/mocha/get-routes.js +13 -13
  73. package/test/mocha/get-shapes-as-geojson.js +14 -15
  74. package/test/mocha/get-shapes.js +25 -25
  75. package/test/mocha/get-stop-attributes.js +7 -13
  76. package/test/mocha/get-stops-as-geojson.js +13 -19
  77. package/test/mocha/get-stops.js +19 -19
  78. package/test/mocha/get-stoptimes.js +11 -17
  79. package/test/mocha/get-timetable-pages.js +7 -13
  80. package/test/mocha/get-timetable-stop-orders.js +6 -7
  81. package/test/mocha/get-timetables.js +7 -13
  82. package/test/mocha/get-transfers.js +7 -13
  83. package/test/mocha/get-translations.js +7 -13
  84. package/test/mocha/get-trip-capacities.js +7 -13
  85. package/test/mocha/get-trips.js +9 -9
  86. package/test/mocha/import-gtfs.js +11 -11
  87. package/test/mocha/{get-db.js → open-db.js} +37 -29
  88. package/test/mocha/raw-query.js +34 -0
  89. package/test/mocha/exec-raw-query.js +0 -39
  90. package/test/mocha/run-raw-query.js +0 -54
package/@types/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import CsvParse = require('csv-parse');
2
- import * as Sqlite3 from 'sqlite';
3
- import { FeatureCollection, Geometry } from '@turf/helpers';
4
2
 
5
- export {}; // disable implicit exporting of types
3
+ import Database = require('better-sqlite3');
6
4
 
7
- type Unpromise<T> = T extends Promise<infer U> ? U : T;
5
+ import { FeatureCollection, Geometry } from '@turf/helpers';
8
6
 
9
- export type SqlDatabase = Unpromise<ReturnType<typeof Sqlite3.open>>;
7
+ export {}; // disable implicit exporting of types
10
8
 
11
9
  export type SqlValue =
12
10
  | undefined
@@ -23,7 +21,7 @@ export type SqlSelect = string[];
23
21
 
24
22
  export type SqlOrderBy = Array<[string, 'ASC' | 'DESC']>;
25
23
 
26
- export type JoinTables = Array<JoinOptions>;
24
+ export type JoinTables = JoinOptions[];
27
25
 
28
26
  export type SqlResults = Array<Record<string, any>>;
29
27
 
@@ -33,25 +31,26 @@ export type SqlTableName = string;
33
31
 
34
32
  export type Config = ExportConfig & ImportConfig;
35
33
 
36
- export type AdvancedQueryOptions = {
34
+ export interface AdvancedQueryOptions {
37
35
  /**
38
- * An advanced query
36
+ * Queries the database with support for table joins and custom tables and returns an array of data.
39
37
  */
40
38
  query?: SqlWhere;
41
39
  fields?: SqlSelect;
42
40
  orderBy?: SqlOrderBy;
43
- join?: Array<JoinOptions>;
41
+ join?: JoinOptions[];
44
42
  options?: QueryOptions;
45
- };
43
+ }
46
44
 
47
- export type JoinOptions = {
45
+ export interface JoinOptions {
48
46
  /**
49
47
  * Options for joining, type
50
48
  */
51
49
  type?: 'LEFT OUTER' | 'INNER';
52
50
  table: string;
53
51
  on: string;
54
- };
52
+ }
53
+
55
54
  interface VerboseConfig {
56
55
  /**
57
56
  * Whether or not to print output to the console. Defaults to true.
@@ -61,7 +60,7 @@ interface VerboseConfig {
61
60
 
62
61
  export interface DbConfig {
63
62
  /**
64
- * A path to an SQLite database. Defaults to using an in-memory database.
63
+ * A path to a SQLite database. Defaults to using an in-memory database.
65
64
  */
66
65
  sqlitePath?: string;
67
66
  }
@@ -75,7 +74,7 @@ export interface ExportConfig extends DbConfig, VerboseConfig {
75
74
 
76
75
  export interface ImportConfig extends DbConfig, VerboseConfig {
77
76
  /**
78
- * An array of GTFS files to be imported.
77
+ * An array of agencies with GTFS files to be imported.
79
78
  */
80
79
  agencies: Array<{
81
80
  /**
@@ -118,11 +117,11 @@ export interface ImportConfig extends DbConfig, VerboseConfig {
118
117
  }
119
118
 
120
119
  export interface QueryOptions {
121
- db?: SqlDatabase;
120
+ db?: Database.Database;
122
121
  }
123
122
 
124
123
  /**
125
- * Use exportGtfs() in your code to run an export of a GTFS file specified in a config.json file.
124
+ * Use exportGtfs() in your code to run an export of a GTFS from SQLite specified in a config.json file.
126
125
  */
127
126
  export function exportGtfs(config: ExportConfig): Promise<void>;
128
127
 
@@ -137,62 +136,67 @@ export function importGtfs(config: ImportConfig): Promise<void>;
137
136
  export function updateGtfsRealtime(config: ImportConfig): Promise<void>;
138
137
 
139
138
  /**
140
- * Open database before making any queries.
139
+ * Opens the database specified in the config object.
141
140
  */
142
- export function openDb(config: DbConfig): Promise<SqlDatabase>;
141
+ export function openDb(config: DbConfig): Database.Database;
143
142
 
144
143
  /**
145
- * Closes open database.
144
+ * Closes the specified database.
146
145
  */
147
- export function closeDb(db?: SqlDatabase): Promise<void>;
146
+ export function closeDb(db?: Database.Database): void;
148
147
 
149
148
  /**
150
- * Get open database. Throws error if no database is open.
149
+ * Returns an array of agencies that match query parameters.
151
150
  */
152
- export function getDb(config?: DbConfig): Promise<SqlDatabase>;
151
+ export function getAgencies(
152
+ query?: SqlWhere,
153
+ fields?: SqlSelect,
154
+ sortBy?: SqlOrderBy,
155
+ options?: QueryOptions
156
+ ): SqlResults;
153
157
 
154
158
  /**
155
- * Queries agencies and returns a promise for an array of agencies.
159
+ * Returns an array of areas that match query parameters.
156
160
  */
157
- export function getAgencies(
161
+ export function getAreas(
158
162
  query?: SqlWhere,
159
163
  fields?: SqlSelect,
160
164
  sortBy?: SqlOrderBy,
161
165
  options?: QueryOptions
162
- ): Promise<SqlResults>;
166
+ ): SqlResults;
163
167
 
164
168
  /**
165
- * Queries attributions and returns a promise for an array of attributions.
169
+ * Returns an array of attributions that match query parameters.
166
170
  */
167
171
  export function getAttributions(
168
172
  query?: SqlWhere,
169
173
  fields?: SqlSelect,
170
174
  sortBy?: SqlOrderBy,
171
175
  options?: QueryOptions
172
- ): Promise<SqlResults>;
176
+ ): SqlResults;
173
177
 
174
178
  /**
175
- * Queries routes and returns a promise for an array of routes.
179
+ * Returns an array of routes that match query parameters.
176
180
  */
177
181
  export function getRoutes(
178
182
  query?: SqlWhere,
179
183
  fields?: SqlSelect,
180
184
  sortBy?: SqlOrderBy,
181
185
  options?: QueryOptions
182
- ): Promise<SqlResults>;
186
+ ): SqlResults;
183
187
 
184
188
  /**
185
- * Queries stops and returns a promise for an array of stops.
189
+ * Returns an array of stops that match query parameters.
186
190
  */
187
191
  export function getStops(
188
192
  query?: SqlWhere,
189
193
  fields?: SqlSelect,
190
194
  sortBy?: SqlOrderBy,
191
195
  options?: QueryOptions
192
- ): Promise<SqlResults>;
196
+ ): SqlResults;
193
197
 
194
198
  /**
195
- * Queries stops and returns a promise for an geoJSON object of stops.
199
+ * Returns geoJSON object of stops that match query parameters.
196
200
  * All valid queries for `getStops()` work for `getStopsAsGeoJSON()`.
197
201
  */
198
202
  export function getStopsAsGeoJSON(
@@ -201,310 +205,315 @@ export function getStopsAsGeoJSON(
201
205
  ): Promise<FeatureCollection<Geometry, { [name: string]: any }>>;
202
206
 
203
207
  /**
204
- * Queries `stop_times` and returns a promise for an array of stop_times.
208
+ * Returns an array of stop_times that match query parameters.
205
209
  */
206
210
  export function getStoptimes(
207
211
  query?: SqlWhere,
208
212
  fields?: SqlSelect,
209
213
  sortBy?: SqlOrderBy,
210
214
  options?: QueryOptions
211
- ): Promise<SqlResults>;
215
+ ): SqlResults;
212
216
 
213
217
  /**
214
- * Queries trips and returns a promise for an array of trips.
218
+ * Returns an array of trips that match query parameters.
215
219
  */
216
220
  export function getTrips(
217
221
  query?: SqlWhere,
218
222
  fields?: SqlSelect,
219
223
  sortBy?: SqlOrderBy,
220
224
  options?: QueryOptions
221
- ): Promise<SqlResults>;
225
+ ): SqlResults;
222
226
 
223
227
  /**
224
- * Queries shapes and returns a promise for an array of shapes.
228
+ * Returns an array of shapes that match query parameters.
225
229
  */
226
230
  export function getShapes(
227
231
  query?: SqlWhere,
228
232
  fields?: SqlSelect,
229
233
  sortBy?: SqlOrderBy,
230
234
  options?: QueryOptions
231
- ): Promise<SqlResults>;
235
+ ): SqlResults;
232
236
 
233
237
  /**
234
- * Queries shapes and returns a promise for an geoJSON object of shapes.
238
+ * Returns a geoJSON object of shapes that match query parameters.
235
239
  * All valid queries for `getShapes()` work for `getShapesAsGeoJSON()`.
236
240
  */
237
241
  export function getShapesAsGeoJSON(
238
242
  query?: SqlWhere,
239
243
  options?: QueryOptions
240
- ): Promise<FeatureCollection<Geometry, { [name: string]: any }>>;
244
+ ): FeatureCollection<Geometry, { [name: string]: any }>;
241
245
 
242
246
  /**
243
- * Queries calendars and returns a promise for an array of calendars.
247
+ * Returns an array of calendars that match query parameters.
244
248
  */
245
249
  export function getCalendars(
246
250
  query?: SqlWhere,
247
251
  fields?: SqlSelect,
248
252
  sortBy?: SqlOrderBy,
249
253
  options?: QueryOptions
250
- ): Promise<SqlResults>;
254
+ ): SqlResults;
251
255
 
252
256
  /**
253
- * Queries calendar_dates and returns a promise for an array of calendar_dates.
257
+ * Returns an array of calendar_dates that match query parameters.
254
258
  */
255
259
  export function getCalendarDates(
256
260
  query?: SqlWhere,
257
261
  fields?: SqlSelect,
258
262
  sortBy?: SqlOrderBy,
259
263
  options?: QueryOptions
260
- ): Promise<SqlResults>;
264
+ ): SqlResults;
261
265
 
262
266
  /**
263
- * Queries fare_attributes and returns a promise for an array of fare_attributes.
267
+ * Returns an array of fare_attributes that match query parameters.
264
268
  */
265
269
  export function getFareAttributes(
266
270
  query?: SqlWhere,
267
271
  fields?: SqlSelect,
268
272
  sortBy?: SqlOrderBy,
269
273
  options?: QueryOptions
270
- ): Promise<SqlResults>;
274
+ ): SqlResults;
271
275
 
272
276
  /**
273
- * Queries fare_rules and returns a promise for an array of fare_rules.
277
+ * Returns an array of fare_leg_rules that match query parameters.
274
278
  */
275
- export function getFareRules(
279
+ export function getFareLegRules(
276
280
  query?: SqlWhere,
277
281
  fields?: SqlSelect,
278
282
  sortBy?: SqlOrderBy,
279
283
  options?: QueryOptions
280
- ): Promise<SqlResults>;
284
+ ): SqlResults;
281
285
 
282
286
  /**
283
- * Queries feed_info and returns a promise for an array of feed_infos.
287
+ * Returns an array of fare_products that match query parameters.
284
288
  */
285
- export function getFeedInfo(
289
+ export function getFareProducts(
286
290
  query?: SqlWhere,
287
291
  fields?: SqlSelect,
288
292
  sortBy?: SqlOrderBy,
289
293
  options?: QueryOptions
290
- ): Promise<SqlResults>;
294
+ ): SqlResults;
291
295
 
292
296
  /**
293
- * Queries frequencies and returns a promise for an array of frequencies.
297
+ * Returns an array of fare_rules that match query parameters.
294
298
  */
295
- export function getFrequencies(
299
+ export function getFareRules(
296
300
  query?: SqlWhere,
297
301
  fields?: SqlSelect,
298
302
  sortBy?: SqlOrderBy,
299
303
  options?: QueryOptions
300
- ): Promise<SqlResults>;
304
+ ): SqlResults;
301
305
 
302
306
  /**
303
- * Queries levels and returns a promise for an array of levels.
307
+ * Returns an array of fare_transfer_rules that match query parameters.
304
308
  */
305
- export function getLevels(
309
+ export function getFareTransferRules(
306
310
  query?: SqlWhere,
307
311
  fields?: SqlSelect,
308
312
  sortBy?: SqlOrderBy,
309
313
  options?: QueryOptions
310
- ): Promise<SqlResults>;
314
+ ): SqlResults;
311
315
 
312
316
  /**
313
- * Queries pathways and returns a promise for an array of pathways.
317
+ * Returns an array of feed_info that match query parameters.
314
318
  */
315
- export function getPathways(
319
+ export function getFeedInfo(
316
320
  query?: SqlWhere,
317
321
  fields?: SqlSelect,
318
322
  sortBy?: SqlOrderBy,
319
323
  options?: QueryOptions
320
- ): Promise<SqlResults>;
324
+ ): SqlResults;
321
325
 
322
326
  /**
323
- * Queries transfers and returns a promise for an array of transfers.
327
+ * Returns an array of frequencies that match query parameters.
324
328
  */
325
- export function getTransfers(
329
+ export function getFrequencies(
326
330
  query?: SqlWhere,
327
331
  fields?: SqlSelect,
328
332
  sortBy?: SqlOrderBy,
329
333
  options?: QueryOptions
330
- ): Promise<SqlResults>;
334
+ ): SqlResults;
331
335
 
332
336
  /**
333
- * Queries translations and returns a promise for an array of translations.
337
+ * Returns an array of levels that match query parameters.
334
338
  */
335
- export function getTranslations(
339
+ export function getLevels(
336
340
  query?: SqlWhere,
337
341
  fields?: SqlSelect,
338
342
  sortBy?: SqlOrderBy,
339
343
  options?: QueryOptions
340
- ): Promise<SqlResults>;
344
+ ): SqlResults;
341
345
 
342
346
  /**
343
- * Queries directions and returns a promise for an array of directions.
344
- * These are from the non-standard `directions.txt` file.
347
+ * Returns an array of pathways that match query parameters.
345
348
  */
346
- export function getDirections(
349
+ export function getPathways(
347
350
  query?: SqlWhere,
348
351
  fields?: SqlSelect,
349
352
  sortBy?: SqlOrderBy,
350
353
  options?: QueryOptions
351
- ): Promise<SqlResults>;
354
+ ): SqlResults;
352
355
 
353
356
  /**
354
- * Queries stop_attributes and returns a promise for an array of stop_attributes.
355
- * These are from the non-standard `stop_attributes.txt` file.
357
+ * Returns an array of transfers that match query parameters.
356
358
  */
357
- export function getStopAttributes(
359
+ export function getTransfers(
358
360
  query?: SqlWhere,
359
361
  fields?: SqlSelect,
360
362
  sortBy?: SqlOrderBy,
361
363
  options?: QueryOptions
362
- ): Promise<SqlResults>;
364
+ ): SqlResults;
363
365
 
364
366
  /**
365
- * Queries timetables and returns a promise for an array of timetables.
366
- * These are from the non-standard `timetables.txt` file.
367
+ * Returns an array of translations that match query parameters.
367
368
  */
368
- export function getTimetables(
369
+ export function getTranslations(
369
370
  query?: SqlWhere,
370
371
  fields?: SqlSelect,
371
372
  sortBy?: SqlOrderBy,
372
373
  options?: QueryOptions
373
- ): Promise<SqlResults>;
374
+ ): SqlResults;
374
375
 
375
376
  /**
376
- * Queries timetable_stop_orders and returns a promise for an array of timetable_stop_orders.
377
- * These are from the non-standard `timetable_stop_order.txt` file.
377
+ * Returns an array of stop_areas that match query parameters.
378
378
  */
379
- export function getTimetableStopOrders(
379
+ export function getStopAreas(
380
380
  query?: SqlWhere,
381
381
  fields?: SqlSelect,
382
382
  sortBy?: SqlOrderBy,
383
383
  options?: QueryOptions
384
- ): Promise<SqlResults>;
384
+ ): SqlResults;
385
385
 
386
386
  /**
387
- * Queries timetable_pages and returns a promise for an array of timetable_pages.
388
- * These are from the non-standard `timetable_pages.txt` file.
387
+ * Returns an array of directions that match query parameters.
388
+ * This is for the non-standard `directions.txt` file.
389
389
  */
390
- export function getTimetablePages(
390
+ export function getDirections(
391
391
  query?: SqlWhere,
392
392
  fields?: SqlSelect,
393
393
  sortBy?: SqlOrderBy,
394
394
  options?: QueryOptions
395
- ): Promise<SqlResults>;
395
+ ): SqlResults;
396
396
 
397
397
  /**
398
- * Queries timetable_notes and returns a promise for an array of timetable_notes.
399
- * These are from the non-standard `timetable_notes.txt` file.
398
+ * Returns an array of stop_attributes that match query parameters.
399
+ * This is for the non-standard `stop_attributes.txt` file.
400
400
  */
401
- export function getTimetableNotes(
401
+ export function getStopAttributes(
402
402
  query?: SqlWhere,
403
403
  fields?: SqlSelect,
404
404
  sortBy?: SqlOrderBy,
405
405
  options?: QueryOptions
406
- ): Promise<SqlResults>;
406
+ ): SqlResults;
407
407
 
408
408
  /**
409
- * Queries timetable_notes_references and returns a promise for an array of timetable_notes references.
410
- * These are from the non-standard `timetable_notes_references.txt` file.
409
+ * Returns an array of timetables that match query parameters.
410
+ * This is for the non-standard `timetables.txt` file used in GTFS-to-HTML.
411
411
  */
412
- export function getTimetableNotesReferences(
412
+ export function getTimetables(
413
413
  query?: SqlWhere,
414
414
  fields?: SqlSelect,
415
415
  sortBy?: SqlOrderBy,
416
416
  options?: QueryOptions
417
- ): Promise<SqlResults>;
417
+ ): SqlResults;
418
418
 
419
419
  /**
420
- * Queries board-alights and returns a promise for an array of board-alights.
420
+ * Returns an array of timetable_stop_orders that match query parameters.
421
+ * This is for the non-standard `timetable_stop_order.txt` file used in GTFS-to-HTML.
421
422
  */
422
- export function getBoardAlights(
423
+ export function getTimetableStopOrders(
423
424
  query?: SqlWhere,
424
425
  fields?: SqlSelect,
425
426
  sortBy?: SqlOrderBy,
426
427
  options?: QueryOptions
427
- ): Promise<SqlResults>;
428
+ ): SqlResults;
428
429
 
429
430
  /**
430
- * Queries ride-feed-info and returns a promise for an array of ride-feed-info.
431
+ * Returns an array of timetable_pages that match query parameters.
432
+ * This is for the non-standard `timetable_pages.txt` file used in GTFS-to-HTML.
431
433
  */
432
- export function getRideFeedInfos(
434
+ export function getTimetablePages(
433
435
  query?: SqlWhere,
434
436
  fields?: SqlSelect,
435
437
  sortBy?: SqlOrderBy,
436
438
  options?: QueryOptions
437
- ): Promise<SqlResults>;
439
+ ): SqlResults;
438
440
 
439
441
  /**
440
- * Queries rider trips and returns a promise for an array of rider trips.
442
+ * Returns an array of timetable_notes that match query parameters.
443
+ * This is for the non-standard `timetable_notes.txt` file used in GTFS-to-HTML.
441
444
  */
442
- export function getRiderTrips(
445
+ export function getTimetableNotes(
443
446
  query?: SqlWhere,
444
447
  fields?: SqlSelect,
445
448
  sortBy?: SqlOrderBy,
446
449
  options?: QueryOptions
447
- ): Promise<SqlResults>;
450
+ ): SqlResults;
448
451
 
449
452
  /**
450
- * Queries riderships and returns a promise for an array of riderships.
453
+ * Returns an array of timetable_notes_references that match query parameters.
454
+ * This is for the non-standard `timetable_notes_references.txt` file used in GTFS-to-HTML.
451
455
  */
452
- export function getRiderships(
456
+ export function getTimetableNotesReferences(
453
457
  query?: SqlWhere,
454
458
  fields?: SqlSelect,
455
459
  sortBy?: SqlOrderBy,
456
460
  options?: QueryOptions
457
- ): Promise<SqlResults>;
461
+ ): SqlResults;
458
462
 
459
463
  /**
460
- * Queries trip-capacities and returns a promise for an array of trip-capacities.
464
+ * Returns an array of trips_dated_vehicle_journey that match query parameters.
465
+ * This is for the non-standard `trips_dated_vehicle_journey.txt` file.
461
466
  */
462
- export function getTripCapacities(
467
+ export function getTripsDatedVehicleJourneys(
463
468
  query?: SqlWhere,
464
469
  fields?: SqlSelect,
465
470
  sortBy?: SqlOrderBy,
466
471
  options?: QueryOptions
467
- ): Promise<SqlResults>;
472
+ ): SqlResults;
468
473
 
469
474
  /**
470
- * Queries trip-capacities and returns a promise for an array of service-alerts.
475
+ * Returns an array of GTFS Realtime service alerts that match query parameters.
476
+ * This only works if you configure GTFS Realtime import in node-gtfs.
471
477
  */
472
478
  export function getServiceAlerts(
473
479
  query?: SqlWhere,
474
480
  fields?: SqlSelect,
475
481
  sortBy?: SqlOrderBy,
476
482
  options?: QueryOptions
477
- ): Promise<SqlResults>;
483
+ ): SqlResults;
478
484
 
479
485
  /**
480
- * Queries trip-capacities and returns a promise for an array of trip-updates.
486
+ * Returns an array of GTFS Realtime trip updates that match query parameters.
487
+ * This only works if you configure GTFS Realtime import in node-gtfs.
481
488
  */
482
489
  export function getTripUpdates(
483
490
  query?: SqlWhere,
484
491
  fields?: SqlSelect,
485
492
  sortBy?: SqlOrderBy,
486
493
  options?: QueryOptions
487
- ): Promise<SqlResults>;
494
+ ): SqlResults;
488
495
 
489
496
  /**
490
- * Queries trip-capacities and returns a promise for an array of vehicle-positions.
497
+ * Returns an array of GTFS Realtime stop time updates that match query parameters.
498
+ * This only works if you configure GTFS Realtime import in node-gtfs.
491
499
  */
492
- export function getVehiclePositions(
500
+ export function getStopTimesUpdates(
493
501
  query?: SqlWhere,
494
502
  fields?: SqlSelect,
495
503
  sortBy?: SqlOrderBy,
496
504
  options?: QueryOptions
497
- ): Promise<SqlResults>;
505
+ ): SqlResults;
498
506
 
499
507
  /**
500
- * Queries trip-capacities and returns a promise for an array of stop-times-updates.
508
+ * Returns an array of GTFS Realtime vehicle positions that match query parameters.
509
+ * This only works if you configure GTFS Realtime import in node-gtfs.
501
510
  */
502
- export function getStopTimesUpdates(
511
+ export function getVehiclePositions(
503
512
  query?: SqlWhere,
504
513
  fields?: SqlSelect,
505
514
  sortBy?: SqlOrderBy,
506
515
  options?: QueryOptions
507
- ): Promise<SqlResults>;
516
+ ): SqlResults;
508
517
 
509
518
  /**
510
519
  * Runs an advanced query.
@@ -512,20 +521,4 @@ export function getStopTimesUpdates(
512
521
  export function advancedQuery(
513
522
  table?: SqlTableName,
514
523
  advancedQueryOptions?: AdvancedQueryOptions
515
- ): Promise<SqlResults>;
516
-
517
- /**
518
- * Runs an raw query retuning all rows.
519
- */
520
- export function runRawQuery(
521
- sql?: SqlQueryString,
522
- options?: QueryOptions
523
- ): Promise<SqlResults>;
524
-
525
- /**
526
- * Executing an raw query.
527
- */
528
- export function execRawQuery(
529
- sql?: SqlQueryString,
530
- options?: QueryOptions
531
- ): Promise<any>;
524
+ ): SqlResults;
package/@types/tests.ts CHANGED
@@ -1,4 +1,11 @@
1
- import { Config, exportGtfs, getAgencies, getDb, getShapesAsGeoJSON, importGtfs, openDb } from "gtfs";
1
+ import {
2
+ Config,
3
+ exportGtfs,
4
+ getAgencies,
5
+ getShapesAsGeoJSON,
6
+ importGtfs,
7
+ openDb,
8
+ } from 'gtfs';
2
9
 
3
10
  /**
4
11
  * This is type-checked (but not executed) by dtslint.
@@ -6,21 +13,19 @@ import { Config, exportGtfs, getAgencies, getDb, getShapesAsGeoJSON, importGtfs,
6
13
  */
7
14
 
8
15
  (async () => {
9
- const config: Config = {
10
- agencies: [{ path: "example.zip" }],
11
- verbose: false,
12
- };
16
+ const config: Config = {
17
+ agencies: [{ path: 'example.zip' }],
18
+ verbose: false,
19
+ };
13
20
 
14
- await importGtfs(config); // $ExpectType void
21
+ await importGtfs(config); // $ExpectType void
15
22
 
16
- await exportGtfs(config); // $ExpectType void
23
+ await exportGtfs(config); // $ExpectType void
17
24
 
18
- await openDb(config); // $ExpectType Database<Database, Statement>
25
+ openDb(config); // $ExpectType Database
19
26
 
20
- await getDb(); // $ExpectType Database<Database, Statement>
27
+ const results = getAgencies();
28
+ results[0]; // $ExpectType Record<string, any>
21
29
 
22
- const results = await getAgencies();
23
- results[0]; // $ExpectType Record<string, any>
24
-
25
- await getShapesAsGeoJSON(); // $ExpectType FeatureCollection<Geometry, { [name: string]: any; }>
30
+ getShapesAsGeoJSON(); // $ExpectType FeatureCollection<Geometry, { [name: string]: any; }>
26
31
  })();
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.0.1] - 2022-12-31
9
+
10
+ ### Updated
11
+
12
+ - Update types info
13
+ - Improved readme
14
+ - Improved queries
15
+
16
+ ## [4.0.0] - 2022-12-30
17
+
18
+ ### Changed
19
+
20
+ - Use better-sqlite3 library
21
+ - Make all query methods synchronous
22
+ - Remove `runRawQuery` (use Raw SQLite query instead)
23
+ - Remove `execRawQuery` (use Raw SQLite query instead)
24
+ - Remove `getDb` (use `openDb` instead)
25
+
8
26
  ## [3.8.0] - 2022-12-22
9
27
 
10
28
  ### Updated