gtfs-sqljs 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -532,6 +532,22 @@ interface TripWithRealtime extends Trip {
532
532
  realtime?: TripRealtime;
533
533
  }
534
534
 
535
+ /**
536
+ * GTFS static enums
537
+ */
538
+ /**
539
+ * Indicates whether passengers are picked up or dropped off at a stop.
540
+ * Used for both pickup_type and drop_off_type fields in stop_times.
541
+ *
542
+ * @see https://gtfs.org/schedule/reference/#stop_timestxt
543
+ */
544
+ declare enum PickupDropOffType {
545
+ REGULAR = 0,
546
+ NONE = 1,
547
+ PHONE_AGENCY = 2,
548
+ COORDINATE_WITH_DRIVER = 3
549
+ }
550
+
535
551
  /**
536
552
  * Stop Time Query Methods
537
553
  */
@@ -543,6 +559,18 @@ interface StopTimeFilters {
543
559
  serviceIds?: string | string[];
544
560
  directionId?: number | number[];
545
561
  agencyId?: string | string[];
562
+ /**
563
+ * Filter by pickup type.
564
+ * 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
565
+ * @see {@link PickupDropOffType}
566
+ */
567
+ pickupType?: PickupDropOffType | PickupDropOffType[];
568
+ /**
569
+ * Filter by drop-off type.
570
+ * 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
571
+ * @see {@link PickupDropOffType}
572
+ */
573
+ dropOffType?: PickupDropOffType | PickupDropOffType[];
546
574
  includeRealtime?: boolean;
547
575
  limit?: number;
548
576
  }
@@ -1086,4 +1114,4 @@ declare function getCacheStats(entries: CacheEntry[]): {
1086
1114
  newestEntry: number | null;
1087
1115
  };
1088
1116
 
1089
- export { type Agency, type AgencyFilters, type Alert, AlertCause, AlertEffect, type AlertFilters, type Attribution, type CacheEntry, type CacheEntryWithData, type CacheMetadata, type CacheStore, type CacheStoreOptions, type Calendar, type CalendarDate, type ColumnDefinition, CongestionLevel, DEFAULT_CACHE_EXPIRATION_MS, type EntitySelector, type FareAttribute, type FareRule, type FeedInfo, type Frequency, GTFS_SCHEMA, type GeoJsonFeatureCollection, GtfsSqlJs, type GtfsSqlJsOptions, type IndexDefinition, type Level, OccupancyStatus, type Pathway, type Position, type RealtimeConfig, type Route, type RouteFilters, ScheduleRelationship, type Shape, type ShapeFilters, type Stop, type StopFilters, type StopTime, type StopTimeEvent, type StopTimeFilters, type StopTimeRealtime, type StopTimeUpdate, type StopTimeUpdateFilters, type StopTimeWithRealtime, type TableSchema, type TimeRange, type Transfer, type TranslatedString, type Trip, type TripFilters, type TripRealtime, type TripUpdate, type TripUpdateFilters, type TripWithRealtime, type VehicleDescriptor, type VehiclePosition, type VehiclePositionFilters, VehicleStopStatus, computeChecksum, computeZipChecksum, filterExpiredEntries, generateCacheKey, getCacheStats, isCacheExpired };
1117
+ export { type Agency, type AgencyFilters, type Alert, AlertCause, AlertEffect, type AlertFilters, type Attribution, type CacheEntry, type CacheEntryWithData, type CacheMetadata, type CacheStore, type CacheStoreOptions, type Calendar, type CalendarDate, type ColumnDefinition, CongestionLevel, DEFAULT_CACHE_EXPIRATION_MS, type EntitySelector, type FareAttribute, type FareRule, type FeedInfo, type Frequency, GTFS_SCHEMA, type GeoJsonFeatureCollection, GtfsSqlJs, type GtfsSqlJsOptions, type IndexDefinition, type Level, OccupancyStatus, type Pathway, PickupDropOffType, type Position, type RealtimeConfig, type Route, type RouteFilters, ScheduleRelationship, type Shape, type ShapeFilters, type Stop, type StopFilters, type StopTime, type StopTimeEvent, type StopTimeFilters, type StopTimeRealtime, type StopTimeUpdate, type StopTimeUpdateFilters, type StopTimeWithRealtime, type TableSchema, type TimeRange, type Transfer, type TranslatedString, type Trip, type TripFilters, type TripRealtime, type TripUpdate, type TripUpdateFilters, type TripWithRealtime, type VehicleDescriptor, type VehiclePosition, type VehiclePositionFilters, VehicleStopStatus, computeChecksum, computeZipChecksum, filterExpiredEntries, generateCacheKey, getCacheStats, isCacheExpired };
package/dist/index.js CHANGED
@@ -1689,7 +1689,7 @@ function mergeRealtimeData2(stopTimes, db, stalenessThreshold) {
1689
1689
  });
