@tmlmobilidade/interfaces 20251031.1051.3 → 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
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { RideSchema, UpdateRideSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type CreateSamDto, type Sam, type UpdateSamDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { SamSchema, UpdateSamSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexInspectionDecision } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexInspectionDecisionsClass extends MongoCollectionClass<SimplifiedApexInspectionDecision, SimplifiedApexInspectionDecision, SimplifiedApexInspectionDecision> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexInspectionDecisionsClass extends MongoCollectionClass {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexInspection } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexInspectionsClass extends MongoCollectionClass<SimplifiedApexInspection, SimplifiedApexInspection, SimplifiedApexInspection> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexInspectionsClass extends MongoCollectionClass {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexLocation, type UpdateSimplifiedApexLocationDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexLocationsClass extends MongoCollectionClass<SimplifiedApexLocation, SimplifiedApexLocation, UpdateSimplifiedApexLocationDto> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexLocationsClass extends MongoCollectionClass {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexOnBoardRefund, type UpdateSimplifiedApexOnBoardRefundDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexOnBoardRefundsClass extends MongoCollectionClass<SimplifiedApexOnBoardRefund, SimplifiedApexOnBoardRefund, UpdateSimplifiedApexOnBoardRefundDto> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexOnBoardRefundsClass extends MongoCollectionClass {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexOnBoardSale, type UpdateSimplifiedApexOnBoardSaleDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexOnBoardSalesClass extends MongoCollectionClass<SimplifiedApexOnBoardSale, SimplifiedApexOnBoardSale, UpdateSimplifiedApexOnBoardSaleDto> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexOnBoardSalesClass extends MongoCollectionClass {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type SimplifiedApexValidation, type UpdateSimplifiedApexValidationDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedApexValidationsClass extends MongoCollectionClass<SimplifiedApexValidation, SimplifiedApexValidation, UpdateSimplifiedApexValidationDto> {
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
4
  /* * */
5
5
  class SimplifiedApexValidationsClass extends MongoCollectionClass {
@@ -1,6 +1,6 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
- import { CreateStopDto, Stop, UpdateStopDto } from '@tmlmobilidade/types';
3
- import { IndexDescription, Sort } from 'mongodb';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
+ import { type CreateStopDto, type Stop, type UpdateStopDto } from '@tmlmobilidade/types';
3
+ import { type IndexDescription, type Sort } from 'mongodb';
4
4
  import { z } from 'zod';
5
5
  declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, UpdateStopDto> {
6
6
  private static _instance;
@@ -50,8 +50,8 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
50
50
  _id?: string | undefined;
51
51
  created_by?: string | undefined;
52
52
  updated_by?: string | undefined;
53
- curr_value?: any;
54
53
  metadata?: Record<string, unknown> | null | undefined;
54
+ curr_value?: any;
55
55
  prev_value?: any;
56
56
  } | {
57
57
  created_at: number & {
@@ -67,7 +67,6 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
67
67
  updated_by?: string | undefined;
68
68
  })[];
69
69
  is_locked: boolean;
70
- operational_status: "active" | "inactive" | "provisional" | "seasonal" | "voided";
71
70
  has_bench: "unknown" | "yes" | "no";
72
71
  has_network_map: "unknown" | "yes" | "no";
73
72
  has_schedules: "unknown" | "yes" | "no";
@@ -76,6 +75,7 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
76
75
  municipality_id: string;
77
76
  is_archived: boolean;
78
77
  jurisdiction: "unknown" | "ip" | "municipality" | "other";
78
+ lifecycle_status: "active" | "inactive" | "provisional" | "seasonal" | "voided";
79
79
  district_id: string;
80
80
  latitude: number;
81
81
  longitude: number;
@@ -149,8 +149,8 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
149
149
  _id?: string | undefined;
150
150
  created_by?: string | undefined;
151
151
  updated_by?: string | undefined;
152
- curr_value?: any;
153
152
  metadata?: Record<string, unknown> | null | undefined;
153
+ curr_value?: any;
154
154
  prev_value?: any;
155
155
  } | {
156
156
  created_at: number & {
@@ -166,7 +166,6 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
166
166
  updated_by?: string | undefined;
167
167
  })[];
168
168
  is_locked: boolean;
169
- operational_status: "active" | "inactive" | "provisional" | "seasonal" | "voided";
170
169
  has_bench: "unknown" | "yes" | "no";
171
170
  has_network_map: "unknown" | "yes" | "no";
172
171
  has_schedules: "unknown" | "yes" | "no";
@@ -175,6 +174,7 @@ declare class StopsClass extends MongoCollectionClass<Stop, CreateStopDto, Updat
175
174
  municipality_id: string;
176
175
  is_archived: boolean;
177
176
  jurisdiction: "unknown" | "ip" | "municipality" | "other";
177
+ lifecycle_status: "active" | "inactive" | "provisional" | "seasonal" | "voided";
178
178
  district_id: string;
179
179
  latitude: number;
180
180
  longitude: number;
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { StopSchema, UpdateStopSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -0,0 +1 @@
1
+ export * from './simplified-vehicle-events.js';
@@ -0,0 +1 @@
1
+ export * from './simplified-vehicle-events.js';
@@ -0,0 +1,13 @@
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
+ import { type SimplifiedVehicleEvent } from '@tmlmobilidade/types';
3
+ import { type IndexDescription } from 'mongodb';
4
+ declare class SimplifiedVehicleEventsClass extends MongoCollectionClass<SimplifiedVehicleEvent, SimplifiedVehicleEvent, SimplifiedVehicleEvent> {
5
+ private static _instance;
6
+ private constructor();
7
+ static getInstance(): Promise<SimplifiedVehicleEventsClass>;
8
+ protected getCollectionIndexes(): IndexDescription[];
9
+ protected getCollectionName(): string;
10
+ protected getEnvName(): string;
11
+ }
12
+ export declare const simplifiedVehicleEvents: SimplifiedVehicleEventsClass;
13
+ export {};
@@ -0,0 +1,33 @@
1
+ /* * */
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
+ import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
4
+ /* * */
5
+ class SimplifiedVehicleEventsClass extends MongoCollectionClass {
6
+ static _instance;
7
+ constructor() {
8
+ super();
9
+ }
10
+ static async getInstance() {
11
+ if (!SimplifiedVehicleEventsClass._instance) {
12
+ const instance = new SimplifiedVehicleEventsClass();
13
+ await instance.connect();
14
+ SimplifiedVehicleEventsClass._instance = instance;
15
+ }
16
+ return SimplifiedVehicleEventsClass._instance;
17
+ }
18
+ getCollectionIndexes() {
19
+ return [
20
+ { background: true, key: { received_at: 1 } },
21
+ // eslint-disable-next-line perfectionist/sort-objects
22
+ { background: true, key: { trip_id: 1, created_at: 1 } },
23
+ ];
24
+ }
25
+ getCollectionName() {
26
+ return 'simplified_vehicle_events';
27
+ }
28
+ getEnvName() {
29
+ return 'DATABASE_URI';
30
+ }
31
+ }
32
+ /* * */
33
+ export const simplifiedVehicleEvents = AsyncSingletonProxy(SimplifiedVehicleEventsClass);
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { CreateZoneDto, UpdateZoneDto, Zone } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
@@ -13,13 +13,13 @@ declare class ZonesClass extends MongoCollectionClass<Zone, CreateZoneDto, Updat
13
13
  * @param code The code of the zone to find
14
14
  * @returns A promise that resolves to the matching zone document or null if not found
15
15
  */
16
- findByCode(code: string): Promise<import("mongodb").WithId<Zone> | null>;
16
+ findByCode(code: string): Promise<import("mongodb").WithId<Zone>>;
17
17
  /**
18
18
  * Finds a zone document by its name.
19
19
  * @param name The name of the zone to find
20
20
  * @returns A promise that resolves to the matching zone document or null if not found
21
21
  */
22
- findByName(name: string): Promise<import("mongodb").WithId<Zone> | null>;
22
+ findByName(name: string): Promise<import("mongodb").WithId<Zone>>;
23
23
  /**
24
24
  * Updates a zone document by its code.
25
25
  * @param code The code of the zone to update.
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { UpdateZoneSchema, ZoneSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -1,4 +1,5 @@
1
- import { CreateUserDto, LoginDto, OneOrTheOther, Permission, Session, User } from '@tmlmobilidade/types';
1
+ import { type CreateUserDto, type LoginDto, type Organization, type Permission, type Session, type User } from '@tmlmobilidade/types';
2
+ export declare const AUTH_SESSION_COOKIE_NAME = "session_token";
2
3
  declare class AuthProvider {
3
4
  private static _instance;
4
5
  /**
@@ -6,23 +7,31 @@ declare class AuthProvider {
6
7
  */
7
8
  static getInstance(): Promise<AuthProvider>;
8
9
  /**
9
- * Get Permissions for a user based on their session token or user_id.
10
- * @param sessionToken - The session token (optional if user_id is provided)
11
- * @param user_id - The user ID (optional if sessionToken is provided)
12
- * @returns The permissions that the user has
10
+ * Get the organization for a user based on their session token.
11
+ * @param sessionToken The session token to look up.
12
+ * @returns The user associated with the session token.
13
+ * @throws An HTTP UNAUTHORIZED error code if user or session not found
14
+ */
15
+ getOrganizationFromSessionToken(sessionToken: string): Promise<Organization>;
16
+ /**
17
+ * Get Permissions for a user based on their session token.
18
+ * @param sessionToken The session token.
19
+ * @returns The permissions that the user has.
20
+ */
21
+ getPermissionsFromSessionToken(sessionToken: string): Promise<Permission[]>;
22
+ /**
23
+ * Get Permissions for a user based on their user ID.
24
+ * @param userId The user ID (optional if sessionToken is provided).
25
+ * @returns The permissions that the user has.
13
26
  */
14
- getPermissions<T>(params: OneOrTheOther<{
15
- sessionToken: string;
16
- }, {
17
- user_id: string;
18
- }>): Promise<Permission<T>[]>;
27
+ getPermissionsFromUserId(userId: string): Promise<Permission[]>;
19
28
  /**
20
- * Gets a user by their session token.
29
+ * Get a user object from their session token.
21
30
  * @param sessionToken The session token to look up.
22
31
  * @returns The user associated with the session token.
23
32
  * @throws An HTTP UNAUTHORIZED error code if user or session not found
24
33
  */
25
- getUser(sessionToken: string): Promise<User>;
34
+ getUserFromSessionToken(sessionToken: string): Promise<User>;
26
35
  /**
27
36
  * Login a user.
28
37
  * @param username The username of the user
@@ -1,10 +1,14 @@
1
1
  /* * */
2
- import { roles, sessions, users, verificationTokens } from '../../interfaces/index.js';
2
+ import { organizations, roles, sessions, users, verificationTokens } from '../../interfaces/index.js';
3
+ import { HttpException, HttpStatus, PAGE_ROUTES } from '@tmlmobilidade/consts';
4
+ import { Dates } from '@tmlmobilidade/dates';
3
5
  import { sendWelcomeEmail } from '@tmlmobilidade/emails';
4
- import { getAppConfig, HttpException, HttpStatus } from '@tmlmobilidade/lib';
5
- import { AsyncSingletonProxy, Dates, generateRandomString, generateRandomToken, mergeObjects } from '@tmlmobilidade/utils';
6
+ import { generateRandomString, generateRandomToken } from '@tmlmobilidade/strings';
7
+ import { AsyncSingletonProxy, mergeObjects } from '@tmlmobilidade/utils';
6
8
  import bcrypt from 'bcryptjs';
7
9
  /* * */
10
+ export const AUTH_SESSION_COOKIE_NAME = 'session_token';
11
+ /* * */
8
12
  class AuthProvider {
9
13
  static _instance;
10
14
  /**
@@ -17,67 +21,83 @@ class AuthProvider {
17
21
  return AuthProvider._instance;
18
22
  }
19
23
  /**
20
- * Get Permissions for a user based on their session token or user_id.
21
- * @param sessionToken - The session token (optional if user_id is provided)
22
- * @param user_id - The user ID (optional if sessionToken is provided)
23
- * @returns The permissions that the user has
24
+ * Get the organization for a user based on their session token.
25
+ * @param sessionToken The session token to look up.
26
+ * @returns The user associated with the session token.
27
+ * @throws An HTTP UNAUTHORIZED error code if user or session not found
24
28
  */
25
- async getPermissions(params) {
26
- //
27
- //
28
- // Get the user and their roles
29
- let userData;
30
- if ('user_id' in params) {
31
- const foundUser = await users.findOne({ _id: { $eq: params.user_id } });
32
- if (!foundUser) {
33
- throw new HttpException(HttpStatus.UNAUTHORIZED, 'User not found');
34
- }
35
- userData = foundUser;
36
- }
37
- else if ('sessionToken' in params) {
38
- userData = await this.getUser(params.sessionToken);
39
- }
40
- else {
41
- throw new HttpException(HttpStatus.BAD_REQUEST, 'Either sessionToken or user_id must be provided');
42
- }
29
+ async getOrganizationFromSessionToken(sessionToken) {
30
+ // Get the user associated with the session token
31
+ const userData = await this.getUserFromSessionToken(sessionToken);
32
+ // Find the organization associated with the user
33
+ const organizationData = await organizations.findOne({ _id: { $eq: userData.organization_id } });
34
+ if (!organizationData)
35
+ return undefined;
36
+ // Return the user data to the caller
37
+ return organizationData;
38
+ }
39
+ /**
40
+ * Get Permissions for a user based on their session token.
41
+ * @param sessionToken The session token.
42
+ * @returns The permissions that the user has.
43
+ */
44
+ async getPermissionsFromSessionToken(sessionToken) {
45
+ // Get the user associated with the session token
46
+ const userData = await this.getUserFromSessionToken(sessionToken);
47
+ // Return the permissions for the user ID
48
+ return this.getPermissionsFromUserId(userData._id);
49
+ }
50
+ /**
51
+ * Get Permissions for a user based on their user ID.
52
+ * @param userId The user ID (optional if sessionToken is provided).
53
+ * @returns The permissions that the user has.
54
+ */
55
+ async getPermissionsFromUserId(userId) {
56
+ // Get the user associated with the session token
57
+ const userData = await users.findById(userId);
58
+ if (!userData)
59
+ throw new HttpException(HttpStatus.UNAUTHORIZED, 'User not found.');
60
+ // Get the roles assigned to the user
43
61
  const rolesData = await roles.findMany({ _id: { $in: userData.role_ids } });
62
+ // Combine permissions from roles and user-specific permissions
44
63
  const allPermissions = [...rolesData.flatMap(role => role.permissions), ...userData.permissions];
64
+ // Merge permissions with the same scope and action
45
65
  const permissionsMap = new Map();
46
66
  for (const permission of allPermissions) {
67
+ // Setup a unique key based on scope and action
47
68
  const key = `${permission.scope}:${permission.action}`;
69
+ // If the permission already exists, merge them
48
70
  if (permissionsMap.has(key)) {
71
+ // Get the existing permission
49
72
  const existingPermission = permissionsMap.get(key);
50
- if (!existingPermission) {
51
- throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Error getting permissions');
52
- }
73
+ // Merge the existing permission with the new one
53
74
  permissionsMap.set(key, mergeObjects(existingPermission, permission));
54
- continue;
55
75
  }
56
- permissionsMap.set(key, permission);
76
+ else {
77
+ // Otherwise, just add the new permission
78
+ permissionsMap.set(key, permission);
79
+ }
57
80
  }
81
+ // Return the merged permissions as an array
58
82
  return Array.from(permissionsMap.values());
59
83
  }
60
84
  /**
61
- * Gets a user by their session token.
85
+ * Get a user object from their session token.
62
86
  * @param sessionToken The session token to look up.
63
87
  * @returns The user associated with the session token.
64
88
  * @throws An HTTP UNAUTHORIZED error code if user or session not found
65
89
  */
66
- async getUser(sessionToken) {
67
- //
68
- //
90
+ async getUserFromSessionToken(sessionToken) {
69
91
  // Find the current session in the database
70
92
  const sessionData = await sessions.findOne({ token: { $eq: sessionToken } });
71
- if (!sessionData) {
93
+ if (!sessionData)
72
94
  throw new HttpException(HttpStatus.UNAUTHORIZED, 'Session not found');
73
- }
74
- //
75
95
  // Find the user associated with the session
76
96
  const userData = await users.findOne({ _id: { $eq: sessionData.user_id } });
77
- if (!userData) {
97
+ if (!userData)
78
98
  throw new HttpException(HttpStatus.UNAUTHORIZED, 'User not found');
79
- }
80
- //
99
+ // Sanitize the user data by removing sensitive fields
100
+ userData.password_hash = undefined;
81
101
  // Return the user data to the caller
82
102
  return userData;
83
103
  }
@@ -91,34 +111,29 @@ class AuthProvider {
91
111
  * - INTERNAL_SERVER_ERROR if login fails
92
112
  */
93
113
  async login(loginDto) {
94
- //
95
- //
96
114
  // Find the user by email
97
115
  const userData = await users.findByEmail(loginDto.email, true);
98
- if (!userData) {
116
+ if (!userData)
99
117
  throw new HttpException(HttpStatus.UNAUTHORIZED, 'User not found');
100
- }
101
- //
102
118
  // Check if the password matches the stored hash
103
119
  const passwordHashMatch = await bcrypt.compare(loginDto.password, userData.password_hash ?? '');
104
- if (!passwordHashMatch) {
120
+ if (!passwordHashMatch)
105
121
  throw new HttpException(HttpStatus.UNAUTHORIZED, 'Invalid password');
106
- }
107
- //
108
122
  // Create a new session object if the password matches
109
- const session = {
123
+ const newSession = {
110
124
  _id: generateRandomString(),
111
125
  created_at: Dates.now('utc').unix_timestamp,
112
126
  created_by: 'system',
127
+ expires_at: Dates.now('utc').plus({ days: 30 }).unix_timestamp,
113
128
  token: generateRandomToken(),
114
129
  updated_at: Dates.now('utc').unix_timestamp,
115
130
  updated_by: 'system',
116
131
  user_id: userData._id.toString(),
117
132
  };
118
- await sessions.insertOne(session);
119
- //
133
+ // Insert the new session into the database
134
+ await sessions.insertOne(newSession);
120
135
  // Return the session to the caller
121
- return session;
136
+ return newSession;
122
137
  }
123
138
  /**
124
139
  * Logout a user by removing their session.
@@ -134,14 +149,11 @@ class AuthProvider {
134
149
  * - INTERNAL_SERVER_ERROR if user creation fails
135
150
  */
136
151
  async register(createUserDto) {
137
- //
138
- //
139
- // Insert the new user into the database
140
- // with the provided data
152
+ // Insert the new user into the database with the provided data
141
153
  const insertNewUserResult = await users.insertOne({ ...createUserDto });
142
- //
143
154
  // Generate a random token that will be used to verify the user
144
155
  const verificationToken = generateRandomToken();
156
+ // Insert the verification token into the database
145
157
  await verificationTokens.insertOne({
146
158
  created_by: 'system',
147
159
  expires_at: Dates.now('utc').plus({ days: 7 }).unix_timestamp,
@@ -149,12 +161,11 @@ class AuthProvider {
149
161
  updated_by: 'system',
150
162
  user_id: insertNewUserResult._id,
151
163
  });
152
- //
153
164
  // Send a welcome email to the user with the verification token
154
- sendWelcomeEmail({
165
+ await sendWelcomeEmail({
155
166
  props: {
156
167
  first_name: createUserDto.first_name,
157
- setup_password_link: `${getAppConfig('auth', 'frontend_url')}/verification?token=${verificationToken}`,
168
+ setup_password_link: `${PAGE_ROUTES.auth.CHANGE_PASSWORD_LIST}?token=${verificationToken}&email=${encodeURIComponent(createUserDto.email)}`,
158
169
  },
159
170
  to: createUserDto.email,
160
171
  });
@@ -0,0 +1 @@
1
+ export * from './auth.js';
@@ -0,0 +1 @@
1
+ export * from './auth.js';
@@ -0,0 +1,2 @@
1
+ export * from './auth/index.js';
2
+ export * from './storage/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './auth/index.js';
2
+ export * from './storage/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './oci-storage.js';
2
+ export * from './storage.factory.js';
3
+ export * from './storage.interface.js';
@@ -0,0 +1,3 @@
1
+ export * from './oci-storage.js';
2
+ export * from './storage.factory.js';
3
+ export * from './storage.interface.js';
@@ -1,5 +1,6 @@
1
1
  /* * */
2
- import { HttpException, HttpStatus, mimeTypes } from '@tmlmobilidade/lib';
2
+ import { HttpException, HttpStatus } from '@tmlmobilidade/consts';
3
+ import { mimeTypes } from '@tmlmobilidade/consts';
3
4
  import { readFileSync } from 'node:fs';
4
5
  import { OciError, Region, SimpleAuthenticationDetailsProvider } from 'oci-common';
5
6
  import { ObjectStorageClient, UploadManager } from 'oci-objectstorage';
@@ -1,18 +1,9 @@
1
1
  import { OCIStorageProviderConfiguration } from './oci-storage.js';
2
- import { S3StorageProviderConfiguration } from './s3-storage.js';
3
2
  import { IStorageProvider } from './storage.interface.js';
4
- export type StorageConfiguration = {
5
- aws_config: S3StorageProviderConfiguration;
6
- type: 'aws';
7
- } | {
8
- cloudflare_config: S3StorageProviderConfiguration & {
9
- endpoint: string;
10
- };
11
- type: 'cloudflare';
12
- } | {
3
+ export interface StorageConfiguration {
13
4
  oci_config: OCIStorageProviderConfiguration;
14
5
  type: 'oci';
15
- };
6
+ }
16
7
  export declare class StorageFactory {
17
8
  /**
18
9
  * Creates and returns an instance of a storage service based on the provided configuration.
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-extraneous-class */
2
2
  /* * */
3
3
  import { OCIStorageProvider } from './oci-storage.js';
4
- import { S3StorageProvider } from './s3-storage.js';
5
4
  /* * */
6
5
  export class StorageFactory {
7
6
  /**
@@ -12,10 +11,6 @@ export class StorageFactory {
12
11
  */
13
12
  static create(config) {
14
13
  switch (config.type) {
15
- case 'aws':
16
- return new S3StorageProvider(config.aws_config);
17
- case 'cloudflare':
18
- return new S3StorageProvider(config.cloudflare_config);
19
14
  case 'oci':
20
15
  return new OCIStorageProvider(config.oci_config);
21
16
  default: