@tmlmobilidade/databases 20260519.2046.53 → 20260525.1333.38

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.
@@ -172,7 +172,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
172
172
  feed_version?: string | null | undefined;
173
173
  };
174
174
  }>;
175
- version: import("zod").ZodLiteral<"cap-v1">;
175
+ version: import("zod").ZodLiteral<"mobi-v1">;
176
176
  }, "strip", import("zod").ZodTypeAny, {
177
177
  _id: string;
178
178
  created_at: number & {
@@ -182,7 +182,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
182
182
  received_at: number & {
183
183
  __brand: "UnixTimestamp";
184
184
  };
185
- version: "cap-v1";
185
+ version: "mobi-v1";
186
186
  payload: {
187
187
  vehicle: {
188
188
  trip: {
@@ -218,7 +218,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
218
218
  created_at: number;
219
219
  agency_id: string;
220
220
  received_at: number;
221
- version: "cap-v1";
221
+ version: "mobi-v1";
222
222
  payload: {
223
223
  vehicle: {
224
224
  trip: {
@@ -1414,14 +1414,14 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1414
1414
  }>;
1415
1415
  timestamp: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
1416
1416
  trip: import("zod").ZodObject<{
1417
- schedule_relationship: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodEnum<["SCHEDULED", "NOT_SCHEDULED"]>>>;
1417
+ schedule_relationship: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodEnum<["SCHEDULED", "NOT_SCHEDULED", "CANCELED"]>>>;
1418
1418
  trip_id: import("zod").ZodString;
1419
1419
  }, "strip", import("zod").ZodTypeAny, {
1420
1420
  trip_id: string;
1421
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1421
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1422
1422
  }, {
1423
1423
  trip_id: string;
1424
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1424
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1425
1425
  }>;
1426
1426
  vehicle: import("zod").ZodObject<{
1427
1427
  id: import("zod").ZodString;
@@ -1433,7 +1433,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1433
1433
  }, "strip", import("zod").ZodTypeAny, {
1434
1434
  trip: {
1435
1435
  trip_id: string;
1436
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1436
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1437
1437
  };
1438
1438
  position: {
1439
1439
  latitude: number;
@@ -1448,7 +1448,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1448
1448
  }, {
1449
1449
  trip: {
1450
1450
  trip_id: string;
1451
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1451
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1452
1452
  };
1453
1453
  position: {
1454
1454
  latitude: number;
@@ -1465,7 +1465,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1465
1465
  vehicle: {
1466
1466
  trip: {
1467
1467
  trip_id: string;
1468
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1468
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1469
1469
  };
1470
1470
  position: {
1471
1471
  latitude: number;
@@ -1488,7 +1488,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1488
1488
  vehicle: {
1489
1489
  trip: {
1490
1490
  trip_id: string;
1491
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1491
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1492
1492
  };
1493
1493
  position: {
1494
1494
  latitude: number;
@@ -1523,7 +1523,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1523
1523
  vehicle: {
1524
1524
  trip: {
1525
1525
  trip_id: string;
1526
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1526
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1527
1527
  };
1528
1528
  position: {
1529
1529
  latitude: number;
@@ -1554,7 +1554,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1554
1554
  vehicle: {
1555
1555
  trip: {
1556
1556
  trip_id: string;
1557
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1557
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1558
1558
  };
1559
1559
  position: {
1560
1560
  latitude: number;
@@ -1,4 +1,4 @@
1
- import { type ApiCacheKey, type ApiCacheKeyParams } from './keys.js';
1
+ import { type ApiCacheKey } from './keys.js';
2
2
  import { type RedisClientType } from 'redis';
3
3
  declare class ApiCacheClass {
4
4
  private static _instance;
@@ -30,12 +30,11 @@ declare class ApiCacheClass {
30
30
  /**
31
31
  * Retrieves a cache entry by its key.
32
32
  * @param key The key of the cache entry to retrieve.
33
- * @param params Optional params to replace `{named}` tokens in the key.
34
33
  * @returns A promise that resolves with the cache entry value,
35
34
  * or `null` if not found.
36
35
  * @throws Will throw an error if the retrieval process fails.
37
36
  */
38
- get(key: ApiCacheKey, params?: ApiCacheKeyParams): Promise<null | string>;
37
+ get(key: ApiCacheKey): Promise<null | string>;
39
38
  /**
40
39
  * Scans cache keys by pattern.
41
40
  * @param pattern The redis pattern to match.
@@ -46,12 +45,9 @@ declare class ApiCacheClass {
46
45
  * Saves a cache entry with an optional time-to-live (TTL).
47
46
  * @param key The key of the cache entry to save.
48
47
  * @param value The value of the cache entry to save. Must be a string.
49
- * @param options Optional params / TTL. Omit when neither applies.
48
+ * @param ttl Optional time-to-live (TTL) in seconds. Omit when not needed.
50
49
  */
51
- set(key: ApiCacheKey, value: string, options?: {
52
- params?: ApiCacheKeyParams;
53
- ttl?: number;
54
- }): Promise<void>;
50
+ set(key: ApiCacheKey, value: string, ttl?: number): Promise<void>;
55
51
  protected connectToClient(): Promise<RedisClientType>;
56
52
  /**
57
53
  * Initializes the Redis client.
@@ -1,6 +1,5 @@
1
1
  /* * */
2
2
  import { GORedisClient } from '../../clients/go-redis.js';
3
- import { resolveApiCacheKey } from './keys.js';
4
3
  import { asyncSingletonProxy } from '@tmlmobilidade/utils';
5
4
  /* * */
6
5
  class ApiCacheClass {
@@ -61,14 +60,12 @@ class ApiCacheClass {
61
60
  /**
62
61
  * Retrieves a cache entry by its key.
63
62
  * @param key The key of the cache entry to retrieve.
64
- * @param params Optional params to replace `{named}` tokens in the key.
65
63
  * @returns A promise that resolves with the cache entry value,
66
64
  * or `null` if not found.
67
65
  * @throws Will throw an error if the retrieval process fails.
68
66
  */
69
- async get(key, params) {
70
- const parsedKey = resolveApiCacheKey(key, params);
71
- const result = await this.client.get(parsedKey);
67
+ async get(key) {
68
+ const result = await this.client.get(key);
72
69
  if (typeof result !== 'string')
73
70
  return null;
74
71
  return result;
@@ -89,18 +86,17 @@ class ApiCacheClass {
89
86
  * Saves a cache entry with an optional time-to-live (TTL).
90
87
  * @param key The key of the cache entry to save.
91
88
  * @param value The value of the cache entry to save. Must be a string.
92
- * @param options Optional params / TTL. Omit when neither applies.
89
+ * @param ttl Optional time-to-live (TTL) in seconds. Omit when not needed.
93
90
  */
94
- async set(key, value, options) {
95
- const parsedKey = resolveApiCacheKey(key, options?.params);
91
+ async set(key, value, ttl) {
96
92
  // Validate value type before setting cache
97
93
  if (typeof value !== 'string')
98
- throw new Error(`[ApiCache] Value must be a string. Got "${typeof value}" for key "${parsedKey}".`);
94
+ throw new Error(`[ApiCache] Value must be a string. Got "${typeof value}" for key "${key}".`);
99
95
  // Set cache with optional TTL
100
- if (options?.ttl)
101
- await this.client.set(parsedKey, value, { expiration: { type: 'EX', value: options.ttl } });
96
+ if (ttl)
97
+ await this.client.set(key, value, { expiration: { type: 'EX', value: ttl } });
102
98
  else
103
- await this.client.set(parsedKey, value);
99
+ await this.client.set(key, value);
104
100
  }
105
101
  connectToClient() {
106
102
  return GORedisClient.getClient();
@@ -1,4 +1,2 @@
1
- export type ApiCacheKeyParams = Record<string, boolean | number | string>;
2
- export declare const ApiCacheKeyValues: readonly ["hub:alerts:published:json", "hub:alerts:published:gtfs", "hub:alerts:published:rss", "hub:plans:approved:json", "hub:plans:gtfs", "hub:plans:gtfs:cm", "hub:facilities", "hub:facilities:helpdesk", "hub:facilities:boat_stations", "hub:facilities:light_rail_stations", "hub:facilities:subway_stations", "hub:facilities:train_stations", "hub:facilities:pips", "hub:facilities:schools", "hub:facilities:stores", "hub:locations:municipalities", "hub:locations:districts", "hub:locations:localities", "hub:locations:parishes", "hub:network:dates", "hub:network:periods", "hub:network:stops", "hub:network:lines", "hub:network:routes", "hub:network:plans", "hub:network:vehicles", "hub:network:vehicles:protobuf", "hub:network:patterns:{patternId}", "hub:network:shapes:{shapeId}"];
1
+ export declare const ApiCacheKeyValues: readonly ["hub:alerts:published:json", "hub:alerts:published:gtfs", "hub:alerts:published:rss", "hub:plans:approved:json", "hub:plans:gtfs", "hub:plans:gtfs:cm", "hub:facilities", "hub:facilities:helpdesk", "hub:facilities:boat_stations", "hub:facilities:light_rail_stations", "hub:facilities:subway_stations", "hub:facilities:train_stations", "hub:facilities:pips", "hub:facilities:schools", "hub:facilities:stores", "hub:locations:municipalities", "hub:locations:districts", "hub:locations:localities", "hub:locations:parishes", "hub:network:dates", "hub:network:periods", "hub:network:stops", "hub:network:lines", "hub:network:routes", "hub:network:plans", "hub:network:vehicles", "hub:network:vehicles:protobuf", `hub:network:patterns:${string}`, `hub:network:shapes:${string}`];
3
2
  export type ApiCacheKey = typeof ApiCacheKeyValues[number];
4
- export declare function resolveApiCacheKey(key: ApiCacheKey, params?: ApiCacheKeyParams): string;
@@ -1,4 +1,5 @@
1
1
  /* * */
2
+ const dynamicKey = () => 'use-for-dynamic-key';
2
3
  export const ApiCacheKeyValues = [
3
4
  'hub:alerts:published:json',
4
5
  'hub:alerts:published:gtfs',
@@ -27,20 +28,6 @@ export const ApiCacheKeyValues = [
27
28
  'hub:network:plans',
28
29
  'hub:network:vehicles',
29
30
  'hub:network:vehicles:protobuf',
30
- 'hub:network:patterns:{patternId}',
31
- 'hub:network:shapes:{shapeId}',
31
+ `hub:network:patterns:${dynamicKey()}`,
32
+ `hub:network:shapes:${dynamicKey()}`,
32
33
  ];
33
- export function resolveApiCacheKey(key, params) {
34
- const resolvedKey = key.replace(/\{([^{}]+)\}/g, (_match, paramName) => {
35
- const value = params?.[paramName];
36
- if (typeof value === 'undefined' || value === null) {
37
- throw new Error(`[ApiCache] Missing key param "${paramName}" for key "${key}".`);
38
- }
39
- return String(value);
40
- });
41
- const unresolvedParam = resolvedKey.match(/\{([^{}]+)\}/);
42
- if (unresolvedParam) {
43
- throw new Error(`[ApiCache] Missing key param "${unresolvedParam[1]}" for key "${key}".`);
44
- }
45
- return resolvedKey;
46
- }
@@ -177,7 +177,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
177
177
  feed_version?: string | null | undefined;
178
178
  };
179
179
  }>;
180
- version: import("zod").ZodLiteral<"cap-v1">;
180
+ version: import("zod").ZodLiteral<"mobi-v1">;
181
181
  }, "strip", import("zod").ZodTypeAny, {
182
182
  _id: string;
183
183
  created_at: number & {
@@ -187,7 +187,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
187
187
  received_at: number & {
188
188
  __brand: "UnixTimestamp";
189
189
  };
190
- version: "cap-v1";
190
+ version: "mobi-v1";
191
191
  payload: {
192
192
  vehicle: {
193
193
  trip: {
@@ -223,7 +223,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
223
223
  created_at: number;
224
224
  agency_id: string;
225
225
  received_at: number;
226
- version: "cap-v1";
226
+ version: "mobi-v1";
227
227
  payload: {
228
228
  vehicle: {
229
229
  trip: {
@@ -1419,14 +1419,14 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1419
1419
  }>;
1420
1420
  timestamp: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
1421
1421
  trip: import("zod").ZodObject<{
1422
- schedule_relationship: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodEnum<["SCHEDULED", "NOT_SCHEDULED"]>>>;
1422
+ schedule_relationship: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodEnum<["SCHEDULED", "NOT_SCHEDULED", "CANCELED"]>>>;
1423
1423
  trip_id: import("zod").ZodString;
1424
1424
  }, "strip", import("zod").ZodTypeAny, {
1425
1425
  trip_id: string;
1426
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1426
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1427
1427
  }, {
1428
1428
  trip_id: string;
1429
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1429
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1430
1430
  }>;
1431
1431
  vehicle: import("zod").ZodObject<{
1432
1432
  id: import("zod").ZodString;
@@ -1438,7 +1438,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1438
1438
  }, "strip", import("zod").ZodTypeAny, {
1439
1439
  trip: {
1440
1440
  trip_id: string;
1441
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1441
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1442
1442
  };
1443
1443
  position: {
1444
1444
  latitude: number;
@@ -1453,7 +1453,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1453
1453
  }, {
1454
1454
  trip: {
1455
1455
  trip_id: string;
1456
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1456
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1457
1457
  };
1458
1458
  position: {
1459
1459
  latitude: number;
@@ -1470,7 +1470,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1470
1470
  vehicle: {
1471
1471
  trip: {
1472
1472
  trip_id: string;
1473
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1473
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1474
1474
  };
1475
1475
  position: {
1476
1476
  latitude: number;
@@ -1493,7 +1493,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1493
1493
  vehicle: {
1494
1494
  trip: {
1495
1495
  trip_id: string;
1496
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1496
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1497
1497
  };
1498
1498
  position: {
1499
1499
  latitude: number;
@@ -1528,7 +1528,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1528
1528
  vehicle: {
1529
1529
  trip: {
1530
1530
  trip_id: string;
1531
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1531
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1532
1532
  };
1533
1533
  position: {
1534
1534
  latitude: number;
@@ -1559,7 +1559,7 @@ declare class RawVehicleEventsNewClass extends MongoInterfaceTemplate<RawVehicle
1559
1559
  vehicle: {
1560
1560
  trip: {
1561
1561
  trip_id: string;
1562
- schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | null | undefined;
1562
+ schedule_relationship?: "SCHEDULED" | "NOT_SCHEDULED" | "CANCELED" | null | undefined;
1563
1563
  };
1564
1564
  position: {
1565
1565
  latitude: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/databases",
3
- "version": "20260519.2046.53",
3
+ "version": "20260525.1333.38",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@tmlmobilidade/tsconfig": "*",
50
- "@types/node": "25.8.0",
50
+ "@types/node": "25.9.1",
51
51
  "resolve-tspaths": "0.8.23",
52
52
  "tsc-watch": "7.2.0",
53
53
  "typescript": "5.9.3"