@tmlmobilidade/import-gtfs 20251010.1427.11 → 20251010.1633.52

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.
@@ -1,4 +1,4 @@
1
- import { SQLiteWriter } from '@tmlmobilidade/connectors';
1
+ import { type SQLiteTableInstance } from '@tmlmobilidade/connectors';
2
2
  import { type GTFS_Route_Extended, type GTFS_Shape, type GTFS_Stop_Extended, type GTFS_StopTime, type GTFS_Trip_Extended, type Plan } from '@tmlmobilidade/types';
3
3
  import { type OperationalDate } from '@tmlmobilidade/types';
4
4
  /**
@@ -18,11 +18,11 @@ export interface ImportGtfsToDatabaseConfig {
18
18
  */
19
19
  export interface GtfsSQLTables {
20
20
  calendar_dates: Map<string, OperationalDate[]>;
21
- routes: SQLiteWriter<GTFS_Route_Extended>;
22
- shapes: SQLiteWriter<GTFS_Shape>;
23
- stop_times: SQLiteWriter<GTFS_StopTime>;
24
- stops: SQLiteWriter<GTFS_Stop_Extended>;
25
- trips: SQLiteWriter<GTFS_Trip_Extended>;
21
+ routes: SQLiteTableInstance<GTFS_Route_Extended>;
22
+ shapes: SQLiteTableInstance<GTFS_Shape>;
23
+ stop_times: SQLiteTableInstance<GTFS_StopTime>;
24
+ stops: SQLiteTableInstance<GTFS_Stop_Extended>;
25
+ trips: SQLiteTableInstance<GTFS_Trip_Extended>;
26
26
  }
27
27
  /**
28
28
  * Context object used throughout the GTFS import process.
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { SQLiteWriter } from '@tmlmobilidade/connectors';
2
+ import { SQLiteDatabase } from '@tmlmobilidade/connectors';
3
3
  /**
4
4
  * Initializes GTFS SQL tables and writers.
5
5
  * @returns An object containing initialized GTFS SQL tables and writers.
@@ -7,7 +7,8 @@ import { SQLiteWriter } from '@tmlmobilidade/connectors';
7
7
  export function initGtfsSqlTables() {
8
8
  //
9
9
  const calendarDatesMap = new Map();
10
- const tripsWriter = new SQLiteWriter({
10
+ const database = new SQLiteDatabase();
11
+ const tripsTable = database.registerTable('trips', {
11
12
  batch_size: 10000,
12
13
  columns: [
13
14
  { indexed: true, name: 'trip_id', not_null: true, primary_key: true, type: 'TEXT' },
@@ -23,7 +24,7 @@ export function initGtfsSqlTables() {
23
24
  { indexed: false, name: 'pattern_id', not_null: true, type: 'TEXT' },
24
25
  ],
25
26
  });
26
- const routesWriter = new SQLiteWriter({
27
+ const routesTable = database.registerTable('routes', {
27
28
  batch_size: 10000,
28
29
  columns: [
29
30
  { indexed: false, name: 'agency_id', not_null: true, type: 'TEXT' },
@@ -47,7 +48,7 @@ export function initGtfsSqlTables() {
47
48
  { indexed: false, name: 'school', type: 'INTEGER' },
48
49
  ],
49
50
  });
50
- const shapesWriter = new SQLiteWriter({
51
+ const shapesTable = database.registerTable('shapes', {
51
52
  batch_size: 100000,
52
53
  columns: [
53
54
  { indexed: true, name: 'shape_id', not_null: true, type: 'TEXT' },
@@ -57,7 +58,7 @@ export function initGtfsSqlTables() {
57
58
  { indexed: false, name: 'shape_dist_traveled', not_null: true, type: 'REAL' },
58
59
  ],
59
60
  });
60
- const stopsWriter = new SQLiteWriter({
61
+ const stopsTable = database.registerTable('stops', {
61
62
  batch_size: 10000,
62
63
  columns: [
63
64
  { indexed: false, name: 'level_id', type: 'TEXT' },
@@ -91,7 +92,7 @@ export function initGtfsSqlTables() {
91
92
  { indexed: false, name: 'tts_stop_name', type: 'TEXT' },
92
93
  ],
93
94
  });
94
- const stopTimesWriter = new SQLiteWriter({
95
+ const stopTimesTable = database.registerTable('stop_times', {
95
96
  batch_size: 100000,
96
97
  columns: [
97
98
  { indexed: false, name: 'arrival_time', not_null: true, type: 'TEXT' },
@@ -110,11 +111,11 @@ export function initGtfsSqlTables() {
110
111
  });
111
112
  return {
112
113
  calendar_dates: calendarDatesMap,
113
- routes: routesWriter,
114
- shapes: shapesWriter,
115
- stop_times: stopTimesWriter,
116
- stops: stopsWriter,
117
- trips: tripsWriter,
114
+ routes: routesTable,
115
+ shapes: shapesTable,
116
+ stop_times: stopTimesTable,
117
+ stops: stopsTable,
118
+ trips: tripsTable,
118
119
  };
119
120
  //
120
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/import-gtfs",
3
- "version": "20251010.1427.11",
3
+ "version": "20251010.1633.52",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",