UNPKG

gtfs

Version:

Import GTFS transit data into SQLite and query routes, stops, times, fares and more

1,262 lines 48 kB
import { Options } from "csv-parse"; import Database$1, { Database } from "better-sqlite3"; //#region src/lib/errors.d.ts declare enum GtfsErrorCategory { CONFIG = "config", DOWNLOAD = "download", ZIP = "zip", VALIDATION = "validation", DATABASE = "database", PARSE = "parse", QUERY = "query", INTERNAL = "internal" } /** * Error codes are a public API contract and must remain stable across * minor/patch releases. */ declare enum GtfsErrorCode { GTFS_DOWNLOAD_HTTP = "GTFS_DOWNLOAD_HTTP", GTFS_DOWNLOAD_FAILED = "GTFS_DOWNLOAD_FAILED", GTFS_ZIP_INVALID = "GTFS_ZIP_INVALID", GTFS_REQUIRED_FIELD_MISSING = "GTFS_REQUIRED_FIELD_MISSING", GTFS_INVALID_DATE = "GTFS_INVALID_DATE", GTFS_CONFIG_INVALID = "GTFS_CONFIG_INVALID", DB_OPEN_FAILED = "DB_OPEN_FAILED", GTFS_DB_OPERATION_FAILED = "GTFS_DB_OPERATION_FAILED", GTFS_JSON_INVALID = "GTFS_JSON_INVALID", GTFS_UNSUPPORTED_FILE_TYPE = "GTFS_UNSUPPORTED_FILE_TYPE", GTFS_CSV_PARSE_FAILED = "GTFS_CSV_PARSE_FAILED", GTFS_QUERY_INVALID = "GTFS_QUERY_INVALID" } declare enum GtfsWarningCode { GTFS_DUPLICATE_PRIMARY_KEY = "GTFS_DUPLICATE_PRIMARY_KEY" } interface GtfsWarning { code: GtfsWarningCode; message: string; details?: Record<string, unknown>; } interface ImportReport { errors: GtfsError[]; warnings: GtfsWarning[]; errorCountsByCode: Partial<Record<GtfsErrorCode, number>>; warningCountsByCode: Partial<Record<GtfsWarningCode, number>>; } interface GtfsErrorOptions { code: GtfsErrorCode; category: GtfsErrorCategory; isOperational?: boolean; statusCode?: number; details?: Record<string, unknown>; cause?: unknown; } declare class GtfsError extends Error { code: GtfsErrorCode; category: GtfsErrorCategory; isOperational: boolean; statusCode?: number; details?: Record<string, unknown>; constructor(message: string, options: GtfsErrorOptions); } declare function isGtfsError(error: unknown): error is GtfsError; declare function isGtfsValidationError(error: unknown): error is GtfsError; declare function formatGtfsError(error: unknown, options?: { verbosity: 'user' | 'developer'; }): string; //#endregion //#region src/types/global_interfaces.d.ts type UnixTimestamp = number; type TableNames = 'agency' | 'stops' | 'routes' | 'trips' | 'stop_times' | 'calendar' | 'calendar_dates' | 'fare_attributes' | 'fare_rules' | 'timeframes' | 'rider_categories' | 'fare_media' | 'fare_products' | 'fare_leg_rules' | 'fare_leg_join_rules' | 'fare_transfer_rules' | 'areas' | 'stop_areas' | 'networks' | 'route_networks' | 'shapes' | 'frequencies' | 'transfers' | 'pathways' | 'levels' | 'location_groups' | 'location_group_stops' | 'locations' | 'booking_rules' | 'translations' | 'feed_info' | 'attributions'; interface BaseConfigAgency { /** * An array of GTFS file names (without .txt) to exclude when importing */ exclude?: TableNames[]; /** * An object of HTTP headers in key:value format to use when fetching GTFS from the url specified */ headers?: Record<string, string>; /** * Settings for fetching GTFS-Realtime alerts */ realtimeAlerts?: { /** * URL for fetching GTFS-Realtime alerts */ url: string; /** * Headers to use when fetching GTFS-Realtime alerts */ headers?: Record<string, string>; }; /** * Settings for fetching GTFS-Realtime trip updates */ realtimeTripUpdates?: { /** * URL for fetching GTFS-Realtime trip updates */ url: string; /** * Headers to use when fetching GTFS-Realtime trip updates */ headers?: Record<string, string>; }; /** * Settings for fetching GTFS-Realtime vehicle positions */ realtimeVehiclePositions?: { /** * URL for fetching GTFS-Realtime vehicle positions */ url: string; /** * Headers to use when fetching GTFS-Realtime vehicle positions */ headers?: Record<string, string>; }; /** * A prefix to be added to every ID field maintain uniqueness when importing multiple GTFS from multiple agencies */ prefix?: string; /** * When set to true and the feed contains exactly one agency, populates any empty `agency_id` fields * on routes, fare_attributes, and other relevant files. Useful when merging single-agency feeds into * a shared database. * * @defaultValue false */ fillEmptyAgencyId?: boolean; /** * Explicit `agency_id` to use when `fillEmptyAgencyId` is true and `agency.txt` does not define * one. Also backfills the `agency_id` on the agency row itself. If `agency.txt` already defines * an `agency_id` and it differs from this value, the value from `agency.txt` takes precedence. */ agencyId?: string; } type ConfigAgency = BaseConfigAgency & ({ /** * The URL to a zipped GTFS file. Required if path not present */ url: string; } | { /** * A path to a zipped GTFS file or a directory of unzipped .txt files. Required if url is not present */ path: string; }); interface Config { /** * An existing database instance to use instead of relying on node-gtfs to connect. */ db?: Database; /** * A path to an SQLite database. Defaults to using an in-memory database. */ sqlitePath?: string; /** * Amount of time in seconds to allow GTFS-Realtime data to be stored in database before allowing to be deleted. * * Note: is an integer * * @defaultValue 0 */ gtfsRealtimeExpirationSeconds?: number; /** * The number of milliseconds to wait before throwing an error when downloading GTFS. * * Note: is an integer */ downloadTimeout?: number; /** * Options passed to `csv-parse` for parsing GTFS CSV files. */ csvOptions?: Options; /** * A path to a directory to put exported GTFS files. * * @defaultValue `gtfs-export/<agency_name>` */ exportPath?: string; /** * Whether or not to ignore unique constraints on ids when importing GTFS, such as `trip_id`, `calendar_id`. * * @defaultValue false */ ignoreDuplicates?: boolean; /** * Whether or not to ignore errors during the import process. If true, failed files will be skipped while the rest are processed. * * @defaultValue false */ ignoreErrors?: boolean; /** * Whether or not to return a structured import report from `importGtfs`. * Useful when `ignoreErrors` is enabled and you want to inspect collected errors/warnings. * * @defaultValue false */ includeImportReport?: boolean; /** * An array of GTFS files to be imported, and which files to exclude. */ agencies: ConfigAgency[]; /** * Whether or not to print output to the console. * * @defaulValue true */ verbose?: boolean; /** * An optional custom logger instead of the build in console.log * * @param message * @returns */ logFunction?: (message: string) => void; } interface ModelColumn { name: string; type: 'text' | 'integer' | 'real' | 'json' | 'date' | 'time'; min?: number; max?: number; required?: boolean; primary?: boolean; index?: boolean; default?: string | number | null; nocase?: boolean; source?: string; prefix?: boolean; } interface Model { filenameBase: TableNames; filenameExtension?: string; extension?: string; nonstandard?: boolean; schema: ModelColumn[]; } interface JoinOptions { type?: string; table: string; on: string; } type SqlValue = undefined | null | string | number | boolean | Date | SqlValue[]; type SqlWhere = Record<string, null | SqlValue | SqlValue[]>; type QueryResult<Base extends object, Select extends keyof Base> = [Select] extends [never] ? Base : Pick<Base, Select>; type SqlOrderBy = Array<[string, 'ASC' | 'DESC']>; interface QueryOptions { db?: Database; bounding_box_side_m?: number; } interface Agency { agency_id: string | null; agency_name: string; agency_url: string; agency_timezone: string; agency_lang: string | null; agency_phone: string | null; agency_fare_url: string | null; agency_email: string | null; cemv_support: 0 | 1 | 2 | null; } interface Area { area_id: string; area_name: string | null; } interface Attribution { attribution_id: string | null; agency_id: string | null; route_id: string | null; trip_id: string | null; organization_name: string; is_producer: 0 | 1 | null; is_operator: 0 | 1 | null; is_authority: 0 | 1 | null; attribution_url: string | null; attribution_email: string | null; attribution_phone: string | null; } interface BookingRule { booking_rule_id: string; booking_type: 0 | 1 | 2; prior_notice_duration_min: number | null; prior_notice_duration_max: number | null; prior_notice_last_day: number | null; prior_notice_last_time: string | null; prior_notice_last_timestamp: UnixTimestamp | null; prior_notice_start_day: number | null; prior_notice_start_time: string | null; prior_notice_start_timestamp: UnixTimestamp | null; prior_notice_service_id: string | null; message: string | null; pickup_message: string | null; drop_off_message: string | null; phone_number: string | null; info_url: string | null; booking_url: string | null; } interface Calendar { service_id: string; monday: 0 | 1; tuesday: 0 | 1; wednesday: 0 | 1; thursday: 0 | 1; friday: 0 | 1; saturday: 0 | 1; sunday: 0 | 1; start_date: number; end_date: number; } interface CalendarDate { service_id: string; date: number; exception_type: 1 | 2; holiday_name: string | null; } interface FareAttribute { fare_id: string; price: number; currency_type: string; payment_method: 0 | 1; transfers: 0 | 1 | 2; agency_id: string | null; transfer_duration: number | null; } interface FareLegRule { leg_group_id: string | null; network_id: string | null; from_area_id: string | null; to_area_id: string | null; from_timeframe_group_id: string | null; to_timeframe_group_id: string | null; fare_product_id: string; rule_priority: number | null; } interface FareMedia { fare_media_id: string; fare_media_name: string | null; fare_media_type: 0 | 1 | 2 | 3 | 4; } interface FareProduct { fare_product_id: string; fare_product_name: string | null; fare_media_id: string | null; amount: number; currency: string; } interface FareRule { fare_id: string; route_id: string | null; origin_id: string | null; destination_id: string | null; contains_id: string | null; } interface FareTransferRule { from_leg_group_id: string | null; to_leg_group_id: string | null; transfer_count: number | null; duration_limit: number; duration_limit_type: 0 | 1 | 2 | 3 | null; fare_transfer_type: 0 | 1 | 2; fare_product_id: string | null; } interface FeedInfo { feed_publisher_name: string; feed_publisher_url: string; feed_lang: string; default_lang: string | null; feed_start_date: number | null; feed_end_date: number | null; feed_version: string | null; feed_contact_email: string | null; feed_contact_url: string | null; } interface Frequency { trip_id: string; start_time: string; start_timestamp: UnixTimestamp; end_time: string; end_timestamp: UnixTimestamp; headway_secs: number; exact_times: 0 | 1 | null; } interface Level { level_id: string; level_index: number; level_name: string | null; } interface LocationGroupStop { location_group_id: string; stop_id: string; } interface LocationGroup { location_group_id: string; location_group_name: string | null; } interface Location { geojson: string; } interface Network { network_id: string; network_name: string | null; } interface Pathway { pathway_id: string; from_stop_id: string; to_stop_id: string; pathway_mode: 1 | 2 | 3 | 4 | 5 | 6 | 7; is_bidirectional: 0 | 1; length: number | null; traversal_time: number | null; stair_count: number | null; max_slope: number | null; min_width: number | null; signposted_as: string | null; reversed_signposted_as: string | null; } interface RouteNetwork { network_id: string; route_id: string; } interface Route { route_id: string; agency_id: string | null; route_short_name: string | null; route_long_name: string | null; route_desc: string | null; route_type: number; route_url: string | null; route_color: string | null; route_text_color: string | null; route_sort_order: number | null; continuous_pickup: 0 | 1 | 2 | 3 | null; continuous_drop_off: 0 | 1 | 2 | 3 | null; network_id: string | null; cemv_support: 0 | 1 | 2 | null; } interface Shape { shape_id: string; shape_pt_lat: number; shape_pt_lon: number; shape_pt_sequence: number; shape_dist_traveled: number | null; } interface StopArea { area_id: string; stop_id: string; } interface StopTime { trip_id: string; arrival_time: string | null; arrival_timestamp: UnixTimestamp | null; departure_time: string | null; departure_timestamp: UnixTimestamp | null; location_group_id: string | null; location_id: string | null; stop_id: string | null; stop_sequence: number; stop_headsign: string | null; start_pickup_drop_off_window: string | null; start_pickup_drop_off_window_timestamp: UnixTimestamp | null; pickup_type: 0 | 1 | 2 | 3 | null; drop_off_type: 0 | 1 | 2 | 3 | null; continuous_pickup: 0 | 1 | 2 | 3 | null; continuous_drop_off: 0 | 1 | 2 | 3 | null; shape_dist_traveled: number | null; timepoint: 0 | 1 | null; pickup_booking_rule_id: string | null; drop_off_booking_rule_id: string | null; } interface Stop { stop_id: string; stop_code: string | null; stop_name: string | null; tts_stop_name: string | null; stop_desc: string | null; stop_lat: number | null; stop_lon: number | null; zone_id: string | null; stop_url: string | null; location_type: 0 | 1 | 2 | 3 | 4 | null; parent_station: string | null; stop_timezone: string | null; wheelchair_boarding: 0 | 1 | 2 | null; level_id: string | null; platform_code: string | null; stop_access: 0 | 1 | null; } interface Timeframe { timeframe_group_id: string; start_time: string | null; end_time: string | null; service_id: string; } interface Transfer { from_stop_id: string | null; to_stop_id: string | null; from_route_id: string | null; to_route_id: string | null; from_trip_id: string | null; to_trip_id: string | null; transfer_type: 0 | 1 | 2 | 3 | 4 | 5; min_transfer_time: number | null; } interface Translation { table_name: string; field_name: string; language: string; translation: string; record_id: string | null; record_sub_id: string | null; field_value: string | null; } interface Trip { route_id: string; service_id: string; trip_id: string; trip_headsign: string | null; trip_short_name: string | null; direction_id: 0 | 1 | null; block_id: string | null; shape_id: string | null; wheelchair_accessible: 0 | 1 | 2 | null; bikes_allowed: 0 | 1 | 2 | null; cars_allowed: 0 | 1 | 2 | null; } interface Timetable { timetable_id: string; route_id: string; direction_id: 0 | 1 | null; start_date: number | null; end_date: number | null; monday: 0 | 1; tuesday: 0 | 1; wednesday: 0 | 1; thursday: 0 | 1; friday: 0 | 1; saturday: 0 | 1; sunday: 0 | 1; start_time: string | null; start_timestamp: UnixTimestamp | null; end_time: string | null; end_timestamp: UnixTimestamp | null; timetable_label: string | null; service_notes: string | null; orientation: string | null; timetable_page_id: string | null; timetable_sequence: number | null; direction_name: string | null; include_exceptions: 0 | 1 | null; show_trip_continuation: 0 | 1 | null; } interface TimetablePage { timetable_page_id: string; timetable_page_label: string | null; filename: string | null; } interface TimetableStopOrder { timetable_id: string; stop_id: string; stop_sequence: number; } interface TimetableNote { note_id: string; symbol: string | null; note: string; } interface TimetableNotesReference { note_id: string; timetable_id: string; route_id: string | null; trip_id: string | null; stop_id: string | null; stop_sequence: number | null; show_on_stoptime: 0 | 1 | null; } interface TripsDatedVehicleJourney { trip_id: string; operating_day_date: string; dated_vehicle_journey_gid: string; journey_number: number; } interface DeadheadTime { deadhead_id: string; arrival_time: string; arrival_timestamp: UnixTimestamp; departure_time: string; departure_timestamp: UnixTimestamp; ops_location_id: string | null; stop_id: string | null; location_sequence: number; shape_dist_traveled: number | null; } interface Deadhead { deadhead_id: string; service_id: string; block_id: string; shape_id: string | null; to_trip_id: string | null; from_trip_id: string | null; to_deadhead_id: string | null; from_deadhead_id: string | null; } interface OpsLocation { ops_location_id: string; ops_location_code: string | null; ops_location_name: string; ops_location_desc: string | null; ops_location_lat: number; ops_location_lon: number; } interface RunEvent { run_event_id: string; piece_id: string; event_type: number; event_name: string | null; event_time: string; event_duration: number; event_from_location_type: 0 | 1; event_from_location_id: string | null; event_to_location_type: 0 | 1; event_to_location_id: string | null; } interface RunPiece { run_id: string; piece_id: string; start_type: 0 | 1 | 2; start_trip_id: string; start_trip_position: number | null; end_type: 0 | 1 | 2; end_trip_id: string; end_trip_position: number | null; } interface ServiceAlertInformedEntity { alert_id: string; agency_id: string | null; stop_id: string | null; route_id: string | null; route_type: number | null; trip_id: string | null; direction_id: number | null; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; } interface ServiceAlert { id: string; active_period: string | null; cause: string | null; effect: string | null; url: string | null; start_time: string | null; end_time: string | null; header_text: string; description_text: string; tts_header_text: string | null; tts_description_text: string | null; severity_level: string | null; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; informed_entities: ServiceAlertInformedEntity[]; } interface StopTimeUpdate { trip_id: string | null; trip_start_time: string | null; direction_id: 0 | 1 | null; route_id: string | null; stop_id: string | null; stop_sequence: number | null; arrival_delay: number | null; departure_delay: number | null; departure_timestamp: UnixTimestamp | null; arrival_timestamp: UnixTimestamp | null; schedule_relationship: string | null; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; } interface TripUpdate { id: string; vehicle_id: string | null; trip_id: string | null; trip_start_time: string | null; direction_id: 0 | 1 | null; route_id: string | null; start_date: number | null; timestamp: UnixTimestamp | null; schedule_relationship: string | null; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; } interface VehiclePosition { id: string; bearing: number | null; latitude: number | null; longitude: number | null; speed: number | null; current_stop_sequence: number | null; trip_id: string | null; trip_start_date: number | null; trip_start_time: string | null; congestion_level: string | null; occupancy_status: string | null; occupancy_percentage: number | null; vehicle_stop_status: string | null; vehicle_id: string | null; vehicle_label: string | null; vehicle_license_plate: string | null; vehicle_wheelchair_accessible: number | null; timestamp: UnixTimestamp | null; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; } interface BoardAlight { trip_id: string; stop_id: string; stop_sequence: number; record_use: 0 | 1; schedule_relationship: number | null; boardings: number | null; alightings: number | null; current_load: number | null; load_count: number | null; load_type: number | null; rack_down: number | null; bike_boardings: number | null; bike_alightings: number | null; ramp_used: number | null; ramp_boardings: number | null; ramp_alightings: number | null; service_date: number | null; service_arrival_time: string | null; service_arrival_timestamp: UnixTimestamp | null; service_departure_time: string | null; service_departure_timestamp: UnixTimestamp | null; source: 0 | 1 | 2 | 3 | 4 | null; } interface RideFeedInfo { ride_files: number; ride_start_date: number | null; ride_end_date: number | null; gtfs_feed_date: number | null; default_currency_type: string | null; ride_feed_version: string | null; } interface RiderCategory { rider_category_id: string; rider_category_name: string; is_default_fare_category: 0 | 1 | null; eligibility_url: string | null; } interface RiderTrip { rider_id: string; agency_id: string | null; trip_id: string | null; boarding_stop_id: string | null; boarding_stop_sequence: number | null; alighting_stop_id: string | null; alighting_stop_sequence: number | null; service_date: number | null; boarding_time: string | null; boarding_timestamp: UnixTimestamp | null; alighting_time: string | null; alighting_timestamp: UnixTimestamp | null; rider_type: number | null; rider_type_description: string | null; fare_paid: number | null; transaction_type: number | null; fare_media: number | null; accompanying_device: number | null; transfer_status: number | null; } interface Ridership { total_boardings: number; total_alightings: number; ridership_start_date: number | null; ridership_end_date: number | null; ridership_start_time: string | null; ridership_start_timestamp: UnixTimestamp | null; ridership_end_time: string | null; ridership_end_timestamp: UnixTimestamp | null; service_id: string | null; monday: 0 | 1 | null; tuesday: 0 | 1 | null; wednesday: 0 | 1 | null; thursday: 0 | 1 | null; friday: 0 | 1 | null; saturday: 0 | 1 | null; sunday: 0 | 1 | null; agency_id: string | null; route_id: string | null; direction_id: 0 | 1 | null; trip_id: string | null; stop_id: string | null; } interface TripCapacity { agency_id: string | null; trip_id: string | null; service_date: number | null; vehicle_description: string | null; seated_capacity: number | null; standing_capacity: number | null; wheelchair_capacity: number | null; bike_capacity: number | null; } interface CalendarAttribute { service_id: string; service_description: string; } interface Direction { route_id: string; direction_id: 0 | 1 | null; direction: string; } interface RouteAttribute { route_id: string; category: number; subcategory: number; running_way: number; } interface StopAttribute { stop_id: string; accessibility_id: number | null; cardinal_direction: string | null; relative_position: string | null; stop_city: string | null; } //#endregion //#region src/lib/import-gtfs.d.ts /** * Function to import GTFS files into the database * * @param initialConfig */ declare function importGtfs(initialConfig: Config): Promise<ImportReport>; declare function importGtfs(initialConfig: Config): Promise<void>; //#endregion //#region src/lib/import-gtfs-realtime.d.ts /** * Main function to update GTFS Realtime data */ declare function updateGtfsRealtime(initialConfig: Config): Promise<void>; //#endregion //#region src/lib/export.d.ts declare const exportGtfs: (initialConfig: Config) => Promise<void>; //#endregion //#region src/lib/db.d.ts declare function openDb(config?: { db?: Database$1.Database; sqlitePath?: string; } | null): Database$1.Database; declare function closeDb(db?: Database$1.Database | null): void; declare function deleteDb(db?: Database$1.Database | null): void; //#endregion //#region src/lib/advancedQuery.d.ts declare function advancedQuery(table: string, advancedQueryOptions: { db?: Database$1.Database; query?: SqlWhere; fields?: string[]; orderBy?: SqlOrderBy; join?: JoinOptions[]; options?: QueryOptions; }): Array<Record<string, SqlValue>>; //#endregion //#region src/lib/file-utils.d.ts /** * Prepares a directory for saving files by clearing its contents * @param {string} exportPath - Path to the directory to prepare * @returns {Promise<void>} * @example * await prepDirectory('./output'); */ declare function prepDirectory(exportPath: string): Promise<void>; /** * Extracts contents of a zip file to specified directory * @param {string} zipfilePath - Path to the zip file * @param {string} exportPath - Directory to extract contents to * @returns {Promise<void>} * @throws {Error} If zip file cannot be opened or extracted * @example * await unzip('./data.zip', './extracted'); */ declare function unzip(zipfilePath: string, exportPath: string): Promise<void>; /** * Generates a safe folder name from input string * Converts to snake_case and removes unsafe characters * @param {string} folderName - Input string to convert to folder name * @returns {string} Sanitized folder name * @example * generateFolderName('My Folder!') // returns 'my_folder' */ declare function generateFolderName(folderName: string): string; /** * Converts a tilde path to a full path * @param pathWithTilde The path to convert * @returns The full path */ declare function untildify(pathWithTilde: string): string; //#endregion //#region src/lib/gtfs/agencies.d.ts declare function getAgencies<Fields extends keyof Agency>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Agency, Fields>[]; //#endregion //#region src/lib/gtfs/areas.d.ts declare function getAreas<Fields extends keyof Area>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Area, Fields>[]; //#endregion //#region src/lib/gtfs/attributions.d.ts declare function getAttributions<Fields extends keyof Attribution>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Attribution, Fields>[]; //#endregion //#region src/lib/gtfs/booking-rules.d.ts declare function getBookingRules<Fields extends keyof BookingRule>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<BookingRule, Fields>[]; //#endregion //#region src/lib/gtfs/calendar-dates.d.ts declare function getCalendarDates<Fields extends keyof CalendarDate>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<CalendarDate, Fields>[]; //#endregion //#region src/lib/gtfs/calendars.d.ts declare function getCalendars<Fields extends keyof Calendar>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Calendar, Fields>[]; declare function getServiceIdsByDate(date: number, options?: QueryOptions): string[]; //#endregion //#region src/lib/gtfs/fare-attributes.d.ts declare function getFareAttributes<Fields extends keyof FareAttribute>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareAttribute, Fields>[]; //#endregion //#region src/lib/gtfs/fare-leg-rules.d.ts declare function getFareLegRules<Fields extends keyof FareLegRule>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareLegRule, Fields>[]; //#endregion //#region src/lib/gtfs/fare-media.d.ts declare function getFareMedia<Fields extends keyof FareMedia>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareMedia, Fields>[]; //#endregion //#region src/lib/gtfs/fare-products.d.ts declare function getFareProducts<Fields extends keyof FareProduct>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareProduct, Fields>[]; //#endregion //#region src/lib/gtfs/fare-rules.d.ts declare function getFareRules<Fields extends keyof FareRule>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareRule, Fields>[]; //#endregion //#region src/lib/gtfs/fare-transfer-rules.d.ts declare function getFareTransferRules<Fields extends keyof FareTransferRule>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FareTransferRule, Fields>[]; //#endregion //#region src/lib/gtfs/feed-info.d.ts declare function getFeedInfo<Fields extends keyof FeedInfo>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<FeedInfo, Fields>[]; //#endregion //#region src/lib/gtfs/frequencies.d.ts declare function getFrequencies<Fields extends keyof Frequency>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Frequency, Fields>[]; //#endregion //#region src/lib/gtfs/levels.d.ts declare function getLevels<Fields extends keyof Level>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Level, Fields>[]; //#endregion //#region src/lib/gtfs/location-groups.d.ts declare function getLocationGroups<Fields extends keyof LocationGroup>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<LocationGroup, Fields>[]; //#endregion //#region src/lib/gtfs/location-group-stops.d.ts declare function getLocationGroupStops<Fields extends keyof LocationGroupStop>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<LocationGroupStop, Fields>[]; //#endregion //#region src/lib/gtfs/locations.d.ts declare function getLocations<Fields extends keyof Location>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Location, Fields>[]; //#endregion //#region src/lib/gtfs/networks.d.ts declare function getNetworks<Fields extends keyof Network>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Network, Fields>[]; //#endregion //#region src/lib/gtfs/pathways.d.ts declare function getPathways<Fields extends keyof Pathway>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Pathway, Fields>[]; //#endregion //#region src/lib/gtfs/rider-categories.d.ts declare function getRiderCategories<Fields extends keyof RiderCategory>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RiderCategory, Fields>[]; //#endregion //#region src/lib/gtfs/route-networks.d.ts declare function getRouteNetworks<Fields extends keyof RouteNetwork>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RouteNetwork, Fields>[]; //#endregion //#region src/lib/gtfs/routes.d.ts declare function getRoutes<Fields extends keyof Route>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Route, Fields>[]; //#endregion //#region node_modules/.pnpm/@types+geojson@7946.0.16/node_modules/@types/geojson/index.d.ts /** * The value values for the "type" property of GeoJSON Objects. * https://tools.ietf.org/html/rfc7946#section-1.4 */ type GeoJsonTypes = GeoJSON["type"]; /** * Bounding box * https://tools.ietf.org/html/rfc7946#section-5 */ type BBox = [number, number, number, number] | [number, number, number, number, number, number]; /** * A Position is an array of coordinates. * https://tools.ietf.org/html/rfc7946#section-3.1.1 * Array should contain between two and three elements. * The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values), * but the current specification only allows X, Y, and (optionally) Z to be defined. * * Note: the type will not be narrowed down to `[number, number] | [number, number, number]` due to * marginal benefits and the large impact of breaking change. * * See previous discussions on the type narrowing: * - {@link https://github.com/DefinitelyTyped/DefinitelyTyped/pull/21590|Nov 2017} * - {@link https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/67773|Dec 2023} * - {@link https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/71441| Dec 2024} * * One can use a * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|user-defined type guard that returns a type predicate} * to determine if a position is a 2D or 3D position. * * @example * import type { Position } from 'geojson'; * * type StrictPosition = [x: number, y: number] | [x: number, y: number, z: number] * * function isStrictPosition(position: Position): position is StrictPosition { * return position.length === 2 || position.length === 3 * }; * * let position: Position = [-116.91, 45.54]; * * let x: number; * let y: number; * let z: number | undefined; * * if (isStrictPosition(position)) { * // `tsc` would throw an error if we tried to destructure a fourth parameter * [x, y, z] = position; * } else { * throw new TypeError("Position is not a 2D or 3D point"); * } */ type Position = number[]; /** * The base GeoJSON object. * https://tools.ietf.org/html/rfc7946#section-3 * The GeoJSON specification also allows foreign members * (https://tools.ietf.org/html/rfc7946#section-6.1) * Developers should use "&" type in TypeScript or extend the interface * to add these foreign members. */ interface GeoJsonObject { // Don't include foreign members directly into this type def. // in order to preserve type safety. // [key: string]: any; /** * Specifies the type of GeoJSON object. */ type: GeoJsonTypes; /** * Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. * The value of the bbox member is an array of length 2*n where n is the number of dimensions * represented in the contained geometries, with all axes of the most southwesterly point * followed by all axes of the more northeasterly point. * The axes order of a bbox follows the axes order of geometries. * https://tools.ietf.org/html/rfc7946#section-5 */ bbox?: BBox | undefined; } /** * Union of GeoJSON objects. */ type GeoJSON<G extends Geometry | null = Geometry, P = GeoJsonProperties> = G | Feature<G, P> | FeatureCollection<G, P>; /** * Geometry object. * https://tools.ietf.org/html/rfc7946#section-3 */ type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon | GeometryCollection; /** * Point geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.2 */ interface Point extends GeoJsonObject { type: "Point"; coordinates: Position; } /** * MultiPoint geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.3 */ interface MultiPoint extends GeoJsonObject { type: "MultiPoint"; coordinates: Position[]; } /** * LineString geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.4 */ interface LineString extends GeoJsonObject { type: "LineString"; coordinates: Position[]; } /** * MultiLineString geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.5 */ interface MultiLineString extends GeoJsonObject { type: "MultiLineString"; coordinates: Position[][]; } /** * Polygon geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.6 */ interface Polygon extends GeoJsonObject { type: "Polygon"; coordinates: Position[][]; } /** * MultiPolygon geometry object. * https://tools.ietf.org/html/rfc7946#section-3.1.7 */ interface MultiPolygon extends GeoJsonObject { type: "MultiPolygon"; coordinates: Position[][][]; } /** * Geometry Collection * https://tools.ietf.org/html/rfc7946#section-3.1.8 */ interface GeometryCollection<G extends Geometry = Geometry> extends GeoJsonObject { type: "GeometryCollection"; geometries: G[]; } type GeoJsonProperties = { [name: string]: any; } | null; /** * A feature object which contains a geometry and associated properties. * https://tools.ietf.org/html/rfc7946#section-3.2 */ interface Feature<G extends Geometry | null = Geometry, P = GeoJsonProperties> extends GeoJsonObject { type: "Feature"; /** * The feature's geometry */ geometry: G; /** * A value that uniquely identifies this feature in a * https://tools.ietf.org/html/rfc7946#section-3.2. */ id?: string | number | undefined; /** * Properties associated with this feature. */ properties: P; } /** * A collection of feature objects. * https://tools.ietf.org/html/rfc7946#section-3.3 */ interface FeatureCollection<G extends Geometry | null = Geometry, P = GeoJsonProperties> extends GeoJsonObject { type: "FeatureCollection"; features: Array<Feature<G, P>>; } //#endregion //#region src/lib/gtfs/shapes.d.ts declare function getShapes<Fields extends keyof Shape>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Shape, Fields>[]; declare function getShapesAsGeoJSON(query?: SqlWhere, options?: QueryOptions): FeatureCollection; //#endregion //#region src/lib/gtfs/stop-areas.d.ts declare function getStopAreas<Fields extends keyof StopArea>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<StopArea, Fields>[]; //#endregion //#region src/lib/gtfs/stops.d.ts declare function getStops<Fields extends keyof Stop>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Stop, Fields>[]; declare function getStopsAsGeoJSON(query?: SqlWhere, options?: QueryOptions): FeatureCollection; //#endregion //#region src/lib/gtfs/stop-times.d.ts declare function getStoptimes<Fields extends keyof StopTime>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<StopTime, Fields>[]; //#endregion //#region src/lib/gtfs/timeframes.d.ts declare function getTimeframes<Fields extends keyof Timeframe>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Timeframe, Fields>[]; //#endregion //#region src/lib/gtfs/transfers.d.ts declare function getTransfers<Fields extends keyof Transfer>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Transfer, Fields>[]; //#endregion //#region src/lib/gtfs/translations.d.ts declare function getTranslations<Fields extends keyof Translation>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Translation, Fields>[]; //#endregion //#region src/lib/gtfs/trips.d.ts declare function getTrips<Fields extends keyof Trip>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Trip, Fields>[]; //#endregion //#region src/lib/gtfs-plus/calendar-attributes.d.ts declare function getCalendarAttributes<Fields extends keyof CalendarAttribute>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<CalendarAttribute, Fields>[]; //#endregion //#region src/lib/gtfs-plus/directions.d.ts declare function getDirections<Fields extends keyof Direction>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Direction, Fields>[]; //#endregion //#region src/lib/gtfs-plus/route-attributes.d.ts declare function getRouteAttributes<Fields extends keyof RouteAttribute>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RouteAttribute, Fields>[]; //#endregion //#region src/lib/gtfs-plus/stop-attributes.d.ts declare function getStopAttributes<Fields extends keyof StopAttribute>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<StopAttribute, Fields>[]; //#endregion //#region src/lib/non-standard/timetables.d.ts declare function getTimetables<Fields extends keyof Timetable>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Timetable, Fields>[]; //#endregion //#region src/lib/non-standard/timetable-stop-order.d.ts declare function getTimetableStopOrders<Fields extends keyof TimetableStopOrder>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TimetableStopOrder, Fields>[]; //#endregion //#region src/lib/non-standard/timetable-pages.d.ts declare function getTimetablePages<Fields extends keyof TimetablePage>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TimetablePage, Fields>[]; //#endregion //#region src/lib/non-standard/timetable-notes.d.ts declare function getTimetableNotes<Fields extends keyof TimetableNote>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TimetableNote, Fields>[]; //#endregion //#region src/lib/non-standard/timetable-notes-references.d.ts declare function getTimetableNotesReferences<Fields extends keyof TimetableNotesReference>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TimetableNotesReference, Fields>[]; //#endregion //#region src/lib/non-standard/trips-dated-vehicle-journey.d.ts declare function getTripsDatedVehicleJourneys<Fields extends keyof TripsDatedVehicleJourney>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TripsDatedVehicleJourney, Fields>[]; //#endregion //#region src/lib/gtfs-ride/board-alights.d.ts declare function getBoardAlights<Fields extends keyof BoardAlight>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<BoardAlight, Fields>[]; //#endregion //#region src/lib/gtfs-ride/ride-feed-info.d.ts declare function getRideFeedInfo<Fields extends keyof RideFeedInfo>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RideFeedInfo, Fields>[]; //#endregion //#region src/lib/gtfs-ride/rider-trips.d.ts declare function getRiderTrips<Fields extends keyof RiderTrip>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RiderTrip, Fields>[]; //#endregion //#region src/lib/gtfs-ride/ridership.d.ts declare function getRidership<Fields extends keyof Ridership>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Ridership, Fields>[]; //#endregion //#region src/lib/gtfs-ride/trip-capacities.d.ts declare function getTripCapacities<Fields extends keyof TripCapacity>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TripCapacity, Fields>[]; //#endregion //#region src/lib/gtfs-realtime/stop-time-updates.d.ts declare function getStopTimeUpdates<Fields extends keyof StopTimeUpdate>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<StopTimeUpdate, Fields>[]; //#endregion //#region src/lib/gtfs-realtime/trip-updates.d.ts declare function getTripUpdates<Fields extends keyof TripUpdate>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<TripUpdate, Fields>[]; //#endregion //#region src/lib/gtfs-realtime/vehicle-positions.d.ts declare function getVehiclePositions<Fields extends keyof VehiclePosition>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<VehiclePosition, Fields>[]; //#endregion //#region src/lib/gtfs-realtime/service-alerts.d.ts declare function getServiceAlerts<Fields extends keyof ServiceAlert>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): { informed_entities: ServiceAlertInformedEntity[]; start_time: string | null; end_time: string | null; id: string; created_timestamp: UnixTimestamp; expiration_timestamp: UnixTimestamp; active_period: string | null; cause: string | null; effect: string | null; url: string | null; header_text: string; description_text: string; tts_header_text: string | null; tts_description_text: string | null; severity_level: string | null; }[]; //#endregion //#region src/lib/gtfs-realtime/service-alert-informed-entities.d.ts declare function getServiceAlertInformedEntities<Fields extends keyof ServiceAlertInformedEntity>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<ServiceAlertInformedEntity, Fields>[]; //#endregion //#region src/lib/ods/deadheads.d.ts declare function getDeadheads<Fields extends keyof Deadhead>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<Deadhead, Fields>[]; //#endregion //#region src/lib/ods/deadhead-times.d.ts declare function getDeadheadTimes<Fields extends keyof DeadheadTime>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<DeadheadTime, Fields>[]; //#endregion //#region src/lib/ods/ops-locations.d.ts declare function getOpsLocations<Fields extends keyof OpsLocation>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<OpsLocation, Fields>[]; //#endregion //#region src/lib/ods/run-events.d.ts declare function getRunEvents<Fields extends keyof RunEvent>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RunEvent, Fields>[]; //#endregion //#region src/lib/ods/runs-pieces.d.ts declare function getRunsPieces<Fields extends keyof RunPiece>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RunPiece, Fields>[]; //#endregion export { Agency, Area, Attribution, BoardAlight, BookingRule, Calendar, CalendarAttribute, CalendarDate, Config, ConfigAgency, Deadhead, DeadheadTime, Direction, FareAttribute, FareLegRule, FareMedia, FareProduct, FareRule, FareTransferRule, FeedInfo, Frequency, GtfsError, GtfsErrorCategory, GtfsErrorCode, type GtfsWarning, GtfsWarningCode, type ImportReport, JoinOptions, Level, Location, LocationGroup, LocationGroupStop, Model, ModelColumn, Network, OpsLocation, Pathway, QueryOptions, QueryResult, RideFeedInfo, RiderCategory, RiderTrip, Ridership, Route, RouteAttribute, RouteNetwork, RunEvent, RunPiece, ServiceAlert, ServiceAlertInformedEntity, Shape, SqlOrderBy, SqlValue, SqlWhere, Stop, StopArea, StopAttribute, StopTime, StopTimeUpdate, TableNames, Timeframe, Timetable, TimetableNote, TimetableNotesReference, TimetablePage, TimetableStopOrder, Transfer, Translation, Trip, TripCapacity, TripUpdate, TripsDatedVehicleJourney, UnixTimestamp, VehiclePosition, advancedQuery, closeDb, deleteDb, exportGtfs, formatGtfsError, generateFolderName, getAgencies, getAreas, getAttributions, getBoardAlights, getBookingRules, getCalendarAttributes, getCalendarDates, getCalendars, getDeadheadTimes, getDeadheads, getDirections, getFareAttributes, getFareLegRules, getFareMedia, getFareProducts, getFareRules, getFareTransferRules, getFeedInfo, getFrequencies, getLevels, getLocationGroupStops, getLocationGroups, getLocations, getNetworks, getOpsLocations, getPathways, getRideFeedInfo, getRiderCategories, getRiderTrips, getRidership, getRouteAttributes, getRouteNetworks, getRoutes, getRunEvents, getRunsPieces, getServiceAlertInformedEntities, getServiceAlerts, getServiceIdsByDate, getShapes, getShapesAsGeoJSON, getStopAreas, getStopAttributes, getStopTimeUpdates, getStops, getStopsAsGeoJSON, getStoptimes, getTimeframes, getTimetableNotes, getTimetableNotesReferences, getTimetablePages, getTimetableStopOrders, getTimetables, getTransfers, getTranslations, getTripCapacities, getTripUpdates, getTrips, getTripsDatedVehicleJourneys, getVehiclePositions, importGtfs, isGtfsError, isGtfsValidationError, openDb, prepDirectory, untildify, unzip, updateGtfsRealtime }; //# sourceMappingURL=index.d.ts.map