gtfs 3.7.0 → 4.0.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 (91) hide show
  1. package/.github/workflows/nodejs.yml +13 -13
  2. package/@types/index.d.ts +35 -60
  3. package/@types/tests.ts +18 -13
  4. package/CHANGELOG.md +21 -0
  5. package/README.md +228 -208
  6. package/lib/advancedQuery.js +8 -17
  7. package/lib/db.js +29 -59
  8. package/lib/export.js +16 -10
  9. package/lib/gtfs/agencies.js +8 -6
  10. package/lib/gtfs/areas.js +8 -11
  11. package/lib/gtfs/attributions.js +8 -6
  12. package/lib/gtfs/calendar-dates.js +8 -6
  13. package/lib/gtfs/calendars.js +8 -6
  14. package/lib/gtfs/fare-attributes.js +8 -6
  15. package/lib/gtfs/fare-leg-rules.js +8 -6
  16. package/lib/gtfs/fare-products.js +8 -6
  17. package/lib/gtfs/fare-rules.js +8 -6
  18. package/lib/gtfs/fare-transfer-rules.js +8 -6
  19. package/lib/gtfs/feed-info.js +8 -6
  20. package/lib/gtfs/frequencies.js +8 -6
  21. package/lib/gtfs/levels.js +8 -11
  22. package/lib/gtfs/pathways.js +8 -6
  23. package/lib/gtfs/routes.js +8 -11
  24. package/lib/gtfs/shapes.js +34 -39
  25. package/lib/gtfs/stop-areas.js +8 -6
  26. package/lib/gtfs/stop-times.js +8 -6
  27. package/lib/gtfs/stops.js +27 -33
  28. package/lib/gtfs/transfers.js +8 -6
  29. package/lib/gtfs/translations.js +8 -6
  30. package/lib/gtfs/trips.js +8 -11
  31. package/lib/gtfs-realtime/service-alerts.js +9 -7
  32. package/lib/gtfs-realtime/stop-times-updates.js +9 -7
  33. package/lib/gtfs-realtime/trip-updates.js +9 -7
  34. package/lib/gtfs-realtime/vehicle-positions.js +9 -7
  35. package/lib/gtfs-ride/board-alights.js +8 -6
  36. package/lib/gtfs-ride/ride-feed-infos.js +8 -6
  37. package/lib/gtfs-ride/rider-trips.js +8 -6
  38. package/lib/gtfs-ride/riderships.js +8 -6
  39. package/lib/gtfs-ride/trip-capacities.js +8 -6
  40. package/lib/gtfs.js +3 -9
  41. package/lib/import.js +195 -202
  42. package/lib/non-standard/directions.js +8 -6
  43. package/lib/non-standard/stop-attributes.js +8 -6
  44. package/lib/non-standard/timetable-notes-references.js +8 -6
  45. package/lib/non-standard/timetable-notes.js +8 -6
  46. package/lib/non-standard/timetable-pages.js +8 -6
  47. package/lib/non-standard/timetable-stop-order.js +8 -6
  48. package/lib/non-standard/timetables.js +8 -6
  49. package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
  50. package/models/gtfs/transfers.js +2 -1
  51. package/package.json +9 -9
  52. package/test/mocha/advanced-query.js +9 -15
  53. package/test/mocha/export-gtfs.js +5 -6
  54. package/test/mocha/fare-transfer-rules.js +32 -0
  55. package/test/mocha/get-agencies.js +13 -19
  56. package/test/mocha/get-areas.js +27 -0
  57. package/test/mocha/get-attributions.js +7 -13
  58. package/test/mocha/get-board-alights.js +7 -13
  59. package/test/mocha/get-calendar-dates.js +11 -17
  60. package/test/mocha/get-calendars.js +11 -17
  61. package/test/mocha/get-directions.js +7 -13
  62. package/test/mocha/get-fare-attributes.js +9 -15
  63. package/test/mocha/get-fare-leg-rules.js +27 -0
  64. package/test/mocha/get-fare-products.js +27 -0
  65. package/test/mocha/get-fare-rules.js +9 -15
  66. package/test/mocha/get-feed-info.js +7 -13
  67. package/test/mocha/get-frequencies.js +7 -13
  68. package/test/mocha/get-levels.js +7 -7
  69. package/test/mocha/get-pathways.js +7 -13
  70. package/test/mocha/get-ride-feed-infos.js +7 -13
  71. package/test/mocha/get-rider-trips.js +7 -13
  72. package/test/mocha/get-riderships.js +7 -13
  73. package/test/mocha/get-routes.js +13 -13
  74. package/test/mocha/get-shapes-as-geojson.js +14 -15
  75. package/test/mocha/get-shapes.js +25 -25
  76. package/test/mocha/get-stop-attributes.js +7 -13
  77. package/test/mocha/get-stops-as-geojson.js +13 -19
  78. package/test/mocha/get-stops.js +19 -19
  79. package/test/mocha/get-stoptimes.js +11 -17
  80. package/test/mocha/get-timetable-pages.js +7 -13
  81. package/test/mocha/get-timetable-stop-orders.js +6 -7
  82. package/test/mocha/get-timetables.js +7 -13
  83. package/test/mocha/get-transfers.js +7 -13
  84. package/test/mocha/get-translations.js +7 -13
  85. package/test/mocha/get-trip-capacities.js +7 -13
  86. package/test/mocha/get-trips.js +9 -9
  87. package/test/mocha/import-gtfs.js +11 -11
  88. package/test/mocha/{get-db.js → open-db.js} +37 -29
  89. package/test/mocha/raw-query.js +34 -0
  90. package/test/mocha/exec-raw-query.js +0 -39
  91. package/test/mocha/run-raw-query.js +0 -54
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import riderTrip from '../../models/gtfs-ride/rider-trip.js';
12
12
  /*
13
13
  * Returns an array of all rider trips that match the query parameters.
14
14
  */
