gtfs-sqljs 0.1.2 → 0.2.2
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/README.md +43 -1041
- package/dist/index.d.ts +31 -2
- package/dist/index.js +38 -12
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -385,7 +385,8 @@ interface FareAttribute {
|
|
|
385
385
|
price: number;
|
|
386
386
|
currency_type: string;
|
|
387
387
|
payment_method: number;
|
|
388
|
-
transfers
|
|
388
|
+
/** Number of transfers permitted. null means unlimited. */
|
|
389
|
+
transfers: number | null;
|
|
389
390
|
agency_id?: string;
|
|
390
391
|
transfer_duration?: number;
|
|
391
392
|
}
|
|
@@ -532,6 +533,22 @@ interface TripWithRealtime extends Trip {
|
|
|
532
533
|
realtime?: TripRealtime;
|
|
533
534
|
}
|
|
534
535
|
|
|
536
|
+
/**
|
|
537
|
+
* GTFS static enums
|
|
538
|
+
*/
|
|
539
|
+
/**
|
|
540
|
+
* Indicates whether passengers are picked up or dropped off at a stop.
|
|
541
|
+
* Used for both pickup_type and drop_off_type fields in stop_times.
|
|
542
|
+
*
|
|
543
|
+
* @see https://gtfs.org/schedule/reference/#stop_timestxt
|
|
544
|
+
*/
|
|
545
|
+
declare enum PickupDropOffType {
|
|
546
|
+
REGULAR = 0,
|
|
547
|
+
NONE = 1,
|
|
548
|
+
PHONE_AGENCY = 2,
|
|
549
|
+
COORDINATE_WITH_DRIVER = 3
|
|
550
|
+
}
|
|
551
|
+
|
|
535
552
|
/**
|
|
536
553
|
* Stop Time Query Methods
|
|
537
554
|
*/
|
|
@@ -543,6 +560,18 @@ interface StopTimeFilters {
|
|
|
543
560
|
serviceIds?: string | string[];
|
|
544
561
|
directionId?: number | number[];
|
|
545
562
|
agencyId?: string | string[];
|
|
563
|
+
/**
|
|
564
|
+
* Filter by pickup type.
|
|
565
|
+
* 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
|
|
566
|
+
* @see {@link PickupDropOffType}
|
|
567
|
+
*/
|
|
568
|
+
pickupType?: PickupDropOffType | PickupDropOffType[];
|
|
569
|
+
/**
|
|
570
|
+
* Filter by drop-off type.
|
|
571
|
+
* 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
|
|
572
|
+
* @see {@link PickupDropOffType}
|
|
573
|
+
*/
|
|
574
|
+
dropOffType?: PickupDropOffType | PickupDropOffType[];
|
|
546
575
|
includeRealtime?: boolean;
|
|
547
576
|
limit?: number;
|
|
548
577
|
}
|
|
@@ -1086,4 +1115,4 @@ declare function getCacheStats(entries: CacheEntry[]): {
|
|
|
1086
1115
|
newestEntry: number | null;
|
|
1087
1116
|
};
|
|
1088
1117
|
|
|
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 };
|
|
1118
|
+
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
|
@@ -185,7 +185,7 @@ var GTFS_SCHEMA = [
|
|
|
185
185
|
{ name: "price", type: "REAL", required: true },
|
|
186
186
|
{ name: "currency_type", type: "TEXT", required: true },
|
|
187
187
|
{ name: "payment_method", type: "INTEGER", required: true },
|
|
188
|
-
{ name: "transfers", type: "INTEGER", required:
|
|
188
|
+
{ name: "transfers", type: "INTEGER", required: false },
|
|
189
189
|
{ name: "agency_id", type: "TEXT", required: false },
|
|
190
190
|
{ name: "transfer_duration", type: "INTEGER", required: false }
|
|
191
191
|
]
|
|
@@ -1591,11 +1591,10 @@ function getTrips(db, filters = {}, stalenessThreshold = 120) {
|
|
|
1591
1591
|
}
|
|
1592
1592
|
if (serviceIds) {
|
|
1593
1593
|
const serviceIdArray = Array.isArray(serviceIds) ? serviceIds : [serviceIds];
|
|
1594
|
-
if (serviceIdArray.length
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
}
|
|
1594
|
+
if (serviceIdArray.length === 0) return [];
|
|
1595
|
+
const placeholders = serviceIdArray.map(() => "?").join(", ");
|
|
1596
|
+
conditions.push(needsRoutesJoin ? `t.service_id IN (${placeholders})` : `service_id IN (${placeholders})`);
|
|
1597
|
+
params.push(...serviceIdArray);
|
|
1599
1598
|
}
|
|
1600
1599
|
if (directionId !== void 0) {
|
|
1601
1600
|
const directionIds = Array.isArray(directionId) ? directionId : [directionId];
|
|
@@ -1689,7 +1688,7 @@ function mergeRealtimeData2(stopTimes, db, stalenessThreshold) {
|
|
|
1689
1688
|
});
|
|
1690
1689
|
}
|
|
1691
1690
|
function getStopTimes(db, filters = {}, stalenessThreshold = 120) {
|
|
1692
|
-
const { tripId, stopId, routeId, serviceIds, directionId, agencyId, includeRealtime, limit } = filters;
|
|
1691
|
+
const { tripId, stopId, routeId, serviceIds, directionId, agencyId, pickupType, dropOffType, includeRealtime, limit } = filters;
|
|
1693
1692
|
const needsTripsJoin = routeId || serviceIds || directionId !== void 0 || agencyId !== void 0;
|
|
1694
1693
|
const needsRoutesJoin = agencyId !== void 0;
|
|
1695
1694
|
const conditions = [];
|
|
@@ -1720,11 +1719,10 @@ function getStopTimes(db, filters = {}, stalenessThreshold = 120) {
|
|
|
1720
1719
|
}
|
|
1721
1720
|
if (serviceIds) {
|
|
1722
1721
|
const serviceIdArray = Array.isArray(serviceIds) ? serviceIds : [serviceIds];
|
|
1723
|
-
if (serviceIdArray.length
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}
|
|
1722
|
+
if (serviceIdArray.length === 0) return [];
|
|
1723
|
+
const placeholders = serviceIdArray.map(() => "?").join(", ");
|
|
1724
|
+
conditions.push(`t.service_id IN (${placeholders})`);
|
|
1725
|
+
params.push(...serviceIdArray);
|
|
1728
1726
|
}
|
|
1729
1727
|
if (directionId !== void 0) {
|
|
1730
1728
|
const directionIds = Array.isArray(directionId) ? directionId : [directionId];
|
|
@@ -1742,6 +1740,24 @@ function getStopTimes(db, filters = {}, stalenessThreshold = 120) {
|
|
|
1742
1740
|
params.push(...agencyIds);
|
|
1743
1741
|
}
|
|
1744
1742
|
}
|
|
1743
|
+
if (pickupType !== void 0) {
|
|
1744
|
+
const types = Array.isArray(pickupType) ? pickupType : [pickupType];
|
|
1745
|
+
if (types.length > 0) {
|
|
1746
|
+
const col = needsTripsJoin ? "st.pickup_type" : "pickup_type";
|
|
1747
|
+
const placeholders = types.map(() => "?").join(", ");
|
|
1748
|
+
conditions.push(`COALESCE(${col}, 0) IN (${placeholders})`);
|
|
1749
|
+
params.push(...types);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
if (dropOffType !== void 0) {
|
|
1753
|
+
const types = Array.isArray(dropOffType) ? dropOffType : [dropOffType];
|
|
1754
|
+
if (types.length > 0) {
|
|
1755
|
+
const col = needsTripsJoin ? "st.drop_off_type" : "drop_off_type";
|
|
1756
|
+
const placeholders = types.map(() => "?").join(", ");
|
|
1757
|
+
conditions.push(`COALESCE(${col}, 0) IN (${placeholders})`);
|
|
1758
|
+
params.push(...types);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1745
1761
|
let sql;
|
|
1746
1762
|
if (needsRoutesJoin) {
|
|
1747
1763
|
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 +3143,15 @@ var AlertEffect = /* @__PURE__ */ ((AlertEffect2) => {
|
|
|
3127
3143
|
return AlertEffect2;
|
|
3128
3144
|
})(AlertEffect || {});
|
|
3129
3145
|
|
|
3146
|
+
// src/types/gtfs-enums.ts
|
|
3147
|
+
var PickupDropOffType = /* @__PURE__ */ ((PickupDropOffType2) => {
|
|
3148
|
+
PickupDropOffType2[PickupDropOffType2["REGULAR"] = 0] = "REGULAR";
|
|
3149
|
+
PickupDropOffType2[PickupDropOffType2["NONE"] = 1] = "NONE";
|
|
3150
|
+
PickupDropOffType2[PickupDropOffType2["PHONE_AGENCY"] = 2] = "PHONE_AGENCY";
|
|
3151
|
+
PickupDropOffType2[PickupDropOffType2["COORDINATE_WITH_DRIVER"] = 3] = "COORDINATE_WITH_DRIVER";
|
|
3152
|
+
return PickupDropOffType2;
|
|
3153
|
+
})(PickupDropOffType || {});
|
|
3154
|
+
|
|
3130
3155
|
// src/index.ts
|
|
3131
3156
|
init_utils();
|
|
3132
3157
|
export {
|
|
@@ -3137,6 +3162,7 @@ export {
|
|
|
3137
3162
|
GTFS_SCHEMA,
|
|
3138
3163
|
GtfsSqlJs,
|
|
3139
3164
|
OccupancyStatus,
|
|
3165
|
+
PickupDropOffType,
|
|
3140
3166
|
ScheduleRelationship,
|
|
3141
3167
|
VehicleStopStatus,
|
|
3142
3168
|
computeChecksum,
|