@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
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { users } from './interfaces/auth/users.js';
2
+ import { users } from '../interfaces/auth/users.js';
3
3
  import { UserDisplayFields } from '@tmlmobilidade/types';
4
4
  const isUserRefKey = (k) => k === 'created_by' || k === 'updated_by';
5
5
  const isEligibleId = (v) => typeof v === 'string' && v && v !== 'system';
@@ -51,7 +51,6 @@ async function fetchUsersMap(ids) {
51
51
  for (const u of result) {
52
52
  map.set(u._id, {
53
53
  _id: u._id,
54
- avatar: u.avatar ?? undefined,
55
54
  email: u.email,
56
55
  first_name: u.first_name,
57
56
  last_name: u.last_name,
@@ -0,0 +1,4 @@
1
+ export * from './aggregation-pipeline.js';
2
+ export * from './enrich-user-refs.js';
3
+ export * from './mongo-collection.js';
4
+ export * from './mongo-transaction.js';
@@ -0,0 +1,4 @@
1
+ export * from './aggregation-pipeline.js';
2
+ export * from './enrich-user-refs.js';
3
+ export * from './mongo-collection.js';
4
+ export * from './mongo-transaction.js';
@@ -1,5 +1,5 @@
1
1
  import { AggregationPipeline } from './aggregation-pipeline.js';
2
- import { MongoConnector } from '@tmlmobilidade/connectors';
2
+ import { MongoConnector } from '@tmlmobilidade/mongo';
3
3
  import { type UnixTimestamp } from '@tmlmobilidade/types';
4
4
  import { AggregateOptions, AggregationCursor, Collection, DeleteOptions, DeleteResult, Document, Filter, FindOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, MongoClientOptions, UpdateOptions, UpdateResult, WithId } from 'mongodb';
5
5
  import { z } from 'zod';
@@ -91,14 +91,14 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
91
91
  * @param options - (Optional) find options
92
92
  * @returns A promise that resolves to an array of matching documents
93
93
  */
94
- findMany(filter?: Filter<T>, options?: FindOptions<T>): Promise<WithId<T>[]>;
94
+ findMany(filter?: Filter<T>, options?: FindOptions): Promise<WithId<T>[]>;
95
95
  /**
96
96
  * Finds a single document matching the filter criteria.
97
97
  * @param filter - The filter criteria to match the document
98
98
  * @param options - (Optional) find options
99
99
  * @returns A promise that resolves to the matching document or null if not found
100
100
  */
101
- findOne(filter: Filter<T>, options?: FindOptions<T>): Promise<null | WithId<T>>;
101
+ findOne(filter: Filter<T>, options?: FindOptions): Promise<null | WithId<T>>;
102
102
  /**
103
103
  * Gets the MongoDB collection instance.
104
104
  * @returns The MongoDB collection instance
@@ -1,7 +1,8 @@
1
1
  /* * */
2
- import { MongoConnector } from '@tmlmobilidade/connectors';
3
- import { HttpException, HttpStatus } from '@tmlmobilidade/lib';
4
- import { Dates, generateRandomString } from '@tmlmobilidade/utils';
2
+ import { HttpException, HttpStatus } from '@tmlmobilidade/consts';
3
+ import { Dates } from '@tmlmobilidade/dates';
4
+ import { MongoConnector } from '@tmlmobilidade/mongo';
5
+ import { generateRandomString } from '@tmlmobilidade/strings';
5
6
  /* * */
6
7
  export class MongoCollectionClass {
7
8
  createSchema = null;
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @see https://www.mongodb.com/docs/manual/core/transactions-operations/
7
7
  */
8
- import { MongoConnector } from '@tmlmobilidade/connectors';
8
+ import { MongoConnector } from '@tmlmobilidade/mongo';
9
9
  import { ClientSession } from 'mongodb';
10
10
  import { MongoCollectionClass } from './mongo-collection.js';
11
11
  export declare class Transaction {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- export * from './src/aggregation-pipeline.js';
2
- export * from './src/enrich-user-refs.js';
3
- export * from './src/interfaces/index.js';
4
- export * from './src/mongo-collection.js';
5
- export * from './src/mongo-transaction.js';
6
- export * from './src/providers/index.js';
1
+ export * from './common/index.js';
2
+ export * from './interfaces/index.js';
3
+ export * from './providers/index.js';
7
4
  export type { AggregationCursor, ChangeStreamDeleteDocument, ChangeStreamDocument, ChangeStreamInsertDocument, ChangeStreamUpdateDocument, Collection, DeleteOptions, Document, Filter, FindOptions, IndexDescription, InsertOneOptions, InsertOneResult, MongoClientOptions, OptionalUnlessRequiredId, Sort, UpdateDescription, UpdateOptions, UpdateResult, WithId, } from 'mongodb';
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  /* * */
2
- export * from './src/aggregation-pipeline.js';
3
- export * from './src/enrich-user-refs.js';
4
- export * from './src/interfaces/index.js';
5
- export * from './src/mongo-collection.js';
6
- export * from './src/mongo-transaction.js';
7
- export * from './src/providers/index.js';
2
+ export * from './common/index.js';
3
+ export * from './interfaces/index.js';
4
+ export * from './providers/index.js';
@@ -1,5 +1,5 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
- import { Agency, CreateAgencyDto, UpdateAgencyDto } from '@tmlmobilidade/types';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
+ import { type Agency, type CreateAgencyDto, type UpdateAgencyDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
5
5
  declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto, UpdateAgencyDto> {
@@ -34,7 +34,7 @@ declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto
34
34
  website_url: string;
35
35
  created_by?: string | undefined;
36
36
  updated_by?: string | undefined;
37
- }> | null>;
37
+ }>>;
38
38
  updateByCode(code: string, fields: Partial<Agency>): Promise<import("mongodb").UpdateResult<{
39
39
  _id: string;
40
40
  created_at: 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 { AgencySchema, UpdateAgencySchema } 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 { Alert, CreateAlertDto, UpdateAlertDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
@@ -8,7 +8,7 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
8
8
  protected updateSchema: z.ZodSchema;
9
9
  private constructor();
10
10
  static getInstance(): Promise<AlertsClass>;
11
- findByMunicipalityId(municipality_id: string): Promise<import("mongodb").WithId<{
11
+ findByExternalId(external_id: string): Promise<import("mongodb").WithId<{
12
12
  _id: string;
13
13
  created_at: number & {
14
14
  __brand: "UnixTimestamp";
@@ -18,7 +18,42 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
18
18
  __brand: "UnixTimestamp";
19
19
  };
20
20
  type: "PLANNED" | "REALTIME";
21
+ active_period_start_date: number & {
22
+ __brand: "UnixTimestamp";
23
+ };
24
+ 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";
25
+ description: string;
26
+ effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
27
+ modified_by: string;
21
28
  municipality_ids: 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
+ external_id?: string | null | undefined;
43
+ file_id?: string | null | undefined;
44
+ info_url?: string | undefined;
45
+ publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
46
+ }>>;
47
+ findByMunicipalityId(municipality_id: string): Promise<import("mongodb").WithId<{
48
+ _id: string;
49
+ created_at: number & {
50
+ __brand: "UnixTimestamp";
51
+ };
52
+ created_by: string;
53
+ updated_at: number & {
54
+ __brand: "UnixTimestamp";
55
+ };
56
+ type: "PLANNED" | "REALTIME";
22
57
  active_period_start_date: number & {
23
58
  __brand: "UnixTimestamp";
24
59
  };
@@ -26,6 +61,7 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
26
61
  description: string;
27
62
  effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
28
63
  modified_by: string;
64
+ municipality_ids: string[];
29
65
  publish_start_date: number & {
30
66
  __brand: "UnixTimestamp";
31
67
  };
@@ -39,6 +75,7 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
39
75
  updated_by?: string | undefined;
40
76
  active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
41
77
  coordinates?: [number, number] | null | undefined;
78
+ external_id?: string | null | undefined;
42
79
  file_id?: string | null | undefined;
43
80
  info_url?: string | undefined;
44
81
  publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
@@ -53,7 +90,6 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
53
90
  __brand: "UnixTimestamp";
54
91
  };
55
92
  type: "PLANNED" | "REALTIME";
56
- municipality_ids: string[];
57
93
  active_period_start_date: number & {
58
94
  __brand: "UnixTimestamp";
59
95
  };
@@ -61,6 +97,7 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
61
97
  description: string;
62
98
  effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
63
99
  modified_by: string;
100
+ municipality_ids: string[];
64
101
  publish_start_date: number & {
65
102
  __brand: "UnixTimestamp";
66
103
  };
@@ -74,10 +111,11 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
74
111
  updated_by?: string | undefined;
75
112
  active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
76
113
  coordinates?: [number, number] | null | undefined;
114
+ external_id?: string | null | undefined;
77
115
  file_id?: string | null | undefined;
78
116
  info_url?: string | undefined;
79
117
  publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
80
- }> | null>;
118
+ }>>;
81
119
  protected getCollectionIndexes(): IndexDescription[];
82
120
  protected getCollectionName(): string;
83
121
  protected getEnvName(): string;
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { AlertSchema, UpdateAlertSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -18,6 +18,9 @@ class AlertsClass extends MongoCollectionClass {
18
18
  }
19
19
  return AlertsClass._instance;
20
20
  }
21
+ async findByExternalId(external_id) {
22
+ return this.mongoCollection.findOne({ external_id });
23
+ }
21
24
  async findByMunicipalityId(municipality_id) {
22
25
  return this.mongoCollection.find({ municipality_ids: { $in: [municipality_id] } }).toArray();
23
26
  }
@@ -0,0 +1 @@
1
+ export * from './alerts.js';
@@ -0,0 +1 @@
1
+ export * from './alerts.js';
@@ -0,0 +1,240 @@
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
+ import { type CreateRoleDto, type Role, type UpdateRoleDto } from '@tmlmobilidade/types';
3
+ import { type Filter, type FindOptions, type 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 user document by its ID.
13
+ * @param id The ID of the user document to find
14
+ * @param includePasswordHash Whether to include the password hash in the result
15
+ * @returns A promise that resolves to the matching user document or null if not found
16
+ */
17
+ findById(id: string, options?: FindOptions): Promise<{
18
+ permissions: ({
19
+ scope: "agencies";
20
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
21
+ } | {
22
+ scope: "alerts_scheduled";
23
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
24
+ } | {
25
+ scope: "alerts_realtime";
26
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
27
+ resources: {
28
+ agency_ids: string[];
29
+ };
30
+ } | {
31
+ scope: "rides";
32
+ action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update";
33
+ resources: {
34
+ agency_ids: string[];
35
+ };
36
+ } | {
37
+ scope: "sams";
38
+ action: "read";
39
+ } | {
40
+ scope: "gtfs_validations";
41
+ action: "create" | "read" | "request_approval";
42
+ resources: {
43
+ agency_ids: string[];
44
+ };
45
+ } | {
46
+ scope: "home";
47
+ action: "read_links" | "read_wiki";
48
+ } | {
49
+ scope: "organizations";
50
+ action: "create" | "update" | "delete" | "read";
51
+ } | {
52
+ scope: "performance";
53
+ action: "read";
54
+ } | {
55
+ scope: "plans";
56
+ action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
57
+ resources: {
58
+ agency_ids: string[];
59
+ };
60
+ } | {
61
+ scope: "roles";
62
+ action: "create" | "update" | "delete" | "read";
63
+ } | {
64
+ scope: "stops";
65
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
66
+ resources: {
67
+ municipality_ids: string[];
68
+ agency_ids: string[];
69
+ };
70
+ } | {
71
+ scope: "users";
72
+ action: "create" | "update" | "delete" | "read";
73
+ })[];
74
+ created_at: number & {
75
+ __brand: "UnixTimestamp";
76
+ };
77
+ created_by?: string | undefined;
78
+ updated_at: number & {
79
+ __brand: "UnixTimestamp";
80
+ };
81
+ updated_by?: string | undefined;
82
+ name: string;
83
+ _id: string;
84
+ }>;
85
+ /**
86
+ * Finds multiple documents matching the filter criteria
87
+ * with optional pagination and sorting.
88
+ * @param filter (Optional) filter criteria to match documents.
89
+ * @param perPage (Optional) number of documents per page for pagination.
90
+ * @param page (Optional) page number for pagination.
91
+ * @param sort (Optional) sort specification.
92
+ * @returns A promise that resolves to an array of matching documents.
93
+ */
94
+ findMany(filter?: Filter<Role>, options?: FindOptions): Promise<{
95
+ permissions: ({
96
+ scope: "agencies";
97
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
98
+ } | {
99
+ scope: "alerts_scheduled";
100
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
101
+ } | {
102
+ scope: "alerts_realtime";
103
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
104
+ resources: {
105
+ agency_ids: string[];
106
+ };
107
+ } | {
108
+ scope: "rides";
109
+ action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update";
110
+ resources: {
111
+ agency_ids: string[];
112
+ };
113
+ } | {
114
+ scope: "sams";
115
+ action: "read";
116
+ } | {
117
+ scope: "gtfs_validations";
118
+ action: "create" | "read" | "request_approval";
119
+ resources: {
120
+ agency_ids: string[];
121
+ };
122
+ } | {
123
+ scope: "home";
124
+ action: "read_links" | "read_wiki";
125
+ } | {
126
+ scope: "organizations";
127
+ action: "create" | "update" | "delete" | "read";
128
+ } | {
129
+ scope: "performance";
130
+ action: "read";
131
+ } | {
132
+ scope: "plans";
133
+ action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
134
+ resources: {
135
+ agency_ids: string[];
136
+ };
137
+ } | {
138
+ scope: "roles";
139
+ action: "create" | "update" | "delete" | "read";
140
+ } | {
141
+ scope: "stops";
142
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
143
+ resources: {
144
+ municipality_ids: string[];
145
+ agency_ids: string[];
146
+ };
147
+ } | {
148
+ scope: "users";
149
+ action: "create" | "update" | "delete" | "read";
150
+ })[];
151
+ created_at: number & {
152
+ __brand: "UnixTimestamp";
153
+ };
154
+ created_by?: string | undefined;
155
+ updated_at: number & {
156
+ __brand: "UnixTimestamp";
157
+ };
158
+ updated_by?: string | undefined;
159
+ name: string;
160
+ _id: string;
161
+ }[]>;
162
+ /**
163
+ * Finds a single document matching the filter criteria.
164
+ * @param filter Filter criteria to match the document.
165
+ * @returns A promise that resolves to the matching document or null if not found.
166
+ */
167
+ findOne(filter: Filter<Role>): Promise<{
168
+ permissions: ({
169
+ scope: "agencies";
170
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
171
+ } | {
172
+ scope: "alerts_scheduled";
173
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
174
+ } | {
175
+ scope: "alerts_realtime";
176
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
177
+ resources: {
178
+ agency_ids: string[];
179
+ };
180
+ } | {
181
+ scope: "rides";
182
+ action: "acceptance_change_status" | "acceptance_justify" | "acceptance_lock" | "acceptance_read" | "analsys_lock" | "analysis_lock" | "analysis_read" | "analysis_reprocess" | "analysis_update" | "audit_lock" | "audit_read" | "audit_update";
183
+ resources: {
184
+ agency_ids: string[];
185
+ };
186
+ } | {
187
+ scope: "sams";
188
+ action: "read";
189
+ } | {
190
+ scope: "gtfs_validations";
191
+ action: "create" | "read" | "request_approval";
192
+ resources: {
193
+ agency_ids: string[];
194
+ };
195
+ } | {
196
+ scope: "home";
197
+ action: "read_links" | "read_wiki";
198
+ } | {
199
+ scope: "organizations";
200
+ action: "create" | "update" | "delete" | "read";
201
+ } | {
202
+ scope: "performance";
203
+ action: "read";
204
+ } | {
205
+ scope: "plans";
206
+ action: "create" | "update" | "delete" | "read" | "toggle_lock" | "read_controller" | "read_pcgi_legacy" | "update_controller" | "update_feed_info_dates" | "update_gtfs_plan" | "update_pcgi_legacy";
207
+ resources: {
208
+ agency_ids: string[];
209
+ };
210
+ } | {
211
+ scope: "roles";
212
+ action: "create" | "update" | "delete" | "read";
213
+ } | {
214
+ scope: "stops";
215
+ action: "create" | "update" | "delete" | "read" | "toggle_lock";
216
+ resources: {
217
+ municipality_ids: string[];
218
+ agency_ids: string[];
219
+ };
220
+ } | {
221
+ scope: "users";
222
+ action: "create" | "update" | "delete" | "read";
223
+ })[];
224
+ created_at: number & {
225
+ __brand: "UnixTimestamp";
226
+ };
227
+ created_by?: string | undefined;
228
+ updated_at: number & {
229
+ __brand: "UnixTimestamp";
230
+ };
231
+ updated_by?: string | undefined;
232
+ name: string;
233
+ _id: string;
234
+ }>;
235
+ protected getCollectionIndexes(): IndexDescription[];
236
+ protected getCollectionName(): string;
237
+ protected getEnvName(): string;
238
+ }
239
+ export declare const roles: RolesClass;
240
+ export {};
@@ -0,0 +1,69 @@
1
+ /* * */
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
+ import { PermissionCatalog, 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 user document by its ID.
23
+ * @param id The ID of the user document to find
24
+ * @param includePasswordHash Whether to include the password hash in the result
25
+ * @returns A promise that resolves to the matching user document or null if not found
26
+ */
27
+ async findById(id, options) {
28
+ const foundRole = await this.mongoCollection.findOne({ _id: id }, options);
29
+ if (!foundRole)
30
+ return null;
31
+ return { ...foundRole, permissions: PermissionCatalog.sanitize(foundRole.permissions) };
32
+ }
33
+ /**
34
+ * Finds multiple documents matching the filter criteria
35
+ * with optional pagination and sorting.
36
+ * @param filter (Optional) filter criteria to match documents.
37
+ * @param perPage (Optional) number of documents per page for pagination.
38
+ * @param page (Optional) page number for pagination.
39
+ * @param sort (Optional) sort specification.
40
+ * @returns A promise that resolves to an array of matching documents.
41
+ */
42
+ async findMany(filter, options) {
43
+ const foundRoles = await this.mongoCollection.find(filter ?? {}, options).toArray();
44
+ return foundRoles.map(item => ({ ...item, permissions: PermissionCatalog.sanitize(item.permissions) }));
45
+ }
46
+ /**
47
+ * Finds a single document matching the filter criteria.
48
+ * @param filter Filter criteria to match the document.
49
+ * @returns A promise that resolves to the matching document or null if not found.
50
+ */
51
+ async findOne(filter) {
52
+ const foundRole = await this.mongoCollection.findOne(filter);
53
+ if (!foundRole)
54
+ return null;
55
+ return { ...foundRole, permissions: PermissionCatalog.sanitize(foundRole.permissions) };
56
+ }
57
+ getCollectionIndexes() {
58
+ return [
59
+ { background: true, key: { name: 1 }, unique: true },
60
+ ];
61
+ }
62
+ getCollectionName() {
63
+ return 'roles';
64
+ }
65
+ getEnvName() {
66
+ return 'DATABASE_URI';
67
+ }
68
+ }
69
+ export const roles = AsyncSingletonProxy(RolesClass);
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { CreateSessionDto, Session, UpdateSessionDto } 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 { SessionSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */