@tmlmobilidade/interfaces 20251211.1246.9 → 20251218.110.37

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.
@@ -1,7 +1,7 @@
1
- import { AggregationPipeline } from './aggregation-pipeline.js';
1
+ import { type AggregationPipeline } from './aggregation-pipeline.js';
2
2
  import { MongoConnector } from '@tmlmobilidade/mongo';
3
3
  import { type UnixTimestamp } from '@tmlmobilidade/types';
4
- import { AggregateOptions, AggregationCursor, Collection, DeleteOptions, DeleteResult, Document, Filter, FindOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, MongoClientOptions, UpdateOptions, UpdateResult, WithId } from 'mongodb';
4
+ import { type AggregateOptions, type AggregationCursor, type Collection, type DeleteOptions, type DeleteResult, type Document, type Filter, type FindOptions, type IndexDescription, type InsertManyResult, type InsertOneOptions, type InsertOneResult, type MongoClientOptions, type UpdateOptions, type UpdateResult, type WithId } from 'mongodb';
5
5
  import { z } from 'zod';
6
6
  export declare abstract class MongoCollectionClass<T extends Document, TCreate, TUpdate> {
7
7
  protected createSchema: null | z.ZodSchema;
@@ -10,9 +10,9 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
10
10
  protected updateSchema: null | z.ZodSchema;
11
11
  /**
12
12
  * Aggregates documents in the collection.
13
- * @param pipeline - The aggregation pipeline to execute
14
- * @param options - The options for the aggregation operation
15
- * @returns A promise that resolves to an array of aggregated documents
13
+ * @param pipeline The aggregation pipeline to execute.
14
+ * @param options The options for the aggregation operation.
15
+ * @returns A promise that resolves to an array of aggregated documents.
16
16
  */
17
17
  aggregate(pipeline: AggregationPipeline<T>, options?: AggregateOptions & {
18
18
  returnResult?: true;
@@ -27,22 +27,24 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
27
27
  all(): Promise<WithId<T>[]>;
28
28
  /**
29
29
  * Establishes a connection to the Mongo database and initializes the collection.
30
- * @param options Optional Mongo client connection options
31
- * @throws {Error} If connection fails
30
+ * @param options Optional Mongo client connection options.
31
+ * @throws Error if the environment variable for the database URI is missing or if the connection fails.
32
32
  */
33
33
  connect(options?: MongoClientOptions): Promise<void>;
34
34
  /**
35
35
  * Counts documents matching the filter criteria.
36
- * @param filter - The filter criteria to match documents
37
- * @returns A promise that resolves to the count of matching documents
36
+ * @param filter The filter criteria to match documents.
37
+ * @returns A promise that resolves to the count of matching documents.
38
38
  */
39
39
  count(filter?: Filter<T>): Promise<number>;
40
40
  /**
41
41
  * Deletes a single document by its ID.
42
- * @param id - The ID of the document to delete
43
- * @returns A promise that resolves to the result of the delete operation
42
+ * @param id The ID of the document to delete.
43
+ * @returns A promise that resolves to the result of the delete operation.
44
44
  */
45
- deleteById(id: string, options?: DeleteOptions): Promise<DeleteResult>;
45
+ deleteById(id: T['_id'], options?: DeleteOptions & {
46
+ forceIfLocked?: boolean;
47
+ }): Promise<DeleteResult>;
46
48
  /**
47
49
  * Deletes multiple documents matching the filter criteria.
48
50
  * @param filter - The filter criteria to match documents to delete
@@ -54,7 +56,9 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
54
56
  * @param filter - The filter criteria to match the document to delete
55
57
  * @returns A promise that resolves to the result of the delete operation
56
58
  */
57
- deleteOne(filter: Filter<T>, options?: DeleteOptions): Promise<DeleteResult>;
59
+ deleteOne(filter: Filter<T>, options?: DeleteOptions & {
60
+ forceIfLocked?: boolean;
61
+ }): Promise<DeleteResult>;
58
62
  /**
59
63
  * Disconnects from the MongoDB database.
60
64
  */
@@ -74,29 +78,29 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
74
78
  exists<K extends keyof T>(key: K, value: T[K]): Promise<boolean>;
75
79
  /**
76
80
  * Checks if a document with the given ID exists in the collection.
77
- * @param _id The ID of the document to check for existence.
81
+ * @param id The ID of the document to check for existence.
78
82
  * @returns A promise that resolves to true if the document exists, false otherwise.
79
83
  */
80
- existsById(_id: T['_id']): Promise<boolean>;
84
+ existsById(id: T['_id']): Promise<boolean>;
81
85
  /**
82
86
  * Finds a document by its ID.
83
- * @param _id The ID of the document to find.
87
+ * @param id The ID of the document to find.
84
88
  * @param options Optional find options.
85
- * @returns A promise that resolves to the matching document or null if not found
89
+ * @returns A promise that resolves to the matching document or null if not found.
86
90
  */
87
- findById(_id: T['_id'], options?: FindOptions): Promise<null | WithId<T>>;
91
+ findById(id: T['_id'], options?: FindOptions): Promise<null | WithId<T>>;
88
92
  /**
89
93
  * Finds multiple documents matching the filter criteria with optional pagination and sorting.
90
- * @param filter - (Optional) filter criteria to match documents
91
- * @param options - (Optional) find options
92
- * @returns A promise that resolves to an array of matching documents
94
+ * @param filter (Optional) filter criteria to match documents.
95
+ * @param options (Optional) find options.
96
+ * @returns A promise that resolves to an array of matching documents.
93
97
  */
94
98
  findMany(filter?: Filter<T>, options?: FindOptions): Promise<WithId<T>[]>;
95
99
  /**
96
100
  * Finds a single document matching the filter criteria.
97
- * @param filter - The filter criteria to match the document
98
- * @param options - (Optional) find options
99
- * @returns A promise that resolves to the matching document or null if not found
101
+ * @param filter The filter criteria to match the document.
102
+ * @param options (Optional) find options.
103
+ * @returns A promise that resolves to the matching document or null if not found.
100
104
  */
101
105
  findOne(filter: Filter<T>, options?: FindOptions): Promise<null | WithId<T>>;
102
106
  /**
@@ -143,14 +147,34 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
143
147
  };
144
148
  unsafe?: boolean;
145
149
  }): Promise<TReturnDocument extends true ? WithId<T> : InsertOneResult<T>>;
150
+ /**
151
+ * Checks if a document with the given ID is locked or not.
152
+ * @param id The ID of the document to check.
153
+ * @returns A promise that resolves to the result of the check operation.
154
+ */
155
+ isLocked(filter: Filter<T>): Promise<boolean>;
156
+ /**
157
+ * Checks if a document with the given ID is locked or not.
158
+ * @param id The ID of the document to check.
159
+ * @returns A promise that resolves to the result of the check operation.
160
+ */
161
+ isLockedById(id: T['_id']): Promise<boolean>;
162
+ /**
163
+ * Toogle the lock status of a document by its ID.
164
+ * @param id The ID of the document to toggle lock status.
165
+ * @param forceValue Optional boolean to explicitly set the lock status.
166
+ * @returns A promise that resolves to the result of the update operation.
167
+ */
168
+ toggleLockById(id: T['_id'], forceValue?: boolean): Promise<void>;
146
169
  /**
147
170
  * Updates a document by its ID.
148
- * @param _id The ID of the document to update.
171
+ * @param id The ID of the document to update.
149
172
  * @param updateFields The fields to update in the document.
150
173
  * @param options Optional options for the update operation.
151
174
  * @returns A promise that resolves to the result of the update operation.
152
175
  */
153
- updateById<TReturnDocument extends boolean = true>(_id: T['_id'], updateFields: TUpdate, options?: UpdateOptions & {
176
+ updateById<TReturnDocument extends boolean = true>(id: T['_id'], updateFields: TUpdate, options?: UpdateOptions & {
177
+ forceIfLocked?: boolean;
154
178
  returnResult?: TReturnDocument;
155
179
  }): Promise<TReturnDocument extends true ? WithId<T> : UpdateResult<T>>;
156
180
  /**
@@ -168,12 +192,13 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
168
192
  }): Promise<TReturnDocument extends true ? WithId<T>[] : UpdateResult<T>>;
169
193
  /**
170
194
  * Updates a single document matching the filter criteria.
171
- * @param filter - The filter criteria to match the document to update
172
- * @param updateFields - The fields to update in the document
173
- * @param options - The options for the update operation
174
- * @returns A promise that resolves to the result of the update operation
195
+ * @param filter The filter criteria to match the document to update.
196
+ * @param updateFields The fields to update in the document.
197
+ * @param options The options for the update operation.
198
+ * @returns A promise that resolves to the result of the update operation.
175
199
  */
176
200
  updateOne<TReturnDocument extends boolean = true>(filter: Filter<T>, updateFields: TUpdate, options?: UpdateOptions & {
201
+ forceIfLocked?: boolean;
177
202
  returnResult?: TReturnDocument;
178
203
  }): Promise<TReturnDocument extends true ? WithId<T> : UpdateResult<T>>;
179
204
  protected abstract getCollectionIndexes(): IndexDescription[];
@@ -5,16 +5,19 @@ import { MongoConnector } from '@tmlmobilidade/mongo';
5
5
  import { generateRandomString } from '@tmlmobilidade/strings';
6
6
  /* * */
7
7
  export class MongoCollectionClass {
8
+ //
8
9
  createSchema = null;
9
10
  mongoCollection;
10
11
  mongoConnector;
11
12
  updateSchema = null;
12
13
  async aggregate(pipeline, options) {
13
- const aggregation = this.mongoCollection.aggregate(pipeline, options);
14
- if (options?.returnResult === false) {
15
- return aggregation;
16
- }
17
- return aggregation.toArray();
14
+ // Perform the aggregation pipeline
15
+ const aggregationResult = this.mongoCollection.aggregate(pipeline, options);
16
+ // If returnResult is false, return the cursor directly
17
+ if (options?.returnResult === false)
18
+ return aggregationResult;
19
+ // Otherwise, return the aggregated documents as an array
20
+ return aggregationResult.toArray();
18
21
  }
19
22
  /**
20
23
  * Gets all documents in the collection.
@@ -25,15 +28,15 @@ export class MongoCollectionClass {
25
28
  }
26
29
  /**
27
30
  * Establishes a connection to the Mongo database and initializes the collection.
28
- * @param options Optional Mongo client connection options
29
- * @throws {Error} If connection fails
31
+ * @param options Optional Mongo client connection options.
32
+ * @throws Error if the environment variable for the database URI is missing or if the connection fails.
30
33
  */
31
34
  async connect(options) {
32
- //
35
+ // Extract the database URI from environment variables
33
36
  const dbUri = process.env[this.getEnvName()];
34
- if (!dbUri) {
37
+ if (!dbUri)
35
38
  throw new Error(`Missing ${this.getEnvName()} environment variable`);
36
- }
39
+ // Attempt to connect to the database
37
40
  try {
38
41
  // Connect to the MongoDB database
39
42
  this.mongoConnector = new MongoConnector(dbUri, options);
@@ -52,22 +55,31 @@ export class MongoCollectionClass {
52
55
  }
53
56
  /**
54
57
  * Counts documents matching the filter criteria.
55
- * @param filter - The filter criteria to match documents
56
- * @returns A promise that resolves to the count of matching documents
58
+ * @param filter The filter criteria to match documents.
59
+ * @returns A promise that resolves to the count of matching documents.
57
60
  */
58
61
  async count(filter) {
59
62
  return await this.mongoCollection.countDocuments(filter);
60
63
  }
61
64
  /**
62
65
  * Deletes a single document by its ID.
63
- * @param id - The ID of the document to delete
64
- * @returns A promise that resolves to the result of the delete operation
66
+ * @param id The ID of the document to delete.
67
+ * @returns A promise that resolves to the result of the delete operation.
65
68
  */
66
69
  async deleteById(id, options) {
70
+ // If forceIfLocked is not set then check if the document is locked.
71
+ // If it is locked, then throw an error to prevent the operation.
72
+ if (!options?.forceIfLocked) {
73
+ const isLocked = await this.isLockedById(id);
74
+ if (isLocked)
75
+ throw new HttpException(HttpStatus.FORBIDDEN, 'Document is locked and cannot be deleted');
76
+ }
77
+ // Perform the delete operation
67
78
  const result = await this.deleteOne({ _id: { $eq: id } }, options);
68
- if (!result.acknowledged) {
79
+ // Check if the delete operation was acknowledged
80
+ if (!result.acknowledged)
69
81
  throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Failed to delete documents', result);
70
- }
82
+ // Return the result of the delete operation
71
83
  return result;
72
84
  }
73
85
  /**
@@ -77,9 +89,8 @@ export class MongoCollectionClass {
77
89
  */
78
90
  async deleteMany(filter) {
79
91
  const result = await this.mongoCollection.deleteMany(filter);
80
- if (!result.acknowledged) {
92
+ if (!result.acknowledged)
81
93
  throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Failed to delete documents', result);
82
- }
83
94
  return result;
84
95
  }
85
96
  /**
@@ -88,10 +99,17 @@ export class MongoCollectionClass {
88
99
  * @returns A promise that resolves to the result of the delete operation
89
100
  */
90
101
  async deleteOne(filter, options) {
102
+ // If forceIfLocked is not set then check if the document is locked.
103
+ // If it is locked, then throw an error to prevent the operation.
104
+ if (!options?.forceIfLocked) {
105
+ const isLocked = await this.isLocked(filter);
106
+ if (isLocked)
107
+ throw new HttpException(HttpStatus.FORBIDDEN, 'Document is locked and cannot be deleted');
108
+ }
109
+ // Perform the delete operation
91
110
  const result = await this.mongoCollection.deleteOne(filter, options);
92
- if (!result.acknowledged) {
111
+ if (!result.acknowledged)
93
112
  throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR, 'Failed to delete document', result);
94
- }
95
113
  return result;
96
114
  }
97
115
  /**
@@ -121,37 +139,36 @@ export class MongoCollectionClass {
121
139
  }
122
140
  /**
123
141
  * Checks if a document with the given ID exists in the collection.
124
- * @param _id The ID of the document to check for existence.
142
+ * @param id The ID of the document to check for existence.
125
143
  * @returns A promise that resolves to true if the document exists, false otherwise.
126
144
  */
127
- async existsById(_id) {
128
- const doc = await this.mongoCollection.findOne({ _id: _id }, { projection: { _id: 1 } });
129
- return doc !== null;
145
+ async existsById(id) {
146
+ const foundDoc = await this.mongoCollection.findOne({ _id: id }, { projection: { _id: 1 } });
147
+ return foundDoc !== null;
130
148
  }
131
149
  /**
132
150
  * Finds a document by its ID.
133
- * @param _id The ID of the document to find.
151
+ * @param id The ID of the document to find.
134
152
  * @param options Optional find options.
135
- * @returns A promise that resolves to the matching document or null if not found
153
+ * @returns A promise that resolves to the matching document or null if not found.
136
154
  */
137
- async findById(_id, options) {
138
- const filter = { _id: { $eq: _id } };
139
- return this.mongoCollection.findOne(filter, options);
155
+ async findById(id, options) {
156
+ return this.mongoCollection.findOne({ _id: { $eq: id } }, options);
140
157
  }
141
158
  /**
142
159
  * Finds multiple documents matching the filter criteria with optional pagination and sorting.
143
- * @param filter - (Optional) filter criteria to match documents
144
- * @param options - (Optional) find options
145
- * @returns A promise that resolves to an array of matching documents
160
+ * @param filter (Optional) filter criteria to match documents.
161
+ * @param options (Optional) find options.
162
+ * @returns A promise that resolves to an array of matching documents.
146
163
  */
147
164
  async findMany(filter, options) {
148
165
  return await this.mongoCollection.find(filter ?? {}, options).toArray();
149
166
  }
150
167
  /**
151
168
  * Finds a single document matching the filter criteria.
152
- * @param filter - The filter criteria to match the document
153
- * @param options - (Optional) find options
154
- * @returns A promise that resolves to the matching document or null if not found
169
+ * @param filter The filter criteria to match the document.
170
+ * @param options (Optional) find options.
171
+ * @returns A promise that resolves to the matching document or null if not found.
155
172
  */
156
173
  async findOne(filter, options) {
157
174
  return await this.mongoCollection.findOne(filter, options);
@@ -256,16 +273,69 @@ export class MongoCollectionClass {
256
273
  }
257
274
  return inserted_doc;
258
275
  }
276
+ /**
277
+ * Checks if a document with the given ID is locked or not.
278
+ * @param id The ID of the document to check.
279
+ * @returns A promise that resolves to the result of the check operation.
280
+ */
281
+ async isLocked(filter) {
282
+ // Fetch the document by its ID from the database
283
+ const foundDoc = await this.findOne(filter);
284
+ // If the document has a is_locked field and it resolves to a truthy value,
285
+ // then the document is considered locked.
286
+ if (foundDoc?.is_locked)
287
+ return true;
288
+ // Otherwise, the document is not locked.
289
+ return false;
290
+ }
291
+ /**
292
+ * Checks if a document with the given ID is locked or not.
293
+ * @param id The ID of the document to check.
294
+ * @returns A promise that resolves to the result of the check operation.
295
+ */
296
+ async isLockedById(id) {
297
+ // Fetch the document by its ID from the database
298
+ const foundDoc = await this.findById(id);
299
+ // If the document has a is_locked field and it resolves to a truthy value,
300
+ // then the document is considered locked.
301
+ if (foundDoc?.is_locked)
302
+ return true;
303
+ // Otherwise, the document is not locked.
304
+ return false;
305
+ }
306
+ /**
307
+ * Toogle the lock status of a document by its ID.
308
+ * @param id The ID of the document to toggle lock status.
309
+ * @param forceValue Optional boolean to explicitly set the lock status.
310
+ * @returns A promise that resolves to the result of the update operation.
311
+ */
312
+ async toggleLockById(id, forceValue) {
313
+ // Get the current document from the database
314
+ const foundDoc = await this.findById(id);
315
+ if (!foundDoc)
316
+ throw new Error('Document not found');
317
+ // Determine the new lock status
318
+ const newLockStatus = forceValue !== undefined ? forceValue : !foundDoc.is_locked;
319
+ // Update the document with the new lock status
320
+ await this.mongoCollection.updateOne({ _id: { $eq: id } }, { $set: { is_locked: newLockStatus } });
321
+ }
259
322
  /**
260
323
  * Updates a document by its ID.
261
- * @param _id The ID of the document to update.
324
+ * @param id The ID of the document to update.
262
325
  * @param updateFields The fields to update in the document.
263
326
  * @param options Optional options for the update operation.
264
327
  * @returns A promise that resolves to the result of the update operation.
265
328
  */
266
- async updateById(_id, updateFields, options) {
267
- const filter = { _id: { $eq: _id } };
268
- return this.updateOne(filter, updateFields, options);
329
+ async updateById(id, updateFields, options) {
330
+ // If forceIfLocked is not set then check if the document is locked.
331
+ // If it is locked, then throw an error to prevent the operation.
332
+ if (!options?.forceIfLocked) {
333
+ const isLocked = await this.isLockedById(id);
334
+ if (isLocked)
335
+ throw new HttpException(HttpStatus.FORBIDDEN, 'Document is locked and cannot be updated');
336
+ }
337
+ // Perform the update operation
338
+ return this.updateOne({ _id: { $eq: id } }, updateFields, options);
269
339
  }
270
340
  /**
271
341
  * Updates multiple documents matching the filter criteria.
@@ -302,12 +372,20 @@ export class MongoCollectionClass {
302
372
  }
303
373
  /**
304
374
  * Updates a single document matching the filter criteria.
305
- * @param filter - The filter criteria to match the document to update
306
- * @param updateFields - The fields to update in the document
307
- * @param options - The options for the update operation
308
- * @returns A promise that resolves to the result of the update operation
375
+ * @param filter The filter criteria to match the document to update.
376
+ * @param updateFields The fields to update in the document.
377
+ * @param options The options for the update operation.
378
+ * @returns A promise that resolves to the result of the update operation.
309
379
  */
310
380
  async updateOne(filter, updateFields, options) {
381
+ // If forceIfLocked is not set then check if the document is locked.
382
+ // If it is locked, then throw an error to prevent the operation.
383
+ if (!options?.forceIfLocked) {
384
+ const isLocked = await this.isLocked(filter);
385
+ if (isLocked)
386
+ throw new HttpException(HttpStatus.FORBIDDEN, 'Document is locked and cannot be updated');
387
+ }
388
+ // Perform the update operation
311
389
  let parsedUpdateFields = updateFields;
312
390
  if (this.updateSchema) {
313
391
  try {
@@ -13,6 +13,7 @@ declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto
13
13
  created_at: number & {
14
14
  __brand: "UnixTimestamp";
15
15
  };
16
+ is_locked: boolean;
16
17
  updated_at: number & {
17
18
  __brand: "UnixTimestamp";
18
19
  };
@@ -24,9 +25,7 @@ declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto
24
25
  vkm_per_month: number[];
25
26
  };
26
27
  name: string;
27
- operation_start_date: string & {
28
- __brand: "OperationalDate";
29
- };
28
+ operation_start_date: import("@tmlmobilidade/types").OperationalDate | null;
30
29
  phone: string;
31
30
  public_email: string;
32
31
  short_name: string;
@@ -40,6 +39,7 @@ declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto
40
39
  created_at: number & {
41
40
  __brand: "UnixTimestamp";
42
41
  };
42
+ is_locked: boolean;
43
43
  updated_at: number & {
44
44
  __brand: "UnixTimestamp";
45
45
  };
@@ -51,9 +51,7 @@ declare class AgenciesClass extends MongoCollectionClass<Agency, CreateAgencyDto
51
51
  vkm_per_month: number[];
52
52
  };
53
53
  name: string;
54
- operation_start_date: string & {
55
- __brand: "OperationalDate";
56
- };
54
+ operation_start_date: import("@tmlmobilidade/types").OperationalDate | null;
57
55
  phone: string;
58
56
  public_email: string;
59
57
  short_name: string;
@@ -13,108 +13,102 @@ declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, Up
13
13
  created_at: number & {
14
14
  __brand: "UnixTimestamp";
15
15
  };
16
- created_by: string;
16
+ created_by: string | null;
17
+ is_locked: boolean;
17
18
  updated_at: number & {
18
19
  __brand: "UnixTimestamp";
19
20
  };
20
- type: "PLANNED" | "REALTIME";
21
+ type: "PLANNED" | "REALTIME" | null;
22
+ active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
21
23
  active_period_start_date: number & {
22
24
  __brand: "UnixTimestamp";
23
25
  };
24
26
  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";
27
+ coordinates: [number, number] | null;
25
28
  description: string;
26
29
  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;
30
+ external_id: string | null;
31
+ file_id: string | null;
32
+ info_url: string | null;
28
33
  municipality_ids: string[];
29
- publish_start_date: number & {
30
- __brand: "UnixTimestamp";
31
- };
34
+ publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
35
+ publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
32
36
  publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
33
- reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
37
+ reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP" | null;
34
38
  references: {
35
39
  child_ids: string[];
36
40
  parent_id: string;
37
41
  }[];
38
42
  title: string;
39
43
  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
44
  }>>;
47
45
  findByMunicipalityId(municipality_id: string): Promise<import("mongodb").WithId<{
48
46
  _id: string;
49
47
  created_at: number & {
50
48
  __brand: "UnixTimestamp";
51
49
  };
52
- created_by: string;
50
+ created_by: string | null;
51
+ is_locked: boolean;
53
52
  updated_at: number & {
54
53
  __brand: "UnixTimestamp";
55
54
  };
56
- type: "PLANNED" | "REALTIME";
55
+ type: "PLANNED" | "REALTIME" | null;
56
+ active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
57
57
  active_period_start_date: number & {
58
58
  __brand: "UnixTimestamp";
59
59
  };
60
60
  cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "ROAD_INCIDENT" | "SYSTEM_FAILURE" | "TRAFFIC_JAM" | "VEHICLE_ISSUE";
61
+ coordinates: [number, number] | null;
61
62
  description: string;
62
63
  effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
63
- modified_by: string;
64
+ external_id: string | null;
65
+ file_id: string | null;
66
+ info_url: string | null;
64
67
  municipality_ids: string[];
65
- publish_start_date: number & {
66
- __brand: "UnixTimestamp";
67
- };
68
+ publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
69
+ publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
68
70
  publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
69
- reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
71
+ reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP" | null;
70
72
  references: {
71
73
  child_ids: string[];
72
74
  parent_id: string;
73
75
  }[];
74
76
  title: string;
75
77
  updated_by?: string | undefined;
76
- active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
77
- coordinates?: [number, number] | null | undefined;
78
- external_id?: string | null | undefined;
79
- file_id?: string | null | undefined;
80
- info_url?: string | undefined;
81
- publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
82
78
  }>[]>;
83
79
  findByTitle(title: string): Promise<import("mongodb").WithId<{
84
80
  _id: string;
85
81
  created_at: number & {
86
82
  __brand: "UnixTimestamp";
87
83
  };
88
- created_by: string;
84
+ created_by: string | null;
85
+ is_locked: boolean;
89
86
  updated_at: number & {
90
87
  __brand: "UnixTimestamp";
91
88
  };
92
- type: "PLANNED" | "REALTIME";
89
+ type: "PLANNED" | "REALTIME" | null;
90
+ active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
93
91
  active_period_start_date: number & {
94
92
  __brand: "UnixTimestamp";
95
93
  };
96
94
  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";
95
+ coordinates: [number, number] | null;
97
96
  description: string;
98
97
  effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT";
99
- modified_by: string;
98
+ external_id: string | null;
99
+ file_id: string | null;
100
+ info_url: string | null;
100
101
  municipality_ids: string[];
101
- publish_start_date: number & {
102
- __brand: "UnixTimestamp";
103
- };
102
+ publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
103
+ publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
104
104
  publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT";
105
- reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP";
105
+ reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP" | null;
106
106
  references: {
107
107
  child_ids: string[];
108
108
  parent_id: string;
109
109
  }[];
110
110
  title: string;
111
111
  updated_by?: string | undefined;
112
- active_period_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
113
- coordinates?: [number, number] | null | undefined;
114
- external_id?: string | null | undefined;
115
- file_id?: string | null | undefined;
116
- info_url?: string | undefined;
117
- publish_end_date?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
118
112
  }>>;
119
113
  protected getCollectionIndexes(): IndexDescription[];
120
114
  protected getCollectionName(): string;