@tmlmobilidade/interfaces 20251103.1255.55 → 20251202.1817.5

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 (153) hide show
  1. package/dist/{src → common}/enrich-user-refs.js +1 -2
  2. package/dist/common/index.d.ts +4 -0
  3. package/dist/common/index.js +4 -0
  4. package/dist/{src → common}/mongo-collection.d.ts +3 -3
  5. package/dist/{src → common}/mongo-collection.js +4 -3
  6. package/dist/{src → common}/mongo-transaction.d.ts +1 -1
  7. package/dist/index.d.ts +3 -6
  8. package/dist/index.js +3 -6
  9. package/dist/{src/interfaces → interfaces}/agencies/agencies.d.ts +3 -3
  10. package/dist/{src/interfaces → interfaces}/agencies/agencies.js +1 -1
  11. package/dist/{src/interfaces → interfaces}/alerts/alerts.d.ts +42 -4
  12. package/dist/{src/interfaces → interfaces}/alerts/alerts.js +4 -1
  13. package/dist/interfaces/alerts/index.d.ts +1 -0
  14. package/dist/interfaces/alerts/index.js +1 -0
  15. package/dist/interfaces/auth/roles.d.ts +240 -0
  16. package/dist/interfaces/auth/roles.js +69 -0
  17. package/dist/{src/interfaces → interfaces}/auth/sessions.d.ts +1 -1
  18. package/dist/{src/interfaces → interfaces}/auth/sessions.js +1 -1
  19. package/dist/interfaces/auth/users.d.ts +522 -0
  20. package/dist/interfaces/auth/users.js +118 -0
  21. package/dist/{src/interfaces → interfaces}/auth/verification-tokens.d.ts +2 -2
  22. package/dist/{src/interfaces → interfaces}/auth/verification-tokens.js +1 -1
  23. package/dist/{src/interfaces → interfaces}/file-exports/file-exports.d.ts +1 -1
  24. package/dist/{src/interfaces → interfaces}/file-exports/file-exports.js +2 -2
  25. package/dist/{src/interfaces → interfaces}/files/files.d.ts +1 -1
  26. package/dist/{src/interfaces → interfaces}/files/files.js +6 -36
  27. package/dist/{src/interfaces → interfaces}/gtfs-validations/gtfs-validations.d.ts +3 -3
  28. package/dist/{src/interfaces → interfaces}/gtfs-validations/gtfs-validations.js +1 -1
  29. package/dist/{src/interfaces → interfaces}/index.d.ts +1 -0
  30. package/dist/{src/interfaces → interfaces}/index.js +1 -0
  31. package/dist/interfaces/locations/index.d.ts +2 -0
  32. package/dist/interfaces/locations/index.js +2 -0
  33. package/dist/{src/interfaces → interfaces}/locations/locations.d.ts +17 -17
  34. package/dist/{src/interfaces → interfaces}/locations/locations.js +3 -3
  35. package/dist/interfaces/locations/municipalities.d.ts +13 -0
  36. package/dist/interfaces/locations/municipalities.js +29 -0
  37. package/dist/{src/interfaces → interfaces}/metrics/metrics.d.ts +1 -1
  38. package/dist/{src/interfaces → interfaces}/metrics/metrics.js +1 -1
  39. package/dist/{src/interfaces → interfaces}/notifications/notifications.d.ts +1 -1
  40. package/dist/{src/interfaces → interfaces}/notifications/notifications.js +5 -5
  41. package/dist/{src/interfaces → interfaces}/organizations/organizations.d.ts +1 -1
  42. package/dist/{src/interfaces → interfaces}/organizations/organizations.js +3 -3
  43. package/dist/interfaces/pcgidb/index.d.ts +3 -0
  44. package/dist/interfaces/pcgidb/index.js +3 -0
  45. package/dist/interfaces/pcgidb/pcgidb-legacy.d.ts +19 -0
  46. package/dist/interfaces/pcgidb/pcgidb-legacy.js +133 -0
  47. package/dist/interfaces/pcgidb/pcgidb-ticketing.d.ts +16 -0
  48. package/dist/interfaces/pcgidb/pcgidb-ticketing.js +127 -0
  49. package/dist/interfaces/pcgidb/pcgidb-validations.d.ts +17 -0
  50. package/dist/interfaces/pcgidb/pcgidb-validations.js +129 -0
  51. package/dist/{src/interfaces → interfaces}/plans/plans.d.ts +12 -6
  52. package/dist/{src/interfaces → interfaces}/plans/plans.js +1 -1
  53. package/dist/{src/interfaces → interfaces}/proposed-changes/proposed-changes.d.ts +1 -1
  54. package/dist/{src/interfaces → interfaces}/proposed-changes/proposed-changes.js +1 -1
  55. package/dist/{src/interfaces → interfaces}/rides/hashed-shapes.d.ts +1 -1
  56. package/dist/{src/interfaces → interfaces}/rides/hashed-shapes.js +1 -1
  57. package/dist/{src/interfaces → interfaces}/rides/hashed-trips.d.ts +1 -1
  58. package/dist/{src/interfaces → interfaces}/rides/hashed-trips.js +1 -1
  59. package/dist/{src/interfaces → interfaces}/rides/pipelines.d.ts +9 -9
  60. package/dist/{src/interfaces → interfaces}/rides/pipelines.js +20 -2
  61. package/dist/{src/interfaces → interfaces}/rides/ride-acceptances.d.ts +1 -1
  62. package/dist/{src/interfaces → interfaces}/rides/ride-acceptances.js +4 -3
  63. package/dist/{src/interfaces → interfaces}/rides/rides.d.ts +313 -313
  64. package/dist/{src/interfaces → interfaces}/rides/rides.js +1 -1
  65. package/dist/{src/interfaces → interfaces}/sams/sams.d.ts +1 -1
  66. package/dist/{src/interfaces → interfaces}/sams/sams.js +1 -1
  67. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspection-decisions.d.ts +1 -1
  68. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspection-decisions.js +1 -1
  69. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspections.d.ts +1 -1
  70. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspections.js +1 -1
  71. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-locations.d.ts +1 -1
  72. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-locations.js +1 -1
  73. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-refunds.d.ts +1 -1
  74. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-refunds.js +1 -1
  75. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-sales.d.ts +1 -1
  76. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-sales.js +1 -1
  77. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-validations.d.ts +1 -1
  78. package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-validations.js +1 -1
  79. package/dist/{src/interfaces → interfaces}/stops/stops.d.ts +7 -7
  80. package/dist/{src/interfaces → interfaces}/stops/stops.js +1 -1
  81. package/dist/interfaces/vehicle-events/index.d.ts +1 -0
  82. package/dist/interfaces/vehicle-events/index.js +1 -0
  83. package/dist/interfaces/vehicle-events/simplified-vehicle-events.d.ts +13 -0
  84. package/dist/interfaces/vehicle-events/simplified-vehicle-events.js +33 -0
  85. package/dist/{src/interfaces → interfaces}/zones/zones.d.ts +3 -3
  86. package/dist/{src/interfaces → interfaces}/zones/zones.js +1 -1
  87. package/dist/{src/providers → providers}/auth/auth.d.ts +21 -12
  88. package/dist/{src/providers → providers}/auth/auth.js +71 -60
  89. package/dist/providers/auth/index.d.ts +1 -0
  90. package/dist/providers/auth/index.js +1 -0
  91. package/dist/providers/index.d.ts +2 -0
  92. package/dist/providers/index.js +2 -0
  93. package/dist/providers/storage/index.d.ts +3 -0
  94. package/dist/providers/storage/index.js +3 -0
  95. package/dist/{src/providers → providers}/storage/oci-storage.js +2 -1
  96. package/dist/{src/providers → providers}/storage/storage.factory.d.ts +2 -11
  97. package/dist/{src/providers → providers}/storage/storage.factory.js +0 -5
  98. package/package.json +25 -26
  99. package/dist/src/interfaces/alerts/alerts-realtime.d.ts +0 -86
  100. package/dist/src/interfaces/alerts/alerts-realtime.js +0 -47
  101. package/dist/src/interfaces/alerts/index.d.ts +0 -2
  102. package/dist/src/interfaces/alerts/index.js +0 -2
  103. package/dist/src/interfaces/auth/roles.d.ts +0 -39
  104. package/dist/src/interfaces/auth/roles.js +0 -42
  105. package/dist/src/interfaces/auth/users.d.ts +0 -107
  106. package/dist/src/interfaces/auth/users.js +0 -110
  107. package/dist/src/interfaces/locations/index.d.ts +0 -1
  108. package/dist/src/interfaces/locations/index.js +0 -1
  109. package/dist/src/interfaces/vehicle-events/index.d.ts +0 -1
  110. package/dist/src/interfaces/vehicle-events/index.js +0 -1
  111. package/dist/src/interfaces/vehicle-events/vehicle-events.d.ts +0 -13
  112. package/dist/src/interfaces/vehicle-events/vehicle-events.js +0 -37
  113. package/dist/src/providers/index.d.ts +0 -5
  114. package/dist/src/providers/index.js +0 -6
  115. package/dist/src/providers/storage/s3-storage.d.ts +0 -64
  116. package/dist/src/providers/storage/s3-storage.js +0 -184
  117. /package/dist/{src → common}/aggregation-pipeline.d.ts +0 -0
  118. /package/dist/{src → common}/aggregation-pipeline.js +0 -0
  119. /package/dist/{src → common}/enrich-user-refs.d.ts +0 -0
  120. /package/dist/{src → common}/mongo-transaction.js +0 -0
  121. /package/dist/{src/interfaces → interfaces}/agencies/index.d.ts +0 -0
  122. /package/dist/{src/interfaces → interfaces}/agencies/index.js +0 -0
  123. /package/dist/{src/interfaces → interfaces}/auth/index.d.ts +0 -0
  124. /package/dist/{src/interfaces → interfaces}/auth/index.js +0 -0
  125. /package/dist/{src/interfaces → interfaces}/file-exports/index.d.ts +0 -0
  126. /package/dist/{src/interfaces → interfaces}/file-exports/index.js +0 -0
  127. /package/dist/{src/interfaces → interfaces}/files/index.d.ts +0 -0
  128. /package/dist/{src/interfaces → interfaces}/files/index.js +0 -0
  129. /package/dist/{src/interfaces → interfaces}/gtfs-validations/index.d.ts +0 -0
  130. /package/dist/{src/interfaces → interfaces}/gtfs-validations/index.js +0 -0
  131. /package/dist/{src/interfaces → interfaces}/metrics/index.d.ts +0 -0
  132. /package/dist/{src/interfaces → interfaces}/metrics/index.js +0 -0
  133. /package/dist/{src/interfaces → interfaces}/notifications/index.d.ts +0 -0
  134. /package/dist/{src/interfaces → interfaces}/notifications/index.js +0 -0
  135. /package/dist/{src/interfaces → interfaces}/organizations/index.d.ts +0 -0
  136. /package/dist/{src/interfaces → interfaces}/organizations/index.js +0 -0
  137. /package/dist/{src/interfaces → interfaces}/plans/index.d.ts +0 -0
  138. /package/dist/{src/interfaces → interfaces}/plans/index.js +0 -0
  139. /package/dist/{src/interfaces → interfaces}/proposed-changes/index.d.ts +0 -0
  140. /package/dist/{src/interfaces → interfaces}/proposed-changes/index.js +0 -0
  141. /package/dist/{src/interfaces → interfaces}/rides/index.d.ts +0 -0
  142. /package/dist/{src/interfaces → interfaces}/rides/index.js +0 -0
  143. /package/dist/{src/interfaces → interfaces}/sams/index.d.ts +0 -0
  144. /package/dist/{src/interfaces → interfaces}/sams/index.js +0 -0
  145. /package/dist/{src/interfaces → interfaces}/simplified-apex/index.d.ts +0 -0
  146. /package/dist/{src/interfaces → interfaces}/simplified-apex/index.js +0 -0
  147. /package/dist/{src/interfaces → interfaces}/stops/index.d.ts +0 -0
  148. /package/dist/{src/interfaces → interfaces}/stops/index.js +0 -0
  149. /package/dist/{src/interfaces → interfaces}/zones/index.d.ts +0 -0
  150. /package/dist/{src/interfaces → interfaces}/zones/index.js +0 -0
  151. /package/dist/{src/providers → providers}/storage/oci-storage.d.ts +0 -0
  152. /package/dist/{src/providers → providers}/storage/storage.interface.d.ts +0 -0
  153. /package/dist/{src/providers → providers}/storage/storage.interface.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20251103.1255.55",
