gtfs 4.18.7 → 4.19.1

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
  ```
@@ -1 +1 @@
1
- #!/usr/bin/env node
1
+ export { };