gtfs 4.15.6 → 4.15.7

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.
@@ -18,6 +18,48 @@ import { omit, snakeCase } from "lodash-es";
18
18
  import sanitize from "sanitize-filename";
19
19
  import untildify from "untildify";
20
20
  import StreamZip from "node-stream-zip";
21
+
22
+ // src/lib/log-utils.ts
23
+ import { clearLine, cursorTo } from "node:readline";
24
+ import { noop } from "lodash-es";
25
+ import * as colors from "yoctocolors";
26
+ function log(config) {
27
+ if (config.verbose === false) {
28
+ return noop;
29
+ }
30
+ if (config.logFunction) {
31
+ return config.logFunction;
32
+ }
33
+ return (text, overwrite = false) => {
34
+ if (overwrite && process.stdout.isTTY) {
35
+ clearLine(process.stdout, 0);
36
+ cursorTo(process.stdout, 0);
37
+ } else {
38
+ process.stdout.write("\n");
39
+ }
40
+ process.stdout.write(text);
41
+ };
42
+ }
43
+ function logWarning(config) {
44
+ if (config.logFunction) {
45
+ return config.logFunction;
46
+ }
47
+ return (text) => {
48
+ process.stdout.write(`
49
+ ${formatWarning(text)}
50
+ `);
51
+ };
52
+ }
53
+ function formatWarning(text) {
54
+ return colors.yellow(`${colors.underline("Warning")}: ${text}`);
55
+ }
56
+ function formatError(error) {
57
+ const messageText = error instanceof Error ? error.message : error;
58
+ const cleanMessage = messageText.replace(/^Error:\s*/i, "");
59
+ return colors.red(`${colors.underline("Error")}: ${cleanMessage}`);
60
+ }
61
+
62
+ // src/lib/file-utils.ts
21
63
  async function getConfig(argv2) {
22
64
  let config;
23
65
  let data;
@@ -38,7 +80,7 @@ async function getConfig(argv2) {
38
80
  } else if (existsSync(path.resolve("./config.json"))) {
39
81
  data = await readFile(path.resolve("./config.json"), "utf8");
40
82
  config = Object.assign(JSON.parse(data), argv2);
41
- console.log("Using configuration from ./config.json");
83
+ log(config)("Using configuration from ./config.json");
42
84
  } else {
43
85
  throw new Error(
44
86
  "Cannot find configuration file. Use config-sample.json as a starting point, pass --configPath option."
@@ -65,46 +107,6 @@ function generateFolderName(folderName) {
65
107
  return snakeCase(sanitize(folderName));
66
108
  }
67
109
 
68
- // src/lib/log-utils.ts
69
- import { clearLine, cursorTo } from "node:readline";
70
- import { noop } from "lodash-es";
71
- import * as colors from "yoctocolors";
72
- function log(config) {
73
- if (!config.verbose) {
74
- return noop;
75
- }
76
- if (config.logFunction) {
77
- return config.logFunction;
78
- }
79
- return (text, overwrite = false) => {
80
- if (overwrite && process.stdout.isTTY) {
81
- clearLine(process.stdout, 0);
82
- cursorTo(process.stdout, 0);
83
- } else {
84
- process.stdout.write("\n");
85
- }
86
- process.stdout.write(text);
87
- };
88
- }
89
- function logWarning(config) {
90
- if (config.logFunction) {
91
- return config.logFunction;
92
- }
93
- return (text) => {
94
- process.stdout.write(`
95
- ${formatWarning(text)}
96
- `);
97
- };
98
- }
99
- function formatWarning(text) {
100
- return colors.yellow(`${colors.underline("Warning")}: ${text}`);
101
- }
102
- function formatError(error) {
103
- const messageText = error instanceof Error ? error.message : error;
104
- const cleanMessage = messageText.replace(/^Error:\s*/i, "");
105
- return colors.red(`${colors.underline("Error")}: ${cleanMessage}`);
106
- }
107
-
108
110
  // src/lib/import-gtfs.ts
109
111
  import { parse } from "csv-parse";
110
112
  import pluralize2 from "pluralize";
@@ -250,7 +252,8 @@ var attributions = {
250
252
  {
251
253
  name: "attribution_id",
252
254
  type: "text",
253
- prefix: true
255
+ prefix: true,
256
+ primary: true
254
257
  },
255
258
  {
256
259
  name: "agency_id",
@@ -683,26 +686,31 @@ var fareRules = {
683
686
  name: "fare_id",
684
687
  type: "text",
685
688
  required: true,
689
+ primary: true,
686
690
  prefix: true
687
691
  },
688
692
  {
689
693
  name: "route_id",
690
694
  type: "text",
695
+ primary: true,
691
696
  prefix: true
692
697
  },
693
698
  {
694
699
  name: "origin_id",
695
700
  type: "text",
701
+ primary: true,
696
702
  prefix: true
697
703
  },
698
704
  {
699
705
  name: "destination_id",
700
706
  type: "text",
707
+ primary: true,
701
708
  prefix: true
702
709
  },
703
710
  {
704
711
  name: "contains_id",
705
712
  type: "text",
713
+ primary: true,
706
714
  prefix: true
707
715
  }
708
716
  ]
@@ -909,14 +917,16 @@ var locationGroupStops = {
909
917
  type: "text",
910
918
  prefix: true,
911
919
  index: true,
912
- required: true
920
+ required: true,
921
+ primary: true
913
922
  },
914
923
  {
915
924
  name: "stop_id",
916
925
  type: "text",
917
926
  required: true,
918
927
  prefix: true,
919
- index: true
928
+ index: true,
929
+ primary: true
920
930
  }
921
931
  ]
922
932
  };
@@ -1177,12 +1187,14 @@ var stopAreas = {
1177
1187
  name: "area_id",
1178
1188
  type: "text",
1179
1189
  required: true,
1190
+ primary: true,
1180
1191
  prefix: true
1181
1192
  },
1182
1193
  {
1183
1194
  name: "stop_id",
1184
1195
  type: "text",
1185
1196
  required: true,
1197
+ primary: true,
1186
1198
  prefix: true
1187
1199
  }
1188
1200
  ]
@@ -1406,16 +1418,19 @@ var timeframes = {
1406
1418
  },
1407
1419
  {
1408
1420
  name: "start_time",
1409
- type: "text"
1421
+ type: "text",
1422
+ primary: true
1410
1423
  },
1411
1424
  {
1412
1425
  name: "end_time",
1413
- type: "text"
1426
+ type: "text",
1427
+ primary: true
1414
1428
  },
1415
1429
  {
1416
1430
  name: "service_id",
1417
1431
  type: "text",
1418
1432
  required: true,
1433
+ primary: true,
1419
1434
  index: true,
1420
1435
  prefix: true
1421
1436
  }
@@ -1602,21 +1617,19 @@ var timetables = {
1602
1617
  filenameExtension: "txt",
1603
1618
  nonstandard: true,
1604
1619
  schema: [
1605
- {
1606
- name: "id",
1607
- type: "integer",
1608
- primary: true,
1609
- prefix: true
1610
- },
1611
1620
  {
1612
1621
  name: "timetable_id",
1613
1622
  type: "text",
1614
- prefix: true
1623
+ prefix: true,
1624
+ required: true,
1625
+ primary: true
1615
1626
  },
1616
1627
  {
1617
1628
  name: "route_id",
1618
1629
  type: "text",
1619
- prefix: true
1630
+ prefix: true,
1631
+ required: true,
1632
+ primary: true
1620
1633
  },
1621
1634
  {
1622
1635
  name: "direction_id",
@@ -1750,6 +1763,7 @@ var timetablePages = {
1750
1763
  name: "timetable_page_id",
1751
1764
  type: "text",
1752
1765
  primary: true,
1766
+ required: true,
1753
1767
  prefix: true
1754
1768
  },
1755
1769
  {
@@ -1769,28 +1783,28 @@ var timetableStopOrder = {
1769
1783
  filenameExtension: "txt",
1770
1784
  nonstandard: true,
1771
1785
  schema: [
1772
- {
1773
- name: "id",
1774
- type: "integer",
1775
- primary: true,
1776
- prefix: true
1777
- },
1778
1786
  {
1779
1787
  name: "timetable_id",
1780
1788
  type: "text",
1781
1789
  index: true,
1782
- prefix: true
1790
+ prefix: true,
1791
+ required: true,
1792
+ primary: true
1783
1793
  },
1784
1794
  {
1785
1795
  name: "stop_id",
1786
1796
  type: "text",
1787
- prefix: true
1797
+ prefix: true,
1798
+ required: true,
1799
+ primary: true
1788
1800
  },
1789
1801
  {
1790
1802
  name: "stop_sequence",
1791
1803
  type: "integer",
1792
1804
  min: 0,
1793
- index: true
1805
+ index: true,
1806
+ required: true,
1807
+ primary: true
1794
1808
  }
1795
1809
  ]
1796
1810
  };
@@ -1805,7 +1819,8 @@ var timetableNotes = {
1805
1819
  name: "note_id",
1806
1820
  type: "text",
1807
1821
  primary: true,
1808
- prefix: true
1822
+ prefix: true,
1823
+ required: true
1809
1824
  },
1810
1825
  {
1811
1826
  name: "symbol",
@@ -1814,7 +1829,8 @@ var timetableNotes = {
1814
1829
  {
1815
1830
  name: "note",
1816
1831
  type: "text",
1817
- nocase: true
1832
+ nocase: true,
1833
+ required: true
1818
1834
  }
1819
1835
  ]
1820
1836
  };
@@ -1828,37 +1844,39 @@ var timetableNotesReferences = {
1828
1844
  {
1829
1845
  name: "note_id",
1830
1846
  type: "text",
1831
- prefix: true
1847
+ prefix: true,
1848
+ required: true,
1849
+ primary: true
1832
1850
  },
1833
1851
  {
1834
1852
  name: "timetable_id",
1835
1853
  type: "text",
1836
- index: true,
1837
- prefix: true
1854
+ prefix: true,
1855
+ primary: true
1838
1856
  },
1839
1857
  {
1840
1858
  name: "route_id",
1841
1859
  type: "text",
1842
- index: true,
1843
- prefix: true
1860
+ prefix: true,
1861
+ primary: true
1844
1862
  },
1845
1863
  {
1846
1864
  name: "trip_id",
1847
1865
  type: "text",
1848
- index: true,
1849
- prefix: true
1866
+ prefix: true,
1867
+ primary: true
1850
1868
  },
1851
1869
  {
1852
1870
  name: "stop_id",
1853
1871
  type: "text",
1854
- index: true,
1855
- prefix: true
1872
+ prefix: true,
1873
+ primary: true
1856
1874
  },
1857
1875
  {
1858
1876
  name: "stop_sequence",
1859
1877
  type: "integer",
1860
1878
  min: 0,
1861
- index: true
1879
+ primary: true
1862
1880
  },
1863
1881
  {
1864
1882
  name: "show_on_stoptime",
@@ -3253,7 +3271,8 @@ function setDefaultConfig(initialConfig) {
3253
3271
  sqlitePath: ":memory:",
3254
3272
  ignoreDuplicates: false,
3255
3273
  ignoreErrors: false,
3256
- gtfsRealtimeExpirationSeconds: 0
3274
+ gtfsRealtimeExpirationSeconds: 0,
3275
+ verbose: true
3257
3276
  };
3258
3277
  return {
3259
3278
  ...defaults,