gtfs 4.17.7 → 4.18.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/dist/index.d.ts CHANGED
@@ -3,36 +3,132 @@ import Database$1, { Database } from 'better-sqlite3';
3
3
  import { FeatureCollection } from 'geojson';
4
4
 
5
5
  type UnixTimestamp = number;
6
- interface ConfigAgency {
7
- exclude?: string[];
8
- url?: string;
9
- path?: string;
6
+ type TableNames = 'agency' | 'stops' | 'routes' | 'trips' | 'stop_times' | 'calendar' | 'calendar_dates' | 'fare_attributes' | 'fare_rules' | 'timeframes' | 'rider_categories' | 'fare_media' | 'fare_products' | 'fare_leg_rules' | 'fare_leg_join_rules' | 'fare_transfer_rules' | 'areas' | 'stop_areas' | 'networks' | 'route_networks' | 'shapes' | 'frequencies' | 'transfers' | 'pathways' | 'levels' | 'location_groups' | 'location_group_stops' | 'locations' | 'booking_rules' | 'translations' | 'feed_info' | 'attributions';
7
+ interface BaseConfigAgency {
8
+ /**
9
+ * An array of GTFS file names (without .txt) to exclude when importing
10
+ */
11
+ exclude?: TableNames[];
12
+ /**
13
+ * An object of HTTP headers in key:value format to use when fetching GTFS from the url specified
14
+ */
10
15
  headers?: Record<string, string>;
16
+ /**
17
+ * Settings for fetching GTFS-Realtime alerts
18
+ */
11
19
  realtimeAlerts?: {
20
+ /**
21
+ * URL for fetching GTFS-Realtime alerts
22
+ */
12
23
  url: string;
24
+ /**
25
+ * Headers to use when fetching GTFS-Realtime alerts
26
+ */
13
27
  headers?: Record<string, string>;
14
28
  };
29
+ /**
30
+ * Settings for fetching GTFS-Realtime trip updates
31
+ */
15
32
  realtimeTripUpdates?: {
33
+ /**
34
+ * URL for fetching GTFS-Realtime trip updates
35
+ */
16
36
  url: string;
37
+ /**
38
+ * Headers to use when fetching GTFS-Realtime trip updates
39
+ */
17
40
  headers?: Record<string, string>;
18
41
  };
42
+ /**
43
+ * Settings for fetching GTFS-Realtime vehicle positions
44
+ */
19
45
  realtimeVehiclePositions?: {
46
+ /**
47
+ * URL for fetching GTFS-Realtime vehicle positions
48
+ */
20
49
  url: string;
50
+ /**
51
+ * Headers to use when fetching GTFS-Realtime vehicle positions
52
+ */
21
53
  headers?: Record<string, string>;
22
54
  };
55
+ /**
56
+ * A prefix to be added to every ID field maintain uniqueness when importing multiple GTFS from multiple agencies
57
+ */
23
58
  prefix?: string;
24
59
  }
60
+ type ConfigAgency = BaseConfigAgency & ({
61
+ /**
62
+ * The URL to a zipped GTFS file. Required if path not present
63
+ */
64
+ url: string;
65
+ } | {
66
+ /**
67
+ * A path to a zipped GTFS file or a directory of unzipped .txt files. Required if url is not present
68
+ */
69
+ path: string;
70
+ });
25
71
  interface Config {
72
+ /**
73
+ * An existing database instance to use instead of relying on node-gtfs to connect.
74
+ */
26
75
  db?: Database;
76
+ /**
77
+ * A path to an SQLite database. Defaults to using an in-memory database.
78
+ */
27
79
  sqlitePath?: string;
80
+ /**
81
+ * Amount of time in seconds to allow GTFS-Realtime data to be stored in database before allowing to be deleted.
82
+ *
83
+ * Note: is an integer
84
+ *
85
+ * @defaultValue 0
86
+ */
28
87
  gtfsRealtimeExpirationSeconds?: number;
88
+ /**
89
+ * The number of milliseconds to wait before throwing an error when downloading GTFS.
90
+ *
91
+ * Note: is an integer
92
+ */
29
93
  downloadTimeout?: number;
94
+ /**
95
+ * Options passed to `csv-parse` for parsing GTFS CSV files.
96
+ */
30
97
  csvOptions?: Options;
98
+ /**
99
+ * A path to a directory to put exported GTFS files.
100
+ *
101
+ * @defaultValue `gtfs-export/<agency_name>`
102
+ */
31
103
  exportPath?: string;
104
+ /**
105
+ * Whether or not to ignore unique constraints on ids when importing GTFS, such as `trip_id`, `calendar_id`.
106
+ *
107
+ * @defaultValue false
108
+ */
32
109
  ignoreDuplicates?: boolean;
110
+ /**
111
+ * Whether or not to ignore errors during the import process. If true, failed files will be skipped while the rest are processed.
112
+ *
113
+ * @defaultValue false
114
+ */
33
115
  ignoreErrors?: boolean;
116
+ /**
117
+ * An array of GTFS files to be imported, and which files to exclude.
118
+ */
34
119
  agencies: ConfigAgency[];
120
+ /**
121
+ * Whether or not to print output to the console.
122
+ *
123
+ * @defaulValue true
124
+ */
35
125
  verbose?: boolean;
126
+ /**
127
+ * An optional custom logger instead of the build in console.log
128
+ *
129
+ * @param message
130
+ * @returns
131
+ */
36
132
  logFunction?: (message: string) => void;
37
133
  }
38
134
  interface ModelColumn {
@@ -49,7 +145,7 @@ interface ModelColumn {
49
145
  prefix?: boolean;
50
146
  }
51
147
  interface Model {
52
- filenameBase: string;
148
+ filenameBase: TableNames;
53
149
  filenameExtension?: string;
54
150
  extension?: string;
55
151
  nonstandard?: boolean;
@@ -71,50 +167,51 @@ interface QueryOptions {
71
167
  bounding_box_side_m?: number;
72
168
  }
73
169
  interface Agency {
74
- agency_id?: string;
170
+ agency_id: string | null;
75
171
  agency_name: string;
76
172
  agency_url: string;
77
173
  agency_timezone: string;
78
- agency_lang?: string;
79
- agency_phone?: string;
80
- agency_fare_url?: string;
81
- agency_email?: string;
174
+ agency_lang: string | null;
175
+ agency_phone: string | null;
176
+ agency_fare_url: string | null;
177
+ agency_email: string | null;
178
+ cemv_support: 0 | 1 | 2 | null;
82
179
  }
83
180
  interface Area {
84
181
  area_id: string;
85
- area_name?: string;
182
+ area_name: string | null;
86
183
  }
87
184
  interface Attribution {
88
- attribution_id?: string;
89
- agency_id?: string;
90
- route_id?: string;
91
- trip_id?: string;
185
+ attribution_id: string | null;
186
+ agency_id: string | null;
187
+ route_id: string | null;
188
+ trip_id: string | null;
92
189
  organization_name: string;
93
- is_producer?: 0 | 1;
94
- is_operator?: 0 | 1;
95
- is_authority?: 0 | 1;
96
- attribution_url?: string;
97
- attribution_email?: string;
98
- attribution_phone?: string;
190
+ is_producer: 0 | 1 | null;
191
+ is_operator: 0 | 1 | null;
192
+ is_authority: 0 | 1 | null;
193
+ attribution_url: string | null;
194
+ attribution_email: string | null;
195
+ attribution_phone: string | null;
99
196
  }
100
197
  interface BookingRule {
101
198
  booking_rule_id: string;
102
199
  booking_type: 0 | 1 | 2;
103
- prior_notice_duration_min?: number;
104
- prior_notice_duration_max?: number;
105
- prior_notice_last_day?: number;
106
- prior_notice_last_time?: string;
107
- prior_notice_last_timestamp?: UnixTimestamp;
108
- prior_notice_start_day?: number;
109
- prior_notice_start_time?: string;
110
- prior_notice_start_timestamp?: UnixTimestamp;
111
- prior_notice_service_id?: string;
112
- message?: string;
113
- pickup_message?: string;
114
- drop_off_message?: string;
115
- phone_number?: string;
116
- info_url?: string;
117
- booking_url?: string;
200
+ prior_notice_duration_min: number | null;
201
+ prior_notice_duration_max: number | null;
202
+ prior_notice_last_day: number | null;
203
+ prior_notice_last_time: string | null;
204
+ prior_notice_last_timestamp: UnixTimestamp | null;
205
+ prior_notice_start_day: number | null;
206
+ prior_notice_start_time: string | null;
207
+ prior_notice_start_timestamp: UnixTimestamp | null;
208
+ prior_notice_service_id: string | null;
209
+ message: string | null;
210
+ pickup_message: string | null;
211
+ drop_off_message: string | null;
212
+ phone_number: string | null;
213
+ info_url: string | null;
214
+ booking_url: string | null;
118
215
  }
119
216
  interface Calendar {
120
217
  service_id: string;
@@ -132,7 +229,7 @@ interface CalendarDate {
132
229
  service_id: string;
133
230
  date: number;
134
231
  exception_type: 1 | 2;
135
- holiday_name?: string;
232
+ holiday_name: string | null;
136
233
  }
137
234
  interface FareAttribute {
138
235
  fare_id: string;
@@ -140,57 +237,57 @@ interface FareAttribute {
140
237
  currency_type: string;
141
238
  payment_method: 0 | 1;
142
239
  transfers: 0 | 1 | 2;
143
- agency_id?: string;
144
- transfer_duration?: number;
240
+ agency_id: string | null;
241
+ transfer_duration: number | null;
145
242
  }
146
243
  interface FareLegRule {
147
- leg_group_id?: string;
148
- network_id?: string;
149
- from_area_id?: string;
150
- to_area_id?: string;
151
- from_timeframe_group_id?: string;
152
- to_timeframe_group_id?: string;
244
+ leg_group_id: string | null;
245
+ network_id: string | null;
246
+ from_area_id: string | null;
247
+ to_area_id: string | null;
248
+ from_timeframe_group_id: string | null;
249
+ to_timeframe_group_id: string | null;
153
250
  fare_product_id: string;
154
- rule_priority?: number;
251
+ rule_priority: number | null;
155
252
  }
156
253
  interface FareMedia {
157
254
  fare_media_id: string;
158
- fare_media_name?: string;
255
+ fare_media_name: string | null;
159
256
  fare_media_type: 0 | 1 | 2 | 3 | 4;
160
257
  }
161
258
  interface FareProduct {
162
259
  fare_product_id: string;
163
- fare_product_name?: string;
164
- fare_media_id?: string;
260
+ fare_product_name: string | null;
261
+ fare_media_id: string | null;
165
262
  amount: number;
166
263
  currency: string;
167
264
  }
168
265
  interface FareRule {
169
266
  fare_id: string;
170
- route_id?: string;
171
- origin_id?: string;
172
- destination_id?: string;
173
- contains_id?: string;
267
+ route_id: string | null;
268
+ origin_id: string | null;
269
+ destination_id: string | null;
270
+ contains_id: string | null;
174
271
  }
175
272
  interface FareTransferRule {
176
- from_leg_group_id?: string;
177
- to_leg_group_id?: string;
178
- transfer_count?: number;
273
+ from_leg_group_id: string | null;
274
+ to_leg_group_id: string | null;
275
+ transfer_count: number | null;
179
276
  duration_limit: number;
180
- duration_limit_type?: 0 | 1 | 2 | 3;
277
+ duration_limit_type: 0 | 1 | 2 | 3 | null;
181
278
  fare_transfer_type: 0 | 1 | 2;
182
- fare_product_id?: string;
279
+ fare_product_id: string | null;
183
280
  }
184
281
  interface FeedInfo {
185
282
  feed_publisher_name: string;
186
283
  feed_publisher_url: string;
187
284
  feed_lang: string;
188
- default_lang?: string;
189
- feed_start_date?: number;
190
- feed_end_date?: number;
191
- feed_version?: string;
192
- feed_contact_email?: string;
193
- feed_contact_url?: string;
285
+ default_lang: string | null;
286
+ feed_start_date: number | null;
287
+ feed_end_date: number | null;
288
+ feed_version: string | null;
289
+ feed_contact_email: string | null;
290
+ feed_contact_url: string | null;
194
291
  }
195
292
  interface Frequency {
196
293
  trip_id: string;
@@ -199,12 +296,12 @@ interface Frequency {
199
296
  end_time: string;
200
297
  end_timestamp: UnixTimestamp;
201
298
  headway_secs: number;
202
- exact_times?: 0 | 1;
299
+ exact_times: 0 | 1 | null;
203
300
  }
204
301
  interface Level {
205
302
  level_id: string;
206
303
  level_index: number;
207
- level_name?: string;
304
+ level_name: string | null;
208
305
  }
209
306
  interface LocationGroupStop {
210
307
  location_group_id: string;
@@ -212,14 +309,14 @@ interface LocationGroupStop {
212
309
  }
213
310
  interface LocationGroup {
214
311
  location_group_id: string;
215
- location_group_name?: string;
312
+ location_group_name: string | null;
216
313
  }
217
314
  interface Location {
218
315
  geojson: string;
219
316
  }
220
317
  interface Network {
221
318
  network_id: string;
222
- network_name?: string;
319
+ network_name: string | null;
223
320
  }
224
321
  interface Pathway {
225
322
  pathway_id: string;
@@ -227,13 +324,13 @@ interface Pathway {
227
324
  to_stop_id: string;
228
325
  pathway_mode: 1 | 2 | 3 | 4 | 5 | 6 | 7;
229
326
  is_bidirectional: 0 | 1;
230
- length?: number;
231
- traversal_time?: number;
232
- stair_count?: number;
233
- max_slope?: number;
234
- min_width?: number;
235
- signposted_as?: string;
236
- reversed_signposted_as?: string;
327
+ length: number | null;
328
+ traversal_time: number | null;
329
+ stair_count: number | null;
330
+ max_slope: number | null;
331
+ min_width: number | null;
332
+ signposted_as: string | null;
333
+ reversed_signposted_as: string | null;
237
334
  }
238
335
  interface RouteNetwork {
239
336
  network_id: string;
@@ -241,25 +338,26 @@ interface RouteNetwork {
241
338
  }
242
339
  interface Route {
243
340
  route_id: string;
244
- agency_id?: string;
245
- route_short_name?: string;
246
- route_long_name?: string;
247
- route_desc?: string;
341
+ agency_id: string | null;
342
+ route_short_name: string | null;
343
+ route_long_name: string | null;
344
+ route_desc: string | null;
248
345
  route_type: number;
249
- route_url?: string;
250
- route_color?: string;
251
- route_text_color?: string;
252
- route_sort_order?: number;
253
- continuous_pickup?: 0 | 1 | 2 | 3;
254
- continuous_drop_off?: 0 | 1 | 2 | 3;
255
- network_id?: string;
346
+ route_url: string | null;
347
+ route_color: string | null;
348
+ route_text_color: string | null;
349
+ route_sort_order: number | null;
350
+ continuous_pickup: 0 | 1 | 2 | 3 | null;
351
+ continuous_drop_off: 0 | 1 | 2 | 3 | null;
352
+ network_id: string | null;
353
+ cemv_support: 0 | 1 | 2 | null;
256
354
  }
257
355
  interface Shape {
258
356
  shape_id: string;
259
357
  shape_pt_lat: number;
260
358
  shape_pt_lon: number;
261
359
  shape_pt_sequence: number;
262
- shape_dist_traveled?: number;
360
+ shape_dist_traveled: number | null;
263
361
  }
264
362
  interface StopArea {
265
363
  area_id: string;
@@ -267,87 +365,88 @@ interface StopArea {
267
365
  }
268
366
  interface StopTime {
269
367
  trip_id: string;
270
- arrival_time?: string;
271
- arrival_timestamp?: UnixTimestamp;
272
- departure_time?: string;
273
- departure_timestamp?: UnixTimestamp;
274
- location_group_id?: string;
275
- location_id?: string;
276
- stop_id?: string;
368
+ arrival_time: string | null;
369
+ arrival_timestamp: UnixTimestamp | null;
370
+ departure_time: string | null;
371
+ departure_timestamp: UnixTimestamp | null;
372
+ location_group_id: string | null;
373
+ location_id: string | null;
374
+ stop_id: string | null;
277
375
  stop_sequence: number;
278
- stop_headsign?: string;
279
- start_pickup_drop_off_window?: string;
280
- start_pickup_drop_off_window_timestamp?: UnixTimestamp;
281
- pickup_type?: 0 | 1 | 2 | 3;
282
- drop_off_type?: 0 | 1 | 2 | 3;
283
- continuous_pickup?: 0 | 1 | 2 | 3;
284
- continuous_drop_off?: 0 | 1 | 2 | 3;
285
- shape_dist_traveled?: number;
286
- timepoint?: 0 | 1;
287
- pickup_booking_rule_id?: string;
288
- drop_off_booking_rule_id?: string;
376
+ stop_headsign: string | null;
377
+ start_pickup_drop_off_window: string | null;
378
+ start_pickup_drop_off_window_timestamp: UnixTimestamp | null;
379
+ pickup_type: 0 | 1 | 2 | 3 | null;
380
+ drop_off_type: 0 | 1 | 2 | 3 | null;
381
+ continuous_pickup: 0 | 1 | 2 | 3 | null;
382
+ continuous_drop_off: 0 | 1 | 2 | 3 | null;
383
+ shape_dist_traveled: number | null;
384
+ timepoint: 0 | 1 | null;
385
+ pickup_booking_rule_id: string | null;
386
+ drop_off_booking_rule_id: string | null;
289
387
  }
290
388
  interface Stop {
291
389
  stop_id: string;
292
- stop_code?: string;
293
- stop_name?: string;
294
- tts_stop_name?: string;
295
- stop_desc?: string;
296
- stop_lat?: number;
297
- stop_lon?: number;
298
- zone_id?: string;
299
- stop_url?: string;
300
- location_type?: 0 | 1 | 2 | 3 | 4;
301
- parent_station?: string;
302
- stop_timezone?: string;
303
- wheelchair_boarding?: 0 | 1 | 2;
304
- level_id?: string;
305
- platform_code?: string;
390
+ stop_code: string | null;
391
+ stop_name: string | null;
392
+ tts_stop_name: string | null;
393
+ stop_desc: string | null;
394
+ stop_lat: number | null;
395
+ stop_lon: number | null;
396
+ zone_id: string | null;
397
+ stop_url: string | null;
398
+ location_type: 0 | 1 | 2 | 3 | 4 | null;
399
+ parent_station: string | null;
400
+ stop_timezone: string | null;
401
+ wheelchair_boarding: 0 | 1 | 2 | null;
402
+ level_id: string | null;
403
+ platform_code: string | null;
404
+ stop_access: 0 | 1 | null;
306
405
  }
307
406
  interface Timeframe {
308
407
  timeframe_group_id: string;
309
- start_time?: string;
310
- end_time?: string;
408
+ start_time: string | null;
409
+ end_time: string | null;
311
410
  service_id: string;
312
411
  }
313
412
  interface Transfer {
314
- from_stop_id?: string;
315
- to_stop_id?: string;
316
- from_route_id?: string;
317
- to_route_id?: string;
318
- from_trip_id?: string;
319
- to_trip_id?: string;
413
+ from_stop_id: string | null;
414
+ to_stop_id: string | null;
415
+ from_route_id: string | null;
416
+ to_route_id: string | null;
417
+ from_trip_id: string | null;
418
+ to_trip_id: string | null;
320
419
  transfer_type: 0 | 1 | 2 | 3 | 4 | 5;
321
- min_transfer_time?: number;
420
+ min_transfer_time: number | null;
322
421
  }
323
422
  interface Translation {
324
423
  table_name: string;
325
424
  field_name: string;
326
425
  language: string;
327
426
  translation: string;
328
- record_id?: string;
329
- record_sub_id?: string;
330
- field_value?: string;
427
+ record_id: string | null;
428
+ record_sub_id: string | null;
429
+ field_value: string | null;
331
430
  }
332
431
  interface Trip {
333
432
  route_id: string;
334
433
  service_id: string;
335
434
  trip_id: string;
336
- trip_headsign?: string;
337
- trip_short_name?: string;
338
- direction_id?: 0 | 1;
339
- block_id?: string;
340
- shape_id?: string;
341
- wheelchair_accessible?: 0 | 1 | 2;
342
- bikes_allowed?: 0 | 1 | 2;
343
- cars_allowed?: 0 | 1 | 2;
435
+ trip_headsign: string | null;
436
+ trip_short_name: string | null;
437
+ direction_id: 0 | 1 | null;
438
+ block_id: string | null;
439
+ shape_id: string | null;
440
+ wheelchair_accessible: 0 | 1 | 2 | null;
441
+ bikes_allowed: 0 | 1 | 2 | null;
442
+ cars_allowed: 0 | 1 | 2 | null;
344
443
  }
345
444
  interface Timetable {
346
445
  timetable_id: string;
347
446
  route_id: string;
348
- direction_id?: 0 | 1;
349
- start_date?: number;
350
- end_date?: number;
447
+ direction_id: 0 | 1 | null;
448
+ start_date: number | null;
449
+ end_date: number | null;
351
450
  monday: 0 | 1;
352
451
  tuesday: 0 | 1;
353
452
  wednesday: 0 | 1;
@@ -355,23 +454,23 @@ interface Timetable {
355
454
  friday: 0 | 1;
356
455
  saturday: 0 | 1;
357
456
  sunday: 0 | 1;
358
- start_time?: string;
359
- start_timestamp?: UnixTimestamp;
360
- end_time?: string;
361
- end_timestamp?: UnixTimestamp;
362
- timetable_label?: string;
363
- service_notes?: string;
364
- orientation?: string;
365
- timetable_page_id?: string;
366
- timetable_sequence?: number;
367
- direction_name?: string;
368
- include_exceptions?: 0 | 1;
369
- show_trip_continuation?: 0 | 1;
457
+ start_time: string | null;
458
+ start_timestamp: UnixTimestamp | null;
459
+ end_time: string | null;
460
+ end_timestamp: UnixTimestamp | null;
461
+ timetable_label: string | null;
462
+ service_notes: string | null;
463
+ orientation: string | null;
464
+ timetable_page_id: string | null;
465
+ timetable_sequence: number | null;
466
+ direction_name: string | null;
467
+ include_exceptions: 0 | 1 | null;
468
+ show_trip_continuation: 0 | 1 | null;
370
469
  }
371
470
  interface TimetablePage {
372
471
  timetable_page_id: string;
373
- timetable_page_label?: string;
374
- filename?: string;
472
+ timetable_page_label: string | null;
473
+ filename: string | null;
375
474
  }
376
475
  interface TimetableStopOrder {
377
476
  timetable_id: string;
@@ -380,17 +479,17 @@ interface TimetableStopOrder {
380
479
  }
381
480
  interface TimetableNote {
382
481
  note_id: string;
383
- symbol?: string;
482
+ symbol: string | null;
384
483
  note: string;
385
484
  }
386
485
  interface TimetableNotesReference {
387
486
  note_id: string;
388
487
  timetable_id: string;
389
- route_id?: string;
390
- trip_id?: string;
391
- stop_id?: string;
392
- stop_sequence?: number;
393
- show_on_stoptime?: 0 | 1;
488
+ route_id: string | null;
489
+ trip_id: string | null;
490
+ stop_id: string | null;
491
+ stop_sequence: number | null;
492
+ show_on_stoptime: 0 | 1 | null;
394
493
  }
395
494
  interface TripsDatedVehicleJourney {
396
495
  trip_id: string;
@@ -404,26 +503,26 @@ interface DeadheadTime {
404
503
  arrival_timestamp: UnixTimestamp;
405
504
  departure_time: string;
406
505
  departure_timestamp: UnixTimestamp;
407
- ops_location_id?: string;
408
- stop_id?: string;
506
+ ops_location_id: string | null;
507
+ stop_id: string | null;
409
508
  location_sequence: number;
410
- shape_dist_traveled?: number;
509
+ shape_dist_traveled: number | null;
411
510
  }
412
511
  interface Deadhead {
413
512
  deadhead_id: string;
414
513
  service_id: string;
415
514
  block_id: string;
416
- shape_id?: string;
417
- to_trip_id?: string;
418
- from_trip_id?: string;
419
- to_deadhead_id?: string;
420
- from_deadhead_id?: string;
515
+ shape_id: string | null;
516
+ to_trip_id: string | null;
517
+ from_trip_id: string | null;
518
+ to_deadhead_id: string | null;
519
+ from_deadhead_id: string | null;
421
520
  }
422
521
  interface OpsLocation {
423
522
  ops_location_id: string;
424
- ops_location_code?: string;
523
+ ops_location_code: string | null;
425
524
  ops_location_name: string;
426
- ops_location_desc?: string;
525
+ ops_location_desc: string | null;
427
526
  ops_location_lat: number;
428
527
  ops_location_lon: number;
429
528
  }
@@ -431,23 +530,23 @@ interface RunEvent {
431
530
  run_event_id: string;
432
531
  piece_id: string;
433
532
  event_type: number;
434
- event_name?: string;
533
+ event_name: string | null;
435
534
  event_time: string;
436
535
  event_duration: number;
437
536
  event_from_location_type: 0 | 1;
438
- event_from_location_id?: string;
537
+ event_from_location_id: string | null;
439
538
  event_to_location_type: 0 | 1;
440
- event_to_location_id?: string;
539
+ event_to_location_id: string | null;
441
540
  }
442
541
  interface RunPiece {
443
542
  run_id: string;
444
543
  piece_id: string;
445
544
  start_type: 0 | 1 | 2;
446
545
  start_trip_id: string;
447
- start_trip_position?: number;
546
+ start_trip_position: number | null;
448
547
  end_type: 0 | 1 | 2;
449
548
  end_trip_id: string;
450
- end_trip_position?: number;
549
+ end_trip_position: number | null;
451
550
  }
452
551
  interface ServiceAlert {
453
552
  cause: number;
@@ -459,52 +558,52 @@ interface ServiceAlert {
459
558
  expiration_timestamp: UnixTimestamp;
460
559
  }
461
560
  interface StopTimeUpdate {
462
- trip_id?: string;
463
- trip_start_time?: string;
464
- direction_id?: 0 | 1;
465
- route_id?: string;
466
- stop_id?: string;
467
- stop_sequence?: number;
468
- arrival_delay?: number;
469
- departure_delay?: number;
470
- departure_timestamp?: UnixTimestamp;
471
- arrival_timestamp?: UnixTimestamp;
472
- schedule_relationship?: string;
561
+ trip_id: string | null;
562
+ trip_start_time: string | null;
563
+ direction_id: 0 | 1 | null;
564
+ route_id: string | null;
565
+ stop_id: string | null;
566
+ stop_sequence: number | null;
567
+ arrival_delay: number | null;
568
+ departure_delay: number | null;
569
+ departure_timestamp: UnixTimestamp | null;
570
+ arrival_timestamp: UnixTimestamp | null;
571
+ schedule_relationship: string | null;
473
572
  created_timestamp: UnixTimestamp;
474
573
  expiration_timestamp: UnixTimestamp;
475
574
  }
476
575
  interface TripUpdate {
477
576
  update_id: string;
478
- vehicle_id?: string;
479
- trip_id?: string;
480
- trip_start_time?: string;
481
- direction_id?: 0 | 1;
482
- route_id?: string;
483
- start_date?: number;
484
- timestamp?: UnixTimestamp;
485
- schedule_relationship?: string;
577
+ vehicle_id: string | null;
578
+ trip_id: string | null;
579
+ trip_start_time: string | null;
580
+ direction_id: 0 | 1 | null;
581
+ route_id: string | null;
582
+ start_date: number | null;
583
+ timestamp: UnixTimestamp | null;
584
+ schedule_relationship: string | null;
486
585
  created_timestamp: UnixTimestamp;
487
586
  expiration_timestamp: UnixTimestamp;
488
587
  }
489
588
  interface VehiclePosition {
490
589
  update_id: string;
491
- bearing?: number;
492
- latitude?: number;
493
- longitude?: number;
494
- speed?: number;
495
- current_stop_sequence?: number;
496
- trip_id?: string;
497
- trip_start_date?: number;
498
- trip_start_time?: string;
499
- congestion_level?: string;
500
- occupancy_status?: string;
501
- occupancy_percentage?: number;
502
- vehicle_stop_status?: string;
503
- vehicle_id?: string;
504
- vehicle_label?: string;
505
- vehicle_license_plate?: string;
506
- vehicle_wheelchair_accessible?: number;
507
- timestamp?: UnixTimestamp;
590
+ bearing: number | null;
591
+ latitude: number | null;
592
+ longitude: number | null;
593
+ speed: number | null;
594
+ current_stop_sequence: number | null;
595
+ trip_id: string | null;
596
+ trip_start_date: number | null;
597
+ trip_start_time: string | null;
598
+ congestion_level: string | null;
599
+ occupancy_status: string | null;
600
+ occupancy_percentage: number | null;
601
+ vehicle_stop_status: string | null;
602
+ vehicle_id: string | null;
603
+ vehicle_label: string | null;
604
+ vehicle_license_plate: string | null;
605
+ vehicle_wheelchair_accessible: number | null;
606
+ timestamp: UnixTimestamp | null;
508
607
  created_timestamp: UnixTimestamp;
509
608
  expiration_timestamp: UnixTimestamp;
510
609
  }
@@ -513,92 +612,92 @@ interface BoardAlight {
513
612
  stop_id: string;
514
613
  stop_sequence: number;
515
614
  record_use: 0 | 1;
516
- schedule_relationship?: number;
517
- boardings?: number;
518
- alightings?: number;
519
- current_load?: number;
520
- load_count?: number;
521
- load_type?: number;
522
- rack_down?: number;
523
- bike_boardings?: number;
524
- bike_alightings?: number;
525
- ramp_used?: number;
526
- ramp_boardings?: number;
527
- ramp_alightings?: number;
528
- service_date?: number;
529
- service_arrival_time?: string;
530
- service_arrival_timestamp?: UnixTimestamp;
531
- service_departure_time?: string;
532
- service_departure_timestamp?: UnixTimestamp;
533
- source?: 0 | 1 | 2 | 3 | 4;
615
+ schedule_relationship: number | null;
616
+ boardings: number | null;
617
+ alightings: number | null;
618
+ current_load: number | null;
619
+ load_count: number | null;
620
+ load_type: number | null;
621
+ rack_down: number | null;
622
+ bike_boardings: number | null;
623
+ bike_alightings: number | null;
624
+ ramp_used: number | null;
625
+ ramp_boardings: number | null;
626
+ ramp_alightings: number | null;
627
+ service_date: number | null;
628
+ service_arrival_time: string | null;
629
+ service_arrival_timestamp: UnixTimestamp | null;
630
+ service_departure_time: string | null;
631
+ service_departure_timestamp: UnixTimestamp | null;
632
+ source: 0 | 1 | 2 | 3 | 4 | null;
534
633
  }
535
634
  interface RideFeedInfo {
536
635
  ride_files: number;
537
- ride_start_date?: number;
538
- ride_end_date?: number;
539
- gtfs_feed_date?: number;
540
- default_currency_type?: string;
541
- ride_feed_version?: string;
636
+ ride_start_date: number | null;
637
+ ride_end_date: number | null;
638
+ gtfs_feed_date: number | null;
639
+ default_currency_type: string | null;
640
+ ride_feed_version: string | null;
542
641
  }
543
642
  interface RiderCategory {
544
643
  rider_category_id: string;
545
644
  rider_category_name: string;
546
- is_default_fare_category?: 0 | 1;
547
- eligibility_url?: string;
645
+ is_default_fare_category: 0 | 1 | null;
646
+ eligibility_url: string | null;
548
647
  }
549
648
  interface RiderTrip {
550
649
  rider_id: string;
551
- agency_id?: string;
552
- trip_id?: string;
553
- boarding_stop_id?: string;
554
- boarding_stop_sequence?: number;
555
- alighting_stop_id?: string;
556
- alighting_stop_sequence?: number;
557
- service_date?: number;
558
- boarding_time?: string;
559
- boarding_timestamp?: UnixTimestamp;
560
- alighting_time?: string;
561
- alighting_timestamp?: UnixTimestamp;
562
- rider_type?: number;
563
- rider_type_description?: string;
564
- fare_paid?: number;
565
- transaction_type?: number;
566
- fare_media?: number;
567
- accompanying_device?: number;
568
- transfer_status?: number;
650
+ agency_id: string | null;
651
+ trip_id: string | null;
652
+ boarding_stop_id: string | null;
653
+ boarding_stop_sequence: number | null;
654
+ alighting_stop_id: string | null;
655
+ alighting_stop_sequence: number | null;
656
+ service_date: number | null;
657
+ boarding_time: string | null;
658
+ boarding_timestamp: UnixTimestamp | null;
659
+ alighting_time: string | null;
660
+ alighting_timestamp: UnixTimestamp | null;
661
+ rider_type: number | null;
662
+ rider_type_description: string | null;
663
+ fare_paid: number | null;
664
+ transaction_type: number | null;
665
+ fare_media: number | null;
666
+ accompanying_device: number | null;
667
+ transfer_status: number | null;
569
668
  }
570
669
  interface Ridership {
571
670
  total_boardings: number;
572
671
  total_alightings: number;
573
- ridership_start_date?: number;
574
- ridership_end_date?: number;
575
- ridership_start_time?: string;
576
- ridership_start_timestamp?: UnixTimestamp;
577
- ridership_end_time?: string;
578
- ridership_end_timestamp?: UnixTimestamp;
579
- service_id?: string;
580
- monday?: 0 | 1;
581
- tuesday?: 0 | 1;
582
- wednesday?: 0 | 1;
583
- thursday?: 0 | 1;
584
- friday?: 0 | 1;
585
- saturday?: 0 | 1;
586
- sunday?: 0 | 1;
587
- agency_id?: string;
588
- route_id?: string;
589
- direction_id?: 0 | 1;
590
- trip_id?: string;
591
- stop_id?: string;
672
+ ridership_start_date: number | null;
673
+ ridership_end_date: number | null;
674
+ ridership_start_time: string | null;
675
+ ridership_start_timestamp: UnixTimestamp | null;
676
+ ridership_end_time: string | null;
677
+ ridership_end_timestamp: UnixTimestamp | null;
678
+ service_id: string | null;
679
+ monday: 0 | 1 | null;
680
+ tuesday: 0 | 1 | null;
681
+ wednesday: 0 | 1 | null;
682
+ thursday: 0 | 1 | null;
683
+ friday: 0 | 1 | null;
684
+ saturday: 0 | 1 | null;
685
+ sunday: 0 | 1 | null;
686
+ agency_id: string | null;
687
+ route_id: string | null;
688
+ direction_id: 0 | 1 | null;
689
+ trip_id: string | null;
690
+ stop_id: string | null;
592
691
  }
593
692
  interface TripCapacity {
594
- agency_id?: string;
595
- trip_id?: string;
596
- service_date?: number;
597
- vehicle_description?: string;
598
- seated_capacity?: number;
599
- standing_capacity?: number;
600
- wheelchair_capacity?: number;
601
- bike_capacity?: number;
693
+ agency_id: string | null;
694
+ trip_id: string | null;
695
+ service_date: number | null;
696
+ vehicle_description: string | null;
697
+ seated_capacity: number | null;
698
+ standing_capacity: number | null;
699
+ wheelchair_capacity: number | null;
700
+ bike_capacity: number | null;
602
701
  }
603
702
  interface CalendarAttribute {
604
703
  service_id: string;
@@ -606,7 +705,7 @@ interface CalendarAttribute {
606
705
  }
607
706
  interface Direction {
608
707
  route_id: string;
609
- direction_id?: 0 | 1;
708
+ direction_id: 0 | 1 | null;
610
709
  direction: string;
611
710
  }
612
711
  interface RouteAttribute {
@@ -617,14 +716,22 @@ interface RouteAttribute {
617
716
  }
618
717
  interface StopAttribute {
619
718
  stop_id: string;
620
- accessibility_id?: number;
621
- cardinal_direction?: string;
622
- relative_position?: string;
623
- stop_city?: string;
719
+ accessibility_id: number | null;
720
+ cardinal_direction: string | null;
721
+ relative_position: string | null;
722
+ stop_city: string | null;
624
723
  }
625
724
 
725
+ /**
726
+ * Function to import GTFS files into the database
727
+ *
728
+ * @param initialConfig
729
+ */
626
730
  declare function importGtfs(initialConfig: Config): Promise<void>;
627
731
 
732
+ /**
733
+ * Main function to update GTFS Realtime data
734
+ */
628
735
  declare function updateGtfsRealtime(initialConfig: Config): Promise<void>;
629
736
 
630
737
  declare const exportGtfs: (initialConfig: Config) => Promise<void>;
@@ -643,7 +750,41 @@ declare function advancedQuery(table: string, advancedQueryOptions: {
643
750
  orderBy?: SqlOrderBy;
644
751
  join?: JoinOptions[];
645
752
  options?: QueryOptions;
646
- }): Array<Record<string, any>>;
753
+ }): Array<Record<string, SqlValue>>;
754
+
755
+ /**
756
+ * Prepares a directory for saving files by clearing its contents
757
+ * @param {string} exportPath - Path to the directory to prepare
758
+ * @returns {Promise<void>}
759
+ * @example
760
+ * await prepDirectory('./output');
761
+ */
762
+ declare function prepDirectory(exportPath: string): Promise<void>;
763
+ /**
764
+ * Extracts contents of a zip file to specified directory
765
+ * @param {string} zipfilePath - Path to the zip file
766
+ * @param {string} exportPath - Directory to extract contents to
767
+ * @returns {Promise<void>}
768
+ * @throws {Error} If zip file cannot be opened or extracted
769
+ * @example
770
+ * await unzip('./data.zip', './extracted');
771
+ */
772
+ declare function unzip(zipfilePath: string, exportPath: string): Promise<void>;
773
+ /**
774
+ * Generates a safe folder name from input string
775
+ * Converts to snake_case and removes unsafe characters
776
+ * @param {string} folderName - Input string to convert to folder name
777
+ * @returns {string} Sanitized folder name
778
+ * @example
779
+ * generateFolderName('My Folder!') // returns 'my_folder'
780
+ */
781
+ declare function generateFolderName(folderName: string): string;
782
+ /**
783
+ * Converts a tilde path to a full path
784
+ * @param pathWithTilde The path to convert
785
+ * @returns The full path
786
+ */
787
+ declare function untildify(pathWithTilde: string): string;
647
788
 
648
789
  declare function getAgencies<Fields extends keyof Agency>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Agency, Fields>[];
649
790
 
@@ -758,4 +899,4 @@ declare function getRunEvents<Fields extends keyof RunEvent>(query?: SqlWhere, f
758
899
 
759
900
  declare function getRunsPieces<Fields extends keyof RunPiece>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RunPiece, Fields>[];
760
901
 
761
- export { type Agency, type Area, type Attribution, type BoardAlight, type BookingRule, type Calendar, type CalendarAttribute, type CalendarDate, type Config, type ConfigAgency, type Deadhead, type DeadheadTime, type Direction, type FareAttribute, type FareLegRule, type FareMedia, type FareProduct, type FareRule, type FareTransferRule, type FeedInfo, type Frequency, type JoinOptions, type Level, type Location, type LocationGroup, type LocationGroupStop, type Model, type ModelColumn, type Network, type OpsLocation, type Pathway, type QueryOptions, type QueryResult, type RideFeedInfo, type RiderCategory, type RiderTrip, type Ridership, type Route, type RouteAttribute, type RouteNetwork, type RunEvent, type RunPiece, type ServiceAlert, type Shape, type SqlOrderBy, type SqlValue, type SqlWhere, type Stop, type StopArea, type StopAttribute, type StopTime, type StopTimeUpdate, type Timeframe, type Timetable, type TimetableNote, type TimetableNotesReference, type TimetablePage, type TimetableStopOrder, type Transfer, type Translation, type Trip, type TripCapacity, type TripUpdate, type TripsDatedVehicleJourney, type UnixTimestamp, type VehiclePosition, advancedQuery, closeDb, deleteDb, exportGtfs, getAgencies, getAreas, getAttributions, getBoardAlights, getBookingRules, getCalendarAttributes, getCalendarDates, getCalendars, getDeadheadTimes, getDeadheads, getDirections, getFareAttributes, getFareLegRules, getFareMedia, getFareProducts, getFareRules, getFareTransferRules, getFeedInfo, getFrequencies, getLevels, getLocationGroupStops, getLocationGroups, getLocations, getNetworks, getOpsLocations, getPathways, getRideFeedInfo, getRiderCategories, getRiderTrips, getRidership, getRouteAttributes, getRouteNetworks, getRoutes, getRunEvents, getRunsPieces, getServiceAlerts, getServiceIdsByDate, getShapes, getShapesAsGeoJSON, getStopAreas, getStopAttributes, getStopTimeUpdates, getStops, getStopsAsGeoJSON, getStoptimes, getTimeframes, getTimetableNotes, getTimetableNotesReferences, getTimetablePages, getTimetableStopOrders, getTimetables, getTransfers, getTranslations, getTripCapacities, getTripUpdates, getTrips, getTripsDatedVehicleJourneys, getVehiclePositions, importGtfs, openDb, updateGtfsRealtime };
902
+ export { type Agency, type Area, type Attribution, type BoardAlight, type BookingRule, type Calendar, type CalendarAttribute, type CalendarDate, type Config, type ConfigAgency, type Deadhead, type DeadheadTime, type Direction, type FareAttribute, type FareLegRule, type FareMedia, type FareProduct, type FareRule, type FareTransferRule, type FeedInfo, type Frequency, type JoinOptions, type Level, type Location, type LocationGroup, type LocationGroupStop, type Model, type ModelColumn, type Network, type OpsLocation, type Pathway, type QueryOptions, type QueryResult, type RideFeedInfo, type RiderCategory, type RiderTrip, type Ridership, type Route, type RouteAttribute, type RouteNetwork, type RunEvent, type RunPiece, type ServiceAlert, type Shape, type SqlOrderBy, type SqlValue, type SqlWhere, type Stop, type StopArea, type StopAttribute, type StopTime, type StopTimeUpdate, type TableNames, type Timeframe, type Timetable, type TimetableNote, type TimetableNotesReference, type TimetablePage, type TimetableStopOrder, type Transfer, type Translation, type Trip, type TripCapacity, type TripUpdate, type TripsDatedVehicleJourney, type UnixTimestamp, type VehiclePosition, advancedQuery, closeDb, deleteDb, exportGtfs, generateFolderName, getAgencies, getAreas, getAttributions, getBoardAlights, getBookingRules, getCalendarAttributes, getCalendarDates, getCalendars, getDeadheadTimes, getDeadheads, getDirections, getFareAttributes, getFareLegRules, getFareMedia, getFareProducts, getFareRules, getFareTransferRules, getFeedInfo, getFrequencies, getLevels, getLocationGroupStops, getLocationGroups, getLocations, getNetworks, getOpsLocations, getPathways, getRideFeedInfo, getRiderCategories, getRiderTrips, getRidership, getRouteAttributes, getRouteNetworks, getRoutes, getRunEvents, getRunsPieces, getServiceAlerts, getServiceIdsByDate, getShapes, getShapesAsGeoJSON, getStopAreas, getStopAttributes, getStopTimeUpdates, getStops, getStopsAsGeoJSON, getStoptimes, getTimeframes, getTimetableNotes, getTimetableNotesReferences, getTimetablePages, getTimetableStopOrders, getTimetables, getTransfers, getTranslations, getTripCapacities, getTripUpdates, getTrips, getTripsDatedVehicleJourneys, getVehiclePositions, importGtfs, openDb, prepDirectory, untildify, unzip, updateGtfsRealtime };