gtfs 4.13.4 → 4.14.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
@@ -2,7 +2,26 @@ import CsvParse from 'csv-parse';
2
2
  import Database from 'better-sqlite3';
3
3
  import { FeatureCollection } from 'geojson';
4
4
 
5
- interface IConfig {
5
+ interface ConfigAgency {
6
+ exclude?: string[];
7
+ url?: string;
8
+ path?: string;
9
+ headers?: Record<string, string>;
10
+ realtimeAlerts?: {
11
+ url: string;
12
+ headers?: Record<string, string>;
13
+ };
14
+ realtimeTripUpdates?: {
15
+ url: string;
16
+ headers?: Record<string, string>;
17
+ };
18
+ realtimeVehiclePositions?: {
19
+ url: string;
20
+ headers?: Record<string, string>;
21
+ };
22
+ prefix?: string;
23
+ }
24
+ interface Config {
6
25
  db?: Database.Database;
7
26
  sqlitePath?: string;
8
27
  ignoreDuplicates?: boolean;
@@ -11,15 +30,7 @@ interface IConfig {
11
30
  csvOptions?: CsvParse.Options;
12
31
  exportPath?: string;
13
32
  ignoreErrors?: boolean;
14
- agencies: {
15
- exclude?: string[];
16
- url?: string;
17
- path?: string;
18
- headers?: Record<string, string>;
19
- realtimeHeaders?: Record<string, string>;
20
- realtimeUrls?: string[];
21
- prefix?: string;
22
- }[];
33
+ agencies: ConfigAgency[];
23
34
  verbose?: boolean;
24
35
  logFunction?: (message: string) => void;
25
36
  }
@@ -37,11 +48,282 @@ interface QueryOptions {
37
48
  bounding_box_side_m?: number;
38
49
  }
39
50
  type SqlResults = Array<Record<string, any>>;
51
+ interface Agency {
52
+ agency_id?: string;
53
+ agency_name: string;
54
+ agency_url: string;
55
+ agency_timezone: string;
56
+ agency_lang?: string;
57
+ agency_phone?: string;
58
+ agency_fare_url?: string;
59
+ agency_email?: string;
60
+ }
61
+ interface Area {
62
+ area_id: string;
63
+ area_name?: string;
64
+ }
65
+ interface Attribution {
66
+ attribution_id?: string;
67
+ agency_id?: string;
68
+ route_id?: string;
69
+ trip_id?: string;
70
+ organization_name: string;
71
+ is_producer?: 0 | 1;
72
+ is_operator?: 0 | 1;
73
+ is_authority?: 0 | 1;
74
+ attribution_url?: string;
75
+ attribution_email?: string;
76
+ attribution_phone?: string;
77
+ }
78
+ interface BookingRule {
79
+ booking_rule_id: string;
80
+ booking_type: 0 | 1 | 2;
81
+ prior_notice_duration_min?: number;
82
+ prior_notice_duration_max?: number;
83
+ prior_notice_last_day?: number;
84
+ prior_notice_last_time?: string;
85
+ prior_notice_last_timestamp?: number;
86
+ prior_notice_start_day?: number;
87
+ prior_notice_start_time?: string;
88
+ prior_notice_start_timestamp?: number;
89
+ prior_notice_service_id?: string;
90
+ message?: string;
91
+ pickup_message?: string;
92
+ drop_off_message?: string;
93
+ phone_number?: string;
94
+ info_url?: string;
95
+ booking_url?: string;
96
+ }
97
+ interface Calendar {
98
+ service_id: string;
99
+ monday: 0 | 1;
100
+ tuesday: 0 | 1;
101
+ wednesday: 0 | 1;
102
+ thursday: 0 | 1;
103
+ friday: 0 | 1;
104
+ saturday: 0 | 1;
105
+ sunday: 0 | 1;
106
+ start_date: number;
107
+ end_date: number;
108
+ }
109
+ interface CalendarDate {
110
+ service_id: string;
111
+ date: number;
112
+ exception_type: 1 | 2;
113
+ holiday_name?: string;
114
+ }
115
+ interface FareAttribute {
116
+ fare_id: string;
117
+ price: number;
118
+ currency_type: string;
119
+ payment_method: 0 | 1;
120
+ transfers: 0 | 1 | 2;
121
+ agency_id?: string;
122
+ transfer_duration?: number;
123
+ }
124
+ interface FareLegRule {
125
+ leg_group_id?: string;
126
+ network_id?: string;
127
+ from_area_id?: string;
128
+ to_area_id?: string;
129
+ from_timeframe_group_id?: string;
130
+ to_timeframe_group_id?: string;
131
+ fare_product_id: string;
132
+ rule_priority?: number;
133
+ }
134
+ interface FareMedia {
135
+ fare_media_id: string;
136
+ fare_media_name?: string;
137
+ fare_media_type: 0 | 1 | 2 | 3 | 4;
138
+ }
139
+ interface FareProduct {
140
+ fare_product_id: string;
141
+ fare_product_name?: string;
142
+ fare_media_id?: string;
143
+ amount: number;
144
+ currency: string;
145
+ }
146
+ interface FareRule {
147
+ fare_id: string;
148
+ route_id?: string;
149
+ origin_id?: string;
150
+ destination_id?: string;
151
+ contains_id?: string;
152
+ }
153
+ interface FareTransferRule {
154
+ from_leg_group_id?: string;
155
+ to_leg_group_id?: string;
156
+ transfer_count?: number;
157
+ duration_limit: number;
158
+ duration_limit_type?: 0 | 1 | 2 | 3;
159
+ fare_transfer_type: 0 | 1 | 2;
160
+ fare_product_id?: string;
161
+ }
162
+ interface FeedInfo {
163
+ feed_publisher_name: string;
164
+ feed_publisher_url: string;
165
+ feed_lang: string;
166
+ default_lang?: string;
167
+ feed_start_date?: number;
168
+ feed_end_date?: number;
169
+ feed_version?: string;
170
+ feed_contact_email?: string;
171
+ feed_contact_url?: string;
172
+ }
173
+ interface Frequency {
174
+ trip_id: string;
175
+ start_time: string;
176
+ start_timestamp: number;
177
+ end_time: string;
178
+ end_timestamp: number;
179
+ headway_secs: number;
180
+ exact_times?: 0 | 1;
181
+ }
182
+ interface Level {
183
+ level_id: string;
184
+ level_index: number;
185
+ level_name?: string;
186
+ }
187
+ interface LocationGroupStop {
188
+ location_group_id: string;
189
+ stop_id: string;
190
+ }
191
+ interface LocationGroup {
192
+ location_group_id: string;
193
+ location_group_name?: string;
194
+ }
195
+ interface Location {
196
+ geojson: string;
197
+ }
198
+ interface Network {
199
+ network_id: string;
200
+ network_name?: string;
201
+ }
202
+ interface Pathway {
203
+ pathway_id: string;
204
+ from_stop_id: string;
205
+ to_stop_id: string;
206
+ pathway_mode: 1 | 2 | 3 | 4 | 5 | 6 | 7;
207
+ is_bidirectional: 0 | 1;
208
+ length?: number;
209
+ traversal_time?: number;
210
+ stair_count?: number;
211
+ max_slope?: number;
212
+ min_width?: number;
213
+ signposted_as?: string;
214
+ reversed_signposted_as?: string;
215
+ }
216
+ interface RouteNetwork {
217
+ network_id: string;
218
+ route_id: string;
219
+ }
220
+ interface Route {
221
+ route_id: string;
222
+ agency_id?: string;
223
+ route_short_name?: string;
224
+ route_long_name?: string;
225
+ route_desc?: string;
226
+ route_type: number;
227
+ route_url?: string;
228
+ route_color?: string;
229
+ route_text_color?: string;
230
+ route_sort_order?: number;
231
+ continuous_pickup?: 0 | 1 | 2 | 3;
232
+ continuous_drop_off?: 0 | 1 | 2 | 3;
233
+ network_id?: string;
234
+ }
235
+ interface Shape {
236
+ shape_id: string;
237
+ shape_pt_lat: number;
238
+ shape_pt_lon: number;
239
+ shape_pt_sequence: number;
240
+ shape_dist_traveled?: number;
241
+ }
242
+ interface StopArea {
243
+ area_id: string;
244
+ stop_id: string;
245
+ }
246
+ interface StopTime {
247
+ trip_id: string;
248
+ arrival_time?: string;
249
+ arrival_timestamp?: number;
250
+ departure_time?: string;
251
+ departure_timestamp?: number;
252
+ location_group_id?: string;
253
+ location_id?: string;
254
+ stop_id?: string;
255
+ stop_sequence: number;
256
+ stop_headsign?: string;
257
+ start_pickup_drop_off_window?: string;
258
+ start_pickup_drop_off_window_timestamp?: number;
259
+ pickup_type?: 0 | 1 | 2 | 3;
260
+ drop_off_type?: 0 | 1 | 2 | 3;
261
+ continuous_pickup?: 0 | 1 | 2 | 3;
262
+ continuous_drop_off?: 0 | 1 | 2 | 3;
263
+ shape_dist_traveled?: number;
264
+ timepoint?: 0 | 1;
265
+ pickup_booking_rule_id?: string;
266
+ drop_off_booking_rule_id?: string;
267
+ }
268
+ interface Stop {
269
+ stop_id: string;
270
+ stop_code?: string;
271
+ stop_name?: string;
272
+ tts_stop_name?: string;
273
+ stop_desc?: string;
274
+ stop_lat?: number;
275
+ stop_lon?: number;
276
+ zone_id?: string;
277
+ stop_url?: string;
278
+ location_type?: 0 | 1 | 2 | 3 | 4;
279
+ parent_station?: string;
280
+ stop_timezone?: string;
281
+ wheelchair_boarding?: 0 | 1 | 2;
282
+ level_id?: string;
283
+ platform_code?: string;
284
+ }
285
+ interface Timeframe {
286
+ timeframe_group_id: string;
287
+ start_time?: string;
288
+ end_time?: string;
289
+ service_id: string;
290
+ }
291
+ interface Transfer {
292
+ from_stop_id?: string;
293
+ to_stop_id?: string;
294
+ from_route_id?: string;
295
+ to_route_id?: string;
296
+ from_trip_id?: string;
297
+ to_trip_id?: string;
298
+ transfer_type: 0 | 1 | 2 | 3 | 4 | 5;
299
+ min_transfer_time?: number;
300
+ }
301
+ interface Translation {
302
+ table_name: string;
303
+ field_name: string;
304
+ language: string;
305
+ translation: string;
306
+ record_id?: string;
307
+ record_sub_id?: string;
308
+ field_value?: string;
309
+ }
310
+ interface Trip {
311
+ route_id: string;
312
+ service_id: string;
313
+ trip_id: string;
314
+ trip_headsign?: string;
315
+ trip_short_name?: string;
316
+ direction_id?: 0 | 1;
317
+ block_id?: string;
318
+ shape_id?: string;
319
+ wheelchair_accessible?: 0 | 1 | 2;
320
+ bikes_allowed?: 0 | 1 | 2;
321
+ }
40
322
 
41
- declare function importGtfs(initialConfig: IConfig): Promise<void>;
42
- declare function updateGtfsRealtime(initialConfig: IConfig): Promise<void>;
323
+ declare function importGtfs(initialConfig: Config): Promise<void>;
324
+ declare function updateGtfsRealtime(initialConfig: Config): Promise<void>;
43
325
 
44
- declare const exportGtfs: (initialConfig: IConfig) => Promise<void>;
326
+ declare const exportGtfs: (initialConfig: Config) => Promise<void>;
45
327
 
46
328
  declare function openDb(config?: {
47
329
  db?: Database.Database;
@@ -59,67 +341,67 @@ declare function advancedQuery(table: string, advancedQueryOptions: {
59
341
  options?: QueryOptions;
60
342
  }): Array<Record<string, any>>;
61
343
 
62
- declare function getAgencies(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
344
+ declare function getAgencies(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Agency[];
63
345
 
64
- declare function getAreas(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
346
+ declare function getAreas(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Area[];
65
347
 
66
- declare function getAttributions(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
348
+ declare function getAttributions(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Attribution[];
67
349
 
68
- declare function getBookingRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
350
+ declare function getBookingRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): BookingRule[];
69
351
 
70
- declare function getCalendarDates(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
352
+ declare function getCalendarDates(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): CalendarDate[];
71
353
 
72
- declare function getCalendars(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
354
+ declare function getCalendars(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Calendar[];
73
355
 
74
- declare function getFareAttributes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
356
+ declare function getFareAttributes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareAttribute[];
75
357
 
76
- declare function getFareLegRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
358
+ declare function getFareLegRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareLegRule[];
77
359
 
78
- declare function getFareMedia(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
360
+ declare function getFareMedia(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareMedia[];
79
361
 
80
- declare function getFareProducts(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
362
+ declare function getFareProducts(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareProduct[];
81
363
 
82
- declare function getFareRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
364
+ declare function getFareRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareRule[];
83
365
 
84
- declare function getFareTransferRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
366
+ declare function getFareTransferRules(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FareTransferRule[];
85
367
 
86
- declare function getFeedInfo(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
368
+ declare function getFeedInfo(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): FeedInfo[];
87
369
 
88
- declare function getFrequencies(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
370
+ declare function getFrequencies(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Frequency[];
89
371
 
90
- declare function getLevels(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
372
+ declare function getLevels(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Level[];
91
373
 
92
- declare function getLocationGroups(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
374
+ declare function getLocationGroups(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): LocationGroup[];
93
375
 
94
- declare function getLocationGroupStops(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
376
+ declare function getLocationGroupStops(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): LocationGroupStop[];
95
377
 
96
- declare function getLocations(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
378
+ declare function getLocations(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Location[];
97
379
 
98
- declare function getNetworks(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
380
+ declare function getNetworks(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Network[];
99
381
 
100
- declare function getPathways(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
382
+ declare function getPathways(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Pathway[];
101
383
 
102
- declare function getRouteNetworks(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
384
+ declare function getRouteNetworks(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): RouteNetwork[];
103
385
 
104
- declare function getRoutes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
386
+ declare function getRoutes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Route[];
105
387
 
106
- declare function getShapes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
388
+ declare function getShapes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Shape[];
107
389
  declare function getShapesAsGeoJSON(query?: SqlWhere, options?: QueryOptions): FeatureCollection;
108
390
 
109
- declare function getStopAreas(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
391
+ declare function getStopAreas(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): StopArea[];
110
392
 
111
- declare function getStops(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
393
+ declare function getStops(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Stop[];
112
394
  declare function getStopsAsGeoJSON(query?: SqlWhere, options?: QueryOptions): FeatureCollection;
113
395
 
114
- declare function getStoptimes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
396
+ declare function getStoptimes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): StopTime[];
115
397
 
116
- declare function getTimeframes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
398
+ declare function getTimeframes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Timeframe[];
117
399
 
118
- declare function getTransfers(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
400
+ declare function getTransfers(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Transfer[];
119
401
 
120
- declare function getTranslations(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
402
+ declare function getTranslations(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Translation[];
121
403
 
122
- declare function getTrips(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
404
+ declare function getTrips(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): Trip[];
123
405
 
124
406
  declare function getCalendarAttributes(query?: SqlWhere, fields?: SqlSelect, orderBy?: SqlOrderBy, options?: QueryOptions): SqlResults;
125
407