gtfs 3.8.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.
- package/@types/index.d.ts +35 -60
- package/@types/tests.ts +18 -13
- package/CHANGELOG.md +10 -0
- package/README.md +227 -207
- package/lib/advancedQuery.js +8 -17
- package/lib/db.js +29 -59
- package/lib/export.js +16 -10
- package/lib/gtfs/agencies.js +8 -6
- package/lib/gtfs/areas.js +8 -11
- package/lib/gtfs/attributions.js +8 -6
- package/lib/gtfs/calendar-dates.js +8 -6
- package/lib/gtfs/calendars.js +8 -6
- package/lib/gtfs/fare-attributes.js +8 -6
- package/lib/gtfs/fare-leg-rules.js +8 -6
- package/lib/gtfs/fare-products.js +8 -6
- package/lib/gtfs/fare-rules.js +8 -6
- package/lib/gtfs/fare-transfer-rules.js +8 -6
- package/lib/gtfs/feed-info.js +8 -6
- package/lib/gtfs/frequencies.js +8 -6
- package/lib/gtfs/levels.js +8 -11
- package/lib/gtfs/pathways.js +8 -6
- package/lib/gtfs/routes.js +8 -11
- package/lib/gtfs/shapes.js +34 -39
- package/lib/gtfs/stop-areas.js +8 -6
- package/lib/gtfs/stop-times.js +8 -6
- package/lib/gtfs/stops.js +27 -33
- package/lib/gtfs/transfers.js +8 -6
- package/lib/gtfs/translations.js +8 -6
- package/lib/gtfs/trips.js +8 -11
- package/lib/gtfs-realtime/service-alerts.js +9 -7
- package/lib/gtfs-realtime/stop-times-updates.js +9 -7
- package/lib/gtfs-realtime/trip-updates.js +9 -7
- package/lib/gtfs-realtime/vehicle-positions.js +9 -7
- package/lib/gtfs-ride/board-alights.js +8 -6
- package/lib/gtfs-ride/ride-feed-infos.js +8 -6
- package/lib/gtfs-ride/rider-trips.js +8 -6
- package/lib/gtfs-ride/riderships.js +8 -6
- package/lib/gtfs-ride/trip-capacities.js +8 -6
- package/lib/gtfs.js +3 -9
- package/lib/import.js +195 -202
- package/lib/non-standard/directions.js +8 -6
- package/lib/non-standard/stop-attributes.js +8 -6
- package/lib/non-standard/timetable-notes-references.js +8 -6
- package/lib/non-standard/timetable-notes.js +8 -6
- package/lib/non-standard/timetable-pages.js +8 -6
- package/lib/non-standard/timetable-stop-order.js +8 -6
- package/lib/non-standard/timetables.js +8 -6
- package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
- package/package.json +2 -3
- package/test/mocha/advanced-query.js +9 -15
- package/test/mocha/export-gtfs.js +5 -6
- package/test/mocha/fare-transfer-rules.js +32 -0
- package/test/mocha/get-agencies.js +13 -19
- package/test/mocha/get-areas.js +27 -0
- package/test/mocha/get-attributions.js +7 -13
- package/test/mocha/get-board-alights.js +7 -13
- package/test/mocha/get-calendar-dates.js +11 -17
- package/test/mocha/get-calendars.js +11 -17
- package/test/mocha/get-directions.js +7 -13
- package/test/mocha/get-fare-attributes.js +9 -15
- package/test/mocha/get-fare-leg-rules.js +27 -0
- package/test/mocha/get-fare-products.js +27 -0
- package/test/mocha/get-fare-rules.js +9 -15
- package/test/mocha/get-feed-info.js +7 -13
- package/test/mocha/get-frequencies.js +7 -13
- package/test/mocha/get-levels.js +7 -7
- package/test/mocha/get-pathways.js +7 -13
- package/test/mocha/get-ride-feed-infos.js +7 -13
- package/test/mocha/get-rider-trips.js +7 -13
- package/test/mocha/get-riderships.js +7 -13
- package/test/mocha/get-routes.js +13 -13
- package/test/mocha/get-shapes-as-geojson.js +14 -15
- package/test/mocha/get-shapes.js +25 -25
- package/test/mocha/get-stop-attributes.js +7 -13
- package/test/mocha/get-stops-as-geojson.js +13 -19
- package/test/mocha/get-stops.js +19 -19
- package/test/mocha/get-stoptimes.js +11 -17
- package/test/mocha/get-timetable-pages.js +7 -13
- package/test/mocha/get-timetable-stop-orders.js +6 -7
- package/test/mocha/get-timetables.js +7 -13
- package/test/mocha/get-transfers.js +7 -13
- package/test/mocha/get-translations.js +7 -13
- package/test/mocha/get-trip-capacities.js +7 -13
- package/test/mocha/get-trips.js +9 -9
- package/test/mocha/import-gtfs.js +11 -11
- package/test/mocha/{get-db.js → open-db.js} +37 -29
- package/test/mocha/raw-query.js +34 -0
- package/test/mocha/exec-raw-query.js +0 -39
- package/test/mocha/run-raw-query.js +0 -54
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
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
|
|
15
|
+
export function getRiderTrips(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
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
|
|
28
|
-
|
|
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 {
|
|
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
|
|
15
|
+
export function getRiderships(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
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
|
|
28
|
-
|
|
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 {
|
|
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
|
|
15
|
+
export function getTripCapacities(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
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
|
|
28
|
-
|
|
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
|
|
55
|
+
import { openDb, closeDb } from './db.js';
|
|
56
56
|
|
|
57
|
-
// Advanced Query
|
|
58
|
-
import {
|
|
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 };
|