gtfs 4.18.7 → 4.19.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/README.md CHANGED
@@ -162,6 +162,7 @@ Copy `config-sample.json` to `config.json` and then add your projects configurat
162
162
  | [`gtfsRealtimeExpirationSeconds`](#gtfsrealtimeexpirationseconds) | integer | Amount of time in seconds to allow GTFS-Realtime data to be stored in database before allowing to be deleted. Optional, defaults to 0. |
163
163
  | [`ignoreDuplicates`](#ignoreduplicates) | boolean | Whether or not to ignore unique constraints on ids when importing GTFS, such as `trip_id`, `calendar_id`. Optional, defaults to false. |
164
164
  | [`ignoreErrors`](#ignoreerrors) | boolean | Whether or not to ignore errors during the import process. If true, failed files will be skipped while the rest are processed. Optional, defaults to false. |
165
+ | [`includeImportReport`](#includeimportreport) | boolean | Whether to return a report object from `importGtfs()` containing details about what was imported and any errors encountered. Optional, defaults to false. |
165
166
  | [`sqlitePath`](#sqlitepath) | string | A path to a SQLite database. Optional, defaults to using an in-memory database. |
166
167
  | [`verbose`](#verbose) | boolean | Whether or not to print output to the console. Optional, defaults to true. |
167
168
 
@@ -414,7 +415,7 @@ importGtfs({
414
415
  }
415
416
  }
416
417
  ],
417
- "gtfsRealtimeExpirationSeconds": false
418
+ "gtfsRealtimeExpirationSeconds": 3600
418
419
  }
419
420
  ```
420
421
 
@@ -469,6 +470,22 @@ importGtfs({
469
470
  }
470
471
  ```
471
472
 
473
+ ### includeImportReport
474
+
475
+ {Boolean} When `true`, `importGtfs()` returns an `ImportReport` object containing details about the import (record counts, errors encountered, etc.) instead of returning `void`. Useful when combined with `ignoreErrors: true` to inspect what failed after a partial import. Defaults to `false`.
476
+
477
+ ```js
478
+ import { importGtfs } from 'gtfs';
479
+
480
+ const report = await importGtfs({
481
+ agencies: [{ path: '/path/to/gtfs' }],
482
+ ignoreErrors: true,
483
+ includeImportReport: true,
484
+ });
485
+
486
+ console.log(report.errors);
487
+ ```
488
+
472
489
  ### sqlitePath
473
490
 
474
491
  {String} A path to a SQLite database. Optional, defaults to using an in-memory database with a value of `:memory:`.
@@ -684,7 +701,7 @@ closeDb(db);
684
701
 
685
702
  ### Deleting a Database
686
703
 
687
- You can use `deleteDb` to delete a sqlite3 database from the filesystem.
704
+ You can use `deleteDb` to close and delete a database. For file-backed databases the file is removed from the filesystem. For in-memory databases (the default) the connection is closed and the internal reference is removed — no filesystem operation is performed.
688
705
 
689
706
  ```js
690
707
  import { deleteDb, openDb } from 'gtfs';
@@ -1050,7 +1067,7 @@ const trips = getTrips({
1050
1067
  const trips = getTrips({
1051
1068
  route_id: 'Lo-16APR',
1052
1069
  direction_id: 0,
1053
- service_id: '
1070
+ service_id: 'CT-16APR-Caltrain-Weekday-01',
1054
1071
  });
1055
1072
 
1056
1073
  /*
@@ -1529,15 +1546,39 @@ In order to use GTFS-Realtime query methods, you must first run the [GTFS-Realti
1529
1546
 
1530
1547
  #### getServiceAlerts(query, fields, sortBy, options)
1531
1548
 
1532
- Returns an array of GTFS Realtime service alerts that match query parameters. Note that this does not refresh the data from GTFS-Realtime feeds, it only fetches what is stored in the database. In order to fetch the latest service alerts from GTFS-Realtime feeds and store in your database, use the [GTFS-Realtime update script or function](#gtfsrealtime-update-script).
1549
+ Returns an array of GTFS Realtime service alerts that match query parameters. Each alert includes a nested `informed_entities` array containing all related informed entities (stops, routes, trips) that the alert applies to. Note that this does not refresh the data from GTFS-Realtime feeds, it only fetches what is stored in the database. In order to fetch the latest service alerts from GTFS-Realtime feeds and store in your database, use the [GTFS-Realtime update script or function](#gtfsrealtime-update-script).
1533
1550
 
1534
1551
  [More details on Service Alerts](https://gtfs.org/realtime/feed-entities/service-alerts/)
1535
1552
 
1553
+ Each alert has an `informed_entities` array containing all stops, routes, and trips the alert applies to. The `active_period` field is a JSON-serialised array of `{start, end}` Unix timestamp objects representing when the alert is active. The convenience fields `start_time` and `end_time` contain the start and end of the first active period (or `null` if none is set).
1554
+
1536
1555
  ```js
1537
1556
  import { getServiceAlerts } from 'gtfs';
1538
1557
 
1539
- // Get service alerts
1558
+ // Get all service alerts
1540
1559
  const serviceAlerts = getServiceAlerts();
1560
+
1561
+ // Get alerts affecting a specific stop
1562
+ const stopAlerts = getServiceAlerts({ stop_id: 'STOP_ID' });
1563
+
1564
+ // Get alerts affecting a specific route
1565
+ const routeAlerts = getServiceAlerts({ route_id: 'ROUTE_ID' });
1566
+ ```
1567
+
1568
+ #### getServiceAlertInformedEntities(query, fields, sortBy, options)
1569
+
1570
+ Returns an array of GTFS Realtime service alert informed entities that match query parameters. Each row represents a single entity (stop, route, trip, etc.) that a service alert applies to, linked back to its alert via `alert_id`. Use this for direct access to the `service_alert_informed_entities` table; use `getServiceAlerts()` to get alerts with all informed entities already nested.
1571
+
1572
+ [More details on Service Alert Informed Entities](https://gtfs.org/realtime/feed-entities/service-alerts/#entityselector)
1573
+
1574
+ ```js
1575
+ import { getServiceAlertInformedEntities } from 'gtfs';
1576
+
1577
+ // Get all service alert informed entities
1578
+ const informedEntities = getServiceAlertInformedEntities();
1579
+
1580
+ // Get all informed entities for a specific alert
1581
+ const informedEntities = getServiceAlertInformedEntities({ alert_id: 'some-alert-id' });
1541
1582
  ```
1542
1583
 
1543
1584
  #### getTripUpdates(query, fields, sortBy, options)
@@ -1714,6 +1755,22 @@ const riderships = getRidership({
1714
1755
  });
1715
1756
  ```
1716
1757
 
1758
+ #### getRiderCategories(query, fields, sortBy, options)
1759
+
1760
+ Returns an array of rider categories that match query parameters. [Details on rider_categories.txt](http://gtfsride.org/specification#rider_categoriestxt)
1761
+
1762
+ ```js
1763
+ import { getRiderCategories } from 'gtfs';
1764
+
1765
+ // Get all rider categories
1766
+ const riderCategories = getRiderCategories();
1767
+
1768
+ // Get a specific rider category
1769
+ const riderCategories = getRiderCategories({
1770
+ rider_category_id: '1',
1771
+ });
1772
+ ```
1773
+
1717
1774
  #### getTripCapacities(query, fields, sortBy, options)
1718
1775
 
1719
1776
  Returns an array of trip_capacity that match query parameters. [Details on trip_capacity.txt](http://gtfsride.org/specification#trip_capacitytxt)
@@ -1799,10 +1856,10 @@ Returns an array of run_events that match query parameters. [Details on run_even
1799
1856
  import { getRunEvents } from 'gtfs';
1800
1857
 
1801
1858
  // Get all run_events
1802
- const runEvents = runEvents();
1859
+ const runEvents = getRunEvents();
1803
1860
 
1804
- // Get a run_events for a specific piece
1805
- const runEvents = runEvents({
1861
+ // Get run_events for a specific piece
1862
+ const runEvents = getRunEvents({
1806
1863
  piece_id: '123',
1807
1864
  });
1808
1865
  ```
@@ -1114,6 +1114,7 @@ var routes = {
1114
1114
  {
1115
1115
  name: "agency_id",
1116
1116
  type: "text",
1117
+ index: true,
1117
1118
  prefix: true
1118
1119
  },
1119
1120
  {
@@ -1366,7 +1367,8 @@ var stops = {
1366
1367
  },
1367
1368
  {
1368
1369
  name: "stop_code",
1369
- type: "text"
1370
+ type: "text",
1371
+ index: true
1370
1372
  },
1371
1373
  {
1372
1374
  name: "stop_name",
@@ -2868,16 +2870,14 @@ var serviceAlerts = {
2868
2870
  {
2869
2871
  name: "start_time",
2870
2872
  type: "text",
2871
- required: true,
2872
2873
  source: "alert.activePeriod[0].start",
2873
- default: ""
2874
+ default: null
2874
2875
  },
2875
2876
  {
2876
2877
  name: "end_time",
2877
2878
  type: "text",
2878
- required: true,
2879
2879
  source: "alert.activePeriod[0].end",
2880
- default: ""
2880
+ default: null
2881
2881
  },
2882
2882
  {
2883
2883
  name: "header_text",
@@ -2937,7 +2937,7 @@ var serviceAlertInformedEntities = {
2937
2937
  {
2938
2938
  name: "stop_id",
2939
2939
  type: "text",
2940
- index: true,
2940
+ primary: true,
2941
2941
  source: "stopId",
2942
2942
  default: null,
2943
2943
  prefix: true
@@ -2945,7 +2945,7 @@ var serviceAlertInformedEntities = {
2945
2945
  {
2946
2946
  name: "route_id",
2947
2947
  type: "text",
2948
- index: true,
2948
+ primary: true,
2949
2949
  source: "routeId",
2950
2950
  default: null,
2951
2951
  prefix: true
@@ -2953,14 +2953,14 @@ var serviceAlertInformedEntities = {
2953
2953
  {
2954
2954
  name: "route_type",
2955
2955
  type: "integer",
2956
- index: true,
2956
+ primary: true,
2957
2957
  source: "routeType",
2958
2958
  default: null
2959
2959
  },
2960
2960
  {
2961
2961
  name: "trip_id",
2962
2962
  type: "text",
2963
- index: true,
2963
+ primary: true,
2964
2964
  source: "trip.tripId",
2965
2965
  default: null,
2966
2966
  prefix: true
@@ -2968,7 +2968,7 @@ var serviceAlertInformedEntities = {
2968
2968
  {
2969
2969
  name: "direction_id",
2970
2970
  type: "integer",
2971
- index: true,
2971
+ primary: true,
2972
2972
  source: "directionId",
2973
2973
  default: null
2974
2974
  },
@@ -3485,7 +3485,8 @@ var passengerEvents = {
3485
3485
  {
3486
3486
  name: "trip_stop_sequence",
3487
3487
  type: "integer",
3488
- min: 1
3488
+ min: 1,
3489
+ required: true
3489
3490
  },
3490
3491
  {
3491
3492
  name: "scheduled_stop_sequence",
@@ -3711,7 +3712,8 @@ var stopVisits = {
3711
3712
  },
3712
3713
  {
3713
3714
  name: "ramp_deployed_time",
3714
- type: "text"
3715
+ type: "real",
3716
+ min: 0
3715
3717
  },
3716
3718
  {
3717
3719
  name: "ramp_failure",
@@ -3719,12 +3721,12 @@ var stopVisits = {
3719
3721
  },
3720
3722
  {
3721
3723
  name: "kneel_deployed_time",
3722
- type: "integer",
3724
+ type: "real",
3723
3725
  min: 0
3724
3726
  },
3725
3727
  {
3726
3728
  name: "lift_deployed_time",
3727
- type: "integer",
3729
+ type: "real",
3728
3730
  min: 0
3729
3731
  },
3730
3732
  {