@tmlmobilidade/interfaces 20251222.1552.52 → 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,
|
|
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 =
|
|
12
|
+
createSchema = CreateFileSchema;
|
|
13
13
|
updateSchema = UpdateFileSchema;
|
|
14
14
|
bucketName;
|
|
15
15
|
storageService;
|