@tmlmobilidade/interfaces 20251222.1537.24 → 20251222.1647.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.
@@ -247,6 +247,18 @@ export class MongoCollectionClass {
247
247
  throw new Error('No schema defined for insert operation. This is either an internal interface error or you should pass unsafe=true to the insert operation.');
248
248
  // Validate the document against the create schema
249
249
  parsedDocument = this.createSchema.parse(parsedDocument);
250
+ // Add the missing default fields, if present in the original document.
251
+ // The schema might have omitted these fields, so we need to add them back.
252
+ if (doc._id)
253
+ parsedDocument._id = doc._id;
254
+ if (doc.created_at)
255
+ parsedDocument.created_at = doc.created_at;
256
+ if (doc.created_by)
257
+ parsedDocument.created_by = doc.created_by;
258
+ if (doc.updated_at)
259
+ parsedDocument.updated_at = doc.updated_at;
260
+ if (doc.updated_by)
261
+ parsedDocument.updated_by = doc.updated_by;
250
262
  }
251
263
  catch (error) {
252
264
  throw new HttpException(HttpStatus.BAD_REQUEST, error.message, { cause: error });
@@ -1,5 +1,5 @@
1
1
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { CreateFileDto, File, UpdateFileDto } from '@tmlmobilidade/types';
2
+ import { type CreateFileDto, type File, type UpdateFileDto } from '@tmlmobilidade/types';
3
3
  import { DeleteOptions, DeleteResult, IndexDescription, InsertOneOptions, WithId } from 'mongodb';
4
4
  import { Readable } from 'node:stream';
5
5
  import { z } from 'zod';
@@ -4,12 +4,12 @@ import { StorageFactory } from '../../providers/index.js';
4
4
  import { HttpException, HttpStatus } from '@tmlmobilidade/consts';
5
5
  import { Files } from '@tmlmobilidade/files';
6
6
  import { generateRandomString } from '@tmlmobilidade/strings';
7
- import { CreateFileSchema, FileSchema, UpdateFileSchema } from '@tmlmobilidade/types';
7
+ import { CreateFileSchema, UpdateFileSchema } from '@tmlmobilidade/types';
8
8
  import { AsyncSingletonProxy, convertObject } from '@tmlmobilidade/utils';
9
9
  /* * */
10
10
  class FilesClass extends MongoCollectionClass {
11
11
  static _instance;
12
- createSchema = FileSchema;
12
+ createSchema = CreateFileSchema;
13
13
  updateSchema = UpdateFileSchema;
14
14
  bucketName;
15
15
  storageService;
@@ -1,6 +1,6 @@
1
1
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { CreateGtfsValidationDto, GtfsValidation, UpdateGtfsValidationDto } from '@tmlmobilidade/types';
3
- import { IndexDescription } from 'mongodb';
2
+ import { type CreateGtfsValidationDto, type GtfsValidation, type UpdateGtfsValidationDto } from '@tmlmobilidade/types';
3
+ import { type IndexDescription } from 'mongodb';
4
4
  import { z } from 'zod';
5
5
  declare class GtfValidationsClass extends MongoCollectionClass<GtfsValidation, CreateGtfsValidationDto, UpdateGtfsValidationDto> {
6
6
  private static _instance;
@@ -10,11 +10,10 @@ declare class GtfValidationsClass extends MongoCollectionClass<GtfsValidation, C
10
10
  static getInstance(): Promise<GtfValidationsClass>;
11
11
  /**
12
12
  * Finds Validation documents by agency ID.
13
- *
14
- * @param id - The agency ID to search for
13
+ * @param agencyId The agency ID to search for.
15
14
  * @returns A promise that resolves to an array of matching documents
16
15
  */
17
- findByAgencyId(id: string): Promise<import("mongodb").WithId<{
16
+ findByAgencyId(agencyId: string): Promise<import("mongodb").WithId<{
18
17
  _id: string;
19
18
  created_at: number & {
20
19
  __brand: "UnixTimestamp";
@@ -1,11 +1,11 @@
1
1
  /* * */
2
2
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
- import { GtfsValidationSchema, UpdateGtfsValidationSchema } from '@tmlmobilidade/types';
3
+ import { CreateGtfsValidationSchema, UpdateGtfsValidationSchema } from '@tmlmobilidade/types';
4
4
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
5
5
  /* * */
6
6
  class GtfValidationsClass extends MongoCollectionClass {
7
7
  static _instance;
8
- createSchema = GtfsValidationSchema;
8
+ createSchema = CreateGtfsValidationSchema;
9
9
  updateSchema = UpdateGtfsValidationSchema;
10
10
  constructor() {
11
11
  super();
@@ -20,12 +20,11 @@ class GtfValidationsClass extends MongoCollectionClass {
20
20
  }
21
21
  /**
22
22
  * Finds Validation documents by agency ID.
23
- *
24
- * @param id - The agency ID to search for
23
+ * @param agencyId The agency ID to search for.
25
24
  * @returns A promise that resolves to an array of matching documents
26
25
  */
27
- async findByAgencyId(id) {
28
- return this.mongoCollection.find({ agency_id: id }).toArray();
26
+ async findByAgencyId(agencyId) {
27
+ return this.mongoCollection.find({ agency_id: agencyId }).toArray();
29
28
  }
30
29
  getCollectionIndexes() {
31
30
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20251222.1537.24",
3
+ "version": "20251222.1647.5",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"