@tmlmobilidade/databases 20260616.2252.19 → 20260617.1703.12

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.
Files changed (31) hide show
  1. package/dist/clients/go-clickhouse.js +2 -2
  2. package/dist/clients/go-mongo.js +10 -10
  3. package/dist/clients/go-redis.js +3 -3
  4. package/dist/clients/pcgi-file-manager.js +10 -10
  5. package/dist/clients/pcgi-raw.js +10 -10
  6. package/dist/clients/pcgi-ticketing.js +10 -10
  7. package/dist/clients/pcgi-validations.js +10 -10
  8. package/dist/interfaces/apex/simplified/simplified-apex-banking-taps.d.ts +0 -3
  9. package/dist/interfaces/apex/simplified/simplified-apex-banking-taps.js +0 -1
  10. package/dist/interfaces/apex/simplified/simplified-apex-inspection-decisions.d.ts +0 -3
  11. package/dist/interfaces/apex/simplified/simplified-apex-inspection-decisions.js +0 -1
  12. package/dist/interfaces/apex/simplified/simplified-apex-inspections.d.ts +1 -4
  13. package/dist/interfaces/apex/simplified/simplified-apex-inspections.js +6 -7
  14. package/dist/interfaces/apex/simplified/simplified-apex-locations.d.ts +0 -3
  15. package/dist/interfaces/apex/simplified/simplified-apex-locations.js +4 -5
  16. package/dist/interfaces/apex/simplified/simplified-apex-refunds.d.ts +2 -5
  17. package/dist/interfaces/apex/simplified/simplified-apex-refunds.js +5 -6
  18. package/dist/interfaces/apex/simplified/simplified-apex-sales.d.ts +2 -5
  19. package/dist/interfaces/apex/simplified/simplified-apex-sales.js +5 -6
  20. package/dist/interfaces/apex/simplified/simplified-apex-validations.d.ts +2 -5
  21. package/dist/interfaces/apex/simplified/simplified-apex-validations.js +5 -6
  22. package/dist/templates/clickhouse.d.ts +1 -1
  23. package/dist/templates/clickhouse.js +6 -6
  24. package/dist/templates/mongodb.js +5 -5
  25. package/dist/types/clickhouse/data-types.d.ts +1 -1
  26. package/dist/utils/clickhouse/get-clickhouse-param-type.d.ts +1 -1
  27. package/dist/utils/clickhouse/get-clickhouse-param-type.js +3 -0
  28. package/dist/utils/clickhouse/prepare-positional-query-params.d.ts +2 -2
  29. package/dist/utils/clickhouse/query-from-file.js +4 -4
  30. package/dist/utils/clickhouse/query-from-string.js +1 -1
  31. package/package.json +1 -1
