@common-stack/store-mongo 8.0.2-alpha.0 → 8.1.1-alpha.13

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 (77) hide show
  1. package/LICENSE +34 -21
  2. package/lib/containers/container.d.ts +14 -0
  3. package/lib/containers/container.js +17 -0
  4. package/lib/containers/container.js.map +1 -0
  5. package/lib/containers/index.d.ts +1 -0
  6. package/lib/dataloaders/bulk-dataloader-v2.d.ts +40 -0
  7. package/lib/dataloaders/bulk-dataloader-v2.js +118 -0
  8. package/lib/dataloaders/bulk-dataloader-v2.js.map +1 -0
  9. package/lib/dataloaders/bulk-dataloader-v2.test.d.ts +1 -0
  10. package/lib/dataloaders/bulk-dataloader.d.ts +1 -1
  11. package/lib/dataloaders/bulk-dataloader.js.map +1 -1
  12. package/lib/dataloaders/bulk-dataloader.test.d.ts +1 -0
  13. package/lib/dataloaders/index.d.ts +1 -0
  14. package/lib/graphql/schema/base-services.graphql +238 -0
  15. package/lib/helpers/mongoose-connection.js.map +1 -1
  16. package/lib/index.d.ts +2 -1
  17. package/lib/index.js +1 -1
  18. package/lib/interfaces/base-repository.d.ts +1 -5
  19. package/lib/interfaces/base-service.d.ts +1 -1
  20. package/lib/interfaces/getAllArgs.d.ts +135 -0
  21. package/lib/interfaces/getAllArgs.js +39 -0
  22. package/lib/interfaces/getAllArgs.js.map +1 -0
  23. package/lib/interfaces/index.d.ts +1 -4
  24. package/lib/interfaces/index.old.d.ts +3 -0
  25. package/lib/mixins/BaseServiceMixin.d.ts +45 -0
  26. package/lib/mixins/BaseServiceMixin.js +212 -0
  27. package/lib/mixins/BaseServiceMixin.js.map +1 -0
  28. package/lib/mixins/__tests__/BaseServiceMixin.test.d.ts +1 -0
  29. package/lib/mixins/base-service-mixin.js.map +1 -1
  30. package/lib/mixins/index.d.ts +1 -0
  31. package/lib/module.d.ts +2 -0
  32. package/lib/module.js +4 -0
  33. package/lib/module.js.map +1 -0
  34. package/lib/services/BaseProxyService.d.ts +28 -0
  35. package/lib/services/BaseProxyService.js +52 -0
  36. package/lib/services/BaseProxyService.js.map +1 -0
  37. package/lib/services/BaseService.d.ts +23 -0
  38. package/lib/services/BaseService.js +65 -0
  39. package/lib/services/BaseService.js.map +1 -0
  40. package/lib/services/BaseService.test.d.ts +1 -0
  41. package/lib/services/ConnectionPoolManager.d.ts +54 -0
  42. package/lib/services/ConnectionPoolManager.js +163 -0
  43. package/lib/services/ConnectionPoolManager.js.map +1 -0
  44. package/lib/services/base-proxy-service.d.ts +2 -1
  45. package/lib/services/base-proxy-service.js.map +1 -1
  46. package/lib/services/base-service.d.ts +2 -1
  47. package/lib/services/base-service.js.map +1 -1
  48. package/lib/services/index.d.ts +3 -0
  49. package/lib/store/models/common-options-v2.d.ts +16 -0
  50. package/lib/store/models/common-options-v2.js +40 -0
  51. package/lib/store/models/common-options-v2.js.map +1 -0
  52. package/lib/store/models/common-options.js.map +1 -1
  53. package/lib/store/models/index.d.ts +1 -0
  54. package/lib/store/repositories/BaseMongoRepository.d.ts +72 -0
  55. package/lib/store/repositories/BaseMongoRepository.js +423 -0
  56. package/lib/store/repositories/BaseMongoRepository.js.map +1 -0
  57. package/lib/store/repositories/BaseMongoRepository.test.d.ts +1 -0
  58. package/lib/store/repositories/CustomIdRepository.test.d.ts +1 -0
  59. package/lib/store/repositories/base-repository.d.ts +2 -1
  60. package/lib/store/repositories/base-repository.js +1 -1
  61. package/lib/store/repositories/base-repository.js.map +1 -1
  62. package/lib/store/repositories/index.d.ts +1 -0
  63. package/lib/templates/constants/SERVER_TYPES.ts.template +7 -0
  64. package/lib/templates/repositories/DataLoader.ts.template +211 -0
  65. package/lib/templates/repositories/DatabaseMigration.ts.template +13 -0
  66. package/lib/templates/repositories/IBaseMongoRepository.ts.template +284 -0
  67. package/lib/templates/repositories/IBaseService.ts.template +231 -0
  68. package/lib/templates/repositories/IBaseServiceMixin.ts.template +477 -0
  69. package/lib/templates/repositories/dbCommonTypes.ts.template +140 -0
  70. package/lib/templates/repositories/moleculerEventHandler.ts.template.toberemoved +118 -0
  71. package/lib/templates/repositories/mongoCommonTypes.ts.template +21 -0
  72. package/lib/templates/repositories/typedMoleculerService.ts.template.toberemoved +1188 -0
  73. package/lib/templates/repositories/zodToMoleculer.ts.template.toberemoved +133 -0
  74. package/package.json +22 -5
  75. package/lib/interfaces/base-repository.js +0 -5
  76. package/lib/interfaces/base-repository.js.map +0 -1
  77. package/lib/interfaces/get-all-args.d.ts +0 -9
