@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
@@ -0,0 +1,17 @@
1
+ import { type Collection } from 'mongodb';
2
+ declare class PCGIDBValidationsClass {
3
+ LocationEntity: Collection;
4
+ ValidationEntity: Collection;
5
+ /**
6
+ * Establishes a connection to the Mongo database and initializes the collection.
7
+ * @throws If connection fails.
8
+ */
9
+ connect(): Promise<void>;
10
+ /**
11
+ * Sets up an SSH Tunnel, if required, and returns the appropriate database URL.
12
+ * @throws If required environment variables are missing or if the tunnel setup fails.
13
+ */
14
+ getPcgidbValidationsConnectionString(): Promise<string>;
15
+ }
16
+ export declare const pcgidbValidations: PCGIDBValidationsClass;
17
+ export {};
@@ -0,0 +1,129 @@
1
+ /* * */
2
+ import { Logger } from '@tmlmobilidade/logger';
3
+ import { MongoConnector } from '@tmlmobilidade/mongo';
4
+ import { SshTunnelService } from '@tmlmobilidade/ssh';
5
+ /* * */
6
+ let GLOBAL_PCGIDB_TUNNEL_INSTANCE;
7
+ /* * */
8
+ class PCGIDBValidationsClass {
9
+ //
10
+ LocationEntity;
11
+ ValidationEntity;
12
+ /**
13
+ * Establishes a connection to the Mongo database and initializes the collection.
14
+ * @throws If connection fails.
15
+ */
16
+ async connect() {
17
+ //
18
+ //
19
+ // Setup SSH Tunnel, if required
20
+ const pcgidbValidationsConnectionString = await this.getPcgidbValidationsConnectionString();
21
+ //
22
+ // Get the database URI from environment variables
23
+ const mongoClientOptions = {
24
+ connectTimeoutMS: 10_000,
25
+ directConnection: true,
26
+ maxPoolSize: 20,
27
+ minPoolSize: 2,
28
+ readPreference: 'secondaryPreferred',
29
+ serverSelectionTimeoutMS: 10_000,
30
+ };
31
+ Logger.info('Connecting to PCGIDB Validations...');
32
+ try {
33
+ // Connect to the MongoDB database
34
+ const mongoConnector = new MongoConnector(pcgidbValidationsConnectionString, mongoClientOptions);
35
+ await mongoConnector.connect();
36
+ // Setup collections
37
+ this.LocationEntity = mongoConnector.client.db('LocationManagement').collection('locationEntity');
38
+ this.ValidationEntity = mongoConnector.client.db('ValidationsManagement').collection('validationEntity');
39
+ // Log success message
40
+ Logger.success('Connected to PCGIDB Validations successfully.');
41
+ }
42
+ catch (error) {
43
+ throw new Error('Error connecting to PCGIDB Validations:', { cause: error });
44
+ }
45
+ }
46
+ /**
47
+ * Sets up an SSH Tunnel, if required, and returns the appropriate database URL.
48
+ * @throws If required environment variables are missing or if the tunnel setup fails.
49
+ */
50
+ async getPcgidbValidationsConnectionString() {
51
+ //
52
+ //
53
+ // Check if the required PCGIDB environment variables are set.
54
+ if (!process.env.PCGIDB_VALIDATIONS_USER || !process.env.PCGIDB_VALIDATIONS_PASSWORD) {
55
+ throw new Error('Missing PCGIDB_VALIDATIONS_USER or PCGIDB_VALIDATIONS_PASSWORD environment variable.');
56
+ }
57
+ if (!process.env.PCGIDB_VALIDATIONS_ADDRESS || !process.env.PCGIDB_VALIDATIONS_PORT) {
58
+ throw new Error('Missing PCGIDB_VALIDATIONS_ADDRESS or PCGIDB_VALIDATIONS_PORT environment variable.');
59
+ }
60
+ //
61
+ // Check if the SSH Tunnel is required based on the environment.
62
+ // In 'production' and 'staging', we assume direct connection is used.
63
+ if (process.env.ENVIRONMENT === 'production' || process.env.ENVIRONMENT === 'staging') {
64
+ return `mongodb://${process.env.PCGIDB_VALIDATIONS_USER}:${process.env.PCGIDB_VALIDATIONS_PASSWORD}@${process.env.PCGIDB_VALIDATIONS_ADDRESS}:${process.env.PCGIDB_VALIDATIONS_PORT}/`;
65
+ }
66
+ //
67
+ // If we're here, then the SSH Tunnel is to be used.
68
+ // Check if the required SSH Tunnel environment variables are set.
69
+ if (!process.env.PCGIDB_VALIDATIONS_ADDRESS || !process.env.PCGIDB_VALIDATIONS_PORT) {
70
+ throw new Error('Missing PCGIDB_VALIDATIONS_ADDRESS or PCGIDB_VALIDATIONS_PORT environment variable.');
71
+ }
72
+ if (!process.env.PCGIDB_TUNNEL_LOCAL_PORT) {
73
+ throw new Error('Missing PCGIDB_TUNNEL_LOCAL_PORT environment variable.');
74
+ }
75
+ if (!process.env.PCGIDB_TUNNEL_SSH_HOST || !process.env.PCGIDB_TUNNEL_SSH_USERNAME) {
76
+ throw new Error('Missing PCGIDB_TUNNEL_SSH_HOST or PCGIDB_TUNNEL_SSH_USERNAME environment variable.');
77
+ }
78
+ //
79
+ // Setup the SSH Tunnel connection configuration
80
+ const sshConfig = {
81
+ forwardOptions: {
82
+ dstAddr: process.env.PCGIDB_VALIDATIONS_ADDRESS,
83
+ dstPort: Number(process.env.PCGIDB_VALIDATIONS_PORT),
84
+ srcAddr: 'localhost',
85
+ srcPort: Number(process.env.PCGIDB_TUNNEL_LOCAL_PORT),
86
+ },
87
+ serverOptions: {
88
+ port: Number(process.env.PCGIDB_TUNNEL_LOCAL_PORT),
89
+ },
90
+ sshOptions: {
91
+ /**
92
+ * Using SSH Agent for authentication.
93
+ * Ensure that your SSH key is added to the SSH agent beforehand.
94
+ * @see https://developer.1password.com/docs/ssh/agent/compatibility/#ssh-auth-sock
95
+ */
96
+ agent: process.env.SSH_AUTH_SOCK,
97
+ host: process.env.PCGIDB_TUNNEL_SSH_HOST,
98
+ keepaliveCountMax: 3, // Retry 3 times before closing the connection
99
+ keepaliveInterval: 10000, // Send keep-alive every 10 seconds
100
+ port: 22,
101
+ username: process.env.PCGIDB_TUNNEL_SSH_USERNAME,
102
+ },
103
+ tunnelOptions: {
104
+ autoClose: false,
105
+ reconnectOnError: true,
106
+ },
107
+ };
108
+ const sshOptions = {
109
+ maxRetries: 3,
110
+ };
111
+ //
112
+ // Actually create the SSH Tunnel connection
113
+ if (!GLOBAL_PCGIDB_TUNNEL_INSTANCE) {
114
+ GLOBAL_PCGIDB_TUNNEL_INSTANCE = new SshTunnelService(sshConfig, sshOptions);
115
+ }
116
+ Logger.info('Setting up SSH Tunnel for PCGIDB Validations...');
117
+ const sshTunnelConnection = await GLOBAL_PCGIDB_TUNNEL_INSTANCE.connect();
118
+ //
119
+ // Construct the PCGIDB connection string using the SSH Tunnel local address
120
+ const localAddress = sshTunnelConnection.address();
121
+ if (!localAddress || typeof localAddress !== 'object') {
122
+ throw new Error('Failed to retrieve the SSH tunnel address for PCGIDB Validations.');
123
+ }
124
+ return `mongodb://${process.env.PCGIDB_VALIDATIONS_USER}:${process.env.PCGIDB_VALIDATIONS_PASSWORD}@localhost:${localAddress.port}/`;
125
+ //
126
+ }
127
+ }
128
+ /* * */
129
+ export const pcgidbValidations = new PCGIDBValidationsClass();
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { type CreatePlanDto, type Plan, type UpdatePlanDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
@@ -44,17 +44,23 @@ declare class PlansClass extends MongoCollectionClass<Plan, CreatePlanDto, Updat
44
44
  feed_start_date?: import("@tmlmobilidade/types").OperationalDate | null | undefined;
45
45
  feed_version?: string | null | undefined;
46
46
  };
