@tmlmobilidade/go-interfaces-labdb 20260722.1043.2 → 20260723.1350.16

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,8 +1,9 @@
1
1
  import { ClickHouseInterfaceTemplate } from '../interface.template.js';
2
2
  import { ClickHouseClient } from '@tmlmobilidade/go-clients-clickhouse';
3
- import { type SimplifiedVehicleEvent } from '@tmlmobilidade/types';
3
+ import { type SimplifiedVehicleEvent } from '@tmlmobilidade/go-types-vehicle-events';
4
4
  export declare class OperationDatabase {
5
5
  readonly vehicleEvents: ClickHouseInterfaceTemplate<SimplifiedVehicleEvent>;
6
6
  private readonly databaseName;
7
7
  constructor(instance: ClickHouseClient);
8
+ init(): Promise<void>;
8
9
  }
@@ -1,21 +1,20 @@
1
1
  /* * */
2
2
  import { ClickHouseInterfaceTemplate } from '../interface.template.js';
3
- import { simplifiedVehicleEventSchema } from '../types/operation.js';
3
+ import { simplifiedVehicleEventTableSchema } from '../schemas/operation.js';
4
4
  /* * */
5
5
  export class OperationDatabase {
6
6
  //
7
- //
8
- // Collections
9
7
  vehicleEvents;
10
- //
11
8
  databaseName = 'operation';
12
9
  constructor(instance) {
13
- // Create collection interfaces
14
- this.vehicleEvents = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'simplified_vehicle_events', simplifiedVehicleEventSchema, {
10
+ this.vehicleEvents = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'simplified_vehicle_events', simplifiedVehicleEventTableSchema, {
15
11
  engine: 'ReplacingMergeTree(created_at)',
16
12
  orderBy: ['operational_date', 'trip_id', 'vehicle_id', 'agency_id', 'created_at'],
17
13
  partitionBy: 'toYYYYMM(fromUnixTimestamp64Milli(created_at))',
18
14
  primaryKey: ['operational_date', 'trip_id', 'vehicle_id'],
19
15
  });
20
16
  }
17
+ async init() {
18
+ await this.vehicleEvents.init();
19
+ }
21
20
  }
@@ -5,4 +5,5 @@ export declare class PerformanceDatabase {
5
5
  readonly demandByAgencyByOperationalDate: ClickHouseInterfaceTemplate<DemandByAgencyByOperationalDate>;
6
6
  private readonly databaseName;
7
7
  constructor(instance: ClickHouseClient);
8
+ init(): Promise<void>;
8
9
  }
@@ -1,21 +1,19 @@
1
1
  /* * */
2
2
  import { ClickHouseInterfaceTemplate } from '../interface.template.js';
3
- import { demandByAgencyByOperationalDateSchema } from '../types/performance.js';
3
+ import { demandByAgencyByOperationalDateTableSchema } from '../schemas/performance.js';
4
4
  /* * */
5
5
  export class PerformanceDatabase {
6
6
  //
7
- //
8
- // Tables
9
7
  demandByAgencyByOperationalDate;
10
- //
11
8
  databaseName = 'performance';
12
9
  constructor(instance) {
13
- //
14
- // Create the table interfaces
15
- this.demandByAgencyByOperationalDate = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'demand_by_agency_by_operational_date', demandByAgencyByOperationalDateSchema, {
10
+ this.demandByAgencyByOperationalDate = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'demand_by_agency_by_operational_date', demandByAgencyByOperationalDateTableSchema, {
16
11
  engine: 'ReplacingMergeTree(updated_at)',
17
12
  orderBy: ['operational_date', 'agency_id'],
18
13
  partitionBy: 'intDiv(operational_date, 100)',
19
14
  });
20
15
  }
16
+ async init() {
17
+ await this.demandByAgencyByOperationalDate.init();
18
+ }
21
19
  }
@@ -10,5 +10,6 @@ export declare class SimplifiedApexDatabase {
10
10
  readonly sales: ClickHouseInterfaceTemplate<SimplifiedApexOnBoardSale>;
11
11
  readonly validations: ClickHouseInterfaceTemplate<SimplifiedApexValidation>;
12
12
  private readonly databaseName;
13
- constructor(instance: ClickHouseClient);
13
+ constructor(client: ClickHouseClient);
14
+ init(): Promise<void>;
14
15
  }
