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.
- package/@types/index.d.ts +130 -137
- package/@types/tests.ts +18 -13
- package/CHANGELOG.md +18 -0
- package/README.md +233 -212
- package/config-sample-rtupdates.json +6 -18
- package/lib/advancedQuery.js +8 -17
- package/lib/db.js +35 -59
- package/lib/export.js +16 -10
- package/lib/gtfs/agencies.js +8 -6
- package/lib/gtfs/areas.js +8 -11
- package/lib/gtfs/attributions.js +8 -6
- package/lib/gtfs/calendar-dates.js +8 -6
- package/lib/gtfs/calendars.js +8 -6
- package/lib/gtfs/fare-attributes.js +8 -6
- package/lib/gtfs/fare-leg-rules.js +8 -6
- package/lib/gtfs/fare-products.js +8 -6
- package/lib/gtfs/fare-rules.js +8 -6
- package/lib/gtfs/fare-transfer-rules.js +8 -6
- package/lib/gtfs/feed-info.js +8 -6
- package/lib/gtfs/frequencies.js +8 -6
- package/lib/gtfs/levels.js +8 -11
- package/lib/gtfs/pathways.js +8 -6
- package/lib/gtfs/routes.js +8 -11
- package/lib/gtfs/shapes.js +34 -39
- package/lib/gtfs/stop-areas.js +8 -6
- package/lib/gtfs/stop-times.js +8 -6
- package/lib/gtfs/stops.js +27 -33
- package/lib/gtfs/transfers.js +8 -6
- package/lib/gtfs/translations.js +8 -6
- package/lib/gtfs/trips.js +8 -11
- package/lib/gtfs-realtime/service-alerts.js +9 -7
- package/lib/gtfs-realtime/stop-times-updates.js +9 -7
- package/lib/gtfs-realtime/trip-updates.js +9 -7
- package/lib/gtfs-realtime/vehicle-positions.js +9 -7
- package/lib/gtfs-ride/board-alights.js +8 -6
- package/lib/gtfs-ride/ride-feed-infos.js +8 -6
- package/lib/gtfs-ride/rider-trips.js +8 -6
- package/lib/gtfs-ride/riderships.js +8 -6
- package/lib/gtfs-ride/trip-capacities.js +8 -6
- package/lib/gtfs.js +3 -9
- package/lib/import.js +213 -273
- package/lib/non-standard/directions.js +8 -6
- package/lib/non-standard/stop-attributes.js +8 -6
- package/lib/non-standard/timetable-notes-references.js +8 -6
- package/lib/non-standard/timetable-notes.js +8 -6
- package/lib/non-standard/timetable-pages.js +8 -6
- package/lib/non-standard/timetable-stop-order.js +8 -6
- package/lib/non-standard/timetables.js +8 -6
- package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
- package/package.json +4 -4
- package/test/mocha/advanced-query.js +9 -15
- package/test/mocha/export-gtfs.js +5 -6
- package/test/mocha/fare-transfer-rules.js +32 -0
- package/test/mocha/get-agencies.js +13 -19
- package/test/mocha/get-areas.js +27 -0
- package/test/mocha/get-attributions.js +7 -13
- package/test/mocha/get-board-alights.js +7 -13
- package/test/mocha/get-calendar-dates.js +11 -17
- package/test/mocha/get-calendars.js +11 -17
- package/test/mocha/get-directions.js +7 -13
- package/test/mocha/get-fare-attributes.js +9 -15
- package/test/mocha/get-fare-leg-rules.js +27 -0
- package/test/mocha/get-fare-products.js +27 -0
- package/test/mocha/get-fare-rules.js +9 -15
- package/test/mocha/get-feed-info.js +7 -13
- package/test/mocha/get-frequencies.js +7 -13
- package/test/mocha/get-levels.js +7 -7
- package/test/mocha/get-pathways.js +7 -13
- package/test/mocha/get-ride-feed-infos.js +7 -13
- package/test/mocha/get-rider-trips.js +7 -13
- package/test/mocha/get-riderships.js +7 -13
- package/test/mocha/get-routes.js +13 -13
- package/test/mocha/get-shapes-as-geojson.js +14 -15
- package/test/mocha/get-shapes.js +25 -25
- package/test/mocha/get-stop-attributes.js +7 -13
- package/test/mocha/get-stops-as-geojson.js +13 -19
- package/test/mocha/get-stops.js +19 -19
- package/test/mocha/get-stoptimes.js +11 -17
- package/test/mocha/get-timetable-pages.js +7 -13
- package/test/mocha/get-timetable-stop-orders.js +6 -7
- package/test/mocha/get-timetables.js +7 -13
- package/test/mocha/get-transfers.js +7 -13
- package/test/mocha/get-translations.js +7 -13
- package/test/mocha/get-trip-capacities.js +7 -13
- package/test/mocha/get-trips.js +9 -9
- package/test/mocha/import-gtfs.js +11 -11
- package/test/mocha/{get-db.js → open-db.js} +37 -29
- package/test/mocha/raw-query.js +34 -0
- package/test/mocha/exec-raw-query.js +0 -39
- 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
|
-
|
|
3
|
+
import Database = require('better-sqlite3');
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
import { FeatureCollection, Geometry } from '@turf/helpers';
|
|
8
6
|
|
|
9
|
-
export
|
|
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 =
|
|
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
|
|
34
|
+
export interface AdvancedQueryOptions {
|
|
37
35
|
/**
|
|
38
|
-
*
|
|
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?:
|
|
41
|
+
join?: JoinOptions[];
|
|
44
42
|
options?: QueryOptions;
|
|
45
|
-
}
|
|
43
|
+
}
|
|
46
44
|
|
|
47
|
-
export
|
|
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
|
|
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?:
|
|
120
|
+
db?: Database.Database;
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
* Use exportGtfs() in your code to run an export of a GTFS
|
|
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
|
-
*
|
|
139
|
+
* Opens the database specified in the config object.
|
|
141
140
|
*/
|
|
142
|
-
export function openDb(config: DbConfig):
|
|
141
|
+
export function openDb(config: DbConfig): Database.Database;
|
|
143
142
|
|
|
144
143
|
/**
|
|
145
|
-
* Closes
|
|
144
|
+
* Closes the specified database.
|
|
146
145
|
*/
|
|
147
|
-
export function closeDb(db?:
|
|
146
|
+
export function closeDb(db?: Database.Database): void;
|
|
148
147
|
|
|
149
148
|
/**
|
|
150
|
-
*
|
|
149
|
+
* Returns an array of agencies that match query parameters.
|
|
151
150
|
*/
|
|
152
|
-
export function
|
|
151
|
+
export function getAgencies(
|
|
152
|
+
query?: SqlWhere,
|
|
153
|
+
fields?: SqlSelect,
|
|
154
|
+
sortBy?: SqlOrderBy,
|
|
155
|
+
options?: QueryOptions
|
|
156
|
+
): SqlResults;
|
|
153
157
|
|
|
154
158
|
/**
|
|
155
|
-
*
|
|
159
|
+
* Returns an array of areas that match query parameters.
|
|
156
160
|
*/
|
|
157
|
-
export function
|
|
161
|
+
export function getAreas(
|
|
158
162
|
query?: SqlWhere,
|
|
159
163
|
fields?: SqlSelect,
|
|
160
164
|
sortBy?: SqlOrderBy,
|
|
161
165
|
options?: QueryOptions
|
|
162
|
-
):
|
|
166
|
+
): SqlResults;
|
|
163
167
|
|
|
164
168
|
/**
|
|
165
|
-
*
|
|
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
|
-
):
|
|
176
|
+
): SqlResults;
|
|
173
177
|
|
|
174
178
|
/**
|
|
175
|
-
*
|
|
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
|
-
):
|
|
186
|
+
): SqlResults;
|
|
183
187
|
|
|
184
188
|
/**
|
|
185
|
-
*
|
|
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
|
-
):
|
|
196
|
+
): SqlResults;
|
|
193
197
|
|
|
194
198
|
/**
|
|
195
|
-
*
|
|
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
|
-
*
|
|
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
|
-
):
|
|
215
|
+
): SqlResults;
|
|
212
216
|
|
|
213
217
|
/**
|
|
214
|
-
*
|
|
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
|
-
):
|
|
225
|
+
): SqlResults;
|
|
222
226
|
|
|
223
227
|
/**
|
|
224
|
-
*
|
|
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
|
-
):
|
|
235
|
+
): SqlResults;
|
|
232
236
|
|
|
233
237
|
/**
|
|
234
|
-
*
|
|
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
|
-
):
|
|
244
|
+
): FeatureCollection<Geometry, { [name: string]: any }>;
|
|
241
245
|
|
|
242
246
|
/**
|
|
243
|
-
*
|
|
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
|
-
):
|
|
254
|
+
): SqlResults;
|
|
251
255
|
|
|
252
256
|
/**
|
|
253
|
-
*
|
|
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
|
-
):
|
|
264
|
+
): SqlResults;
|
|
261
265
|
|
|
262
266
|
/**
|
|
263
|
-
*
|
|
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
|
-
):
|
|
274
|
+
): SqlResults;
|
|
271
275
|
|
|
272
276
|
/**
|
|
273
|
-
*
|
|
277
|
+
* Returns an array of fare_leg_rules that match query parameters.
|
|
274
278
|
*/
|
|
275
|
-
export function
|
|
279
|
+
export function getFareLegRules(
|
|
276
280
|
query?: SqlWhere,
|
|
277
281
|
fields?: SqlSelect,
|
|
278
282
|
sortBy?: SqlOrderBy,
|
|
279
283
|
options?: QueryOptions
|
|
280
|
-
):
|
|
284
|
+
): SqlResults;
|
|
281
285
|
|
|
282
286
|
/**
|
|
283
|
-
*
|
|
287
|
+
* Returns an array of fare_products that match query parameters.
|
|
284
288
|
*/
|
|
285
|
-
export function
|
|
289
|
+
export function getFareProducts(
|
|
286
290
|
query?: SqlWhere,
|
|
287
291
|
fields?: SqlSelect,
|
|
288
292
|
sortBy?: SqlOrderBy,
|
|
289
293
|
options?: QueryOptions
|
|
290
|
-
):
|
|
294
|
+
): SqlResults;
|
|
291
295
|
|
|
292
296
|
/**
|
|
293
|
-
*
|
|
297
|
+
* Returns an array of fare_rules that match query parameters.
|
|
294
298
|
*/
|
|
295
|
-
export function
|
|
299
|
+
export function getFareRules(
|
|
296
300
|
query?: SqlWhere,
|
|
297
301
|
fields?: SqlSelect,
|
|
298
302
|
sortBy?: SqlOrderBy,
|
|
299
303
|
options?: QueryOptions
|
|
300
|
-
):
|
|
304
|
+
): SqlResults;
|
|
301
305
|
|
|
302
306
|
/**
|
|
303
|
-
*
|
|
307
|
+
* Returns an array of fare_transfer_rules that match query parameters.
|
|
304
308
|
*/
|
|
305
|
-
export function
|
|
309
|
+
export function getFareTransferRules(
|
|
306
310
|
query?: SqlWhere,
|
|
307
311
|
fields?: SqlSelect,
|
|
308
312
|
sortBy?: SqlOrderBy,
|
|
309
313
|
options?: QueryOptions
|
|
310
|
-
):
|
|
314
|
+
): SqlResults;
|
|
311
315
|
|
|
312
316
|
/**
|
|
313
|
-
*
|
|
317
|
+
* Returns an array of feed_info that match query parameters.
|
|
314
318
|
*/
|
|
315
|
-
export function
|
|
319
|
+
export function getFeedInfo(
|
|
316
320
|
query?: SqlWhere,
|
|
317
321
|
fields?: SqlSelect,
|
|
318
322
|
sortBy?: SqlOrderBy,
|
|
319
323
|
options?: QueryOptions
|
|
320
|
-
):
|
|
324
|
+
): SqlResults;
|
|
321
325
|
|
|
322
326
|
/**
|
|
323
|
-
*
|
|
327
|
+
* Returns an array of frequencies that match query parameters.
|
|
324
328
|
*/
|
|
325
|
-
export function
|
|
329
|
+
export function getFrequencies(
|
|
326
330
|
query?: SqlWhere,
|
|
327
331
|
fields?: SqlSelect,
|
|
328
332
|
sortBy?: SqlOrderBy,
|
|
329
333
|
options?: QueryOptions
|
|
330
|
-
):
|
|
334
|
+
): SqlResults;
|
|
331
335
|
|
|
332
336
|
/**
|
|
333
|
-
*
|
|
337
|
+
* Returns an array of levels that match query parameters.
|
|
334
338
|
*/
|
|
335
|
-
export function
|
|
339
|
+
export function getLevels(
|
|
336
340
|
query?: SqlWhere,
|
|
337
341
|
fields?: SqlSelect,
|
|
338
342
|
sortBy?: SqlOrderBy,
|
|
339
343
|
options?: QueryOptions
|
|
340
|
-
):
|
|
344
|
+
): SqlResults;
|
|
341
345
|
|
|
342
346
|
/**
|
|
343
|
-
*
|
|
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
|
|
349
|
+
export function getPathways(
|
|
347
350
|
query?: SqlWhere,
|
|
348
351
|
fields?: SqlSelect,
|
|
349
352
|
sortBy?: SqlOrderBy,
|
|
350
353
|
options?: QueryOptions
|
|
351
|
-
):
|
|
354
|
+
): SqlResults;
|
|
352
355
|
|
|
353
356
|
/**
|
|
354
|
-
*
|
|
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
|
|
359
|
+
export function getTransfers(
|
|
358
360
|
query?: SqlWhere,
|
|
359
361
|
fields?: SqlSelect,
|
|
360
362
|
sortBy?: SqlOrderBy,
|
|
361
363
|
options?: QueryOptions
|
|
362
|
-
):
|
|
364
|
+
): SqlResults;
|
|
363
365
|
|
|
364
366
|
/**
|
|
365
|
-
*
|
|
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
|
|
369
|
+
export function getTranslations(
|
|
369
370
|
query?: SqlWhere,
|
|
370
371
|
fields?: SqlSelect,
|
|
371
372
|
sortBy?: SqlOrderBy,
|
|
372
373
|
options?: QueryOptions
|
|
373
|
-
):
|
|
374
|
+
): SqlResults;
|
|
374
375
|
|
|
375
376
|
/**
|
|
376
|
-
*
|
|
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
|
|
379
|
+
export function getStopAreas(
|
|
380
380
|
query?: SqlWhere,
|
|
381
381
|
fields?: SqlSelect,
|
|
382
382
|
sortBy?: SqlOrderBy,
|
|
383
383
|
options?: QueryOptions
|
|
384
|
-
):
|
|
384
|
+
): SqlResults;
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
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
|
|
390
|
+
export function getDirections(
|
|
391
391
|
query?: SqlWhere,
|
|
392
392
|
fields?: SqlSelect,
|
|
393
393
|
sortBy?: SqlOrderBy,
|
|
394
394
|
options?: QueryOptions
|
|
395
|
-
):
|
|
395
|
+
): SqlResults;
|
|
396
396
|
|
|
397
397
|
/**
|
|
398
|
-
*
|
|
399
|
-
*
|
|
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
|
|
401
|
+
export function getStopAttributes(
|
|
402
402
|
query?: SqlWhere,
|
|
403
403
|
fields?: SqlSelect,
|
|
404
404
|
sortBy?: SqlOrderBy,
|
|
405
405
|
options?: QueryOptions
|
|
406
|
-
):
|
|
406
|
+
): SqlResults;
|
|
407
407
|
|
|
408
408
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
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
|
|
412
|
+
export function getTimetables(
|
|
413
413
|
query?: SqlWhere,
|
|
414
414
|
fields?: SqlSelect,
|
|
415
415
|
sortBy?: SqlOrderBy,
|
|
416
416
|
options?: QueryOptions
|
|
417
|
-
):
|
|
417
|
+
): SqlResults;
|
|
418
418
|
|
|
419
419
|
/**
|
|
420
|
-
*
|
|
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
|
|
423
|
+
export function getTimetableStopOrders(
|
|
423
424
|
query?: SqlWhere,
|
|
424
425
|
fields?: SqlSelect,
|
|
425
426
|
sortBy?: SqlOrderBy,
|
|
426
427
|
options?: QueryOptions
|
|
427
|
-
):
|
|
428
|
+
): SqlResults;
|
|
428
429
|
|
|
429
430
|
/**
|
|
430
|
-
*
|
|
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
|
|
434
|
+
export function getTimetablePages(
|
|
433
435
|
query?: SqlWhere,
|
|
434
436
|
fields?: SqlSelect,
|
|
435
437
|
sortBy?: SqlOrderBy,
|
|
436
438
|
options?: QueryOptions
|
|
437
|
-
):
|
|
439
|
+
): SqlResults;
|
|
438
440
|
|
|
439
441
|
/**
|
|
440
|
-
*
|
|
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
|
|
445
|
+
export function getTimetableNotes(
|
|
443
446
|
query?: SqlWhere,
|
|
444
447
|
fields?: SqlSelect,
|
|
445
448
|
sortBy?: SqlOrderBy,
|
|
446
449
|
options?: QueryOptions
|
|
447
|
-
):
|
|
450
|
+
): SqlResults;
|
|
448
451
|
|
|
449
452
|
/**
|
|
450
|
-
*
|
|
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
|
|
456
|
+
export function getTimetableNotesReferences(
|
|
453
457
|
query?: SqlWhere,
|
|
454
458
|
fields?: SqlSelect,
|
|
455
459
|
sortBy?: SqlOrderBy,
|
|
456
460
|
options?: QueryOptions
|
|
457
|
-
):
|
|
461
|
+
): SqlResults;
|
|
458
462
|
|
|
459
463
|
/**
|
|
460
|
-
*
|
|
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
|
|
467
|
+
export function getTripsDatedVehicleJourneys(
|
|
463
468
|
query?: SqlWhere,
|
|
464
469
|
fields?: SqlSelect,
|
|
465
470
|
sortBy?: SqlOrderBy,
|
|
466
471
|
options?: QueryOptions
|
|
467
|
-
):
|
|
472
|
+
): SqlResults;
|
|
468
473
|
|
|
469
474
|
/**
|
|
470
|
-
*
|
|
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
|
-
):
|
|
483
|
+
): SqlResults;
|
|
478
484
|
|
|
479
485
|
/**
|
|
480
|
-
*
|
|
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
|
-
):
|
|
494
|
+
): SqlResults;
|
|
488
495
|
|
|
489
496
|
/**
|
|
490
|
-
*
|
|
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
|
|
500
|
+
export function getStopTimesUpdates(
|
|
493
501
|
query?: SqlWhere,
|
|
494
502
|
fields?: SqlSelect,
|
|
495
503
|
sortBy?: SqlOrderBy,
|
|
496
504
|
options?: QueryOptions
|
|
497
|
-
):
|
|
505
|
+
): SqlResults;
|
|
498
506
|
|
|
499
507
|
/**
|
|
500
|
-
*
|
|
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
|
|
511
|
+
export function getVehiclePositions(
|
|
503
512
|
query?: SqlWhere,
|
|
504
513
|
fields?: SqlSelect,
|
|
505
514
|
sortBy?: SqlOrderBy,
|
|
506
515
|
options?: QueryOptions
|
|
507
|
-
):
|
|
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
|
-
):
|
|
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 {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
const config: Config = {
|
|
17
|
+
agencies: [{ path: 'example.zip' }],
|
|
18
|
+
verbose: false,
|
|
19
|
+
};
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
await importGtfs(config); // $ExpectType void
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
await exportGtfs(config); // $ExpectType void
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
openDb(config); // $ExpectType Database
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
const results = getAgencies();
|
|
28
|
+
results[0]; // $ExpectType Record<string, any>
|
|
21
29
|
|
|
22
|
-
|
|
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
|