gtfs 4.11.3 → 4.13.0

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 (199) hide show
  1. package/README.md +27 -5
  2. package/dist/bin/gtfs-export.d.ts +1 -0
  3. package/dist/bin/gtfs-export.js +3646 -0
  4. package/dist/bin/gtfs-export.js.map +1 -0
  5. package/dist/bin/gtfs-import.d.ts +1 -0
  6. package/dist/bin/gtfs-import.js +4146 -0
  7. package/dist/bin/gtfs-import.js.map +1 -0
  8. package/dist/bin/gtfsrealtime-update.d.ts +1 -0
  9. package/dist/bin/gtfsrealtime-update.js +3802 -0
  10. package/dist/bin/gtfsrealtime-update.js.map +1 -0
  11. package/dist/index.d.ts +169 -0
  12. package/dist/index.js +5205 -0
  13. package/dist/index.js.map +1 -0
  14. package/package.json +27 -13
  15. package/.eslintrc.json +0 -28
  16. package/.github/workflows/nodejs.yml +0 -21
  17. package/.husky/pre-commit +0 -4
  18. package/@types/index.d.ts +0 -606
  19. package/@types/tests.ts +0 -31
  20. package/@types/tsconfig.json +0 -17
  21. package/CHANGELOG.md +0 -895
  22. package/bin/gtfs-export.js +0 -42
  23. package/bin/gtfs-import.js +0 -52
  24. package/bin/gtfsrealtime-update.js +0 -35
  25. package/config-sample-full.json +0 -20
  26. package/config-sample-rtupdates.json +0 -16
  27. package/config-sample.json +0 -8
  28. package/docs/images/node-gtfs-logo.svg +0 -18
  29. package/index.js +0 -1
  30. package/lib/advancedQuery.js +0 -36
  31. package/lib/db.js +0 -92
  32. package/lib/export.js +0 -141
  33. package/lib/file-utils.js +0 -103
  34. package/lib/geojson-utils.js +0 -138
  35. package/lib/gtfs/agencies.js +0 -32
  36. package/lib/gtfs/areas.js +0 -27
  37. package/lib/gtfs/attributions.js +0 -32
  38. package/lib/gtfs/booking-rules.js +0 -32
  39. package/lib/gtfs/calendar-dates.js +0 -32
  40. package/lib/gtfs/calendars.js +0 -32
  41. package/lib/gtfs/fare-attributes.js +0 -32
  42. package/lib/gtfs/fare-leg-rules.js +0 -32
  43. package/lib/gtfs/fare-media.js +0 -32
  44. package/lib/gtfs/fare-products.js +0 -32
  45. package/lib/gtfs/fare-rules.js +0 -32
  46. package/lib/gtfs/fare-transfer-rules.js +0 -32
  47. package/lib/gtfs/feed-info.js +0 -32
  48. package/lib/gtfs/frequencies.js +0 -32
  49. package/lib/gtfs/levels.js +0 -27
  50. package/lib/gtfs/location-group-stops.js +0 -32
  51. package/lib/gtfs/location-groups.js +0 -32
  52. package/lib/gtfs/locations.js +0 -32
  53. package/lib/gtfs/networks.js +0 -32
  54. package/lib/gtfs/pathways.js +0 -32
  55. package/lib/gtfs/route-networks.js +0 -32
  56. package/lib/gtfs/routes.js +0 -56
  57. package/lib/gtfs/shapes.js +0 -119
  58. package/lib/gtfs/stop-areas.js +0 -32
  59. package/lib/gtfs/stop-times.js +0 -32
  60. package/lib/gtfs/stops.js +0 -136
  61. package/lib/gtfs/timeframes.js +0 -32
  62. package/lib/gtfs/transfers.js +0 -32
  63. package/lib/gtfs/translations.js +0 -32
  64. package/lib/gtfs/trips.js +0 -27
  65. package/lib/gtfs-plus/calendar-attributes.js +0 -32
  66. package/lib/gtfs-plus/directions.js +0 -32
  67. package/lib/gtfs-plus/route-attributes.js +0 -32
  68. package/lib/gtfs-plus/stop-attributes.js +0 -32
  69. package/lib/gtfs-realtime/service-alerts.js +0 -34
  70. package/lib/gtfs-realtime/stop-time-updates.js +0 -32
  71. package/lib/gtfs-realtime/trip-updates.js +0 -32
  72. package/lib/gtfs-realtime/vehicle-positions.js +0 -32
  73. package/lib/gtfs-ride/board-alights.js +0 -32
  74. package/lib/gtfs-ride/ride-feed-infos.js +0 -32
  75. package/lib/gtfs-ride/rider-trips.js +0 -32
  76. package/lib/gtfs-ride/riderships.js +0 -32
  77. package/lib/gtfs-ride/trip-capacities.js +0 -32
  78. package/lib/gtfs.js +0 -261
  79. package/lib/import.js +0 -803
  80. package/lib/log-utils.js +0 -73
  81. package/lib/non-standard/timetable-notes-references.js +0 -32
  82. package/lib/non-standard/timetable-notes.js +0 -32
  83. package/lib/non-standard/timetable-pages.js +0 -32
  84. package/lib/non-standard/timetable-stop-order.js +0 -32
  85. package/lib/non-standard/timetables.js +0 -32
  86. package/lib/non-standard/trips-dated-vehicle-journey.js +0 -32
  87. package/lib/ods/deadhead-times.js +0 -32
  88. package/lib/ods/deadheads.js +0 -32
  89. package/lib/ods/ops-locations.js +0 -32
  90. package/lib/ods/run-events.js +0 -32
  91. package/lib/ods/runs-pieces.js +0 -32
  92. package/lib/utils.js +0 -178
  93. package/models/gtfs/agency.js +0 -49
  94. package/models/gtfs/areas.js +0 -19
  95. package/models/gtfs/attributions.js +0 -68
  96. package/models/gtfs/booking-rules.js +0 -92
  97. package/models/gtfs/calendar-dates.js +0 -34
  98. package/models/gtfs/calendar.js +0 -76
  99. package/models/gtfs/fare-attributes.js +0 -48
  100. package/models/gtfs/fare-leg-rules.js +0 -55
  101. package/models/gtfs/fare-media.js +0 -26
  102. package/models/gtfs/fare-products.js +0 -35
  103. package/models/gtfs/fare-rules.js +0 -34
  104. package/models/gtfs/fare-transfer-rules.js +0 -56
  105. package/models/gtfs/feed-info.js +0 -50
  106. package/models/gtfs/frequencies.js +0 -46
  107. package/models/gtfs/levels.js +0 -25
  108. package/models/gtfs/location-group-stops.js +0 -22
  109. package/models/gtfs/location-groups.js +0 -19
  110. package/models/gtfs/locations.js +0 -12
  111. package/models/gtfs/networks.js +0 -20
  112. package/models/gtfs/pathways.js +0 -74
  113. package/models/gtfs/route-networks.js +0 -21
  114. package/models/gtfs/routes.js +0 -79
  115. package/models/gtfs/shapes.js +0 -41
  116. package/models/gtfs/stop-areas.js +0 -20
  117. package/models/gtfs/stop-times.js +0 -120
  118. package/models/gtfs/stops.js +0 -85
  119. package/models/gtfs/timeframes.js +0 -29
  120. package/models/gtfs/transfers.js +0 -56
  121. package/models/gtfs/translations.js +0 -48
  122. package/models/gtfs/trips.js +0 -70
  123. package/models/gtfs-plus/calendar-attributes.js +0 -22
  124. package/models/gtfs-plus/directions.js +0 -29
  125. package/models/gtfs-plus/route-attributes.js +0 -34
  126. package/models/gtfs-plus/stop-attributes.js +0 -35
  127. package/models/gtfs-realtime/service-alert-targets.js +0 -37
  128. package/models/gtfs-realtime/service-alerts.js +0 -60
  129. package/models/gtfs-realtime/stop-time-updates.js +0 -85
  130. package/models/gtfs-realtime/trip-updates.js +0 -75
  131. package/models/gtfs-realtime/vehicle-positions.js +0 -135
  132. package/models/gtfs-ride/board-alight.js +0 -132
  133. package/models/gtfs-ride/ride-feed-info.js +0 -40
  134. package/models/gtfs-ride/rider-trip.js +0 -113
  135. package/models/gtfs-ride/ridership.js +0 -127
  136. package/models/gtfs-ride/trip-capacity.js +0 -51
  137. package/models/models.js +0 -120
  138. package/models/non-standard/timetable-notes-references.js +0 -50
  139. package/models/non-standard/timetable-notes.js +0 -24
  140. package/models/non-standard/timetable-pages.js +0 -23
  141. package/models/non-standard/timetable-stop-order.js +0 -32
  142. package/models/non-standard/timetables.js +0 -144
  143. package/models/non-standard/trips-dated-vehicle-journey.js +0 -34
  144. package/models/ods/deadhead-times.js +0 -65
  145. package/models/ods/deadheads.js +0 -60
  146. package/models/ods/ops-locations.js +0 -46
  147. package/models/ods/run-events.js +0 -70
  148. package/models/ods/runs-pieces.js +0 -59
  149. package/test/fixture/caltrain_20160406.zip +0 -0
  150. package/test/mocha/advanced-query.js +0 -74
  151. package/test/mocha/delete-db.js +0 -62
  152. package/test/mocha/export-gtfs.js +0 -147
  153. package/test/mocha/fare-transfer-rules.js +0 -32
  154. package/test/mocha/get-agencies.js +0 -90
  155. package/test/mocha/get-areas.js +0 -27
  156. package/test/mocha/get-attributions.js +0 -27
  157. package/test/mocha/get-board-alights.js +0 -28
  158. package/test/mocha/get-booking-rules.js +0 -28
  159. package/test/mocha/get-calendar-attributes.js +0 -33
  160. package/test/mocha/get-calendar-dates.js +0 -107
  161. package/test/mocha/get-calendars.js +0 -94
  162. package/test/mocha/get-directions.js +0 -28
  163. package/test/mocha/get-fare-attributes.js +0 -51
  164. package/test/mocha/get-fare-leg-rules.js +0 -27
  165. package/test/mocha/get-fare-media.js +0 -27
  166. package/test/mocha/get-fare-products.js +0 -27
  167. package/test/mocha/get-fare-rules.js +0 -50
  168. package/test/mocha/get-feed-info.js +0 -28
  169. package/test/mocha/get-frequencies.js +0 -28
  170. package/test/mocha/get-levels.js +0 -28
  171. package/test/mocha/get-location-group-stops.js +0 -33
  172. package/test/mocha/get-location-groups.js +0 -28
  173. package/test/mocha/get-locations.js +0 -69
  174. package/test/mocha/get-networks.js +0 -28
  175. package/test/mocha/get-pathways.js +0 -28
  176. package/test/mocha/get-ride-feed-infos.js +0 -24
  177. package/test/mocha/get-rider-trips.js +0 -28
  178. package/test/mocha/get-riderships.js +0 -28
  179. package/test/mocha/get-route-attributes.js +0 -33
  180. package/test/mocha/get-route-networks.js +0 -28
  181. package/test/mocha/get-routes.js +0 -143
  182. package/test/mocha/get-shapes-as-geojson.js +0 -92
  183. package/test/mocha/get-shapes.js +0 -240
  184. package/test/mocha/get-stop-attributes.js +0 -28
  185. package/test/mocha/get-stops-as-geojson.js +0 -87
  186. package/test/mocha/get-stops.js +0 -343
  187. package/test/mocha/get-stoptimes.js +0 -67
  188. package/test/mocha/get-timeframes.js +0 -28
  189. package/test/mocha/get-timetable-pages.js +0 -28
  190. package/test/mocha/get-timetable-stop-orders.js +0 -33
  191. package/test/mocha/get-timetables.js +0 -28
  192. package/test/mocha/get-transfers.js +0 -28
  193. package/test/mocha/get-translations.js +0 -28
  194. package/test/mocha/get-trip-capacities.js +0 -28
  195. package/test/mocha/get-trips.js +0 -53
  196. package/test/mocha/import-gtfs.js +0 -173
  197. package/test/mocha/open-db.js +0 -149
  198. package/test/mocha/raw-query.js +0 -34
  199. package/test/test-config.js +0 -12
