diff --git a/src/lib/gtfs/agencies.ts b/src/lib/gtfs/agencies.ts index f92f75a9..69ff5528 100644 --- a/src/lib/gtfs/agencies.ts +++ b/src/lib/gtfs/agencies.ts @@ -1,8 +1,8 @@ -import { +import type { Agency, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all agencies that match the query parameters. */ -export function getAgencies( +export function getAgencies( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getAgencies( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Agency[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/areas.ts b/src/lib/gtfs/areas.ts index e03ce6dd..f728c056 100644 --- a/src/lib/gtfs/areas.ts +++ b/src/lib/gtfs/areas.ts @@ -1,8 +1,8 @@ -import { +import type { Area, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all areas that match the query parameters. */ -export function getAreas( +export function getAreas( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getAreas( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Area[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/attributions.ts b/src/lib/gtfs/attributions.ts index 90b846ba..6d34d035 100644 --- a/src/lib/gtfs/attributions.ts +++ b/src/lib/gtfs/attributions.ts @@ -1,8 +1,8 @@ -import { +import type { Attribution, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all attributions that match the query parameters. */ -export function getAttributions( +export function getAttributions( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getAttributions( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Attribution[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/booking-rules.ts b/src/lib/gtfs/booking-rules.ts index 96f9025e..d4c79f0a 100644 --- a/src/lib/gtfs/booking-rules.ts +++ b/src/lib/gtfs/booking-rules.ts @@ -1,8 +1,8 @@ -import { +import type { BookingRule, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all booking rules that match the query parameters. */ -export function getBookingRules( +export function getBookingRules( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getBookingRules( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as BookingRule[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/calendar-dates.ts b/src/lib/gtfs/calendar-dates.ts index b7d7298e..c8fb3f5f 100644 --- a/src/lib/gtfs/calendar-dates.ts +++ b/src/lib/gtfs/calendar-dates.ts @@ -1,8 +1,8 @@ -import { +import type { CalendarDate, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of calendarDates that match the query parameters. */ -export function getCalendarDates( +export function getCalendarDates( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getCalendarDates( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as CalendarDate[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/calendars.ts b/src/lib/gtfs/calendars.ts index b443e34d..827eb5b7 100644 --- a/src/lib/gtfs/calendars.ts +++ b/src/lib/gtfs/calendars.ts @@ -1,8 +1,8 @@ -import { +import type { Calendar, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -16,9 +16,9 @@ import { /* * Returns an array of calendars that match the query parameters. */ -export function getCalendars( +export function getCalendars( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -32,7 +32,7 @@ export function getCalendars( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Calendar[]; + .all() as QueryResult[]; } /* diff --git a/src/lib/gtfs/fare-attributes.ts b/src/lib/gtfs/fare-attributes.ts index a2e7de99..f2a5f111 100644 --- a/src/lib/gtfs/fare-attributes.ts +++ b/src/lib/gtfs/fare-attributes.ts @@ -1,8 +1,8 @@ -import { +import type { FareAttribute, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare attributes that match the query parameters. */ -export function getFareAttributes( +export function getFareAttributes( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareAttributes( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareAttribute[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/fare-leg-rules.ts b/src/lib/gtfs/fare-leg-rules.ts index e3a09f85..cd7d9e7f 100644 --- a/src/lib/gtfs/fare-leg-rules.ts +++ b/src/lib/gtfs/fare-leg-rules.ts @@ -1,8 +1,8 @@ -import { +import type { FareLegRule, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare leg rules that match the query parameters. */ -export function getFareLegRules( +export function getFareLegRules( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareLegRules( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareLegRule[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/fare-media.ts b/src/lib/gtfs/fare-media.ts index 7f3fc46c..c2d3d955 100644 --- a/src/lib/gtfs/fare-media.ts +++ b/src/lib/gtfs/fare-media.ts @@ -1,8 +1,8 @@ -import { +import type { FareMedia, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare media that match the query parameters. */ -export function getFareMedia( +export function getFareMedia( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareMedia( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareMedia[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/fare-products.ts b/src/lib/gtfs/fare-products.ts index f3f7a5db..77dd82d1 100644 --- a/src/lib/gtfs/fare-products.ts +++ b/src/lib/gtfs/fare-products.ts @@ -1,8 +1,8 @@ -import { +import type { FareProduct, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare products that match the query parameters. */ -export function getFareProducts( +export function getFareProducts( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareProducts( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareProduct[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/fare-rules.ts b/src/lib/gtfs/fare-rules.ts index e709c9d1..6a3baeb8 100644 --- a/src/lib/gtfs/fare-rules.ts +++ b/src/lib/gtfs/fare-rules.ts @@ -1,8 +1,8 @@ -import { +import type { FareRule, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare rules that match the query parameters. */ -export function getFareRules( +export function getFareRules( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareRules( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareRule[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/fare-transfer-rules.ts b/src/lib/gtfs/fare-transfer-rules.ts index 9564357f..8fd97b0f 100644 --- a/src/lib/gtfs/fare-transfer-rules.ts +++ b/src/lib/gtfs/fare-transfer-rules.ts @@ -1,8 +1,8 @@ -import { +import type { FareTransferRule, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all fare transfer rules that match the query parameters. */ -export function getFareTransferRules( +export function getFareTransferRules( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFareTransferRules( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FareTransferRule[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/feed-info.ts b/src/lib/gtfs/feed-info.ts index 68ae439c..137f346c 100644 --- a/src/lib/gtfs/feed-info.ts +++ b/src/lib/gtfs/feed-info.ts @@ -1,8 +1,8 @@ -import { +import type { FeedInfo, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all feed info that match the query parameters. */ -export function getFeedInfo( +export function getFeedInfo( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFeedInfo( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as FeedInfo[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/frequencies.ts b/src/lib/gtfs/frequencies.ts index 024225f8..d276521a 100644 --- a/src/lib/gtfs/frequencies.ts +++ b/src/lib/gtfs/frequencies.ts @@ -1,8 +1,8 @@ -import { +import type { Frequency, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all frequencies that match the query parameters. */ -export function getFrequencies( +export function getFrequencies( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getFrequencies( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Frequency[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/levels.ts b/src/lib/gtfs/levels.ts index b316884e..e9fd1bcb 100644 --- a/src/lib/gtfs/levels.ts +++ b/src/lib/gtfs/levels.ts @@ -1,8 +1,8 @@ -import { +import type { Level, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all levels that match the query parameters. */ -export function getLevels( +export function getLevels( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getLevels( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Level[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/location-group-stops.ts b/src/lib/gtfs/location-group-stops.ts index 8d503629..2d244944 100644 --- a/src/lib/gtfs/location-group-stops.ts +++ b/src/lib/gtfs/location-group-stops.ts @@ -1,8 +1,8 @@ -import { +import type { LocationGroupStop, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all location group stops that match the query parameters. */ -export function getLocationGroupStops( +export function getLocationGroupStops( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getLocationGroupStops( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as LocationGroupStop[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/location-groups.ts b/src/lib/gtfs/location-groups.ts index b9206589..fdcd209d 100644 --- a/src/lib/gtfs/location-groups.ts +++ b/src/lib/gtfs/location-groups.ts @@ -1,8 +1,8 @@ -import { +import type { LocationGroup, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all location groups that match the query parameters. */ -export function getLocationGroups( +export function getLocationGroups( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getLocationGroups( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as LocationGroup[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/locations.ts b/src/lib/gtfs/locations.ts index ff57ee23..1c70b1d7 100644 --- a/src/lib/gtfs/locations.ts +++ b/src/lib/gtfs/locations.ts @@ -1,8 +1,8 @@ -import { +import type { Location, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all locations that match the query parameters. */ -export function getLocations( +export function getLocations( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getLocations( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Location[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/networks.ts b/src/lib/gtfs/networks.ts index 2d657199..d5188772 100644 --- a/src/lib/gtfs/networks.ts +++ b/src/lib/gtfs/networks.ts @@ -1,8 +1,8 @@ -import { +import type { Network, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all networks that match the query parameters. */ -export function getNetworks( +export function getNetworks( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getNetworks( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Network[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/pathways.ts b/src/lib/gtfs/pathways.ts index c9952858..03343231 100644 --- a/src/lib/gtfs/pathways.ts +++ b/src/lib/gtfs/pathways.ts @@ -1,8 +1,8 @@ -import { +import type { Pathway, QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all pathways that match the query parameters. */ -export function getPathways( +export function getPathways( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getPathways( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Pathway[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/route-networks.ts b/src/lib/gtfs/route-networks.ts index 603c0f27..524c6c88 100644 --- a/src/lib/gtfs/route-networks.ts +++ b/src/lib/gtfs/route-networks.ts @@ -1,8 +1,8 @@ -import { +import type { QueryOptions, RouteNetwork, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all route_networks that match the query parameters. */ -export function getRouteNetworks( +export function getRouteNetworks( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getRouteNetworks( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as RouteNetwork[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/routes.ts b/src/lib/gtfs/routes.ts index f805470b..b1f73e8c 100644 --- a/src/lib/gtfs/routes.ts +++ b/src/lib/gtfs/routes.ts @@ -1,10 +1,10 @@ import { omit, pick } from 'lodash-es'; -import { +import type { QueryOptions, Route, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -46,9 +46,9 @@ function buildTripSubquery(query: { service_id?: string; stop_id?: string }) { * A `service_id` query parameter may be passed to limit routes to specific * calendars. */ -export function getRoutes( +export function getRoutes( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -80,5 +80,5 @@ export function getRoutes( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Route[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/shapes.ts b/src/lib/gtfs/shapes.ts index 93b4dc40..4b859bda 100644 --- a/src/lib/gtfs/shapes.ts +++ b/src/lib/gtfs/shapes.ts @@ -2,11 +2,11 @@ import { compact, omit, pick } from 'lodash-es'; import { FeatureCollection } from 'geojson'; import { featureCollection } from '@turf/helpers'; -import { +import type { QueryOptions, Shape, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, } from '../../types/global_interfaces.ts'; import { openDb } from '../db.ts'; @@ -32,9 +32,9 @@ function buildTripSubquery(query: { [key: string]: string }) { * parameter may be passed to find all shapes for a trip. A `direction_id` * query parameter may be passed to find all shapes for a direction. */ -export function getShapes( +export function getShapes( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -73,7 +73,7 @@ export function getShapes( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Shape[]; + .all() as QueryResult[]; } /* diff --git a/src/lib/gtfs/stop-areas.ts b/src/lib/gtfs/stop-areas.ts index 7dd6f7ea..cd3cc2b8 100644 --- a/src/lib/gtfs/stop-areas.ts +++ b/src/lib/gtfs/stop-areas.ts @@ -1,7 +1,7 @@ -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, StopArea, } from '../../types/global_interfaces.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all stop areas that match the query parameters. */ -export function getStopAreas( +export function getStopAreas( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getStopAreas( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as StopArea[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/stop-times.ts b/src/lib/gtfs/stop-times.ts index fe8e1fe4..d748a63d 100644 --- a/src/lib/gtfs/stop-times.ts +++ b/src/lib/gtfs/stop-times.ts @@ -1,9 +1,9 @@ import { omit } from 'lodash-es'; import sqlString from 'sqlstring-sqlite'; -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, StopTime, } from '../../types/global_interfaces.ts'; @@ -19,9 +19,9 @@ import { getServiceIdsByDate } from './calendars.ts'; /* * Returns an array of stoptimes that match the query parameters. */ -export function getStoptimes( +export function getStoptimes( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -79,5 +79,5 @@ export function getStoptimes( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as StopTime[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/stops.ts b/src/lib/gtfs/stops.ts index 9d6cc3a8..ce0ec929 100644 --- a/src/lib/gtfs/stops.ts +++ b/src/lib/gtfs/stops.ts @@ -1,10 +1,10 @@ import { omit, orderBy, pick } from 'lodash-es'; import { FeatureCollection } from 'geojson'; -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, Stop, } from '../../types/global_interfaces.ts'; @@ -38,9 +38,9 @@ function buildStoptimeSubquery(query: { [key: string]: string }) { * `direction_id` query parameter may be passed to find all shapes for a * direction. */ -export function getStops( +export function getStops( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -109,7 +109,7 @@ export function getStops( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Stop[]; + .all() as QueryResult[]; } /* diff --git a/src/lib/gtfs/timeframes.ts b/src/lib/gtfs/timeframes.ts index 87c11968..fe406fdf 100644 --- a/src/lib/gtfs/timeframes.ts +++ b/src/lib/gtfs/timeframes.ts @@ -1,7 +1,7 @@ -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, Timeframe, } from '../../types/global_interfaces.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all timeframes that match the query parameters. */ -export function getTimeframes( +export function getTimeframes( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getTimeframes( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Timeframe[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/transfers.ts b/src/lib/gtfs/transfers.ts index 0811b1f6..fabe1380 100644 --- a/src/lib/gtfs/transfers.ts +++ b/src/lib/gtfs/transfers.ts @@ -1,7 +1,7 @@ -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, Transfer, } from '../../types/global_interfaces.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all transfers that match the query parameters. */ -export function getTransfers( +export function getTransfers( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getTransfers( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Transfer[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/translations.ts b/src/lib/gtfs/translations.ts index a55a984b..316cacac 100644 --- a/src/lib/gtfs/translations.ts +++ b/src/lib/gtfs/translations.ts @@ -1,7 +1,7 @@ -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, Translation, } from '../../types/global_interfaces.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all translations that match the query parameters. */ -export function getTranslations( +export function getTranslations( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getTranslations( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Translation[]; + .all() as QueryResult[]; } diff --git a/src/lib/gtfs/trips.ts b/src/lib/gtfs/trips.ts index f89a3973..75328c4e 100644 --- a/src/lib/gtfs/trips.ts +++ b/src/lib/gtfs/trips.ts @@ -1,7 +1,7 @@ -import { +import type { QueryOptions, SqlOrderBy, - SqlSelect, + QueryResult, SqlWhere, Trip, } from '../../types/global_interfaces.ts'; @@ -15,9 +15,9 @@ import { /* * Returns an array of all trips that match the query parameters. */ -export function getTrips( +export function getTrips( query: SqlWhere = {}, - fields: SqlSelect = [], + fields: Fields[] = [], orderBy: SqlOrderBy = [], options: QueryOptions = {}, ) { @@ -31,5 +31,5 @@ export function getTrips( .prepare( `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`, ) - .all() as Trip[]; + .all() as QueryResult[]; } diff --git a/src/types/global_interfaces.ts b/src/types/global_interfaces.ts index 49ae448b..ef21535b 100644 --- a/src/types/global_interfaces.ts +++ b/src/types/global_interfaces.ts @@ -76,6 +76,12 @@ export type SqlWhere = Record; export type SqlSelect = string[]; +export type QueryResult = [ + Select, +] extends [never] + ? Base + : Pick; + export type SqlOrderBy = Array<[string, 'ASC' | 'DESC']>; export interface QueryOptions {