@@ -0,0 +1,423 @@
1
+ import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {IMongoOptions,PAGINATION_OPTIONS}from'common/server';var BaseMongoRepository_1;
2
+ var _a;
3
+ let BaseMongoRepository = BaseMongoRepository_1 = class BaseMongoRepository {
4
+ modelFunc;
5
+ options;
6
+ logger;
7
+ model;
8
+ constructor(modelFunc, db, logger, options) {
9
+ this.modelFunc = modelFunc;
10
+ // Safe model registration to prevent "Cannot overwrite model once compiled" errors
11
+ this.model = this.safeModelRegistration(db);
12
+ this.options = options;
13
+ this.logger = logger.child({ className: BaseMongoRepository_1.name });
14
+ }
15
+ /**
16
+ * Safely registers or retrieves a Mongoose model to prevent overwrite errors
17
+ * This is crucial for development environments where multiple containers might try to register the same model
18
+ */
19
+ safeModelRegistration(db) {
20
+ try {
21
+ return this.modelFunc(db);
22
+ }
23
+ catch (error) {
24
+ // If the error is about overwriting a model, try to get the existing model
25
+ if (error instanceof Error && error.message.includes('Cannot overwrite')) {
26
+ // Extract model name from the error message or try to infer it
27
+ const modelNameMatch = error.message.match(/Cannot overwrite `(\w+)` model/);
28
+ if (modelNameMatch) {
29
+ const modelName = modelNameMatch[1];
30
+ try {
31
+ return db.model(modelName);
32
+ }
33
+ catch (getError) {
34
+ // If we can't get the existing model, re-throw the original error
35
+ throw error;
36
+ }
37
+ }
38
+ }
39
+ // For any other error, re-throw it
40
+ throw error;
41
+ }
42
+ }
43
+ /**
44
+ * Transforms a document to the domain model format
45
+ */
46
+ transformDocument(doc) {
47
+ if (!doc)
48
+ return null;
49
+ // If it's already a plain object (not a Mongoose document)
50
+ if (!doc.toObject) {
51
+ // Ensure id exists if _id is present
52
+ if (doc._id && !doc.id) {
53
+ doc.id = typeof doc._id === 'object' && doc._id.toString ? doc._id.toString() : doc._id;
54
+ }
55
+ return doc;
56
+ }
57
+ // For Mongoose documents, use the built-in toObject transformation
58
+ return doc.toObject();
59
+ }
60
+ /**
61
+ * Transforms an array of documents
62
+ */
63
+ transformDocuments(docs) {
64
+ if (!docs || !Array.isArray(docs))
65
+ return [];
66
+ return docs.map((doc) => this.transformDocument(doc)).filter(Boolean);
67
+ }
68
+ /**
69
+ * Maps API criteria with 'id' to MongoDB criteria with '_id'
70
+ */
71
+ mapConditions(conditions) {
72
+ if (!conditions)
73
+ return {};
74
+ const { id, ...remaining } = conditions;
75
+ if (!id)
76
+ return remaining;
77
+ // Handle custom _id that might not be an ObjectId
78
+ let _id;
79
+ if (Types.ObjectId.isValid(id)) {
80
+ _id = new Types.ObjectId(id);
81
+ }
82
+ else {
83
+ _id = id; // Use the id as-is if it's not a valid ObjectId
84
+ }
85
+ return {
86
+ _id,
87
+ ...remaining,
88
+ };
89
+ }
90
+ /**
91
+ * Computes sort object from GetAllArgs sort parameter
92
+ * Handles both string-based and object-based sort specifications
93
+ */
94
+ computeSort(sort) {
95
+ // Default sort by createdAt descending if available, otherwise empty sort
96
+ if (!sort) {
97
+ return { createdAt: -1 };
98
+ }
99
+ // Handle object-based sort { key: 'fieldName', value: 'asc'|'desc' }
100
+ if (isObject(sort) && 'key' in sort) {
101
+ return {
102
+ [sort.key]: sort.value?.toLowerCase() === 'asc' ? 1 : -1,
103
+ };
104
+ }
105
+ // Handle string-based sort 'fieldName:asc' or 'fieldName:desc'
106
+ if (typeof sort === 'string') {
107
+ const [field, direction] = sort.split(':');
108
+ if (field) {
109
+ return {
110
+ [field]: direction?.toLowerCase() === 'asc' ? 1 : -1,
111
+ };
112
+ }
113
+ }
114
+ // Handle array of sort specifications
115
+ if (Array.isArray(sort)) {
116
+ return sort.reduce((acc, sortItem) => {
117
+ if (isObject(sortItem) && sortItem.key) {
118
+ acc[sortItem.key] = sortItem.value?.toLowerCase() === 'asc' ? 1 : -1;
119
+ }
120
+ return acc;
121
+ }, {});
122
+ }
123
+ // Fallback to default sort
124
+ return { createdAt: -1 };
125
+ }
126
+ /**
127
+ * Prepares an aggregation pipeline with standard stages
128
+ * @param options Query options including filtering, sorting, pagination
129
+ * @param customPipeline Optional custom pipeline stages to include
130
+ * @returns Complete MongoDB aggregation pipeline
131
+ */
132
+ preparePipeline(options, customPipeline = []) {
133
+ const { criteria, sort, limit, skip } = options;
134
+ const pipeline = [];
135
+ // Match stage (filtering)
136
+ if (criteria) {
137
+ pipeline.push({
138
+ $match: this.mapConditions(criteria),
139
+ });
140
+ }
141
+ // Add custom pipeline stages
142
+ if (customPipeline.length > 0) {
143
+ pipeline.push(...customPipeline);
144
+ }
145
+ // Sort stage
146
+ const sortBy = this.computeSort(sort);
147
+ if (Object.keys(sortBy).length > 0) {
148
+ pipeline.push({ $sort: sortBy });
149
+ }
150
+ // Pagination stages
151
+ if (skip !== undefined) {
152
+ pipeline.push({ $skip: skip || PAGINATION_OPTIONS.skip });
153
+ }
154
+ if (limit !== undefined) {
155
+ pipeline.push({ $limit: limit || PAGINATION_OPTIONS.limit });
156
+ }
157
+ return pipeline;
158
+ }
159
+ /**
160
+ * Execute an aggregation pipeline and transform the results
161
+ */
162
+ async aggregate(pipeline) {
163
+ try {
164
+ const results = await this.model.aggregate(pipeline).exec();
165
+ return this.transformDocuments(results);
166
+ }
167
+ catch (e) {
168
+ this.logger.error(e, 'Error executing aggregation pipeline: %j', pipeline);
169
+ throw e;
170
+ }
171
+ }
172
+ async count(conditions) {
173
+ return this.model.count(this.mapConditions(conditions)).exec();
174
+ }
175
+ async get(conditions, selectedFields) {
176
+ try {
177
+ const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).lean().exec();
178
+ if (!response)
179
+ return null;
180
+ // Ensure id exists
181
+ if (response && response._id && !response.id) {
182
+ response.id = response._id.toString();
183
+ }
184
+ return response;
185
+ }
186
+ catch (e) {
187
+ this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);
188
+ throw e;
189
+ }
190
+ }
191
+ async find(conditions, selectedFields) {
192
+ try {
193
+ const response = await this.model.findOne(conditions, selectedFields).lean().exec();
194
+ if (!response)
195
+ return null;
196
+ // Ensure id exists
197
+ if (response && response._id && !response.id) {
198
+ response.id = response._id.toString();
199
+ }
200
+ return response;
201
+ }
202
+ catch (e) {
203
+ this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);
204
+ throw e;
205
+ }
206
+ }
207
+ async getAll(options) {
208
+ try {
209
+ const { criteria, selectedFields, sort, limit, skip } = options;
210
+ const mappedCriteria = this.mapConditions(criteria);
211
+ const sortBy = this.computeSort(sort);
212
+ const response = await this.model
213
+ .find(mappedCriteria, selectedFields)
214
+ .sort(sortBy)
215
+ .limit(limit || PAGINATION_OPTIONS.limit)
216
+ .skip(skip || PAGINATION_OPTIONS.skip)
217
+ .lean()
218
+ .exec();
219
+ // Ensure id exists for each document
220
+ return response.map((doc) => {
221
+ if (doc._id && !doc.id) {
222
+ doc.id = doc._id.toString();
223
+ }
224
+ return doc;
225
+ });
226
+ }
227
+ catch (e) {
228
+ this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);
229
+ throw e;
230
+ }
231
+ }
232
+ /**
233
+ * Get all documents using aggregation pipeline
234
+ */
235
+ async getAllWithPipeline(options, customPipeline = []) {
236
+ try {
237
+ const pipeline = this.preparePipeline(options, customPipeline);
238
+ return this.aggregate(pipeline);
239
+ }
240
+ catch (e) {
241
+ this.logger.error(e, 'Unable to retrieve Model with pipeline [%j]', customPipeline);
242
+ throw e;
243
+ }
244
+ }
245
+ async getAllWithCount(options) {
246
+ const data = await this.getAll(options);
247
+ const totalCount = await this.count(options.criteria);
248
+ return { totalCount, data };
249
+ }
250
+ /**
251
+ * Get all documents with count using aggregation pipeline
252
+ */
253
+ async getAllWithCountAndPipeline(options, customPipeline = []) {
254
+ // Clone options to avoid modifying the original
255
+ const countOptions = { ...options };
256
+ // Remove pagination for count
257
+ delete countOptions.limit;
258
+ delete countOptions.skip;
259
+ // Prepare count pipeline (without pagination)
260
+ const countPipeline = this.preparePipeline(countOptions, customPipeline);
261
+ countPipeline.push({ $count: 'total' });
262
+ // Execute both queries in parallel
263
+ const [data, countResult] = await Promise.all([
264
+ this.getAllWithPipeline(options, customPipeline),
265
+ this.model.aggregate(countPipeline).exec(),
266
+ ]);
267
+ const totalCount = countResult?.[0]?.total || 0;
268
+ return { data, totalCount };
269
+ }
270
+ async create(data) {
271
+ try {
272
+ // Handle custom _id if provided in the data
273
+ const createData = { ...data };
274
+ // If id is provided but _id is not, map id to _id
275
+ if (createData.id && !createData._id) {
276
+ createData._id = Types.ObjectId.isValid(createData.id)
277
+ ? new Types.ObjectId(createData.id)
278
+ : createData.id;
279
+ delete createData.id; // Remove id to avoid conflicts
280
+ }
281
+ const response = await this.model.create(createData);
282
+ return this.transformDocument(response);
283
+ }
284
+ catch (e) {
285
+ this.logger.error(e, 'Unable to create Model with data [%j]', data);
286
+ throw e;
287
+ }
288
+ }
289
+ async bulkCreate(data) {
290
+ try {
291
+ const response = await this.model.insertMany(data, {
292
+ lean: true,
293
+ ordered: true,
294
+ });
295
+ // Ensure id exists for each document
296
+ return response.map((doc) => {
297
+ if (doc._id && !doc.id) {
298
+ doc.id = doc._id.toString();
299
+ }
300
+ return doc;
301
+ });
302
+ }
303
+ catch (e) {
304
+ this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);
305
+ throw e;
306
+ }
307
+ }
308
+ async upsert(conditions, update, options = {}) {
309
+ return this.update(conditions, update, {
310
+ upsert: true,
311
+ ...options,
312
+ });
313
+ }
314
+ async update(criteria, update, options = {}) {
315
+ try {
316
+ const mappedCriteria = this.mapConditions(criteria);
317
+ const mergedOptions = {
318
+ new: true,
319
+ useFindAndModify: false,
320
+ ...options,
321
+ };
322
+ const { id } = criteria;
323
+ let response;
324
+ if (id) {
325
+ response = await this.model.findByIdAndUpdate(id, update, mergedOptions).exec();
326
+ }
327
+ else {
328
+ response = await this.model.findOneAndUpdate(mappedCriteria, update, mergedOptions).exec();
329
+ }
330
+ return this.transformDocument(response);
331
+ }
332
+ catch (e) {
333
+ this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);
334
+ throw e;
335
+ }
336
+ }
337
+ async bulkUpdate(criteria, update, options = {}) {
338
+ try {
339
+ const mappedCriteria = this.mapConditions(criteria);
340
+ await this.model.updateMany(mappedCriteria, update, options);
341
+ // Fetch the updated documents
342
+ const response = await this.model.find(mappedCriteria).lean().exec();
343
+ // Ensure id exists for each document
344
+ return response.map((doc) => {
345
+ if (doc._id && !doc.id) {
346
+ doc.id = doc._id.toString();
347
+ }
348
+ return doc;
349
+ });
350
+ }
351
+ catch (e) {
352
+ this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);
353
+ throw e;
354
+ }
355
+ }
356
+ async delete(criteria) {
357
+ try {
358
+ const mappedCriteria = this.mapConditions(criteria);
359
+ let deleted;
360
+ if (criteria?.id) {
361
+ deleted = await this.model.findByIdAndDelete(criteria.id);
362
+ }
363
+ else {
364
+ deleted = await this.model.findOneAndDelete(mappedCriteria);
365
+ }
366
+ return !!deleted;
367
+ }
368
+ catch (e) {
369
+ this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);
370
+ throw e;
371
+ }
372
+ }
373
+ async bulkDelete(criteria) {
374
+ try {
375
+ const mappedCriteria = this.mapConditions(criteria);
376
+ const deleted = await this.model.deleteMany(mappedCriteria);
377
+ return deleted?.deletedCount || 0;
378
+ }
379
+ catch (e) {
380
+ this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);
381
+ throw e;
382
+ }
383
+ }
384
+ async bulkGet(ids, selectedFields) {
385
+ try {
386
+ // Create a query that handles both ObjectId and string IDs
387
+ const query = { _id: { $in: [] } };
388
+ // Process each ID
389
+ ids?.forEach((id) => {
390
+ if (Types.ObjectId.isValid(id)) {
391
+ query._id.$in.push(new Types.ObjectId(id));
392
+ }
393
+ else {
394
+ query._id.$in.push(id); // Add as string
395
+ }
396
+ });
397
+ let findQuery = this.model.find(query);
398
+ // apply select if selectedFields is provided
399
+ if (selectedFields) {
400
+ findQuery = findQuery.select(selectedFields);
401
+ }
402
+ const results = await findQuery.lean().exec();
403
+ // Ensure id exists for each document
404
+ return results.map((doc) => {
405
+ if (doc._id && !doc.id) {
406
+ doc.id = doc._id.toString();
407
+ }
408
+ return doc;
409
+ });
410
+ }
411
+ catch (e) {
412
+ this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);
413
+ throw e;
414
+ }
415
+ }
416
+ };
417
+ BaseMongoRepository = BaseMongoRepository_1 = __decorate([
418
+ injectable(),
419
+ __param(0, unmanaged()),
420
+ __param(2, unmanaged()),
421
+ __param(3, unmanaged()),
422
+ __metadata("design:paramtypes", [Function, Connection, Object, typeof (_a = typeof IMongoOptions !== "undefined" && IMongoOptions) === "function" ? _a : Object])
423
+ ], BaseMongoRepository);export{BaseMongoRepository};//# sourceMappingURL=BaseMongoRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseMongoRepository.js","sources":["../../../src/store/repositories/BaseMongoRepository.ts"],"sourcesContent":["/* eslint-disable import/no-unresolved */\n/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable no-param-reassign */\n/* eslint-disable no-underscore-dangle */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable class-methods-use-this */\nimport { isObject } from 'lodash-es';\nimport { CdmLogger } from '@cdm-logger/core';\nimport { Connection, FilterQuery, Model, PipelineStage, Types, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport {\n GetAllArgs,\n ISort,\n IBaseMongoRepository,\n IMongoOptions,\n PAGINATION_OPTIONS,\n AsDomainType,\n CreateType,\n UpdateType,\n} from 'common/server';\n\n@injectable()\nexport class BaseMongoRepository<SchemaType> implements IBaseMongoRepository<SchemaType> {\n private options: IMongoOptions;\n\n protected logger: CdmLogger.ILogger;\n\n model: Model<SchemaType & { id: string }>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<SchemaType>,\n\n db: Connection,\n @unmanaged()\n logger: CdmLogger.ILogger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n // Safe model registration to prevent \"Cannot overwrite model once compiled\" errors\n this.model = this.safeModelRegistration(db) as Model<SchemaType & { id: string }>;\n this.options = options;\n this.logger = logger.child({ className: BaseMongoRepository.name });\n }\n\n /**\n * Safely registers or retrieves a Mongoose model to prevent overwrite errors\n * This is crucial for development environments where multiple containers might try to register the same model\n */\n private safeModelRegistration(db: Connection): Model<SchemaType> {\n try {\n return this.modelFunc(db);\n } catch (error) {\n // If the error is about overwriting a model, try to get the existing model\n if (error instanceof Error && error.message.includes('Cannot overwrite')) {\n // Extract model name from the error message or try to infer it\n const modelNameMatch = error.message.match(/Cannot overwrite `(\\w+)` model/);\n if (modelNameMatch) {\n const modelName = modelNameMatch[1];\n try {\n return db.model(modelName);\n } catch (getError) {\n // If we can't get the existing model, re-throw the original error\n throw error;\n }\n }\n }\n // For any other error, re-throw it\n throw error;\n }\n }\n\n /**\n * Transforms a document to the domain model format\n */\n protected transformDocument(doc: any): AsDomainType<SchemaType> | null {\n if (!doc) return null;\n\n // If it's already a plain object (not a Mongoose document)\n if (!doc.toObject) {\n // Ensure id exists if _id is present\n if (doc._id && !doc.id) {\n doc.id = typeof doc._id === 'object' && doc._id.toString ? doc._id.toString() : doc._id;\n }\n return doc as unknown as AsDomainType<SchemaType>;\n }\n\n // For Mongoose documents, use the built-in toObject transformation\n return doc.toObject() as AsDomainType<SchemaType>;\n }\n\n /**\n * Transforms an array of documents\n */\n protected transformDocuments(docs: SchemaType[]): AsDomainType<SchemaType>[] {\n if (!docs || !Array.isArray(docs)) return [];\n return docs.map((doc) => this.transformDocument(doc)).filter(Boolean) as AsDomainType<SchemaType>[];\n }\n\n /**\n * Maps API criteria with 'id' to MongoDB criteria with '_id'\n */\n private mapConditions(conditions?: FilterQuery<SchemaType>): FilterQuery<SchemaType> {\n if (!conditions) return {};\n\n const { id, ...remaining } = conditions as any;\n\n if (!id) return remaining as FilterQuery<SchemaType>;\n\n // Handle custom _id that might not be an ObjectId\n let _id;\n if (Types.ObjectId.isValid(id)) {\n _id = new Types.ObjectId(id);\n } else {\n _id = id; // Use the id as-is if it's not a valid ObjectId\n }\n\n return {\n _id,\n ...remaining,\n } as FilterQuery<SchemaType>;\n }\n\n /**\n * Computes sort object from GetAllArgs sort parameter\n * Handles both string-based and object-based sort specifications\n */\n protected computeSort(sort: ISort | string | ISort[]): Record<string, 1 | -1> {\n // Default sort by createdAt descending if available, otherwise empty sort\n if (!sort) {\n return { createdAt: -1 };\n }\n\n // Handle object-based sort { key: 'fieldName', value: 'asc'|'desc' }\n if (isObject(sort) && 'key' in sort) {\n return {\n [sort.key]: sort.value?.toLowerCase() === 'asc' ? 1 : -1,\n };\n }\n\n // Handle string-based sort 'fieldName:asc' or 'fieldName:desc'\n if (typeof sort === 'string') {\n const [field, direction] = sort.split(':');\n if (field) {\n return {\n [field]: direction?.toLowerCase() === 'asc' ? 1 : -1,\n };\n }\n }\n\n // Handle array of sort specifications\n if (Array.isArray(sort)) {\n return sort.reduce((acc, sortItem) => {\n if (isObject(sortItem) && sortItem.key) {\n acc[sortItem.key] = sortItem.value?.toLowerCase() === 'asc' ? 1 : -1;\n }\n return acc;\n }, {});\n }\n\n // Fallback to default sort\n return { createdAt: -1 };\n }\n\n /**\n * Prepares an aggregation pipeline with standard stages\n * @param options Query options including filtering, sorting, pagination\n * @param customPipeline Optional custom pipeline stages to include\n * @returns Complete MongoDB aggregation pipeline\n */\n protected preparePipeline(options: GetAllArgs<SchemaType>, customPipeline: PipelineStage[] = []): PipelineStage[] {\n const { criteria, sort, limit, skip } = options;\n const pipeline: PipelineStage[] = [];\n\n // Match stage (filtering)\n if (criteria) {\n pipeline.push({\n $match: this.mapConditions(criteria),\n });\n }\n\n // Add custom pipeline stages\n if (customPipeline.length > 0) {\n pipeline.push(...customPipeline);\n }\n\n // Sort stage\n const sortBy = this.computeSort(sort);\n if (Object.keys(sortBy).length > 0) {\n pipeline.push({ $sort: sortBy });\n }\n\n // Pagination stages\n if (skip !== undefined) {\n pipeline.push({ $skip: skip || PAGINATION_OPTIONS.skip });\n }\n\n if (limit !== undefined) {\n pipeline.push({ $limit: limit || PAGINATION_OPTIONS.limit });\n }\n\n return pipeline;\n }\n\n /**\n * Execute an aggregation pipeline and transform the results\n */\n protected async aggregate(pipeline: PipelineStage[]): Promise<AsDomainType<SchemaType>[]> {\n try {\n const results = await this.model.aggregate(pipeline).exec();\n return this.transformDocuments(results);\n } catch (e) {\n this.logger.error(e, 'Error executing aggregation pipeline: %j', pipeline);\n throw e;\n }\n }\n\n public async count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.model.count(this.mapConditions(conditions)).exec();\n }\n\n public async get(\n conditions?: FilterQuery<SchemaType>,\n selectedFields?: string,\n ): Promise<AsDomainType<SchemaType> | null> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).lean().exec();\n\n if (!response) return null;\n\n // Ensure id exists\n if (response && (response as any)._id && !(response as any).id) {\n (response as any).id = (response as any)._id.toString();\n }\n\n return response as AsDomainType<SchemaType>;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async find(\n conditions: Partial<FilterQuery<SchemaType>>,\n selectedFields?: string,\n ): Promise<AsDomainType<SchemaType> | null> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).lean().exec();\n\n if (!response) return null;\n\n // Ensure id exists\n if (response && (response as any)._id && !(response as any).id) {\n (response as any).id = (response as any)._id.toString();\n }\n\n return response as AsDomainType<SchemaType>;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n const mappedCriteria = this.mapConditions(criteria);\n const sortBy = this.computeSort(sort);\n\n const response = await this.model\n .find(mappedCriteria, selectedFields)\n .sort(sortBy as any)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .lean()\n .exec();\n\n // Ensure id exists for each document\n return response.map((doc) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);\n throw e;\n }\n }\n\n /**\n * Get all documents using aggregation pipeline\n */\n public async getAllWithPipeline(\n options: GetAllArgs<SchemaType>,\n customPipeline: PipelineStage[] = [],\n ): Promise<AsDomainType<SchemaType>[]> {\n try {\n const pipeline = this.preparePipeline(options, customPipeline);\n return this.aggregate(pipeline);\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with pipeline [%j]', customPipeline);\n throw e;\n }\n }\n\n public async getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n }> {\n const data = await this.getAll(options);\n const totalCount = await this.count(options.criteria);\n return { totalCount, data };\n }\n\n /**\n * Get all documents with count using aggregation pipeline\n */\n public async getAllWithCountAndPipeline(\n options: GetAllArgs<SchemaType>,\n customPipeline: PipelineStage[] = [],\n ): Promise<{\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n }> {\n // Clone options to avoid modifying the original\n const countOptions = { ...options };\n\n // Remove pagination for count\n delete countOptions.limit;\n delete countOptions.skip;\n\n // Prepare count pipeline (without pagination)\n const countPipeline = this.preparePipeline(countOptions, customPipeline);\n countPipeline.push({ $count: 'total' });\n\n // Execute both queries in parallel\n const [data, countResult] = await Promise.all([\n this.getAllWithPipeline(options, customPipeline),\n this.model.aggregate(countPipeline).exec(),\n ]);\n\n const totalCount = countResult?.[0]?.total || 0;\n return { data, totalCount };\n }\n\n public async create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>> {\n try {\n // Handle custom _id if provided in the data\n const createData = { ...data } as any;\n\n // If id is provided but _id is not, map id to _id\n if (createData.id && !createData._id) {\n createData._id = Types.ObjectId.isValid(createData.id)\n ? new Types.ObjectId(createData.id)\n : createData.id;\n delete createData.id; // Remove id to avoid conflicts\n }\n\n const response = await this.model.create(createData);\n return this.transformDocument(response);\n } catch (e) {\n this.logger.error(e, 'Unable to create Model with data [%j]', data);\n throw e;\n }\n }\n\n public async bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n\n // Ensure id exists for each document\n return response.map((doc: any) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);\n throw e;\n }\n }\n\n public async upsert<T = UpdateType<SchemaType>>(\n conditions: FilterQuery<SchemaType>,\n update: T,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>> {\n return this.update(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async update<T = UpdateType<SchemaType>>(\n criteria: FilterQuery<SchemaType>,\n update: T | UpdateQuery<SchemaType>,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n\n const { id } = criteria as any;\n let response;\n\n if (id) {\n response = await this.model.findByIdAndUpdate(id, update as any, mergedOptions).exec();\n } else {\n response = await this.model.findOneAndUpdate(mappedCriteria, update as any, mergedOptions).exec();\n }\n\n return this.transformDocument(response);\n } catch (e) {\n this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async bulkUpdate<T = UpdateType<SchemaType>>(\n criteria: FilterQuery<SchemaType>,\n update: T | UpdateQuery<SchemaType>,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>[]> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n await this.model.updateMany(mappedCriteria, update as any, options);\n\n // Fetch the updated documents\n const response = await this.model.find(mappedCriteria).lean().exec();\n\n // Ensure id exists for each document\n return response.map((doc) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<SchemaType>): Promise<boolean> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n let deleted;\n\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(mappedCriteria);\n }\n\n return !!deleted;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n const deleted = await this.model.deleteMany(mappedCriteria);\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[], selectedFields?: string): Promise<AsDomainType<SchemaType>[]> {\n try {\n // Create a query that handles both ObjectId and string IDs\n const query: any = { _id: { $in: [] } };\n\n // Process each ID\n ids?.forEach((id) => {\n if (Types.ObjectId.isValid(id)) {\n query._id.$in.push(new Types.ObjectId(id));\n } else {\n query._id.$in.push(id); // Add as string\n }\n });\n\n let findQuery = this.model.find(query);\n\n // apply select if selectedFields is provided\n if (selectedFields) {\n findQuery = findQuery.select(selectedFields);\n }\n\n const results = await findQuery.lean().exec();\n\n // Ensure id exists for each document\n return results.map((doc) => {\n if ((doc as any)._id && !(doc as any).id) {\n (doc as any).id = (doc as any)._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);\n throw e;\n }\n }\n}\n"],"names":[],"mappings":";;AAsBa,IAAA,mBAAmB,GAAzB,qBAAA,GAAA,MAAM,mBAAmB,CAAA;AAShB,IAAA,SAAA,CAAA;AARJ,IAAA,OAAO,CAAgB;AAErB,IAAA,MAAM,CAAoB;AAEpC,IAAA,KAAK,CAAqC;AAE1C,IAAA,WAAA,CAEY,SAAgD,EAExD,EAAc,EAEd,MAAyB,EAEzB,OAAuB,EAAA;QANf,IAAS,CAAA,SAAA,GAAT,SAAS,CAAuC;;QASxD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAuC,CAAC;AAClF,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,qBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;KACvE;AAED;;;AAGG;AACK,IAAA,qBAAqB,CAAC,EAAc,EAAA;AACxC,QAAA,IAAI;AACA,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;SAC7B;QAAC,OAAO,KAAK,EAAE;;AAEZ,YAAA,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;;gBAEtE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBAC7E,IAAI,cAAc,EAAE;AAChB,oBAAA,MAAM,SAAS,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AC,EAAE,6CAA6C,EAAE,GAAG,CAAC,CAAC;AACzE,YAAA,MAAM,CAAC,CAAC;SACX;KACJ;EACJ;AA9eY,mBAAmB,GAAA,qBAAA,GAAA,UAAA,CAAA;AAD/B,IAAA,UAAU,EAAE;IASJ,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAIX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;+CAHR,UAAU,EAAA,MAAA,EAAA,QAAA,EAAA,GAAA,OAIJ,aAAa,KAAA,WAAA,IAAb,aAAa,CAAA,KAAA,UAAA,GAAA,EAAA,GAAA,MAAA,CAAA,CAAA;AAflB,CAAA,EAAA,mBAAmB,CA8e/B"}
@@ -0,0 +1 @@
1
+ import 'reflect-metadata';
@@ -0,0 +1 @@
1
+ import 'reflect-metadata';
@@ -1,6 +1,7 @@
1
1
  import { CdmLogger } from '@cdm-logger/core';
