@common-stack/store-mongo 7.1.1-alpha.4 → 7.1.1-alpha.41

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 (75) hide show
  1. package/lib/containers/container.d.ts +14 -0
  2. package/lib/containers/container.js +17 -0
  3. package/lib/containers/container.js.map +1 -0
  4. package/lib/containers/index.d.ts +1 -0
  5. package/lib/dataloaders/bulk-dataloader-v2.d.ts +7 -0
  6. package/lib/dataloaders/bulk-dataloader-v2.js +34 -0
  7. package/lib/dataloaders/bulk-dataloader-v2.js.map +1 -0
  8. package/lib/dataloaders/bulk-dataloader.d.ts +6 -4
  9. package/lib/dataloaders/bulk-dataloader.js +5 -7
  10. package/lib/dataloaders/bulk-dataloader.js.map +1 -1
  11. package/lib/dataloaders/index.d.ts +1 -0
  12. package/lib/graphql/schema/base-services.graphql +237 -0
  13. package/lib/helpers/mongoose-connection.js.map +1 -1
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js +1 -1
  16. package/lib/interfaces/base-repository.d.ts +15 -25
  17. package/lib/interfaces/base-service.d.ts +19 -18
  18. package/lib/interfaces/dataloaders.d.ts +10 -0
  19. package/lib/interfaces/getAllArgs.d.ts +133 -0
  20. package/lib/interfaces/getAllArgs.js +39 -0
  21. package/lib/interfaces/getAllArgs.js.map +1 -0
  22. package/lib/interfaces/index.d.ts +2 -2
  23. package/lib/mixins/BaseServiceMixin.d.ts +45 -0
  24. package/lib/mixins/BaseServiceMixin.js +208 -0
  25. package/lib/mixins/BaseServiceMixin.js.map +1 -0
  26. package/lib/mixins/base-service-mixin.d.ts +1 -1
  27. package/lib/mixins/base-service-mixin.js +2 -2
  28. package/lib/mixins/base-service-mixin.js.map +1 -1
  29. package/lib/mixins/index.d.ts +1 -0
  30. package/lib/module.d.ts +3 -0
  31. package/lib/module.js +4 -0
  32. package/lib/module.js.map +1 -0
  33. package/lib/services/BaseProxyService.d.ts +28 -0
  34. package/lib/services/BaseProxyService.js +52 -0
  35. package/lib/services/BaseProxyService.js.map +1 -0
  36. package/lib/services/BaseService.d.ts +23 -0
  37. package/lib/services/BaseService.js +65 -0
  38. package/lib/services/BaseService.js.map +1 -0
  39. package/lib/services/base-proxy-service.d.ts +17 -20
  40. package/lib/services/base-proxy-service.js +0 -3
  41. package/lib/services/base-proxy-service.js.map +1 -1
  42. package/lib/services/base-service.d.ts +18 -19
  43. package/lib/services/base-service.js +11 -13
  44. package/lib/services/base-service.js.map +1 -1
  45. package/lib/services/index.d.ts +2 -0
  46. package/lib/store/models/common-options-v2.d.ts +16 -0
  47. package/lib/store/models/common-options-v2.js +40 -0
  48. package/lib/store/models/common-options-v2.js.map +1 -0
  49. package/lib/store/models/common-options.d.ts +2 -3
  50. package/lib/store/models/common-options.js +3 -23
  51. package/lib/store/models/common-options.js.map +1 -1
  52. package/lib/store/models/index.d.ts +1 -0
  53. package/lib/store/repositories/BaseMongoRepository.d.ts +65 -0
  54. package/lib/store/repositories/BaseMongoRepository.js +395 -0
  55. package/lib/store/repositories/BaseMongoRepository.js.map +1 -0
  56. package/lib/store/repositories/base-repository.d.ts +22 -58
  57. package/lib/store/repositories/base-repository.js +135 -277
  58. package/lib/store/repositories/base-repository.js.map +1 -1
  59. package/lib/store/repositories/index.d.ts +1 -0
  60. package/lib/templates/constants/SERVER_TYPES.ts.template +7 -0
  61. package/lib/templates/repositories/DataLoader.ts.template +211 -0
  62. package/lib/templates/repositories/DatabaseMigration.ts.template +13 -0
  63. package/lib/templates/repositories/IBaseMongoRepository.ts.template +284 -0
  64. package/lib/templates/repositories/IBaseService.ts.template +231 -0
  65. package/lib/templates/repositories/IBaseServiceMixin.ts.template +473 -0
  66. package/lib/templates/repositories/dbCommonTypes.ts.template +139 -0
  67. package/lib/templates/repositories/mongoCommonTypes.ts.template +21 -0
  68. package/package.json +21 -5
  69. package/lib/interfaces/dataloader.d.ts +0 -17
  70. package/lib/interfaces/get-all-args.d.ts +0 -28
  71. package/lib/interfaces/get-all-args.js +0 -5
  72. package/lib/interfaces/get-all-args.js.map +0 -1
  73. /package/lib/services/{base-service.test.d.ts → BaseService.test.d.ts} +0 -0
  74. /package/lib/store/repositories/{base-repository.test.d.ts → BaseMongoRepository.test.d.ts} +0 -0
  75. /package/lib/store/repositories/{custom-id-repository.test.d.ts → CustomIdRepository.test.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseProxyService.js","sources":["../../src/services/BaseProxyService.ts"],"sourcesContent":["/* eslint-disable import/no-unresolved */\n/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-empty-function */\nimport { 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 { GetAllArgs, IBaseService, AsDomainType, CreateType, UpdateType, BaseServiceCommands } from 'common/server';\n\n@injectable()\nexport abstract class BaseProxyService2<SchemaType> implements IBaseService<SchemaType> {\n protected abstract logger?: CdmLogger.ILogger;\n\n protected abstract topic: string;\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 getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.callAction(BaseServiceCommands.GetByName, { name });\n }\n\n bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]> {\n return this.callAction(BaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<SchemaType>): Promise<number> {\n return this.callAction(BaseServiceCommands.Count, { criteria });\n }\n\n create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>> {\n return this.callAction(BaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<SchemaType>): Promise<boolean> {\n return this.callAction(BaseServiceCommands.Delete, { id });\n }\n\n bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n return this.callAction(BaseServiceCommands.BulkDelete, { criteria });\n }\n\n get(id?: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n return this.callAction(BaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.callAction(BaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.callAction(BaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n }> {\n return this.callAction(BaseServiceCommands.GetAllWithCount, options);\n }\n\n insert<T = CreateType<SchemaType>>(\n data: T & { id?: string },\n overwrite?: boolean,\n ): Promise<AsDomainType<SchemaType>> {\n return this.callAction(BaseServiceCommands.Insert, { data, overwrite });\n }\n\n update<T = UpdateType<SchemaType>>(id: string, data: T, overwrite?: boolean): Promise<AsDomainType<SchemaType>> {\n return this.callAction(BaseServiceCommands.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"],"names":[],"mappings":"gQAasB,IAAA,iBAAiB,GAAhC,MAAe,iBAAiB,CAAA;AAOd,IAAA,MAAA,CAAA;IAFrB,WAEqB,CAAA,MAAqB,EAGtC,MAAyB,EAAA;QAHR,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;KAItC;AAEJ,IAAA,SAAS,CAAC,IAAY,EAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACnE;AAED,IAAA,UAAU,CAA6B,IAAS,EAAA;AAC5C,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,U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BAAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC3E;AAED,IAAA,MAAM,CAA6B,EAAU,EAAE,IAAO,EAAE,SAAmB,EAAA;AACvE,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC/E;AAES,IAAA,MAAM,UAAU,CAAiB,OAAe,EAAE,MAAU,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,CAAG,EAAA,IAAI,CAAC,KAAK,IAAI,OAAO,CAAA,CAAE,EAAE,MAAM,CAAC,CAAC;KACrE;EACJ;AAtEqB,iBAAiB,GAAA,UAAA,CAAA;AADtC,IAAA,UAAU,EAAE;AAOJ,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAEnC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzB,OAAA,CAAA,CAAA,EAAA,QAAQ,EAAE,CAAA;qCAFc,aAAa,EAAA,MAAA,CAAA,CAAA;AAPxB,CAAA,EAAA,iBAAiB,CAsEtC"}
@@ -0,0 +1,23 @@
1
+ import { FilterQuery } from 'mongoose';
2
+ import { GetAllArgs, IBaseMongoRepository, IBaseService, AsDomainType, CreateType, UpdateType } from 'common/server';
3
+ export declare class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>> implements IBaseService<SchemaType, C, U> {
4
+ protected repository: IBaseMongoRepository<SchemaType>;
5
+ constructor(repository: IBaseMongoRepository<SchemaType>);
6
+ getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{
7
+ data: AsDomainType<SchemaType>[];
8
+ totalCount: number;
9
+ }>;
10
+ count(conditions?: FilterQuery<SchemaType>): Promise<number>;
11
+ get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null>;
12
+ getByName(name: string): Promise<AsDomainType<SchemaType> | null>;
13
+ getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]>;
14
+ getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]>;
15
+ create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>>;
16
+ bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]>;
17
+ update<T = UpdateType<SchemaType>>(id: string, data: T, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
18
+ insert<T = CreateType<SchemaType>>(data: T & {
19
+ id?: string;
20
+ }, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
21
+ delete(id: string | FilterQuery<SchemaType>): Promise<boolean>;
22
+ bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number>;
23
+ }
@@ -0,0 +1,65 @@
1
+ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';import {IBaseMongoRepository}from'common/server';var _a;
2
+ let BaseService2 = class BaseService2 {
3
+ repository;
4
+ constructor(repository) {
5
+ this.repository = repository;
6
+ }
7
+ async getAllWithCount(options) {
8
+ return this.repository.getAllWithCount(options);
9
+ }
10
+ count(conditions) {
11
+ return this.repository.count(conditions);
12
+ }
13
+ get(conditions) {
14
+ if (typeof conditions === 'string') {
15
+ return this.repository.get({ id: conditions });
16
+ }
17
+ return this.repository.get(conditions);
18
+ }
19
+ getByName(name) {
20
+ return this.repository.get({ name });
21
+ }
22
+ getAll(options) {
23
+ return this.repository.getAll(options);
24
+ }
25
+ getByIds(ids) {
26
+ return this.repository.bulkGet(ids);
27
+ }
28
+ create(data) {
29
+ return this.repository.create(data);
30
+ }
31
+ bulkCreate(data) {
32
+ return this.repository.bulkCreate(data);
33
+ }
34
+ async update(id, data, overwrite = false) {
35
+ return this.repository.update({ id }, data, { overwrite });
36
+ }
37
+ async insert(data, overwrite = true) {
38
+ const { id, ...rest } = data;
39
+ if (id) {
40
+ try {
41
+ const existing = await this.repository.get({ id });
42
+ if (existing) {
43
+ return this.update(id, rest, overwrite);
44
+ }
45
+ }
46
+ catch (error) {
47
+ // If not found, continue to create
48
+ }
49
+ }
50
+ return this.create(rest);
51
+ }
52
+ delete(id) {
53
+ if (typeof id === 'string') {
54
+ return this.repository.delete({ id });
55
+ }
56
+ return this.repository.delete(id);
57
+ }
58
+ bulkDelete(criteria) {
59
+ return this.repository.bulkDelete(criteria);
60
+ }
61
+ };
62
+ BaseService2 = __decorate([
63
+ injectable(),
64
+ __metadata("design:paramtypes", [typeof (_a = typeof IBaseMongoRepository !== "undefined" && IBaseMongoRepository) === "function" ? _a : Object])
65
+ ], BaseService2);export{BaseService2};//# sourceMappingURL=BaseService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseService.js","sources":["../../src/services/BaseService.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable import/no-unresolved */\n/* eslint-disable no-useless-catch */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable no-empty-function */\nimport { FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseMongoRepository, IBaseService, AsDomainType, CreateType, UpdateType } from 'common/server';\n\n@injectable()\nexport class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>>\n implements IBaseService<SchemaType, C, U>\n{\n constructor(protected repository: IBaseMongoRepository<SchemaType>) {}\n\n async getAllWithCount(\n options: GetAllArgs<SchemaType>,\n ): Promise<{ data: AsDomainType<SchemaType>[]; totalCount: number }> {\n return this.repository.getAllWithCount(options);\n }\n\n count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions } as FilterQuery<SchemaType>);\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.repository.get({ name } as any);\n }\n\n getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkGet(ids);\n }\n\n create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>> {\n return this.repository.create(data);\n }\n\n bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkCreate(data);\n }\n\n async update<T = UpdateType<SchemaType>>(\n id: string,\n data: T,\n overwrite = false,\n ): Promise<AsDomainType<SchemaType>> {\n return this.repository.update({ id } as any, data, { overwrite });\n }\n\n async insert<T = CreateType<SchemaType>>(\n data: T & { id?: string },\n overwrite = true,\n ): Promise<AsDomainType<SchemaType>> {\n const { id, ...rest } = data;\n\n if (id) {\n try {\n const existing = await this.repository.get({ id } as any);\n if (existing) {\n return this.update(id, rest as any, overwrite);\n }\n } catch (error) {\n // If not found, continue to create\n }\n }\n\n return this.create(rest as T);\n }\n\n delete(id: string | FilterQuery<SchemaType>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id } as any);\n }\n return this.repository.delete(id);\n }\n\n bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.bulkDelete(criteria);\n }\n}\n"],"names":[],"mappings":";AAWa,IAAA,YAAY,GAAlB,MAAM,YAAY,CAAA;AAGC,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA4C,EAAA;QAA5C,IAAU,CAAA,UAAA,GAAV,UAAU,CAAkC;KAAI;IAEtE,MAAM,eAAe,CACjB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KACnD;AAED,IAAA,KAAK,CAAC,UAAoC,EAAA;QACtC,OAAO,IAAI,C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,YAAA,IAAI;AACA,gBAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;gBAC1D,IAAI,QAAQ,EAAE;oBACV,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAW,EAAE,SAAS,CAAC,CAAC;iBAClD;aACJ;YAAC,OAAO,KAAK,EAAE;;aAEf;SACJ;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/C;EACJ;AAhFY,YAAY,GAAA,UAAA,CAAA;AADxB,IAAA,UAAU,EAAE;AAIyB,IAAA,UAAA,CAAA,mBAAA,EAAA,CAAA,QAAA,EAAA,GAAA,OAAA,oBAAoB,oBAApB,oBAAoB,CAAA,KAAA,UAAA,GAAA,EAAA,GAAA,MAAA,CAAA,CAAA;AAH7C,CAAA,EAAA,YAAY,CAgFxB"}
@@ -1,28 +1,25 @@
1
1
  import { ServiceBroker } from 'moleculer';
2
2
  import { FilterQuery } from 'mongoose';
3
3
  import { CdmLogger } from '@cdm-logger/core';
4
- import { GetAllArgs, IBaseService, AsDomainType, CreateType, UpdateType } from '../interfaces';
5
- export declare abstract class BaseProxyService<SchemaType> implements IBaseService<SchemaType> {
4
+ import { GetAllArgs, IBaseService } from '../interfaces';
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
+ export declare abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {
6
8
  private readonly broker;
7
9
  protected abstract logger?: CdmLogger.ILogger;
8
- protected abstract topic: string;
10
+ protected abstract topic: any;
9
11
  constructor(broker: ServiceBroker, logger: CdmLogger.ILogger);
10
- getByName(name: string): Promise<AsDomainType<SchemaType> | null>;
11
- bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]>;
12
- count(criteria?: FilterQuery<SchemaType>): Promise<number>;
13
- create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>>;
14
- delete(id: string | FilterQuery<SchemaType>): Promise<boolean>;
15
- bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number>;
16
- get(id?: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null>;
17
- getAll(options?: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]>;
18
- getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]>;
19
- getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{
20
- data: AsDomainType<SchemaType>[];
21
- totalCount: number;
22
- }>;
23
- insert<T = CreateType<SchemaType>>(data: T & {
24
- id?: string;
25
- }, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
26
- update<T = UpdateType<SchemaType>>(id: string, data: T, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
12
+ getByName(name: string): Promise<T>;
13
+ bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'>;
14
+ count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'>;
15
+ create(data: C): MethodResponse<T, C, U, 'create'>;
16
+ delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'>;
17
+ get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'>;
18
+ getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'>;
19
+ getByIds(ids: string[]): Promise<T[]>;
20
+ getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'>;
21
+ insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'>;
22
+ update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'>;
27
23
  protected callAction<T, P = unknown>(command: string, params?: P): Promise<T>;
28
24
  }
25
+ export {};
@@ -18,9 +18,6 @@ import {__decorate,__param,__metadata}from'tslib';import {injectable,inject,opti
18
18
  delete(id) {
19
19
  return this.callAction(BaseServiceCommands.Delete, { id });
20
20
  }
21
- bulkDelete(criteria) {
22
- return this.callAction(BaseServiceCommands.BulkDelete, { criteria });
23
- }
24
21
  get(id) {
25
22
  return this.callAction(BaseServiceCommands.Get, { id });
26
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-proxy-service.js","sources":["../../src/services/base-proxy-service.ts"],"sourcesContent":[null],"names":[],"mappings":"yPAYsB,IAAA,gBAAgB,GAA/B,MAAe,gBAAgB,CAAA;AAOb,IAAA,MAAA,CAAA;IAFrB,WAEqB,CAAA,MAAqB,EAGtC,MAAyB,EAAA;QAHR,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;KAItC;AAEJ,IAAA,SAAS,CAAC,IAAY,EAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACnE;AAED,IAAA,UAAU,CAA6B,IAAS,EAAA;AAC5C,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACpE;AAED,IAAA,KAAK,CAAC,QAAkC,EAAA;AACpC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;KACnE;AAED,IAAA,MAAM,CAA6B,IAAO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AAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC/E;AAES,IAAA,MAAM,UAAU,CAAiB,OAAe,EAAE,MAAU,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,CAAG,EAAA,IAAI,CAAC,KAAK,IAAI,OAAO,CAAA,CAAE,EAAE,MAAM,CAAC,CAAC;KACrE;EACJ;AAtEqB,gBAAgB,GAAA,UAAA,CAAA;AADrC,IAAA,UAAU,EAAE;AAOJ,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAEnC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzB,OAAA,CAAA,CAAA,EAAA,QAAQ,EAAE,CAAA;qCAFc,aAAa,EAAA,MAAA,CAAA,CAAA;AAPxB,CAAA,EAAA,gBAAgB,CAsErC"}
1
+ {"version":3,"file":"base-proxy-service.js","sources":["../../src/services/base-proxy-service.ts"],"sourcesContent":["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 { BaseServiceCommands } from 'common';\nimport { 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 getByName(name: string): Promise<T> {\n return this.callAction(BaseServiceCommands.GetByName, { name });\n }\n\n bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'> {\n return this.callAction<T[], { data: C[] }>(BaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'> {\n return this.callAction(BaseServiceCommands.Count, { criteria });\n }\n\n create(data: C): MethodResponse<T, C, U, 'create'> {\n return this.callAction(BaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'> {\n return this.callAction(BaseServiceCommands.Delete, { id });\n }\n\n get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'> {\n return this.callAction(BaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'> {\n return this.callAction(BaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.callAction(BaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'> {\n return this.callAction(BaseServiceCommands.GetAllWithCount, options);\n }\n\n insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'> {\n return this.callAction(BaseServiceCommands.Insert, { data, overwrite });\n }\n\n update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'> {\n return this.callAction<T>(BaseServiceCommands.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"],"names":[],"mappings":"yPAYsB,IAAA,gBAAgB,GAA/B,MAAe,gBAAgB,CAAA;AAOb,IAAA,MAAA,CAAA;IAFrB,WAEqB,CAAA,MAAqB,EAGtC,MAAyB,EAAA;QAHR,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;KAItC;AAEJ,IAAA,SAAS,CAAC,IAAY,EAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CA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AAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC3E;AAED,IAAA,MAAM,CAAC,EAAU,EAAE,IAAO,EAAE,SAAmB,EAAA;AAC3C,QAAA,OAAO,IAAI,CAAC,UAAU,CAAI,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAClF;AAES,IAAA,MAAM,UAAU,CAAiB,OAAe,EAAE,MAAU,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,CAAG,EAAA,IAAI,CAAC,KAAK,IAAI,OAAO,CAAA,CAAE,EAAE,MAAM,CAAC,CAAC;KACrE;EACJ;AA5DqB,gBAAgB,GAAA,UAAA,CAAA;AADrC,IAAA,UAAU,EAAE;AAOJ,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAEnC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzB,OAAA,CAAA,CAAA,EAAA,QAAQ,EAAE,CAAA;qCAFc,aAAa,EAAA,MAAA,CAAA,CAAA;AAPxB,CAAA,EAAA,gBAAgB,CA4DrC"}
@@ -1,23 +1,22 @@
1
- import { FilterQuery } from 'mongoose';
2
- import { GetAllArgs, IBaseRepository, IBaseService, AsDomainType, CreateType, UpdateType } from '../interfaces';
3
- export declare class BaseService<SchemaType> implements IBaseService<SchemaType> {
4
- protected repository: IBaseRepository<SchemaType>;
5
- constructor(repository: IBaseRepository<SchemaType>);
6
- getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{
7
- data: AsDomainType<SchemaType>[];
1
+ import { Document, FilterQuery } from 'mongoose';
2
+ import { GetAllArgs, IBaseRepository, IBaseService } from '../interfaces';
3
+ export declare class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {
4
+ protected repository: IBaseRepository<T>;
5
+ constructor(repository: IBaseRepository<T>);
6
+ getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{
7
+ data: T[];
8
8
  totalCount: number;
9
9
  }>;
10
- count(conditions?: FilterQuery<SchemaType>): Promise<number>;
11
- get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null>;
12
- getByName(name: string): Promise<AsDomainType<SchemaType> | null>;
13
- getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]>;
14
- getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]>;
15
- create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>>;
16
- bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]>;
17
- update<T = UpdateType<SchemaType>>(id: string, data: T, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
18
- insert<T = CreateType<SchemaType>>(data: T & {
10
+ count(conditions?: FilterQuery<Document<T>>): Promise<number>;
11
+ get(conditions: string | FilterQuery<Document<T>>): Promise<T>;
12
+ getByName(name: string): Promise<T>;
13
+ getAll(options: GetAllArgs<Document<T>>): Promise<T[]>;
14
+ getByIds(ids: string[]): Promise<T[]>;
15
+ create(data: C): Promise<T>;
16
+ bulkCreate(data: C[]): Promise<T[]>;
17
+ update(id: string, data: Partial<U>, overwrite?: boolean): Promise<T>;
18
+ insert(data: (C | U) & {
19
19
  id?: string;
20
- }, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
21
- delete(id: string | FilterQuery<SchemaType>): Promise<boolean>;
22
- bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number>;
20
+ }, overwrite?: boolean): Promise<T>;
21
+ delete(id: string | FilterQuery<Document<T>>): Promise<boolean>;
23
22
  }
@@ -2,9 +2,15 @@ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';let
2
2
  repository;
3
3
  constructor(repository) {
4
4
  this.repository = repository;
5
+ this.repository = repository;
5
6
  }
6
7
  async getAllWithCount(options) {
7
- return this.repository.getAllWithCount(options);
8
+ const totalCount = await this.count(options.criteria);
9
+ const data = await this.getAll(options);
10
+ return {
11
+ totalCount,
12
+ data,
13
+ };
8
14
  }
9
15
  count(conditions) {
10
16
  return this.repository.count(conditions);
@@ -33,17 +39,12 @@ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';let
33
39
  async update(id, data, overwrite = false) {
34
40
  return this.repository.update({ id }, data, { overwrite });
35
41
  }
36
- async insert(data, overwrite = true) {
42
+ insert(data, overwrite = true) {
37
43
  const { id, ...rest } = data;
38
44
  if (id) {
39
- try {
40
- const existing = await this.repository.get({ id });
41
- if (existing) {
42
- return this.update(id, rest, overwrite);
43
- }
44
- }
45
- catch (error) {
46
- // If not found, continue to create
45
+ const existing = this.repository.get({ id });
46
+ if (existing) {
47
+ return this.update(id, rest, overwrite);
47
48
  }
48
49
  }
49
50
  return this.create(rest);
@@ -54,9 +55,6 @@ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';let
54
55
  }
55
56
  return this.repository.delete(id);
56
57
  }
57
- bulkDelete(criteria) {
58
- return this.repository.bulkDelete(criteria);
59
- }
60
58
  };
61
59
  BaseService = __decorate([
62
60
  injectable(),
@@ -1 +1 @@
1
- {"version":3,"file":"base-service.js","sources":["../../src/services/base-service.ts"],"sourcesContent":[null],"names":[],"mappings":"6EASa,IAAA,WAAW,GAAjB,MAAM,WAAW,CAAA;AACE,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAAuC,EAAA;QAAvC,IAAU,CAAA,UAAA,GAAV,UAAU,CAA6B;KAAI;IAEjE,MAAM,eAAe,CACjB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KACnD;AAED,IAAA,KAAK,CAAC,UAAoC,EAAA;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,U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G,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;gBAC1D,IAAI,QAAQ,EAAE;oBACV,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAW,EAAE,SAAS,CAAC,CAAC;iBAClD;aACJ;YAAC,OAAO,KAAK,EAAE;;aAEf;SACJ;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/C;EACJ;AA9EY,WAAW,GAAA,UAAA,CAAA;AADvB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,WAAW,CA8EvB"}
1
+ {"version":3,"file":"base-service.js","sources":["../../src/services/base-service.ts"],"sourcesContent":["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 getByName(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"],"names":[],"mappings":"6EAKa,IAAA,WAAW,GAAjB,MAAM,WAAW,CAAA;AACE,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA8B,EAAA;QAA9B,IAAU,CAAA,UAAA,GAAV,UAAU,CAAoB;AAChD,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;IAED,MAAM,eAAe,CAAC,OAAgC,EAAA;QAClD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO;YACH,UAAU;YACV,IAAI;SACP,CAAC;KACL;AAED,IAAA,KAAK,CAAC,UAAqC,EAAA;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,UAA6C,EAAA;AAC7C,QAAA,IAAI,OAAO,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OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAS,EAAE,SAAS,CAAC,CAAC;aAChD;SACJ;AACD,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAqC,EAAA;AACxC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;SACzC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;EACJ;AAlEY,WAAW,GAAA,UAAA,CAAA;AADvB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,WAAW,CAkEvB"}
@@ -1,2 +1,4 @@
1
+ export * from './BaseService';
2
+ export * from './BaseProxyService';
1
3
  export * from './base-service';
2
4
  export * from './base-proxy-service';
@@ -0,0 +1,16 @@
1
+ import { Schema } from 'mongoose';
2
+ export declare const commonModelSchemaOptions2: {
3
+ timestamps: boolean;
4
+ toJSON: {
5
+ virtuals: boolean;
6
+ transform(doc: any, ret: any): any;
7
+ };
8
+ toObject: {
9
+ virtuals: boolean;
10
+ getters: boolean;
11
+ transform(doc: any, ret: any): any;
12
+ };
13
+ };
14
+ export declare const addIdVirtualFields2: (schema: Schema) => Schema<any, import("mongoose").Model<any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
15
+ [x: string]: any;
16
+ }>;
@@ -0,0 +1,40 @@
1
+ const commonModelSchemaOptions2 = {
2
+ timestamps: true,
3
+ toJSON: {
4
+ virtuals: true,
5
+ transform(doc, ret) {
6
+ ret.id = ret._id.toString();
7
+ delete ret.__v;
8
+ // Uncomment if you don't want _id in output
9
+ // delete ret._id;
10
+ return ret;
11
+ },
12
+ },
13
+ toObject: {
14
+ virtuals: true,
15
+ getters: true,
16
+ transform(doc, ret) {
17
+ ret.id = ret._id.toString();
18
+ delete ret.__v;
19
+ // Uncomment if you don't want _id in output
20
+ // delete ret._id;
21
+ return ret;
22
+ },
23
+ },
24
+ };
25
+ const addIdVirtualFields2 = (schema) => {
26
+ // Add id virtual getter
27
+ schema.virtual('id').get(function () {
28
+ return this._id.toHexString();
29
+ });
30
+ // Ensure virtuals are included in JSON
31
+ schema.set('toJSON', {
32
+ virtuals: true,
33
+ transform: (_, ret) => {
34
+ ret.id = ret._id.toString();
35
+ delete ret.__v;
36
+ return ret;
37
+ },
38
+ });
39
+ return schema;
40
+ };export{addIdVirtualFields2,commonModelSchemaOptions2};//# sourceMappingURL=common-options-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-options-v2.js","sources":["../../../src/store/models/common-options-v2.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/* eslint-disable no-param-reassign */\nimport { Schema } from 'mongoose';\n\nexport const commonModelSchemaOptions2 = {\n timestamps: true,\n toJSON: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id.toString();\n delete ret.__v;\n // Uncomment if you don't want _id in output\n // delete ret._id;\n return ret;\n },\n },\n toObject: {\n virtuals: true,\n getters: true,\n transform(doc, ret) {\n ret.id = ret._id.toString();\n delete ret.__v;\n // Uncomment if you don't want _id in output\n // delete ret._id;\n return ret;\n },\n },\n};\n\nexport const addIdVirtualFields2 = (schema: Schema) => {\n // Add id virtual getter\n schema.virtual('id').get(function () {\n return (this._id as any).toHexString();\n });\n\n // Ensure virtuals are included in JSON\n schema.set('toJSON', {\n virtuals: true,\n transform: (_, ret) => {\n ret.id = ret._id.toString();\n delete ret.__v;\n return ret;\n },\n });\n\n return schema;\n};\n"],"names":[],"mappings":"AAIa,MAAA,yBAAyB,GAAG;AACrC,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,MAAM,EAAE;AACJ,QAAA,QAAQ,EAAE,IAAI;QACd,SAAS,CAAC,GAAG,EAAE,GAAG,EAAA;YACd,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;;;AAGf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA;AACD,IAAA,QAAQ,EAAE;AACN,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,OAAO,EAAE,IAAI;QACb,SAAS,CAAC,GAAG,EAAE,GAAG,EAAA;YACd,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;;;AAGf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA;EACH;AAEW,MAAA,mBAAmB,GAAG,CAAC,MAAc,KAAI;;AAElD,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,YAAA;AACrB,QAAA,OAAQ,IAAI,CAAC,GAAW,CAAC,WAAW,EAAE,CAAC;AAC3C,KAAC,CAAC,CAAC;;AAGH,IAAA,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;AACjB,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAI;YAClB,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;AACf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,MAAM,CAAC;AAClB"}
@@ -1,14 +1,13 @@
1
1
  import { Schema } from 'mongoose';
2
- export declare const commonModelSchemaOptions: {
2
+ export declare const commonModeSchemaOptions: {
3
3
  timestamps: boolean;
4
4
  toJSON: {
5
5
  virtuals: boolean;
6
- transform(doc: any, ret: any): any;
7
6
  };
8
7
  toObject: {
9
8
  virtuals: boolean;
10
9
  getters: boolean;
11
- transform(doc: any, ret: any): any;
10
+ transform(doc: any, ret: any): void;
12
11
  };
13
12
  };
14
13
  export declare const addIdVirtualFields: (schema: Schema) => Schema<any, import("mongoose").Model<any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
@@ -1,40 +1,20 @@
1
- const commonModelSchemaOptions = {
1
+ const commonModeSchemaOptions = {
2
2
  timestamps: true,
3
3
  toJSON: {
4
4
  virtuals: true,
5
- transform(doc, ret) {
6
- ret.id = ret._id.toString();
7
- delete ret.__v;
8
- // Uncomment if you don't want _id in output
9
- // delete ret._id;
10
- return ret;
11
- },
12
5
  },
13
6
  toObject: {
14
7
  virtuals: true,
15
8
  getters: true,
16
9
  transform(doc, ret) {
17
- ret.id = ret._id.toString();
18
10
  delete ret.__v;
19
- // Uncomment if you don't want _id in output
20
- // delete ret._id;
21
- return ret;
11
+ delete ret._id;
22
12
  },
23
13
  },
24
14
  };
25
15
  const addIdVirtualFields = (schema) => {
26
- // Add id virtual getter
27
- schema.virtual('id').get(function () {
28
- return this._id.toHexString();
29
- });
30
- // Ensure virtuals are included in JSON
31
16
  schema.set('toJSON', {
32
17
  virtuals: true,
33
- transform: (_, ret) => {
34
- ret.id = ret._id.toString();
35
- delete ret.__v;
36
- return ret;
37
- },
38
18
  });
39
19
  return schema;
40
- };export{addIdVirtualFields,commonModelSchemaOptions};//# sourceMappingURL=common-options.js.map
20
+ };export{addIdVirtualFields,commonModeSchemaOptions};//# sourceMappingURL=common-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-options.js","sources":["../../../src/store/models/common-options.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIa,MAAA,wBAAwB,GAAG;AACpC,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,MAAM,EAAE;AACJ,QAAA,QAAQ,EAAE,IAAI;QACd,SAAS,CAAC,GAAG,EAAE,GAAG,EAAA;YACd,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;;;AAGf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA;AACD,IAAA,QAAQ,EAAE;AACN,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,OAAO,EAAE,IAAI;QACb,SAAS,CAAC,GAAG,EAAE,GAAG,EAAA;YACd,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;;;AAGf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA;EACH;AAEW,MAAA,kBAAkB,GAAG,CAAC,MAAc,KAAI;;AAEjD,IAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,YAAA;AACrB,QAAA,OAAQ,IAAI,CAAC,GAAW,CAAC,WAAW,EAAE,CAAC;AAC3C,KAAC,CAAC,CAAC;;AAGH,IAAA,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;AACjB,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAI;YAClB,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC,GAAG,CAAC;AACf,YAAA,OAAO,GAAG,CAAC;SACd;AACJ,KAAA,CAAC,CAAC;AAEH,IAAA,OAAO,MAAM,CAAC;AAClB"}
1
+ {"version":3,"file":"common-options.js","sources":["../../../src/store/models/common-options.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAEa,MAAA,uBAAuB,GAAG;AACnC,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,MAAM,EAAE;AACJ,QAAA,QAAQ,EAAE,IAAI;AACjB,KAAA;AACD,IAAA,QAAQ,EAAE;AACN,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,OAAO,EAAE,IAAI;QACb,SAAS,CAAC,GAAG,EAAE,GAAG,EAAA;YACd,OAAO,GAAG,CAAC,GAAG,CAAC;YACf,OAAO,GAAG,CAAC,GAAG,CAAC;SAClB;AACJ,KAAA;EACH;AAEW,MAAA,kBAAkB,GAAG,CAAC,MAAc,KAAI;AACjD,IAAA,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;AACjB,QAAA,QAAQ,EAAE,IAAI;AACjB,KAAA,CAAC,CAAC;AACH,IAAA,OAAO,MAAM,CAAC;AAClB"}
@@ -1 +1,2 @@
1
+ export * from './common-options-v2';
1
2
  export * from './common-options';
@@ -0,0 +1,65 @@
1
+ import { CdmLogger } from '@cdm-logger/core';
2
+ import { Connection, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';
3
+ import { GetAllArgs, ISort, IBaseMongoRepository, IMongoOptions, AsDomainType, CreateType, UpdateType } from 'common/server';
4
+ export declare class BaseMongoRepository<SchemaType> implements IBaseMongoRepository<SchemaType> {
5
+ private modelFunc;
6
+ private options;
7
+ protected logger: CdmLogger.ILogger;
8
+ model: Model<SchemaType>;
9
+ constructor(modelFunc: (db: Connection) => Model<SchemaType>, db: Connection, logger: CdmLogger.ILogger, options?: IMongoOptions);
10
+ /**
11
+ * Transforms a document to the domain model format
12
+ */
13
+ protected transformDocument(doc: any): AsDomainType<SchemaType> | null;
14
+ /**
15
+ * Transforms an array of documents
16
+ */
17
+ protected transformDocuments(docs: SchemaType[]): AsDomainType<SchemaType>[];
18
+ /**
19
+ * Maps API criteria with 'id' to MongoDB criteria with '_id'
20
+ */
21
+ private mapConditions;
22
+ /**
23
+ * Computes sort object from GetAllArgs sort parameter
24
+ * Handles both string-based and object-based sort specifications
25
+ */
26
+ protected computeSort(sort: ISort | string | ISort[]): Record<string, 1 | -1>;
27
+ /**
28
+ * Prepares an aggregation pipeline with standard stages
29
+ * @param options Query options including filtering, sorting, pagination
30
+ * @param customPipeline Optional custom pipeline stages to include
31
+ * @returns Complete MongoDB aggregation pipeline
32
+ */
33
+ protected preparePipeline(options: GetAllArgs<SchemaType>, customPipeline?: PipelineStage[]): PipelineStage[];
34
+ /**
35
+ * Execute an aggregation pipeline and transform the results
36
+ */
37
+ protected aggregate(pipeline: PipelineStage[]): Promise<AsDomainType<SchemaType>[]>;
38
+ count(conditions?: FilterQuery<SchemaType>): Promise<number>;
39
+ get(conditions?: FilterQuery<SchemaType>, selectedFields?: string): Promise<AsDomainType<SchemaType> | null>;
40
+ find(conditions: Partial<FilterQuery<SchemaType>>, selectedFields?: string): Promise<AsDomainType<SchemaType> | null>;
41
+ getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]>;
42
+ /**
43
+ * Get all documents using aggregation pipeline
44
+ */
45
+ getAllWithPipeline(options: GetAllArgs<SchemaType>, customPipeline?: PipelineStage[]): Promise<AsDomainType<SchemaType>[]>;
46
+ getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{
47
+ data: AsDomainType<SchemaType>[];
48
+ totalCount: number;
49
+ }>;
50
+ /**
51
+ * Get all documents with count using aggregation pipeline
52
+ */
53
+ getAllWithCountAndPipeline(options: GetAllArgs<SchemaType>, customPipeline?: PipelineStage[]): Promise<{
54
+ data: AsDomainType<SchemaType>[];
55
+ totalCount: number;
56
+ }>;
57
+ create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>>;
58
+ bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]>;
59
+ upsert<T = UpdateType<SchemaType>>(conditions: FilterQuery<SchemaType>, update: T, options?: Record<string, unknown>): Promise<AsDomainType<SchemaType>>;
60
+ update<T = UpdateType<SchemaType>>(criteria: FilterQuery<SchemaType>, update: T | UpdateQuery<SchemaType>, options?: Record<string, unknown>): Promise<AsDomainType<SchemaType>>;
61
+ bulkUpdate<T = UpdateType<SchemaType>>(criteria: FilterQuery<SchemaType>, update: T | UpdateQuery<SchemaType>, options?: Record<string, unknown>): Promise<AsDomainType<SchemaType>[]>;
62
+ delete(criteria: FilterQuery<SchemaType>): Promise<boolean>;
63
+ bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number>;
64
+ bulkGet(ids: string[], selectedFields?: string): Promise<AsDomainType<SchemaType>[]>;
65
+ }