15
- export async function getRiderTrips(
15
+ export function getRiderTrips(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(riderTrip.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import riderships from '../../models/gtfs-ride/ridership.js';
12
12
  /*
13
13
  * Returns an array of all riderships that match the query parameters.
14
14
  */
15
- export async function getRiderships(
15
+ export function getRiderships(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(riderships.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
@@ -1,6 +1,6 @@
1
1
  import sqlString from 'sqlstring-sqlite';
2
2
 
3
- import { getDb } from '../db.js';
3
+ import { openDb } from '../db.js';
4
4
 
5
5
  import {
6
6
  formatOrderByClause,
@@ -12,19 +12,21 @@ import tripCapacity from '../../models/gtfs-ride/trip-capacity.js';
12
12
  /*
13
13
  * Returns an array of all trip-capacities that match the query parameters.
14
14
  */
15
- export async function getTripCapacities(
15
+ export function getTripCapacities(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
19
  options = {}
20
20
  ) {
21
- const db = options.db ?? (await getDb());
21
+ const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(tripCapacity.filenameBase);
23
23
  const selectClause = formatSelectClause(fields);
24
24
  const whereClause = formatWhereClauses(query);
25
25
  const orderByClause = formatOrderByClause(orderBy);
26
26
 
27
- return db.all(
28
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
- );
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
30
32
  }
package/lib/gtfs.js CHANGED
@@ -52,10 +52,10 @@ import { getVehiclePositions } from './gtfs-realtime/vehicle-positions.js';
52
52
  import { getServiceAlerts } from './gtfs-realtime/service-alerts.js';
53
53
 
54
54
  // Expose database connection
55
- import { openDb, closeDb, getDb } from './db.js';
55
+ import { openDb, closeDb } from './db.js';
56
56
 
57
- // Advanced Query Support or Raw Query Support
58
- import { runRawQuery, execRawQuery, advancedQuery } from './advancedQuery.js';
57
+ // Advanced Query
58
+ import { advancedQuery } from './advancedQuery.js';
59
59
 
60
60
  const _importGtfs = importGtfs;
61
61
  export { _importGtfs as importGtfs };
@@ -190,12 +190,6 @@ const _openDb = openDb;
190
190
  export { _openDb as openDb };
191
191
  const _closeDb = closeDb;
192
192
  export { _closeDb as closeDb };
193
- const _getDb = getDb;
194
- export { _getDb as getDb };
195
193
 
196
194
  const _advancedQuery = advancedQuery;
197
195
  export { _advancedQuery as advancedQuery };
198
- const _runRawQuery = runRawQuery;
199
- export { _runRawQuery as runRawQuery };
200
- const _execRawQuery = execRawQuery;
201
- export { _execRawQuery as execRawQuery };