Skip to content

Commit e0af4e5

Browse files
authored
Merge pull request #18 from sysdevrun/claude/gtfs-rt-time-delay-handling-011CUtRt1d4j49UTEg86gufv
Clarify GTFS-RT time and delay handling
2 parents 2b57e3b + 1093bed commit e0af4e5

16 files changed

Lines changed: 711 additions & 1156 deletions

‎dist/index.d.mts‎

Lines changed: 51 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ interface TripUpdate {
144144
}
145145
interface StopTimeRealtime {
146146
arrival_delay?: number;
147+
arrival_time?: number;
147148
departure_delay?: number;
149+
departure_time?: number;
148150
schedule_relationship?: ScheduleRelationship;
149151
}
150152
interface TripRealtime {
@@ -395,7 +397,7 @@ interface Attribution {
395397
*/
396398

397399
interface AgencyFilters {
398-
agencyId?: string;
400+
agencyId?: string | string[];
399401
limit?: number;
400402
}
401403

@@ -404,10 +406,10 @@ interface AgencyFilters {
404406
*/
405407

406408
interface StopFilters {
407-
stopId?: string;
408-
stopCode?: string;
409+
stopId?: string | string[];
410+
stopCode?: string | string[];
409411
name?: string;
410-
tripId?: string;
412+
tripId?: string | string[];
411413
limit?: number;
412414
}
413415

@@ -416,8 +418,8 @@ interface StopFilters {
416418
*/
417419

418420
interface RouteFilters {
419-
routeId?: string;
420-
agencyId?: string;
421+
routeId?: string | string[];
422+
agencyId?: string | string[];
421423
limit?: number;
422424
}
423425

@@ -426,11 +428,11 @@ interface RouteFilters {
426428
*/
427429

428430
interface TripFilters {
429-
tripId?: string;
430-
routeId?: string;
431-
serviceIds?: string[];
432-
directionId?: number;
433-
agencyId?: string;
431+
tripId?: string | string[];
432+
routeId?: string | string[];
433+
serviceIds?: string | string[];
434+
directionId?: number | number[];
435+
agencyId?: string | string[];
434436
includeRealtime?: boolean;
435437
limit?: number;
436438
}
@@ -443,12 +445,12 @@ interface TripWithRealtime extends Trip {
443445
*/
444446

445447
interface StopTimeFilters {
446-
tripId?: string;
447-
stopId?: string;
448-
routeId?: string;
449-
serviceIds?: string[];
450-
directionId?: number;
451-
agencyId?: string;
448+
tripId?: string | string[];
449+
stopId?: string | string[];
450+
routeId?: string | string[];
451+
serviceIds?: string | string[];
452+
directionId?: number | number[];
453+
agencyId?: string | string[];
452454
includeRealtime?: boolean;
453455
limit?: number;
454456
}
@@ -464,9 +466,9 @@ interface TripUpdateFilters {
464466
}
465467

466468
interface StopTimeUpdateFilters {
467-
tripId?: string;
468-
stopId?: string;
469-
stopSequence?: number;
469+
tripId?: string | string[];
470+
stopId?: string | string[];
471+
stopSequence?: number | number[];
470472
limit?: number;
471473
}
472474
/**
@@ -546,28 +548,19 @@ declare class GtfsSqlJs {
546548
* Get direct access to the database (for advanced queries)
547549
*/
548550
getDatabase(): Database;
549-
/**
550-
* Get an agency by its agency_id
551-
*/
552-
getAgencyById(agencyId: string): Agency | null;
553551
/**
554552
* Get agencies with optional filters
553+
* Pass agencyId filter to get a specific agency
555554
*/
556555
getAgencies(filters?: AgencyFilters): Agency[];
557-
/**
558-
* Get a stop by its stop_id
559-
*/
560-
getStopById(stopId: string): Stop | null;
561556
/**
562557
* Get stops with optional filters
558+
* Pass stopId filter to get a specific stop
563559
*/
564560
getStops(filters?: StopFilters): Stop[];
565-
/**
566-
* Get a route by its route_id
567-
*/
568-
getRouteById(routeId: string): Route | null;
569561
/**
570562
* Get routes with optional filters
563+
* Pass routeId filter to get a specific route
571564
*/
572565
getRoutes(filters?: RouteFilters): Route[];
573566
/**
@@ -586,19 +579,16 @@ declare class GtfsSqlJs {
586579
* Get calendar date exceptions for a specific date
587580
*/
588581
getCalendarDatesForDate(date: string): CalendarDate[];
589-
/**
590-
* Get a trip by its trip_id
591-
*/
592-
getTripById(tripId: string): Trip | null;
593582
/**
594583
* Get trips with optional filters
584+
* Pass tripId filter to get a specific trip
595585
*
596586
* @param filters - Optional filters
597-
* @param filters.tripId - Filter by trip ID
598-
* @param filters.routeId - Filter by route ID
587+
* @param filters.tripId - Filter by trip ID (single value or array)
588+
* @param filters.routeId - Filter by route ID (single value or array)
599589
* @param filters.date - Filter by date (YYYYMMDD format) - will get active services for that date
600-
* @param filters.directionId - Filter by direction ID
601-
* @param filters.agencyId - Filter by agency ID
590+
* @param filters.directionId - Filter by direction ID (single value or array)
591+
* @param filters.agencyId - Filter by agency ID (single value or array)
602592
* @param filters.limit - Limit number of results
603593
*
604594
* @example
@@ -608,24 +598,25 @@ declare class GtfsSqlJs {
608598
* @example
609599
* // Get all trips for a route going in one direction
610600
* const trips = gtfs.getTrips({ routeId: 'ROUTE_1', directionId: 0 });
601+
*
602+
* @example
603+
* // Get a specific trip
604+
* const trips = gtfs.getTrips({ tripId: 'TRIP_123' });
611605
*/
612606
getTrips(filters?: TripFilters & {
613607
date?: string;
614608
}): Trip[];
615-
/**
616-
* Get stop times for a trip (ordered by stop_sequence)
617-
*/
618-
getStopTimesByTrip(tripId: string): StopTime[];
619609
/**
620610
* Get stop times with optional filters
621611
*
622612
* @param filters - Optional filters
623-
* @param filters.tripId - Filter by trip ID
624-
* @param filters.stopId - Filter by stop ID
625-
* @param filters.routeId - Filter by route ID
613+
* @param filters.tripId - Filter by trip ID (single value or array)
614+
* @param filters.stopId - Filter by stop ID (single value or array)
615+
* @param filters.routeId - Filter by route ID (single value or array)
626616
* @param filters.date - Filter by date (YYYYMMDD format) - will get active services for that date
627-
* @param filters.directionId - Filter by direction ID
628-
* @param filters.agencyId - Filter by agency ID
617+
* @param filters.directionId - Filter by direction ID (single value or array)
618+
* @param filters.agencyId - Filter by agency ID (single value or array)
619+
* @param filters.includeRealtime - Include realtime data (delay and time fields)
629620
* @param filters.limit - Limit number of results
630621
*
631622
* @example
@@ -639,6 +630,13 @@ declare class GtfsSqlJs {
639630
* routeId: 'ROUTE_1',
640631
* date: '20240115'
641632
* });
633+
*
634+
* @example
635+
* // Get stop times with realtime data
636+
* const stopTimes = gtfs.getStopTimes({
637+
* tripId: 'TRIP_123',
638+
* includeRealtime: true
639+
* });
642640
*/
643641
getStopTimes(filters?: StopTimeFilters & {
644642
date?: string;
@@ -670,36 +668,24 @@ declare class GtfsSqlJs {
670668
clearRealtimeData(): void;
671669
/**
672670
* Get alerts with optional filters
671+
* Pass alertId filter to get a specific alert
673672
*/
674673
getAlerts(filters?: AlertFilters): Alert[];
675-
/**
676-
* Get alert by ID
677-
*/
678-
getAlertById(alertId: string): Alert | null;
679674
/**
680675
* Get vehicle positions with optional filters
676+
* Pass tripId filter to get vehicle position for a specific trip
681677
*/
682678
getVehiclePositions(filters?: VehiclePositionFilters): VehiclePosition[];
683-
/**
684-
* Get vehicle position by trip ID
685-
*/
686-
getVehiclePositionByTripId(tripId: string): VehiclePosition | null;
687679
/**
688680
* Get trip updates with optional filters
681+
* Pass tripId filter to get trip update for a specific trip
689682
*/
690683
getTripUpdates(filters?: TripUpdateFilters): TripUpdate[];
691-
/**
692-
* Get trip update by trip ID
693-
*/
694-
getTripUpdateByTripId(tripId: string): TripUpdate | null;
695684
/**
696685
* Get stop time updates with optional filters
686+
* Pass tripId filter to get stop time updates for a specific trip
697687
*/
698688
getStopTimeUpdates(filters?: StopTimeUpdateFilters): StopTimeUpdate[];
699-
/**
700-
* Get stop time updates for a specific trip
701-
*/
702-
getStopTimeUpdatesByTripId(tripId: string): StopTimeUpdate[];
703689
/**
704690
* Export all alerts without staleness filtering (for debugging)
705691
*/

0 commit comments

Comments
 (0)