@tmlmobilidade/interfaces 20250825.1202.16 → 20250825.1622.13

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.
@@ -0,0 +1,18 @@
1
+ import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { Alert, CreateAlertDto, UpdateAlertDto } from '@tmlmobilidade/types';
3
+ import { IndexDescription } from 'mongodb';
4
+ import { z } from 'zod';
5
+ declare class AlertsRealtimeClass extends MongoCollectionClass<Alert, CreateAlertDto, UpdateAlertDto> {
6
+ private static _instance;
7
+ protected createSchema: z.ZodSchema;
8
+ protected updateSchema: z.ZodSchema;
9
+ private constructor();
10
+ static getInstance(): Promise<AlertsRealtimeClass>;
11
+ findByMunicipalityId(municipality_id: string): Promise<import("mongodb").WithId<Alert>[]>;
12
+ findByTitle(title: string): Promise<import("mongodb").WithId<Alert> | null>;
13
+ protected getCollectionIndexes(): IndexDescription[];
14
+ protected getCollectionName(): string;
15
+ protected getEnvName(): string;
16
+ }
17
+ export declare const alertsRealtime: AlertsRealtimeClass;
18
+ export {};
@@ -0,0 +1,47 @@
1
+ /* * */
2
+ import { MongoCollectionClass } from '../../mongo-collection.js';
3
+ import { AlertSchema, UpdateAlertSchema } from '@tmlmobilidade/types';
4
+ import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
+ /* * */
6
+ class AlertsRealtimeClass extends MongoCollectionClass {
7
+ static _instance;
8
+ createSchema = AlertSchema;
9
+ updateSchema = UpdateAlertSchema;
10
+ constructor() {
11
+ super();
12
+ }
13
+ static async getInstance() {
14
+ if (!AlertsRealtimeClass._instance) {
15
+ const instance = new AlertsRealtimeClass();
16
+ await instance.connect();
17
+ AlertsRealtimeClass._instance = instance;
18
+ }
19
+ return AlertsRealtimeClass._instance;
20
+ }
21
+ async findByMunicipalityId(municipality_id) {
22
+ return this.mongoCollection.find({ municipality_ids: { $in: [municipality_id] } }).toArray();
23
+ }
24
+ async findByTitle(title) {
25
+ return this.mongoCollection.findOne({ title });
26
+ }
27
+ getCollectionIndexes() {
28
+ return [
29
+ { background: true, key: { agency_ids: 1 } },
30
+ { background: true, key: { line_ids: 1 } },
31
+ { background: true, key: { municipality_ids: 1 } },
32
+ { background: true, key: { route_ids: 1 } },
33
+ { background: true, key: { stop_ids: 1 } },
34
+ { background: true, key: { title: 1 } },
35
+ { background: true, key: { active_period_end_date: -1, active_period_start_date: -1 } },
36
+ { background: true, key: { publish_end_date: -1, publish_start_date: -1 } },
37
+ ];
38
+ }
39
+ getCollectionName() {
40
+ return 'alerts_realtime';
41
+ }
42
+ getEnvName() {
43
+ return 'DATABASE_URI';
44
+ }
45
+ }
46
+ /* * */
47
+ export const alertsRealtime = AsyncSingletonProxy(AlertsRealtimeClass);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20250825.1202.16",
3
+ "version": "20250825.1622.13",
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",