diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c8dcf..c9800a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Changed +### Fixed - Correction to trips_dated_vehicle_journey +### Updated +- Changed model exports + ## [4.13.3] - 2024-08-03 ### Changed diff --git a/README.md b/README.md index b35e362..593af21 100644 --- a/README.md +++ b/README.md @@ -1565,15 +1565,15 @@ const boardAlights = getBoardAlights({ }); ``` -#### getRideFeedInfos(query, fields, sortBy, options) +#### getRideFeedInfo(query, fields, sortBy, options) Returns an array of ride_feed_info that match query parameters. [Details on ride_feed_info.txt](http://gtfsride.org/specification#ride_feed_infotxt) ```js -import { getRideFeedInfos } from 'gtfs'; +import { getRideFeedInfo } from 'gtfs'; // Get all ride_feed_info -const rideFeedInfos = getRideFeedInfos(); +const rideFeedInfos = getRideFeedInfo(); ``` #### getRiderTrips(query, fields, sortBy, options) @@ -1592,18 +1592,18 @@ const riderTrips = getRiderTrips({ }); ``` -#### getRiderships(query, fields, sortBy, options) +#### getRidership(query, fields, sortBy, options) Returns an array of ridership that match query parameters. [Details on ridership.txt](http://gtfsride.org/specification#ridershiptxt) ```js -import { getRiderships } from 'gtfs'; +import { getRidership } from 'gtfs'; // Get all ridership -const riderships = getRiderships(); +const riderships = getRidership(); // Get ridership for a specific route -const riderships = getRiderships({ +const riderships = getRidership({ route_id: '123', }); ``` diff --git a/package.json b/package.json index 40cba26..7b0ed5f 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,16 @@ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js", "build": "tsup" }, + "exports": { + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./models": { + "import": "./dist/models/models.js", + "types": "./dist/models/models.d.ts" + } + }, "dependencies": { "@turf/helpers": "^7.0.0", "better-sqlite3": "^11.1.2", diff --git a/src/index.ts b/src/index.ts index 02f8931..4c289ea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -58,9 +58,9 @@ export { getTripsDatedVehicleJourneys } from './lib/non-standard/trips-dated-veh // GTFS-ride export { getBoardAlights } from './lib/gtfs-ride/board-alights.ts'; -export { getRideFeedInfos } from './lib/gtfs-ride/ride-feed-infos.ts'; +export { getRideFeedInfo } from './lib/gtfs-ride/ride-feed-info.ts'; export { getRiderTrips } from './lib/gtfs-ride/rider-trips.ts'; -export { getRiderships } from './lib/gtfs-ride/riderships.ts'; +export { getRidership } from './lib/gtfs-ride/ridership.ts'; export { getTripCapacities } from './lib/gtfs-ride/trip-capacities.ts'; // GTFS-Realtime diff --git a/src/lib/export.ts b/src/lib/export.ts index 3345e59..b383c42 100644 --- a/src/lib/export.ts +++ b/src/lib/export.ts @@ -9,7 +9,7 @@ import Database from 'better-sqlite3'; import mapSeries from 'promise-map-series'; import untildify from 'untildify'; -import models from '../models/models.ts'; +import * as models from '../models/models.ts'; import { openDb } from './db.ts'; import { prepDirectory, generateFolderName } from './file-utils.ts'; import { log as _log, logWarning as _logWarning } from './log-utils.ts'; @@ -70,8 +70,8 @@ export const exportGtfs = async (initialConfig: IConfig) => { await prepDirectory(exportPath); // Loop through each GTFS file - const modelsToExport = models.filter( - (model) => model.extension !== 'gtfs-realtime', + const modelsToExport = Object.values(models).filter( + (model: IModel) => model.extension !== 'gtfs-realtime', ); const exportedFiles = await mapSeries( modelsToExport, diff --git a/src/lib/gtfs-plus/calendar-attributes.ts b/src/lib/gtfs-plus/calendar-attributes.ts index 826f70d..fefba9a 100644 --- a/src/lib/gtfs-plus/calendar-attributes.ts +++ b/src/lib/gtfs-plus/calendar-attributes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import calendarAttributes from '../../models/gtfs-plus/calendar-attributes.ts'; /* * Returns an array of all calendar_attributes that match the query parameters. @@ -25,7 +22,7 @@ export function getCalendarAttributes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(calendarAttributes.filenameBase); + const tableName = 'calendar_attributes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-plus/directions.ts b/src/lib/gtfs-plus/directions.ts index 88173a9..e19fdcc 100644 --- a/src/lib/gtfs-plus/directions.ts +++ b/src/lib/gtfs-plus/directions.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import directions from '../../models/gtfs-plus/directions.ts'; /* * Returns an array of all directions that match the query parameters. @@ -25,7 +22,7 @@ export function getDirections( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(directions.filenameBase); + const tableName = 'directions'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-plus/route-attributes.ts b/src/lib/gtfs-plus/route-attributes.ts index 06d9a0b..207f709 100644 --- a/src/lib/gtfs-plus/route-attributes.ts +++ b/src/lib/gtfs-plus/route-attributes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import routeAttributes from '../../models/gtfs-plus/route-attributes.ts'; /* * Returns an array of all route_attributes that match the query parameters. @@ -25,7 +22,7 @@ export function getRouteAttributes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(routeAttributes.filenameBase); + const tableName = 'route_attributes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-plus/stop-attributes.ts b/src/lib/gtfs-plus/stop-attributes.ts index a5c132d..939156f 100644 --- a/src/lib/gtfs-plus/stop-attributes.ts +++ b/src/lib/gtfs-plus/stop-attributes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import stopAttributes from '../../models/gtfs-plus/stop-attributes.ts'; /* * Returns an array of all stop attributes that match the query parameters. @@ -25,7 +22,7 @@ export function getStopAttributes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(stopAttributes.filenameBase); + const tableName = 'stop_attributes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-realtime/service-alerts.ts b/src/lib/gtfs-realtime/service-alerts.ts index ba584c5..fc43b86 100644 --- a/src/lib/gtfs-realtime/service-alerts.ts +++ b/src/lib/gtfs-realtime/service-alerts.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,8 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import serviceAlerts from '../../models/gtfs-realtime/service-alerts.ts'; -import serviceAlertTargets from '../../models/gtfs-realtime/service-alert-targets.ts'; /* * Returns an array of all service alerts that match the query parameters. @@ -26,15 +22,15 @@ export function getServiceAlerts( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(serviceAlerts.filenameBase); - const joinTable = sqlString.escapeId(serviceAlertTargets.filenameBase); + const tableName = 'service_alerts'; + const joinTableName = 'service_alert_targets'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); return db .prepare( - `${selectClause} FROM ${tableName} INNER JOIN ${joinTable} ON ${tableName}.id=${joinTable}.alert_id ${whereClause} ${orderByClause};`, + `${selectClause} FROM ${tableName} INNER JOIN ${joinTableName} ON ${tableName}.id=${joinTableName}.alert_id ${whereClause} ${orderByClause};`, ) .all() as SqlResults; } diff --git a/src/lib/gtfs-realtime/stop-time-updates.ts b/src/lib/gtfs-realtime/stop-time-updates.ts index b36c5fb..e8140f1 100644 --- a/src/lib/gtfs-realtime/stop-time-updates.ts +++ b/src/lib/gtfs-realtime/stop-time-updates.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import stopTimeUpdates from '../../models/gtfs-realtime/stop-time-updates.ts'; /* * Returns an array of all stop time updates that match the query parameters. @@ -25,7 +22,7 @@ export function getStopTimeUpdates( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(stopTimeUpdates.filenameBase); + const tableName = 'stop_time_updates'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-realtime/trip-updates.ts b/src/lib/gtfs-realtime/trip-updates.ts index 1745bff..18ebcc2 100644 --- a/src/lib/gtfs-realtime/trip-updates.ts +++ b/src/lib/gtfs-realtime/trip-updates.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import tripUpdates from '../../models/gtfs-realtime/trip-updates.ts'; /* * Returns an array of all trip updates that match the query parameters. @@ -25,7 +22,7 @@ export function getTripUpdates( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(tripUpdates.filenameBase); + const tableName = 'trip_updates'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-realtime/vehicle-positions.ts b/src/lib/gtfs-realtime/vehicle-positions.ts index 8dbe0f0..03c9ae7 100644 --- a/src/lib/gtfs-realtime/vehicle-positions.ts +++ b/src/lib/gtfs-realtime/vehicle-positions.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import vehiclePositions from '../../models/gtfs-realtime/vehicle-positions.ts'; /* * Returns an array of all vehicle positions that match the query parameters. @@ -25,7 +22,7 @@ export function getVehiclePositions( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(vehiclePositions.filenameBase); + const tableName = 'vehicle_positions'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-ride/board-alights.ts b/src/lib/gtfs-ride/board-alights.ts index 81321be..f271bfa 100644 --- a/src/lib/gtfs-ride/board-alights.ts +++ b/src/lib/gtfs-ride/board-alights.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import boardAlights from '../../models/gtfs-ride/board-alight.ts'; /* * Returns an array of all board-alights that match the query parameters. @@ -25,7 +22,7 @@ export function getBoardAlights( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(boardAlights.filenameBase); + const tableName = 'board_alight'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-ride/ride-feed-infos.ts b/src/lib/gtfs-ride/ride-feed-info.ts similarity index 78% rename from src/lib/gtfs-ride/ride-feed-infos.ts rename to src/lib/gtfs-ride/ride-feed-info.ts index db05d5b..68e1950 100644 --- a/src/lib/gtfs-ride/ride-feed-infos.ts +++ b/src/lib/gtfs-ride/ride-feed-info.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,19 +11,18 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import rideFeedInfo from '../../models/gtfs-ride/ride-feed-info.ts'; /* * Returns an array of all ride-feed-info that match the query parameters. */ -export function getRideFeedInfos( +export function getRideFeedInfo( query: SqlWhere = {}, fields: SqlSelect = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(rideFeedInfo.filenameBase); + const tableName = 'ride_feed_info'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-ride/rider-trips.ts b/src/lib/gtfs-ride/rider-trips.ts index 4588f2c..6331b12 100644 --- a/src/lib/gtfs-ride/rider-trips.ts +++ b/src/lib/gtfs-ride/rider-trips.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import riderTrip from '../../models/gtfs-ride/rider-trip.ts'; /* * Returns an array of all rider trips that match the query parameters. @@ -25,7 +22,7 @@ export function getRiderTrips( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(riderTrip.filenameBase); + const tableName = 'rider_trip'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-ride/riderships.ts b/src/lib/gtfs-ride/ridership.ts similarity index 72% rename from src/lib/gtfs-ride/riderships.ts rename to src/lib/gtfs-ride/ridership.ts index 3115e07..4113ffa 100644 --- a/src/lib/gtfs-ride/riderships.ts +++ b/src/lib/gtfs-ride/ridership.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,19 +11,18 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import riderships from '../../models/gtfs-ride/ridership.ts'; /* - * Returns an array of all riderships that match the query parameters. + * Returns an array of all ridership that match the query parameters. */ -export function getRiderships( +export function getRidership( query: SqlWhere = {}, fields: SqlSelect = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(riderships.filenameBase); + const tableName = 'ridership'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs-ride/trip-capacities.ts b/src/lib/gtfs-ride/trip-capacities.ts index 9121202..ff92950 100644 --- a/src/lib/gtfs-ride/trip-capacities.ts +++ b/src/lib/gtfs-ride/trip-capacities.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import tripCapacity from '../../models/gtfs-ride/trip-capacity.ts'; /* * Returns an array of all trip-capacities that match the query parameters. @@ -25,7 +22,7 @@ export function getTripCapacities( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(tripCapacity.filenameBase); + const tableName = 'trip_capacity'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/agencies.ts b/src/lib/gtfs/agencies.ts index 28a4827..56e0173 100644 --- a/src/lib/gtfs/agencies.ts +++ b/src/lib/gtfs/agencies.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import agency from '../../models/gtfs/agency.ts'; /* * Returns an array of all agencies that match the query parameters. @@ -25,7 +22,7 @@ export function getAgencies( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(agency.filenameBase); + const tableName = 'agency'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/areas.ts b/src/lib/gtfs/areas.ts index dbe0653..1e799c3 100644 --- a/src/lib/gtfs/areas.ts +++ b/src/lib/gtfs/areas.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import areas from '../../models/gtfs/areas.ts'; /* * Returns an array of all areas that match the query parameters. @@ -25,7 +22,7 @@ export function getAreas( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(areas.filenameBase); + const tableName = 'areas'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/attributions.ts b/src/lib/gtfs/attributions.ts index e2104b4..b92dbac 100644 --- a/src/lib/gtfs/attributions.ts +++ b/src/lib/gtfs/attributions.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import attributions from '../../models/gtfs/attributions.ts'; /* * Returns an array of all attributions that match the query parameters. @@ -25,7 +22,7 @@ export function getAttributions( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(attributions.filenameBase); + const tableName = 'attributions'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/booking-rules.ts b/src/lib/gtfs/booking-rules.ts index 9e69f99..d7e65a8 100644 --- a/src/lib/gtfs/booking-rules.ts +++ b/src/lib/gtfs/booking-rules.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import bookingRules from '../../models/gtfs/booking-rules.ts'; /* * Returns an array of all booking rules that match the query parameters. @@ -25,7 +22,7 @@ export function getBookingRules( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(bookingRules.filenameBase); + const tableName = 'booking_rules'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/calendar-dates.ts b/src/lib/gtfs/calendar-dates.ts index 8adf156..57fbad1 100644 --- a/src/lib/gtfs/calendar-dates.ts +++ b/src/lib/gtfs/calendar-dates.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import calendarDates from '../../models/gtfs/calendar-dates.ts'; /* * Returns an array of calendarDates that match the query parameters. @@ -25,7 +22,7 @@ export function getCalendarDates( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(calendarDates.filenameBase); + const tableName = 'calendar_dates'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/calendars.ts b/src/lib/gtfs/calendars.ts index 74cc81e..382ea34 100644 --- a/src/lib/gtfs/calendars.ts +++ b/src/lib/gtfs/calendars.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import calendars from '../../models/gtfs/calendar.ts'; /* * Returns an array of calendars that match the query parameters. @@ -25,7 +22,7 @@ export function getCalendars( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(calendars.filenameBase); + const tableName = 'calendar'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-attributes.ts b/src/lib/gtfs/fare-attributes.ts index 6b0f6eb..50ed89f 100644 --- a/src/lib/gtfs/fare-attributes.ts +++ b/src/lib/gtfs/fare-attributes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareAttributes from '../../models/gtfs/fare-attributes.ts'; /* * Returns an array of all fare attributes that match the query parameters. @@ -25,7 +22,7 @@ export function getFareAttributes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareAttributes.filenameBase); + const tableName = 'fare_attributes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-leg-rules.ts b/src/lib/gtfs/fare-leg-rules.ts index ae505e6..216221e 100644 --- a/src/lib/gtfs/fare-leg-rules.ts +++ b/src/lib/gtfs/fare-leg-rules.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareLegRules from '../../models/gtfs/fare-leg-rules.ts'; /* * Returns an array of all fare leg rules that match the query parameters. @@ -25,7 +22,7 @@ export function getFareLegRules( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareLegRules.filenameBase); + const tableName = 'fare_leg_rules'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-media.ts b/src/lib/gtfs/fare-media.ts index 3861d23..9a7c90f 100644 --- a/src/lib/gtfs/fare-media.ts +++ b/src/lib/gtfs/fare-media.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareMedia from '../../models/gtfs/fare-media.ts'; /* * Returns an array of all fare media that match the query parameters. @@ -25,7 +22,7 @@ export function getFareMedia( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareMedia.filenameBase); + const tableName = 'fare_media'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-products.ts b/src/lib/gtfs/fare-products.ts index 063b53b..774fbe3 100644 --- a/src/lib/gtfs/fare-products.ts +++ b/src/lib/gtfs/fare-products.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareProducts from '../../models/gtfs/fare-products.ts'; /* * Returns an array of all fare products that match the query parameters. @@ -25,7 +22,7 @@ export function getFareProducts( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareProducts.filenameBase); + const tableName = 'fare_products'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-rules.ts b/src/lib/gtfs/fare-rules.ts index eb94ded..c369f62 100644 --- a/src/lib/gtfs/fare-rules.ts +++ b/src/lib/gtfs/fare-rules.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareRules from '../../models/gtfs/fare-rules.ts'; /* * Returns an array of all fare rules that match the query parameters. @@ -25,7 +22,7 @@ export function getFareRules( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareRules.filenameBase); + const tableName = 'fare_rules'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/fare-transfer-rules.ts b/src/lib/gtfs/fare-transfer-rules.ts index 10f2fcd..e3a3b5e 100644 --- a/src/lib/gtfs/fare-transfer-rules.ts +++ b/src/lib/gtfs/fare-transfer-rules.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import fareTransferRules from '../../models/gtfs/fare-transfer-rules.ts'; /* * Returns an array of all fare transfer rules that match the query parameters. @@ -25,7 +22,7 @@ export function getFareTransferRules( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(fareTransferRules.filenameBase); + const tableName = 'fare_transfer_rules'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/feed-info.ts b/src/lib/gtfs/feed-info.ts index 8dfa81e..cd7c403 100644 --- a/src/lib/gtfs/feed-info.ts +++ b/src/lib/gtfs/feed-info.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import feedInfo from '../../models/gtfs/feed-info.ts'; /* * Returns an array of all feed info that match the query parameters. @@ -25,7 +22,7 @@ export function getFeedInfo( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(feedInfo.filenameBase); + const tableName = 'feed_info'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/frequencies.ts b/src/lib/gtfs/frequencies.ts index 9c56ba0..5968fed 100644 --- a/src/lib/gtfs/frequencies.ts +++ b/src/lib/gtfs/frequencies.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import frequencies from '../../models/gtfs/frequencies.ts'; /* * Returns an array of all frequencies that match the query parameters. @@ -25,7 +22,7 @@ export function getFrequencies( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(frequencies.filenameBase); + const tableName = 'frequencies'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/levels.ts b/src/lib/gtfs/levels.ts index 5239b44..cd6eaf5 100644 --- a/src/lib/gtfs/levels.ts +++ b/src/lib/gtfs/levels.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import levels from '../../models/gtfs/levels.ts'; /* * Returns an array of all levels that match the query parameters. @@ -25,7 +22,7 @@ export function getLevels( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(levels.filenameBase); + const tableName = 'levels'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/location-group-stops.ts b/src/lib/gtfs/location-group-stops.ts index e0d39f3..5f04d71 100644 --- a/src/lib/gtfs/location-group-stops.ts +++ b/src/lib/gtfs/location-group-stops.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import locationGroupStops from '../../models/gtfs/location-group-stops.ts'; /* * Returns an array of all location group stops that match the query parameters. @@ -25,7 +22,7 @@ export function getLocationGroupStops( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(locationGroupStops.filenameBase); + const tableName = 'location_group_stops'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/location-groups.ts b/src/lib/gtfs/location-groups.ts index 43adddb..e493811 100644 --- a/src/lib/gtfs/location-groups.ts +++ b/src/lib/gtfs/location-groups.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import locationGroups from '../../models/gtfs/location-groups.ts'; /* * Returns an array of all location groups that match the query parameters. @@ -25,7 +22,7 @@ export function getLocationGroups( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(locationGroups.filenameBase); + const tableName = 'location_groups'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/locations.ts b/src/lib/gtfs/locations.ts index 02251ca..0b79893 100644 --- a/src/lib/gtfs/locations.ts +++ b/src/lib/gtfs/locations.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import locations from '../../models/gtfs/locations.ts'; /* * Returns an array of all locations that match the query parameters. @@ -25,7 +22,7 @@ export function getLocations( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(locations.filenameBase); + const tableName = 'locations'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/networks.ts b/src/lib/gtfs/networks.ts index e91d1e5..1d95744 100644 --- a/src/lib/gtfs/networks.ts +++ b/src/lib/gtfs/networks.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import networks from '../../models/gtfs/networks.ts'; /* * Returns an array of all networks that match the query parameters. @@ -25,7 +22,7 @@ export function getNetworks( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(networks.filenameBase); + const tableName = 'networks'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/pathways.ts b/src/lib/gtfs/pathways.ts index 40a64e0..1dbfc29 100644 --- a/src/lib/gtfs/pathways.ts +++ b/src/lib/gtfs/pathways.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import pathways from '../../models/gtfs/pathways.ts'; /* * Returns an array of all pathways that match the query parameters. @@ -25,7 +22,7 @@ export function getPathways( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(pathways.filenameBase); + const tableName = 'pathways'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/route-networks.ts b/src/lib/gtfs/route-networks.ts index 7a7005d..8fadfc8 100644 --- a/src/lib/gtfs/route-networks.ts +++ b/src/lib/gtfs/route-networks.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import routeNetworks from '../../models/gtfs/route-networks.ts'; /* * Returns an array of all route_networks that match the query parameters. @@ -25,7 +22,7 @@ export function getRouteNetworks( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(routeNetworks.filenameBase); + const tableName = 'route_networks'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/routes.ts b/src/lib/gtfs/routes.ts index 83a9274..f9e667d 100644 --- a/src/lib/gtfs/routes.ts +++ b/src/lib/gtfs/routes.ts @@ -1,5 +1,4 @@ import { omit, pick } from 'lodash-es'; -import sqlString from 'sqlstring-sqlite'; import { QueryOptions, @@ -15,7 +14,6 @@ import { formatWhereClause, formatWhereClauses, } from '../utils.ts'; -import routes from '../../models/gtfs/routes.ts'; function buildStoptimeSubquery(query: { [key: string]: string }) { const whereClause = formatWhereClauses(query); @@ -55,7 +53,7 @@ export function getRoutes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(routes.filenameBase); + const tableName = 'routes'; const selectClause = formatSelectClause(fields); let whereClause = ''; const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/shapes.ts b/src/lib/gtfs/shapes.ts index 0c2ba22..1b3acef 100644 --- a/src/lib/gtfs/shapes.ts +++ b/src/lib/gtfs/shapes.ts @@ -1,6 +1,5 @@ -import { compact, omit, pick, uniq } from 'lodash-es'; +import { compact, omit, pick } from 'lodash-es'; import { FeatureCollection } from 'geojson'; -import sqlString from 'sqlstring-sqlite'; import { featureCollection } from '@turf/helpers'; import { @@ -18,7 +17,6 @@ import { formatWhereClauses, } from '../utils.ts'; import { shapesToGeoJSONFeature } from '../geojson-utils.ts'; -import shapes from '../../models/gtfs/shapes.ts'; import { getAgencies } from './agencies.ts'; import { getRoutes } from './routes.ts'; import { getRouteAttributes } from '../gtfs-plus/route-attributes.ts'; @@ -41,7 +39,7 @@ export function getShapes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(shapes.filenameBase); + const tableName = 'shapes'; const selectClause = formatSelectClause(fields); let whereClause = ''; const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/stop-areas.ts b/src/lib/gtfs/stop-areas.ts index f22aa6b..ba995a0 100644 --- a/src/lib/gtfs/stop-areas.ts +++ b/src/lib/gtfs/stop-areas.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import stopAreas from '../../models/gtfs/stop-areas.ts'; /* * Returns an array of all stop areas that match the query parameters. @@ -25,7 +22,7 @@ export function getStopAreas( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(stopAreas.filenameBase); + const tableName = 'stop_areas'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/stop-times.ts b/src/lib/gtfs/stop-times.ts index 67e0c42..13a40bb 100644 --- a/src/lib/gtfs/stop-times.ts +++ b/src/lib/gtfs/stop-times.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import stopTimes from '../../models/gtfs/stop-times.ts'; /* * Returns an array of stoptimes that match the query parameters. @@ -25,7 +22,7 @@ export function getStoptimes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(stopTimes.filenameBase); + const tableName = 'stop_times'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/stops.ts b/src/lib/gtfs/stops.ts index 0ec8c40..5937bba 100644 --- a/src/lib/gtfs/stops.ts +++ b/src/lib/gtfs/stops.ts @@ -1,5 +1,4 @@ import { omit, orderBy, pick } from 'lodash-es'; -import sqlString from 'sqlstring-sqlite'; import { FeatureCollection } from 'geojson'; import { @@ -18,7 +17,6 @@ import { formatWhereClauses, } from '../utils.ts'; import { stopsToGeoJSONFeatureCollection } from '../geojson-utils.ts'; -import stops from '../../models/gtfs/stops.ts'; import { getAgencies } from './agencies.ts'; import { getStopAttributes } from '../gtfs-plus/stop-attributes.ts'; @@ -47,7 +45,7 @@ export function getStops( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(stops.filenameBase); + const tableName = 'stops'; const selectClause = formatSelectClause(fields); let whereClause = ''; const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/timeframes.ts b/src/lib/gtfs/timeframes.ts index 5a514c1..313ee92 100644 --- a/src/lib/gtfs/timeframes.ts +++ b/src/lib/gtfs/timeframes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timeframes from '../../models/gtfs/timeframes.ts'; /* * Returns an array of all timeframes that match the query parameters. @@ -25,7 +22,7 @@ export function getTimeframes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timeframes.filenameBase); + const tableName = 'timeframes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/transfers.ts b/src/lib/gtfs/transfers.ts index 491f042..dd181e6 100644 --- a/src/lib/gtfs/transfers.ts +++ b/src/lib/gtfs/transfers.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import transfers from '../../models/gtfs/transfers.ts'; /* * Returns an array of all transfers that match the query parameters. @@ -25,7 +22,7 @@ export function getTransfers( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(transfers.filenameBase); + const tableName = 'transfers'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/translations.ts b/src/lib/gtfs/translations.ts index 77549a4..211199a 100644 --- a/src/lib/gtfs/translations.ts +++ b/src/lib/gtfs/translations.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import translations from '../../models/gtfs/translations.ts'; /* * Returns an array of all translations that match the query parameters. @@ -25,7 +22,7 @@ export function getTranslations( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(translations.filenameBase); + const tableName = 'translations'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/gtfs/trips.ts b/src/lib/gtfs/trips.ts index 055871f..c053be2 100644 --- a/src/lib/gtfs/trips.ts +++ b/src/lib/gtfs/trips.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import trips from '../../models/gtfs/trips.ts'; /* * Returns an array of all trips that match the query parameters. @@ -25,7 +22,7 @@ export function getTrips( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(trips.filenameBase); + const tableName = 'trips'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/import.ts b/src/lib/import.ts index dd11853..4b95926 100644 --- a/src/lib/import.ts +++ b/src/lib/import.ts @@ -11,7 +11,7 @@ import GtfsRealtimeBindings from 'gtfs-realtime-bindings'; import sqlString from 'sqlstring-sqlite'; import Database from 'better-sqlite3'; -import models from '../models/models.ts'; +import * as models from '../models/models.ts'; import { openDb } from './db.ts'; import { unzip } from './file-utils.ts'; import { isValidJSON } from './geojson-utils.ts'; @@ -203,33 +203,6 @@ const updateRealtimeData = async (task: IRealtimeTask) => { sqlitePath: task.sqlitePath, }); - const vehiclePositionsModel = models.find( - (x) => x.filenameBase === 'vehicle_positions', - ); - const tripUpdatesModel = models.find( - (x) => x.filenameBase === 'trip_updates', - ); - const stoptimeUpdatesModel = models.find( - (x) => x.filenameBase === 'stop_time_updates', - ); - const serviceAlertsModel = models.find( - (x) => x.filenameBase === 'service_alerts', - ); - const serviceAlertTargetsModel = models.find( - (x) => x.filenameBase === 'service_alert_targets', - ); - - if ( - !vehiclePositionsModel || - !tripUpdatesModel || - !stoptimeUpdatesModel || - !serviceAlertsModel || - !serviceAlertTargetsModel - ) { - task.logError('GTFS-Realtime models definitions not found'); - return; - } - task.log( `Starting GTFS-Realtime import from ${task.realtime_urls.length} urls`, ); @@ -251,15 +224,15 @@ const updateRealtimeData = async (task: IRealtimeTask) => { // Determine the type of GTFS-Realtime let model; if (entity.vehicle) { - model = vehiclePositionsModel; + model = models.vehiclePositions; } if (entity.tripUpdate) { - model = tripUpdatesModel; + model = models.tripUpdates; } if (entity.alert) { - model = serviceAlertsModel; + model = models.serviceAlerts; } if (!model) { @@ -286,7 +259,7 @@ const updateRealtimeData = async (task: IRealtimeTask) => { const stopTimeUpdateArray = []; for (const stopTimeUpdate of entity.tripUpdate.stopTimeUpdate) { stopTimeUpdate.parent = entity; - const subValues = stoptimeUpdatesModel.schema.map((column) => + const subValues = models.stopTimeUpdates.schema.map((column) => prepareRealtimeValue(stopTimeUpdate, column, task), ); stopTimeUpdateArray.push(`(${subValues.join(', ')})`); @@ -295,7 +268,7 @@ const updateRealtimeData = async (task: IRealtimeTask) => { try { db.prepare( - `REPLACE INTO ${stoptimeUpdatesModel.filenameBase} (${stoptimeUpdatesModel.schema + `REPLACE INTO ${models.stopTimeUpdates.filenameBase} (${models.stopTimeUpdates.schema .map((column) => column.name) .join(', ')}) VALUES ${stopTimeUpdateArray.join(', ')}`, ).run(); @@ -309,7 +282,7 @@ const updateRealtimeData = async (task: IRealtimeTask) => { const alertTargetArray = []; for (const informedEntity of entity.alert.informedEntity) { informedEntity.parent = entity; - const subValues = serviceAlertTargetsModel.schema.map((column) => + const subValues = models.serviceAlertTargets.schema.map((column) => prepareRealtimeValue(informedEntity, column, task), ); alertTargetArray.push(`(${subValues.join(', ')})`); @@ -318,7 +291,7 @@ const updateRealtimeData = async (task: IRealtimeTask) => { try { db.prepare( - `REPLACE INTO ${serviceAlertTargetsModel.filenameBase} (${serviceAlertTargetsModel.schema + `REPLACE INTO ${models.serviceAlertTargets.filenameBase} (${models.serviceAlertTargets.schema .map((column) => column.name) .join(', ')}) VALUES ${alertTargetArray.join(', ')}`, ).run(); @@ -401,7 +374,7 @@ const readFiles = async (task: ITask) => { }; const createTables = (db: Database.Database) => { - for (const model of models as IModel[]) { + for (const model of Object.values(models) as IModel[]) { if (!model.schema) { return; } @@ -625,7 +598,7 @@ const importLines = ( const importFiles = (task: ITask) => mapSeries( - models, + Object.values(models), (model: IModel) => new Promise((resolve, reject) => { const lines: {}[] = []; diff --git a/src/lib/non-standard/timetable-notes-references.ts b/src/lib/non-standard/timetable-notes-references.ts index e5df6aa..97c37b6 100644 --- a/src/lib/non-standard/timetable-notes-references.ts +++ b/src/lib/non-standard/timetable-notes-references.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timetableNotesReferences from '../../models/non-standard/timetable-notes-references.ts'; /* * Returns an array of all timetable notes references that match the query parameters. @@ -25,7 +22,7 @@ export function getTimetableNotesReferences( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timetableNotesReferences.filenameBase); + const tableName = 'timetable_notes_references'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/non-standard/timetable-notes.ts b/src/lib/non-standard/timetable-notes.ts index c825667..9803bcd 100644 --- a/src/lib/non-standard/timetable-notes.ts +++ b/src/lib/non-standard/timetable-notes.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timetableNotes from '../../models/non-standard/timetable-notes.ts'; /* * Returns an array of all timetable notes that match the query parameters. @@ -25,7 +22,7 @@ export function getTimetableNotes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timetableNotes.filenameBase); + const tableName = 'timetable_notes'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/non-standard/timetable-pages.ts b/src/lib/non-standard/timetable-pages.ts index 95d6017..5a17e1d 100644 --- a/src/lib/non-standard/timetable-pages.ts +++ b/src/lib/non-standard/timetable-pages.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timetablePages from '../../models/non-standard/timetable-pages.ts'; /* * Returns an array of all timetable pages that match the query parameters. @@ -25,7 +22,7 @@ export function getTimetablePages( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timetablePages.filenameBase); + const tableName = 'timetable_pages'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/non-standard/timetable-stop-order.ts b/src/lib/non-standard/timetable-stop-order.ts index fced368..661c283 100644 --- a/src/lib/non-standard/timetable-stop-order.ts +++ b/src/lib/non-standard/timetable-stop-order.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timetableStopOrder from '../../models/non-standard/timetable-stop-order.ts'; /* * Returns an array of all timetable stop orders that match the query parameters. @@ -25,7 +22,7 @@ export function getTimetableStopOrders( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timetableStopOrder.filenameBase); + const tableName = 'timetable_stop_order'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/non-standard/timetables.ts b/src/lib/non-standard/timetables.ts index 22f3441..34b6f42 100644 --- a/src/lib/non-standard/timetables.ts +++ b/src/lib/non-standard/timetables.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,8 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import timetables from '../../models/non-standard/timetables.ts'; - /* * Returns an array of all timetables that match the query parameters. */ @@ -25,7 +21,7 @@ export function getTimetables( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(timetables.filenameBase); + const tableName = 'timetables'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/non-standard/trips-dated-vehicle-journey.ts b/src/lib/non-standard/trips-dated-vehicle-journey.ts index 6f0597e..f6fa281 100644 --- a/src/lib/non-standard/trips-dated-vehicle-journey.ts +++ b/src/lib/non-standard/trips-dated-vehicle-journey.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import directions from '../../models/non-standard/trips-dated-vehicle-journey.ts'; /* * Returns an array of all trips dated vehicle journeys that match the query parameters. @@ -25,7 +22,7 @@ export function getTripsDatedVehicleJourneys( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(directions.filenameBase); + const tableName = 'trips_dated_vehicle_journey'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/ods/deadhead-times.ts b/src/lib/ods/deadhead-times.ts index 9b3eaae..b65b3f6 100644 --- a/src/lib/ods/deadhead-times.ts +++ b/src/lib/ods/deadhead-times.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import deadheadTimes from '../../models/ods/deadhead-times.ts'; /* * Returns an array of all deadhead_times that match the query parameters. @@ -25,7 +22,7 @@ export function getDeadheadTimes( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(deadheadTimes.filenameBase); + const tableName = 'deadhead_times'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/ods/deadheads.ts b/src/lib/ods/deadheads.ts index e0ebbe9..d4da295 100644 --- a/src/lib/ods/deadheads.ts +++ b/src/lib/ods/deadheads.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import deadheads from '../../models/ods/deadheads.ts'; /* * Returns an array of all deadheads that match the query parameters. @@ -25,7 +22,7 @@ export function getDeadheads( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(deadheads.filenameBase); + const tableName = 'deadheads'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/ods/ops-locations.ts b/src/lib/ods/ops-locations.ts index 08a3fe0..37ab45c 100644 --- a/src/lib/ods/ops-locations.ts +++ b/src/lib/ods/ops-locations.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import opsLocations from '../../models/ods/ops-locations.ts'; /* * Returns an array of all ops_locations that match the query parameters. @@ -25,7 +22,7 @@ export function getOpsLocations( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(opsLocations.filenameBase); + const tableName = 'ops_locations'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/ods/run-events.ts b/src/lib/ods/run-events.ts index d35fb19..810346c 100644 --- a/src/lib/ods/run-events.ts +++ b/src/lib/ods/run-events.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import runEvents from '../../models/ods/run-events.ts'; /* * Returns an array of all run_events that match the query parameters. @@ -25,7 +22,7 @@ export function getRunEvents( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(runEvents.filenameBase); + const tableName = 'run_events'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/lib/ods/runs-pieces.ts b/src/lib/ods/runs-pieces.ts index 97dce73..57d6378 100644 --- a/src/lib/ods/runs-pieces.ts +++ b/src/lib/ods/runs-pieces.ts @@ -1,5 +1,3 @@ -import sqlString from 'sqlstring-sqlite'; - import { QueryOptions, SqlOrderBy, @@ -13,7 +11,6 @@ import { formatSelectClause, formatWhereClauses, } from '../utils.ts'; -import runsPieces from '../../models/ods/runs-pieces.ts'; /* * Returns an array of all runs_pieces that match the query parameters. @@ -25,7 +22,7 @@ export function getRunsPieces( options: QueryOptions = {}, ): SqlResults { const db = options.db ?? openDb(); - const tableName = sqlString.escapeId(runsPieces.filenameBase); + const tableName = 'runs_pieces'; const selectClause = formatSelectClause(fields); const whereClause = formatWhereClauses(query); const orderByClause = formatOrderByClause(orderBy); diff --git a/src/models/gtfs-plus/calendar-attributes.ts b/src/models/gtfs-plus/calendar-attributes.ts index e750d36..1bfb11a 100644 --- a/src/models/gtfs-plus/calendar-attributes.ts +++ b/src/models/gtfs-plus/calendar-attributes.ts @@ -1,4 +1,4 @@ -const model = { +export const calendarAttributes = { filenameBase: 'calendar_attributes', filenameExtension: 'txt', nonstandard: true, @@ -18,5 +18,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-plus/directions.ts b/src/models/gtfs-plus/directions.ts index 8d30020..b845252 100644 --- a/src/models/gtfs-plus/directions.ts +++ b/src/models/gtfs-plus/directions.ts @@ -1,4 +1,4 @@ -const model = { +export const directions = { filenameBase: 'directions', filenameExtension: 'txt', nonstandard: true, @@ -25,5 +25,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-plus/route-attributes.ts b/src/models/gtfs-plus/route-attributes.ts index f0bf17b..1369ddb 100644 --- a/src/models/gtfs-plus/route-attributes.ts +++ b/src/models/gtfs-plus/route-attributes.ts @@ -1,4 +1,4 @@ -const model = { +export const routeAttributes = { filenameBase: 'route_attributes', filenameExtension: 'txt', nonstandard: true, @@ -30,5 +30,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-plus/stop-attributes.ts b/src/models/gtfs-plus/stop-attributes.ts index 6134047..78150b1 100644 --- a/src/models/gtfs-plus/stop-attributes.ts +++ b/src/models/gtfs-plus/stop-attributes.ts @@ -1,4 +1,4 @@ -const model = { +export const stopAttributes = { filenameBase: 'stop_attributes', filenameExtension: 'txt', nonstandard: true, @@ -31,5 +31,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-realtime/service-alert-targets.ts b/src/models/gtfs-realtime/service-alert-targets.ts index 2a0da0b..a76d0af 100644 --- a/src/models/gtfs-realtime/service-alert-targets.ts +++ b/src/models/gtfs-realtime/service-alert-targets.ts @@ -1,4 +1,4 @@ -const model = { +export const serviceAlertTargets = { filenameBase: 'service_alert_targets', extension: 'gtfs-realtime', schema: [ @@ -35,5 +35,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-realtime/service-alerts.ts b/src/models/gtfs-realtime/service-alerts.ts index b5fd0d1..7bac9ad 100644 --- a/src/models/gtfs-realtime/service-alerts.ts +++ b/src/models/gtfs-realtime/service-alerts.ts @@ -1,4 +1,4 @@ -const model = { +export const serviceAlerts = { filenameBase: 'service_alerts', extension: 'gtfs-realtime', schema: [ @@ -58,5 +58,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-realtime/stop-time-updates.ts b/src/models/gtfs-realtime/stop-time-updates.ts index 6beba4c..8361162 100644 --- a/src/models/gtfs-realtime/stop-time-updates.ts +++ b/src/models/gtfs-realtime/stop-time-updates.ts @@ -1,4 +1,4 @@ -const model = { +export const stopTimeUpdates = { filenameBase: 'stop_time_updates', extension: 'gtfs-realtime', schema: [ @@ -83,5 +83,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-realtime/trip-updates.ts b/src/models/gtfs-realtime/trip-updates.ts index d07bdad..087556a 100644 --- a/src/models/gtfs-realtime/trip-updates.ts +++ b/src/models/gtfs-realtime/trip-updates.ts @@ -1,4 +1,4 @@ -const model = { +export const tripUpdates = { filenameBase: 'trip_updates', extension: 'gtfs-realtime', schema: [ @@ -73,5 +73,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-realtime/vehicle-positions.ts b/src/models/gtfs-realtime/vehicle-positions.ts index 98da379..4ef4cfa 100644 --- a/src/models/gtfs-realtime/vehicle-positions.ts +++ b/src/models/gtfs-realtime/vehicle-positions.ts @@ -1,4 +1,4 @@ -const model = { +export const vehiclePositions = { filenameBase: 'vehicle_positions', extension: 'gtfs-realtime', schema: [ @@ -133,5 +133,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-ride/board-alight.ts b/src/models/gtfs-ride/board-alight.ts index 9e24e9a..675dadb 100644 --- a/src/models/gtfs-ride/board-alight.ts +++ b/src/models/gtfs-ride/board-alight.ts @@ -1,4 +1,4 @@ -const model = { +export const boardAlight = { filenameBase: 'board_alight', filenameExtension: 'txt', nonstandard: true, @@ -128,5 +128,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-ride/ride-feed-info.ts b/src/models/gtfs-ride/ride-feed-info.ts index 0687849..a574d08 100644 --- a/src/models/gtfs-ride/ride-feed-info.ts +++ b/src/models/gtfs-ride/ride-feed-info.ts @@ -1,4 +1,4 @@ -const model = { +export const rideFeedInfo = { filenameBase: 'ride_feed_info', filenameExtension: 'txt', nonstandard: true, @@ -36,5 +36,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-ride/rider-trip.ts b/src/models/gtfs-ride/rider-trip.ts index f4fb731..ad70d0d 100644 --- a/src/models/gtfs-ride/rider-trip.ts +++ b/src/models/gtfs-ride/rider-trip.ts @@ -1,4 +1,4 @@ -const model = { +export const riderTrip = { filenameBase: 'rider_trip', filenameExtension: 'txt', nonstandard: true, @@ -109,5 +109,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-ride/ridership.ts b/src/models/gtfs-ride/ridership.ts index 18c6389..0497471 100644 --- a/src/models/gtfs-ride/ridership.ts +++ b/src/models/gtfs-ride/ridership.ts @@ -1,4 +1,4 @@ -const model = { +export const ridership = { filenameBase: 'ridership', filenameExtension: 'txt', nonstandard: true, @@ -123,5 +123,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs-ride/trip-capacity.ts b/src/models/gtfs-ride/trip-capacity.ts index e98b4f3..2ff972a 100644 --- a/src/models/gtfs-ride/trip-capacity.ts +++ b/src/models/gtfs-ride/trip-capacity.ts @@ -1,4 +1,4 @@ -const model = { +export const tripCapacity = { filenameBase: 'trip_capacity', filenameExtension: 'txt', nonstandard: true, @@ -47,5 +47,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/agency.ts b/src/models/gtfs/agency.ts index bb30e22..310b285 100644 --- a/src/models/gtfs/agency.ts +++ b/src/models/gtfs/agency.ts @@ -1,4 +1,4 @@ -const model = { +export const agency = { filenameBase: 'agency', filenameExtension: 'txt', schema: [ @@ -45,5 +45,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/areas.ts b/src/models/gtfs/areas.ts index a096c4a..21e1b05 100644 --- a/src/models/gtfs/areas.ts +++ b/src/models/gtfs/areas.ts @@ -1,4 +1,4 @@ -const model = { +export const areas = { filenameBase: 'areas', filenameExtension: 'txt', schema: [ @@ -15,5 +15,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/attributions.ts b/src/models/gtfs/attributions.ts index 1c095f1..a62133a 100644 --- a/src/models/gtfs/attributions.ts +++ b/src/models/gtfs/attributions.ts @@ -1,4 +1,4 @@ -const model = { +export const attributions = { filenameBase: 'attributions', filenameExtension: 'txt', schema: [ @@ -62,5 +62,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/booking-rules.ts b/src/models/gtfs/booking-rules.ts index ddab47f..f89c295 100644 --- a/src/models/gtfs/booking-rules.ts +++ b/src/models/gtfs/booking-rules.ts @@ -1,4 +1,4 @@ -const model = { +export const bookingRules = { filenameBase: 'booking_rules', filenameExtension: 'txt', schema: [ @@ -88,5 +88,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/calendar-dates.ts b/src/models/gtfs/calendar-dates.ts index 1da4c3f..ef4bb92 100644 --- a/src/models/gtfs/calendar-dates.ts +++ b/src/models/gtfs/calendar-dates.ts @@ -1,4 +1,4 @@ -const model = { +export const calendarDates = { filenameBase: 'calendar_dates', filenameExtension: 'txt', schema: [ @@ -30,5 +30,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/calendar.ts b/src/models/gtfs/calendar.ts index db11448..15bc410 100644 --- a/src/models/gtfs/calendar.ts +++ b/src/models/gtfs/calendar.ts @@ -1,4 +1,4 @@ -const model = { +export const calendar = { filenameBase: 'calendar', filenameExtension: 'txt', schema: [ @@ -72,5 +72,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-attributes.ts b/src/models/gtfs/fare-attributes.ts index e2b123b..ffada06 100644 --- a/src/models/gtfs/fare-attributes.ts +++ b/src/models/gtfs/fare-attributes.ts @@ -1,4 +1,4 @@ -const model = { +export const fareAttributes = { filenameBase: 'fare_attributes', filenameExtension: 'txt', schema: [ @@ -44,5 +44,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-leg-rules.ts b/src/models/gtfs/fare-leg-rules.ts index 24596ae..a207e04 100644 --- a/src/models/gtfs/fare-leg-rules.ts +++ b/src/models/gtfs/fare-leg-rules.ts @@ -1,4 +1,4 @@ -const model = { +export const fareLegRules = { filenameBase: 'fare_leg_rules', filenameExtension: 'txt', schema: [ @@ -51,5 +51,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-media.ts b/src/models/gtfs/fare-media.ts index 46f0487..c4ce9b4 100644 --- a/src/models/gtfs/fare-media.ts +++ b/src/models/gtfs/fare-media.ts @@ -1,4 +1,4 @@ -const model = { +export const fareMedia = { filenameBase: 'fare_media', filenameExtension: 'txt', schema: [ @@ -22,5 +22,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-products.ts b/src/models/gtfs/fare-products.ts index 501ca08..4ec390c 100644 --- a/src/models/gtfs/fare-products.ts +++ b/src/models/gtfs/fare-products.ts @@ -1,4 +1,4 @@ -const model = { +export const fareProducts = { filenameBase: 'fare_products', filenameExtension: 'txt', schema: [ @@ -31,5 +31,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-rules.ts b/src/models/gtfs/fare-rules.ts index f28296f..c668279 100644 --- a/src/models/gtfs/fare-rules.ts +++ b/src/models/gtfs/fare-rules.ts @@ -1,4 +1,4 @@ -const model = { +export const fareRules = { filenameBase: 'fare_rules', filenameExtension: 'txt', schema: [ @@ -30,5 +30,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/fare-transfer-rules.ts b/src/models/gtfs/fare-transfer-rules.ts index 95a3bcd..9d9a820 100644 --- a/src/models/gtfs/fare-transfer-rules.ts +++ b/src/models/gtfs/fare-transfer-rules.ts @@ -1,4 +1,4 @@ -const model = { +export const fareTransferRules = { filenameBase: 'fare_transfer_rules', filenameExtension: 'txt', schema: [ @@ -52,5 +52,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/feed-info.ts b/src/models/gtfs/feed-info.ts index a24bb32..352f811 100644 --- a/src/models/gtfs/feed-info.ts +++ b/src/models/gtfs/feed-info.ts @@ -1,4 +1,4 @@ -const model = { +export const feedInfo = { filenameBase: 'feed_info', filenameExtension: 'txt', schema: [ @@ -46,5 +46,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/frequencies.ts b/src/models/gtfs/frequencies.ts index 393c13e..2734eee 100644 --- a/src/models/gtfs/frequencies.ts +++ b/src/models/gtfs/frequencies.ts @@ -1,4 +1,4 @@ -const model = { +export const frequencies = { filenameBase: 'frequencies', filenameExtension: 'txt', schema: [ @@ -42,5 +42,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/levels.ts b/src/models/gtfs/levels.ts index 920d164..73897e8 100644 --- a/src/models/gtfs/levels.ts +++ b/src/models/gtfs/levels.ts @@ -1,4 +1,4 @@ -const model = { +export const levels = { filenameBase: 'levels', filenameExtension: 'txt', schema: [ @@ -21,5 +21,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/location-group-stops.ts b/src/models/gtfs/location-group-stops.ts index fd8f817..8062beb 100644 --- a/src/models/gtfs/location-group-stops.ts +++ b/src/models/gtfs/location-group-stops.ts @@ -1,4 +1,4 @@ -const model = { +export const locationGroupStops = { filenameBase: 'location_group_stops', filenameExtension: 'txt', schema: [ @@ -18,5 +18,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/location-groups.ts b/src/models/gtfs/location-groups.ts index a14b748..7040937 100644 --- a/src/models/gtfs/location-groups.ts +++ b/src/models/gtfs/location-groups.ts @@ -1,4 +1,4 @@ -const model = { +export const locationGroups = { filenameBase: 'location_groups', filenameExtension: 'txt', schema: [ @@ -15,5 +15,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/locations.ts b/src/models/gtfs/locations.ts index af73796..d63c0d0 100644 --- a/src/models/gtfs/locations.ts +++ b/src/models/gtfs/locations.ts @@ -1,4 +1,4 @@ -const model = { +export const locations = { filenameBase: 'locations', filenameExtension: 'geojson', schema: [ @@ -8,5 +8,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/networks.ts b/src/models/gtfs/networks.ts index fdd9af9..804f1c0 100644 --- a/src/models/gtfs/networks.ts +++ b/src/models/gtfs/networks.ts @@ -1,4 +1,4 @@ -const model = { +export const networks = { filenameBase: 'networks', filenameExtension: 'txt', schema: [ @@ -16,5 +16,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/pathways.ts b/src/models/gtfs/pathways.ts index 3a5067d..6fcd374 100644 --- a/src/models/gtfs/pathways.ts +++ b/src/models/gtfs/pathways.ts @@ -1,4 +1,4 @@ -const model = { +export const pathways = { filenameBase: 'pathways', filenameExtension: 'txt', schema: [ @@ -70,5 +70,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/route-networks.ts b/src/models/gtfs/route-networks.ts index 0632d51..0beab54 100644 --- a/src/models/gtfs/route-networks.ts +++ b/src/models/gtfs/route-networks.ts @@ -1,4 +1,4 @@ -const model = { +export const routeNetworks = { filenameBase: 'route_networks', filenameExtension: 'txt', schema: [ @@ -17,5 +17,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/routes.ts b/src/models/gtfs/routes.ts index 9af6e0b..64aa7fd 100644 --- a/src/models/gtfs/routes.ts +++ b/src/models/gtfs/routes.ts @@ -1,4 +1,4 @@ -const model = { +export const routes = { filenameBase: 'routes', filenameExtension: 'txt', schema: [ @@ -75,5 +75,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/shapes.ts b/src/models/gtfs/shapes.ts index 666e560..906d042 100644 --- a/src/models/gtfs/shapes.ts +++ b/src/models/gtfs/shapes.ts @@ -1,4 +1,4 @@ -const model = { +export const shapes = { filenameBase: 'shapes', filenameExtension: 'txt', schema: [ @@ -37,5 +37,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/stop-areas.ts b/src/models/gtfs/stop-areas.ts index d3269cb..e7a0fb5 100644 --- a/src/models/gtfs/stop-areas.ts +++ b/src/models/gtfs/stop-areas.ts @@ -1,4 +1,4 @@ -const model = { +export const stopAreas = { filenameBase: 'stop_areas', filenameExtension: 'txt', schema: [ @@ -16,5 +16,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/stop-times.ts b/src/models/gtfs/stop-times.ts index c6d4c22..6b96b8d 100644 --- a/src/models/gtfs/stop-times.ts +++ b/src/models/gtfs/stop-times.ts @@ -1,4 +1,4 @@ -const model = { +export const stopTimes = { filenameBase: 'stop_times', filenameExtension: 'txt', schema: [ @@ -116,5 +116,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/stops.ts b/src/models/gtfs/stops.ts index fee56fc..1a627fc 100644 --- a/src/models/gtfs/stops.ts +++ b/src/models/gtfs/stops.ts @@ -1,4 +1,4 @@ -const model = { +export const stops = { filenameBase: 'stops', filenameExtension: 'txt', schema: [ @@ -81,5 +81,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/timeframes.ts b/src/models/gtfs/timeframes.ts index 6c8dab4..05bb1cc 100644 --- a/src/models/gtfs/timeframes.ts +++ b/src/models/gtfs/timeframes.ts @@ -1,4 +1,4 @@ -const model = { +export const timeframes = { filenameBase: 'timeframes', filenameExtension: 'txt', schema: [ @@ -25,5 +25,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/transfers.ts b/src/models/gtfs/transfers.ts index fc8365c..1a8c01f 100644 --- a/src/models/gtfs/transfers.ts +++ b/src/models/gtfs/transfers.ts @@ -1,4 +1,4 @@ -const model = { +export const transfers = { filenameBase: 'transfers', filenameExtension: 'txt', schema: [ @@ -52,5 +52,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/translations.ts b/src/models/gtfs/translations.ts index 3728162..18f49b9 100644 --- a/src/models/gtfs/translations.ts +++ b/src/models/gtfs/translations.ts @@ -1,4 +1,4 @@ -const model = { +export const translations = { filenameBase: 'translations', filenameExtension: 'txt', schema: [ @@ -44,5 +44,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/gtfs/trips.ts b/src/models/gtfs/trips.ts index 9b13181..8257fb2 100644 --- a/src/models/gtfs/trips.ts +++ b/src/models/gtfs/trips.ts @@ -1,4 +1,4 @@ -const model = { +export const trips = { filenameBase: 'trips', filenameExtension: 'txt', schema: [ @@ -66,5 +66,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/models.ts b/src/models/models.ts index c2dfc96..0f07ae4 100644 --- a/src/models/models.ts +++ b/src/models/models.ts @@ -1,122 +1,60 @@ -import { IModel } from '../types/global_interfaces.ts'; - -import agency from './gtfs/agency.ts'; -import areas from './gtfs/areas.ts'; -import attributions from './gtfs/attributions.ts'; -import bookingRules from './gtfs/booking-rules.ts'; -import calendarDates from './gtfs/calendar-dates.ts'; -import calendar from './gtfs/calendar.ts'; -import fareAttributes from './gtfs/fare-attributes.ts'; -import fareLegRules from './gtfs/fare-leg-rules.ts'; -import fareMedia from './gtfs/fare-media.ts'; -import fareProducts from './gtfs/fare-products.ts'; -import fareRules from './gtfs/fare-rules.ts'; -import fareTransferRules from './gtfs/fare-transfer-rules.ts'; -import feedInfo from './gtfs/feed-info.ts'; -import frequencies from './gtfs/frequencies.ts'; -import levels from './gtfs/levels.ts'; -import locationGroups from './gtfs/location-groups.ts'; -import locationGroupStops from './gtfs/location-group-stops.ts'; -import locations from './gtfs/locations.ts'; -import networks from './gtfs/networks.ts'; -import pathways from './gtfs/pathways.ts'; -import routeNetworks from './gtfs/route-networks.ts'; -import routes from './gtfs/routes.ts'; -import shapes from './gtfs/shapes.ts'; -import stopAreas from './gtfs/stop-areas.ts'; -import stopTimes from './gtfs/stop-times.ts'; -import stops from './gtfs/stops.ts'; -import timeframes from './gtfs/timeframes.ts'; -import transfers from './gtfs/transfers.ts'; -import translations from './gtfs/translations.ts'; -import trips from './gtfs/trips.ts'; - -import timetables from './non-standard/timetables.ts'; -import timetablePages from './non-standard/timetable-pages.ts'; -import timetableStopOrder from './non-standard/timetable-stop-order.ts'; -import timetableNotes from './non-standard/timetable-notes.ts'; -import timetableNotesReferences from './non-standard/timetable-notes-references.ts'; -import tripsDatedVehicleJourney from './non-standard/trips-dated-vehicle-journey.ts'; - -import calendarAttributes from './gtfs-plus/calendar-attributes.ts'; -import directions from './gtfs-plus/directions.ts'; -import routeAttributes from './gtfs-plus/route-attributes.ts'; -import stopAttributes from './gtfs-plus/stop-attributes.ts'; - -import boardAlight from './gtfs-ride/board-alight.ts'; -import riderTrip from './gtfs-ride/rider-trip.ts'; -import ridership from './gtfs-ride/ridership.ts'; -import tripCapacity from './gtfs-ride/trip-capacity.ts'; -import rideFeedInfo from './gtfs-ride/ride-feed-info.ts'; - -import tripUpdates from './gtfs-realtime/trip-updates.ts'; -import stopTimeUpdates from './gtfs-realtime/stop-time-updates.ts'; -import vehiclePositions from './gtfs-realtime/vehicle-positions.ts'; -import serviceAlerts from './gtfs-realtime/service-alerts.ts'; -import serviceAlertTargets from './gtfs-realtime/service-alert-targets.ts'; - -import deadheadTimes from './ods/deadhead-times.ts'; -import deadheads from './ods/deadheads.ts'; -import opsLocations from './ods/ops-locations.ts'; -import runEvents from './ods/run-events.ts'; -import runsPieces from './ods/runs-pieces.ts'; - -const models: IModel[] = [ - agency, - areas, - attributions, - bookingRules, - calendarDates, - calendar, - fareAttributes, - fareLegRules, - fareMedia, - fareProducts, - fareRules, - fareTransferRules, - feedInfo, - frequencies, - levels, - locationGroups, - locationGroupStops, - locations, - networks, - pathways, - routeNetworks, - routes, - shapes, - stopAreas, - stopTimes, - stops, - timeframes, - transfers, - translations, - trips, - timetables, - timetablePages, - timetableStopOrder, - timetableNotes, - timetableNotesReferences, - tripsDatedVehicleJourney, - calendarAttributes, - directions, - routeAttributes, - stopAttributes, - boardAlight, - rideFeedInfo, - riderTrip, - ridership, - tripCapacity, - tripUpdates, - stopTimeUpdates, - vehiclePositions, - serviceAlerts, - serviceAlertTargets, - deadheadTimes, - deadheads, - opsLocations, - runEvents, - runsPieces, -]; - -export default models; +export { agency } from './gtfs/agency.ts'; +export { areas } from './gtfs/areas.ts'; +export { attributions } from './gtfs/attributions.ts'; +export { bookingRules } from './gtfs/booking-rules.ts'; +export { calendarDates } from './gtfs/calendar-dates.ts'; +export { calendar } from './gtfs/calendar.ts'; +export { fareAttributes } from './gtfs/fare-attributes.ts'; +export { fareLegRules } from './gtfs/fare-leg-rules.ts'; +export { fareMedia } from './gtfs/fare-media.ts'; +export { fareProducts } from './gtfs/fare-products.ts'; +export { fareRules } from './gtfs/fare-rules.ts'; +export { fareTransferRules } from './gtfs/fare-transfer-rules.ts'; +export { feedInfo } from './gtfs/feed-info.ts'; +export { frequencies } from './gtfs/frequencies.ts'; +export { levels } from './gtfs/levels.ts'; +export { locationGroups } from './gtfs/location-groups.ts'; +export { locationGroupStops } from './gtfs/location-group-stops.ts'; +export { locations } from './gtfs/locations.ts'; +export { networks } from './gtfs/networks.ts'; +export { pathways } from './gtfs/pathways.ts'; +export { routeNetworks } from './gtfs/route-networks.ts'; +export { routes } from './gtfs/routes.ts'; +export { shapes } from './gtfs/shapes.ts'; +export { stopAreas } from './gtfs/stop-areas.ts'; +export { stopTimes } from './gtfs/stop-times.ts'; +export { stops } from './gtfs/stops.ts'; +export { timeframes } from './gtfs/timeframes.ts'; +export { transfers } from './gtfs/transfers.ts'; +export { translations } from './gtfs/translations.ts'; +export { trips } from './gtfs/trips.ts'; + +export { timetables } from './non-standard/timetables.ts'; +export { timetablePages } from './non-standard/timetable-pages.ts'; +export { timetableStopOrder } from './non-standard/timetable-stop-order.ts'; +export { timetableNotes } from './non-standard/timetable-notes.ts'; +export { timetableNotesReferences } from './non-standard/timetable-notes-references.ts'; +export { tripsDatedVehicleJourney } from './non-standard/trips-dated-vehicle-journey.ts'; + +export { calendarAttributes } from './gtfs-plus/calendar-attributes.ts'; +export { directions } from './gtfs-plus/directions.ts'; +export { routeAttributes } from './gtfs-plus/route-attributes.ts'; +export { stopAttributes } from './gtfs-plus/stop-attributes.ts'; + +export { boardAlight } from './gtfs-ride/board-alight.ts'; +export { riderTrip } from './gtfs-ride/rider-trip.ts'; +export { ridership } from './gtfs-ride/ridership.ts'; +export { tripCapacity } from './gtfs-ride/trip-capacity.ts'; +export { rideFeedInfo } from './gtfs-ride/ride-feed-info.ts'; + +export { tripUpdates } from './gtfs-realtime/trip-updates.ts'; +export { stopTimeUpdates } from './gtfs-realtime/stop-time-updates.ts'; +export { vehiclePositions } from './gtfs-realtime/vehicle-positions.ts'; +export { serviceAlerts } from './gtfs-realtime/service-alerts.ts'; +export { serviceAlertTargets } from './gtfs-realtime/service-alert-targets.ts'; + +export { deadheadTimes } from './ods/deadhead-times.ts'; +export { deadheads } from './ods/deadheads.ts'; +export { opsLocations } from './ods/ops-locations.ts'; +export { runEvents } from './ods/run-events.ts'; +export { runsPieces } from './ods/runs-pieces.ts'; diff --git a/src/models/non-standard/timetable-notes-references.ts b/src/models/non-standard/timetable-notes-references.ts index d7b978b..12f469a 100644 --- a/src/models/non-standard/timetable-notes-references.ts +++ b/src/models/non-standard/timetable-notes-references.ts @@ -1,4 +1,4 @@ -const model = { +export const timetableNotesReferences = { filenameBase: 'timetable_notes_references', filenameExtension: 'txt', nonstandard: true, @@ -46,5 +46,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/non-standard/timetable-notes.ts b/src/models/non-standard/timetable-notes.ts index 6a8d1ea..166e253 100644 --- a/src/models/non-standard/timetable-notes.ts +++ b/src/models/non-standard/timetable-notes.ts @@ -1,4 +1,4 @@ -const model = { +export const timetableNotes = { filenameBase: 'timetable_notes', filenameExtension: 'txt', nonstandard: true, @@ -20,5 +20,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/non-standard/timetable-pages.ts b/src/models/non-standard/timetable-pages.ts index 2954417..1d74fe5 100644 --- a/src/models/non-standard/timetable-pages.ts +++ b/src/models/non-standard/timetable-pages.ts @@ -1,4 +1,4 @@ -const model = { +export const timetablePages = { filenameBase: 'timetable_pages', filenameExtension: 'txt', nonstandard: true, @@ -19,5 +19,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/non-standard/timetable-stop-order.ts b/src/models/non-standard/timetable-stop-order.ts index ddfd397..fee2b8c 100644 --- a/src/models/non-standard/timetable-stop-order.ts +++ b/src/models/non-standard/timetable-stop-order.ts @@ -1,4 +1,4 @@ -const model = { +export const timetableStopOrder = { filenameBase: 'timetable_stop_order', filenameExtension: 'txt', nonstandard: true, @@ -28,5 +28,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/non-standard/timetables.ts b/src/models/non-standard/timetables.ts index a97896d..3d6f301 100644 --- a/src/models/non-standard/timetables.ts +++ b/src/models/non-standard/timetables.ts @@ -1,4 +1,4 @@ -const model = { +export const timetables = { filenameBase: 'timetables', filenameExtension: 'txt', nonstandard: true, @@ -140,5 +140,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/non-standard/trips-dated-vehicle-journey.ts b/src/models/non-standard/trips-dated-vehicle-journey.ts index ff5e997..2931f59 100644 --- a/src/models/non-standard/trips-dated-vehicle-journey.ts +++ b/src/models/non-standard/trips-dated-vehicle-journey.ts @@ -1,4 +1,4 @@ -const model = { +export const tripsDatedVehicleJourney = { filenameBase: 'trips_dated_vehicle_journey', filenameExtension: 'txt', nonstandard: true, @@ -30,5 +30,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/ods/deadhead-times.ts b/src/models/ods/deadhead-times.ts index 53b62b2..28afa28 100644 --- a/src/models/ods/deadhead-times.ts +++ b/src/models/ods/deadhead-times.ts @@ -1,4 +1,4 @@ -const model = { +export const deadheadTimes = { filenameBase: 'deadhead_times', filenameExtension: 'txt', nonstandard: true, @@ -61,5 +61,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/ods/deadheads.ts b/src/models/ods/deadheads.ts index 9dd38e4..b18a282 100644 --- a/src/models/ods/deadheads.ts +++ b/src/models/ods/deadheads.ts @@ -1,4 +1,4 @@ -const model = { +export const deadheads = { filenameBase: 'deadheads', filenameExtension: 'txt', nonstandard: true, @@ -56,5 +56,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/ods/ops-locations.ts b/src/models/ods/ops-locations.ts index 8da2750..33e82e7 100644 --- a/src/models/ods/ops-locations.ts +++ b/src/models/ods/ops-locations.ts @@ -1,4 +1,4 @@ -const model = { +export const opsLocations = { filenameBase: 'ops_locations', filenameExtension: 'txt', nonstandard: true, @@ -42,5 +42,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/ods/run-events.ts b/src/models/ods/run-events.ts index c4047ea..5f20fb7 100644 --- a/src/models/ods/run-events.ts +++ b/src/models/ods/run-events.ts @@ -1,4 +1,4 @@ -const model = { +export const runEvents = { filenameBase: 'run_event', filenameExtension: 'txt', nonstandard: true, @@ -66,5 +66,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/models/ods/runs-pieces.ts b/src/models/ods/runs-pieces.ts index 50a9d4f..c8b499a 100644 --- a/src/models/ods/runs-pieces.ts +++ b/src/models/ods/runs-pieces.ts @@ -1,4 +1,4 @@ -const model = { +export const runsPieces = { filenameBase: 'runs_pieces', filenameExtension: 'txt', nonstandard: true, @@ -55,5 +55,3 @@ const model = { }, ], }; - -export default model; diff --git a/src/test/export-gtfs.test.ts b/src/test/export-gtfs.test.ts index f6c73b6..817b813 100644 --- a/src/test/export-gtfs.test.ts +++ b/src/test/export-gtfs.test.ts @@ -13,7 +13,8 @@ import { exportGtfs, getAgencies, } from '../index.ts'; -import models from '../models/models.ts'; +import * as models from '../models/models.ts'; +import { IModel } from '../types/global_interfaces.ts'; describe('exportGtfs():', function () { describe('Export GTFS', () => { @@ -43,7 +44,7 @@ describe('exportGtfs():', function () { await unzip(config.agencies[0].path, temporaryDir); await Promise.all( - models.map((model) => { + Object.values(models).map((model: IModel) => { const filePath = path.join( temporaryDir, `${model.filenameBase}.${model.filenameExtension}`, @@ -98,8 +99,8 @@ describe('exportGtfs():', function () { await rm(temporaryDir, { recursive: true, force: true }); }); - const modelsToValidate = models.filter( - (model) => model.extension !== 'gtfs-realtime', + const modelsToValidate: IModel[] = Object.values(models).filter( + (model: IModel) => model.extension !== 'gtfs-realtime', ); for (const model of modelsToValidate) { diff --git a/src/test/get-ride-feed-infos.test.ts b/src/test/get-ride-feed-infos.test.ts index 6e82e3a..809dfd8 100644 --- a/src/test/get-ride-feed-infos.test.ts +++ b/src/test/get-ride-feed-infos.test.ts @@ -1,5 +1,5 @@ import config from './test-config.ts'; -import { openDb, closeDb, importGtfs, getRideFeedInfos } from '../index.ts'; +import { openDb, closeDb, importGtfs, getRideFeedInfo } from '../index.ts'; beforeAll(async () => { openDb(); @@ -11,9 +11,9 @@ afterAll(async () => { closeDb(db); }); -describe('getRideFeedInfos():', () => { +describe('getRideFeedInfo():', () => { it('should return empty array if no ride-feed-infos (GTFS-ride)', () => { - const results = getRideFeedInfos({}); + const results = getRideFeedInfo({}); expect(results).toHaveLength(0); }); diff --git a/src/test/get-riderships.test.ts b/src/test/get-riderships.test.ts index d446078..f33da37 100644 --- a/src/test/get-riderships.test.ts +++ b/src/test/get-riderships.test.ts @@ -1,5 +1,5 @@ import config from './test-config.ts'; -import { openDb, closeDb, importGtfs, getRiderships } from '../index.ts'; +import { openDb, closeDb, importGtfs, getRidership } from '../index.ts'; beforeAll(async () => { openDb(); @@ -11,11 +11,11 @@ afterAll(async () => { closeDb(db); }); -describe('getRiderships():', () => { +describe('getRidership():', () => { it('should return empty array if no riderships (GTFS-ride)', () => { const routeId = 'fake-route-id'; - const results = getRiderships({ + const results = getRidership({ route_id: routeId, }); diff --git a/src/test/import-gtfs.test.ts b/src/test/import-gtfs.test.ts index 901de96..de813f0 100644 --- a/src/test/import-gtfs.test.ts +++ b/src/test/import-gtfs.test.ts @@ -7,7 +7,8 @@ import { temporaryDirectory } from 'tempy'; import { prepDirectory, unzip } from '../lib/file-utils.ts'; import config from './test-config.ts'; import { openDb, closeDb, importGtfs, getRoutes, getStops } from '../index.ts'; -import models from '../models/models.ts'; +import * as models from '../models/models.ts'; +import { IModel } from '../types/global_interfaces.ts'; const agenciesFixturesRemote = [ { @@ -113,7 +114,7 @@ describe('importGtfs():', function () { await unzip(agenciesFixturesLocal[0].path, temporaryDir); await Promise.all( - models.map((model) => { + Object.values(models).map((model: IModel) => { const filePath = path.join( temporaryDir, `${model.filenameBase}.${model.filenameExtension}`, @@ -157,8 +158,8 @@ describe('importGtfs():', function () { await rm(temporaryDir, { recursive: true, force: true }); }); - const modelsToValidate = models.filter( - (model) => model.extension !== 'gtfs-realtime', + const modelsToValidate: IModel[] = Object.values(models).filter( + (model: IModel) => model.extension !== 'gtfs-realtime', ); for (const model of modelsToValidate) { diff --git a/tsup.config.js b/tsup.config.js index b694410..6f22805 100644 --- a/tsup.config.js +++ b/tsup.config.js @@ -6,6 +6,7 @@ export default defineConfig({ 'src/bin/gtfs-export.ts', 'src/bin/gtfs-import.ts', 'src/bin/gtfsrealtime-update.ts', + 'src/models/models.ts', ], dts: true, clean: true,