@@ -1,11 +1,9 @@
1
1
  /* * */
2
2
  import { ClickHouseInterfaceTemplate } from '../interface.template.js';
3
- import { simplifiedApexBankingTapSchema, simplifiedApexInspectionDecisionSchema, simplifiedApexInspectionSchema, simplifiedApexLocationSchema, simplifiedApexOnBoardRefundSchema, simplifiedApexOnBoardSaleSchema, simplifiedApexValidationSchema } from '../types/simplified-apex.js';
3
+ import { simplifiedApexBankingTapTableSchema, simplifiedApexInspectionDecisionTableSchema, simplifiedApexInspectionTableSchema, simplifiedApexLocationTableSchema, simplifiedApexOnBoardRefundTableSchema, simplifiedApexOnBoardSaleTableSchema, simplifiedApexValidationTableSchema } from '../schemas/simplified-apex.js';
4
4
  /* * */
5
5
  export class SimplifiedApexDatabase {
6
6
  //
7
- //
8
- // Tables
9
7
  bankingTaps;
10
8
  inspectionDecisions;
11
9
  inspections;
@@ -13,23 +11,31 @@ export class SimplifiedApexDatabase {
13
11
  refunds;
14
12
  sales;
15
13
  validations;
16
- //
17
14
  databaseName = 'simplified_apex';
18
- constructor(instance) {
15
+ constructor(client) {
19
16
  //
20
- // Setup the table options, as they are the same for all simplified APEX tables
21
17
  const simplifiedTableOptions = {
22
18
  engine: 'ReplacingMergeTree(updated_at)',
23
19
  orderBy: ['agency_id', 'operational_date', 'created_at', '_id'],
24
20
  partitionBy: 'intDiv(operational_date, 100)',
25
21
  };
26
- // Create the table interfaces
27
- this.bankingTaps = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'banking_taps', simplifiedApexBankingTapSchema, simplifiedTableOptions);
28
- this.inspectionDecisions = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'inspection_decisions', simplifiedApexInspectionDecisionSchema, simplifiedTableOptions);
29
- this.inspections = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'inspections', simplifiedApexInspectionSchema, simplifiedTableOptions);
30
- this.locations = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'locations', simplifiedApexLocationSchema, simplifiedTableOptions);
31
- this.refunds = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'refunds', simplifiedApexOnBoardRefundSchema, simplifiedTableOptions);
32
- this.sales = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'sales', simplifiedApexOnBoardSaleSchema, simplifiedTableOptions);
33
- this.validations = new ClickHouseInterfaceTemplate(instance, this.databaseName, 'validations', simplifiedApexValidationSchema, simplifiedTableOptions);
22
+ this.bankingTaps = new ClickHouseInterfaceTemplate(client, this.databaseName, 'banking_taps', simplifiedApexBankingTapTableSchema, simplifiedTableOptions);
23
+ this.inspectionDecisions = new ClickHouseInterfaceTemplate(client, this.databaseName, 'inspection_decisions', simplifiedApexInspectionDecisionTableSchema, simplifiedTableOptions);
24
+ this.inspections = new ClickHouseInterfaceTemplate(client, this.databaseName, 'inspections', simplifiedApexInspectionTableSchema, simplifiedTableOptions);
25
+ this.locations = new ClickHouseInterfaceTemplate(client, this.databaseName, 'locations', simplifiedApexLocationTableSchema, simplifiedTableOptions);
26
+ this.refunds = new ClickHouseInterfaceTemplate(client, this.databaseName, 'refunds', simplifiedApexOnBoardRefundTableSchema, simplifiedTableOptions);
27
+ this.sales = new ClickHouseInterfaceTemplate(client, this.databaseName, 'sales', simplifiedApexOnBoardSaleTableSchema, simplifiedTableOptions);
28
+ this.validations = new ClickHouseInterfaceTemplate(client, this.databaseName, 'validations', simplifiedApexValidationTableSchema, simplifiedTableOptions);
29
+ }
30
+ async init() {
31
+ await Promise.all([
32
+ this.bankingTaps.init(),
33
+ this.inspectionDecisions.init(),
34
+ this.inspections.init(),
35
+ this.locations.init(),
36
+ this.refunds.init(),
37
+ this.sales.init(),
38
+ this.validations.init(),
39
+ ]);
34
40
  }