4
- "author": "João de Vasconcelos & Jusi Monteiro",
3
+ "version": "20251202.1817.5",
4
+ "author": {
5
+ "email": "iso@tmlmobilidade.pt",
6
+ "name": "TML-ISO"
7
+ },
5
8
  "license": "AGPL-3.0-or-later",
6
9
  "homepage": "https://github.com/tmlmobilidade/services#readme",
7
10
  "bugs": {
@@ -22,41 +25,37 @@
22
25
  },
23
26
  "type": "module",
24
27
  "files": [
25
- "dist/"
28
+ "dist"
26
29
  ],
27
- "exports": {
28
- ".": {
29
- "types": "./dist/index.d.ts",
30
- "default": "./dist/index.js"
31
- }
32
- },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
33
32
  "scripts": {
34
- "build": "rimraf ./dist && tsc && resolve-tspaths",
33
+ "build": "tsc && resolve-tspaths",
35
34
  "lint": "eslint && tsc --noEmit",
36
- "lint:fix": "eslint --fix"
35
+ "lint:fix": "eslint --fix",
36
+ "watch": "tsc-watch --onSuccess 'resolve-tspaths'"
37
37
  },
38
38
  "dependencies": {
39
- "@aws-sdk/client-s3": "3.913.0",
40
- "@aws-sdk/s3-request-presigner": "3.913.0",
41
- "@tmlmobilidade/connectors": "*",
39
+ "@tmlmobilidade/consts": "*",
40
+ "@tmlmobilidade/dates": "*",
42
41
  "@tmlmobilidade/emails": "*",
43
- "@tmlmobilidade/lib": "*",
44
- "@tmlmobilidade/tsconfig": "*",
45
- "@tmlmobilidade/types": "*",
42
+ "@tmlmobilidade/files": "*",
43
+ "@tmlmobilidade/logger": "*",
44
+ "@tmlmobilidade/mongo": "*",
45
+ "@tmlmobilidade/ssh": "*",
46
+ "@tmlmobilidade/strings": "*",
46
47
  "@tmlmobilidade/utils": "*",
47
- "bcryptjs": "3.0.2",
48
- "luxon": "3.7.2",
49
- "mongodb": "6.20.0",
50
- "oci-common": "2.119.1",
51
- "oci-objectstorage": "2.119.1",
48
+ "bcryptjs": "3.0.3",
49
+ "oci-common": "2.122.0",
50
+ "oci-objectstorage": "2.122.0",
52
51
  "zod": "3.25.76"
53
52
  },
