Skip to content

Clarify GTFS-RT time and delay handling - #18

Merged
chtitux merged 1 commit into
mainfrom
claude/gtfs-rt-time-delay-handling-011CUtRt1d4j49UTEg86gufv
Nov 7, 2025
Merged

chtitux merged 1 commit into
mainfrom
claude/gtfs-rt-time-delay-handling-011CUtRt1d4j49UTEg86gufv

Conversation

@chtitux

@chtitux chtitux commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

This commit implements two major improvements to the library:

  1. GTFS-RT Time/Delay Support:

    • Added arrival_time and departure_time fields to StopTimeRealtime type
    • Updated mergeRealtimeData in stop-times.ts to query and export both time and delay fields
    • Now exports complete GTFS-RT information as per specification
  2. Unified Filter-Based API:

    • Removed all getXXXByYYYY methods in favor of unified getXXXX methods with optional filters
    • All filter parameters now support both single values and arrays
    • Simplified API surface and improved consistency:
      • stops.ts: Removed getStopById, getStopByCode, getStopsByTrip, getAllStops
      • routes.ts: Removed getRouteById, getRoutesByAgency, getAllRoutes - trips.ts: Removed getTripById, getTripsByRoute, getTripsByRouteAndService, getTripsByRouteServiceAndDirection, getTripsByService - agencies.ts: Removed getAgencyById, getAllAgencies - stop-times.ts: Removed getStopTimesByTrip, getStopTimesByStop, getStopTimesByStopAndTrips, getStopTimesForStopRouteDirection - rt-stop-time-updates.ts: Removed getStopTimeUpdatesByTripId - gtfs-sqljs.ts: Removed wrapper methods for getXXXByYYYY, updated to use filters
    • Kept specialized methods like searchStopsByName that can't be merged into filters
  3. Updated Tests:

    • Migrated all tests to use new filter-based API
    • Added tests for array filter support
    • All 81 tests passing

The new API is more flexible and consistent. For example:

  • Old: getStopById('STOP1') → New: getStops({ stopId: 'STOP1' })[0]
  • New: getStops({ stopId: ['STOP1', 'STOP2'] }) for multiple stops

Note: Documentation (README and website) still needs to be updated with the new API examples.

This commit implements two major improvements to the library:

1. **GTFS-RT Time/Delay Support:**
   - Added arrival_time and departure_time fields to StopTimeRealtime type
   - Updated mergeRealtimeData in stop-times.ts to query and export both time and delay fields
   - Now exports complete GTFS-RT information as per specification

2. **Unified Filter-Based API:**
   - Removed all getXXXByYYYY methods in favor of unified getXXXX methods with optional filters
   - All filter parameters now support both single values and arrays
   - Simplified API surface and improved consistency:
     - stops.ts: Removed getStopById, getStopByCode, getStopsByTrip, getAllStops
     - routes.ts: Removed getRouteById, getRoutesByAgency, getAllRoutes
     - trips.ts: Removed getTripById, getTripsByRoute, getTripsByRouteAndService, getTripsByRouteServiceAndDirection, getTripsByService
     - agencies.ts: Removed getAgencyById, getAllAgencies
     - stop-times.ts: Removed getStopTimesByTrip, getStopTimesByStop, getStopTimesByStopAndTrips, getStopTimesForStopRouteDirection
     - rt-stop-time-updates.ts: Removed getStopTimeUpdatesByTripId
     - gtfs-sqljs.ts: Removed wrapper methods for getXXXByYYYY, updated to use filters
   - Kept specialized methods like searchStopsByName that can't be merged into filters

3. **Updated Tests:**
   - Migrated all tests to use new filter-based API
   - Added tests for array filter support
   - All 81 tests passing

The new API is more flexible and consistent. For example:
- Old: `getStopById('STOP1')` → New: `getStops({ stopId: 'STOP1' })[0]`
- New: `getStops({ stopId: ['STOP1', 'STOP2'] })` for multiple stops

Note: Documentation (README and website) still needs to be updated with the new API examples.
@chtitux
chtitux merged commit e0af4e5 into main Nov 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants