@@ -3,37 +3,171 @@ import type { Database } from 'better-sqlite3';
33
44export type UnixTimestamp = number ;
55
6- export interface ConfigAgency {
7- exclude ?: string [ ] ;
8- url ?: string ;
9- path ?: string ;
6+ export type TableNames =
7+ | 'agency'
8+ | 'stops'
9+ | 'routes'
10+ | 'trips'
11+ | 'stop_times'
12+ | 'calendar'
13+ | 'calendar_dates'
14+ | 'fare_attributes'
15+ | 'fare_rules'
16+ | 'timeframes'
17+ | 'rider_categories'
18+ | 'fare_media'
19+ | 'fare_products'
20+ | 'fare_leg_rules'
21+ | 'fare_leg_join_rules'
22+ | 'fare_transfer_rules'
23+ | 'areas'
24+ | 'stop_areas'
25+ | 'networks'
26+ | 'route_networks'
27+ | 'shapes'
28+ | 'frequencies'
29+ | 'transfers'
30+ | 'pathways'
31+ | 'levels'
32+ | 'location_groups'
33+ | 'location_group_stops'
34+ | 'locations'
35+ | 'booking_rules'
36+ | 'translations'
37+ | 'feed_info'
38+ | 'attributions' ;
39+
40+ interface BaseConfigAgency {
41+ /**
42+ * An array of GTFS file names (without .txt) to exclude when importing
43+ */
44+ exclude ?: TableNames [ ] ;
45+ /**
46+ * An object of HTTP headers in key:value format to use when fetching GTFS from the url specified
47+ */
1048 headers ?: Record < string , string > ;
49+ /**
50+ * Settings for fetching GTFS-Realtime alerts
51+ */
1152 realtimeAlerts ?: {
53+ /**
54+ * URL for fetching GTFS-Realtime alerts
55+ */
1256 url : string ;
57+ /**
58+ * Headers to use when fetching GTFS-Realtime alerts
59+ */
1360 headers ?: Record < string , string > ;
1461 } ;
62+ /**
63+ * Settings for fetching GTFS-Realtime trip updates
64+ */
1565 realtimeTripUpdates ?: {
66+ /**
67+ * URL for fetching GTFS-Realtime trip updates
68+ */
1669 url : string ;
70+ /**
71+ * Headers to use when fetching GTFS-Realtime trip updates
72+ */
1773 headers ?: Record < string , string > ;
1874 } ;
75+ /**
76+ * Settings for fetching GTFS-Realtime vehicle positions
77+ */
1978 realtimeVehiclePositions ?: {
79+ /**
80+ * URL for fetching GTFS-Realtime vehicle positions
81+ */
2082 url : string ;
83+ /**
84+ * Headers to use when fetching GTFS-Realtime vehicle positions
85+ */
2186 headers ?: Record < string , string > ;
2287 } ;
88+ /**
89+ * A prefix to be added to every ID field maintain uniqueness when importing multiple GTFS from multiple agencies
90+ */
2391 prefix ?: string ;
2492}
2593
94+ export type ConfigAgency = BaseConfigAgency &
95+ (
96+ | {
97+ /**
98+ * The URL to a zipped GTFS file. Required if path not present
99+ */
100+ url : string ;
101+ }
102+ | {
103+ /**
104+ * A path to a zipped GTFS file or a directory of unzipped .txt files. Required if url is not present
105+ */
106+ path : string ;
107+ }
108+ ) ;
109+
26110export interface Config {
111+ /**
112+ * An existing database instance to use instead of relying on node-gtfs to connect.
113+ */
27114 db ?: Database ;
115+ /**
116+ * A path to an SQLite database. Defaults to using an in-memory database.
117+ */
28118 sqlitePath ?: string ;
119+ /**
120+ * Amount of time in seconds to allow GTFS-Realtime data to be stored in database before allowing to be deleted.
121+ *
122+ * Note: is an integer
123+ *
124+ * @defaultValue 0
125+ */
29126 gtfsRealtimeExpirationSeconds ?: number ;
127+ /**
128+ * The number of milliseconds to wait before throwing an error when downloading GTFS.
129+ *
130+ * Note: is an integer
131+ */
30132 downloadTimeout ?: number ;
133+ /**
134+ * Options passed to `csv-parse` for parsing GTFS CSV files.
135+ */
31136 csvOptions ?: Options ;
137+ /**
138+ * A path to a directory to put exported GTFS files.
139+ *
140+ * @defaultValue `gtfs-export/<agency_name>`
141+ */
32142 exportPath ?: string ;
143+ /**
144+ * Whether or not to ignore unique constraints on ids when importing GTFS, such as `trip_id`, `calendar_id`.
145+ *
146+ * @defaultValue false
147+ */
33148 ignoreDuplicates ?: boolean ;
149+ /**
150+ * Whether or not to ignore errors during the import process. If true, failed files will be skipped while the rest are processed.
151+ *
152+ * @defaultValue false
153+ */
34154 ignoreErrors ?: boolean ;
155+ /**
156+ * An array of GTFS files to be imported, and which files to exclude.
157+ */
35158 agencies : ConfigAgency [ ] ;
159+ /**
160+ * Whether or not to print output to the console.
161+ *
162+ * @defaulValue true
163+ */
36164 verbose ?: boolean ;
165+ /**
166+ * An optional custom logger instead of the build in console.log
167+ *
168+ * @param message
169+ * @returns
170+ */
37171 logFunction ?: ( message : string ) => void ;
38172}
39173
@@ -52,7 +186,7 @@ export interface ModelColumn {
52186}
53187
54188export interface Model {
55- filenameBase : string ;
189+ filenameBase : TableNames ;
56190 filenameExtension ?: string ;
57191 extension ?: string ;
58192 nonstandard ?: boolean ;
0 commit comments