1690
1690
  }
1691
1691
  function getStopTimes(db, filters = {}, stalenessThreshold = 120) {
1692
- const { tripId, stopId, routeId, serviceIds, directionId, agencyId, includeRealtime, limit } = filters;
1692
+ const { tripId, stopId, routeId, serviceIds, directionId, agencyId, pickupType, dropOffType, includeRealtime, limit } = filters;
1693
1693
  const needsTripsJoin = routeId || serviceIds || directionId !== void 0 || agencyId !== void 0;
1694
1694
  const needsRoutesJoin = agencyId !== void 0;
1695
1695
  const conditions = [];
@@ -1742,6 +1742,24 @@ function getStopTimes(db, filters = {}, stalenessThreshold = 120) {
1742
1742
  params.push(...agencyIds);
1743
1743
  }
1744
1744
  }
1745
+ if (pickupType !== void 0) {
1746
+ const types = Array.isArray(pickupType) ? pickupType : [pickupType];
1747
+ if (types.length > 0) {
1748
+ const col = needsTripsJoin ? "st.pickup_type" : "pickup_type";
1749
+ const placeholders = types.map(() => "?").join(", ");
1750
+ conditions.push(`COALESCE(${col}, 0) IN (${placeholders})`);
1751
+ params.push(...types);
1752
+ }
1753
+ }
1754
+ if (dropOffType !== void 0) {
1755
+ const types = Array.isArray(dropOffType) ? dropOffType : [dropOffType];
1756
+ if (types.length > 0) {
1757
+ const col = needsTripsJoin ? "st.drop_off_type" : "drop_off_type";
1758
+ const placeholders = types.map(() => "?").join(", ");
1759
+ conditions.push(`COALESCE(${col}, 0) IN (${placeholders})`);
1760
+ params.push(...types);
1761
+ }
1762
+ }
1745
1763
  let sql;
1746
1764
  if (needsRoutesJoin) {
1747
1765
  sql = "SELECT st.* FROM stop_times st INNER JOIN trips t ON st.trip_id = t.trip_id INNER JOIN routes r ON t.route_id = r.route_id";
@@ -3127,6 +3145,15 @@ var AlertEffect = /* @__PURE__ */ ((AlertEffect2) => {
3127
3145
  return AlertEffect2;
3128
3146
  })(AlertEffect || {});
3129
3147
 
3148
+ // src/types/gtfs-enums.ts
3149
+ var PickupDropOffType = /* @__PURE__ */ ((PickupDropOffType2) => {
3150
+ PickupDropOffType2[PickupDropOffType2["REGULAR"] = 0] = "REGULAR";
3151
+ PickupDropOffType2[PickupDropOffType2["NONE"] = 1] = "NONE";
3152
+ PickupDropOffType2[PickupDropOffType2["PHONE_AGENCY"] = 2] = "PHONE_AGENCY";
3153
+ PickupDropOffType2[PickupDropOffType2["COORDINATE_WITH_DRIVER"] = 3] = "COORDINATE_WITH_DRIVER";
3154
+ return PickupDropOffType2;
3155
+ })(PickupDropOffType || {});
3156
+
3130
3157
  // src/index.ts
3131
3158
  init_utils();
3132
3159
  export {
@@ -3137,6 +3164,7 @@ export {
3137
3164
  GTFS_SCHEMA,
3138
3165
  GtfsSqlJs,
3139
3166
  OccupancyStatus,
3167
+ PickupDropOffType,
3140
3168
  ScheduleRelationship,
3141
3169
  VehicleStopStatus,
3142
3170
  computeChecksum,