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.
@@ -221,8 +221,6 @@ var model3 = {
221
221
  {
222
222
  name: "attribution_id",
223
223
  type: "text",
224
- primary: true,
225
- required: true,
226
224
  prefix: true
227
225
  },
228
226
  {
@@ -3282,54 +3280,6 @@ var models_default = models;
3282
3280
  // src/lib/db.ts
3283
3281
  import Database from "better-sqlite3";
3284
3282
  import untildify2 from "untildify";
3285
-
3286
- // src/lib/utils.ts
3287
- import sqlString from "sqlstring-sqlite";
3288
- import Long from "long";
3289
- function validateConfigForImport(config) {
3290
- if (!config.agencies || config.agencies.length === 0) {
3291
- throw new Error("No `agencies` specified in config");
3292
- }
3293
- for (const [index, agency] of config.agencies.entries()) {
3294
- if (!agency.path && !agency.url) {
3295
- throw new Error(
3296
- `No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
3297
- );
3298
- }
3299
- }
3300
- return config;
3301
- }
3302
- function setDefaultConfig(initialConfig) {
3303
- const defaults = {
3304
- sqlitePath: ":memory:",
3305
- ignoreDuplicates: false,
3306
- gtfsRealtimeExpirationSeconds: 0
3307
- };
3308
- return {
3309
- ...defaults,
3310
- ...initialConfig
3311
- };
3312
- }
3313
- function convertLongTimeToDate(longDate) {
3314
- const { high, low, unsigned } = longDate;
3315
- return new Date(new Long(low, high, unsigned).toInt() * 1e3).toISOString();
3316
- }
3317
- function calculateSecondsFromMidnight(time) {
3318
- const split = time.split(":").map((d) => Number.parseInt(d, 10));
3319
- if (split.length !== 3) {
3320
- return null;
3321
- }
3322
- return split[0] * 3600 + split[1] * 60 + split[2];
3323
- }
3324
- function padLeadingZeros(time) {
3325
- const split = time.split(":").map((d) => String(Number(d)).padStart(2, "0"));
3326
- if (split.length !== 3) {
3327
- return null;
3328
- }
3329
- return split.join(":");
3330
- }
3331
-
3332
- // src/lib/db.ts
3333
3283
  var dbs = {};
3334
3284
  function setupDb(sqlitePath) {
3335
3285
  const db = new Database(untildify2(sqlitePath));
@@ -3341,7 +3291,7 @@ function setupDb(sqlitePath) {
3341
3291
  }
3342
3292
  function openDb(config = null) {
3343
3293
  if (config) {
3344
- const { sqlitePath, db } = setDefaultConfig(config);
3294
+ const { sqlitePath = ":memory:", db } = config;
3345
3295
  if (db) {
3346
3296
  return db;
3347
3297
  }
@@ -3350,6 +3300,9 @@ function openDb(config = null) {
3350
3300
  }
3351
3301
  return setupDb(sqlitePath);
3352
3302
  }
3303
+ if (Object.keys(dbs).length === 0) {
3304
+ return setupDb(":memory:");
3305
+ }
3353
3306
  if (Object.keys(dbs).length === 1) {
3354
3307
  const filename = Object.keys(dbs)[0];
3355
3308
  return dbs[filename];
@@ -3399,6 +3352,52 @@ function isValidJSON(string) {
3399
3352
  return true;
3400
3353
  }
3401
3354
 
3355
+ // src/lib/utils.ts
3356
+ import sqlString from "sqlstring-sqlite";
3357
+ import Long from "long";
3358
+ function validateConfigForImport(config) {
3359
+ if (!config.agencies || config.agencies.length === 0) {
3360
+ throw new Error("No `agencies` specified in config");
3361
+ }
3362
+ for (const [index, agency] of config.agencies.entries()) {
3363
+ if (!agency.path && !agency.url) {
3364
+ throw new Error(
3365
+ `No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
3366
+ );
3367
+ }
3368
+ }
3369
+ return config;
3370
+ }
3371
+ function setDefaultConfig(initialConfig) {
3372
+ const defaults = {
3373
+ sqlitePath: ":memory:",
3374
+ ignoreDuplicates: false,
3375
+ gtfsRealtimeExpirationSeconds: 0
3376
+ };
3377
+ return {
3378
+ ...defaults,
3379
+ ...initialConfig
3380
+ };
3381
+ }
3382
+ function convertLongTimeToDate(longDate) {
3383
+ const { high, low, unsigned } = longDate;
3384
+ return new Date(new Long(low, high, unsigned).toInt() * 1e3).toISOString();
3385
+ }
3386
+ function calculateSecondsFromMidnight(time) {
3387
+ const split = time.split(":").map((d) => Number.parseInt(d, 10));
3388
+ if (split.length !== 3) {
3389
+ return null;
3390
+ }
3391
+ return split[0] * 3600 + split[1] * 60 + split[2];
3392
+ }
3393
+ function padLeadingZeros(time) {
3394
+ const split = time.split(":").map((d) => String(Number(d)).padStart(2, "0"));
3395
+ if (split.length !== 3) {
3396
+ return null;
3397
+ }
3398
+ return split.join(":");
3399
+ }
3400
+
3402
3401
  // src/lib/import.ts
3403
3402
  var downloadFiles = async (task) => {
3404
3403
  task.log(`Downloading GTFS from ${task.agency_url}`);
@@ -3489,8 +3488,7 @@ var updateRealtimeData = async (task) => {
3489
3488
  return;
3490
3489
  }
3491
3490
  const db = openDb({
3492
- sqlitePath: task.sqlitePath,
3493
- agencies: []
3491
+ sqlitePath: task.sqlitePath
3494
3492
  });
3495
3493
  const vehiclePositionsModel = models_default.find(
3496
3494
  (x) => x.filenameBase === "vehicle_positions"
@@ -3731,8 +3729,7 @@ var formatLine = (line, model56, totalLineCount) => {
3731
3729
  };
3732
3730
  var importLines = (task, lines, model56, totalLineCount) => {
3733
3731
  const db = openDb({
3734
- sqlitePath: task.sqlitePath,
3735
- agencies: []
3732
+ sqlitePath: task.sqlitePath
3736
3733
  });
3737
3734
  if (lines.length === 0) {
3738
3735
  return;