35
41
  }
package/dist/index.d.ts CHANGED
@@ -1,20 +1,27 @@
1
- import { queryFromFile, queryFromString } from '@tmlmobilidade/go-clients-clickhouse';
1
+ import { ClickHouseClient, queryFromFile, queryFromString } from '@tmlmobilidade/go-clients-clickhouse';
2
2
  import { OperationDatabase } from './databases/operation.js';
3
3
  import { PerformanceDatabase } from './databases/performance.js';
4
4
  import { SimplifiedApexDatabase } from './databases/simplified-apex.js';
5
5
  declare class LabDbClass {
6
6
  private static _instance;
7
- private readonly clickhouseClient;
8
7
  readonly operation: OperationDatabase;
9
8
  readonly performance: PerformanceDatabase;
10
9
  readonly simplifiedApex: SimplifiedApexDatabase;
10
+ private readonly clickhouseClient;
11
+ private constructor();
11
12
  /**
12
- * Establishes a connection to the Mongo database and initializes the collection.
13
- * @param options Optional Mongo client connection options.
14
- * @throws Error if the environment variable for the database URI is missing or if the connection fails.
13
+ * Returns the singleton instance.
14
+ * Concurrent callers share the same initialization promise so schema setup runs once.
15
15
  */
16
16
  static getInstance(): Promise<LabDbClass>;
17
- private constructor();
17
+ /**
18
+ * Returns the ClickHouse client.
19
+ * @returns The ClickHouse client.
20
+ * @deprecated Avoid using this method directly. Find alternative ways
21
+ * to query the database using the database-specific methods instead.
22
+ */
23
+ getClient(): Promise<ClickHouseClient>;
24
+ private init;
18
25
  /**
19
26
  * Executes a query from a .sql file with optional parameter substitutions.
20
27
  * @param filePath Absolute or relative path to the .sql file.
package/dist/index.js CHANGED
@@ -7,37 +7,50 @@ import { SimplifiedApexDatabase } from './databases/simplified-apex.js';
7
7
  /* * */
8
8
  class LabDbClass {
9
9
  //
10
- //
11
- //
12
- static _instance;
13
- clickhouseClient;
14
- //
15
- // Databases
10
+ static _instance = null;
16
11
  operation;
17
12
  performance;
18
13
  simplifiedApex;
14
+ clickhouseClient;
15
+ constructor(client) {
16
+ this.clickhouseClient = client;
17
+ this.operation = new OperationDatabase(this.clickhouseClient);
18
+ this.performance = new PerformanceDatabase(this.clickhouseClient);
19
+ this.simplifiedApex = new SimplifiedApexDatabase(this.clickhouseClient);
20
+ }
19
21
  /**
20
- * Establishes a connection to the Mongo database and initializes the collection.
21
- * @param options Optional Mongo client connection options.
22
- * @throws Error if the environment variable for the database URI is missing or if the connection fails.
22
+ * Returns the singleton instance.
23
+ * Concurrent callers share the same initialization promise so schema setup runs once.
23
24
  */
24
25
  static async getInstance() {
25
26
  if (!LabDbClass._instance) {
26
- const clickhouseClient = await ClickHouseDatabaseClient.getClient({ prefix: 'LABDB' });
27
- LabDbClass._instance = new LabDbClass(clickhouseClient);
27
+ LabDbClass._instance = (async () => {
28
+ const clickhouseClient = await ClickHouseDatabaseClient.getClient({ prefix: 'LABDB', tunnelType: 'GO' });
29
+ const instance = new LabDbClass(clickhouseClient);
30
+ // Behaves like an async constructor: create DBs/tables before the proxy exposes the instance.
31
+ await instance.init();
32
+ return instance;
33
+ })();
28
34
  }
29
- return LabDbClass._instance;
35
+ return await LabDbClass._instance;
30
36
  }
31
- //
32
- // Constructor
33
- constructor(clickhouseClient) {
34
- this.clickhouseClient = clickhouseClient;
35
- this.operation = new OperationDatabase(this.clickhouseClient);
36
- this.performance = new PerformanceDatabase(this.clickhouseClient);
37
- this.simplifiedApex = new SimplifiedApexDatabase(this.clickhouseClient);
37
+ /**
38
+ * Returns the ClickHouse client.
39
+ * @returns The ClickHouse client.
40
+ * @deprecated Avoid using this method directly. Find alternative ways
41
+ * to query the database using the database-specific methods instead.
42
+ */
43
+ async getClient() {
44
+ const instance = await LabDbClass.getInstance();
45
+ return instance.clickhouseClient;
46
+ }
47
+ async init() {
48
+ await Promise.all([
49
+ this.operation.init(),
50
+ this.performance.init(),
51
+ this.simplifiedApex.init(),
52
+ ]);
38
53
  }
39
- //
40
- // Queries
41
54
  /**
42
55
  * Executes a query from a .sql file with optional parameter substitutions.
43
56
  * @param filePath Absolute or relative path to the .sql file.
@@ -70,4 +83,5 @@ class LabDbClass {
70
83
  return await queryFromString(this.clickhouseClient, query, params);
71
84
  }
72
85
  }
86
+ /* * */
73
87
  export const labDb = asyncSingletonProxy(LabDbClass);
@@ -1,4 +1,4 @@
1
- import type { ClickHouseClient, ClickhouseField, ClickHouseTableEngine, ClickHouseTableSchema, DataFormat } from '@tmlmobilidade/go-clients-clickhouse';
1
+ import { type ClickHouseClient, type ClickhouseField, type ClickHouseTableEngine, type ClickHouseTableSchema, type DataFormat } from '@tmlmobilidade/go-clients-clickhouse';
2
2
  import { queryFromFile, queryFromString } from '@tmlmobilidade/go-clients-clickhouse';
3
3
  export interface ClickhouseInterfaceTableOptions<T extends object> {
4
4
  engine?: ClickHouseTableEngine<T>;
@@ -74,13 +74,12 @@ export declare class ClickHouseInterfaceTemplate<T extends object> {
74
74
  */
75
75
  select(select: string, where: string, params?: Record<string, number | string>): Promise<T[]>;
76
76
  /**
77
- * Initializes the ClickHouse client and ensures that the specified database and table exist.
78
- * This method should be called before performing any operations on the database or table.
79
- * It handles the asynchronous setup process and logs any errors that occur during initialization.
80
- * @throws Will throw an error if the client initialization or database/table setup fails.
77
+ * Ensures that the specified database and table exist.
78
+ * Called by `LabDbClass.getInstance()` before the singleton is exposed via `asyncSingletonProxy`.
79
+ * @throws Will throw an error if database/table setup fails.
81
80
  * @returns A promise that resolves when the initialization process is complete.
82
81
  */
83
- protected init(): Promise<void>;
82
+ init(): Promise<void>;
84
83
  /**
85
84
  * Optional override for custom setup logic:
86
85
  * indexes, materialized views, constraints, etc.
@@ -113,6 +112,13 @@ export declare class ClickHouseInterfaceTemplate<T extends object> {
113
112
  * );
114
113
  */
115
114
  queryFromString<T>(query: string, params?: Record<string, number | string>): ReturnType<typeof queryFromString<T>>;
115
+ /**
116
+ * Ensures that the specified database exists in ClickHouse, creating it if it does not already exist.
117
+ * This method performs input validation to prevent SQL injection and logs the outcome of the operation.
118
+ * It constructs a CREATE DATABASE query and executes it using the client.
119
+ * @throws Will throw an error if any of the inputs are unsafe or if the database creation query fails.
120
+ * @returns A promise that resolves when the database is ensured to exist.
121
+ */
116
122
  private ensureDatabase;
117
123
  /**
118
124
  * Ensures that the specified table exists in ClickHouse, creating it if it does not already exist.
@@ -26,10 +26,6 @@ export class ClickHouseInterfaceTemplate {
26
26
  partitionBy: options.partitionBy ?? undefined,
27
27
  primaryKey: options.primaryKey ?? undefined,
28
28
  };
29
- this.init().catch((error) => {
30
- Logger.error({ error, message: `LABDB [${this.databaseName}."${this.tableName}"]: Error @ constructor(): ${error.message}` });
31
- throw error;
32
- });
33
29
  }
34
30
  /**
35
31
  * Executes a COUNT query on the ClickHouse table using the service's client.
@@ -73,8 +69,6 @@ export class ClickHouseInterfaceTemplate {
73
69
  * @warning Use with caution: direct access to the client allows for executing arbitrary queries.
74
70
  */
75
71
  async getClient() {
76
- if (!this.client)
77
- await this.init();
78
72
  return this.client;
79
73
  }
80
74
  /**
@@ -113,16 +107,12 @@ export class ClickHouseInterfaceTemplate {
113
107
  return await queryFromString(this.client, `SELECT ${select} FROM "${this.databaseName}"."${this.tableName}" WHERE ${where}`, params);
114
108
  }
115
109
  /**
116
- * Initializes the ClickHouse client and ensures that the specified database and table exist.
117
- * This method should be called before performing any operations on the database or table.
118
- * It handles the asynchronous setup process and logs any errors that occur during initialization.
119
- * @throws Will throw an error if the client initialization or database/table setup fails.
110
+ * Ensures that the specified database and table exist.
111
+ * Called by `LabDbClass.getInstance()` before the singleton is exposed via `asyncSingletonProxy`.
112
+ * @throws Will throw an error if database/table setup fails.
120
113
  * @returns A promise that resolves when the initialization process is complete.
121
114
  */
122
115
  async init() {
123
- // Skip if already initialized
124
- if (this.client)
125
- return;
126
116
  // Validate required properties before attempting to connect
127
117
  if (!this.databaseName)
128
118
  throw new Error('CLICKHOUSE: databaseName is required.');
@@ -134,9 +124,9 @@ export class ClickHouseInterfaceTemplate {
134
124
  // Only own the schema when this interface is the source of truth.
135
125
  // External DDL owners (see `manageSchema`) skip this entirely.
136
126
  if (this.tableOptions.manageSchema) {
137
- await this.ensureDatabase();
138
127
  await this.ensureTable();
139
128
  }
129
+ // Run any additional setup logic
140
130
  await this.postInit();
141
131
  }
142
132
  /**
@@ -177,6 +167,13 @@ export class ClickHouseInterfaceTemplate {
177
167
  async queryFromString(query, params) {
178
168
  return await queryFromString(this.client, query, params);
179
169
  }
170
+ /**
171
+ * Ensures that the specified database exists in ClickHouse, creating it if it does not already exist.
172
+ * This method performs input validation to prevent SQL injection and logs the outcome of the operation.
173
+ * It constructs a CREATE DATABASE query and executes it using the client.
174
+ * @throws Will throw an error if any of the inputs are unsafe or if the database creation query fails.
175
+ * @returns A promise that resolves when the database is ensured to exist.
176
+ */
180
177
  async ensureDatabase() {
181
178
  // Validate the inputs are safe identifiers to prevent SQL injection
182
179
  if (!validateSqlParam(this.databaseName, false))
@@ -213,7 +210,9 @@ export class ClickHouseInterfaceTemplate {
213
210
  // Setup the full CREATE TABLE query
214
211
  const createTableQuery = `
215
212
  CREATE TABLE IF NOT EXISTS "${this.databaseName}"."${this.tableName}" (
216
- ${Object.entries(this.schema).map(([key, column]) => `${key} ${column.type}`).join(', ')}
213
+ ${Object.entries(this.schema)
214
+ .map(([key, column]) => `${key} ${column.type} ${column.materialized ? ` MATERIALIZED ${column.materialized}` : ''}`)
215
+ .join(', ')}
217
216
  ) ENGINE = ${this.tableOptions.engine}
218
217
  ${this.tableOptions.primaryKey ? `PRIMARY KEY (${Array.isArray(this.tableOptions.primaryKey) ? this.tableOptions.primaryKey.join(', ') : this.tableOptions.primaryKey})` : ''}
219
218
  ${this.tableOptions.orderBy ? `ORDER BY (${Array.isArray(this.tableOptions.orderBy) ? this.tableOptions.orderBy.join(', ') : this.tableOptions.orderBy})` : ''}
@@ -243,7 +242,6 @@ export class ClickHouseInterfaceTemplate {
243
242
  throw error;
244
243
  }
245
244
  catch (verifyError) {
246
- //
247
245
  Logger.error({ error: verifyError, message: `LABDB [${this.tableName}]: Failed to verify table existence after ACCESS_DENIED: ${verifyError.message}` });
248
246
  throw verifyError;
249
247
  }
@@ -0,0 +1,3 @@
1
+ import { type ClickHouseTableSchema } from '@tmlmobilidade/go-clients-clickhouse';
2
+ import { type SimplifiedVehicleEvent } from '@tmlmobilidade/go-types-vehicle-events';
3
+ export declare const simplifiedVehicleEventTableSchema: ClickHouseTableSchema<SimplifiedVehicleEvent>;
@@ -0,0 +1,21 @@
1
+ /* * */
2
+ /* * */
3
+ export const simplifiedVehicleEventTableSchema = {
4
+ _id: { type: 'String' },
5
+ agency_id: { type: 'LowCardinality(String)' },
6
+ bearing: { type: 'Nullable(UInt16) CODEC(T64, ZSTD)' },
7
+ created_at: { type: 'Int64 CODEC(DoubleDelta, ZSTD)' },
8
+ current_status: { type: 'LowCardinality(Nullable(String))' },
9
+ driver_id: { type: 'LowCardinality(Nullable(String))' },
10
+ extra_trip_id: { type: 'Nullable(String)' },
11
+ geohash: { materialized: 'geohashEncode(longitude, latitude, 7)', type: 'FixedString(7)' },
12
+ latitude: { type: 'Float32 CODEC(Gorilla, ZSTD)' },
13
+ longitude: { type: 'Float32 CODEC(Gorilla, ZSTD)' },
14
+ odometer: { type: 'Nullable(UInt32)' },
15
+ operational_date: { type: 'UInt32' },
16
+ received_at: { type: 'Int64 CODEC(DoubleDelta, ZSTD)' },
17
+ speed: { type: 'Nullable(UInt8) CODEC(T64, ZSTD)' },
18
+ stop_id: { type: 'LowCardinality(Nullable(String))' },
19
+ trip_id: { type: 'String' },
20
+ vehicle_id: { type: 'LowCardinality(String)' },
21
+ };
@@ -1,3 +1,3 @@
1
1
  import { type ClickHouseTableSchema } from '@tmlmobilidade/go-clients-clickhouse';
2
2
  import { type DemandByAgencyByOperationalDate } from '@tmlmobilidade/go-types-performance';
3
- export declare const demandByAgencyByOperationalDateSchema: ClickHouseTableSchema<DemandByAgencyByOperationalDate>;
3
+ export declare const demandByAgencyByOperationalDateTableSchema: ClickHouseTableSchema<DemandByAgencyByOperationalDate>;
@@ -1,6 +1,6 @@
1
1
  /* * */
2
2
  /* * */
3
- export const demandByAgencyByOperationalDateSchema = {
3
+ export const demandByAgencyByOperationalDateTableSchema = {
4
4
  agency_id: { type: 'LowCardinality(String)' },
5
5
  operational_date: { type: 'UInt32' },
6
6
  qty: { type: 'UInt64' },
@@ -0,0 +1,9 @@
1
+ import { type ClickHouseTableSchema } from '@tmlmobilidade/go-clients-clickhouse';
2
+ import { type SimplifiedApexBankingTap, SimplifiedApexInspection, SimplifiedApexInspectionDecision, SimplifiedApexLocation, SimplifiedApexOnBoardRefund, SimplifiedApexOnBoardSale, SimplifiedApexValidation } from '@tmlmobilidade/go-types-apex';
3
+ export declare const simplifiedApexBankingTapTableSchema: ClickHouseTableSchema<SimplifiedApexBankingTap>;
4
+ export declare const simplifiedApexInspectionDecisionTableSchema: ClickHouseTableSchema<SimplifiedApexInspectionDecision>;
5
+ export declare const simplifiedApexInspectionTableSchema: ClickHouseTableSchema<SimplifiedApexInspection>;
6
+ export declare const simplifiedApexLocationTableSchema: ClickHouseTableSchema<SimplifiedApexLocation>;
7
+ export declare const simplifiedApexOnBoardRefundTableSchema: ClickHouseTableSchema<SimplifiedApexOnBoardRefund>;
8
+ export declare const simplifiedApexOnBoardSaleTableSchema: ClickHouseTableSchema<SimplifiedApexOnBoardSale>;
9
+ export declare const simplifiedApexValidationTableSchema: ClickHouseTableSchema<SimplifiedApexValidation>;
@@ -1,6 +1,6 @@
1
1
  /* * */
2
2
  /* * */
3
- export const simplifiedApexBankingTapSchema = {
3
+ export const simplifiedApexBankingTapTableSchema = {
4
4
  _id: { type: 'UUID' },
5
5
  agency_id: { type: 'LowCardinality(String)' },
6
6
  apex_version: { type: 'LowCardinality(String)' },
@@ -25,7 +25,7 @@ export const simplifiedApexBankingTapSchema = {
25
25
  updated_at: { type: 'Int64' },
26
26
  vehicle_id: { type: 'LowCardinality(Nullable(String))' },
27
27
  };
28
- export const simplifiedApexInspectionDecisionSchema = {
28
+ export const simplifiedApexInspectionDecisionTableSchema = {
29
29
  _id: { type: 'UUID' },
30
30
  agency_id: { type: 'LowCardinality(String)' },
31
31
  apex_version: { type: 'LowCardinality(String)' },
@@ -41,7 +41,7 @@ export const simplifiedApexInspectionDecisionSchema = {
41
41
  received_at: { type: 'Int64' },
42
42
  updated_at: { type: 'Int64' },
43
43
  };
44
- export const simplifiedApexInspectionSchema = {
44
+ export const simplifiedApexInspectionTableSchema = {
45
45
  _id: { type: 'UUID' },
46
46
  agency_id: { type: 'LowCardinality(String)' },
47
47
  apex_version: { type: 'LowCardinality(String)' },
@@ -66,7 +66,7 @@ export const simplifiedApexInspectionSchema = {
66
66
  updated_at: { type: 'Int64' },
67
67
  vehicle_id: { type: 'LowCardinality(Nullable(String))' },
68
68
  };
69
- export const simplifiedApexLocationSchema = {
69
+ export const simplifiedApexLocationTableSchema = {
70
70
  _id: { type: 'UUID' },
71
71
  agency_id: { type: 'LowCardinality(String)' },
72
72
  apex_version: { type: 'LowCardinality(String)' },
@@ -85,7 +85,7 @@ export const simplifiedApexLocationSchema = {
85
85
  updated_at: { type: 'Int64' },
86
86
  vehicle_id: { type: 'LowCardinality(Nullable(String))' },
87
87
  };
88
- export const simplifiedApexOnBoardRefundSchema = {
88
+ export const simplifiedApexOnBoardRefundTableSchema = {
89
89
  _id: { type: 'UUID' },
90
90
  agency_id: { type: 'LowCardinality(String)' },
91
91
  apex_version: { type: 'LowCardinality(String)' },
@@ -112,7 +112,7 @@ export const simplifiedApexOnBoardRefundSchema = {
112
112
  validation_id: { type: 'Nullable(UUID)' },
113
113
  vehicle_id: { type: 'LowCardinality(Nullable(String))' },
114
114
  };
115
- export const simplifiedApexOnBoardSaleSchema = {
115
+ export const simplifiedApexOnBoardSaleTableSchema = {
116
116
  _id: { type: 'UUID' },
117
117
  agency_id: { type: 'LowCardinality(String)' },
118
118
  apex_version: { type: 'LowCardinality(String)' },
@@ -140,7 +140,7 @@ export const simplifiedApexOnBoardSaleSchema = {
140
140
  validation_id: { type: 'Nullable(UUID)' },
141
141
  vehicle_id: { type: 'LowCardinality(Nullable(String))' },
142
142
  };
143
- export const simplifiedApexValidationSchema = {
143
+ export const simplifiedApexValidationTableSchema = {
144
144
  _id: { type: 'UUID' },
145
145
  agency_id: { type: 'LowCardinality(String)' },
146
146
  apex_version: { type: 'LowCardinality(String)' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/go-interfaces-labdb",
3
- "version": "20260722.1043.2",
3
+ "version": "20260723.1350.16",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"
@@ -39,15 +39,13 @@
39
39
  "@tmlmobilidade/go-clients-clickhouse": "*",
40
40
  "@tmlmobilidade/go-types-apex": "*",
41
41
  "@tmlmobilidade/go-types-performance": "*",
42
+ "@tmlmobilidade/go-types-vehicle-events": "*",
42
43
  "@tmlmobilidade/logger": "*",
43
44
  "@tmlmobilidade/types": "*",
44
- "@tmlmobilidade/utils": "*",
45
- "luxon": "3.7.2",
46
- "zod": "3.25.76"
45
+ "@tmlmobilidade/utils": "*"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@tmlmobilidade/tsconfig": "*",
50
- "@types/luxon": "3.7.2",
51
49
  "@types/node": "26.1.1",
52
50
  "resolve-tspaths": "0.8.23",
53
51
  "tsc-watch": "7.2.1",
@@ -1,3 +0,0 @@
1
- import { type ClickHouseTableSchema } from '@tmlmobilidade/go-clients-clickhouse';
2
- import { type SimplifiedVehicleEvent } from '@tmlmobilidade/types';
3
- export declare const simplifiedVehicleEventSchema: ClickHouseTableSchema<SimplifiedVehicleEvent>;
@@ -1,24 +0,0 @@
1
- /* * */
2
- /* * */
3
- export const simplifiedVehicleEventSchema = {
4
- _id: { type: 'String' },
5
- agency_id: { type: 'String' },
6
- created_at: { type: 'Int64' },
7
- geohash: { default: 'geohashEncode(longitude, latitude, 7)', type: 'String' },
8
- latitude: { type: 'Float64' },
9
- longitude: { type: 'Float64' },
10
- operational_date: { type: 'Date' },
11
- received_at: { type: 'Int64' },
12
- trip_id: { type: 'String' },
13
- vehicle_id: { type: 'String' },
14
- // Optional Fields
15
- bearing: { type: 'Nullable(Int64)' },
16
- current_status: { type: 'Nullable(String)' },
17
- door: { type: 'Nullable(String)' },
18
- driver_id: { type: 'Nullable(String)' },
19
- extra_trip_id: { type: 'Nullable(String)' },
20
- odometer: { type: 'Nullable(Int64)' },
21
- pattern_id: { type: 'Nullable(String)' },
22
- speed: { type: 'Nullable(Int64)' },
23
- stop_id: { type: 'Nullable(String)' },
24
- };
@@ -1,9 +0,0 @@
1
- import { type ClickHouseTableSchema } from '@tmlmobilidade/go-clients-clickhouse';
2
- import { type SimplifiedApexBankingTap, SimplifiedApexInspection, SimplifiedApexInspectionDecision, SimplifiedApexLocation, SimplifiedApexOnBoardRefund, SimplifiedApexOnBoardSale, SimplifiedApexValidation } from '@tmlmobilidade/go-types-apex';
3
- export declare const simplifiedApexBankingTapSchema: ClickHouseTableSchema<SimplifiedApexBankingTap>;
4
- export declare const simplifiedApexInspectionDecisionSchema: ClickHouseTableSchema<SimplifiedApexInspectionDecision>;
5
- export declare const simplifiedApexInspectionSchema: ClickHouseTableSchema<SimplifiedApexInspection>;
6
- export declare const simplifiedApexLocationSchema: ClickHouseTableSchema<SimplifiedApexLocation>;
7
- export declare const simplifiedApexOnBoardRefundSchema: ClickHouseTableSchema<SimplifiedApexOnBoardRefund>;
8
- export declare const simplifiedApexOnBoardSaleSchema: ClickHouseTableSchema<SimplifiedApexOnBoardSale>;
9
- export declare const simplifiedApexValidationSchema: ClickHouseTableSchema<SimplifiedApexValidation>;