47
- controller: {
48
- status: "error" | "waiting" | "processing" | "complete";
49
- last_hash: string | null;
50
- timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
47
+ apps: {
48
+ controller: {
49
+ status: "waiting" | "processing" | "complete" | "error" | "skipped";
50
+ last_hash: string | null;
51
+ timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
52
+ };
53
+ merger: {
54
+ status: "waiting" | "processing" | "complete" | "error" | "skipped";
55
+ last_hash: string | null;
56
+ timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
57
+ };
51
58
  };
52
59
  hash: string;
53
60
  operation_file_id: string;
54
61
  pcgi_legacy: {
55
62
  operation_plan_id: string | null;
56
63
  };
57
- status_merger: "error" | "waiting" | "processing" | "complete";
58
64
  created_by?: string | undefined;
59
65
  updated_by?: string | undefined;
60
66
  }>[]>;
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
3
  import { PlanSchema, UpdatePlanSchema } 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 { CreateProposedChangeDto, ProposedChange, UpdateProposedChangeDto } 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 { ProposedChangeSchema, UpdateProposedChangeSchema } 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 { HashedShape } 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 { DocumentSchema } 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 { HashedTrip } 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 { DocumentSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
@@ -1,5 +1,5 @@
1
- import { AggregationPipeline } from '../../aggregation-pipeline.js';
2
- import { Ride, RideAcceptanceStatus, RideAnalysisGradeWithNone, RideDelayStatus, RideOperationalStatus, RideSeenStatus, UnixTimestamp } from '@tmlmobilidade/types';
1
+ import { AggregationPipeline } from '../../common/aggregation-pipeline.js';
2
+ import { DelayStatus, OperationalStatus, Ride, RideAcceptanceStatus, RideAnalysisGradeWithNone, SeenStatus, UnixTimestamp } from '@tmlmobilidade/types';
3
3
  /**
4
4
  * Creates MongoDB aggregation pipeline stages to calculate and categorize delay statuses.
5
5
  *
@@ -18,8 +18,8 @@ import { Ride, RideAcceptanceStatus, RideAnalysisGradeWithNone, RideDelayStatus,
18
18
  */
19
19
  export declare function ridesPipelineDelayStatus({ filter }?: {
20
20
  filter?: {
21
- end_delay_status?: RideDelayStatus[];
22
- start_delay_status?: RideDelayStatus[];
21
+ end_delay_status?: DelayStatus[];
22
+ start_delay_status?: DelayStatus[];
23
23
  };
24
24
  }): AggregationPipeline<Ride>;
25
25
  /**
@@ -45,7 +45,7 @@ export declare function ridesPipelineDelayStatus({ filter }?: {
45
45
  */
46
46
  export declare function ridesPipelineOperationalStatus({ filter }?: {
47
47
  filter?: {
48
- operational_status?: RideOperationalStatus[];
48
+ operational_status?: OperationalStatus[];
49
49
  };
50
50
  }): AggregationPipeline<Ride>;
51
51
  /**
@@ -70,7 +70,7 @@ export declare function ridesPipelineOperationalStatus({ filter }?: {
70
70
  */
71
71
  export declare function ridesPipelineSeenStatus({ filter }?: {
72
72
  filter?: {
73
- seen_status?: RideSeenStatus[];
73
+ seen_status?: SeenStatus[];
74
74
  };
75
75
  }): AggregationPipeline<Ride>;
76
76
  interface RidesPipelineFilter {
@@ -82,11 +82,11 @@ interface RidesPipelineFilter {
82
82
  analysis_transaction_sequentiality?: RideAnalysisGradeWithNone[];
83
83
  date_end: UnixTimestamp;
84
84
  date_start: UnixTimestamp;
85
- delay_statuses?: RideDelayStatus[];
85
+ delay_statuses?: DelayStatus[];
86
86
  line_ids?: string[];
87
- operational_statuses?: RideOperationalStatus[];
87
+ operational_statuses?: OperationalStatus[];
88
88
  search?: string;
89
- seen_statuses?: RideSeenStatus[];
89
+ seen_statuses?: SeenStatus[];
90
90
  stop_ids?: string[];
91
91
  }
92
92
  /**
@@ -1,4 +1,4 @@
1
- import { Dates } from '@tmlmobilidade/utils';
1
+ import { Dates } from '@tmlmobilidade/dates';
2
2
  /**
3
3
  * Creates MongoDB aggregation pipeline stages to calculate and categorize delay statuses.
4
4
  *
@@ -310,8 +310,26 @@ export function ridesBatchAggregationPipeline({ ...filter }) {
310
310
  { field: 'analysis_ended_at_last_stop_grade', path: 'analysis.ENDED_AT_LAST_STOP.grade' },
311
311
  { field: 'analysis_expected_apex_validation_interval', path: 'analysis.EXPECTED_APEX_VALIDATION_INTERVAL.grade' },
312
312
  { field: 'analysis_simple_three_vehicle_events_grade', path: 'analysis.SIMPLE_THREE_VEHICLE_EVENTS.grade' },
313
+ { field: 'analysis_transaction_sequentiality', path: 'analysis.TRANSACTION_SEQUENTIALITY.grade' },
313
314
  ];
314
- analysisFilters.forEach(({ field, path }) => filter[field] && pipeline.push({ $match: { [path]: { $in: filter[field] } } }));
315
+ analysisFilters.forEach(({ field, path }) => {
316
+ if (!filter[field])
317
+ return;
318
+ if (filter[field].includes('none')) {
319
+ // When 'none' is included, set the field to 'none' if it doesn't exist, then match on the filter array
320
+ pipeline.push({
321
+ $addFields: {
322
+ [path]: { $ifNull: [`$${path}`, 'none'] },
323
+ },
324
+ });
325
+ }
326
+ // Match documents where the field value is in the filter array
327
+ pipeline.push({
328
+ $match: {
329
+ [path]: { $in: filter[field] },
330
+ },
331
+ });
332
+ });
315
333
  // Stage 7: Filter by acceptance status
316
334
  // Only applies filter if acceptance_status is provided and doesn't include 'none'
317
335
  if (filter.acceptance_status && filter.acceptance_status.length > 0 && !filter.acceptance_status.includes('none')) {
@@ -1,4 +1,4 @@
1
- import { MongoCollectionClass } from '../../mongo-collection.js';
1
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
2
  import { CreateRideAcceptanceDto, RideAcceptance, UpdateRideAcceptanceDto } from '@tmlmobilidade/types';
3
3
  import { IndexDescription, InsertOneOptions, UpdateOptions } from 'mongodb';
4
4
  import { z } from 'zod';
@@ -1,8 +1,9 @@
1
1
  /* * */
2
- import { MongoCollectionClass } from '../../mongo-collection.js';
3
- import { HttpException, HttpStatus } from '@tmlmobilidade/lib';
2
+ import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
+ import { HttpException, HttpStatus } from '@tmlmobilidade/consts';
4
+ import { Dates } from '@tmlmobilidade/dates';
4
5
  import { RideAcceptanceSchema, UpdateRideAcceptanceSchema } from '@tmlmobilidade/types';
5
- import { AsyncSingletonProxy, compareObjects, Dates, flattenObject } from '@tmlmobilidade/utils';
6
+ import { AsyncSingletonProxy, compareObjects, flattenObject } from '@tmlmobilidade/utils';
6
7
  /* * */
7
8
  class RideAcceptanceClass extends MongoCollectionClass {
8
9
  static _instance;