gtfs-sqljs 0.1.0 → 0.1.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 +1 -82
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Try the live demo to explore GTFS data, view routes with colors, and see trip sc
|
|
|
21
21
|
|
|
22
22
|
### GTFS Static Data
|
|
23
23
|
- ✅ Load GTFS data from ZIP files (URL or local path)
|
|
24
|
-
- ✅ **High-performance loading**
|
|
24
|
+
- ✅ **High-performance loading** with optimized bulk inserts
|
|
25
25
|
- ✅ **Progress tracking** - Real-time progress callbacks (0-100%)
|
|
26
26
|
- ✅ Skip importing specific files (e.g., shapes.txt) to reduce memory usage
|
|
27
27
|
- ✅ Load existing SQLite databases
|
|
@@ -55,87 +55,6 @@ Try the live demo to explore GTFS data, view routes with colors, and see trip sc
|
|
|
55
55
|
- ✅ **Custom cache stores** - Implement your own (Redis, S3, etc.)
|
|
56
56
|
- ✅ **Dramatic speed improvement** - Subsequent loads in <1 second
|
|
57
57
|
|
|
58
|
-
## Migration Guide (v1.0.0+)
|
|
59
|
-
|
|
60
|
-
If you're upgrading from an earlier version, the API has been simplified and improved:
|
|
61
|
-
|
|
62
|
-
### Unified Filter-Based API
|
|
63
|
-
|
|
64
|
-
All `getXXXByYYYY` methods have been removed in favor of unified `getXXXX` methods with optional filters. Filters now support both single values and arrays for maximum flexibility.
|
|
65
|
-
|
|
66
|
-
**Migration examples:**
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
// ❌ Old API
|
|
70
|
-
const stop = gtfs.getStopById('STOP_123');
|
|
71
|
-
const route = gtfs.getRouteById('ROUTE_1');
|
|
72
|
-
const trip = gtfs.getTripById('TRIP_123');
|
|
73
|
-
const stopTimes = gtfs.getStopTimesByTrip('TRIP_123');
|
|
74
|
-
const agency = gtfs.getAgencyById('AGENCY_1');
|
|
75
|
-
const alert = gtfs.getAlertById('alert:123');
|
|
76
|
-
const vehicle = gtfs.getVehiclePositionByTripId('TRIP_123');
|
|
77
|
-
|
|
78
|
-
// ✅ New API
|
|
79
|
-
const stops = gtfs.getStops({ stopId: 'STOP_123' });
|
|
80
|
-
const stop = stops.length > 0 ? stops[0] : null;
|
|
81
|
-
|
|
82
|
-
const routes = gtfs.getRoutes({ routeId: 'ROUTE_1' });
|
|
83
|
-
const route = routes.length > 0 ? routes[0] : null;
|
|
84
|
-
|
|
85
|
-
const trips = gtfs.getTrips({ tripId: 'TRIP_123' });
|
|
86
|
-
const trip = trips.length > 0 ? trips[0] : null;
|
|
87
|
-
|
|
88
|
-
const stopTimes = gtfs.getStopTimes({ tripId: 'TRIP_123' });
|
|
89
|
-
|
|
90
|
-
const agencies = gtfs.getAgencies({ agencyId: 'AGENCY_1' });
|
|
91
|
-
const agency = agencies.length > 0 ? agencies[0] : null;
|
|
92
|
-
|
|
93
|
-
const alerts = gtfs.getAlerts({ alertId: 'alert:123' });
|
|
94
|
-
const alert = alerts.length > 0 ? alerts[0] : null;
|
|
95
|
-
|
|
96
|
-
const vehicles = gtfs.getVehiclePositions({ tripId: 'TRIP_123' });
|
|
97
|
-
const vehicle = vehicles.length > 0 ? vehicles[0] : null;
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Benefits of the new API:**
|
|
101
|
-
- ✅ Support for filtering by multiple IDs at once (arrays)
|
|
102
|
-
- ✅ More consistent API surface
|
|
103
|
-
- ✅ Easier to combine multiple filters
|
|
104
|
-
- ✅ Better TypeScript inference
|
|
105
|
-
|
|
106
|
-
**Array filtering example:**
|
|
107
|
-
```typescript
|
|
108
|
-
// Get multiple stops at once
|
|
109
|
-
const stops = gtfs.getStops({ stopId: ['STOP_1', 'STOP_2', 'STOP_3'] });
|
|
110
|
-
|
|
111
|
-
// Get trips for multiple routes
|
|
112
|
-
const trips = gtfs.getTrips({ routeId: ['ROUTE_1', 'ROUTE_2'], date: '20240115' });
|
|
113
|
-
|
|
114
|
-
// Get stop times for multiple trips
|
|
115
|
-
const stopTimes = gtfs.getStopTimes({ tripId: ['TRIP_1', 'TRIP_2'] });
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### GTFS-RT Time/Delay Support
|
|
119
|
-
|
|
120
|
-
Stop time updates now include both `time` and `delay` fields:
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
const stopTimes = gtfs.getStopTimes({
|
|
124
|
-
tripId: 'TRIP_123',
|
|
125
|
-
includeRealtime: true
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
for (const st of stopTimes) {
|
|
129
|
-
if (st.realtime) {
|
|
130
|
-
// Both delay (relative to schedule) and time (absolute) are now available
|
|
131
|
-
console.log('Arrival delay:', st.realtime.arrival_delay, 'seconds');
|
|
132
|
-
console.log('Arrival time:', st.realtime.arrival_time, '(UNIX timestamp)');
|
|
133
|
-
console.log('Departure delay:', st.realtime.departure_delay, 'seconds');
|
|
134
|
-
console.log('Departure time:', st.realtime.departure_time, '(UNIX timestamp)');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
58
|
## Installation
|
|
140
59
|
|
|
141
60
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtfs-sqljs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Load GTFS data into sql.js SQLite database for querying in browser and Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"prepare": "npm run build",
|
|
22
22
|
"test": "vitest run",
|
|
23
23
|
"test:watch": "vitest",
|
|
24
|
-
"lint": "eslint src
|
|
24
|
+
"lint": "eslint src",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"prepublishOnly": "npm run build"
|
|
27
27
|
},
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/sysdevrun/gtfs-sqljs.git"
|
|
40
|
+
"url": "git+https://github.com/sysdevrun/gtfs-sqljs.git"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"jszip": "^3.10.1",
|
|
44
44
|
"papaparse": "^5.5.3",
|
|
45
|
-
"protobufjs": "^
|
|
45
|
+
"protobufjs": "^8.0.0",
|
|
46
46
|
"sql.js": "^1.10.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@
|
|
49
|
+
"@eslint/js": "^9.39.3",
|
|
50
|
+
"@types/node": "^25.3.1",
|
|
50
51
|
"@types/papaparse": "^5.5.0",
|
|
51
52
|
"@types/sql.js": "^1.4.9",
|
|
52
|
-
"
|
|
53
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
54
|
-
"eslint": "^8.56.0",
|
|
53
|
+
"eslint": "^9.39.3",
|
|
55
54
|
"tsup": "^8.0.1",
|
|
56
|
-
"typescript": "^5.
|
|
57
|
-
"
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"typescript-eslint": "^8.56.1",
|
|
57
|
+
"vitest": "^4.0.18"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=18.0.0"
|