54
53
  "devDependencies": {
55
- "@carrismetropolitana/eslint": "20250622.1204.50",
56
- "@types/luxon": "3.7.1",
57
- "@types/node": "24.9.1",
54
+ "@tmlmobilidade/tsconfig": "*",
55
+ "@tmlmobilidade/types": "*",
56
+ "@types/node": "24.10.1",
58
57
  "resolve-tspaths": "0.8.23",
59
- "rimraf": "6.0.1",
58
+ "tsc-watch": "7.2.0",
60
59
  "typescript": "5.9.3"
61
60
  }
62
61
  }
@@ -1,86 +0,0 @@
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<{
12
- _id: string;
13
- created_at: number & {
14
- __brand: "UnixTimestamp";
15
- };
16
- created_by: string;
17
- updated_at: number & {
18
- __brand: "UnixTimestamp";
19
- };
20
- type: "PLANNED" | "REALTIME";
21
- municipality_ids: string[];
22
- active_period_start_date: number & {
23
- __brand: "UnixTimestamp";
24
- };
25
- cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "ROAD_INCIDENT" | "SYSTEM_FAILURE" | "TRAFFIC_JAM" | "VEHICLE_ISSUE";
26
- description: string;
27
- effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
28
- modified_by: string;
29
- publish_start_date: number & {
30
- __brand: "UnixTimestamp";
31
- };
32
- publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
33
- reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
34
- references: {
35
- child_ids: string[];
36
- parent_id: string;
37
- }[];
38
- title: string;
39
- updated_by?: string | undefined;
40
- active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
41
- coordinates?: [number, number] | null | undefined;
42
- file_id?: string | null | undefined;
43
- info_url?: string | undefined;
44
- publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
45
- }>[]>;
46
- findByTitle(title: string): Promise<import("mongodb").WithId<{
47
- _id: string;
48
- created_at: number & {
49
- __brand: "UnixTimestamp";
50
- };
51
- created_by: string;
52
- updated_at: number & {
53
- __brand: "UnixTimestamp";
54
- };
55
- type: "PLANNED" | "REALTIME";
56
- municipality_ids: string[];
57
- active_period_start_date: number & {
58
- __brand: "UnixTimestamp";
59
- };
60
- cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "ROAD_INCIDENT" | "SYSTEM_FAILURE" | "TRAFFIC_JAM" | "VEHICLE_ISSUE";
61
- description: string;
62
- effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
63
- modified_by: string;
64
- publish_start_date: number & {
65
- __brand: "UnixTimestamp";
66
- };
67
- publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
68
- reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
69
- references: {
70
- child_ids: string[];
71
- parent_id: string;
72
- }[];
73
- title: string;
74
- updated_by?: string | undefined;
75
- active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
76
- coordinates?: [number, number] | null | undefined;
77
- file_id?: string | null | undefined;
78
- info_url?: string | undefined;
79
- publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
80
- }> | null>;
81
- protected getCollectionIndexes(): IndexDescription[];
82
- protected getCollectionName(): string;
83
- protected getEnvName(): string;
84
- }
85
- export declare const alertsRealtime: AlertsRealtimeClass;
86
- export {};
@@ -1,47 +0,0 @@
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);
@@ -1,2 +0,0 @@
1
- export * from './alerts-realtime.js';
2
- export * from './alerts.js';
@@ -1,2 +0,0 @@
1
- export * from './alerts-realtime.js';
2
- export * from './alerts.js';
@@ -1,39 +0,0 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
- import { CreateRoleDto, Role, UpdateRoleDto } from '@tmlmobilidade/types';
3
- import { IndexDescription } from 'mongodb';
4
- import { z } from 'zod';
5
- declare class RolesClass extends MongoCollectionClass<Role, CreateRoleDto, UpdateRoleDto> {
6
- private static _instance;
7
- protected createSchema: z.ZodSchema;
8
- protected updateSchema: z.ZodSchema;
9
- private constructor();
10
- static getInstance(): Promise<RolesClass>;
11
- /**
12
- * Finds a role by its name
13
- *
14
- * @param name - The name of the role to find
15
- * @returns A promise that resolves to the matching role document or null if not found
16
- */
17
- findByName(name: string): Promise<import("mongodb").WithId<{
18
- _id: string;
19
- created_at: number & {
20
- __brand: "UnixTimestamp";
21
- };
22
- updated_at: number & {
23
- __brand: "UnixTimestamp";
24
- };
25
- name: string;
26
- permissions: {
27
- action: string;
28
- scope: string;
29
- resource?: Record<string, any> | null | undefined;
30
- }[];
31
- created_by?: string | undefined;
32
- updated_by?: string | undefined;
33
- }> | null>;
34
- protected getCollectionIndexes(): IndexDescription[];
35
- protected getCollectionName(): string;
36
- protected getEnvName(): string;
37
- }
38
- export declare const roles: RolesClass;
39
- export {};
@@ -1,42 +0,0 @@
1
- /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
3
- import { RoleSchema, UpdateRoleSchema } from '@tmlmobilidade/types';
4
- import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
- /* * */
6
- class RolesClass extends MongoCollectionClass {
7
- static _instance;
8
- createSchema = RoleSchema;
9
- updateSchema = UpdateRoleSchema;
10
- constructor() {
11
- super();
12
- }
13
- static async getInstance() {
14
- if (!RolesClass._instance) {
15
- const instance = new RolesClass();
16
- await instance.connect();
17
- RolesClass._instance = instance;
18
- }
19
- return RolesClass._instance;
20
- }
21
- /**
22
- * Finds a role by its name
23
- *
24
- * @param name - The name of the role to find
25
- * @returns A promise that resolves to the matching role document or null if not found
26
- */
27
- async findByName(name) {
28
- return this.mongoCollection.findOne({ name });
29
- }
30
- getCollectionIndexes() {
31
- return [
32
- { background: true, key: { name: 1 }, unique: true },
33
- ];
34
- }
35
- getCollectionName() {
36
- return 'roles';
37
- }
38
- getEnvName() {
39
- return 'DATABASE_URI';
40
- }
41
- }
42
- export const roles = AsyncSingletonProxy(RolesClass);
@@ -1,107 +0,0 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
- import { CreateUserDto, UpdateUserDto, User } from '@tmlmobilidade/types';
3
- import { Filter, FindOptions, IndexDescription, WithId } from 'mongodb';
4
- import { z } from 'zod';
5
- declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, UpdateUserDto> {
6
- private static _instance;
7
- protected createSchema: z.ZodSchema;
8
- protected updateSchema: z.ZodSchema;
9
- private constructor();
10
- static getInstance(): Promise<UsersClass>;
11
- /**
12
- * Finds a user document by its email.
13
- *
14
- * @param email - The email of the user to find
15
- * @param includePasswordHash - Whether to include the password hash in the result
16
- * @returns A promise that resolves to the matching user document or null if not found
17
- */
18
- findByEmail(email: string, includePasswordHash?: boolean): Promise<null | WithId<User>>;
19
- /**
20
- * Finds a document by its ID.
21
- *
22
- * @param id - The ID of the document to find
23
- * @param includePasswordHash - Whether to include the password hash in the result
24
- * @returns A promise that resolves to the matching document or null if not found
25
- */
26
- findById(id: string, options?: FindOptions<User>, includePasswordHash?: boolean): Promise<User | null>;
27
- /**
28
- * Finds users by their organization code
29
- *
30
- * @param code - The code of the organization to find users for
31
- * @param includePasswordHash - Whether to include the password hash in the result
32
- * @returns A promise that resolves to the matching user documents or null if not found
33
- */
34
- findByOrganization(id: string, includePasswordHash?: boolean): Promise<{
35
- created_at: number & {
36
- __brand: "UnixTimestamp";
37
- };
38
- updated_at: number & {
39
- __brand: "UnixTimestamp";
40
- };
41
- created_by?: string | undefined | undefined;
42
- updated_by?: string | undefined | undefined;
43
- avatar?: string | null | undefined | undefined;
44
- bio?: string | null | undefined | undefined;
45
- email: string;
46
- email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
47
- first_name: string;
48
- last_name: string;
49
- organization_id?: string | null | undefined | undefined;
50
- permissions: import("@tmlmobilidade/types").Permission<unknown>[];
51
- phone?: string | null | undefined | undefined;
52
- preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
53
- role_ids: string[];
54
- session_ids: string[];
55
- theme_id?: string | null | undefined | undefined;
56
- verification_token_ids: string[];
57
- _id: string;
58
- }[]>;
59
- /**
60
- * Finds a user by their role
61
- *
62
- * @param role - The role of the user to find
63
- * @returns A promise that resolves to the matching user document or null if not found
64
- */
65
- findByRole(role: string, includePasswordHash?: boolean): Promise<{
66
- created_at: number & {
67
- __brand: "UnixTimestamp";
68
- };
69
- updated_at: number & {
70
- __brand: "UnixTimestamp";
71
- };
72
- created_by?: string | undefined | undefined;
73
- updated_by?: string | undefined | undefined;
74
- avatar?: string | null | undefined | undefined;
75
- bio?: string | null | undefined | undefined;
76
- email: string;
77
- email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
78
- first_name: string;
79
- last_name: string;
80
- organization_id?: string | null | undefined | undefined;
81
- permissions: import("@tmlmobilidade/types").Permission<unknown>[];
82
- phone?: string | null | undefined | undefined;
83
- preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
84
- role_ids: string[];
85
- session_ids: string[];
86
- theme_id?: string | null | undefined | undefined;
87
- verification_token_ids: string[];
88
- _id: string;
89
- }[]>;
90
- /**
91
- * Finds multiple documents matching the filter criteria with optional pagination and sorting.
92
- *
93
- * @param filter - (Optional) filter criteria to match documents
94
- * @param perPage - (Optional) number of documents per page for pagination
95
- * @param page - (Optional) page number for pagination
96
- * @param sort - (Optional) sort specification
97
- * @returns A promise that resolves to an array of matching documents
98
- */
99
- findMany(filter?: Filter<User>, options?: FindOptions<User>): Promise<WithId<User>[]>;
100
- findOne(filter: Filter<User>): Promise<WithId<User> | null>;
101
- protected getCollectionIndexes(): IndexDescription[];
102
- protected getCollectionName(): string;
103
- protected getEnvName(): string;
104
- private deletePasswordHash;
105
- }
106
- export declare const users: UsersClass;
107
- export {};
@@ -1,110 +0,0 @@
1
- /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
3
- import { UpdateUserSchema, UserSchema } from '@tmlmobilidade/types';
4
- import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
- /* * */
6
- class UsersClass extends MongoCollectionClass {
7
- static _instance;
8
- createSchema = UserSchema;
9
- updateSchema = UpdateUserSchema;
10
- constructor() {
11
- super();
12
- }
13
- static async getInstance() {
14
- if (!UsersClass._instance) {
15
- const instance = new UsersClass();
16
- await instance.connect();
17
- UsersClass._instance = instance;
18
- }
19
- return UsersClass._instance;
20
- }
21
- /**
22
- * Finds a user document by its email.
23
- *
24
- * @param email - The email of the user to find
25
- * @param includePasswordHash - Whether to include the password hash in the result
26
- * @returns A promise that resolves to the matching user document or null if not found
27
- */
28
- async findByEmail(email, includePasswordHash = false) {
29
- const user = await this.mongoCollection.findOne({ email: { $eq: email } });
30
- if (!user) {
31
- return null;
32
- }
33
- return includePasswordHash ? user : this.deletePasswordHash(user);
34
- }
35
- /**
36
- * Finds a document by its ID.
37
- *
38
- * @param id - The ID of the document to find
39
- * @param includePasswordHash - Whether to include the password hash in the result
40
- * @returns A promise that resolves to the matching document or null if not found
41
- */
42
- async findById(id, options, includePasswordHash = false) {
43
- const user = await this.mongoCollection.findOne({ _id: id }, options);
44
- if (!user) {
45
- return null;
46
- }
47
- return includePasswordHash ? user : this.deletePasswordHash(user);
48
- }
49
- /**
50
- * Finds users by their organization code
51
- *
52
- * @param code - The code of the organization to find users for
53
- * @param includePasswordHash - Whether to include the password hash in the result
54
- * @returns A promise that resolves to the matching user documents or null if not found
55
- */
56
- async findByOrganization(id, includePasswordHash = false) {
57
- const users = await this.mongoCollection.find({ organization_id: { $in: [id] } }).toArray();
58
- return includePasswordHash ? users : users.map(user => this.deletePasswordHash(user));
59
- }
60
- /**
61
- * Finds a user by their role
62
- *
63
- * @param role - The role of the user to find
64
- * @returns A promise that resolves to the matching user document or null if not found
65
- */
66
- async findByRole(role, includePasswordHash = false) {
67
- const users = await this.mongoCollection.find({ role_ids: { $in: [role] } }).toArray();
68
- return includePasswordHash ? users : users.map(user => this.deletePasswordHash(user));
69
- }
70
- /**
71
- * Finds multiple documents matching the filter criteria with optional pagination and sorting.
72
- *
73
- * @param filter - (Optional) filter criteria to match documents
74
- * @param perPage - (Optional) number of documents per page for pagination
75
- * @param page - (Optional) page number for pagination
76
- * @param sort - (Optional) sort specification
77
- * @returns A promise that resolves to an array of matching documents
78
- */
79
- async findMany(filter, options) {
80
- const users = await this.mongoCollection.find(filter ?? {}, options).toArray();
81
- return users.map(user => this.deletePasswordHash(user));
82
- }
83
- async findOne(filter) {
84
- const user = await this.mongoCollection.findOne(filter);
85
- if (!user) {
86
- return null;
87
- }
88
- return this.deletePasswordHash(user);
89
- }
90
- getCollectionIndexes() {
91
- return [
92
- { background: true, key: { email: 1 }, unique: true },
93
- { background: true, key: { 'profile.first_name': 1, 'profile.last_name': 1 } },
94
- { background: true, key: { session_ids: 1 } },
95
- { background: true, key: { role_ids: 1 } },
96
- ];
97
- }
98
- getCollectionName() {
99
- return 'users';
100
- }
101
- getEnvName() {
102
- return 'DATABASE_URI';
103
- }
104
- deletePasswordHash(user) {
105
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
106
- const { password_hash, ...userWithoutPassword } = user;
107
- return userWithoutPassword;
108
- }
109
- }
110
- export const users = AsyncSingletonProxy(UsersClass);
@@ -1 +0,0 @@
1
- export * from './locations.js';
@@ -1 +0,0 @@
1
- export * from './locations.js';
@@ -1 +0,0 @@
1
- export * from './vehicle-events.js';
@@ -1 +0,0 @@
1
- export * from './vehicle-events.js';
@@ -1,13 +0,0 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
- import { VehicleEvent } from '@tmlmobilidade/types';
3
- import { IndexDescription } from 'mongodb';
4
- declare class VehicleEventsClass extends MongoCollectionClass<VehicleEvent, VehicleEvent, VehicleEvent> {
5
- private static _instance;
6
- private constructor();
7
- static getInstance(): Promise<VehicleEventsClass>;
8
- protected getCollectionIndexes(): IndexDescription[];
9
- protected getCollectionName(): string;
10
- protected getEnvName(): string;
11
- }
12
- export declare const vehicleEvents: VehicleEventsClass;
13
- export {};
@@ -1,37 +0,0 @@
1
- /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
3
- import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
- /* * */
5
- class VehicleEventsClass extends MongoCollectionClass {
6
- static _instance;
7
- constructor() {
8
- super();
9
- }
10
- static async getInstance() {
11
- if (!VehicleEventsClass._instance) {
12
- const instance = new VehicleEventsClass();
13
- await instance.connect();
14
- VehicleEventsClass._instance = instance;
15
- }
16
- return VehicleEventsClass._instance;
17
- }
18
- getCollectionIndexes() {
19
- return [
20
- { background: true, key: { created_at: 1 } },
21
- { background: true, key: { received_at: 1 } },
22
- // eslint-disable-next-line perfectionist/sort-objects
23
- { background: true, key: { trip_id: 1, created_at: 1 } },
24
- { background: true, key: { agency_id: 1, created_at: 1 } },
25
- // eslint-disable-next-line perfectionist/sort-objects
26
- { background: true, key: { vehicle_id: 1, created_at: 1 } },
27
- ];
28
- }
29
- getCollectionName() {
30
- return 'vehicle_events';
31
- }
32
- getEnvName() {
33
- return 'TML_INTERFACE_VEHICLE_EVENTS';
34
- }
35
- }
36
- /* * */
37
- export const vehicleEvents = AsyncSingletonProxy(VehicleEventsClass);
@@ -1,5 +0,0 @@
1
- export * from './auth/auth.js';
2
- export * from './storage/oci-storage.js';
3
- export * from './storage/s3-storage.js';
4
- export * from './storage/storage.factory.js';
5
- export * from './storage/storage.interface.js';
@@ -1,6 +0,0 @@
1
- /* * */
2
- export * from './auth/auth.js';
3
- export * from './storage/oci-storage.js';
4
- export * from './storage/s3-storage.js';
5
- export * from './storage/storage.factory.js';
6
- export * from './storage/storage.interface.js';
@@ -1,64 +0,0 @@
1
- import { IStorageProvider } from './storage.interface.js';
2
- import { Readable } from 'node:stream';
3
- export interface S3StorageProviderConfiguration {
4
- access_key_id: string;
5
- bucket_name: string;
6
- endpoint?: string;
7
- region?: string;
8
- secret_access_key: string;
9
- }
10
- export declare class S3StorageProvider implements IStorageProvider {
11
- private readonly bucketName;
12
- private readonly s3Client;
13
- constructor(config: S3StorageProviderConfiguration);
14
- /**
15
- * Checks if the bucket exists and creates it if it doesn't.
16
- */
17
- checkBucket(): Promise<void>;
18
- /**
19
- * Copies a file from one path to another.
20
- * @param source - The source file path and name in S3.
21
- * @param destination - The destination file path and name in S3.
22
- */
23
- copyFile(source: string, destination: string): Promise<void>;
24
- /**
25
- * Deletes a file from S3.
26
- * @param key - The file path and name in S3.
27
- */
28
- deleteFile(key: string): Promise<void>;
29
- /**
30
- * Deletes multiple files from S3.
31
- * @param keys - The file paths and names in S3.
32
- */
33
- deleteFiles(keys: string[]): Promise<void>;
34
- /**
35
- * Downloads a file from S3.
36
- * @param key - The file path and name in S3.
37
- * @returns The file as a readable stream.
38
- */
39
- downloadFile(key: string): Promise<Readable>;
40
- /**
41
- * Checks if a file exists in S3.
42
- * @param key - The file path and name in S3.
43
- * @returns True if the file exists, false otherwise.
44
- */
45
- fileExists(key: string): Promise<boolean>;
46
- /**
47
- * Get the signed URL of a file from the storage.
48
- * @param key - The file path and name in the storage.
49
- * @returns The signed URL of the file.
50
- */
51
- getFileUrl(key: string): Promise<string>;
52
- /**
53
- * Lists files in an S3 bucket.
54
- * @param prefix - Filter by prefix (optional).
55
- * @returns Array of file keys in the bucket.
56
- */
57
- listFiles(prefix?: string): Promise<string[]>;
58
- /**
59
- * Uploads a file to S3.
60
- * @param key - The file path and name in S3.
61
- * @param body - The content to upload, either as a string, buffer, or readable stream.
62
- */
63
- uploadFile(key: string, body: Buffer | Readable | ReadableStream | string, mimeType?: string): Promise<void>;
64
- }