2
2
  import { Connection, Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';
3
- import { GetAllArgs, IBaseRepository, IMongoOptions } from '../../interfaces';
3
+ import { GetAllArgs, IMongoOptions } from '../../interfaces';
4
+ import { IBaseRepository } from 'src/interfaces/index.old';
4
5
  export declare class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {
5
6
  private modelFunc;
6
7
  private options;
@@ -1,4 +1,4 @@
1
- import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'../../interfaces/base-repository.js';var BaseRepository_1;
1
+ import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'../../interfaces/getAllArgs.js';var BaseRepository_1;
2
2
  let BaseRepository = BaseRepository_1 = class BaseRepository {
3
3
  modelFunc;
4
4
  options;
@@ -1 +1 @@
1
- {"version":3,"file":"base-repository.js","sources":["../../../src/store/repositories/base-repository.ts"],"sourcesContent":[null],"names":[],"mappings":";AAOa,IAAA,cAAc,GAApB,gBAAA,GAAA,MAAM,cAAc,CAAA;AASX,IAAA,SAAA,CAAA;AARJ,IAAA,OAAO,CAAgB;AAErB,IAAA,MAAM,CAAoB;AAEpC,IAAA,KAAK,CAAW;AAEhB,IAAA,WAAA,CAEY,SAAuC,EAE/C,EAAc,EAEd,MAAyB,EAEzB,OAAuB,EAAA;QANf,IAAS,CAAA,SAAA,GAAT,SAAS,CAA8B;AAQ/C,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;AAC3B,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,gBAAc,CAAC,IAAI,EAAE,CAAC,CAAC;KAClE;AAEO,IAAA,WAAW,CAAC,IAA2B,EAAA;AAC3C,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;SACvE;AACD,QAAA,OAAO,IAAI,CAAC;KACf;AAED,IAAA,eAAe,CAAC,OAAsB,EAAA;AAClC,QAAA,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;;QAEhE,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CACxD,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM;AACpB,YAAA,GAAG,GAAG;YACN,CAAC,GAAG,GAAG,K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O,CAAC,CAAC,OAAO,CAAC;SACpB;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,+CAA+C,EAAE,QAAQ,CAAC,CAAC;AAChF,YAAA,MAAM,CAAC,CAAC;SACX;KACJ;IAEM,MAAM,UAAU,CAAC,QAAwB,EAAA;AAC5C,QAAA,IAAI;AACA,YAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1E,YAAA,OAAO,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;SACrC;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,+CAA+C,EAAE,QAAQ,CAAC,CAAC;AAChF,YAAA,MAAM,CAAC,CAAC;SACX;KACJ;EACJ;AA/QY,cAAc,GAAA,gBAAA,GAAA,UAAA,CAAA;AAD1B,IAAA,UAAU,EAAE;IASJ,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;+CAHR,UAAU,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;AAXT,CAAA,EAAA,cAAc,CA+Q1B"}
1
+ {"version":3,"file":"base-repository.js","sources":["../../../src/store/repositories/base-repository.ts"],"sourcesContent":["import { isObject } from 'lodash-es';\nimport { CdmLogger } from '@cdm-logger/core';\nimport { Connection, Document, FilterQuery, Model, PipelineStage, Types, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport { GetAllArgs, IMongoOptions, PAGINATION_OPTIONS } from '../../interfaces';\nimport { IBaseRepository } from 'src/interfaces/index.old';\n\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: CdmLogger.ILogger;\n\n model: Model<D>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<D>,\n @unmanaged()\n db: Connection,\n @unmanaged()\n logger: CdmLogger.ILogger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db);\n this.options = options;\n this.logger = logger.child({ className: BaseRepository.name });\n }\n\n private computeSort(sort: GetAllArgs<D>['sort']): Record<string, 1 | -1> | null {\n if (isObject(sort)) {\n return { [sort?.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 };\n }\n return null;\n }\n\n preparePipeLine(options: GetAllArgs<D>): PipelineStage[] {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const mappedCriteria = Object.entries(criteria || {}).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: Types.ObjectId.isValid(value) ? new Types.ObjectId(value) : value,\n }),\n { id: undefined },\n );\n const { id, ...rest } = mappedCriteria;\n const projectedFields = selectedFields?.split(' ').reduce(\n (acc, key) => ({\n ...acc,\n [key]: 1,\n }),\n {},\n );\n return [\n { $match: Object.assign({}, rest, id ? { _id: id } : {}) },\n ...(sort ? [{ $sort: this.computeSort(sort) }] : []),\n ...(selectedFields?.length\n ? [\n {\n $project: projectedFields,\n },\n ]\n : []),\n { $skip: skip || PAGINATION_OPTIONS.skip },\n { $limit: limit || PAGINATION_OPTIONS.limit },\n { $addFields: { id: '$_id' } },\n { $project: { _id: 0 } },\n ];\n }\n\n // public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n // try {\n // return this.model.aggregate(this.preparePipeLine(options));\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const { id, ...rest } = criteria || { id: undefined };\n const sortBy = isObject(sort) ? { [sort?.key]: sort.value } : { createdAt: 1 };\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .sort(sortBy as never)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);\n throw e;\n }\n }\n\n public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[]; totalCount: number }> {\n const data = await this.getAll(options);\n const totalCount = await this.count(options.criteria);\n return { totalCount, data };\n }\n\n // public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[], totalCount: number }> {\n // try {\n // const pipeline: PipelineStage[] = this.preparePipeLine(options);\n // pipeline.push({\n // $facet: {\n // data: [{\n // $group: {\n // _id: null,\n // items: { $push: '$$ROOT' }\n // }\n // }],\n // count: [{ $count: 'count' }],\n // },\n // })\n // const result = await this.model.aggregate(pipeline);\n // const data = result[0]?.data[0]?.items || [];\n // const totalCount = result[0]?.count[0]?.count || 0;\n // return { data, totalCount };\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n // eslint-disable-next-line class-methods-use-this\n private mapConditions(conditions: FilterQuery<D>): FilterQuery<D> {\n const { id: _id, ...remaining } = conditions;\n return {\n ...(_id ? { _id } : {}),\n ...remaining,\n };\n }\n\n public async count(conditions?: FilterQuery<D>): Promise<number> {\n return this.model.count(conditions).exec();\n }\n\n public async get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[]): Promise<T[]> {\n try {\n const results = await this.model.find().setOptions({ batchSize: 100 }).where('_id').in(ids).exec();\n return results.map((i) => i.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);\n throw e;\n }\n }\n\n public async find(conditions: Partial<FilterQuery<D>>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async create<I>(data: I): Promise<T> {\n try {\n const response = await this.model.create(data);\n return response.toObject() as T;\n } catch (e) {\n this.logger.error(\n e,\n 'Unable to create Model with data ${JSON.stringify(data)} due to error [%s]',\n e.message,\n );\n throw e;\n }\n }\n\n public async bulkCreate<I>(data: I[]): Promise<T[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n return response as unknown as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);\n }\n }\n\n public async upsert<I>(conditions: FilterQuery<D>, update: I, options?: Record<string, unknown>): Promise<T> {\n return this.update<I>(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async bulkUpdate<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T[]> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const res = await this.model.updateMany(processedCriteria, update);\n if (res) {\n const response = await this.model.find(processedCriteria).exec();\n return response.map((i) => i?.toObject()) as T[];\n } else {\n this.logger.error('Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw new Error('Unable to do bulk update');\n }\n } catch (e) {\n this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async update<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n if (id) {\n return (await this.model\n .findByIdAndUpdate(id, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n }\n return (await this.model\n .findOneAndUpdate(processedCriteria, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n } catch (e) {\n this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<D>): Promise<boolean> {\n try {\n let deleted;\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(this.mapConditions(criteria));\n }\n return !!deleted;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkDelete(criteria: FilterQuery<D>): Promise<number> {\n try {\n const deleted = await this.model.deleteMany(this.mapConditions(criteria));\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n}\n"],"names":[],"mappings":";AAQa,IAAA,cAAc,GAApB,gBAAA,GAAA,MAAM,cAAc,CAAA;AASX,IAAA,SAAA,CAAA;AARJ,IAAA,OAAO,CAAgB;AAErB,IAAA,MAAM,CAAoB;AAEpC,IAAA,KAAK,CAAW;AAEhB,IAAA,WAAA,CAEY,SAAuC,EAE/C,EAAc,EAEd,MAAyB,EAEzB,OAAuB,EAAA;QANf,IAAS,CAAA,SAAA,GAAT,SAAS,CAA8B;AAQ/C,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;AAC3B,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,gBAAc,CAAC,IAAI,EAAE,CAAC,CAAC;KAClE;AAEO,IAAA,WAAW,CAAC,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,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;+CAHR,UAAU,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;AAXT,CAAA,EAAA,cAAc,CA+Q1B"}
@@ -1 +1,2 @@
1
+ export * from './BaseMongoRepository';
1
2
  export * from './base-repository';
@@ -0,0 +1,7 @@
1
+ export const SERVER_TYPES = {
2
+ BaseMongoRepository: Symbol.for('BaseMongoRepository'),
3
+ BaseMongoService: Symbol.for('BaseMongoService'),
4
+ BaseService: Symbol.for('BaseService'),
5
+ MongoDBMigration: Symbol.for('MongodbMigration'),
6
+ MongoDBConnection: Symbol.for('MongoDBConnection'),
7
+ };