gtfs 4.13.0 → 4.13.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.
@@ -213,8 +213,6 @@ var model3 = {
213
213
  {
214
214
  name: "attribution_id",
215
215
  type: "text",
216
- primary: true,
217
- required: true,
218
216
  prefix: true
219
217
  },
220
218
  {
@@ -3274,40 +3272,6 @@ var models_default = models;
3274
3272
  // src/lib/db.ts
3275
3273
  import Database from "better-sqlite3";
3276
3274
  import untildify2 from "untildify";
3277
-
3278
- // src/lib/utils.ts
3279
- import sqlString from "sqlstring-sqlite";
3280
- import Long from "long";
3281
- function validateConfigForImport(config) {
3282
- if (!config.agencies || config.agencies.length === 0) {
3283
- throw new Error("No `agencies` specified in config");
3284
- }
3285
- for (const [index, agency] of config.agencies.entries()) {
3286
- if (!agency.path && !agency.url) {
3287
- throw new Error(
3288
- `No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
3289
- );
3290
- }
3291
- }
3292
- return config;
3293
- }
3294
- function setDefaultConfig(initialConfig) {
3295
- const defaults = {
3296
- sqlitePath: ":memory:",
3297
- ignoreDuplicates: false,
3298
- gtfsRealtimeExpirationSeconds: 0
3299
- };
3300
- return {
3301
- ...defaults,
3302
- ...initialConfig
3303
- };
3304
- }
3305
- function convertLongTimeToDate(longDate) {
3306
- const { high, low, unsigned } = longDate;
3307
- return new Date(new Long(low, high, unsigned).toInt() * 1e3).toISOString();
3308
- }
3309
-
3310
- // src/lib/db.ts
3311
3275
  var dbs = {};
3312
3276
  function setupDb(sqlitePath) {
3313
3277
  const db = new Database(untildify2(sqlitePath));
@@ -3319,7 +3283,7 @@ function setupDb(sqlitePath) {
3319
3283
  }
3320
3284
  function openDb(config = null) {
3321
3285
  if (config) {
3322
- const { sqlitePath, db } = setDefaultConfig(config);
3286
+ const { sqlitePath = ":memory:", db } = config;
3323
3287
  if (db) {
3324
3288
  return db;
3325
3289
  }
@@ -3328,6 +3292,9 @@ function openDb(config = null) {
3328
3292
  }
3329
3293
  return setupDb(sqlitePath);
3330
3294
  }
3295
+ if (Object.keys(dbs).length === 0) {
3296
+ return setupDb(":memory:");
3297
+ }
3331
3298
  if (Object.keys(dbs).length === 1) {
3332
3299
  const filename = Object.keys(dbs)[0];
3333
3300
  return dbs[filename];
@@ -3352,6 +3319,38 @@ import {
3352
3319
  } from "lodash-es";
3353
3320
  import { feature, featureCollection } from "@turf/helpers";
3354
3321
 
3322
+ // src/lib/utils.ts
3323
+ import sqlString from "sqlstring-sqlite";
3324
+ import Long from "long";
3325
+ function validateConfigForImport(config) {
3326
+ if (!config.agencies || config.agencies.length === 0) {
3327
+ throw new Error("No `agencies` specified in config");
3328
+ }
3329
+ for (const [index, agency] of config.agencies.entries()) {
3330
+ if (!agency.path && !agency.url) {
3331
+ throw new Error(
3332
+ `No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
3333
+ );
3334
+ }
3335
+ }
3336
+ return config;
3337
+ }
3338
+ function setDefaultConfig(initialConfig) {
3339
+ const defaults = {
3340
+ sqlitePath: ":memory:",
3341
+ ignoreDuplicates: false,
3342
+ gtfsRealtimeExpirationSeconds: 0
3343
+ };
3344
+ return {
3345
+ ...defaults,
3346
+ ...initialConfig
3347
+ };
3348
+ }
3349
+ function convertLongTimeToDate(longDate) {
3350
+ const { high, low, unsigned } = longDate;
3351
+ return new Date(new Long(low, high, unsigned).toInt() * 1e3).toISOString();
3352
+ }
3353
+
3355
3354
  // src/lib/import.ts
3356
3355
  var downloadGtfsRealtimeData = async (url, task) => {
3357
3356
  const response = await fetch(url, {
@@ -3448,8 +3447,7 @@ var updateRealtimeData = async (task) => {
3448
3447
  return;
3449
3448
  }
3450
3449
  const db = openDb({
3451
- sqlitePath: task.sqlitePath,
3452
- agencies: []
3450
+ sqlitePath: task.sqlitePath
3453
3451
  });
3454
3452
  const vehiclePositionsModel = models_default.find(
3455
3453
  (x) => x.filenameBase === "vehicle_positions"