@@ -41,7 +41,7 @@ export class GOClickHouseClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[GOClickHouseClient] Connecting to database...');
44
+ Logger.info({ message: '[GOClickHouseClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = createClient({
47
47
  clickhouse_settings: {
@@ -114,7 +114,7 @@ export class GOClickHouseClient {
114
114
  maxRetries: 3,
115
115
  };
116
116
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
117
- Logger.info('[GOClickHouseClient] Setting up SSH Tunnel...');
117
+ Logger.info({ message: '[GOClickHouseClient] Setting up SSH Tunnel...' });
118
118
  const connection = await this.tunnel.connect();
119
119
  const addr = connection.address();
120
120
  if (!addr || typeof addr !== 'object') {
@@ -41,7 +41,7 @@ export class GOMongoClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[GOMongoClient] Connecting to database...');
44
+ Logger.info({ message: '[GOMongoClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = new MongoClient(connectionString, {
47
47
  connectTimeoutMS: 10_000,
@@ -55,28 +55,28 @@ export class GOMongoClient {
55
55
  serverSelectionTimeoutMS: 10_000,
56
56
  });
57
57
  this.client.on('connectionPoolCreated', () => {
58
- Logger.info('[GOMongoClient] Database connection pool created.');
58
+ Logger.info({ message: '[GOMongoClient] Database connection pool created.' });
59
59
  });
60
60
  this.client.on('topologyDescriptionChanged', () => {
61
- Logger.info('[GOMongoClient] Database topology description changed.');
61
+ Logger.info({ message: '[GOMongoClient] Database topology description changed.' });
62
62
  });
63
63
  this.client.on('serverDescriptionChanged', () => {
64
- Logger.info('[GOMongoClient] Database server description changed.');
64
+ Logger.info({ message: '[GOMongoClient] Database server description changed.' });
65
65
  });
66
66
  this.client.on('open', () => {
67
- Logger.info('[GOMongoClient] Database connection opened.');
67
+ Logger.info({ message: '[GOMongoClient] Database connection opened.' });
68
68
  });
69
69
  this.client.on('connectionReady', () => {
70
- Logger.info('[GOMongoClient] Database connection is ready.');
70
+ Logger.info({ message: '[GOMongoClient] Database connection is ready.' });
71
71
  });
72
72
  this.client.on('close', () => {
73
- Logger.error('[GOMongoClient] Database connection closed unexpectedly.');
73
+ Logger.error({ message: '[GOMongoClient] Database connection closed unexpectedly.' });
74
74
  });
75
75
  this.client.on('reconnect', () => {
76
- Logger.info('[GOMongoClient] Database reconnected.');
76
+ Logger.info({ message: '[GOMongoClient] Database reconnected.' });
77
77
  });
78
78
  this.client.on('error', (error) => {
79
- Logger.error('[GOMongoClient] Database connection error:', error);
79
+ Logger.error({ error, message: '[GOMongoClient] Database connection error:' });
80
80
  });
81
81
  await this.client.connect();
82
82
  }
@@ -145,7 +145,7 @@ export class GOMongoClient {
145
145
  maxRetries: 3,
146
146
  };
147
147
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
148
- Logger.info('[GOMongoClient] Setting up SSH Tunnel...');
148
+ Logger.info({ message: '[GOMongoClient] Setting up SSH Tunnel...' });
149
149
  const connection = await this.tunnel.connect();
150
150
  const addr = connection.address();
151
151
  if (!addr || typeof addr !== 'object') {
@@ -41,11 +41,11 @@ export class GORedisClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[GORedisClient] Connecting to database...');
44
+ Logger.info({ message: '[GORedisClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = createClient({ url: connectionString });
47
47
  await this.client.connect();
48
- Logger.info('[GORedisClient] Connected to database');
48
+ Logger.info({ message: '[GORedisClient] Connected to database' });
49
49
  }
50
50
  /**
51
51
  * Constructs the connection string based on environment variables
@@ -103,7 +103,7 @@ export class GORedisClient {
103
103
  maxRetries: 3,
104
104
  };
105
105
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
106
- Logger.info('[GORedisClient] Setting up SSH Tunnel...');
106
+ Logger.info({ message: '[GORedisClient] Setting up SSH Tunnel...' });
107
107
  const connection = await this.tunnel.connect();
108
108
  const addr = connection.address();
109
109
  if (!addr || typeof addr !== 'object') {
@@ -41,7 +41,7 @@ export class PCGIFileManagerClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[PCGIFileManagerClient] Connecting to database...');
44
+ Logger.info({ message: '[PCGIFileManagerClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = new MongoClient(connectionString, {
47
47
  connectTimeoutMS: 10_000,
@@ -55,28 +55,28 @@ export class PCGIFileManagerClient {
55
55
  serverSelectionTimeoutMS: 10_000,
56
56
  });
57
57
  this.client.on('connectionPoolCreated', () => {
58
- Logger.info('[PCGIFileManagerClient] Database connection pool created.');
58
+ Logger.info({ message: '[PCGIFileManagerClient] Database connection pool created.' });
59
59
  });
60
60
  this.client.on('topologyDescriptionChanged', () => {
61
- Logger.info('[PCGIFileManagerClient] Database topology description changed.');
61
+ Logger.info({ message: '[PCGIFileManagerClient] Database topology description changed.' });
62
62
  });
63
63
  this.client.on('serverDescriptionChanged', () => {
64
- Logger.info('[PCGIFileManagerClient] Database server description changed.');
64
+ Logger.info({ message: '[PCGIFileManagerClient] Database server description changed.' });
65
65
  });
66
66
  this.client.on('open', () => {
67
- Logger.info('[PCGIFileManagerClient] Database connection opened.');
67
+ Logger.info({ message: '[PCGIFileManagerClient] Database connection opened.' });
68
68
  });
69
69
  this.client.on('connectionReady', () => {
70
- Logger.info('[PCGIFileManagerClient] Database connection is ready.');
70
+ Logger.info({ message: '[PCGIFileManagerClient] Database connection is ready.' });
71
71
  });
72
72
  this.client.on('close', () => {
73
- Logger.error('[PCGIFileManagerClient] Database connection closed unexpectedly.');
73
+ Logger.error({ message: '[PCGIFileManagerClient] Database connection closed unexpectedly.' });
74
74
  });
75
75
  this.client.on('reconnect', () => {
76
- Logger.info('[PCGIFileManagerClient] Database reconnected.');
76
+ Logger.info({ message: '[PCGIFileManagerClient] Database reconnected.' });
77
77
  });
78
78
  this.client.on('error', (error) => {
79
- Logger.error('[PCGIFileManagerClient] Database connection error:', error);
79
+ Logger.error({ error, message: '[PCGIFileManagerClient] Database connection error:' });
80
80
  });
81
81
  await this.client.connect();
82
82
  }
@@ -145,7 +145,7 @@ export class PCGIFileManagerClient {
145
145
  maxRetries: 3,
146
146
  };
147
147
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
148
- Logger.info('[PCGIFileManagerClient] Setting up SSH Tunnel...');
148
+ Logger.info({ message: '[PCGIFileManagerClient] Setting up SSH Tunnel...' });
149
149
  const connection = await this.tunnel.connect();
150
150
  const addr = connection.address();
151
151
  if (!addr || typeof addr !== 'object') {
@@ -41,7 +41,7 @@ export class PCGIRawClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[PCGIRawClient] Connecting to database...');
44
+ Logger.info({ message: '[PCGIRawClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = new MongoClient(connectionString, {
47
47
  connectTimeoutMS: 10_000,
@@ -55,28 +55,28 @@ export class PCGIRawClient {
55
55
  serverSelectionTimeoutMS: 10_000,
56
56
  });
57
57
  this.client.on('connectionPoolCreated', () => {
58
- Logger.info('[PCGIRawClient] Database connection pool created.');
58
+ Logger.info({ message: '[PCGIRawClient] Database connection pool created.' });
59
59
  });
60
60
  this.client.on('topologyDescriptionChanged', () => {
61
- Logger.info('[PCGIRawClient] Database topology description changed.');
61
+ Logger.info({ message: '[PCGIRawClient] Database topology description changed.' });
62
62
  });
63
63
  this.client.on('serverDescriptionChanged', () => {
64
- Logger.info('[PCGIRawClient] Database server description changed.');
64
+ Logger.info({ message: '[PCGIRawClient] Database server description changed.' });
65
65
  });
66
66
  this.client.on('open', () => {
67
- Logger.info('[PCGIRawClient] Database connection opened.');
67
+ Logger.info({ message: '[PCGIRawClient] Database connection opened.' });
68
68
  });
69
69
  this.client.on('connectionReady', () => {
70
- Logger.info('[PCGIRawClient] Database connection is ready.');
70
+ Logger.info({ message: '[PCGIRawClient] Database connection is ready.' });
71
71
  });
72
72
  this.client.on('close', () => {
73
- Logger.error('[PCGIRawClient] Database connection closed unexpectedly.');
73
+ Logger.error({ message: '[PCGIRawClient] Database connection closed unexpectedly.' });
74
74
  });
75
75
  this.client.on('reconnect', () => {
76
- Logger.info('[PCGIRawClient] Database reconnected.');
76
+ Logger.info({ message: '[PCGIRawClient] Database reconnected.' });
77
77
  });
78
78
  this.client.on('error', (error) => {
79
- Logger.error('[PCGIRawClient] Database connection error:', error);
79
+ Logger.error({ error, message: '[PCGIRawClient] Database connection error:' });
80
80
  });
81
81
  await this.client.connect();
82
82
  }
@@ -145,7 +145,7 @@ export class PCGIRawClient {
145
145
  maxRetries: 3,
146
146
  };
147
147
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
148
- Logger.info('[PCGIRawClient] Setting up SSH Tunnel...');
148
+ Logger.info({ message: '[PCGIRawClient] Setting up SSH Tunnel...' });
149
149
  const connection = await this.tunnel.connect();
150
150
  const addr = connection.address();
151
151
  if (!addr || typeof addr !== 'object') {
@@ -41,7 +41,7 @@ export class PCGITicketingClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[PCGITicketingClient] Connecting to database...');
44
+ Logger.info({ message: '[PCGITicketingClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = new MongoClient(connectionString, {
47
47
  connectTimeoutMS: 10_000,
@@ -55,28 +55,28 @@ export class PCGITicketingClient {
55
55
  serverSelectionTimeoutMS: 10_000,
56
56
  });
57
57
  this.client.on('connectionPoolCreated', () => {
58
- Logger.info('[PCGITicketingClient] Database connection pool created.');
58
+ Logger.info({ message: '[PCGITicketingClient] Database connection pool created.' });
59
59
  });
60
60
  this.client.on('topologyDescriptionChanged', () => {
61
- Logger.info('[PCGITicketingClient] Database topology description changed.');
61
+ Logger.info({ message: '[PCGITicketingClient] Database topology description changed.' });
62
62
  });
63
63
  this.client.on('serverDescriptionChanged', () => {
64
- Logger.info('[PCGITicketingClient] Database server description changed.');
64
+ Logger.info({ message: '[PCGITicketingClient] Database server description changed.' });
65
65
  });
66
66
  this.client.on('open', () => {
67
- Logger.info('[PCGITicketingClient] Database connection opened.');
67
+ Logger.info({ message: '[PCGITicketingClient] Database connection opened.' });
68
68
  });
69
69
  this.client.on('connectionReady', () => {
70
- Logger.info('[PCGITicketingClient] Database connection is ready.');
70
+ Logger.info({ message: '[PCGITicketingClient] Database connection is ready.' });
71
71
  });
72
72
  this.client.on('close', () => {
73
- Logger.error('[PCGITicketingClient] Database connection closed unexpectedly.');
73
+ Logger.error({ message: '[PCGITicketingClient] Database connection closed unexpectedly.' });
74
74
  });
75
75
  this.client.on('reconnect', () => {
76
- Logger.info('[PCGITicketingClient] Database reconnected.');
76
+ Logger.info({ message: '[PCGITicketingClient] Database reconnected.' });
77
77
  });
78
78
  this.client.on('error', (error) => {
79
- Logger.error('[PCGITicketingClient] Database connection error:', error);
79
+ Logger.error({ error, message: '[PCGITicketingClient] Database connection error:' });
80
80
  });
81
81
  await this.client.connect();
82
82
  }
@@ -145,7 +145,7 @@ export class PCGITicketingClient {
145
145
  maxRetries: 3,
146
146
  };
147
147
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
148
- Logger.info('[PCGITicketingClient] Setting up SSH Tunnel...');
148
+ Logger.info({ message: '[PCGITicketingClient] Setting up SSH Tunnel...' });
149
149
  const connection = await this.tunnel.connect();
150
150
  const addr = connection.address();
151
151
  if (!addr || typeof addr !== 'object') {
@@ -41,7 +41,7 @@ export class PCGIValidationsClient {
41
41
  * This method is called internally by the service and should not be used directly.
42
42
  */
43
43
  async connect() {
44
- Logger.info('[PCGIValidationsClient] Connecting to database...');
44
+ Logger.info({ message: '[PCGIValidationsClient] Connecting to database...' });
45
45
  const connectionString = await this.getConnectionString();
46
46
  this.client = new MongoClient(connectionString, {
47
47
  connectTimeoutMS: 10_000,
@@ -55,28 +55,28 @@ export class PCGIValidationsClient {
55
55
  serverSelectionTimeoutMS: 10_000,
56
56
  });
57
57
  this.client.on('connectionPoolCreated', () => {
58
- Logger.info('[PCGIValidationsClient] Database connection pool created.');
58
+ Logger.info({ message: '[PCGIValidationsClient] Database connection pool created.' });
59
59
  });
60
60
  this.client.on('topologyDescriptionChanged', () => {
61
- Logger.info('[PCGIValidationsClient] Database topology description changed.');
61
+ Logger.info({ message: '[PCGIValidationsClient] Database topology description changed.' });
62
62
  });
63
63
  this.client.on('serverDescriptionChanged', () => {
64
- Logger.info('[PCGIValidationsClient] Database server description changed.');
64
+ Logger.info({ message: '[PCGIValidationsClient] Database server description changed.' });
65
65
  });
66
66
  this.client.on('open', () => {
67
- Logger.info('[PCGIValidationsClient] Database connection opened.');
67
+ Logger.info({ message: '[PCGIValidationsClient] Database connection opened.' });
68
68
  });
69
69
  this.client.on('connectionReady', () => {
70
- Logger.info('[PCGIValidationsClient] Database connection is ready.');
70
+ Logger.info({ message: '[PCGIValidationsClient] Database connection is ready.' });
71
71
  });
72
72
  this.client.on('close', () => {
73
- Logger.error('[PCGIValidationsClient] Database connection closed unexpectedly.');
73
+ Logger.error({ message: '[PCGIValidationsClient] Database connection closed unexpectedly.' });
74
74
  });
75
75
  this.client.on('reconnect', () => {
76
- Logger.info('[PCGIValidationsClient] Database reconnected.');
76
+ Logger.info({ message: '[PCGIValidationsClient] Database reconnected.' });
77
77
  });
78
78
  this.client.on('error', (error) => {
79
- Logger.error('[PCGIValidationsClient] Database connection error:', error);
79
+ Logger.error({ error, message: '[PCGIValidationsClient] Database connection error:' });
80
80
  });
81
81
  await this.client.connect();
82
82
  }
@@ -145,7 +145,7 @@ export class PCGIValidationsClient {
145
145
  maxRetries: 3,
146
146
  };
147
147
  this.tunnel = new SshTunnelService(sshConfig, sshOptions);
148
- Logger.info('[PCGIValidationsClient] Setting up SSH Tunnel...');
148
+ Logger.info({ message: '[PCGIValidationsClient] Setting up SSH Tunnel...' });
149
149
  const connection = await this.tunnel.connect();
150
150
  const addr = connection.address();
151
151
  if (!addr || typeof addr !== 'object') {
@@ -19,9 +19,6 @@ declare class SimplifiedApexBankingTapsNewClass extends ClickHouseInterfaceTempl
19
19
  };
20
20
  apex_version: string;
21
21
  banking_token: string;
22
- calendar_date: string & {
23
- __brand: "CalendarDate";
24
- };
25
22
  card_brand: number;
26
23
  card_pan: string;
27
24
  device_id: string;
@@ -8,7 +8,6 @@ const tableSchema = {
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
10
  banking_token: { type: 'String' },
11
- calendar_date: { type: 'Date' },
12
11
  card_brand: { type: 'UInt8' },
13
12
  card_pan: { type: 'String' },
14
13
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
@@ -18,9 +18,6 @@ declare class SimplifiedApexInspectionDecisionsNewClass extends ClickHouseInterf
18
18
  __brand: "UnixTimestamp";
19
19
  };
20
20
  apex_version: string;
21
- calendar_date: string & {
22
- __brand: "CalendarDate";
23
- };
24
21
  device_id: string;
25
22
  is_ok_pcgi: boolean;
26
23
  mac_ase_counter_value: number;
@@ -7,7 +7,6 @@ const tableSchema = {
7
7
  _id: { type: 'UUID' },
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
- calendar_date: { type: 'Date' },
11
10
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
12
11
  device_id: { type: 'LowCardinality(String)' },
13
12
  final_control_status: { type: 'UInt8' },
@@ -18,9 +18,6 @@ declare class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTempl
18
18
  __brand: "UnixTimestamp";
19
19
  };
20
20
  apex_version: string;
21
- calendar_date: string & {
22
- __brand: "CalendarDate";
23
- };
24
21
  device_id: string;
25
22
  is_ok_pcgi: boolean;
26
23
  line_id: string;
@@ -33,7 +30,7 @@ declare class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTempl
33
30
  __brand: "UnixTimestamp";
34
31
  };
35
32
  vehicle_id: number | null;
36
- card_serial_number: bigint | null;
33
+ card_serial_number: string | null;
37
34
  control_destination_stop_id: string;
38
35
  control_origin_stop_id: string;
39
36
  control_status: number;
@@ -7,10 +7,9 @@ const tableSchema = {
7
7
  _id: { type: 'UUID' },
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
- calendar_date: { type: 'Date' },
11
10
  card_serial_number: { type: 'Nullable(UInt64)' },
12
- control_destination_stop_id: { type: 'Nullable(LowCardinality(String))' },
13
- control_origin_stop_id: { type: 'Nullable(LowCardinality(String))' },
11
+ control_destination_stop_id: { type: 'LowCardinality(Nullable(String))' },
12
+ control_origin_stop_id: { type: 'LowCardinality(Nullable(String))' },
14
13
  control_status: { type: 'UInt8' },
15
14
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
16
15
  device_id: { type: 'LowCardinality(String)' },
@@ -18,15 +17,15 @@ const tableSchema = {
18
17
  inspection_id: { type: 'Nullable(UUID)' },
19
18
  is_ok: { type: 'Bool' },
20
19
  is_ok_pcgi: { type: 'Bool' },
21
- line_id: { type: 'Nullable(LowCardinality(String))' },
20
+ line_id: { type: 'LowCardinality(Nullable(String))' },
22
21
  mac_ase_counter_value: { type: 'UInt64' },
23
22
  mac_sam_serial_number: { type: 'UInt64' },
24
- pattern_id: { type: 'Nullable(LowCardinality(String))' },
25
- product_id: { type: 'Nullable(LowCardinality(String))' },
23
+ pattern_id: { type: 'LowCardinality(Nullable(String))' },
24
+ product_id: { type: 'LowCardinality(Nullable(String))' },
26
25
  received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
27
26
  trip_id: { type: 'Nullable(String)' },
28
27
  updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
29
- vehicle_id: { type: 'Nullable(LowCardinality(String))' },
28
+ vehicle_id: { type: 'LowCardinality(Nullable(String))' },
30
29
  };
31
30
  /* * */
32
31
  class SimplifiedApexInspectionsNewClass extends ClickHouseInterfaceTemplate {
@@ -17,9 +17,6 @@ declare class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplat
17
17
  __brand: "UnixTimestamp";
18
18
  };
19
19
  apex_version: string;
20
- calendar_date: string & {
21
- __brand: "CalendarDate";
22
- };
23
20
  device_id: string;
24
21
  line_id: string;
25
22
  mac_ase_counter_value: number;
@@ -7,18 +7,17 @@ const tableSchema = {
7
7
  _id: { type: 'UUID' },
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
- calendar_date: { type: 'Date' },
11
10
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
12
11
  device_id: { type: 'LowCardinality(String)' },
13
- line_id: { type: 'Nullable(LowCardinality(String))' },
12
+ line_id: { type: 'LowCardinality(Nullable(String))' },
14
13
  mac_ase_counter_value: { type: 'UInt64' },
15
14
  mac_sam_serial_number: { type: 'UInt64' },
16
- pattern_id: { type: 'Nullable(LowCardinality(String))' },
15
+ pattern_id: { type: 'LowCardinality(Nullable(String))' },
17
16
  received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
18
- stop_id: { type: 'Nullable(LowCardinality(String))' },
17
+ stop_id: { type: 'LowCardinality(Nullable(String))' },
19
18
  trip_id: { type: 'Nullable(String)' },
20
19
  updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
21
- vehicle_id: { type: 'Nullable(LowCardinality(String))' },
20
+ vehicle_id: { type: 'LowCardinality(Nullable(String))' },
22
21
  };
23
22
  /* * */
24
23
  class SimplifiedApexLocationsNewClass extends ClickHouseInterfaceTemplate {
@@ -18,27 +18,24 @@ declare class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTe
18
18
  };
19
19
  price: number;
20
20
  apex_version: string;
21
- calendar_date: string & {
22
- __brand: "CalendarDate";
23
- };
24
21
  device_id: string;
25
22
  line_id: string | null;
26
23
  mac_ase_counter_value: number;
27
24
  mac_sam_serial_number: number;
28
25
  pattern_id: string | null;
26
+ product_id: string;
29
27
  stop_id: string | null;
30
28
  trip_id: string | null;
31
29
  updated_at: number & {
32
30
  __brand: "UnixTimestamp";
33
31
  };
34
32
  vehicle_id: number | null;
35
- card_serial_number: bigint | null;
33
+ card_serial_number: string | null;
36
34
  block_id: string | null;
37
35
  card_physical_type: number;
38
36
  duty_id: string | null;
39
37
  on_board_sale_id: string | null;
40
38
  payment_method: number;
41
- product_long_id: string;
42
39
  product_quantity: number;
43
40
  validation_id: string | null;
44
41
  }>;
@@ -8,27 +8,26 @@ const tableSchema = {
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
10
  block_id: { type: 'Nullable(String)' },
11
- calendar_date: { type: 'Date' },
12
11
  card_physical_type: { type: 'UInt8' },
13
12
  card_serial_number: { type: 'Nullable(UInt64)' },
14
13
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
15
14
  device_id: { type: 'LowCardinality(String)' },
16
15
  duty_id: { type: 'Nullable(String)' },
17
- line_id: { type: 'Nullable(LowCardinality(String))' },
16
+ line_id: { type: 'LowCardinality(Nullable(String))' },
18
17
  mac_ase_counter_value: { type: 'UInt64' },
19
18
  mac_sam_serial_number: { type: 'UInt64' },
20
19
  on_board_sale_id: { type: 'Nullable(UUID)' },
21
- pattern_id: { type: 'Nullable(LowCardinality(String))' },
20
+ pattern_id: { type: 'LowCardinality(Nullable(String))' },
22
21
  payment_method: { type: 'UInt8' },
23
22
  price: { type: 'Int32' },
24
- product_long_id: { type: 'Nullable(LowCardinality(String))' },
23
+ product_id: { type: 'LowCardinality(Nullable(String))' },
25
24
  product_quantity: { type: 'Int32' },
26
25
  received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
27
- stop_id: { type: 'Nullable(LowCardinality(String))' },
26
+ stop_id: { type: 'LowCardinality(Nullable(String))' },
28
27
  trip_id: { type: 'Nullable(String)' },
29
28
  updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
30
29
  validation_id: { type: 'Nullable(UUID)' },
31
- vehicle_id: { type: 'Nullable(LowCardinality(String))' },
30
+ vehicle_id: { type: 'LowCardinality(Nullable(String))' },
32
31
  };
33
32
  /* * */
34
33
  class SimplifiedApexOnBoardRefundsNewClass extends ClickHouseInterfaceTemplate {
@@ -18,26 +18,23 @@ declare class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemp
18
18
  };
19
19
  price: number;
20
20
  apex_version: string;
21
- calendar_date: string & {
22
- __brand: "CalendarDate";
23
- };
24
21
  device_id: string;
25
22
  line_id: string | null;
26
23
  mac_ase_counter_value: number;
27
24
  mac_sam_serial_number: number;
28
25
  pattern_id: string | null;
26
+ product_id: string;
29
27
  stop_id: string | null;
30
28
  trip_id: string | null;
31
29
  updated_at: number & {
32
30
  __brand: "UnixTimestamp";
33
31
  };
34
32
  vehicle_id: number | null;
35
- card_serial_number: bigint | null;
33
+ card_serial_number: string | null;
36
34
  block_id: string | null;
37
35
  card_physical_type: number;
38
36
  duty_id: string | null;
39
37
  payment_method: number;
40
- product_long_id: string;
41
38
  product_quantity: number;
42
39
  validation_id: string | null;
43
40
  is_passenger: boolean;
@@ -8,28 +8,27 @@ const tableSchema = {
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
10
  block_id: { type: 'Nullable(String)' },
11
- calendar_date: { type: 'Date' },
12
11
  card_physical_type: { type: 'UInt8' },
13
12
  card_serial_number: { type: 'Nullable(UInt64)' },
14
13
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
15
14
  device_id: { type: 'LowCardinality(String)' },
16
15
  duty_id: { type: 'Nullable(String)' },
17
16
  is_passenger: { type: 'Bool' },
18
- line_id: { type: 'Nullable(LowCardinality(String))' },
17
+ line_id: { type: 'LowCardinality(Nullable(String))' },
19
18
  mac_ase_counter_value: { type: 'UInt64' },
20
19
  mac_sam_serial_number: { type: 'UInt64' },
21
20
  on_board_refund_id: { type: 'Nullable(UUID)' },
22
- pattern_id: { type: 'Nullable(LowCardinality(String))' },
21
+ pattern_id: { type: 'LowCardinality(Nullable(String))' },
23
22
  payment_method: { type: 'UInt8' },
24
23
  price: { type: 'Int32' },
25
- product_long_id: { type: 'Nullable(LowCardinality(String))' },
24
+ product_id: { type: 'LowCardinality(Nullable(String))' },
26
25
  product_quantity: { type: 'Int32' },
27
26
  received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
28
- stop_id: { type: 'Nullable(LowCardinality(String))' },
27
+ stop_id: { type: 'LowCardinality(Nullable(String))' },
29
28
  trip_id: { type: 'Nullable(String)' },
30
29
  updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
31
30
  validation_id: { type: 'Nullable(UUID)' },
32
- vehicle_id: { type: 'Nullable(LowCardinality(String))' },
31
+ vehicle_id: { type: 'LowCardinality(Nullable(String))' },
33
32
  };
34
33
  /* * */
35
34
  class SimplifiedApexOnBoardSalesNewClass extends ClickHouseInterfaceTemplate {
@@ -18,9 +18,6 @@ declare class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTempl
18
18
  __brand: "UnixTimestamp";
19
19
  };
20
20
  apex_version: string;
21
- calendar_date: string & {
22
- __brand: "CalendarDate";
23
- };
24
21
  device_id: string;
25
22
  event_type: number;
26
23
  is_ok_pcgi: boolean;
@@ -36,11 +33,11 @@ declare class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTempl
36
33
  __brand: "UnixTimestamp";
37
34
  };
38
35
  vehicle_id: number | null;
39
- card_serial_number: bigint | null;
36
+ card_serial_number: string | null;
40
37
  on_board_sale_id: string | null;
41
38
  is_passenger: boolean;
42
39
  on_board_refund_id: string | null;
43
- category: "on_board_sale" | "prepaid" | "subscription" | null;
40
+ category: "prepaid" | "subscription" | "on_board_sale" | null;
44
41
  validation_status: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13";
45
42
  }>;
46
43
  protected readonly tableName = "validations";
@@ -7,7 +7,6 @@ const tableSchema = {
7
7
  _id: { type: 'UUID' },
8
8
  agency_id: { type: 'LowCardinality(String)' },
9
9
  apex_version: { type: 'LowCardinality(String)' },
10
- calendar_date: { type: 'Date' },
11
10
  card_serial_number: { type: 'Nullable(UInt64)' },
12
11
  category: { type: 'LowCardinality(String)' },
13
12
  created_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
@@ -16,20 +15,20 @@ const tableSchema = {
16
15
  is_ok: { type: 'Bool' },
17
16
  is_ok_pcgi: { type: 'Bool' },
18
17
  is_passenger: { type: 'Bool' },
19
- line_id: { type: 'Nullable(LowCardinality(String))' },
18
+ line_id: { type: 'LowCardinality(Nullable(String))' },
20
19
  mac_ase_counter_value: { type: 'UInt64' },
21
20
  mac_sam_serial_number: { type: 'UInt64' },
22
21
  on_board_refund_id: { type: 'Nullable(UUID)' },
23
22
  on_board_sale_id: { type: 'Nullable(UUID)' },
24
- pattern_id: { type: 'Nullable(LowCardinality(String))' },
25
- product_id: { type: 'Nullable(LowCardinality(String))' },
23
+ pattern_id: { type: 'LowCardinality(Nullable(String))' },
24
+ product_id: { type: 'LowCardinality(Nullable(String))' },
26
25
  received_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
27
- stop_id: { type: 'Nullable(LowCardinality(String))' },
26
+ stop_id: { type: 'LowCardinality(Nullable(String))' },
28
27
  trip_id: { type: 'Nullable(String)' },
29
28
  units_qty: { type: 'Nullable(Int32)' },
30
29
  updated_at: { type: 'DateTime64(3, \'UTC\') CODEC(Delta, ZSTD)' },
31
30
  validation_status: { type: 'LowCardinality(String)' },
32
- vehicle_id: { type: 'Nullable(LowCardinality(String))' },
31
+ vehicle_id: { type: 'LowCardinality(Nullable(String))' },
33
32
  };
34
33
  /* * */
35
34
  class SimplifiedApexValidationsNewClass extends ClickHouseInterfaceTemplate {
@@ -37,7 +37,7 @@ export declare abstract class ClickHouseInterfaceTemplate<T extends object> {
37
37
  * @param params Optional key-value substitutions applied to the WHERE clause (replaces $1, $2, etc.).
38
38
  * @returns A promise that resolves when the delete operation is complete.
39
39
  */
40
- delete(where: string, params?: Record<string, number | string>): Promise<void>;
40
+ delete(where: string, params?: Record<string, number | string | string[]>): Promise<void>;
41
41
  /**
42
42
  * Executes a DISTINCT query on the ClickHouse table using the service's client.
43
43
  * @param select The columns to select in the query (e.g., `"*"`, `"column1, column2"`).
@@ -179,10 +179,10 @@ export class ClickHouseInterfaceTemplate {
179
179
  // Perform the query to create the database if it does not exist
180
180
  try {
181
181
  await this.client.command({ query: `CREATE DATABASE IF NOT EXISTS "${this.databaseName}"` });
182
- Logger.info(`CLICKHOUSE [${this.databaseName}]: Database created.`);
182
+ Logger.info({ message: `CLICKHOUSE [${this.databaseName}]: Database created.` });
183
183
  }
184
184
  catch (error) {
185
- Logger.error(`CLICKHOUSE [${this.databaseName}]: Error @ createDatabase(): ${error.message}`);
185
+ Logger.error({ error, message: `CLICKHOUSE [${this.databaseName}]: Error @ createDatabase(): ${error.message}` });
186
186
  throw error;
187
187
  }
188
188
  }
@@ -217,12 +217,12 @@ export class ClickHouseInterfaceTemplate {
217
217
  // Perform the query to create the table
218
218
  try {
219
219
  await this.client.command({ query: createTableQuery });
220
- Logger.info(`CLICKHOUSE [${this.tableName}]: Table created.`);
220
+ Logger.info({ message: `CLICKHOUSE [${this.tableName}]: Table created.` });
221
221
  }
222
222
  catch (error) {
223
223
  // If the error is not an ACCESS_DENIED, throw it right away
224
224
  if (!(error instanceof ClickHouseError) || error.code !== '497') {
225
- Logger.error(`CLICKHOUSE [${this.tableName}]: Error @ createTable(): ${error.message}`);
225
+ Logger.error({ error, message: `CLICKHOUSE [${this.tableName}]: Error @ createTable(): ${error.message}` });
226
226
  throw error;
227
227
  }
228
228
  // If the error is an ACCESS_DENIED, check if the table exists
@@ -234,12 +234,12 @@ export class ClickHouseInterfaceTemplate {
234
234
  const tables = await resultSet.json();
235
235
  if (Array.isArray(tables) && tables.length > 0)
236
236
  return;
237
- Logger.error(`CLICKHOUSE [${this.tableName}]: ACCESS_DENIED and table does not exist. ${error.message}`);
237
+ Logger.error({ error, message: `CLICKHOUSE [${this.tableName}]: ACCESS_DENIED and table does not exist. ${error.message}` });
238
238
  throw error;
239
239
  }
240
240
  catch (verifyError) {
241
241
  //
242
- Logger.error(`CLICKHOUSE [${this.tableName}]: Failed to verify table existence after ACCESS_DENIED: ${verifyError.message}`);
242
+ Logger.error({ error: verifyError, message: `CLICKHOUSE [${this.tableName}]: Failed to verify table existence after ACCESS_DENIED: ${verifyError.message}` });
243
243
  throw verifyError;
244
244
  }
245
245
  }
@@ -180,7 +180,7 @@ export class MongoInterfaceTemplate {
180
180
  if (collections.length)
181
181
  return;
182
182
  await this.database.createCollection(this.collectionName);
183
- Logger.info(`MONGODB [${this.collectionName}]: Collection created.`);
183
+ Logger.info({ message: `MONGODB [${this.collectionName}]: Collection created.` });
184
184
  }
185
185
  /**
186
186
  * Ensures that the specified indexes exist in MongoDB, creating them if they do not already exist.
@@ -192,11 +192,11 @@ export class MongoInterfaceTemplate {
192
192
  async syncIndexes() {
193
193
  try {
194
194
  if (this.indexDescription === false) {
195
- Logger.info(`MONGODB [${this.collectionName}]: Skipping index synchronization.`);
195
+ Logger.info({ message: `MONGODB [${this.collectionName}]: Skipping index synchronization.` });
196
196
  return;
197
197
  }
198
198
  // Start index synchronization process
199
- Logger.info(`MONGODB [${this.collectionName}]: Synchronizing indexes...`);
199
+ Logger.info({ message: `MONGODB [${this.collectionName}]: Synchronizing indexes...` });
200
200
  // Normalize already applied and new indexes
201
201
  // and filter the default _id index.
202
202
  const existingIndexes = await this.collection.indexes();
@@ -214,14 +214,14 @@ export class MongoInterfaceTemplate {
214
214
  }
215
215
  // Create indexes
216
216
  for (const idx of indexesToCreate) {
217
- Logger.info(`MONGODB [${this.collectionName}]: Creating index on keys ${JSON.stringify(idx.key)} with options ${JSON.stringify(prepareMongoIndexOptions(idx))}.`);
217
+ Logger.info({ message: `MONGODB [${this.collectionName}]: Creating index on keys ${JSON.stringify(idx.key)} with options ${JSON.stringify(prepareMongoIndexOptions(idx))}.` });
218
218
  await this.collection.createIndex(idx.key, prepareMongoIndexOptions(idx));
219
219
  Logger.success(`MONGODB [${this.collectionName}]: Created index on keys ${JSON.stringify(idx.key)}.`);
220
220
  }
221
221
  Logger.success(`MONGODB [${this.collectionName}]: Indexes synchronized.`);
222
222
  }
223
223
  catch (error) {
224
- Logger.error(`MONGODB [${this.collectionName}]: Error @ syncIndexes(): ${error.message}`);
224
+ Logger.error({ error, message: `MONGODB [${this.collectionName}]: Error @ syncIndexes(): ${error.message}` });
225
225
  throw error;
226
226
  }
227
227
  }
@@ -2,4 +2,4 @@
2
2
  * Supported ClickHouse data types that
3
3
  * can be used in ClickHouse table schemas.
4
4
  */
5
- export type ClickHouseDataType = 'Bool' | 'Date' | 'Float64' | 'Int32' | 'Int64' | 'String' | 'UInt8' | 'UInt64' | 'UUID' | `DateTime64(3, 'UTC') CODEC(Delta, ZSTD)` | `Enum8(${string})` | `LowCardinality(String)` | `Nullable(Float64)` | `Nullable(Int32)` | `Nullable(Int64)` | `Nullable(LowCardinality(String))` | `Nullable(String)` | `Nullable(UInt64)` | `Nullable(UUID)`;
5
+ export type ClickHouseDataType = 'Bool' | 'Date' | 'Float64' | 'Int32' | 'Int64' | 'String' | 'UInt8' | 'UInt64' | 'UUID' | `DateTime64(3, 'UTC') CODEC(Delta, ZSTD)` | `Enum8(${string})` | `LowCardinality(Nullable(String))` | `LowCardinality(String)` | `Nullable(Float64)` | `Nullable(Int32)` | `Nullable(Int64)` | `Nullable(String)` | `Nullable(UInt64)` | `Nullable(UUID)`;
@@ -4,4 +4,4 @@
4
4
  * @param value
5
5
  * @returns
6
6
  */
7
- export declare function getClickHouseParamType(value: number | string): 'Float64' | 'Int64' | 'String';
7
+ export declare function getClickHouseParamType(value: number | string | string[]): 'Array(String)' | 'Float64' | 'Int64' | 'String';
@@ -12,5 +12,8 @@ export function getClickHouseParamType(value) {
12
12
  }
13
13
  return Number.isInteger(value) ? 'Int64' : 'Float64';
14
14
  }
15
+ if (Array.isArray(value)) {
16
+ return 'Array(String)';
17
+ }
15
18
  return 'String';
16
19
  }
@@ -7,7 +7,7 @@
7
7
  * @throws Will throw an error if a placeholder is missing a corresponding parameter, if there are unused parameters, or if any parameter keys are invalid.
8
8
  * @returns An object containing the transformed query and a mapping of named parameters to their values.
9
9
  */
10
- export declare function preparePositionalQueryParams(query: string, params?: Record<string, number | string>): {
10
+ export declare function preparePositionalQueryParams(query: string, params?: Record<string, number | string | string[]>): {
11
11
  query: string;
12
- query_params: Record<string, number | string>;
12
+ query_params: Record<string, number | string | string[]>;
13
13
  };
@@ -114,7 +114,7 @@ export async function queryFromFile(client, filePath, params) {
114
114
  sql = await readFile(filePath, { encoding: 'utf-8' });
115
115
  }
116
116
  catch (error) {
117
- Logger.error(`CLICKHOUSE: Error @ queryFromFile(): Failed to read SQL file "${filePath}": ${error.message}`);
117
+ Logger.error({ error, message: `CLICKHOUSE: Error @ queryFromFile(): Failed to read SQL file "${filePath}": ${error.message}` });
118
118
  throw error;
119
119
  }
120
120
  const { query, queryParams } = prepareNamedQueryParams(sql, params, filePath);
@@ -127,7 +127,7 @@ export async function queryFromFile(client, filePath, params) {
127
127
  return result.json();
128
128
  }
129
129
  catch (error) {
130
- Logger.error(`CLICKHOUSE: Error @ queryFromFile(): Failed to execute query from file "${filePath}": ${error.message}`);
130
+ Logger.error({ error, message: `CLICKHOUSE: Error @ queryFromFile(): Failed to execute query from file "${filePath}": ${error.message}` });
131
131
  throw error;
132
132
  }
133
133
  }
@@ -141,7 +141,7 @@ export async function queryEachStatementFromFile(client, filePath, params) {
141
141
  sql = await readFile(filePath, { encoding: 'utf-8' });
142
142
  }
143
143
  catch (error) {
144
- Logger.error(`CLICKHOUSE: Error @ queryEachStatementFromFile(): Failed to read SQL file "${filePath}": ${error.message}`);
144
+ Logger.error({ error, message: `CLICKHOUSE: Error @ queryEachStatementFromFile(): Failed to read SQL file "${filePath}": ${error.message}` });
145
145
  throw error;
146
146
  }
147
147
  const statements = splitClickHouseStatements(sql);
@@ -157,7 +157,7 @@ export async function queryEachStatementFromFile(client, filePath, params) {
157
157
  merged.push(...(await result.json()));
158
158
  }
159
159
  catch (error) {
160
- Logger.error(`CLICKHOUSE: Error @ queryEachStatementFromFile(): Failed to execute statement from file "${filePath}": ${error.message}`);
160
+ Logger.error({ error, message: `CLICKHOUSE: Error @ queryEachStatementFromFile(): Failed to execute statement from file "${filePath}": ${error.message}` });
161
161
  throw error;
162
162
  }
163
163
  }
@@ -25,7 +25,7 @@ export async function queryFromString(client, query, params) {
25
25
  return result.json();
26
26
  }
27
27
  catch (error) {
28
- Logger.error(`CLICKHOUSE: Error @ queryFromString(): Failed to execute query "${query}": ${error.message}`);
28
+ Logger.error({ error, message: `CLICKHOUSE: Error @ queryFromString(): Failed to execute query "${query}": ${error.message}` });
29
29
  throw error;
30
30
  }
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/databases",
3
- "version": "20260616.2252.19",
3
+ "version": "20260617.1703.12",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"