@common-stack/store-mongo 0.6.1-alpha.3 → 0.6.1-alpha.4
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.
- package/lib/index.js +127 -14
- package/lib/index.js.map +1 -1
- package/lib/interfaces/base-repository.d.ts +1 -4
- package/lib/interfaces/dataloaders.d.ts +1 -1
- package/lib/interfaces/generated-models.d.ts +17 -15
- package/lib/mixins/base-service-mixin.d.ts +3 -3
- package/lib/services/base-proxy-service.d.ts +5 -5
- package/lib/store/repositories/base-repository.d.ts +7 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -163,15 +163,12 @@ __exportStar(__webpack_require__(/*! ./mixins */ "./src/mixins/index.ts"), expor
|
|
|
163
163
|
|
|
164
164
|
|
|
165
165
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
166
|
-
exports.
|
|
166
|
+
exports.PAGINATION_OPTIONS = void 0;
|
|
167
167
|
var PAGINATION_OPTIONS;
|
|
168
168
|
(function (PAGINATION_OPTIONS) {
|
|
169
169
|
PAGINATION_OPTIONS[PAGINATION_OPTIONS["limit"] = 10] = "limit";
|
|
170
170
|
PAGINATION_OPTIONS[PAGINATION_OPTIONS["skip"] = 0] = "skip";
|
|
171
171
|
})(PAGINATION_OPTIONS = exports.PAGINATION_OPTIONS || (exports.PAGINATION_OPTIONS = {}));
|
|
172
|
-
exports.DEFAULT_SORTING = {
|
|
173
|
-
id: 'asc',
|
|
174
|
-
};
|
|
175
172
|
|
|
176
173
|
|
|
177
174
|
/***/ }),
|
|
@@ -220,6 +217,7 @@ var IBaseServiceCommands;
|
|
|
220
217
|
IBaseServiceCommands["BulkCreate"] = "bulkCreate";
|
|
221
218
|
IBaseServiceCommands["Update"] = "update";
|
|
222
219
|
IBaseServiceCommands["Delete"] = "delete";
|
|
220
|
+
IBaseServiceCommands["DeleteMany"] = "deleteMany";
|
|
223
221
|
IBaseServiceCommands["GetAllWithCount"] = "getAllWithCount";
|
|
224
222
|
})(IBaseServiceCommands = exports.IBaseServiceCommands || (exports.IBaseServiceCommands = {}));
|
|
225
223
|
var ICacheControlScope;
|
|
@@ -306,8 +304,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
306
304
|
|
|
307
305
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
308
306
|
exports.BaseServiceMixin = void 0;
|
|
307
|
+
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
309
308
|
const interfaces_1 = __webpack_require__(/*! ../interfaces */ "./src/interfaces/index.ts");
|
|
310
|
-
const
|
|
309
|
+
const defaultEvents = [
|
|
310
|
+
interfaces_1.IBaseServiceCommands.Create,
|
|
311
|
+
interfaces_1.IBaseServiceCommands.BulkCreate,
|
|
312
|
+
interfaces_1.IBaseServiceCommands.Update,
|
|
313
|
+
interfaces_1.IBaseServiceCommands.Delete,
|
|
314
|
+
interfaces_1.IBaseServiceCommands.DeleteMany
|
|
315
|
+
];
|
|
316
|
+
const BaseServiceMixin = (service, broker, name, events = defaultEvents) => ({
|
|
311
317
|
name: 'BaseServiceMixin',
|
|
312
318
|
actions: {
|
|
313
319
|
[interfaces_1.IBaseServiceCommands.Get]: {
|
|
@@ -326,19 +332,38 @@ const BaseServiceMixin = (service) => ({
|
|
|
326
332
|
params: {
|
|
327
333
|
data: { type: 'array', items: 'object' },
|
|
328
334
|
},
|
|
329
|
-
handler: async (ctx) =>
|
|
335
|
+
handler: async (ctx) => {
|
|
336
|
+
const response = await service.bulkCreate(ctx.params.data);
|
|
337
|
+
if (events.includes(interfaces_1.IBaseServiceCommands.BulkCreate)) {
|
|
338
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(interfaces_1.IBaseServiceCommands.BulkCreate)}`, response));
|
|
339
|
+
}
|
|
340
|
+
return response;
|
|
341
|
+
},
|
|
330
342
|
},
|
|
331
343
|
[interfaces_1.IBaseServiceCommands.Create]: {
|
|
332
344
|
params: {
|
|
333
345
|
data: 'object',
|
|
334
346
|
},
|
|
335
|
-
handler: async (ctx) =>
|
|
347
|
+
handler: async (ctx) => {
|
|
348
|
+
const response = await service.create(ctx.params.data);
|
|
349
|
+
if (events.includes(interfaces_1.IBaseServiceCommands.Create)) {
|
|
350
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(interfaces_1.IBaseServiceCommands.Create)}`, response));
|
|
351
|
+
}
|
|
352
|
+
return response;
|
|
353
|
+
},
|
|
336
354
|
},
|
|
337
355
|
[interfaces_1.IBaseServiceCommands.Delete]: {
|
|
338
356
|
params: {
|
|
339
357
|
id: 'string',
|
|
340
358
|
},
|
|
341
|
-
handler: async (ctx) =>
|
|
359
|
+
handler: async (ctx) => {
|
|
360
|
+
const { id } = ctx.params;
|
|
361
|
+
const response = await service.delete(id);
|
|
362
|
+
if (events.includes(interfaces_1.IBaseServiceCommands.Delete)) {
|
|
363
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(interfaces_1.IBaseServiceCommands.Delete)}`, { id }));
|
|
364
|
+
}
|
|
365
|
+
return response;
|
|
366
|
+
}
|
|
342
367
|
},
|
|
343
368
|
[interfaces_1.IBaseServiceCommands.GetAll]: {
|
|
344
369
|
params: {
|
|
@@ -365,7 +390,15 @@ const BaseServiceMixin = (service) => ({
|
|
|
365
390
|
data: 'object',
|
|
366
391
|
overwrite: 'boolean|optional',
|
|
367
392
|
},
|
|
368
|
-
handler: async (ctx) =>
|
|
393
|
+
handler: async (ctx) => {
|
|
394
|
+
const { data } = ctx.params;
|
|
395
|
+
const response = await service.insert(data, ctx.params.overwrite);
|
|
396
|
+
const action = (data === null || data === void 0 ? void 0 : data.id) ? interfaces_1.IBaseServiceCommands.Update : interfaces_1.IBaseServiceCommands.Create;
|
|
397
|
+
if (events.includes(action)) {
|
|
398
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(action)}`, response));
|
|
399
|
+
}
|
|
400
|
+
return response;
|
|
401
|
+
},
|
|
369
402
|
},
|
|
370
403
|
[interfaces_1.IBaseServiceCommands.Update]: {
|
|
371
404
|
params: {
|
|
@@ -373,7 +406,26 @@ const BaseServiceMixin = (service) => ({
|
|
|
373
406
|
data: 'object',
|
|
374
407
|
overwrite: 'boolean|optional',
|
|
375
408
|
},
|
|
376
|
-
handler: async (ctx) =>
|
|
409
|
+
handler: async (ctx) => {
|
|
410
|
+
const response = await service.update(ctx.params.id, ctx.params.data, ctx.params.overwrite);
|
|
411
|
+
if (events.includes(interfaces_1.IBaseServiceCommands.Update)) {
|
|
412
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(interfaces_1.IBaseServiceCommands.Update)}`, response));
|
|
413
|
+
}
|
|
414
|
+
return response;
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
[interfaces_1.IBaseServiceCommands.DeleteMany]: {
|
|
418
|
+
params: {
|
|
419
|
+
criteria: 'object',
|
|
420
|
+
},
|
|
421
|
+
handler: async (ctx) => {
|
|
422
|
+
const { criteria } = ctx.params;
|
|
423
|
+
const response = await service.delete(criteria);
|
|
424
|
+
if (events.includes(interfaces_1.IBaseServiceCommands.DeleteMany)) {
|
|
425
|
+
await (broker === null || broker === void 0 ? void 0 : broker.emit(`${name}.on${(0, lodash_1.upperFirst)(interfaces_1.IBaseServiceCommands.DeleteMany)}`, criteria));
|
|
426
|
+
}
|
|
427
|
+
return response;
|
|
428
|
+
},
|
|
377
429
|
},
|
|
378
430
|
},
|
|
379
431
|
});
|
|
@@ -421,7 +473,6 @@ const interfaces_1 = __webpack_require__(/*! ../interfaces */ "./src/interfaces/
|
|
|
421
473
|
let BaseProxyService = class BaseProxyService {
|
|
422
474
|
constructor(broker, logger) {
|
|
423
475
|
this.broker = broker;
|
|
424
|
-
this.logger = logger.child({ className: 'BaseProxyService' });
|
|
425
476
|
}
|
|
426
477
|
bulkCreate(data) {
|
|
427
478
|
return this.callAction(interfaces_1.IBaseServiceCommands.BulkCreate, { data });
|
|
@@ -460,7 +511,8 @@ let BaseProxyService = class BaseProxyService {
|
|
|
460
511
|
BaseProxyService = __decorate([
|
|
461
512
|
(0, inversify_1.injectable)(),
|
|
462
513
|
__param(0, (0, inversify_1.inject)(core_1.CommonType.MOLECULER_BROKER)),
|
|
463
|
-
__param(1, (0, inversify_1.inject)(
|
|
514
|
+
__param(1, (0, inversify_1.inject)(core_1.CommonType.LOGGER)),
|
|
515
|
+
__param(1, (0, inversify_1.optional)())
|
|
464
516
|
], BaseProxyService);
|
|
465
517
|
exports.BaseProxyService = BaseProxyService;
|
|
466
518
|
|
|
@@ -707,6 +759,7 @@ var BaseRepository_1;
|
|
|
707
759
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
708
760
|
exports.BaseRepository = void 0;
|
|
709
761
|
const lodash_1 = __webpack_require__(/*! lodash */ "lodash");
|
|
762
|
+
const mongoose_1 = __webpack_require__(/*! mongoose */ "mongoose");
|
|
710
763
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
|
711
764
|
const interfaces_1 = __webpack_require__(/*! ../../interfaces */ "./src/interfaces/index.ts");
|
|
712
765
|
let BaseRepository = BaseRepository_1 = class BaseRepository {
|
|
@@ -716,17 +769,49 @@ let BaseRepository = BaseRepository_1 = class BaseRepository {
|
|
|
716
769
|
this.options = options;
|
|
717
770
|
this.logger = logger.child({ className: BaseRepository_1.name });
|
|
718
771
|
}
|
|
772
|
+
computeSort(sort) {
|
|
773
|
+
if ((0, lodash_1.isObject)(sort)) {
|
|
774
|
+
return { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 };
|
|
775
|
+
}
|
|
776
|
+
return null;
|
|
777
|
+
}
|
|
778
|
+
preparePipeLine(options) {
|
|
779
|
+
const { criteria, selectedFields, sort, limit, skip } = options;
|
|
780
|
+
// map id to mongoose _id
|
|
781
|
+
const mappedCriteria = Object.entries(criteria || {}).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: mongoose_1.Types.ObjectId.isValid(value) ? new mongoose_1.Types.ObjectId(value) : value })), { id: undefined });
|
|
782
|
+
const { id } = mappedCriteria, rest = __rest(mappedCriteria, ["id"]);
|
|
783
|
+
const projectedFields = selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.split(' ').reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: 1 })), {});
|
|
784
|
+
return [
|
|
785
|
+
{ $match: Object.assign({}, rest, id ? { _id: id } : {}) },
|
|
786
|
+
...(sort ? [{ $sort: this.computeSort(sort) }] : []),
|
|
787
|
+
...((selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.length) ? [{
|
|
788
|
+
$project: projectedFields
|
|
789
|
+
}] : []),
|
|
790
|
+
{ $skip: skip || interfaces_1.PAGINATION_OPTIONS.skip },
|
|
791
|
+
{ $limit: limit || interfaces_1.PAGINATION_OPTIONS.limit },
|
|
792
|
+
{ $addFields: { id: '$_id' } },
|
|
793
|
+
{ $project: { _id: 0 } },
|
|
794
|
+
];
|
|
795
|
+
}
|
|
796
|
+
// public async getAll(options: GetAllArgs<D>): Promise<T[]> {
|
|
797
|
+
// try {
|
|
798
|
+
// return this.model.aggregate(this.preparePipeLine(options));
|
|
799
|
+
// } catch (e) {
|
|
800
|
+
// this.logger.error(`Unable to retrieve Model with options ${JSON.stringify(options)}`);
|
|
801
|
+
// throw e;
|
|
802
|
+
// }
|
|
803
|
+
// }
|
|
719
804
|
async getAll(options) {
|
|
720
805
|
try {
|
|
721
806
|
const { criteria, selectedFields, sort, limit, skip } = options;
|
|
722
807
|
// map id to mongoose _id
|
|
723
808
|
const _a = criteria || { id: undefined }, { id } = _a, rest = __rest(_a, ["id"]);
|
|
724
|
-
const sortBy = (0, lodash_1.isObject)(sort) ? { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value } :
|
|
809
|
+
const sortBy = (0, lodash_1.isObject)(sort) ? { [sort === null || sort === void 0 ? void 0 : sort.key]: sort.value } : { createdAt: 1 };
|
|
725
810
|
const response = await this.model
|
|
726
811
|
.find(Object.assign(Object.assign({}, rest), (id ? { _id: id } : {})), selectedFields)
|
|
812
|
+
.sort(sortBy)
|
|
727
813
|
.limit(limit || interfaces_1.PAGINATION_OPTIONS.limit)
|
|
728
814
|
.skip(skip || interfaces_1.PAGINATION_OPTIONS.skip)
|
|
729
|
-
.sort(sortBy)
|
|
730
815
|
.exec();
|
|
731
816
|
return response.map((i) => i === null || i === void 0 ? void 0 : i.toObject());
|
|
732
817
|
}
|
|
@@ -735,6 +820,34 @@ let BaseRepository = BaseRepository_1 = class BaseRepository {
|
|
|
735
820
|
throw e;
|
|
736
821
|
}
|
|
737
822
|
}
|
|
823
|
+
async getAllWithCount(options) {
|
|
824
|
+
const data = await this.getAll(options);
|
|
825
|
+
const totalCount = await this.count(options.criteria);
|
|
826
|
+
return { totalCount, data };
|
|
827
|
+
}
|
|
828
|
+
// public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[], totalCount: number }> {
|
|
829
|
+
// try {
|
|
830
|
+
// const pipeline: PipelineStage[] = this.preparePipeLine(options);
|
|
831
|
+
// pipeline.push({
|
|
832
|
+
// $facet: {
|
|
833
|
+
// data: [{
|
|
834
|
+
// $group: {
|
|
835
|
+
// _id: null,
|
|
836
|
+
// items: { $push: '$$ROOT' }
|
|
837
|
+
// }
|
|
838
|
+
// }],
|
|
839
|
+
// count: [{ $count: 'count' }],
|
|
840
|
+
// },
|
|
841
|
+
// })
|
|
842
|
+
// const result = await this.model.aggregate(pipeline);
|
|
843
|
+
// const data = result[0]?.data[0]?.items || [];
|
|
844
|
+
// const totalCount = result[0]?.count[0]?.count || 0;
|
|
845
|
+
// return { data, totalCount };
|
|
846
|
+
// } catch (e) {
|
|
847
|
+
// this.logger.error(`Unable to retrieve Model with options ${JSON.stringify(options)}`);
|
|
848
|
+
// throw e;
|
|
849
|
+
// }
|
|
850
|
+
// }
|
|
738
851
|
// eslint-disable-next-line class-methods-use-this
|
|
739
852
|
mapConditions(conditions) {
|
|
740
853
|
const { id: _id } = conditions, remaining = __rest(conditions, ["id"]);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAyC;AACzC,sEAAkD;AAI3C,IAAM,cAAc,GAApB,MAAM,cAAyC,SAAQ,UAAqB;IAC/E,YAEI,OAAwB;QAExB,KAAK,CAAC,KAAK,EAAE,GAAa,EAAE,EAAE;YAC1B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACzC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAVY,cAAc;IAD1B,0BAAU,GAAE;IAGJ,oCAAS,GAAE;GAFP,cAAc,CAU1B;AAVY,wCAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL3B,4GAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAlC,gHAAsC;;;;;;;;;;;;;;ACAtC,iEAAqC;AAErC,MAAM,aAAa,GAAqC,CAAC,QAAQ,EAAE,EAAE;IAEjE,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,gCAAgC;QAChC,4DAA4D;IAChE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAmB,EAAE,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,G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AY,KAAI,CAAC,CAAC;SACrC;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,QAAQ,CAAC,CAAC;YACxE,MAAM,CAAC,CAAC;SACX;IACL,CAAC;CAEJ;AApMY,cAAc;IAD1B,0BAAU,GAAE;IASJ,oCAAS,GAAE;IAEX,oCAAS,GAAE;IAEX,oCAAS,GAAE;IAEX,oCAAS,GAAE;GAdP,cAAc,CAoM1B;AApMY,wCAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;ACP3B,mHAAkC;;;;;;;;;;;ACAlC;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://@common-stack/store-mongo/./src/dataloaders/bulk-dataloader.ts","webpack://@common-stack/store-mongo/./src/dataloaders/index.ts","webpack://@common-stack/store-mongo/./src/helpers/index.ts","webpack://@common-stack/store-mongo/./src/helpers/mongoose-connection.ts","webpack://@common-stack/store-mongo/./src/index.ts","webpack://@common-stack/store-mongo/./src/interfaces/base-repository.ts","webpack://@common-stack/store-mongo/./src/interfaces/base-service.ts","webpack://@common-stack/store-mongo/./src/interfaces/dataloaders.ts","webpack://@common-stack/store-mongo/./src/interfaces/generated-models.ts","webpack://@common-stack/store-mongo/./src/interfaces/get-all-args.ts","webpack://@common-stack/store-mongo/./src/interfaces/index.ts","webpack://@common-stack/store-mongo/./src/interfaces/mongoose-settings.ts","webpack://@common-stack/store-mongo/./src/mixins/base-service-mixin.ts","webpack://@common-stack/store-mongo/./src/mixins/index.ts","webpack://@common-stack/store-mongo/./src/services/base-proxy-service.ts","webpack://@common-stack/store-mongo/./src/services/base-service.ts","webpack://@common-stack/store-mongo/./src/services/index.ts","webpack://@common-stack/store-mongo/./src/store/index.ts","webpack://@common-stack/store-mongo/./src/store/models/common-options.ts","webpack://@common-stack/store-mongo/./src/store/models/index.ts","webpack://@common-stack/store-mongo/./src/store/repositories/base-repository.ts","webpack://@common-stack/store-mongo/./src/store/repositories/index.ts","webpack://@common-stack/store-mongo/external commonjs \"@common-stack/core\"","webpack://@common-stack/store-mongo/external commonjs \"dataloader\"","webpack://@common-stack/store-mongo/external commonjs \"inversify\"","webpack://@common-stack/store-mongo/external commonjs \"lodash\"","webpack://@common-stack/store-mongo/external commonjs \"mongoose\"","webpack://@common-stack/store-mongo/webpack/bootstrap","webpack://@common-stack/store-mongo/webpack/before-startup","webpack://@common-stack/store-mongo/webpack/startup","webpack://@common-stack/store-mongo/webpack/after-startup"],"sourcesContent":["import * as DataLoader from 'dataloader';\nimport { injectable, unmanaged } from 'inversify';\nimport { IBaseService } from '../interfaces';\n\n@injectable()\nexport class BulkDataLoader<T extends { id: string }> extends DataLoader<string, T> {\n constructor(\n @unmanaged()\n service: IBaseService<T>,\n ) {\n super(async (ids: string[]) => {\n const data = await service.getByIds(ids);\n return ids.map((id) => data.find((record) => record.id === id));\n });\n }\n}\n","export * from './bulk-dataloader';\n","export * from './mongoose-connection';\n","import * as mongoose from 'mongoose';\n\nconst generateMongo: (monoUrl) => mongoose.Connection = (mongoUrl) => {\n\n // creates default connection\n mongoose.connect(mongoUrl, {\n }).then(() => {\n console.info('mogoose connect - success');\n // console.info(`uri - ${uri}`);\n // console.info(`connectionOptions - ${connectionOptions}`);\n }).catch((err: mongoose.Error) => {\n console.error('mogoose connect - error - ', err);\n // throw err;\n process.kill(process.pid);\n });\n // to access default connection\n const mongooseConnection: mongoose.Connection = mongoose.connection;\n\n return mongooseConnection;\n};\n\n\n\nexport { generateMongo };\n","export * from './interfaces';\nexport * from './helpers';\nexport * from './services';\nexport * from './store';\nexport * from './dataloaders';\nexport * from './mixins';\n","import { FilterQuery, Document, Model, UpdateQuery } from 'mongoose';\nimport { GetAllArgs } from './get-all-args';\n\nexport enum PAGINATION_OPTIONS {\n limit = 10,\n skip = 0,\n}\n\nexport const DEFAULT_SORTING = {\n id: 'asc',\n};\n\nexport interface IBaseRepository<T, D = Document<T>> {\n model: Model<D>;\n count(conditions?: FilterQuery<D>): Promise<number>;\n getAll(options: GetAllArgs<D>): Promise<T[]>;\n get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T>;\n create<I>(data: I): Promise<T>;\n upsert<I>(conditions: FilterQuery<D>, update: I, options): Promise<T>;\n update<I>(criteria: FilterQuery<D>, update: UpdateQuery<D>, options?): Promise<T>;\n bulkUpdate<I>(criteria: FilterQuery<D>, update: UpdateQuery<D>, options?): Promise<T[]>;\n delete(criteria: FilterQuery<D>): Promise<boolean>;\n bulkGet(ids: string[], selectedFields?: string): Promise<T[]>;\n bulkCreate<I>(data: I[]): Promise<T[]>;\n bulkDelete(criteria: FilterQuery<D>): Promise<number>;\n}\n","import { FilterQuery, Document } from 'mongoose';\nimport { GetAllArgs } from './get-all-args';\n\nexport interface IBaseService<T, C = Omit<T, 'id'>, U = C> {\n count(conditions?: FilterQuery<Document<T>>): Promise<number>;\n\n get(id: string): Promise<T>;\n\n get(conditions?: string | FilterQuery<Document<T>>): Promise<T>;\n\n getAll(options?: GetAllArgs<Document<T>>): Promise<T[]>;\n\n getByIds(ids: string[]): Promise<T[]>;\n\n create(data: C): Promise<T>;\n\n insert(data: (C | U) & { id?: string }, overwrite?: boolean): Promise<T>;\n\n bulkCreate(data: C[]): Promise<T[]>;\n\n update(id: string, data: U, overwrite?: boolean): Promise<T>;\n\n delete(id: string): Promise<boolean>;\n\n delete(conditions: string | FilterQuery<Document<T>>): Promise<boolean>;\n\n getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }>;\n}\n","import * as DataLoader from 'dataloader';\n\nexport type IDataLoader<T> = DataLoader<string, T>;\n","/* tslint:disable */\nexport type Maybe<T> = T | null;\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\nexport type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };\nexport type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };\n/** All built-in and custom scalars, mapped to their actual values */\nexport type Scalars = {\n ID: string;\n String: string;\n Boolean: boolean;\n Int: number;\n Float: number;\n AnyObject: any;\n Date: any;\n DateTime: any;\n JSON: any;\n JSONObject: any;\n Observable: any;\n Time: any;\n URI: any;\n URIInput: any;\n};\n\n\nexport type IAdminIdeSettings = {\n __typename?: 'AdminIdeSettings';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n\nexport enum IBaseServiceCommands {\n Count = 'count',\n Get = 'get',\n GetAll = 'getAll',\n GetByIds = 'getByIds',\n Create = 'create',\n Insert = 'insert',\n BulkCreate = 'bulkCreate',\n Update = 'update',\n Delete = 'delete',\n GetAllWithCount = 'getAllWithCount'\n}\n\nexport enum ICacheControlScope {\n Public = 'PUBLIC',\n Private = 'PRIVATE'\n}\n\n\n\n/** Represents a null return value. */\nexport type IEmptyResponse = {\n __typename?: 'EmptyResponse';\n alwaysNil?: Maybe<Scalars['String']>;\n};\n\nexport type IFieldError = {\n __typename?: 'FieldError';\n field: Scalars['String'];\n message: Scalars['String'];\n};\n\n\n\n/** All Moleculer Topic names are extended from this. */\nexport enum IMoleculerServiceName {\n Dummy = 'dummy'\n}\n\nexport type IMutation = {\n __typename?: 'Mutation';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n/** An object with an ID. */\nexport type INode = {\n /** The ID of the node. */\n id: Scalars['ID'];\n};\n\n\nexport type IPageInfo = {\n __typename?: 'PageInfo';\n hasNextPage: Scalars['Boolean'];\n};\n\nexport type IQuery = {\n __typename?: 'Query';\n /** Looks up a node by ID. */\n node?: Maybe<INode>;\n};\n\n\nexport type IQueryNodeArgs = {\n id: Scalars['ID'];\n};\n\nexport type ISort = {\n key: Scalars['String'];\n value: ISortEnum;\n};\n\nexport enum ISortEnum {\n Asc = 'ASC',\n Desc = 'DESC'\n}\n\nexport type ISubscription = {\n __typename?: 'Subscription';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n\n\n","import { FilterQuery } from 'mongoose';\nimport { ISortEnum, ISort } from './generated-models';\n\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n","export * from './mongoose-settings';\nexport * from './get-all-args';\nexport * from './base-repository';\nexport * from './base-service';\nexport * from './dataloaders';\nexport * from './generated-models';\n","import * as mongoose from 'mongoose';\n\nexport interface IMongoDBSettings {\n mongoConnection: mongoose.Connection;\n}\nexport interface IMongoOptions {\n collectionName?: string;\n sessionCollectionName?: string;\n timestamps?: {\n createdAt: string;\n updatedAt: string;\n };\n convertUserIdToMongoObjectId?: boolean;\n convertSessionIdToMongoObjectId?: boolean;\n caseSensitiveUserName?: boolean;\n idProvider?: (() => string | Object);\n dateProvider?: (date?: Date) => any;\n}\n","import { Context, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { IBaseServiceCommands, GetAllArgs, IBaseService } from '../interfaces';\n\nexport const BaseServiceMixin = <T, C, U>(service: IBaseService<T, C, U>): Partial<ServiceSchema> => ({\n name: 'BaseServiceMixin',\n actions: {\n [IBaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => service.get(ctx.params.id),\n },\n [IBaseServiceCommands.Count]: {\n params: {\n criteria: { type: 'object', optional: true },\n },\n handler: async (ctx: Context<{ criteria?: FilterQuery<Document<T>> }>) =>\n service.count(ctx.params.criteria),\n },\n [IBaseServiceCommands.BulkCreate]: {\n params: {\n data: { type: 'array', items: 'object' },\n },\n handler: async (ctx: Context<{ data: never[] }>) => service.bulkCreate(ctx.params.data),\n },\n [IBaseServiceCommands.Create]: {\n params: {\n data: 'object',\n },\n handler: async (ctx: Context<{ data: never }>) => service.create(ctx.params.data),\n },\n [IBaseServiceCommands.Delete]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string | FilterQuery<Document<T>> }>) =>\n service.delete(ctx.params.id as never),\n },\n [IBaseServiceCommands.GetAll]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAll(ctx.params),\n },\n [IBaseServiceCommands.GetAllWithCount]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAllWithCount(ctx.params),\n },\n [IBaseServiceCommands.Insert]: {\n params: {\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ data: never & { id?: string }; overwrite: boolean }>) =>\n service.insert(ctx.params.data, ctx.params.overwrite),\n },\n [IBaseServiceCommands.Update]: {\n params: {\n id: 'string',\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ id: string; data: never; overwrite: boolean }>) =>\n service.update(ctx.params.id, ctx.params.data, ctx.params.overwrite),\n },\n },\n});\n","export { BaseServiceMixin } from './base-service-mixin';\n","import { inject, injectable } from 'inversify';\nimport { ServiceBroker } from 'moleculer';\nimport { FilterQuery } from 'mongoose';\nimport * as Logger from 'bunyan';\nimport { CommonType } from '@common-stack/core';\nimport { IBaseServiceCommands, GetAllArgs, IBaseService } from '../interfaces';\n\ntype MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;\ntype MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;\n\n@injectable()\nexport abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {\n protected logger: Logger;\n\n protected abstract topic;\n\n constructor(\n @inject(CommonType.MOLECULER_BROKER)\n private readonly broker: ServiceBroker,\n @inject('Logger')\n logger: Logger,\n ) {\n this.logger = logger.child({ className: 'BaseProxyService' });\n }\n\n bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'> {\n return this.callAction<T[], { data: C[] }>(IBaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'> {\n return this.callAction(IBaseServiceCommands.Count, { criteria });\n }\n\n create(data: C): MethodResponse<T, C, U, 'create'> {\n return this.callAction(IBaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'> {\n return this.callAction(IBaseServiceCommands.Delete, { id });\n }\n\n get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'> {\n return this.callAction(IBaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'> {\n return this.callAction(IBaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.callAction(IBaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'> {\n return this.callAction(IBaseServiceCommands.GetAllWithCount, options);\n }\n\n insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'> {\n return this.callAction(IBaseServiceCommands.Insert, { data, overwrite });\n }\n\n update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'> {\n return this.callAction<T>(IBaseServiceCommands.Update, { id, data, overwrite });\n }\n\n protected async callAction<T, P = unknown>(command: string, params?: P): Promise<T> {\n return this.broker.call<T, P>(`${this.topic}.${command}`, params);\n }\n}\n","import { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IBaseService } from '../interfaces';\n\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<Document<T>>): Promise<T> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions });\n }\n return this.repository.get(conditions);\n }\n\n getName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<Document<T>>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id });\n }\n return this.repository.delete(id);\n }\n}\n","export * from './base-service';\nexport * from './base-proxy-service';\n","export * from './models';\nexport * from './repositories';\n","import { Schema } from 'mongoose';\n\nexport const commonModeSchemaOptions = {\n timestamps: true,\n toJSON: {\n virtuals: true,\n },\n toObject: {\n virtuals: true,\n getters: true,\n transform(doc, ret) {\n delete ret.__v;\n delete ret._id;\n },\n },\n};\n\nexport const addIdVirtualFields = (schema: Schema) => {\n schema.set('toJSON', {\n virtuals: true,\n });\n return schema;\n};\n","export * from './common-options';\n","import { isObject } from 'lodash';\nimport { logger as Logger } from '@cdm-logger/server';\nimport { Connection, Document, FilterQuery, Model, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IMongoOptions, DEFAULT_SORTING, PAGINATION_OPTIONS, } from '../../interfaces';\n\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: typeof Logger;\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: typeof Logger,\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 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 } : DEFAULT_SORTING;\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .sort(sortBy as never)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to create Model with data ${JSON.stringify(data)} due to ${e?.message}`);\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(`Unable to bulk create due to error`, 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\n .find(processedCriteria)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } else {\n this.logger.error(\n `Unable to Bulk Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\n throw new Error('Unable to do bulk update');\n }\n\n } catch (e) {\n this.logger.error(\n `Unable to Bulk Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\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(\n `Unable to Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\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(`Unable to delete the model with criteria`, 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(`Unable to delete the model with criteria`, criteria);\n throw e;\n }\n }\n \n}\n","export * from './base-repository';\n","module.exports = require(\"@common-stack/core\");","module.exports = require(\"dataloader\");","module.exports = require(\"inversify\");","module.exports = require(\"lodash\");","module.exports = require(\"mongoose\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/index.ts\");\n",""],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAyC;AACzC,sEAAkD;AAI3C,IAAM,cAAc,GAApB,MAAM,cAAyC,SAAQ,UAAqB;IAC/E,YAEI,OAAwB;QAExB,KAAK,CAAC,KAAK,EAAE,GAAa,EAAE,EAAE;YAC1B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACzC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAVY,cAAc;IAD1B,0BAAU,GAAE;IAGJ,oCAAS,GAAE;GAFP,cAAc,CAU1B;AAVY,wCAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL3B,4GAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAlC,gHAAsC;;;;;;;;;;;;;;ACAtC,iEAAqC;AAErC,MAAM,aAAa,GAAqC,CAAC,QAAQ,EAAE,EAAE;IAEjE,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,gCAAgC;QAChC,4DAA4D;IAChE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAmB,EAAE,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;QACjD,aAAa;QACb,OAAO,CAAC,IAAI,CAAC,O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AO,CAAE,YAAY,KAAI,CAAC,CAAC;SACrC;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,QAAQ,CAAC,CAAC;YACxE,MAAM,CAAC,CAAC;SACX;IACL,CAAC;CAEJ;AA5QY,cAAc;IAD1B,0BAAU,GAAE;IASJ,oCAAS,GAAE;IAEX,oCAAS,GAAE;IAEX,oCAAS,GAAE;IAEX,oCAAS,GAAE;GAdP,cAAc,CA4Q1B;AA5QY,wCAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;ACP3B,mHAAkC;;;;;;;;;;;ACAlC;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://@common-stack/store-mongo/./src/dataloaders/bulk-dataloader.ts","webpack://@common-stack/store-mongo/./src/dataloaders/index.ts","webpack://@common-stack/store-mongo/./src/helpers/index.ts","webpack://@common-stack/store-mongo/./src/helpers/mongoose-connection.ts","webpack://@common-stack/store-mongo/./src/index.ts","webpack://@common-stack/store-mongo/./src/interfaces/base-repository.ts","webpack://@common-stack/store-mongo/./src/interfaces/base-service.ts","webpack://@common-stack/store-mongo/./src/interfaces/dataloaders.ts","webpack://@common-stack/store-mongo/./src/interfaces/generated-models.ts","webpack://@common-stack/store-mongo/./src/interfaces/get-all-args.ts","webpack://@common-stack/store-mongo/./src/interfaces/index.ts","webpack://@common-stack/store-mongo/./src/interfaces/mongoose-settings.ts","webpack://@common-stack/store-mongo/./src/mixins/base-service-mixin.ts","webpack://@common-stack/store-mongo/./src/mixins/index.ts","webpack://@common-stack/store-mongo/./src/services/base-proxy-service.ts","webpack://@common-stack/store-mongo/./src/services/base-service.ts","webpack://@common-stack/store-mongo/./src/services/index.ts","webpack://@common-stack/store-mongo/./src/store/index.ts","webpack://@common-stack/store-mongo/./src/store/models/common-options.ts","webpack://@common-stack/store-mongo/./src/store/models/index.ts","webpack://@common-stack/store-mongo/./src/store/repositories/base-repository.ts","webpack://@common-stack/store-mongo/./src/store/repositories/index.ts","webpack://@common-stack/store-mongo/external commonjs \"@common-stack/core\"","webpack://@common-stack/store-mongo/external commonjs \"dataloader\"","webpack://@common-stack/store-mongo/external commonjs \"inversify\"","webpack://@common-stack/store-mongo/external commonjs \"lodash\"","webpack://@common-stack/store-mongo/external commonjs \"mongoose\"","webpack://@common-stack/store-mongo/webpack/bootstrap","webpack://@common-stack/store-mongo/webpack/before-startup","webpack://@common-stack/store-mongo/webpack/startup","webpack://@common-stack/store-mongo/webpack/after-startup"],"sourcesContent":["import * as DataLoader from 'dataloader';\nimport { injectable, unmanaged } from 'inversify';\nimport { IBaseService } from '../interfaces';\n\n@injectable()\nexport class BulkDataLoader<T extends { id: string }> extends DataLoader<string, T> {\n constructor(\n @unmanaged()\n service: IBaseService<T>,\n ) {\n super(async (ids: string[]) => {\n const data = await service.getByIds(ids);\n return ids.map((id) => data.find((record) => record.id === id));\n });\n }\n}\n","export * from './bulk-dataloader';\n","export * from './mongoose-connection';\n","import * as mongoose from 'mongoose';\n\nconst generateMongo: (monoUrl) => mongoose.Connection = (mongoUrl) => {\n\n // creates default connection\n mongoose.connect(mongoUrl, {\n }).then(() => {\n console.info('mogoose connect - success');\n // console.info(`uri - ${uri}`);\n // console.info(`connectionOptions - ${connectionOptions}`);\n }).catch((err: mongoose.Error) => {\n console.error('mogoose connect - error - ', err);\n // throw err;\n process.kill(process.pid);\n });\n // to access default connection\n const mongooseConnection: mongoose.Connection = mongoose.connection;\n\n return mongooseConnection;\n};\n\n\n\nexport { generateMongo };\n","export * from './interfaces';\nexport * from './helpers';\nexport * from './services';\nexport * from './store';\nexport * from './dataloaders';\nexport * from './mixins';\n","import { Document, FilterQuery, Model, UpdateQuery } from 'mongoose';\nimport { GetAllArgs } from './get-all-args';\n\nexport enum PAGINATION_OPTIONS {\n limit = 10,\n skip = 0,\n}\n\nexport interface IBaseRepository<T, D = Document<T>> {\n model: Model<D>;\n count(conditions?: FilterQuery<D>): Promise<number>;\n getAll(options: GetAllArgs<D>): Promise<T[]>;\n get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T>;\n create<I>(data: I): Promise<T>;\n upsert<I>(conditions: FilterQuery<D>, update: I, options): Promise<T>;\n update<I>(criteria: FilterQuery<D>, update: UpdateQuery<D>, options?): Promise<T>;\n bulkUpdate<I>(criteria: FilterQuery<D>, update: UpdateQuery<D>, options?): Promise<T[]>;\n delete(criteria: FilterQuery<D>): Promise<boolean>;\n bulkGet(ids: string[], selectedFields?: string): Promise<T[]>;\n bulkCreate<I>(data: I[]): Promise<T[]>;\n bulkDelete(criteria: FilterQuery<D>): Promise<number>;\n}\n","import { FilterQuery, Document } from 'mongoose';\nimport { GetAllArgs } from './get-all-args';\n\nexport interface IBaseService<T, C = Omit<T, 'id'>, U = C> {\n count(conditions?: FilterQuery<Document<T>>): Promise<number>;\n\n get(id: string): Promise<T>;\n\n get(conditions?: string | FilterQuery<Document<T>>): Promise<T>;\n\n getAll(options?: GetAllArgs<Document<T>>): Promise<T[]>;\n\n getByIds(ids: string[]): Promise<T[]>;\n\n create(data: C): Promise<T>;\n\n insert(data: (C | U) & { id?: string }, overwrite?: boolean): Promise<T>;\n\n bulkCreate(data: C[]): Promise<T[]>;\n\n update(id: string, data: U, overwrite?: boolean): Promise<T>;\n\n delete(id: string): Promise<boolean>;\n\n delete(conditions: string | FilterQuery<Document<T>>): Promise<boolean>;\n\n getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }>;\n}\n","import * as DataLoader from 'dataloader';\n\nexport type IDataLoader<T> = DataLoader<string, T>;\n","/* tslint:disable */\nexport type Maybe<T> = T | null;\nexport type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\nexport type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };\nexport type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };\n/** All built-in and custom scalars, mapped to their actual values */\nexport type Scalars = {\n ID: string;\n String: string;\n Boolean: boolean;\n Int: number;\n Float: number;\n AnyObject: any;\n Date: any;\n DateTime: any;\n JSON: any;\n JSONObject: any;\n Observable: any;\n Time: any;\n Timestamp: any;\n URI: any;\n URIInput: any;\n};\n\n\nexport type IAdminIdeSettings = {\n __typename?: 'AdminIdeSettings';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n\nexport enum IBaseServiceCommands {\n Count = 'count',\n Get = 'get',\n GetAll = 'getAll',\n GetByIds = 'getByIds',\n Create = 'create',\n Insert = 'insert',\n BulkCreate = 'bulkCreate',\n Update = 'update',\n Delete = 'delete',\n DeleteMany = 'deleteMany',\n GetAllWithCount = 'getAllWithCount'\n}\n\nexport enum ICacheControlScope {\n Public = 'PUBLIC',\n Private = 'PRIVATE'\n}\n\n\n\n/** Represents a null return value. */\nexport type IEmptyResponse = {\n __typename?: 'EmptyResponse';\n alwaysNil?: Maybe<Scalars['String']>;\n};\n\nexport type IFieldError = {\n __typename?: 'FieldError';\n field: Scalars['String'];\n message: Scalars['String'];\n};\n\n\n\n/** All Moleculer Topic names are extended from this. */\nexport enum IMoleculerServiceName {\n Dummy = 'dummy'\n}\n\nexport type IMutation = {\n __typename?: 'Mutation';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n/** An object with an ID. */\nexport type INode = {\n /** The ID of the node. */\n id: Scalars['ID'];\n};\n\n\nexport type IPageInfo = {\n __typename?: 'PageInfo';\n hasNextPage: Scalars['Boolean'];\n};\n\nexport type IQuery = {\n __typename?: 'Query';\n /** Looks up a node by ID. */\n node?: Maybe<INode>;\n};\n\n\nexport type IQueryNodeArgs = {\n id: Scalars['ID'];\n};\n\nexport type ISort = {\n key: Scalars['String'];\n value: ISortEnum;\n};\n\nexport enum ISortEnum {\n Asc = 'ASC',\n Desc = 'DESC'\n}\n\nexport type ISubscription = {\n __typename?: 'Subscription';\n dummy?: Maybe<Scalars['Int']>;\n};\n\n\n\n\n","import { FilterQuery } from 'mongoose';\nimport { ISortEnum, ISort } from './generated-models';\n\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n","export * from './mongoose-settings';\nexport * from './get-all-args';\nexport * from './base-repository';\nexport * from './base-service';\nexport * from './dataloaders';\nexport * from './generated-models';\n","import * as mongoose from 'mongoose';\n\nexport interface IMongoDBSettings {\n mongoConnection: mongoose.Connection;\n}\nexport interface IMongoOptions {\n collectionName?: string;\n sessionCollectionName?: string;\n timestamps?: {\n createdAt: string;\n updatedAt: string;\n };\n convertUserIdToMongoObjectId?: boolean;\n convertSessionIdToMongoObjectId?: boolean;\n caseSensitiveUserName?: boolean;\n idProvider?: (() => string | Object);\n dateProvider?: (date?: Date) => any;\n}\n","import { Context, ServiceBroker, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { upperFirst } from 'lodash';\nimport { GetAllArgs, IBaseService, IBaseServiceCommands } from '../interfaces';\n\n\nconst defaultEvents = [\n IBaseServiceCommands.Create,\n IBaseServiceCommands.BulkCreate,\n IBaseServiceCommands.Update,\n IBaseServiceCommands.Delete,\n IBaseServiceCommands.DeleteMany\n];\n\nexport const BaseServiceMixin = <T, C, U>(\n service: IBaseService<T, C, U>,\n broker?: ServiceBroker,\n name?: string,\n events = defaultEvents,\n): Partial<ServiceSchema> => ({\n name: 'BaseServiceMixin',\n actions: {\n [IBaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => service.get(ctx.params.id),\n },\n [IBaseServiceCommands.Count]: {\n params: {\n criteria: { type: 'object', optional: true },\n },\n handler: async (ctx: Context<{ criteria?: FilterQuery<Document<T>> }>) =>\n service.count(ctx.params.criteria),\n },\n [IBaseServiceCommands.BulkCreate]: {\n params: {\n data: { type: 'array', items: 'object' },\n },\n handler: async (ctx: Context<{ data: never[] }>) => {\n const response = await service.bulkCreate(ctx.params.data);\n if (events.includes(IBaseServiceCommands.BulkCreate)) {\n await broker?.emit(`${name}.on${upperFirst(IBaseServiceCommands.BulkCreate)}`, response);\n }\n return response;\n },\n },\n [IBaseServiceCommands.Create]: {\n params: {\n data: 'object',\n },\n handler: async (ctx: Context<{ data: never }>) => {\n const response = await service.create(ctx.params.data);\n if (events.includes(IBaseServiceCommands.Create)) {\n await broker?.emit(`${name}.on${upperFirst(IBaseServiceCommands.Create)}`, response);\n }\n return response\n },\n },\n [IBaseServiceCommands.Delete]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string | FilterQuery<Document<T>> }>) => {\n const { id } = ctx.params;\n const response = await service.delete(id as never);\n if (events.includes(IBaseServiceCommands.Delete)) {\n await broker?.emit(`${name}.on${upperFirst(IBaseServiceCommands.Delete)}`, { id });\n }\n return response\n }\n },\n [IBaseServiceCommands.GetAll]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAll(ctx.params),\n },\n [IBaseServiceCommands.GetAllWithCount]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAllWithCount(ctx.params),\n },\n [IBaseServiceCommands.Insert]: {\n params: {\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ data: never & { id?: string }; overwrite: boolean }>) => {\n const { data } = ctx.params;\n const response = await service.insert(data, ctx.params.overwrite);\n const action = (data as { id: string })?.id ? IBaseServiceCommands.Update : IBaseServiceCommands.Create;\n if (events.includes(action)) {\n await broker?.emit(`${name}.on${upperFirst(action)}`, response);\n }\n return response;\n },\n },\n [IBaseServiceCommands.Update]: {\n params: {\n id: 'string',\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ id: string; data: never; overwrite: boolean }>) => {\n const response = await service.update(ctx.params.id, ctx.params.data, ctx.params.overwrite);\n if (events.includes(IBaseServiceCommands.Update)) {\n await broker?.emit(`${name}.on${upperFirst(IBaseServiceCommands.Update)}`, response);\n }\n return response\n }\n },\n [IBaseServiceCommands.DeleteMany]: {\n params: {\n criteria: 'object',\n },\n handler: async (ctx: Context<{ criteria }>) => {\n const { criteria } = ctx.params;\n const response = await service.delete(criteria);\n if (events.includes(IBaseServiceCommands.DeleteMany)) {\n await broker?.emit(`${name}.on${upperFirst(IBaseServiceCommands.DeleteMany)}`, criteria);\n }\n return response\n },\n },\n },\n});\n","export { BaseServiceMixin } from './base-service-mixin';\n","import { inject, injectable, optional } from 'inversify';\nimport { ServiceBroker } from 'moleculer';\nimport { FilterQuery } from 'mongoose';\nimport { CdmLogger } from '@cdm-logger/core';\nimport { CommonType } from '@common-stack/core';\nimport { IBaseServiceCommands, GetAllArgs, IBaseService } from '../interfaces';\n\ntype MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;\ntype MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;\n\n@injectable()\nexport abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {\n protected abstract logger?: CdmLogger.ILogger;\n\n protected abstract topic;\n\n constructor(\n @inject(CommonType.MOLECULER_BROKER)\n private readonly broker: ServiceBroker,\n @inject(CommonType.LOGGER)\n @optional()\n logger: CdmLogger.ILogger,\n ) {\n }\n\n bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'> {\n return this.callAction<T[], { data: C[] }>(IBaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'> {\n return this.callAction(IBaseServiceCommands.Count, { criteria });\n }\n\n create(data: C): MethodResponse<T, C, U, 'create'> {\n return this.callAction(IBaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'> {\n return this.callAction(IBaseServiceCommands.Delete, { id });\n }\n\n get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'> {\n return this.callAction(IBaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'> {\n return this.callAction(IBaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.callAction(IBaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'> {\n return this.callAction(IBaseServiceCommands.GetAllWithCount, options);\n }\n\n insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'> {\n return this.callAction(IBaseServiceCommands.Insert, { data, overwrite });\n }\n\n update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'> {\n return this.callAction<T>(IBaseServiceCommands.Update, { id, data, overwrite });\n }\n\n protected async callAction<T, P = unknown>(command: string, params?: P): Promise<T> {\n return this.broker.call<T, P>(`${this.topic}.${command}`, params);\n }\n}\n","import { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IBaseService } from '../interfaces';\n\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<Document<T>>): Promise<T> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions });\n }\n return this.repository.get(conditions);\n }\n\n getName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<Document<T>>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id });\n }\n return this.repository.delete(id);\n }\n}\n","export * from './base-service';\nexport * from './base-proxy-service';\n","export * from './models';\nexport * from './repositories';\n","import { Schema } from 'mongoose';\n\nexport const commonModeSchemaOptions = {\n timestamps: true,\n toJSON: {\n virtuals: true,\n },\n toObject: {\n virtuals: true,\n getters: true,\n transform(doc, ret) {\n delete ret.__v;\n delete ret._id;\n },\n },\n};\n\nexport const addIdVirtualFields = (schema: Schema) => {\n schema.set('toJSON', {\n virtuals: true,\n });\n return schema;\n};\n","export * from './common-options';\n","import { isObject } from 'lodash';\nimport { logger as Logger } from '@cdm-logger/server';\nimport { Connection, Document, FilterQuery, Model, PipelineStage, Types, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IMongoOptions, PAGINATION_OPTIONS, } from '../../interfaces';\n\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: typeof Logger;\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: typeof Logger,\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\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((acc, [key, value]) => ({\n ...acc,\n [key]: Types.ObjectId.isValid(value) ? new Types.ObjectId(value) : value,\n }), { id: undefined })\n const { id, ...rest } = mappedCriteria;\n const projectedFields = selectedFields?.split(' ').reduce((acc, key) => ({\n ...acc,\n [key]: 1\n }), {});\n return [\n { $match: Object.assign({}, rest, id ? { _id: id } : {}) },\n ...(sort ? [{ $sort: this.computeSort(sort) }] : []),\n ...(selectedFields?.length ? [{\n $project: projectedFields\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(`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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to retrieve Model with criteria ${JSON.stringify(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(`Unable to create Model with data ${JSON.stringify(data)} due to ${e?.message}`);\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(`Unable to bulk create due to error`, 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\n .find(processedCriteria)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } else {\n this.logger.error(\n `Unable to Bulk Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\n throw new Error('Unable to do bulk update');\n }\n\n } catch (e) {\n this.logger.error(\n `Unable to Bulk Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\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(\n `Unable to Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\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(`Unable to delete the model with criteria`, 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(`Unable to delete the model with criteria`, criteria);\n throw e;\n }\n }\n\n}\n","export * from './base-repository';\n","module.exports = require(\"@common-stack/core\");","module.exports = require(\"dataloader\");","module.exports = require(\"inversify\");","module.exports = require(\"lodash\");","module.exports = require(\"mongoose\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/index.ts\");\n",""],"names":[],"sourceRoot":""}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Document, FilterQuery, Model, UpdateQuery } from 'mongoose';
|
|
2
2
|
import { GetAllArgs } from './get-all-args';
|
|
3
3
|
export declare enum PAGINATION_OPTIONS {
|
|
4
4
|
limit = 10,
|
|
5
5
|
skip = 0
|
|
6
6
|
}
|
|
7
|
-
export declare const DEFAULT_SORTING: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
7
|
export interface IBaseRepository<T, D = Document<T>> {
|
|
11
8
|
model: Model<D>;
|
|
12
9
|
count(conditions?: FilterQuery<D>): Promise<number>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as DataLoader from 'dataloader';
|
|
2
|
-
export
|
|
2
|
+
export type IDataLoader<T> = DataLoader<string, T>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type Maybe<T> = T | null;
|
|
2
|
+
export type Exact<T extends {
|
|
3
3
|
[key: string]: unknown;
|
|
4
4
|
}> = {
|
|
5
5
|
[K in keyof T]: T[K];
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
8
8
|
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
11
11
|
[SubKey in K]: Maybe<T[SubKey]>;
|
|
12
12
|
};
|
|
13
13
|
/** All built-in and custom scalars, mapped to their actual values */
|
|
14
|
-
export
|
|
14
|
+
export type Scalars = {
|
|
15
15
|
ID: string;
|
|
16
16
|
String: string;
|
|
17
17
|
Boolean: boolean;
|
|
@@ -24,10 +24,11 @@ export declare type Scalars = {
|
|
|
24
24
|
JSONObject: any;
|
|
25
25
|
Observable: any;
|
|
26
26
|
Time: any;
|
|
27
|
+
Timestamp: any;
|
|
27
28
|
URI: any;
|
|
28
29
|
URIInput: any;
|
|
29
30
|
};
|
|
30
|
-
export
|
|
31
|
+
export type IAdminIdeSettings = {
|
|
31
32
|
__typename?: 'AdminIdeSettings';
|
|
32
33
|
dummy?: Maybe<Scalars['Int']>;
|
|
33
34
|
};
|
|
@@ -41,6 +42,7 @@ export declare enum IBaseServiceCommands {
|
|
|
41
42
|
BulkCreate = "bulkCreate",
|
|
42
43
|
Update = "update",
|
|
43
44
|
Delete = "delete",
|
|
45
|
+
DeleteMany = "deleteMany",
|
|
44
46
|
GetAllWithCount = "getAllWithCount"
|
|
45
47
|
}
|
|
46
48
|
export declare enum ICacheControlScope {
|
|
@@ -48,11 +50,11 @@ export declare enum ICacheControlScope {
|
|
|
48
50
|
Private = "PRIVATE"
|
|
49
51
|
}
|
|
50
52
|
/** Represents a null return value. */
|
|
51
|
-
export
|
|
53
|
+
export type IEmptyResponse = {
|
|
52
54
|
__typename?: 'EmptyResponse';
|
|
53
55
|
alwaysNil?: Maybe<Scalars['String']>;
|
|
54
56
|
};
|
|
55
|
-
export
|
|
57
|
+
export type IFieldError = {
|
|
56
58
|
__typename?: 'FieldError';
|
|
57
59
|
field: Scalars['String'];
|
|
58
60
|
message: Scalars['String'];
|
|
@@ -61,28 +63,28 @@ export declare type IFieldError = {
|
|
|
61
63
|
export declare enum IMoleculerServiceName {
|
|
62
64
|
Dummy = "dummy"
|
|
63
65
|
}
|
|
64
|
-
export
|
|
66
|
+
export type IMutation = {
|
|
65
67
|
__typename?: 'Mutation';
|
|
66
68
|
dummy?: Maybe<Scalars['Int']>;
|
|
67
69
|
};
|
|
68
70
|
/** An object with an ID. */
|
|
69
|
-
export
|
|
71
|
+
export type INode = {
|
|
70
72
|
/** The ID of the node. */
|
|
71
73
|
id: Scalars['ID'];
|
|
72
74
|
};
|
|
73
|
-
export
|
|
75
|
+
export type IPageInfo = {
|
|
74
76
|
__typename?: 'PageInfo';
|
|
75
77
|
hasNextPage: Scalars['Boolean'];
|
|
76
78
|
};
|
|
77
|
-
export
|
|
79
|
+
export type IQuery = {
|
|
78
80
|
__typename?: 'Query';
|
|
79
81
|
/** Looks up a node by ID. */
|
|
80
82
|
node?: Maybe<INode>;
|
|
81
83
|
};
|
|
82
|
-
export
|
|
84
|
+
export type IQueryNodeArgs = {
|
|
83
85
|
id: Scalars['ID'];
|
|
84
86
|
};
|
|
85
|
-
export
|
|
87
|
+
export type ISort = {
|
|
86
88
|
key: Scalars['String'];
|
|
87
89
|
value: ISortEnum;
|
|
88
90
|
};
|
|
@@ -90,7 +92,7 @@ export declare enum ISortEnum {
|
|
|
90
92
|
Asc = "ASC",
|
|
91
93
|
Desc = "DESC"
|
|
92
94
|
}
|
|
93
|
-
export
|
|
95
|
+
export type ISubscription = {
|
|
94
96
|
__typename?: 'Subscription';
|
|
95
97
|
dummy?: Maybe<Scalars['Int']>;
|
|
96
98
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ServiceSchema } from 'moleculer';
|
|
2
|
-
import { IBaseService } from '../interfaces';
|
|
3
|
-
export declare const BaseServiceMixin: <T, C, U>(service: IBaseService<T, C, U
|
|
1
|
+
import { ServiceBroker, ServiceSchema } from 'moleculer';
|
|
2
|
+
import { IBaseService, IBaseServiceCommands } from '../interfaces';
|
|
3
|
+
export declare const BaseServiceMixin: <T, C, U>(service: IBaseService<T, C, U>, broker?: ServiceBroker, name?: string, events?: IBaseServiceCommands[]) => Partial<ServiceSchema>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ServiceBroker } from 'moleculer';
|
|
2
2
|
import { FilterQuery } from 'mongoose';
|
|
3
|
-
import
|
|
3
|
+
import { CdmLogger } from '@cdm-logger/core';
|
|
4
4
|
import { GetAllArgs, IBaseService } from '../interfaces';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;
|
|
6
|
+
type MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;
|
|
7
7
|
export declare abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {
|
|
8
8
|
private readonly broker;
|
|
9
|
-
protected logger
|
|
9
|
+
protected abstract logger?: CdmLogger.ILogger;
|
|
10
10
|
protected abstract topic: any;
|
|
11
|
-
constructor(broker: ServiceBroker, logger:
|
|
11
|
+
constructor(broker: ServiceBroker, logger: CdmLogger.ILogger);
|
|
12
12
|
bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'>;
|
|
13
13
|
count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'>;
|
|
14
14
|
create(data: C): MethodResponse<T, C, U, 'create'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger as Logger } from '@cdm-logger/server';
|
|
2
|
-
import { Connection, Document, FilterQuery, Model, UpdateQuery } from 'mongoose';
|
|
2
|
+
import { Connection, Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';
|
|
3
3
|
import { GetAllArgs, IBaseRepository, IMongoOptions } from '../../interfaces';
|
|
4
4
|
export declare class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {
|
|
5
5
|
private modelFunc;
|
|
@@ -7,7 +7,13 @@ export declare class BaseRepository<T, D = Document<T>> implements IBaseReposito
|
|
|
7
7
|
protected logger: typeof Logger;
|
|
8
8
|
model: Model<D>;
|
|
9
9
|
constructor(modelFunc: (db: Connection) => Model<D>, db: Connection, logger: typeof Logger, options?: IMongoOptions);
|
|
10
|
+
private computeSort;
|
|
11
|
+
preparePipeLine(options: GetAllArgs<D>): PipelineStage[];
|
|
10
12
|
getAll(options: GetAllArgs<D>): Promise<T[]>;
|
|
13
|
+
getAllWithCount(options: GetAllArgs<D>): Promise<{
|
|
14
|
+
data: T[];
|
|
15
|
+
totalCount: number;
|
|
16
|
+
}>;
|
|
11
17
|
private mapConditions;
|
|
12
18
|
count(conditions?: FilterQuery<D>): Promise<number>;
|
|
13
19
|
get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/store-mongo",
|
|
3
|
-
"version": "0.6.1-alpha.
|
|
3
|
+
"version": "0.6.1-alpha.4",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"watch": "npm run build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@common-stack/core": "0.6.1-alpha.
|
|
22
|
+
"@common-stack/core": "0.6.1-alpha.4"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"dataloader": ">=2.0.0",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"typescript": {
|
|
32
32
|
"definition": "lib/index.d.ts"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "8f1002595ef0da183fc26d37a4a185b9c94cfc76"
|
|
35
35
|
}
|