@@ -0,0 +1,4146 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bin/gtfs-import.ts
4
+ import yargs from "yargs";
5
+ import { hideBin } from "yargs/helpers";
6
+ import PrettyError from "pretty-error";
7
+
8
+ // src/lib/file-utils.ts
9
+ import path from "node:path";
10
+ import { existsSync } from "node:fs";
11
+ import { mkdir, readFile, rm } from "node:fs/promises";
12
+ import { omit, snakeCase } from "lodash-es";
13
+ import sanitize from "sanitize-filename";
14
+ import untildify from "untildify";
15
+ import StreamZip from "node-stream-zip";
16
+ async function getConfig(argv2) {
17
+ let config;
18
+ let data;
19
+ if (argv2.configPath) {
20
+ try {
21
+ data = await readFile(path.resolve(untildify(argv2.configPath)), "utf8");
22
+ } catch (error) {
23
+ throw new Error(
24
+ `Cannot find configuration file at \`${argv2.configPath}\`. Use config-sample.json as a starting point.`
25
+ );
26
+ }
27
+ try {
28
+ config = Object.assign(JSON.parse(data), argv2);
29
+ } catch (error) {
30
+ throw new Error(
31
+ `Cannot parse configuration file at \`${argv2.configPath}\`. Check to ensure that it is valid JSON.`
32
+ );
33
+ }
34
+ } else if (argv2.gtfsPath || argv2.gtfsUrl || argv2.sqlitePath) {
35
+ const agencies = [];
36
+ if (argv2.gtfsPath) {
37
+ agencies.push({
38
+ path: argv2.gtfsPath
39
+ });
40
+ }
41
+ if (argv2.gtfsUrl) {
42
+ agencies.push({
43
+ url: argv2.gtfsUrl
44
+ });
45
+ }
46
+ config = {
47
+ agencies,
48
+ ...omit(argv2, ["path", "url"])
49
+ };
50
+ } else if (existsSync(path.resolve("./config.json"))) {
51
+ try {
52
+ data = await readFile(path.resolve("./config.json"), "utf8");
53
+ } catch (error) {
54
+ throw new Error(
55
+ `Cannot open configuration file at \`${path.resolve("./config.json")}\`. Check to ensure that it exists. Use config-sample.json as a starting point.`
56
+ );
57
+ }
58
+ try {
59
+ config = Object.assign(JSON.parse(data), argv2);
60
+ console.log("Using configuration from ./config.json");
61
+ } catch (error) {
62
+ throw new Error(
63
+ `Cannot parse configuration file at \`${path.resolve("./config.json")}\`. Check to ensure that it is valid JSON.`
64
+ );
65
+ }
66
+ } else {
67
+ throw new Error(
68
+ "Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
69
+ );
70
+ }
71
+ return config;
72
+ }
73
+ async function unzip(zipfilePath, exportPath) {
74
+ const zip = new StreamZip.async({ file: zipfilePath });
75
+ await zip.extract(null, exportPath);
76
+ await zip.close();
77
+ }
78
+
79
+ // src/lib/log-utils.ts
80
+ import { clearLine, cursorTo } from "node:readline";
81
+ import { noop } from "lodash-es";
82
+ import * as colors from "yoctocolors";
83
+ function log(config) {
84
+ if (config.verbose === false) {
85
+ return noop;
86
+ }
87
+ if (config.logFunction) {
88
+ return config.logFunction;
89
+ }
90
+ return (text, overwrite) => {
91
+ if (overwrite === true && process.stdout.isTTY) {
92
+ clearLine(process.stdout, 0);
93
+ cursorTo(process.stdout, 0);
94
+ } else {
95
+ process.stdout.write("\n");
96
+ }
97
+ process.stdout.write(text);
98
+ };
99
+ }
100
+ function logWarning(config) {
101
+ if (config.logFunction) {
102
+ return config.logFunction;
103
+ }
104
+ return (text) => {
105
+ process.stdout.write(`
106
+ ${formatWarning(text)}
107
+ `);
108
+ };
109
+ }
110
+ function logError(config) {
111
+ if (config.logFunction) {
112
+ return config.logFunction;
113
+ }
114
+ return (text) => {
115
+ process.stdout.write(`
116
+ ${formatError(text)}
117
+ `);
118
+ };
119
+ }
120
+ function formatWarning(text) {
121
+ const warningMessage = `${colors.underline("Warning")}: ${text}`;
122
+ return colors.yellow(warningMessage);
123
+ }
124
+ function formatError(error) {
125
+ const messageText = error instanceof Error ? error.message : error;
126
+ const errorMessage = `${colors.underline("Error")}: ${messageText.replace(
127
+ "Error: ",
128
+ ""
129
+ )}`;
130
+ return colors.red(errorMessage);
131
+ }
132
+
133
+ // src/lib/import.ts
134
+ import path2 from "node:path";
135
+ import { createReadStream, existsSync as existsSync2, lstatSync } from "node:fs";
136
+ import { cp, readdir, rename, readFile as readFile2, rm as rm2, writeFile } from "node:fs/promises";
137
+ import { parse } from "csv-parse";
138
+ import pluralize from "pluralize";
139
+ import stripBomStream from "strip-bom-stream";
140
+ import { temporaryDirectory } from "tempy";
141
+ import untildify3 from "untildify";
142
+ import mapSeries from "promise-map-series";
143
+ import GtfsRealtimeBindings from "gtfs-realtime-bindings";
144
+ import sqlString2 from "sqlstring-sqlite";
145
+
146
+ // src/models/gtfs/agency.ts
147
+ var model = {
148
+ filenameBase: "agency",
149
+ filenameExtension: "txt",
150
+ schema: [
151
+ {
152
+ name: "agency_id",
153
+ type: "text",
154
+ primary: true,
155
+ prefix: true
156
+ },
157
+ {
158
+ name: "agency_name",
159
+ type: "text",
160
+ required: true,
161
+ nocase: true
162
+ },
163
+ {
164
+ name: "agency_url",
165
+ type: "text",
166
+ required: true
167
+ },
168
+ {
169
+ name: "agency_timezone",
170
+ type: "text",
171
+ required: true
172
+ },
173
+ {
174
+ name: "agency_lang",
175
+ type: "text",
176
+ nocase: true
177
+ },
178
+ {
179
+ name: "agency_phone",
180
+ type: "text",
181
+ nocase: true
182
+ },
183
+ {
184
+ name: "agency_fare_url",
185
+ type: "text"
186
+ },
187
+ {
188
+ name: "agency_email",
189
+ type: "text",
190
+ nocase: true
191
+ }
192
+ ]
193
+ };
194
+ var agency_default = model;
195
+
196
+ // src/models/gtfs/areas.ts
197
+ var model2 = {
198
+ filenameBase: "areas",
199
+ filenameExtension: "txt",
200
+ schema: [
201
+ {
202
+ name: "area_id",
203
+ type: "text",
204
+ required: true,
205
+ primary: true,
206
+ prefix: true
207
+ },
208
+ {
209
+ name: "area_name",
210
+ type: "text"
211
+ }
212
+ ]
213
+ };
214
+ var areas_default = model2;
215
+
216
+ // src/models/gtfs/attributions.ts
217
+ var model3 = {
218
+ filenameBase: "attributions",
219
+ filenameExtension: "txt",
220
+ schema: [
221
+ {
222
+ name: "attribution_id",
223
+ type: "text",
224
+ primary: true,
225
+ required: true,
226
+ prefix: true
227
+ },
228
+ {
229
+ name: "agency_id",
230
+ type: "text",
231
+ prefix: true
232
+ },
233
+ {
234
+ name: "route_id",
235
+ type: "text",
236
+ prefix: true
237
+ },
238
+ {
239
+ name: "trip_id",
240
+ type: "text",
241
+ prefix: true
242
+ },
243
+ {
244
+ name: "organization_name",
245
+ type: "text",
246
+ required: true,
247
+ nocase: true
248
+ },
249
+ {
250
+ name: "is_producer",
251
+ type: "integer",
252
+ min: 0,
253
+ max: 1
254
+ },
255
+ {
256
+ name: "is_operator",
257
+ type: "integer",
258
+ min: 0,
259
+ max: 1
260
+ },
261
+ {
262
+ name: "is_authority",
263
+ type: "integer",
264
+ min: 0,
265
+ max: 1
266
+ },
267
+ {
268
+ name: "attribution_url",
269
+ type: "text"
270
+ },
271
+ {
272
+ name: "attribution_email",
273
+ type: "text",
274
+ nocase: true
275
+ },
276
+ {
277
+ name: "attribution_phone",
278
+ type: "text",
279
+ nocase: true
280
+ }
281
+ ]
282
+ };
283
+ var attributions_default = model3;
284
+
285
+ // src/models/gtfs/booking-rules.ts
286
+ var model4 = {
287
+ filenameBase: "booking_rules",
288
+ filenameExtension: "txt",
289
+ schema: [
290
+ {
291
+ name: "booking_rule_id",
292
+ type: "text",
293
+ primary: true,
294
+ prefix: true
295
+ },
296
+ {
297
+ name: "booking_type",
298
+ type: "integer",
299
+ required: true,
300
+ min: 0,
301
+ max: 2
302
+ },
303
+ {
304
+ name: "prior_notice_duration_min",
305
+ type: "integer",
306
+ min: 0
307
+ },
308
+ {
309
+ name: "prior_notice_duration_max",
310
+ type: "integer",
311
+ min: 0
312
+ },
313
+ {
314
+ name: "prior_notice_last_day",
315
+ type: "integer",
316
+ min: 0
317
+ },
318
+ {
319
+ name: "prior_notice_last_time",
320
+ type: "text"
321
+ },
322
+ {
323
+ name: "prior_notice_last_timestamp",
324
+ type: "integer",
325
+ index: true
326
+ },
327
+ {
328
+ name: "prior_notice_start_day",
329
+ type: "integer",
330
+ min: 0
331
+ },
332
+ {
333
+ name: "prior_notice_start_time",
334
+ type: "text"
335
+ },
336
+ {
337
+ name: "prior_notice_start_timestamp",
338
+ type: "integer",
339
+ index: true
340
+ },
341
+ {
342
+ name: "prior_notice_service_id",
343
+ type: "text",
344
+ prefix: true
345
+ },
346
+ {
347
+ name: "message",
348
+ type: "text",
349
+ nocase: true
350
+ },
351
+ {
352
+ name: "pickup_message",
353
+ type: "text",
354
+ nocase: true
355
+ },
356
+ {
357
+ name: "drop_off_message",
358
+ type: "text",
359
+ nocase: true
360
+ },
361
+ {
362
+ name: "phone_number",
363
+ type: "text",
364
+ nocase: true
365
+ },
366
+ {
367
+ name: "info_url",
368
+ type: "text"
369
+ },
370
+ {
371
+ name: "booking_url",
372
+ type: "text"
373
+ }
374
+ ]
375
+ };
376
+ var booking_rules_default = model4;
377
+
378
+ // src/models/gtfs/calendar-dates.ts
379
+ var model5 = {
380
+ filenameBase: "calendar_dates",
381
+ filenameExtension: "txt",
382
+ schema: [
383
+ {
384
+ name: "service_id",
385
+ type: "text",
386
+ required: true,
387
+ primary: true,
388
+ prefix: true
389
+ },
390
+ {
391
+ name: "date",
392
+ type: "integer",
393
+ required: true,
394
+ primary: true
395
+ },
396
+ {
397
+ name: "exception_type",
398
+ type: "integer",
399
+ required: true,
400
+ min: 1,
401
+ max: 2,
402
+ index: true
403
+ },
404
+ {
405
+ name: "holiday_name",
406
+ type: "text",
407
+ nocase: true
408
+ }
409
+ ]
410
+ };
411
+ var calendar_dates_default = model5;
412
+
413
+ // src/models/gtfs/calendar.ts
414
+ var model6 = {
415
+ filenameBase: "calendar",
416
+ filenameExtension: "txt",
417
+ schema: [
418
+ {
419
+ name: "service_id",
420
+ type: "text",
421
+ required: true,
422
+ primary: true,
423
+ prefix: true
424
+ },
425
+ {
426
+ name: "monday",
427
+ type: "integer",
428
+ required: true,
429
+ min: 0,
430
+ max: 1
431
+ },
432
+ {
433
+ name: "tuesday",
434
+ type: "integer",
435
+ required: true,
436
+ min: 0,
437
+ max: 1
438
+ },
439
+ {
440
+ name: "wednesday",
441
+ type: "integer",
442
+ required: true,
443
+ min: 0,
444
+ max: 1
445
+ },
446
+ {
447
+ name: "thursday",
448
+ type: "integer",
449
+ required: true,
450
+ min: 0,
451
+ max: 1
452
+ },
453
+ {
454
+ name: "friday",
455
+ type: "integer",
456
+ required: true,
457
+ min: 0,
458
+ max: 1
459
+ },
460
+ {
461
+ name: "saturday",
462
+ type: "integer",
463
+ required: true,
464
+ min: 0,
465
+ max: 1
466
+ },
467
+ {
468
+ name: "sunday",
469
+ type: "integer",
470
+ required: true,
471
+ min: 0,
472
+ max: 1
473
+ },
474
+ {
475
+ name: "start_date",
476
+ type: "integer",
477
+ required: true,
478
+ index: true
479
+ },
480
+ {
481
+ name: "end_date",
482
+ type: "integer",
483
+ required: true,
484
+ index: true
485
+ }
486
+ ]
487
+ };
488
+ var calendar_default = model6;
489
+
490
+ // src/models/gtfs/fare-attributes.ts
491
+ var model7 = {
492
+ filenameBase: "fare_attributes",
493
+ filenameExtension: "txt",
494
+ schema: [
495
+ {
496
+ name: "fare_id",
497
+ type: "text",
498
+ required: true,
499
+ primary: true,
500
+ prefix: true
501
+ },
502
+ {
503
+ name: "price",
504
+ type: "real",
505
+ required: true
506
+ },
507
+ {
508
+ name: "currency_type",
509
+ type: "text",
510
+ required: true
511
+ },
512
+ {
513
+ name: "payment_method",
514
+ type: "integer",
515
+ required: true,
516
+ min: 0,
517
+ max: 1
518
+ },
519
+ {
520
+ name: "transfers",
521
+ type: "integer",
522
+ min: 0,
523
+ max: 2
524
+ },
525
+ {
526
+ name: "agency_id",
527
+ type: "text",
528
+ prefix: true
529
+ },
530
+ {
531
+ name: "transfer_duration",
532
+ type: "integer",
533
+ min: 0
534
+ }
535
+ ]
536
+ };
537
+ var fare_attributes_default = model7;
538
+
539
+ // src/models/gtfs/fare-leg-rules.ts
540
+ var model8 = {
541
+ filenameBase: "fare_leg_rules",
542
+ filenameExtension: "txt",
543
+ schema: [
544
+ {
545
+ name: "leg_group_id",
546
+ type: "text",
547
+ prefix: true
548
+ },
549
+ {
550
+ name: "network_id",
551
+ type: "text",
552
+ primary: true,
553
+ prefix: true
554
+ },
555
+ {
556
+ name: "from_area_id",
557
+ type: "text",
558
+ primary: true,
559
+ prefix: true
560
+ },
561
+ {
562
+ name: "to_area_id",
563
+ type: "text",
564
+ primary: true,
565
+ prefix: true
566
+ },
567
+ {
568
+ name: "from_timeframe_group_id",
569
+ type: "text",
570
+ primary: true,
571
+ prefix: true
572
+ },
573
+ {
574
+ name: "to_timeframe_group_id",
575
+ type: "text",
576
+ primary: true,
577
+ prefix: true
578
+ },
579
+ {
580
+ name: "fare_product_id",
581
+ type: "text",
582
+ required: true,
583
+ primary: true,
584
+ prefix: true
585
+ },
586
+ {
587
+ name: "rule_priority",
588
+ type: "integer",
589
+ min: 0
590
+ }
591
+ ]
592
+ };
593
+ var fare_leg_rules_default = model8;
594
+
595
+ // src/models/gtfs/fare-media.ts
596
+ var model9 = {
597
+ filenameBase: "fare_media",
598
+ filenameExtension: "txt",
599
+ schema: [
600
+ {
601
+ name: "fare_media_id",
602
+ type: "text",
603
+ required: true,
604
+ primary: true,
605
+ prefix: true
606
+ },
607
+ {
608
+ name: "fare_media_name",
609
+ type: "text"
610
+ },
611
+ {
612
+ name: "fare_media_type",
613
+ type: "integer",
614
+ required: true,
615
+ min: 0,
616
+ max: 4
617
+ }
618
+ ]
619
+ };
620
+ var fare_media_default = model9;
621
+
622
+ // src/models/gtfs/fare-products.ts
623
+ var model10 = {
624
+ filenameBase: "fare_products",
625
+ filenameExtension: "txt",
626
+ schema: [
627
+ {
628
+ name: "fare_product_id",
629
+ type: "text",
630
+ required: true,
631
+ primary: true,
632
+ prefix: true
633
+ },
634
+ {
635
+ name: "fare_product_name",
636
+ type: "text"
637
+ },
638
+ {
639
+ name: "fare_media_id",
640
+ type: "text",
641
+ primary: true,
642
+ prefix: true
643
+ },
644
+ {
645
+ name: "amount",
646
+ type: "real",
647
+ required: true
648
+ },
649
+ {
650
+ name: "currency",
651
+ type: "text",
652
+ required: true
653
+ }
654
+ ]
655
+ };
656
+ var fare_products_default = model10;
657
+
658
+ // src/models/gtfs/fare-rules.ts
659
+ var model11 = {
660
+ filenameBase: "fare_rules",
661
+ filenameExtension: "txt",
662
+ schema: [
663
+ {
664
+ name: "fare_id",
665
+ type: "text",
666
+ required: true,
667
+ prefix: true
668
+ },
669
+ {
670
+ name: "route_id",
671
+ type: "text",
672
+ prefix: true
673
+ },
674
+ {
675
+ name: "origin_id",
676
+ type: "text",
677
+ prefix: true
678
+ },
679
+ {
680
+ name: "destination_id",
681
+ type: "text",
682
+ prefix: true
683
+ },
684
+ {
685
+ name: "contains_id",
686
+ type: "text",
687
+ prefix: true
688
+ }
689
+ ]
690
+ };
691
+ var fare_rules_default = model11;
692
+
693
+ // src/models/gtfs/fare-transfer-rules.ts
694
+ var model12 = {
695
+ filenameBase: "fare_transfer_rules",
696
+ filenameExtension: "txt",
697
+ schema: [
698
+ {
699
+ name: "from_leg_group_id",
700
+ type: "text",
701
+ primary: true,
702
+ prefix: true
703
+ },
704
+ {
705
+ name: "to_leg_group_id",
706
+ type: "text",
707
+ primary: true,
708
+ prefix: true
709
+ },
710
+ {
711
+ name: "transfer_count",
712
+ type: "integer",
713
+ min: -1,
714
+ primary: true
715
+ },
716
+ {
717
+ name: "transfer_id",
718
+ type: "text",
719
+ prefix: true
720
+ },
721
+ {
722
+ name: "duration_limit",
723
+ type: "integer",
724
+ min: 0,
725
+ primary: true
726
+ },
727
+ {
728
+ name: "duration_limit_type",
729
+ type: "integer",
730
+ min: 0,
731
+ max: 3
732
+ },
733
+ {
734
+ name: "fare_transfer_type",
735
+ type: "integer",
736
+ min: 0,
737
+ max: 2,
738
+ required: true
739
+ },
740
+ {
741
+ name: "fare_product_id",
742
+ type: "text",
743
+ primary: true,
744
+ prefix: true
745
+ }
746
+ ]
747
+ };
748
+ var fare_transfer_rules_default = model12;
749
+
750
+ // src/models/gtfs/feed-info.ts
751
+ var model13 = {
752
+ filenameBase: "feed_info",
753
+ filenameExtension: "txt",
754
+ schema: [
755
+ {
756
+ name: "feed_publisher_name",
757
+ type: "text",
758
+ required: true,
759
+ nocase: true
760
+ },
761
+ {
762
+ name: "feed_publisher_url",
763
+ type: "text",
764
+ required: true
765
+ },
766
+ {
767
+ name: "feed_lang",
768
+ type: "text",
769
+ required: true
770
+ },
771
+ {
772
+ name: "default_lang",
773
+ type: "text",
774
+ nocase: true
775
+ },
776
+ {
777
+ name: "feed_start_date",
778
+ type: "integer"
779
+ },
780
+ {
781
+ name: "feed_end_date",
782
+ type: "integer"
783
+ },
784
+ {
785
+ name: "feed_version",
786
+ type: "text"
787
+ },
788
+ {
789
+ name: "feed_contact_email",
790
+ type: "text",
791
+ nocase: true
792
+ },
793
+ {
794
+ name: "feed_contact_url",
795
+ type: "text"
796
+ }
797
+ ]
798
+ };
799
+ var feed_info_default = model13;
800
+
801
+ // src/models/gtfs/frequencies.ts
802
+ var model14 = {
803
+ filenameBase: "frequencies",
804
+ filenameExtension: "txt",
805
+ schema: [
806
+ {
807
+ name: "trip_id",
808
+ type: "text",
809
+ required: true,
810
+ primary: true,
811
+ prefix: true
812
+ },
813
+ {
814
+ name: "start_time",
815
+ type: "text",
816
+ required: true,
817
+ primary: true
818
+ },
819
+ {
820
+ name: "start_timestamp",
821
+ type: "integer"
822
+ },
823
+ {
824
+ name: "end_time",
825
+ type: "text",
826
+ required: true
827
+ },
828
+ {
829
+ name: "end_timestamp",
830
+ type: "integer"
831
+ },
832
+ {
833
+ name: "headway_secs",
834
+ type: "integer",
835
+ required: true,
836
+ min: 0
837
+ },
838
+ {
839
+ name: "exact_times",
840
+ type: "integer",
841
+ min: 0,
842
+ max: 1
843
+ }
844
+ ]
845
+ };
846
+ var frequencies_default = model14;
847
+
848
+ // src/models/gtfs/levels.ts
849
+ var model15 = {
850
+ filenameBase: "levels",
851
+ filenameExtension: "txt",
852
+ schema: [
853
+ {
854
+ name: "level_id",
855
+ type: "text",
856
+ primary: true,
857
+ required: true,
858
+ prefix: true
859
+ },
860
+ {
861
+ name: "level_index",
862
+ type: "real",
863
+ required: true
864
+ },
865
+ {
866
+ name: "level_name",
867
+ type: "text",
868
+ nocase: true
869
+ }
870
+ ]
871
+ };
872
+ var levels_default = model15;
873
+
874
+ // src/models/gtfs/location-groups.ts
875
+ var model16 = {
876
+ filenameBase: "location_groups",
877
+ filenameExtension: "txt",
878
+ schema: [
879
+ {
880
+ name: "location_group_id",
881
+ type: "text",
882
+ primary: true,
883
+ prefix: true
884
+ },
885
+ {
886
+ name: "location_group_name",
887
+ type: "text",
888
+ nocase: true
889
+ }
890
+ ]
891
+ };
892
+ var location_groups_default = model16;
893
+
894
+ // src/models/gtfs/location-group-stops.ts
895
+ var model17 = {
896
+ filenameBase: "location_group_stops",
897
+ filenameExtension: "txt",
898
+ schema: [
899
+ {
900
+ name: "location_group_id",
901
+ type: "text",
902
+ prefix: true,
903
+ index: true,
904
+ required: true
905
+ },
906
+ {
907
+ name: "stop_id",
908
+ type: "text",
909
+ required: true,
910
+ prefix: true,
911
+ index: true
912
+ }
913
+ ]
914
+ };
915
+ var location_group_stops_default = model17;
916
+
917
+ // src/models/gtfs/locations.ts
918
+ var model18 = {
919
+ filenameBase: "locations",
920
+ filenameExtension: "geojson",
921
+ schema: [
922
+ {
923
+ name: "geojson",
924
+ type: "text"
925
+ }
926
+ ]
927
+ };
928
+ var locations_default = model18;
929
+
930
+ // src/models/gtfs/networks.ts
931
+ var model19 = {
932
+ filenameBase: "networks",
933
+ filenameExtension: "txt",
934
+ schema: [
935
+ {
936
+ name: "network_id",
937
+ type: "text",
938
+ primary: true,
939
+ required: true,
940
+ prefix: true
941
+ },
942
+ {
943
+ name: "network_name",
944
+ type: "text",
945
+ nocase: true
946
+ }
947
+ ]
948
+ };
949
+ var networks_default = model19;
950
+
951
+ // src/models/gtfs/pathways.ts
952
+ var model20 = {
953
+ filenameBase: "pathways",
954
+ filenameExtension: "txt",
955
+ schema: [
956
+ {
957
+ name: "pathway_id",
958
+ type: "text",
959
+ primary: true,
960
+ required: true,
961
+ prefix: true
962
+ },
963
+ {
964
+ name: "from_stop_id",
965
+ type: "text",
966
+ required: true,
967
+ prefix: true
968
+ },
969
+ {
970
+ name: "to_stop_id",
971
+ type: "text",
972
+ required: true,
973
+ prefix: true
974
+ },
975
+ {
976
+ name: "pathway_mode",
977
+ type: "integer",
978
+ required: true,
979
+ min: 1,
980
+ max: 7
981
+ },
982
+ {
983
+ name: "is_bidirectional",
984
+ type: "integer",
985
+ required: true,
986
+ min: 0,
987
+ max: 1
988
+ },
989
+ {
990
+ name: "length",
991
+ type: "real",
992
+ min: 0
993
+ },
994
+ {
995
+ name: "traversal_time",
996
+ type: "integer",
997
+ min: 0
998
+ },
999
+ {
1000
+ name: "stair_count",
1001
+ type: "integer"
1002
+ },
1003
+ {
1004
+ name: "max_slope",
1005
+ type: "real"
1006
+ },
1007
+ {
1008
+ name: "min_width",
1009
+ type: "real",
1010
+ min: 0
1011
+ },
1012
+ {
1013
+ name: "signposted_as",
1014
+ type: "text",
1015
+ nocase: true
1016
+ },
1017
+ {
1018
+ name: "reversed_signposted_as",
1019
+ type: "text",
1020
+ nocase: true
1021
+ }
1022
+ ]
1023
+ };
1024
+ var pathways_default = model20;
1025
+
1026
+ // src/models/gtfs/route-networks.ts
1027
+ var model21 = {
1028
+ filenameBase: "route_networks",
1029
+ filenameExtension: "txt",
1030
+ schema: [
1031
+ {
1032
+ name: "network_id",
1033
+ type: "text",
1034
+ required: true,
1035
+ prefix: true
1036
+ },
1037
+ {
1038
+ name: "route_id",
1039
+ type: "text",
1040
+ primary: true,
1041
+ index: true,
1042
+ prefix: true
1043
+ }
1044
+ ]
1045
+ };
1046
+ var route_networks_default = model21;
1047
+
1048
+ // src/models/gtfs/routes.ts
1049
+ var model22 = {
1050
+ filenameBase: "routes",
1051
+ filenameExtension: "txt",
1052
+ schema: [
1053
+ {
1054
+ name: "route_id",
1055
+ type: "text",
1056
+ primary: true,
1057
+ required: true,
1058
+ prefix: true
1059
+ },
1060
+ {
1061
+ name: "agency_id",
1062
+ type: "text",
1063
+ prefix: true
1064
+ },
1065
+ {
1066
+ name: "route_short_name",
1067
+ type: "text",
1068
+ nocase: true
1069
+ },
1070
+ {
1071
+ name: "route_long_name",
1072
+ type: "text",
1073
+ nocase: true
1074
+ },
1075
+ {
1076
+ name: "route_desc",
1077
+ type: "text",
1078
+ nocase: true
1079
+ },
1080
+ {
1081
+ name: "route_type",
1082
+ type: "integer",
1083
+ required: true,
1084
+ min: 0
1085
+ // Support extended GTFS route types with no max value
1086
+ // https://developers.google.com/transit/gtfs/reference/extended-route-types
1087
+ },
1088
+ {
1089
+ name: "route_url",
1090
+ type: "text"
1091
+ },
1092
+ {
1093
+ name: "route_color",
1094
+ type: "text",
1095
+ nocase: true
1096
+ },
1097
+ {
1098
+ name: "route_text_color",
1099
+ type: "text",
1100
+ nocase: true
1101
+ },
1102
+ {
1103
+ name: "route_sort_order",
1104
+ type: "integer",
1105
+ min: 0
1106
+ },
1107
+ {
1108
+ name: "continuous_pickup",
1109
+ type: "integer",
1110
+ min: 0,
1111
+ max: 3
1112
+ },
1113
+ {
1114
+ name: "continuous_drop_off",
1115
+ type: "integer",
1116
+ min: 0,
1117
+ max: 3
1118
+ },
1119
+ {
1120
+ name: "network_id",
1121
+ type: "text",
1122
+ prefix: true
1123
+ }
1124
+ ]
1125
+ };
1126
+ var routes_default = model22;
1127
+
1128
+ // src/models/gtfs/shapes.ts
1129
+ var model23 = {
1130
+ filenameBase: "shapes",
1131
+ filenameExtension: "txt",
1132
+ schema: [
1133
+ {
1134
+ name: "shape_id",
1135
+ type: "text",
1136
+ required: true,
1137
+ primary: true,
1138
+ prefix: true
1139
+ },
1140
+ {
1141
+ name: "shape_pt_lat",
1142
+ type: "real",
1143
+ required: true,
1144
+ min: -90,
1145
+ max: 90
1146
+ },
1147
+ {
1148
+ name: "shape_pt_lon",
1149
+ type: "real",
1150
+ required: true,
1151
+ min: -180,
1152
+ max: 180
1153
+ },
1154
+ {
1155
+ name: "shape_pt_sequence",
1156
+ type: "integer",
1157
+ required: true,
1158
+ primary: true,
1159
+ min: 0
1160
+ },
1161
+ {
1162
+ name: "shape_dist_traveled",
1163
+ type: "real",
1164
+ min: 0
1165
+ }
1166
+ ]
1167
+ };
1168
+ var shapes_default = model23;
1169
+
1170
+ // src/models/gtfs/stop-areas.ts
1171
+ var model24 = {
1172
+ filenameBase: "stop_areas",
1173
+ filenameExtension: "txt",
1174
+ schema: [
1175
+ {
1176
+ name: "area_id",
1177
+ type: "text",
1178
+ required: true,
1179
+ prefix: true
1180
+ },
1181
+ {
1182
+ name: "stop_id",
1183
+ type: "text",
1184
+ required: true,
1185
+ prefix: true
1186
+ }
1187
+ ]
1188
+ };
1189
+ var stop_areas_default = model24;
1190
+
1191
+ // src/models/gtfs/stop-times.ts
1192
+ var model25 = {
1193
+ filenameBase: "stop_times",
1194
+ filenameExtension: "txt",
1195
+ schema: [
1196
+ {
1197
+ name: "trip_id",
1198
+ type: "text",
1199
+ required: true,
1200
+ primary: true,
1201
+ prefix: true
1202
+ },
1203
+ {
1204
+ name: "arrival_time",
1205
+ type: "text"
1206
+ },
1207
+ {
1208
+ name: "arrival_timestamp",
1209
+ type: "integer",
1210
+ index: true
1211
+ },
1212
+ {
1213
+ name: "departure_time",
1214
+ type: "text"
1215
+ },
1216
+ {
1217
+ name: "departure_timestamp",
1218
+ type: "integer",
1219
+ index: true
1220
+ },
1221
+ {
1222
+ name: "location_group_id",
1223
+ type: "text",
1224
+ prefix: true,
1225
+ index: true
1226
+ },
1227
+ {
1228
+ name: "location_id",
1229
+ type: "text",
1230
+ prefix: true,
1231
+ index: true
1232
+ },
1233
+ {
1234
+ name: "stop_id",
1235
+ type: "text",
1236
+ required: true,
1237
+ prefix: true,
1238
+ index: true
1239
+ },
1240
+ {
1241
+ name: "stop_sequence",
1242
+ type: "integer",
1243
+ required: true,
1244
+ primary: true,
1245
+ min: 0
1246
+ },
1247
+ {
1248
+ name: "stop_headsign",
1249
+ type: "text",
1250
+ nocase: true
1251
+ },
1252
+ {
1253
+ name: "start_pickup_drop_off_window",
1254
+ type: "text"
1255
+ },
1256
+ {
1257
+ name: "start_pickup_drop_off_window_timestamp",
1258
+ type: "integer",
1259
+ index: true
1260
+ },
1261
+ {
1262
+ name: "pickup_type",
1263
+ type: "integer",
1264
+ min: 0,
1265
+ max: 3
1266
+ },
1267
+ {
1268
+ name: "drop_off_type",
1269
+ type: "integer",
1270
+ min: 0,
1271
+ max: 3
1272
+ },
1273
+ {
1274
+ name: "continuous_pickup",
1275
+ type: "integer",
1276
+ min: 0,
1277
+ max: 3
1278
+ },
1279
+ {
1280
+ name: "continuous_drop_off",
1281
+ type: "integer",
1282
+ min: 0,
1283
+ max: 3
1284
+ },
1285
+ {
1286
+ name: "shape_dist_traveled",
1287
+ type: "real",
1288
+ min: 0
1289
+ },
1290
+ {
1291
+ name: "timepoint",
1292
+ type: "integer",
1293
+ min: 0,
1294
+ max: 1
1295
+ },
1296
+ {
1297
+ name: "pickup_booking_rule_id",
1298
+ type: "text",
1299
+ prefix: true,
1300
+ index: true
1301
+ },
1302
+ {
1303
+ name: "drop_off_booking_rule_id",
1304
+ type: "text",
1305
+ prefix: true,
1306
+ index: true
1307
+ }
1308
+ ]
1309
+ };
1310
+ var stop_times_default = model25;
1311
+
1312
+ // src/models/gtfs/stops.ts
1313
+ var model26 = {
1314
+ filenameBase: "stops",
1315
+ filenameExtension: "txt",
1316
+ schema: [
1317
+ {
1318
+ name: "stop_id",
1319
+ type: "text",
1320
+ primary: true,
1321
+ required: true,
1322
+ prefix: true
1323
+ },
1324
+ {
1325
+ name: "stop_code",
1326
+ type: "text"
1327
+ },
1328
+ {
1329
+ name: "stop_name",
1330
+ type: "text",
1331
+ nocase: true
1332
+ },
1333
+ {
1334
+ name: "tts_stop_name",
1335
+ type: "text",
1336
+ nocase: true
1337
+ },
1338
+ {
1339
+ name: "stop_desc",
1340
+ type: "text",
1341
+ nocase: true
1342
+ },
1343
+ {
1344
+ name: "stop_lat",
1345
+ type: "real",
1346
+ min: -90,
1347
+ max: 90
1348
+ },
1349
+ {
1350
+ name: "stop_lon",
1351
+ type: "real",
1352
+ min: -180,
1353
+ max: 180
1354
+ },
1355
+ {
1356
+ name: "zone_id",
1357
+ type: "text",
1358
+ prefix: true
1359
+ },
1360
+ {
1361
+ name: "stop_url",
1362
+ type: "text"
1363
+ },
1364
+ {
1365
+ name: "location_type",
1366
+ type: "integer",
1367
+ min: 0,
1368
+ max: 4
1369
+ },
1370
+ {
1371
+ name: "parent_station",
1372
+ type: "text",
1373
+ index: true
1374
+ },
1375
+ {
1376
+ name: "stop_timezone",
1377
+ type: "text"
1378
+ },
1379
+ {
1380
+ name: "wheelchair_boarding",
1381
+ type: "integer",
1382
+ min: 0,
1383
+ max: 2
1384
+ },
1385
+ {
1386
+ name: "level_id",
1387
+ type: "text",
1388
+ prefix: true
1389
+ },
1390
+ {
1391
+ name: "platform_code",
1392
+ type: "text"
1393
+ }
1394
+ ]
1395
+ };
1396
+ var stops_default = model26;
1397
+
1398
+ // src/models/gtfs/timeframes.ts
1399
+ var model27 = {
1400
+ filenameBase: "timeframes",
1401
+ filenameExtension: "txt",
1402
+ schema: [
1403
+ {
1404
+ name: "timeframe_group_id",
1405
+ type: "text",
1406
+ primary: true,
1407
+ prefix: true
1408
+ },
1409
+ {
1410
+ name: "start_time",
1411
+ type: "text"
1412
+ },
1413
+ {
1414
+ name: "end_time",
1415
+ type: "text"
1416
+ },
1417
+ {
1418
+ name: "service_id",
1419
+ type: "text",
1420
+ required: true,
1421
+ index: true,
1422
+ prefix: true
1423
+ }
1424
+ ]
1425
+ };
1426
+ var timeframes_default = model27;
1427
+
1428
+ // src/models/gtfs/transfers.ts
1429
+ var model28 = {
1430
+ filenameBase: "transfers",
1431
+ filenameExtension: "txt",
1432
+ schema: [
1433
+ {
1434
+ name: "from_stop_id",
1435
+ type: "text",
1436
+ primary: true,
1437
+ prefix: true
1438
+ },
1439
+ {
1440
+ name: "to_stop_id",
1441
+ type: "text",
1442
+ primary: true,
1443
+ prefix: true
1444
+ },
1445
+ {
1446
+ name: "from_route_id",
1447
+ type: "text",
1448
+ primary: true,
1449
+ prefix: true
1450
+ },
1451
+ {
1452
+ name: "to_route_id",
1453
+ type: "text",
1454
+ primary: true,
1455
+ prefix: true
1456
+ },
1457
+ {
1458
+ name: "from_trip_id",
1459
+ type: "text",
1460
+ primary: true,
1461
+ prefix: true
1462
+ },
1463
+ {
1464
+ name: "to_trip_id",
1465
+ type: "text",
1466
+ primary: true,
1467
+ prefix: true
1468
+ },
1469
+ {
1470
+ name: "transfer_type",
1471
+ type: "integer",
1472
+ min: 0,
1473
+ max: 5,
1474
+ default: 0
1475
+ },
1476
+ {
1477
+ name: "min_transfer_time",
1478
+ type: "integer",
1479
+ min: 0
1480
+ }
1481
+ ]
1482
+ };
1483
+ var transfers_default = model28;
1484
+
1485
+ // src/models/gtfs/translations.ts
1486
+ var model29 = {
1487
+ filenameBase: "translations",
1488
+ filenameExtension: "txt",
1489
+ schema: [
1490
+ {
1491
+ name: "table_name",
1492
+ type: "text",
1493
+ primary: true,
1494
+ required: true
1495
+ },
1496
+ {
1497
+ name: "field_name",
1498
+ type: "text",
1499
+ primary: true,
1500
+ required: true
1501
+ },
1502
+ {
1503
+ name: "language",
1504
+ type: "text",
1505
+ primary: true,
1506
+ required: true
1507
+ },
1508
+ {
1509
+ name: "translation",
1510
+ type: "text",
1511
+ required: true
1512
+ },
1513
+ {
1514
+ name: "record_id",
1515
+ type: "text",
1516
+ primary: true,
1517
+ prefix: true
1518
+ },
1519
+ {
1520
+ name: "record_sub_id",
1521
+ type: "text",
1522
+ primary: true,
1523
+ prefix: true
1524
+ },
1525
+ {
1526
+ name: "field_value",
1527
+ type: "text",
1528
+ primary: true
1529
+ }
1530
+ ]
1531
+ };
1532
+ var translations_default = model29;
1533
+
1534
+ // src/models/gtfs/trips.ts
1535
+ var model30 = {
1536
+ filenameBase: "trips",
1537
+ filenameExtension: "txt",
1538
+ schema: [
1539
+ {
1540
+ name: "route_id",
1541
+ type: "text",
1542
+ required: true,
1543
+ index: true,
1544
+ prefix: true
1545
+ },
1546
+ {
1547
+ name: "service_id",
1548
+ type: "text",
1549
+ required: true,
1550
+ index: true,
1551
+ prefix: true
1552
+ },
1553
+ {
1554
+ name: "trip_id",
1555
+ type: "text",
1556
+ primary: true,
1557
+ required: true,
1558
+ prefix: true
1559
+ },
1560
+ {
1561
+ name: "trip_headsign",
1562
+ type: "text",
1563
+ nocase: true
1564
+ },
1565
+ {
1566
+ name: "trip_short_name",
1567
+ type: "text",
1568
+ nocase: true
1569
+ },
1570
+ {
1571
+ name: "direction_id",
1572
+ type: "integer",
1573
+ min: 0,
1574
+ max: 1,
1575
+ index: true
1576
+ },
1577
+ {
1578
+ name: "block_id",
1579
+ type: "text",
1580
+ index: true,
1581
+ prefix: true
1582
+ },
1583
+ {
1584
+ name: "shape_id",
1585
+ type: "text",
1586
+ index: true,
1587
+ prefix: true
1588
+ },
1589
+ {
1590
+ name: "wheelchair_accessible",
1591
+ type: "integer",
1592
+ min: 0,
1593
+ max: 2
1594
+ },
1595
+ {
1596
+ name: "bikes_allowed",
1597
+ type: "integer",
1598
+ min: 0,
1599
+ max: 2
1600
+ }
1601
+ ]
1602
+ };
1603
+ var trips_default = model30;
1604
+
1605
+ // src/models/non-standard/timetables.ts
1606
+ var model31 = {
1607
+ filenameBase: "timetables",
1608
+ filenameExtension: "txt",
1609
+ nonstandard: true,
1610
+ schema: [
1611
+ {
1612
+ name: "id",
1613
+ type: "integer",
1614
+ primary: true,
1615
+ prefix: true
1616
+ },
1617
+ {
1618
+ name: "timetable_id",
1619
+ type: "text",
1620
+ prefix: true
1621
+ },
1622
+ {
1623
+ name: "route_id",
1624
+ type: "text",
1625
+ prefix: true
1626
+ },
1627
+ {
1628
+ name: "direction_id",
1629
+ type: "integer",
1630
+ min: 0,
1631
+ max: 1
1632
+ },
1633
+ {
1634
+ name: "start_date",
1635
+ type: "integer"
1636
+ },
1637
+ {
1638
+ name: "end_date",
1639
+ type: "integer"
1640
+ },
1641
+ {
1642
+ name: "monday",
1643
+ type: "integer",
1644
+ required: true,
1645
+ min: 0,
1646
+ max: 1
1647
+ },
1648
+ {
1649
+ name: "tuesday",
1650
+ type: "integer",
1651
+ required: true,
1652
+ min: 0,
1653
+ max: 1
1654
+ },
1655
+ {
1656
+ name: "wednesday",
1657
+ type: "integer",
1658
+ required: true,
1659
+ min: 0,
1660
+ max: 1
1661
+ },
1662
+ {
1663
+ name: "thursday",
1664
+ type: "integer",
1665
+ required: true,
1666
+ min: 0,
1667
+ max: 1
1668
+ },
1669
+ {
1670
+ name: "friday",
1671
+ type: "integer",
1672
+ required: true,
1673
+ min: 0,
1674
+ max: 1
1675
+ },
1676
+ {
1677
+ name: "saturday",
1678
+ type: "integer",
1679
+ required: true,
1680
+ min: 0,
1681
+ max: 1
1682
+ },
1683
+ {
1684
+ name: "sunday",
1685
+ type: "integer",
1686
+ required: true,
1687
+ min: 0,
1688
+ max: 1
1689
+ },
1690
+ {
1691
+ name: "start_time",
1692
+ type: "text"
1693
+ },
1694
+ {
1695
+ name: "start_timestamp",
1696
+ type: "integer"
1697
+ },
1698
+ {
1699
+ name: "end_time",
1700
+ type: "text"
1701
+ },
1702
+ {
1703
+ name: "end_timestamp",
1704
+ type: "integer"
1705
+ },
1706
+ {
1707
+ name: "timetable_label",
1708
+ type: "text",
1709
+ nocase: true
1710
+ },
1711
+ {
1712
+ name: "service_notes",
1713
+ type: "text",
1714
+ nocase: true
1715
+ },
1716
+ {
1717
+ name: "orientation",
1718
+ type: "text"
1719
+ },
1720
+ {
1721
+ name: "timetable_page_id",
1722
+ type: "text"
1723
+ },
1724
+ {
1725
+ name: "timetable_sequence",
1726
+ type: "integer",
1727
+ min: 0,
1728
+ index: true
1729
+ },
1730
+ {
1731
+ name: "direction_name",
1732
+ type: "text"
1733
+ },
1734
+ {
1735
+ name: "include_exceptions",
1736
+ type: "integer",
1737
+ min: 0,
1738
+ max: 1
1739
+ },
1740
+ {
1741
+ name: "show_trip_continuation",
1742
+ type: "integer",
1743
+ min: 0,
1744
+ max: 1
1745
+ }
1746
+ ]
1747
+ };
1748
+ var timetables_default = model31;
1749
+
1750
+ // src/models/non-standard/timetable-pages.ts
1751
+ var model32 = {
1752
+ filenameBase: "timetable_pages",
1753
+ filenameExtension: "txt",
1754
+ nonstandard: true,
1755
+ schema: [
1756
+ {
1757
+ name: "timetable_page_id",
1758
+ type: "text",
1759
+ primary: true,
1760
+ prefix: true
1761
+ },
1762
+ {
1763
+ name: "timetable_page_label",
1764
+ type: "text"
1765
+ },
1766
+ {
1767
+ name: "filename",
1768
+ type: "text"
1769
+ }
1770
+ ]
1771
+ };
1772
+ var timetable_pages_default = model32;
1773
+
1774
+ // src/models/non-standard/timetable-stop-order.ts
1775
+ var model33 = {
1776
+ filenameBase: "timetable_stop_order",
1777
+ filenameExtension: "txt",
1778
+ nonstandard: true,
1779
+ schema: [
1780
+ {
1781
+ name: "id",
1782
+ type: "integer",
1783
+ primary: true,
1784
+ prefix: true
1785
+ },
1786
+ {
1787
+ name: "timetable_id",
1788
+ type: "text",
1789
+ index: true,
1790
+ prefix: true
1791
+ },
1792
+ {
1793
+ name: "stop_id",
1794
+ type: "text",
1795
+ prefix: true
1796
+ },
1797
+ {
1798
+ name: "stop_sequence",
1799
+ type: "integer",
1800
+ min: 0,
1801
+ index: true
1802
+ }
1803
+ ]
1804
+ };
1805
+ var timetable_stop_order_default = model33;
1806
+
1807
+ // src/models/non-standard/timetable-notes.ts
1808
+ var model34 = {
1809
+ filenameBase: "timetable_notes",
1810
+ filenameExtension: "txt",
1811
+ nonstandard: true,
1812
+ schema: [
1813
+ {
1814
+ name: "note_id",
1815
+ type: "text",
1816
+ primary: true,
1817
+ prefix: true
1818
+ },
1819
+ {
1820
+ name: "symbol",
1821
+ type: "text"
1822
+ },
1823
+ {
1824
+ name: "note",
1825
+ type: "text",
1826
+ nocase: true
1827
+ }
1828
+ ]
1829
+ };
1830
+ var timetable_notes_default = model34;
1831
+
1832
+ // src/models/non-standard/timetable-notes-references.ts
1833
+ var model35 = {
1834
+ filenameBase: "timetable_notes_references",
1835
+ filenameExtension: "txt",
1836
+ nonstandard: true,
1837
+ schema: [
1838
+ {
1839
+ name: "note_id",
1840
+ type: "text",
1841
+ prefix: true
1842
+ },
1843
+ {
1844
+ name: "timetable_id",
1845
+ type: "text",
1846
+ index: true,
1847
+ prefix: true
1848
+ },
1849
+ {
1850
+ name: "route_id",
1851
+ type: "text",
1852
+ index: true,
1853
+ prefix: true
1854
+ },
1855
+ {
1856
+ name: "trip_id",
1857
+ type: "text",
1858
+ index: true,
1859
+ prefix: true
1860
+ },
1861
+ {
1862
+ name: "stop_id",
1863
+ type: "text",
1864
+ index: true,
1865
+ prefix: true
1866
+ },
1867
+ {
1868
+ name: "stop_sequence",
1869
+ type: "integer",
1870
+ min: 0,
1871
+ index: true
1872
+ },
1873
+ {
1874
+ name: "show_on_stoptime",
1875
+ type: "integer",
1876
+ min: 0,
1877
+ max: 1
1878
+ }
1879
+ ]
1880
+ };
1881
+ var timetable_notes_references_default = model35;
1882
+
1883
+ // src/models/non-standard/trips-dated-vehicle-journey.ts
1884
+ var model36 = {
1885
+ filenameBase: "trips_dated_vehicle_journeys",
1886
+ filenameExtension: "txt",
1887
+ nonstandard: true,
1888
+ schema: [
1889
+ {
1890
+ name: "trip_id",
1891
+ type: "text",
1892
+ required: true,
1893
+ index: true,
1894
+ prefix: true
1895
+ },
1896
+ {
1897
+ name: "operating_day_date",
1898
+ type: "text",
1899
+ index: true,
1900
+ required: true
1901
+ },
1902
+ {
1903
+ name: "dated_vehicle_journey_gid",
1904
+ type: "text",
1905
+ required: true
1906
+ },
1907
+ {
1908
+ name: "journey_number",
1909
+ type: "integer",
1910
+ min: 0,
1911
+ max: 65535,
1912
+ index: true
1913
+ }
1914
+ ]
1915
+ };
1916
+ var trips_dated_vehicle_journey_default = model36;
1917
+
1918
+ // src/models/gtfs-plus/calendar-attributes.ts
1919
+ var model37 = {
1920
+ filenameBase: "calendar_attributes",
1921
+ filenameExtension: "txt",
1922
+ nonstandard: true,
1923
+ extension: "gtfs-plus",
1924
+ schema: [
1925
+ {
1926
+ name: "service_id",
1927
+ type: "text",
1928
+ primary: true,
1929
+ prefix: true
1930
+ },
1931
+ {
1932
+ name: "service_description",
1933
+ type: "text",
1934
+ required: true,
1935
+ nocase: true
1936
+ }
1937
+ ]
1938
+ };
1939
+ var calendar_attributes_default = model37;
1940
+
1941
+ // src/models/gtfs-plus/directions.ts
1942
+ var model38 = {
1943
+ filenameBase: "directions",
1944
+ filenameExtension: "txt",
1945
+ nonstandard: true,
1946
+ extension: "gtfs-plus",
1947
+ schema: [
1948
+ {
1949
+ name: "route_id",
1950
+ type: "text",
1951
+ required: true,
1952
+ primary: true,
1953
+ prefix: true
1954
+ },
1955
+ {
1956
+ name: "direction_id",
1957
+ type: "integer",
1958
+ min: 0,
1959
+ max: 1,
1960
+ primary: true
1961
+ },
1962
+ {
1963
+ name: "direction",
1964
+ type: "text",
1965
+ required: true
1966
+ }
1967
+ ]
1968
+ };
1969
+ var directions_default = model38;
1970
+
1971
+ // src/models/gtfs-plus/route-attributes.ts
1972
+ var model39 = {
1973
+ filenameBase: "route_attributes",
1974
+ filenameExtension: "txt",
1975
+ nonstandard: true,
1976
+ extension: "gtfs-plus",
1977
+ schema: [
1978
+ {
1979
+ name: "route_id",
1980
+ type: "text",
1981
+ primary: true,
1982
+ prefix: true
1983
+ },
1984
+ {
1985
+ name: "category",
1986
+ type: "integer",
1987
+ min: 0,
1988
+ required: true
1989
+ },
1990
+ {
1991
+ name: "subcategory",
1992
+ type: "integer",
1993
+ min: 101,
1994
+ required: true
1995
+ },
1996
+ {
1997
+ name: "running_way",
1998
+ type: "integer",
1999
+ min: 1,
2000
+ required: true
2001
+ }
2002
+ ]
2003
+ };
2004
+ var route_attributes_default = model39;
2005
+
2006
+ // src/models/gtfs-plus/stop-attributes.ts
2007
+ var model40 = {
2008
+ filenameBase: "stop_attributes",
2009
+ filenameExtension: "txt",
2010
+ nonstandard: true,
2011
+ extension: "gtfs-plus",
2012
+ schema: [
2013
+ {
2014
+ name: "stop_id",
2015
+ type: "text",
2016
+ required: true,
2017
+ primary: true,
2018
+ prefix: true
2019
+ },
2020
+ {
2021
+ name: "accessibility_id",
2022
+ type: "integer",
2023
+ min: 0
2024
+ },
2025
+ {
2026
+ name: "cardinal_direction",
2027
+ type: "text"
2028
+ },
2029
+ {
2030
+ name: "relative_position",
2031
+ type: "text"
2032
+ },
2033
+ {
2034
+ name: "stop_city",
2035
+ type: "text",
2036
+ nocase: true
2037
+ }
2038
+ ]
2039
+ };
2040
+ var stop_attributes_default = model40;
2041
+
2042
+ // src/models/gtfs-ride/board-alight.ts
2043
+ var model41 = {
2044
+ filenameBase: "board_alight",
2045
+ filenameExtension: "txt",
2046
+ nonstandard: true,
2047
+ extension: "gtfs-ride",
2048
+ schema: [
2049
+ {
2050
+ name: "trip_id",
2051
+ type: "text",
2052
+ required: true,
2053
+ index: true,
2054
+ prefix: true
2055
+ },
2056
+ {
2057
+ name: "stop_id",
2058
+ type: "text",
2059
+ required: true,
2060
+ index: true,
2061
+ prefix: true
2062
+ },
2063
+ {
2064
+ name: "stop_sequence",
2065
+ type: "integer",
2066
+ required: true,
2067
+ min: 0,
2068
+ index: true
2069
+ },
2070
+ {
2071
+ name: "record_use",
2072
+ type: "integer",
2073
+ required: true,
2074
+ min: 0,
2075
+ max: 1,
2076
+ index: true
2077
+ },
2078
+ {
2079
+ name: "schedule_relationship",
2080
+ type: "integer",
2081
+ min: 0,
2082
+ max: 8
2083
+ },
2084
+ {
2085
+ name: "boardings",
2086
+ type: "integer",
2087
+ min: 0
2088
+ },
2089
+ {
2090
+ name: "alightings",
2091
+ type: "integer",
2092
+ min: 0
2093
+ },
2094
+ {
2095
+ name: "current_load",
2096
+ type: "integer",
2097
+ min: 0
2098
+ },
2099
+ {
2100
+ name: "load_count",
2101
+ type: "integer",
2102
+ min: 0
2103
+ },
2104
+ {
2105
+ name: "load_type",
2106
+ type: "integer",
2107
+ min: 0,
2108
+ max: 1
2109
+ },
2110
+ {
2111
+ name: "rack_down",
2112
+ type: "integer",
2113
+ min: 0,
2114
+ max: 1
2115
+ },
2116
+ {
2117
+ name: "bike_boardings",
2118
+ type: "integer",
2119
+ min: 0
2120
+ },
2121
+ {
2122
+ name: "bike_alightings",
2123
+ type: "integer",
2124
+ min: 0
2125
+ },
2126
+ {
2127
+ name: "ramp_used",
2128
+ type: "integer",
2129
+ min: 0,
2130
+ max: 1
2131
+ },
2132
+ {
2133
+ name: "ramp_boardings",
2134
+ type: "integer",
2135
+ min: 0
2136
+ },
2137
+ {
2138
+ name: "ramp_alightings",
2139
+ type: "integer",
2140
+ min: 0
2141
+ },
2142
+ {
2143
+ name: "service_date",
2144
+ type: "integer",
2145
+ index: true
2146
+ },
2147
+ {
2148
+ name: "service_arrival_time",
2149
+ type: "text"
2150
+ },
2151
+ {
2152
+ name: "service_arrival_timestamp",
2153
+ type: "integer",
2154
+ index: true
2155
+ },
2156
+ {
2157
+ name: "service_departure_time",
2158
+ type: "text"
2159
+ },
2160
+ {
2161
+ name: "service_departure_timestamp",
2162
+ type: "integer",
2163
+ index: true
2164
+ },
2165
+ {
2166
+ name: "source",
2167
+ type: "integer",
2168
+ min: 0,
2169
+ max: 4
2170
+ }
2171
+ ]
2172
+ };
2173
+ var board_alight_default = model41;
2174
+
2175
+ // src/models/gtfs-ride/rider-trip.ts
2176
+ var model42 = {
2177
+ filenameBase: "rider_trip",
2178
+ filenameExtension: "txt",
2179
+ nonstandard: true,
2180
+ extension: "gtfs-ride",
2181
+ schema: [
2182
+ {
2183
+ name: "rider_id",
2184
+ type: "text",
2185
+ primary: true,
2186
+ prefix: true
2187
+ },
2188
+ {
2189
+ name: "agency_id",
2190
+ type: "text",
2191
+ index: true,
2192
+ prefix: true
2193
+ },
2194
+ {
2195
+ name: "trip_id",
2196
+ type: "text",
2197
+ index: true,
2198
+ prefix: true
2199
+ },
2200
+ {
2201
+ name: "boarding_stop_id",
2202
+ type: "text",
2203
+ index: true,
2204
+ prefix: true
2205
+ },
2206
+ {
2207
+ name: "boarding_stop_sequence",
2208
+ type: "integer",
2209
+ min: 0,
2210
+ index: true
2211
+ },
2212
+ {
2213
+ name: "alighting_stop_id",
2214
+ type: "text",
2215
+ index: true,
2216
+ prefix: true
2217
+ },
2218
+ {
2219
+ name: "alighting_stop_sequence",
2220
+ type: "integer",
2221
+ min: 0,
2222
+ index: true
2223
+ },
2224
+ {
2225
+ name: "service_date",
2226
+ type: "integer",
2227
+ index: true
2228
+ },
2229
+ {
2230
+ name: "boarding_time",
2231
+ type: "text"
2232
+ },
2233
+ {
2234
+ name: "boarding_timestamp",
2235
+ type: "integer",
2236
+ index: true
2237
+ },
2238
+ {
2239
+ name: "alighting_time",
2240
+ type: "text"
2241
+ },
2242
+ {
2243
+ name: "alighting_timestamp",
2244
+ type: "integer",
2245
+ index: true
2246
+ },
2247
+ {
2248
+ name: "rider_type",
2249
+ type: "integer",
2250
+ min: 0,
2251
+ max: 13
2252
+ },
2253
+ {
2254
+ name: "rider_type_description",
2255
+ type: "text"
2256
+ },
2257
+ {
2258
+ name: "fare_paid",
2259
+ type: "real"
2260
+ },
2261
+ {
2262
+ name: "transaction_type",
2263
+ type: "integer",
2264
+ min: 0,
2265
+ max: 8
2266
+ },
2267
+ {
2268
+ name: "fare_media",
2269
+ type: "integer",
2270
+ min: 0,
2271
+ max: 9
2272
+ },
2273
+ {
2274
+ name: "accompanying_device",
2275
+ type: "integer",
2276
+ min: 0,
2277
+ max: 6
2278
+ },
2279
+ {
2280
+ name: "transfer_status",
2281
+ type: "integer",
2282
+ min: 0,
2283
+ max: 1
2284
+ }
2285
+ ]
2286
+ };
2287
+ var rider_trip_default = model42;
2288
+
2289
+ // src/models/gtfs-ride/ridership.ts
2290
+ var model43 = {
2291
+ filenameBase: "ridership",
2292
+ filenameExtension: "txt",
2293
+ nonstandard: true,
2294
+ extension: "gtfs-ride",
2295
+ schema: [
2296
+ {
2297
+ name: "total_boardings",
2298
+ type: "integer",
2299
+ min: 0,
2300
+ required: true
2301
+ },
2302
+ {
2303
+ name: "total_alightings",
2304
+ type: "integer",
2305
+ min: 0,
2306
+ required: true
2307
+ },
2308
+ {
2309
+ name: "ridership_start_date",
2310
+ type: "integer",
2311
+ index: true
2312
+ },
2313
+ {
2314
+ name: "ridership_end_date",
2315
+ type: "integer",
2316
+ index: true
2317
+ },
2318
+ {
2319
+ name: "ridership_start_time",
2320
+ type: "text"
2321
+ },
2322
+ {
2323
+ name: "ridership_start_timestamp",
2324
+ type: "integer",
2325
+ index: true
2326
+ },
2327
+ {
2328
+ name: "ridership_end_time",
2329
+ type: "text"
2330
+ },
2331
+ {
2332
+ name: "ridership_end_timestamp",
2333
+ type: "integer",
2334
+ index: true
2335
+ },
2336
+ {
2337
+ name: "service_id",
2338
+ type: "text",
2339
+ index: true,
2340
+ prefix: true
2341
+ },
2342
+ {
2343
+ name: "monday",
2344
+ type: "integer",
2345
+ min: 0,
2346
+ max: 1
2347
+ },
2348
+ {
2349
+ name: "tuesday",
2350
+ type: "integer",
2351
+ min: 0,
2352
+ max: 1
2353
+ },
2354
+ {
2355
+ name: "wednesday",
2356
+ type: "integer",
2357
+ min: 0,
2358
+ max: 1
2359
+ },
2360
+ {
2361
+ name: "thursday",
2362
+ type: "integer",
2363
+ min: 0,
2364
+ max: 1
2365
+ },
2366
+ {
2367
+ name: "friday",
2368
+ type: "integer",
2369
+ min: 0,
2370
+ max: 1
2371
+ },
2372
+ {
2373
+ name: "saturday",
2374
+ type: "integer",
2375
+ min: 0,
2376
+ max: 1
2377
+ },
2378
+ {
2379
+ name: "sunday",
2380
+ type: "integer",
2381
+ min: 0,
2382
+ max: 1
2383
+ },
2384
+ {
2385
+ name: "agency_id",
2386
+ type: "text",
2387
+ index: true,
2388
+ prefix: true
2389
+ },
2390
+ {
2391
+ name: "route_id",
2392
+ type: "text",
2393
+ index: true,
2394
+ prefix: true
2395
+ },
2396
+ {
2397
+ name: "direction_id",
2398
+ type: "integer",
2399
+ min: 0,
2400
+ max: 1,
2401
+ index: true
2402
+ },
2403
+ {
2404
+ name: "trip_id",
2405
+ type: "text",
2406
+ prefix: true
2407
+ },
2408
+ {
2409
+ name: "stop_id",
2410
+ type: "text",
2411
+ prefix: true
2412
+ }
2413
+ ]
2414
+ };
2415
+ var ridership_default = model43;
2416
+
2417
+ // src/models/gtfs-ride/trip-capacity.ts
2418
+ var model44 = {
2419
+ filenameBase: "trip_capacity",
2420
+ filenameExtension: "txt",
2421
+ nonstandard: true,
2422
+ extension: "gtfs-ride",
2423
+ schema: [
2424
+ {
2425
+ name: "agency_id",
2426
+ type: "text",
2427
+ index: true,
2428
+ prefix: true
2429
+ },
2430
+ {
2431
+ name: "trip_id",
2432
+ type: "text",
2433
+ index: true,
2434
+ prefix: true
2435
+ },
2436
+ {
2437
+ name: "service_date",
2438
+ type: "integer",
2439
+ index: true
2440
+ },
2441
+ {
2442
+ name: "vehicle_description",
2443
+ type: "text"
2444
+ },
2445
+ {
2446
+ name: "seated_capacity",
2447
+ type: "integer",
2448
+ min: 0
2449
+ },
2450
+ {
2451
+ name: "standing_capacity",
2452
+ type: "integer",
2453
+ min: 0
2454
+ },
2455
+ {
2456
+ name: "wheelchair_capacity",
2457
+ type: "integer",
2458
+ min: 0
2459
+ },
2460
+ {
2461
+ name: "bike_capacity",
2462
+ type: "integer",
2463
+ min: 0
2464
+ }
2465
+ ]
2466
+ };
2467
+ var trip_capacity_default = model44;
2468
+
2469
+ // src/models/gtfs-ride/ride-feed-info.ts
2470
+ var model45 = {
2471
+ filenameBase: "ride_feed_info",
2472
+ filenameExtension: "txt",
2473
+ nonstandard: true,
2474
+ extension: "gtfs-ride",
2475
+ schema: [
2476
+ {
2477
+ name: "ride_files",
2478
+ type: "integer",
2479
+ min: 0,
2480
+ max: 6,
2481
+ required: true
2482
+ },
2483
+ {
2484
+ name: "ride_start_date",
2485
+ type: "integer",
2486
+ index: true
2487
+ },
2488
+ {
2489
+ name: "ride_end_date",
2490
+ type: "integer",
2491
+ index: true
2492
+ },
2493
+ {
2494
+ name: "gtfs_feed_date",
2495
+ type: "integer",
2496
+ index: true
2497
+ },
2498
+ {
2499
+ name: "default_currency_type",
2500
+ type: "text"
2501
+ },
2502
+ {
2503
+ name: "ride_feed_version",
2504
+ type: "text"
2505
+ }
2506
+ ]
2507
+ };
2508
+ var ride_feed_info_default = model45;
2509
+
2510
+ // src/models/gtfs-realtime/trip-updates.ts
2511
+ var model46 = {
2512
+ filenameBase: "trip_updates",
2513
+ extension: "gtfs-realtime",
2514
+ schema: [
2515
+ {
2516
+ name: "update_id",
2517
+ type: "text",
2518
+ required: true,
2519
+ primary: true,
2520
+ index: true,
2521
+ source: "id"
2522
+ },
2523
+ {
2524
+ name: "vehicle_id",
2525
+ type: "text",
2526
+ index: true,
2527
+ source: "tripUpdate.vehicle.id",
2528
+ default: null
2529
+ },
2530
+ {
2531
+ name: "trip_id",
2532
+ type: "text",
2533
+ index: true,
2534
+ source: "tripUpdate.trip.tripId",
2535
+ default: null
2536
+ },
2537
+ {
2538
+ name: "trip_start_time",
2539
+ type: "text",
2540
+ source: "tripUpdate.trip.startTime",
2541
+ default: null
2542
+ },
2543
+ {
2544
+ name: "direction_id",
2545
+ type: "integer",
2546
+ source: "tripUpdate.trip.directionId",
2547
+ default: null
2548
+ },
2549
+ {
2550
+ name: "route_id",
2551
+ type: "text",
2552
+ index: true,
2553
+ source: "tripUpdate.trip.routeId",
2554
+ default: null
2555
+ },
2556
+ {
2557
+ name: "start_date",
2558
+ type: "text",
2559
+ source: "tripUpdate.trip.startDate",
2560
+ default: null
2561
+ },
2562
+ {
2563
+ name: "timestamp",
2564
+ type: "text",
2565
+ source: "tripUpdate.timestamp",
2566
+ default: null
2567
+ },
2568
+ {
2569
+ name: "schedule_relationship",
2570
+ type: "text",
2571
+ source: "tripUpdate.trip.scheduleRelationship",
2572
+ default: null
2573
+ },
2574
+ {
2575
+ name: "created_timestamp",
2576
+ type: "integer",
2577
+ required: true
2578
+ },
2579
+ {
2580
+ name: "expiration_timestamp",
2581
+ type: "integer",
2582
+ required: true
2583
+ }
2584
+ ]
2585
+ };
2586
+ var trip_updates_default = model46;
2587
+
2588
+ // src/models/gtfs-realtime/stop-time-updates.ts
2589
+ var model47 = {
2590
+ filenameBase: "stop_time_updates",
2591
+ extension: "gtfs-realtime",
2592
+ schema: [
2593
+ {
2594
+ name: "trip_id",
2595
+ type: "text",
2596
+ index: true,
2597
+ source: "parent.tripUpdate.trip.tripId",
2598
+ default: null
2599
+ },
2600
+ {
2601
+ name: "trip_start_time",
2602
+ type: "text",
2603
+ source: "parent.tripUpdate.trip.startTime",
2604
+ default: null
2605
+ },
2606
+ {
2607
+ name: "direction_id",
2608
+ type: "integer",
2609
+ source: "parent.tripUpdate.trip.directionId",
2610
+ default: null
2611
+ },
2612
+ {
2613
+ name: "route_id",
2614
+ type: "text",
2615
+ index: true,
2616
+ source: "parent.tripUpdate.trip.routeId",
2617
+ default: null
2618
+ },
2619
+ {
2620
+ name: "stop_id",
2621
+ type: "text",
2622
+ index: true,
2623
+ source: "stopId",
2624
+ default: null
2625
+ },
2626
+ {
2627
+ name: "stop_sequence",
2628
+ type: "integer",
2629
+ source: "stopSequence",
2630
+ default: null
2631
+ },
2632
+ {
2633
+ name: "arrival_delay",
2634
+ type: "integer",
2635
+ source: "arrival.delay",
2636
+ default: null
2637
+ },
2638
+ {
2639
+ name: "departure_delay",
2640
+ type: "integer",
2641
+ source: "departure.delay",
2642
+ default: null
2643
+ },
2644
+ {
2645
+ name: "departure_timestamp",
2646
+ type: "text",
2647
+ source: "departure.time",
2648
+ default: null
2649
+ },
2650
+ {
2651
+ name: "arrival_timestamp",
2652
+ type: "text",
2653
+ source: "arrival.time",
2654
+ default: null
2655
+ },
2656
+ {
2657
+ name: "schedule_relationship",
2658
+ type: "text",
2659
+ source: "scheduleRelationship",
2660
+ default: null
2661
+ },
2662
+ {
2663
+ name: "created_timestamp",
2664
+ type: "integer",
2665
+ required: true
2666
+ },
2667
+ {
2668
+ name: "expiration_timestamp",
2669
+ type: "integer",
2670
+ required: true
2671
+ }
2672
+ ]
2673
+ };
2674
+ var stop_time_updates_default = model47;
2675
+
2676
+ // src/models/gtfs-realtime/vehicle-positions.ts
2677
+ var model48 = {
2678
+ filenameBase: "vehicle_positions",
2679
+ extension: "gtfs-realtime",
2680
+ schema: [
2681
+ {
2682
+ name: "update_id",
2683
+ type: "text",
2684
+ required: true,
2685
+ primary: true,
2686
+ index: true,
2687
+ source: "id"
2688
+ },
2689
+ {
2690
+ name: "bearing",
2691
+ type: "real",
2692
+ source: "vehicle.position.bearing",
2693
+ default: null
2694
+ },
2695
+ {
2696
+ name: "latitude",
2697
+ type: "real",
2698
+ min: -90,
2699
+ max: 90,
2700
+ source: "vehicle.position.latitude",
2701
+ default: null
2702
+ },
2703
+ {
2704
+ name: "longitude",
2705
+ type: "real",
2706
+ source: "vehicle.position.longitude",
2707
+ min: -180,
2708
+ max: 180,
2709
+ default: null
2710
+ },
2711
+ {
2712
+ name: "speed",
2713
+ type: "real",
2714
+ min: 0,
2715
+ source: "vehicle.position.speed",
2716
+ default: null
2717
+ },
2718
+ {
2719
+ name: "current_stop_sequence",
2720
+ type: "integer",
2721
+ source: "vehicle.currentStopSequence",
2722
+ default: null
2723
+ },
2724
+ {
2725
+ name: "trip_id",
2726
+ type: "text",
2727
+ index: true,
2728
+ source: "vehicle.trip.tripId",
2729
+ default: null
2730
+ },
2731
+ {
2732
+ name: "trip_start_date",
2733
+ type: "text",
2734
+ index: true,
2735
+ source: "vehicle.trip.startDate",
2736
+ default: null
2737
+ },
2738
+ {
2739
+ name: "trip_start_time",
2740
+ type: "text",
2741
+ index: true,
2742
+ source: "vehicle.trip.startTime",
2743
+ default: null
2744
+ },
2745
+ {
2746
+ name: "congestion_level",
2747
+ type: "text",
2748
+ source: "vehicle.congestionLevel",
2749
+ default: null
2750
+ },
2751
+ {
2752
+ name: "occupancy_status",
2753
+ type: "text",
2754
+ source: "vehicle.occupancyStatus",
2755
+ default: null
2756
+ },
2757
+ {
2758
+ name: "occupancy_percentage",
2759
+ type: "integer",
2760
+ source: "vehicle.occupancyPercentage",
2761
+ default: null
2762
+ },
2763
+ {
2764
+ name: "vehicle_stop_status",
2765
+ type: "text",
2766
+ source: "vehicle.vehicleStopStatus",
2767
+ default: null
2768
+ },
2769
+ {
2770
+ name: "vehicle_id",
2771
+ type: "text",
2772
+ index: true,
2773
+ source: "vehicle.vehicle.id",
2774
+ default: null
2775
+ },
2776
+ {
2777
+ name: "vehicle_label",
2778
+ type: "text",
2779
+ source: "vehicle.vehicle.label",
2780
+ default: null
2781
+ },
2782
+ {
2783
+ name: "vehicle_license_plate",
2784
+ type: "text",
2785
+ source: "vehicle.vehicle.licensePlate",
2786
+ default: null
2787
+ },
2788
+ {
2789
+ name: "vehicle_wheelchair_accessible",
2790
+ type: "text",
2791
+ source: "vehicle.vehicle.wheelchairAccessible",
2792
+ default: null
2793
+ },
2794
+ {
2795
+ name: "timestamp",
2796
+ type: "text",
2797
+ source: "vehicle.timestamp",
2798
+ default: null
2799
+ },
2800
+ {
2801
+ name: "created_timestamp",
2802
+ type: "integer",
2803
+ required: true
2804
+ },
2805
+ {
2806
+ name: "expiration_timestamp",
2807
+ type: "integer",
2808
+ required: true
2809
+ }
2810
+ ]
2811
+ };
2812
+ var vehicle_positions_default = model48;
2813
+
2814
+ // src/models/gtfs-realtime/service-alerts.ts
2815
+ var model49 = {
2816
+ filenameBase: "service_alerts",
2817
+ extension: "gtfs-realtime",
2818
+ schema: [
2819
+ {
2820
+ name: "id",
2821
+ type: "text",
2822
+ required: true,
2823
+ primary: true,
2824
+ index: true,
2825
+ source: "id"
2826
+ },
2827
+ {
2828
+ name: "cause",
2829
+ type: "integer",
2830
+ required: true,
2831
+ min: 0,
2832
+ source: "alert.cause",
2833
+ default: 0
2834
+ },
2835
+ {
2836
+ name: "start_time",
2837
+ type: "text",
2838
+ required: true,
2839
+ source: "alert.activePeriod[0].start",
2840
+ default: ""
2841
+ },
2842
+ {
2843
+ name: "end_time",
2844
+ type: "text",
2845
+ required: true,
2846
+ source: "alert.activePeriod[0].end",
2847
+ default: ""
2848
+ },
2849
+ {
2850
+ name: "headline",
2851
+ type: "text",
2852
+ required: true,
2853
+ source: "alert.headerText.translation[0].text",
2854
+ default: ""
2855
+ },
2856
+ {
2857
+ name: "description",
2858
+ type: "text",
2859
+ required: true,
2860
+ source: "alert.descriptionText.translation[0].text",
2861
+ default: ""
2862
+ },
2863
+ {
2864
+ name: "created_timestamp",
2865
+ type: "integer",
2866
+ required: true
2867
+ },
2868
+ {
2869
+ name: "expiration_timestamp",
2870
+ type: "integer",
2871
+ required: true
2872
+ }
2873
+ ]
2874
+ };
2875
+ var service_alerts_default = model49;
2876
+
2877
+ // src/models/gtfs-realtime/service-alert-targets.ts
2878
+ var model50 = {
2879
+ filenameBase: "service_alert_targets",
2880
+ extension: "gtfs-realtime",
2881
+ schema: [
2882
+ {
2883
+ name: "alert_id",
2884
+ type: "text",
2885
+ required: true,
2886
+ primary: true,
2887
+ source: "parent.id"
2888
+ },
2889
+ {
2890
+ name: "stop_id",
2891
+ type: "text",
2892
+ index: true,
2893
+ source: "stopId",
2894
+ default: null
2895
+ },
2896
+ {
2897
+ name: "route_id",
2898
+ type: "text",
2899
+ index: true,
2900
+ source: "routeId",
2901
+ default: null
2902
+ },
2903
+ {
2904
+ name: "created_timestamp",
2905
+ type: "integer",
2906
+ required: true
2907
+ },
2908
+ {
2909
+ name: "expiration_timestamp",
2910
+ type: "integer",
2911
+ required: true
2912
+ }
2913
+ ]
2914
+ };
2915
+ var service_alert_targets_default = model50;
2916
+
2917
+ // src/models/ods/deadhead-times.ts
2918
+ var model51 = {
2919
+ filenameBase: "deadhead_times",
2920
+ filenameExtension: "txt",
2921
+ nonstandard: true,
2922
+ extension: "ods",
2923
+ schema: [
2924
+ {
2925
+ name: "id",
2926
+ type: "integer",
2927
+ primary: true,
2928
+ prefix: true
2929
+ },
2930
+ {
2931
+ name: "deadhead_id",
2932
+ type: "text",
2933
+ required: true,
2934
+ index: true,
2935
+ prefix: true
2936
+ },
2937
+ {
2938
+ name: "arrival_time",
2939
+ type: "text",
2940
+ required: true
2941
+ },
2942
+ {
2943
+ name: "arrival_timestamp",
2944
+ type: "integer",
2945
+ index: true
2946
+ },
2947
+ {
2948
+ name: "departure_time",
2949
+ type: "text",
2950
+ required: true
2951
+ },
2952
+ {
2953
+ name: "departure_timestamp",
2954
+ type: "integer",
2955
+ index: true
2956
+ },
2957
+ {
2958
+ name: "ops_location_id",
2959
+ type: "text",
2960
+ prefix: true
2961
+ },
2962
+ {
2963
+ name: "stop_id",
2964
+ type: "text",
2965
+ prefix: true
2966
+ },
2967
+ {
2968
+ name: "location_sequence",
2969
+ type: "integer",
2970
+ required: true,
2971
+ min: 0,
2972
+ index: true
2973
+ },
2974
+ {
2975
+ name: "shape_dist_traveled",
2976
+ type: "real",
2977
+ min: 0
2978
+ }
2979
+ ]
2980
+ };
2981
+ var deadhead_times_default = model51;
2982
+
2983
+ // src/models/ods/deadheads.ts
2984
+ var model52 = {
2985
+ filenameBase: "deadheads",
2986
+ filenameExtension: "txt",
2987
+ nonstandard: true,
2988
+ extension: "ods",
2989
+ schema: [
2990
+ {
2991
+ name: "deadhead_id",
2992
+ type: "text",
2993
+ primary: true,
2994
+ required: true,
2995
+ prefix: true
2996
+ },
2997
+ {
2998
+ name: "service_id",
2999
+ type: "text",
3000
+ required: true,
3001
+ prefix: true
3002
+ },
3003
+ {
3004
+ name: "block_id",
3005
+ type: "text",
3006
+ required: true,
3007
+ index: true,
3008
+ prefix: true
3009
+ },
3010
+ {
3011
+ name: "shape_id",
3012
+ type: "text",
3013
+ index: true,
3014
+ prefix: true
3015
+ },
3016
+ {
3017
+ name: "to_trip_id",
3018
+ type: "text",
3019
+ index: true,
3020
+ prefix: true
3021
+ },
3022
+ {
3023
+ name: "from_trip_id",
3024
+ type: "text",
3025
+ index: true,
3026
+ prefix: true
3027
+ },
3028
+ {
3029
+ name: "to_deadhead_id",
3030
+ type: "text",
3031
+ index: true,
3032
+ prefix: true
3033
+ },
3034
+ {
3035
+ name: "from_deadhead_id",
3036
+ type: "text",
3037
+ index: true,
3038
+ prefix: true
3039
+ }
3040
+ ]
3041
+ };
3042
+ var deadheads_default = model52;
3043
+
3044
+ // src/models/ods/ops-locations.ts
3045
+ var model53 = {
3046
+ filenameBase: "ops_locations",
3047
+ filenameExtension: "txt",
3048
+ nonstandard: true,
3049
+ extension: "ods",
3050
+ schema: [
3051
+ {
3052
+ name: "ops_location_id",
3053
+ type: "text",
3054
+ primary: true,
3055
+ required: true,
3056
+ prefix: true
3057
+ },
3058
+ {
3059
+ name: "ops_location_code",
3060
+ type: "text"
3061
+ },
3062
+ {
3063
+ name: "ops_location_name",
3064
+ type: "text",
3065
+ required: true,
3066
+ nocase: true
3067
+ },
3068
+ {
3069
+ name: "ops_location_desc",
3070
+ type: "text",
3071
+ nocase: true
3072
+ },
3073
+ {
3074
+ name: "ops_location_lat",
3075
+ type: "real",
3076
+ required: true,
3077
+ min: -90,
3078
+ max: 90
3079
+ },
3080
+ {
3081
+ name: "ops_location_lon",
3082
+ type: "real",
3083
+ required: true,
3084
+ min: -180,
3085
+ max: 180
3086
+ }
3087
+ ]
3088
+ };
3089
+ var ops_locations_default = model53;
3090
+
3091
+ // src/models/ods/run-events.ts
3092
+ var model54 = {
3093
+ filenameBase: "run_event",
3094
+ filenameExtension: "txt",
3095
+ nonstandard: true,
3096
+ extension: "ods",
3097
+ schema: [
3098
+ {
3099
+ name: "run_event_id",
3100
+ type: "text",
3101
+ primary: true,
3102
+ required: true,
3103
+ prefix: true
3104
+ },
3105
+ {
3106
+ name: "piece_id",
3107
+ type: "text",
3108
+ required: true,
3109
+ prefix: true
3110
+ },
3111
+ {
3112
+ name: "event_type",
3113
+ type: "integer",
3114
+ required: true,
3115
+ min: 0,
3116
+ index: true
3117
+ },
3118
+ {
3119
+ name: "event_name",
3120
+ type: "text",
3121
+ nocase: true
3122
+ },
3123
+ {
3124
+ name: "event_time",
3125
+ type: "text",
3126
+ required: true
3127
+ },
3128
+ {
3129
+ name: "event_duration",
3130
+ type: "integer",
3131
+ required: true,
3132
+ min: 0
3133
+ },
3134
+ {
3135
+ name: "event_from_location_type",
3136
+ type: "integer",
3137
+ min: 0,
3138
+ max: 1,
3139
+ index: true
3140
+ },
3141
+ {
3142
+ name: "event_from_location_id",
3143
+ type: "text",
3144
+ prefix: true
3145
+ },
3146
+ {
3147
+ name: "event_to_location_type",
3148
+ type: "integer",
3149
+ min: 0,
3150
+ max: 1,
3151
+ index: true
3152
+ },
3153
+ {
3154
+ name: "event_to_location_id",
3155
+ type: "text",
3156
+ prefix: true
3157
+ }
3158
+ ]
3159
+ };
3160
+ var run_events_default = model54;
3161
+
3162
+ // src/models/ods/runs-pieces.ts
3163
+ var model55 = {
3164
+ filenameBase: "runs_pieces",
3165
+ filenameExtension: "txt",
3166
+ nonstandard: true,
3167
+ extension: "ods",
3168
+ schema: [
3169
+ {
3170
+ name: "run_id",
3171
+ type: "text",
3172
+ required: true
3173
+ },
3174
+ {
3175
+ name: "piece_id",
3176
+ type: "text",
3177
+ primary: true,
3178
+ required: true
3179
+ },
3180
+ {
3181
+ name: "start_type",
3182
+ type: "integer",
3183
+ required: true,
3184
+ min: 0,
3185
+ max: 2,
3186
+ index: true
3187
+ },
3188
+ {
3189
+ name: "start_trip_id",
3190
+ type: "text",
3191
+ required: true,
3192
+ index: true
3193
+ },
3194
+ {
3195
+ name: "start_trip_position",
3196
+ type: "integer",
3197
+ min: 0
3198
+ },
3199
+ {
3200
+ name: "end_type",
3201
+ type: "integer",
3202
+ required: true,
3203
+ min: 0,
3204
+ max: 2,
3205
+ index: true
3206
+ },
3207
+ {
3208
+ name: "end_trip_id",
3209
+ type: "text",
3210
+ required: true,
3211
+ index: true
3212
+ },
3213
+ {
3214
+ name: "end_trip_position",
3215
+ type: "integer",
3216
+ min: 0
3217
+ }
3218
+ ]
3219
+ };
3220
+ var runs_pieces_default = model55;
3221
+
3222
+ // src/models/models.ts
3223
+ var models = [
3224
+ agency_default,
3225
+ areas_default,
3226
+ attributions_default,
3227
+ booking_rules_default,
3228
+ calendar_dates_default,
3229
+ calendar_default,
3230
+ fare_attributes_default,
3231
+ fare_leg_rules_default,
3232
+ fare_media_default,
3233
+ fare_products_default,
3234
+ fare_rules_default,
3235
+ fare_transfer_rules_default,
3236
+ feed_info_default,
3237
+ frequencies_default,
3238
+ levels_default,
3239
+ location_groups_default,
3240
+ location_group_stops_default,
3241
+ locations_default,
3242
+ networks_default,
3243
+ pathways_default,
3244
+ route_networks_default,
3245
+ routes_default,
3246
+ shapes_default,
3247
+ stop_areas_default,
3248
+ stop_times_default,
3249
+ stops_default,
3250
+ timeframes_default,
3251
+ transfers_default,
3252
+ translations_default,
3253
+ trips_default,
3254
+ timetables_default,
3255
+ timetable_pages_default,
3256
+ timetable_stop_order_default,
3257
+ timetable_notes_default,
3258
+ timetable_notes_references_default,
3259
+ trips_dated_vehicle_journey_default,
3260
+ calendar_attributes_default,
3261
+ directions_default,
3262
+ route_attributes_default,
3263
+ stop_attributes_default,
3264
+ board_alight_default,
3265
+ ride_feed_info_default,
3266
+ rider_trip_default,
3267
+ ridership_default,
3268
+ trip_capacity_default,
3269
+ trip_updates_default,
3270
+ stop_time_updates_default,
3271
+ vehicle_positions_default,
3272
+ service_alerts_default,
3273
+ service_alert_targets_default,
3274
+ deadhead_times_default,
3275
+ deadheads_default,
3276
+ ops_locations_default,
3277
+ run_events_default,
3278
+ runs_pieces_default
3279
+ ];
3280
+ var models_default = models;
3281
+
3282
+ // src/lib/db.ts
3283
+ import Database from "better-sqlite3";
3284
+ import untildify2 from "untildify";
3285
+
3286
+ // src/lib/utils.ts
3287
+ import sqlString from "sqlstring-sqlite";
3288
+ import Long from "long";
3289
+ function validateConfigForImport(config) {
3290
+ if (!config.agencies || config.agencies.length === 0) {
3291
+ throw new Error("No `agencies` specified in config");
3292
+ }
3293
+ for (const [index, agency] of config.agencies.entries()) {
3294
+ if (!agency.path && !agency.url) {
3295
+ throw new Error(
3296
+ `No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
3297
+ );
3298
+ }
3299
+ }
3300
+ return config;
3301
+ }
3302
+ function setDefaultConfig(initialConfig) {
3303
+ const defaults = {
3304
+ sqlitePath: ":memory:",
3305
+ ignoreDuplicates: false,
3306
+ gtfsRealtimeExpirationSeconds: 0
3307
+ };
3308
+ return {
3309
+ ...defaults,
3310
+ ...initialConfig
3311
+ };
3312
+ }
3313
+ function convertLongTimeToDate(longDate) {
3314
+ const { high, low, unsigned } = longDate;
3315
+ return new Date(new Long(low, high, unsigned).toInt() * 1e3).toISOString();
3316
+ }
3317
+ function calculateSecondsFromMidnight(time) {
3318
+ const split = time.split(":").map((d) => Number.parseInt(d, 10));
3319
+ if (split.length !== 3) {
3320
+ return null;
3321
+ }
3322
+ return split[0] * 3600 + split[1] * 60 + split[2];
3323
+ }
3324
+ function padLeadingZeros(time) {
3325
+ const split = time.split(":").map((d) => String(Number(d)).padStart(2, "0"));
3326
+ if (split.length !== 3) {
3327
+ return null;
3328
+ }
3329
+ return split.join(":");
3330
+ }
3331
+
3332
+ // src/lib/db.ts
3333
+ var dbs = {};
3334
+ function setupDb(sqlitePath) {
3335
+ const db = new Database(untildify2(sqlitePath));
3336
+ db.pragma("journal_mode = OFF");
3337
+ db.pragma("synchronous = OFF");
3338
+ db.pragma("temp_store = MEMORY");
3339
+ dbs[sqlitePath] = db;
3340
+ return db;
3341
+ }
3342
+ function openDb(config = null) {
3343
+ if (config) {
3344
+ const { sqlitePath, db } = setDefaultConfig(config);
3345
+ if (db) {
3346
+ return db;
3347
+ }
3348
+ if (dbs[sqlitePath]) {
3349
+ return dbs[sqlitePath];
3350
+ }
3351
+ return setupDb(sqlitePath);
3352
+ }
3353
+ if (Object.keys(dbs).length === 1) {
3354
+ const filename = Object.keys(dbs)[0];
3355
+ return dbs[filename];
3356
+ }
3357
+ if (Object.keys(dbs).length > 1) {
3358
+ throw new Error(
3359
+ "Multiple databases open, please specify which one to use."
3360
+ );
3361
+ }
3362
+ throw new Error("Unable to find database connection.");
3363
+ }
3364
+ function closeDb(db = null) {
3365
+ if (Object.keys(dbs).length === 0) {
3366
+ throw new Error(
3367
+ "No database connection. Call `openDb(config)` before using any methods."
3368
+ );
3369
+ }
3370
+ if (!db) {
3371
+ if (Object.keys(dbs).length > 1) {
3372
+ throw new Error(
3373
+ "Multiple database connections. Pass the db you want to close as a parameter to `closeDb`."
3374
+ );
3375
+ }
3376
+ db = dbs[Object.keys(dbs)[0]];
3377
+ }
3378
+ db.close();
3379
+ delete dbs[db.name];
3380
+ }
3381
+
3382
+ // src/lib/geojson-utils.ts
3383
+ import {
3384
+ cloneDeep,
3385
+ filter,
3386
+ groupBy,
3387
+ last,
3388
+ omit as omit2,
3389
+ sortBy,
3390
+ omitBy
3391
+ } from "lodash-es";
3392
+ import { feature, featureCollection } from "@turf/helpers";
3393
+ function isValidJSON(string) {
3394
+ try {
3395
+ JSON.parse(string);
3396
+ } catch (error) {
3397
+ return false;
3398
+ }
3399
+ return true;
3400
+ }
3401
+
3402
+ // src/lib/import.ts
3403
+ var downloadFiles = async (task) => {
3404
+ task.log(`Downloading GTFS from ${task.agency_url}`);
3405
+ task.path = `${task.downloadDir}/gtfs.zip`;
3406
+ const response = await fetch(task.agency_url, {
3407
+ method: "GET",
3408
+ headers: task.headers || {},
3409
+ signal: task.downloadTimeout ? AbortSignal.timeout(task.downloadTimeout) : void 0
3410
+ });
3411
+ if (response.status !== 200) {
3412
+ throw new Error(`Unable to download GTFS from ${task.agency_url}`);
3413
+ }
3414
+ const buffer = await response.arrayBuffer();
3415
+ await writeFile(task.path, Buffer.from(buffer));
3416
+ task.log("Download successful");
3417
+ };
3418
+ var downloadGtfsRealtimeData = async (url, task) => {
3419
+ const response = await fetch(url, {
3420
+ method: "GET",
3421
+ headers: {
3422
+ ...task.realtime_headers || {},
3423
+ "Accept-Encoding": "gzip"
3424
+ },
3425
+ signal: task.downloadTimeout ? AbortSignal.timeout(task.downloadTimeout) : void 0
3426
+ });
3427
+ if (response.status !== 200) {
3428
+ task.logWarning(`Unable to download GTFS-Realtime from ${url}`);
3429
+ return null;
3430
+ }
3431
+ const buffer = await response.arrayBuffer();
3432
+ const message = GtfsRealtimeBindings.transit_realtime.FeedMessage.decode(
3433
+ new Uint8Array(buffer)
3434
+ );
3435
+ return GtfsRealtimeBindings.transit_realtime.FeedMessage.toObject(message, {
3436
+ enums: String,
3437
+ longs: String,
3438
+ bytes: String,
3439
+ defaults: true,
3440
+ arrays: true,
3441
+ objects: true,
3442
+ oneofs: true
3443
+ });
3444
+ };
3445
+ function getDescendantProp(obj, defaultValue, source) {
3446
+ if (source === void 0) return defaultValue;
3447
+ const arr = source.split(".");
3448
+ while (arr.length) {
3449
+ const nextKey = arr.shift();
3450
+ if (nextKey === void 0) {
3451
+ return defaultValue;
3452
+ } else if (obj == null) {
3453
+ return defaultValue;
3454
+ } else if (nextKey?.includes("[")) {
3455
+ const arrayKey = nextKey.match(/(\w*)\[(\d+)\]/);
3456
+ if (arrayKey === null) {
3457
+ return defaultValue;
3458
+ }
3459
+ if (obj[arrayKey[1]] === void 0) {
3460
+ return defaultValue;
3461
+ }
3462
+ if (obj[arrayKey[1]][arrayKey[2]] === void 0) {
3463
+ return defaultValue;
3464
+ }
3465
+ obj = obj[arrayKey[1]][arrayKey[2]];
3466
+ } else {
3467
+ if (obj[nextKey] === void 0) {
3468
+ return defaultValue;
3469
+ }
3470
+ obj = obj[nextKey];
3471
+ }
3472
+ }
3473
+ if (obj.__isLong__) return convertLongTimeToDate(obj);
3474
+ return obj;
3475
+ }
3476
+ var prepareRealtimeValue = (entity, column, task) => {
3477
+ if (column.name === "created_timestamp") {
3478
+ return task.currentTimestamp;
3479
+ }
3480
+ if (column.name === "expiration_timestamp") {
3481
+ return task.currentTimestamp + task.gtfsRealtimeExpirationSeconds;
3482
+ }
3483
+ return sqlString2.escape(
3484
+ getDescendantProp(entity, column.default, column.source)
3485
+ );
3486
+ };
3487
+ var updateRealtimeData = async (task) => {
3488
+ if (!task.realtime_urls) {
3489
+ return;
3490
+ }
3491
+ const db = openDb({
3492
+ sqlitePath: task.sqlitePath,
3493
+ agencies: []
3494
+ });
3495
+ const vehiclePositionsModel = models_default.find(
3496
+ (x) => x.filenameBase === "vehicle_positions"
3497
+ );
3498
+ const tripUpdatesModel = models_default.find(
3499
+ (x) => x.filenameBase === "trip_updates"
3500
+ );
3501
+ const stoptimeUpdatesModel = models_default.find(
3502
+ (x) => x.filenameBase === "stop_time_updates"
3503
+ );
3504
+ const serviceAlertsModel = models_default.find(
3505
+ (x) => x.filenameBase === "service_alerts"
3506
+ );
3507
+ const serviceAlertTargetsModel = models_default.find(
3508
+ (x) => x.filenameBase === "service_alert_targets"
3509
+ );
3510
+ if (!vehiclePositionsModel || !tripUpdatesModel || !stoptimeUpdatesModel || !serviceAlertsModel || !serviceAlertTargetsModel) {
3511
+ task.logError("GTFS-Realtime models definitions not found");
3512
+ return;
3513
+ }
3514
+ task.log(
3515
+ `Starting GTFS-Realtime import from ${task.realtime_urls.length} urls`
3516
+ );
3517
+ for (const realtimeUrl of task.realtime_urls) {
3518
+ task.log(`Downloading GTFS-Realtime from ${realtimeUrl}`);
3519
+ const gtfsRealtimeData = await downloadGtfsRealtimeData(realtimeUrl, task);
3520
+ if (!gtfsRealtimeData?.entity) {
3521
+ continue;
3522
+ }
3523
+ task.log(`Download successful`);
3524
+ let totalLineCount = 0;
3525
+ for (const entity of gtfsRealtimeData.entity) {
3526
+ let model56;
3527
+ if (entity.vehicle) {
3528
+ model56 = vehiclePositionsModel;
3529
+ }
3530
+ if (entity.tripUpdate) {
3531
+ model56 = tripUpdatesModel;
3532
+ }
3533
+ if (entity.alert) {
3534
+ model56 = serviceAlertsModel;
3535
+ }
3536
+ if (!model56) {
3537
+ break;
3538
+ }
3539
+ const fieldValues = model56.schema.map(
3540
+ (column) => prepareRealtimeValue(entity, column, task)
3541
+ );
3542
+ try {
3543
+ db.prepare(
3544
+ `REPLACE INTO ${model56.filenameBase} (${model56.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
3545
+ ).run();
3546
+ } catch (error) {
3547
+ task.logWarning("Import error: " + error.message);
3548
+ }
3549
+ if (entity.tripUpdate) {
3550
+ const stopTimeUpdateArray = [];
3551
+ for (const stopTimeUpdate of entity.tripUpdate.stopTimeUpdate) {
3552
+ stopTimeUpdate.parent = entity;
3553
+ const subValues = stoptimeUpdatesModel.schema.map(
3554
+ (column) => prepareRealtimeValue(stopTimeUpdate, column, task)
3555
+ );
3556
+ stopTimeUpdateArray.push(`(${subValues.join(", ")})`);
3557
+ totalLineCount++;
3558
+ }
3559
+ try {
3560
+ db.prepare(
3561
+ `REPLACE INTO ${stoptimeUpdatesModel.filenameBase} (${stoptimeUpdatesModel.schema.map((column) => column.name).join(", ")}) VALUES ${stopTimeUpdateArray.join(", ")}`
3562
+ ).run();
3563
+ } catch (error) {
3564
+ task.logWarning("Import error: " + error.message);
3565
+ }
3566
+ }
3567
+ if (entity.alert) {
3568
+ const alertTargetArray = [];
3569
+ for (const informedEntity of entity.alert.informedEntity) {
3570
+ informedEntity.parent = entity;
3571
+ const subValues = serviceAlertTargetsModel.schema.map(
3572
+ (column) => prepareRealtimeValue(informedEntity, column, task)
3573
+ );
3574
+ alertTargetArray.push(`(${subValues.join(", ")})`);
3575
+ totalLineCount++;
3576
+ }
3577
+ try {
3578
+ db.prepare(
3579
+ `REPLACE INTO ${serviceAlertTargetsModel.filenameBase} (${serviceAlertTargetsModel.schema.map((column) => column.name).join(", ")}) VALUES ${alertTargetArray.join(", ")}`
3580
+ ).run();
3581
+ } catch (error) {
3582
+ task.logWarning("Import error: " + error.message);
3583
+ }
3584
+ }
3585
+ task.log(`Importing - ${totalLineCount++} entries imported\r`, true);
3586
+ }
3587
+ }
3588
+ task.log(`GTFS-Realtime data import complete`);
3589
+ };
3590
+ var getTextFiles = async (folderPath) => {
3591
+ const files = await readdir(folderPath);
3592
+ return files.filter((filename) => filename.slice(-3) === "txt");
3593
+ };
3594
+ var readFiles = async (task) => {
3595
+ const gtfsPath = untildify3(task.path);
3596
+ task.log(`Importing GTFS from ${task.path}\r`);
3597
+ if (path2.extname(gtfsPath) === ".zip") {
3598
+ try {
3599
+ await unzip(gtfsPath, task.downloadDir);
3600
+ const textFiles = await getTextFiles(task.downloadDir);
3601
+ if (textFiles.length === 0) {
3602
+ const files = await readdir(task.downloadDir);
3603
+ const folders = files.filter((filename) => !["__MACOSX"].includes(filename)).map((filename) => path2.join(task.downloadDir, filename)).filter((source) => lstatSync(source).isDirectory());
3604
+ if (folders.length > 1) {
3605
+ throw new Error(
3606
+ `More than one subfolder found in zip file at \`${task.path}\`. Ensure that .txt files are in the top level of the zip file, or in a single subdirectory.`
3607
+ );
3608
+ } else if (folders.length === 0) {
3609
+ throw new Error(
3610
+ `No .txt files found in \`${task.path}\`. Ensure that .txt files are in the top level of the zip file, or in a single subdirectory.`
3611
+ );
3612
+ }
3613
+ const subfolderName = folders[0];
3614
+ const directoryTextFiles = await getTextFiles(subfolderName);
3615
+ if (directoryTextFiles.length === 0) {
3616
+ throw new Error(
3617
+ `No .txt files found in \`${task.path}\`. Ensure that .txt files are in the top level of the zip file, or in a single subdirectory.`
3618
+ );
3619
+ }
3620
+ await Promise.all(
3621
+ directoryTextFiles.map(
3622
+ async (fileName) => rename(
3623
+ path2.join(subfolderName, fileName),
3624
+ path2.join(task.downloadDir, fileName)
3625
+ )
3626
+ )
3627
+ );
3628
+ }
3629
+ } catch (error) {
3630
+ task.logError(error);
3631
+ throw new Error(`Unable to unzip file ${task.path}`);
3632
+ }
3633
+ } else {
3634
+ try {
3635
+ await cp(gtfsPath, task.downloadDir, { recursive: true });
3636
+ } catch {
3637
+ throw new Error(
3638
+ `Unable to load files from path \`${gtfsPath}\` defined in configuration. Verify that path exists and contains GTFS files.`
3639
+ );
3640
+ }
3641
+ }
3642
+ };
3643
+ var createTables = (db) => {
3644
+ for (const model56 of models_default) {
3645
+ if (!model56.schema) {
3646
+ return;
3647
+ }
3648
+ const columns = model56.schema.map((column) => {
3649
+ let check = "";
3650
+ if (column.min !== void 0 && column.max) {
3651
+ check = `CHECK( ${column.name} >= ${column.min} AND ${column.name} <= ${column.max} )`;
3652
+ } else if (column.min) {
3653
+ check = `CHECK( ${column.name} >= ${column.min} )`;
3654
+ } else if (column.max) {
3655
+ check = `CHECK( ${column.name} <= ${column.max} )`;
3656
+ }
3657
+ const required = column.required ? "NOT NULL" : "";
3658
+ const columnDefault = column.default ? "DEFAULT " + column.default : "";
3659
+ const columnCollation = column.nocase ? "COLLATE NOCASE" : "";
3660
+ return `${column.name} ${column.type} ${check} ${required} ${columnDefault} ${columnCollation}`;
3661
+ });
3662
+ const primaryColumns = model56.schema.filter((column) => column.primary);
3663
+ if (primaryColumns.length > 0) {
3664
+ columns.push(
3665
+ `PRIMARY KEY (${primaryColumns.map((column) => column.name).join(", ")})`
3666
+ );
3667
+ }
3668
+ db.prepare(`DROP TABLE IF EXISTS ${model56.filenameBase};`).run();
3669
+ db.prepare(
3670
+ `CREATE TABLE ${model56.filenameBase} (${columns.join(", ")});`
3671
+ ).run();
3672
+ for (const column of model56.schema.filter((column2) => column2.index)) {
3673
+ db.prepare(
3674
+ `CREATE INDEX idx_${model56.filenameBase}_${column.name} ON ${model56.filenameBase} (${column.name});`
3675
+ ).run();
3676
+ }
3677
+ }
3678
+ };
3679
+ var formatLine = (line, model56, totalLineCount) => {
3680
+ const lineNumber = totalLineCount + 1;
3681
+ const formattedLine = {};
3682
+ for (const columnSchema of model56.schema) {
3683
+ const lineValue = line[columnSchema.name];
3684
+ if (columnSchema.type === "integer") {
3685
+ formattedLine[columnSchema.name] = Number.parseInt(lineValue, 10);
3686
+ } else if (columnSchema.type === "real") {
3687
+ formattedLine[columnSchema.name] = Number.parseFloat(lineValue);
3688
+ } else {
3689
+ formattedLine[columnSchema.name] = lineValue;
3690
+ }
3691
+ if (formattedLine[columnSchema.name] === "" || formattedLine[columnSchema.name] === void 0 || formattedLine[columnSchema.name] === null || Number.isNaN(formattedLine[columnSchema.name])) {
3692
+ formattedLine[columnSchema.name] = null;
3693
+ }
3694
+ if (columnSchema.required === true && formattedLine[columnSchema.name] === null) {
3695
+ throw new Error(
3696
+ `Missing required value in ${model56.filenameBase}.${model56.filenameExtension} for ${columnSchema.name} on line ${lineNumber}.`
3697
+ );
3698
+ }
3699
+ if (columnSchema.min !== void 0 && formattedLine[columnSchema.name] < columnSchema.min) {
3700
+ throw new Error(
3701
+ `Invalid value in ${model56.filenameBase}.${model56.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: below minimum value of ${columnSchema.min}.`
3702
+ );
3703
+ }
3704
+ if (columnSchema.max !== void 0 && formattedLine[columnSchema.name] > columnSchema.max) {
3705
+ throw new Error(
3706
+ `Invalid value in ${model56.filenameBase}.${model56.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: above maximum value of ${columnSchema.max}.`
3707
+ );
3708
+ }
3709
+ }
3710
+ const timeColumnNames = [
3711
+ "start_time",
3712
+ "end_time",
3713
+ "arrival_time",
3714
+ "departure_time",
3715
+ "prior_notice_last_time",
3716
+ "prior_notice_start_time",
3717
+ "start_pickup_drop_off_window"
3718
+ ];
3719
+ for (const timeColumnName of timeColumnNames) {
3720
+ if (formattedLine[timeColumnName]) {
3721
+ const timestampColumnName = timeColumnName.endsWith("time") ? `${timeColumnName}stamp` : `${timeColumnName}_timestamp`;
3722
+ formattedLine[timestampColumnName] = calculateSecondsFromMidnight(
3723
+ formattedLine[timeColumnName]
3724
+ );
3725
+ formattedLine[timeColumnName] = padLeadingZeros(
3726
+ formattedLine[timeColumnName]
3727
+ );
3728
+ }
3729
+ }
3730
+ return formattedLine;
3731
+ };
3732
+ var importLines = (task, lines, model56, totalLineCount) => {
3733
+ const db = openDb({
3734
+ sqlitePath: task.sqlitePath,
3735
+ agencies: []
3736
+ });
3737
+ if (lines.length === 0) {
3738
+ return;
3739
+ }
3740
+ const linesToImportCount = lines.length;
3741
+ const columns = model56.schema.filter((column) => column.name !== "id");
3742
+ const placeholders = [];
3743
+ const values = [];
3744
+ while (lines.length > 0) {
3745
+ const line = lines.pop();
3746
+ if (line === void 0) {
3747
+ continue;
3748
+ }
3749
+ placeholders.push(`(${columns.map(() => "?").join(", ")})`);
3750
+ values.push(
3751
+ ...columns.map((column) => {
3752
+ if (task.prefix !== void 0 && column.prefix === true) {
3753
+ return `${task.prefix}${line[column.name]}`;
3754
+ }
3755
+ return line[column.name];
3756
+ })
3757
+ );
3758
+ }
3759
+ try {
3760
+ db.prepare(
3761
+ `INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model56.filenameBase} (${columns.map((column) => column.name).join(", ")}) VALUES ${placeholders.join(",")}`
3762
+ ).run(...values);
3763
+ } catch (error) {
3764
+ if (error.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
3765
+ const primaryColumns = model56.schema.filter((column) => column.primary);
3766
+ task.logWarning(
3767
+ `Duplicate values for primary key (${primaryColumns.map((column) => column.name).join(", ")}) found in ${model56.filenameBase}.${model56.filenameExtension}. Set the \`ignoreDuplicates\` option to true in config.json to ignore this error`
3768
+ );
3769
+ }
3770
+ task.logWarning(
3771
+ `Check ${model56.filenameBase}.${model56.filenameExtension} for invalid data between lines ${totalLineCount - linesToImportCount} and ${totalLineCount}.`
3772
+ );
3773
+ throw error;
3774
+ }
3775
+ task.log(
3776
+ `Importing - ${model56.filenameBase}.${model56.filenameExtension} - ${totalLineCount} lines imported\r`,
3777
+ true
3778
+ );
3779
+ };
3780
+ var importFiles = (task) => mapSeries(
3781
+ models_default,
3782
+ (model56) => new Promise((resolve, reject) => {
3783
+ const lines = [];
3784
+ let totalLineCount = 0;
3785
+ const maxInsertVariables = 32e3;
3786
+ if (task.exclude && task.exclude.includes(model56.filenameBase)) {
3787
+ task.log(
3788
+ `Skipping - ${model56.filenameBase}.${model56.filenameExtension}\r`
3789
+ );
3790
+ resolve();
3791
+ return;
3792
+ }
3793
+ if (model56.extension === "gtfs-realtime") {
3794
+ resolve();
3795
+ return;
3796
+ }
3797
+ const filepath = path2.join(
3798
+ task.downloadDir,
3799
+ `${model56.filenameBase}.${model56.filenameExtension}`
3800
+ );
3801
+ if (!existsSync2(filepath)) {
3802
+ if (!model56.nonstandard) {
3803
+ task.log(
3804
+ `Importing - ${model56.filenameBase}.${model56.filenameExtension} - No file found\r`
3805
+ );
3806
+ }
3807
+ resolve();
3808
+ return;
3809
+ }
3810
+ task.log(
3811
+ `Importing - ${model56.filenameBase}.${model56.filenameExtension}\r`
3812
+ );
3813
+ if (model56.filenameExtension === "txt") {
3814
+ const parser = parse({
3815
+ columns: true,
3816
+ relax_quotes: true,
3817
+ trim: true,
3818
+ skip_empty_lines: true,
3819
+ ...task.csvOptions
3820
+ });
3821
+ parser.on("readable", () => {
3822
+ let record;
3823
+ while (record = parser.read()) {
3824
+ try {
3825
+ totalLineCount += 1;
3826
+ lines.push(formatLine(record, model56, totalLineCount));
3827
+ if (lines.length >= maxInsertVariables / model56.schema.length) {
3828
+ importLines(task, lines, model56, totalLineCount);
3829
+ }
3830
+ } catch (error) {
3831
+ reject(error);
3832
+ }
3833
+ }
3834
+ });
3835
+ parser.on("end", () => {
3836
+ try {
3837
+ importLines(task, lines, model56, totalLineCount);
3838
+ } catch (error) {
3839
+ reject(error);
3840
+ }
3841
+ resolve();
3842
+ });
3843
+ parser.on("error", reject);
3844
+ createReadStream(filepath).pipe(stripBomStream()).pipe(parser);
3845
+ } else if (model56.filenameExtension === "geojson") {
3846
+ readFile2(filepath, "utf8").then((data) => {
3847
+ if (isValidJSON(data) === false) {
3848
+ reject(
3849
+ new Error(
3850
+ `Invalid JSON in ${model56.filenameBase}.${model56.filenameExtension}`
3851
+ )
3852
+ );
3853
+ }
3854
+ const line = formatLine({ geojson: data }, model56, totalLineCount);
3855
+ importLines(task, [line], model56, totalLineCount);
3856
+ resolve();
3857
+ }).catch(reject);
3858
+ } else {
3859
+ reject(
3860
+ new Error(`Unsupported file type: ${model56.filenameExtension}`)
3861
+ );
3862
+ }
3863
+ })
3864
+ );
3865
+ async function importGtfs(initialConfig) {
3866
+ const config = setDefaultConfig(initialConfig);
3867
+ validateConfigForImport(config);
3868
+ const log2 = log(config);
3869
+ const logError2 = logError(config);
3870
+ const logWarning2 = logWarning(config);
3871
+ try {
3872
+ const db = openDb(config);
3873
+ const agencyCount = config.agencies.length;
3874
+ log2(
3875
+ `Starting GTFS import for ${pluralize(
3876
+ "file",
3877
+ agencyCount,
3878
+ true
3879
+ )} using SQLite database at ${config.sqlitePath}`
3880
+ );
3881
+ createTables(db);
3882
+ await mapSeries(
3883
+ config.agencies,
3884
+ async (agency) => {
3885
+ const tempPath = temporaryDirectory();
3886
+ const task = {
3887
+ exclude: agency.exclude,
3888
+ agency_url: agency.url,
3889
+ headers: agency.headers,
3890
+ realtime_headers: agency.realtimeHeaders,
3891
+ realtime_urls: agency.realtimeUrls,
3892
+ downloadDir: tempPath,
3893
+ downloadTimeout: config.downloadTimeout,
3894
+ gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
3895
+ path: agency.path,
3896
+ csvOptions: config.csvOptions || {},
3897
+ ignoreDuplicates: config.ignoreDuplicates,
3898
+ sqlitePath: config.sqlitePath,
3899
+ prefix: agency.prefix,
3900
+ currentTimestamp: Math.floor(Date.now() / 1e3),
3901
+ log: log2,
3902
+ logWarning: logWarning2,
3903
+ logError: logError2
3904
+ };
3905
+ try {
3906
+ if (task.agency_url) {
3907
+ await downloadFiles(task);
3908
+ }
3909
+ await readFiles(task);
3910
+ await importFiles(task);
3911
+ await updateRealtimeData(task);
3912
+ await rm2(tempPath, { recursive: true });
3913
+ } catch (error) {
3914
+ if (config.ignoreErrors) {
3915
+ logError2(error.message);
3916
+ } else {
3917
+ throw error;
3918
+ }
3919
+ }
3920
+ }
3921
+ );
3922
+ log2(
3923
+ `Completed GTFS import for ${pluralize("agency", agencyCount, true)}
3924
+ `
3925
+ );
3926
+ } catch (error) {
3927
+ if (error?.code === "SQLITE_CANTOPEN") {
3928
+ logError2(
3929
+ `Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
3930
+ );
3931
+ }
3932
+ throw error;
3933
+ }
3934
+ }
3935
+
3936
+ // src/lib/export.ts
3937
+ import { without, compact } from "lodash-es";
3938
+ import pluralize2 from "pluralize";
3939
+ import { stringify } from "csv-stringify";
3940
+ import sqlString3 from "sqlstring-sqlite";
3941
+ import mapSeries2 from "promise-map-series";
3942
+ import untildify4 from "untildify";
3943
+
3944
+ // src/lib/advancedQuery.ts
3945
+ import sqlString4 from "sqlstring-sqlite";
3946
+
3947
+ // src/lib/gtfs/agencies.ts
3948
+ import sqlString5 from "sqlstring-sqlite";
3949
+
3950
+ // src/lib/gtfs/areas.ts
3951
+ import sqlString6 from "sqlstring-sqlite";
3952
+
3953
+ // src/lib/gtfs/attributions.ts
3954
+ import sqlString7 from "sqlstring-sqlite";
3955
+
3956
+ // src/lib/gtfs/booking-rules.ts
3957
+ import sqlString8 from "sqlstring-sqlite";
3958
+
3959
+ // src/lib/gtfs/calendar-dates.ts
3960
+ import sqlString9 from "sqlstring-sqlite";
3961
+
3962
+ // src/lib/gtfs/calendars.ts
3963
+ import sqlString10 from "sqlstring-sqlite";
3964
+
3965
+ // src/lib/gtfs/fare-attributes.ts
3966
+ import sqlString11 from "sqlstring-sqlite";
3967
+
3968
+ // src/lib/gtfs/fare-leg-rules.ts
3969
+ import sqlString12 from "sqlstring-sqlite";
3970
+
3971
+ // src/lib/gtfs/fare-media.ts
3972
+ import sqlString13 from "sqlstring-sqlite";
3973
+
3974
+ // src/lib/gtfs/fare-products.ts
3975
+ import sqlString14 from "sqlstring-sqlite";
3976
+
3977
+ // src/lib/gtfs/fare-rules.ts
3978
+ import sqlString15 from "sqlstring-sqlite";
3979
+
3980
+ // src/lib/gtfs/fare-transfer-rules.ts
3981
+ import sqlString16 from "sqlstring-sqlite";
3982
+
3983
+ // src/lib/gtfs/feed-info.ts
3984
+ import sqlString17 from "sqlstring-sqlite";
3985
+
3986
+ // src/lib/gtfs/frequencies.ts
3987
+ import sqlString18 from "sqlstring-sqlite";
3988
+
3989
+ // src/lib/gtfs/levels.ts
3990
+ import sqlString19 from "sqlstring-sqlite";
3991
+
3992
+ // src/lib/gtfs/location-groups.ts
3993
+ import sqlString20 from "sqlstring-sqlite";
3994
+
3995
+ // src/lib/gtfs/location-group-stops.ts
3996
+ import sqlString21 from "sqlstring-sqlite";
3997
+
3998
+ // src/lib/gtfs/locations.ts
3999
+ import sqlString22 from "sqlstring-sqlite";
4000
+
4001
+ // src/lib/gtfs/networks.ts
4002
+ import sqlString23 from "sqlstring-sqlite";
4003
+
4004
+ // src/lib/gtfs/pathways.ts
4005
+ import sqlString24 from "sqlstring-sqlite";
4006
+
4007
+ // src/lib/gtfs/route-networks.ts
4008
+ import sqlString25 from "sqlstring-sqlite";
4009
+
4010
+ // src/lib/gtfs/routes.ts
4011
+ import { omit as omit3, pick } from "lodash-es";
4012
+ import sqlString26 from "sqlstring-sqlite";
4013
+
4014
+ // src/lib/gtfs/shapes.ts
4015
+ import { omit as omit4, pick as pick2 } from "lodash-es";
4016
+ import sqlString28 from "sqlstring-sqlite";
4017
+ import { featureCollection as featureCollection2 } from "@turf/helpers";
4018
+
4019
+ // src/lib/gtfs-plus/route-attributes.ts
4020
+ import sqlString27 from "sqlstring-sqlite";
4021
+
4022
+ // src/lib/gtfs/stop-areas.ts
4023
+ import sqlString29 from "sqlstring-sqlite";
4024
+
4025
+ // src/lib/gtfs/stops.ts
4026
+ import { omit as omit5, orderBy, pick as pick3 } from "lodash-es";
4027
+ import sqlString31 from "sqlstring-sqlite";
4028
+
4029
+ // src/lib/gtfs-plus/stop-attributes.ts
4030
+ import sqlString30 from "sqlstring-sqlite";
4031
+
4032
+ // src/lib/gtfs/stop-times.ts
4033
+ import sqlString32 from "sqlstring-sqlite";
4034
+
4035
+ // src/lib/gtfs/timeframes.ts
4036
+ import sqlString33 from "sqlstring-sqlite";
4037
+
4038
+ // src/lib/gtfs/transfers.ts
4039
+ import sqlString34 from "sqlstring-sqlite";
4040
+
4041
+ // src/lib/gtfs/translations.ts
4042
+ import sqlString35 from "sqlstring-sqlite";
4043
+
4044
+ // src/lib/gtfs/trips.ts
4045
+ import sqlString36 from "sqlstring-sqlite";
4046
+
4047
+ // src/lib/gtfs-plus/calendar-attributes.ts
4048
+ import sqlString37 from "sqlstring-sqlite";
4049
+
4050
+ // src/lib/gtfs-plus/directions.ts
4051
+ import sqlString38 from "sqlstring-sqlite";
4052
+
4053
+ // src/lib/non-standard/timetables.ts
4054
+ import sqlString39 from "sqlstring-sqlite";
4055
+
4056
+ // src/lib/non-standard/timetable-stop-order.ts
4057
+ import sqlString40 from "sqlstring-sqlite";
4058
+
4059
+ // src/lib/non-standard/timetable-pages.ts
4060
+ import sqlString41 from "sqlstring-sqlite";
4061
+
4062
+ // src/lib/non-standard/timetable-notes.ts
4063
+ import sqlString42 from "sqlstring-sqlite";
4064
+
4065
+ // src/lib/non-standard/timetable-notes-references.ts
4066
+ import sqlString43 from "sqlstring-sqlite";
4067
+
4068
+ // src/lib/non-standard/trips-dated-vehicle-journey.ts
4069
+ import sqlString44 from "sqlstring-sqlite";
4070
+
4071
+ // src/lib/gtfs-ride/board-alights.ts
4072
+ import sqlString45 from "sqlstring-sqlite";
4073
+
4074
+ // src/lib/gtfs-ride/ride-feed-infos.ts
4075
+ import sqlString46 from "sqlstring-sqlite";
4076
+
4077
+ // src/lib/gtfs-ride/rider-trips.ts
4078
+ import sqlString47 from "sqlstring-sqlite";
4079
+
4080
+ // src/lib/gtfs-ride/riderships.ts
4081
+ import sqlString48 from "sqlstring-sqlite";
4082
+
4083
+ // src/lib/gtfs-ride/trip-capacities.ts
4084
+ import sqlString49 from "sqlstring-sqlite";
4085
+
4086
+ // src/lib/gtfs-realtime/stop-time-updates.ts
4087
+ import sqlString50 from "sqlstring-sqlite";
4088
+
4089
+ // src/lib/gtfs-realtime/trip-updates.ts
4090
+ import sqlString51 from "sqlstring-sqlite";
4091
+
4092
+ // src/lib/gtfs-realtime/vehicle-positions.ts
4093
+ import sqlString52 from "sqlstring-sqlite";
4094
+
4095
+ // src/lib/gtfs-realtime/service-alerts.ts
4096
+ import sqlString53 from "sqlstring-sqlite";
4097
+
4098
+ // src/lib/ods/deadheads.ts
4099
+ import sqlString54 from "sqlstring-sqlite";
4100
+
4101
+ // src/lib/ods/deadhead-times.ts
4102
+ import sqlString55 from "sqlstring-sqlite";
4103
+
4104
+ // src/lib/ods/ops-locations.ts
4105
+ import sqlString56 from "sqlstring-sqlite";
4106
+
4107
+ // src/lib/ods/run-events.ts
4108
+ import sqlString57 from "sqlstring-sqlite";
4109
+
4110
+ // src/lib/ods/runs-pieces.ts
4111
+ import sqlString58 from "sqlstring-sqlite";
4112
+
4113
+ // src/bin/gtfs-import.ts
4114
+ var pe = new PrettyError();
4115
+ var argv = yargs(hideBin(process.argv)).usage("Usage: $0 --configPath ./config.json").help().option("c", {
4116
+ alias: "configPath",
4117
+ describe: "Path to config file",
4118
+ type: "string"
4119
+ }).option("gtfsPath", {
4120
+ describe: "Path to gtfs (zipped or unzipped)",
4121
+ type: "string"
4122
+ }).option("gtfsUrl", {
4123
+ describe: "URL of gtfs file",
4124
+ type: "string"
4125
+ }).option("sqlitePath", {
4126
+ describe: "Path to SQLite database",
4127
+ type: "string"
4128
+ }).parseSync();
4129
+ var handleError = (error = "Unknown Error") => {
4130
+ process.stdout.write(`
4131
+ ${formatError(error)}
4132
+ `);
4133
+ console.error(pe.render(error));
4134
+ process.exit(1);
4135
+ };
4136
+ var setupImport = async () => {
4137
+ const config = await getConfig(argv);
4138
+ await importGtfs(config);
4139
+ const db = openDb(config);
4140
+ if (db.name !== ":memory:") {
4141
+ closeDb(db);
4142
+ }
4143
+ process.exit();
4144
+ };
4145
+ setupImport().catch(handleError);
4146
+ //# sourceMappingURL=gtfs-import.js.map