@common-stack/store-mongo 7.1.1-alpha.6 → 7.1.1-alpha.60
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/containers/container.d.ts +14 -0
- package/lib/containers/container.js +17 -0
- package/lib/containers/container.js.map +1 -0
- package/lib/containers/index.d.ts +1 -0
- package/lib/dataloaders/bulk-dataloader-v2.d.ts +1 -1
- package/lib/dataloaders/bulk-dataloader-v2.js +3 -2
- package/lib/dataloaders/bulk-dataloader-v2.js.map +1 -1
- package/lib/dataloaders/bulk-dataloader.d.ts +1 -1
- package/lib/dataloaders/bulk-dataloader.js.map +1 -1
- package/lib/graphql/schema/base-services.graphql +237 -0
- package/lib/helpers/mongoose-connection.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/interfaces/base-repository.d.ts +1 -1
- package/lib/interfaces/base-service.d.ts +1 -1
- package/lib/interfaces/getAllArgs.d.ts +135 -0
- package/lib/interfaces/getAllArgs.js +39 -0
- package/lib/interfaces/getAllArgs.js.map +1 -0
- package/lib/interfaces/index.d.ts +1 -7
- package/lib/interfaces/index.old.d.ts +3 -0
- package/lib/mixins/BaseServiceMixin.d.ts +45 -0
- package/lib/mixins/{base-service-mixin-v2.js → BaseServiceMixin.js} +92 -3
- package/lib/mixins/BaseServiceMixin.js.map +1 -0
- package/lib/mixins/__tests__/BaseServiceMixin.test.d.ts +1 -0
- package/lib/mixins/base-service-mixin.js.map +1 -1
- package/lib/mixins/index.d.ts +1 -1
- package/lib/module.d.ts +3 -0
- package/lib/module.js +4 -0
- package/lib/module.js.map +1 -0
- package/lib/services/{base-proxy-service-v2.d.ts → BaseProxyService.d.ts} +1 -1
- package/lib/services/{base-proxy-service-v2.js → BaseProxyService.js} +2 -2
- package/lib/services/BaseProxyService.js.map +1 -0
- package/lib/{interfaces/base-service-v2.d.ts → services/BaseService.d.ts} +4 -2
- package/lib/services/{base-service-v2.js → BaseService.js} +4 -3
- package/lib/services/BaseService.js.map +1 -0
- package/lib/services/base-proxy-service.d.ts +2 -1
- package/lib/services/base-proxy-service.js.map +1 -1
- package/lib/services/base-service.d.ts +2 -1
- package/lib/services/base-service.js.map +1 -1
- package/lib/services/index.d.ts +2 -2
- package/lib/store/models/common-options-v2.js.map +1 -1
- package/lib/store/models/common-options.js.map +1 -1
- package/lib/store/repositories/{base-repository-v2.d.ts → BaseMongoRepository.d.ts} +5 -3
- package/lib/store/repositories/{base-repository-v2.js → BaseMongoRepository.js} +14 -9
- package/lib/store/repositories/BaseMongoRepository.js.map +1 -0
- package/lib/store/repositories/base-repository.d.ts +2 -1
- package/lib/store/repositories/base-repository.js +1 -1
- package/lib/store/repositories/base-repository.js.map +1 -1
- package/lib/store/repositories/index.d.ts +1 -1
- package/lib/templates/constants/SERVER_TYPES.ts.template +7 -0
- package/lib/templates/repositories/DataLoader.ts.template +211 -0
- package/lib/templates/repositories/DatabaseMigration.ts.template +13 -0
- package/lib/templates/repositories/IBaseMongoRepository.ts.template +284 -0
- package/lib/templates/repositories/IBaseService.ts.template +231 -0
- package/lib/templates/repositories/IBaseServiceMixin.ts.template +477 -0
- package/lib/templates/repositories/dbCommonTypes.ts.template +140 -0
- package/lib/templates/repositories/mongoCommonTypes.ts.template +21 -0
- package/package.json +21 -5
- package/lib/interfaces/base-repository-v2.d.ts +0 -26
- package/lib/interfaces/dataloader-v2.d.ts +0 -17
- package/lib/interfaces/get-all-args.d.ts +0 -28
- package/lib/interfaces/get-all-args.js +0 -5
- package/lib/interfaces/get-all-args.js.map +0 -1
- package/lib/mixins/base-service-mixin-v2.d.ts +0 -4
- package/lib/mixins/base-service-mixin-v2.js.map +0 -1
- package/lib/services/base-proxy-service-v2.js.map +0 -1
- package/lib/services/base-service-v2.d.ts +0 -23
- package/lib/services/base-service-v2.js.map +0 -1
- package/lib/store/repositories/base-repository-v2.js.map +0 -1
- /package/lib/services/{base-service.test.d.ts → BaseService.test.d.ts} +0 -0
- /package/lib/store/repositories/{base-repository.test.d.ts → BaseMongoRepository.test.d.ts} +0 -0
- /package/lib/store/repositories/{custom-id-repository.test.d.ts → CustomIdRepository.test.d.ts} +0 -0
|
@@ -1,25 +1,93 @@
|
|
|
1
|
-
import {upperFirst}from'lodash-es';import {BaseServiceCommands}from'common'
|
|
1
|
+
import {upperFirst}from'lodash-es';import {BaseServiceCommands}from'common';/**
|
|
2
|
+
* @file BaseServiceMixin.ts
|
|
3
|
+
* @description Provides a mixin function that adds standardized service methods to Moleculer service schemas.
|
|
4
|
+
* This mixin implements the IBaseService interface and connects it to Moleculer's service framework,
|
|
5
|
+
* creating action handlers for all standard service operations.
|
|
6
|
+
*
|
|
7
|
+
* The mixin pattern allows for composable service functionality, where multiple mixins can be combined
|
|
8
|
+
* to create feature-rich services without code duplication. This particular mixin handles the core CRUD
|
|
9
|
+
* operations and emits events when data changes.
|
|
10
|
+
*
|
|
11
|
+
* Key features:
|
|
12
|
+
* - Automatic action creation for all IBaseService methods
|
|
13
|
+
* - Event emission for data changes (create, update, delete)
|
|
14
|
+
* - Parameter validation for all actions
|
|
15
|
+
* - Consistent error handling
|
|
16
|
+
* - Type safety through generics
|
|
17
|
+
*
|
|
18
|
+
* @see IBaseService - The interface this mixin implements
|
|
19
|
+
* @see IBaseMongoRepository - The repository interface used for data access
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Default events that will trigger event emissions when data changes
|
|
23
|
+
* Services can customize this list to control which operations emit events
|
|
24
|
+
*/
|
|
25
|
+
const defaultEvents = [
|
|
2
26
|
BaseServiceCommands.Create,
|
|
3
27
|
BaseServiceCommands.BulkCreate,
|
|
4
28
|
BaseServiceCommands.Update,
|
|
5
29
|
BaseServiceCommands.Delete,
|
|
6
30
|
BaseServiceCommands.DeleteMany,
|
|
7
31
|
];
|
|
8
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Creates a mixin that implements the IBaseService interface as Moleculer actions
|
|
34
|
+
*
|
|
35
|
+
* @param service - Implementation of IBaseService that will handle the actual business logic
|
|
36
|
+
* @param broker - Moleculer service broker for event emission
|
|
37
|
+
* @param name - Service name used for event naming
|
|
38
|
+
* @param events - List of operations that should emit events
|
|
39
|
+
* @returns A partial ServiceSchema that can be merged with other service definitions
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Create a user service with the base service mixin
|
|
43
|
+
* const UserService: ServiceSchema = {
|
|
44
|
+
* name: "users",
|
|
45
|
+
* mixins: [
|
|
46
|
+
* BaseServiceMixin(userService, broker, "users")
|
|
47
|
+
* ],
|
|
48
|
+
* // Additional service-specific actions and methods
|
|
49
|
+
* actions: {
|
|
50
|
+
* changePassword: { ... }
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
*/
|
|
54
|
+
const BaseServiceMixin = (service, broker, name, events = defaultEvents) => ({
|
|
9
55
|
name: 'BaseServiceMixin',
|
|
10
56
|
actions: {
|
|
57
|
+
/**
|
|
58
|
+
* Get a single document by ID
|
|
59
|
+
*/
|
|
11
60
|
[BaseServiceCommands.Get]: {
|
|
12
61
|
params: {
|
|
13
62
|
id: 'string',
|
|
14
63
|
},
|
|
15
64
|
handler: async (ctx) => service.get({ id: ctx.params.id }),
|
|
16
65
|
},
|
|
66
|
+
/**
|
|
67
|
+
* Get multiple documents by their IDs
|
|
68
|
+
*/
|
|
69
|
+
[BaseServiceCommands.GetByIds]: {
|
|
70
|
+
params: {
|
|
71
|
+
ids: {
|
|
72
|
+
type: 'array',
|
|
73
|
+
items: 'string',
|
|
74
|
+
optional: false
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
handler: async (ctx) => service.getByIds(ctx.params.ids),
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Count documents matching criteria
|
|
81
|
+
*/
|
|
17
82
|
[BaseServiceCommands.Count]: {
|
|
18
83
|
params: {
|
|
19
84
|
criteria: { type: 'object', optional: true },
|
|
20
85
|
},
|
|
21
86
|
handler: async (ctx) => service.count(ctx.params.criteria),
|
|
22
87
|
},
|
|
88
|
+
/**
|
|
89
|
+
* Create multiple documents
|
|
90
|
+
*/
|
|
23
91
|
[BaseServiceCommands.BulkCreate]: {
|
|
24
92
|
params: {
|
|
25
93
|
data: { type: 'array', items: 'object' },
|
|
@@ -32,6 +100,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
32
100
|
return response;
|
|
33
101
|
},
|
|
34
102
|
},
|
|
103
|
+
/**
|
|
104
|
+
* Create a single document
|
|
105
|
+
*/
|
|
35
106
|
[BaseServiceCommands.Create]: {
|
|
36
107
|
params: {
|
|
37
108
|
data: 'object',
|
|
@@ -44,6 +115,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
44
115
|
return response;
|
|
45
116
|
},
|
|
46
117
|
},
|
|
118
|
+
/**
|
|
119
|
+
* Delete a document by ID
|
|
120
|
+
*/
|
|
47
121
|
[BaseServiceCommands.Delete]: {
|
|
48
122
|
params: {
|
|
49
123
|
id: 'string',
|
|
@@ -57,6 +131,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
57
131
|
return response;
|
|
58
132
|
},
|
|
59
133
|
},
|
|
134
|
+
/**
|
|
135
|
+
* Get documents with pagination
|
|
136
|
+
*/
|
|
60
137
|
[BaseServiceCommands.GetAll]: {
|
|
61
138
|
params: {
|
|
62
139
|
criteria: 'object|optional',
|
|
@@ -67,6 +144,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
67
144
|
},
|
|
68
145
|
handler: async (ctx) => service.getAll(ctx.params),
|
|
69
146
|
},
|
|
147
|
+
/**
|
|
148
|
+
* Get documents with pagination and total count
|
|
149
|
+
*/
|
|
70
150
|
[BaseServiceCommands.GetAllWithCount]: {
|
|
71
151
|
params: {
|
|
72
152
|
criteria: 'object|optional',
|
|
@@ -77,6 +157,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
77
157
|
},
|
|
78
158
|
handler: async (ctx) => service.getAllWithCount(ctx.params),
|
|
79
159
|
},
|
|
160
|
+
/**
|
|
161
|
+
* Create or update a document
|
|
162
|
+
*/
|
|
80
163
|
[BaseServiceCommands.Insert]: {
|
|
81
164
|
params: {
|
|
82
165
|
data: 'object',
|
|
@@ -92,6 +175,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
92
175
|
return response;
|
|
93
176
|
},
|
|
94
177
|
},
|
|
178
|
+
/**
|
|
179
|
+
* Update a document by ID
|
|
180
|
+
*/
|
|
95
181
|
[BaseServiceCommands.Update]: {
|
|
96
182
|
params: {
|
|
97
183
|
id: 'string',
|
|
@@ -106,6 +192,9 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
106
192
|
return response;
|
|
107
193
|
},
|
|
108
194
|
},
|
|
195
|
+
/**
|
|
196
|
+
* Delete multiple documents matching criteria
|
|
197
|
+
*/
|
|
109
198
|
[BaseServiceCommands.DeleteMany]: {
|
|
110
199
|
params: {
|
|
111
200
|
criteria: 'object',
|
|
@@ -120,4 +209,4 @@ const BaseServiceMixin2 = (service, broker, name, events = defaultEvents) => ({
|
|
|
120
209
|
},
|
|
121
210
|
},
|
|
122
211
|
},
|
|
123
|
-
});export{
|
|
212
|
+
});export{BaseServiceMixin};//# sourceMappingURL=BaseServiceMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseServiceMixin.js","sources":["../../src/mixins/BaseServiceMixin.ts"],"sourcesContent":["/**\n * @file BaseServiceMixin.ts\n * @description Provides a mixin function that adds standardized service methods to Moleculer service schemas.\n * This mixin implements the IBaseService interface and connects it to Moleculer's service framework,\n * creating action handlers for all standard service operations.\n *\n * The mixin pattern allows for composable service functionality, where multiple mixins can be combined\n * to create feature-rich services without code duplication. This particular mixin handles the core CRUD\n * operations and emits events when data changes.\n *\n * Key features:\n * - Automatic action creation for all IBaseService methods\n * - Event emission for data changes (create, update, delete)\n * - Parameter validation for all actions\n * - Consistent error handling\n * - Type safety through generics\n *\n * @see IBaseService - The interface this mixin implements\n * @see IBaseMongoRepository - The repository interface used for data access\n */\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { Context, ServiceBroker, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { upperFirst } from 'lodash-es';\nimport { GetAllArgs, IBaseService, BaseServiceCommands } from 'common';\n\n/**\n * Default events that will trigger event emissions when data changes\n * Services can customize this list to control which operations emit events\n */\nconst defaultEvents = [\n BaseServiceCommands.Create,\n BaseServiceCommands.BulkCreate,\n BaseServiceCommands.Update,\n BaseServiceCommands.Delete,\n BaseServiceCommands.DeleteMany,\n];\n\n/**\n * Creates a mixin that implements the IBaseService interface as Moleculer actions\n *\n * @param service - Implementation of IBaseService that will handle the actual business logic\n * @param broker - Moleculer service broker for event emission\n * @param name - Service name used for event naming\n * @param events - List of operations that should emit events\n * @returns A partial ServiceSchema that can be merged with other service definitions\n *\n * @example\n * // Create a user service with the base service mixin\n * const UserService: ServiceSchema = {\n * name: \"users\",\n * mixins: [\n * BaseServiceMixin(userService, broker, \"users\")\n * ],\n * // Additional service-specific actions and methods\n * actions: {\n * changePassword: { ... }\n * }\n * };\n */\nexport const BaseServiceMixin = <T>(\n service: IBaseService<T>,\n broker?: ServiceBroker,\n name?: string,\n events = defaultEvents,\n): Partial<ServiceSchema> => ({\n name: 'BaseServiceMixin',\n actions: {\n /**\n * Get a single document by ID\n */\n [BaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) =>\n service.get({ id: ctx.params.id } as FilterQuery<Document<T>>),\n },\n\n /**\n * Get multiple documents by their IDs\n */\n [BaseServiceCommands.GetByIds]: {\n params: {\n ids: { \n type: 'array', \n items: 'string',\n optional: false\n },\n },\n handler: async (ctx: Context<{ ids: string[] }>) => service.getByIds(ctx.params.ids),\n },\n\n /**\n * Count documents matching criteria\n */\n [BaseServiceCommands.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\n /**\n * Create multiple documents\n */\n [BaseServiceCommands.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(BaseServiceCommands.BulkCreate)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.BulkCreate)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Create a single document\n */\n [BaseServiceCommands.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(BaseServiceCommands.Create)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Create)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete a document by ID\n */\n [BaseServiceCommands.Delete]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => {\n const { id } = ctx.params;\n const response = await service.delete({ id } as FilterQuery<Document<T>>);\n if (events.includes(BaseServiceCommands.Delete)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Delete)}`, { id });\n }\n return response;\n },\n },\n\n /**\n * Get documents with pagination\n */\n [BaseServiceCommands.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\n /**\n * Get documents with pagination and total count\n */\n [BaseServiceCommands.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\n /**\n * Create or update a document\n */\n [BaseServiceCommands.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 ? BaseServiceCommands.Update : BaseServiceCommands.Create;\n if (events.includes(action)) {\n await broker?.emit(`${name}.on${upperFirst(action)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Update a document by ID\n */\n [BaseServiceCommands.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(BaseServiceCommands.Update)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Update)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete multiple documents matching criteria\n */\n [BaseServiceCommands.DeleteMany]: {\n params: {\n criteria: 'object',\n },\n handler: async (ctx: Context<{ criteria: FilterQuery<Document<T>> }>) => {\n const { criteria } = ctx.params;\n const response = await service.delete(criteria);\n if (events.includes(BaseServiceCommands.DeleteMany)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.DeleteMany)}`, criteria);\n }\n return response;\n },\n },\n },\n});\n"],"names":[],"mappings":"4EAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAQH;;;AAGG;AACH,MAAM,aAAa,GAAG;AAClB,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;AAC9B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;AAqBG;AACU,MAAA,gBAAgB,GAAG,CAC5B,OAAwB,EACxB,MAAsB,EACtB,IAAa,EACb,MAAM,GAAG,aAAa,MACI;AAC1B,IA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AQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC5F,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE;AAC7C,oBAAA,MAAM,MAAM,EAAE,IAAI,CAAC,CAAA,EAAG,IAAI,CAAM,GAAA,EAAA,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBACvF;AACD,gBAAA,OAAO,QAAQ,CAAC;aACnB;AACJ,SAAA;AACD,QAAA,CAAC,mBAAmB,CAAC,UAAU,GAAG;AAC9B,YAAA,MAAM,EAAE;AACJ,gBAAA,QAAQ,EAAE,QAAQ;AACrB,aAAA;AACD,YAAA,OAAO,EAAE,OAAO,GAA0B,KAAI;AAC1C,gBAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;gBAChC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChD,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;AACjD,oBAAA,MAAM,MAAM,EAAE,IAAI,CAAC,CAAA,EAAG,IAAI,CAAM,GAAA,EAAA,UAAU,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBAC3F;AACD,gBAAA,OAAO,QAAQ,CAAC;aACnB;AACJ,SAAA;AACJ,KAAA;AACJ,CAAA"}
|
|
1
|
+
{"version":3,"file":"base-service-mixin.js","sources":["../../src/mixins/base-service-mixin.ts"],"sourcesContent":["import { Context, ServiceBroker, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { upperFirst } from 'lodash-es';\nimport { BaseServiceCommands } from 'common';\nimport { GetAllArgs, IBaseService } from '../interfaces';\n\nconst defaultEvents = [\n BaseServiceCommands.Create,\n BaseServiceCommands.BulkCreate,\n BaseServiceCommands.Update,\n BaseServiceCommands.Delete,\n BaseServiceCommands.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 [BaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => service.get(ctx.params.id),\n },\n [BaseServiceCommands.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 [BaseServiceCommands.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(BaseServiceCommands.BulkCreate)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.BulkCreate)}`, response);\n }\n return response;\n },\n },\n [BaseServiceCommands.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(BaseServiceCommands.Create)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Create)}`, response);\n }\n return response;\n },\n },\n [BaseServiceCommands.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(BaseServiceCommands.Delete)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Delete)}`, { id });\n }\n return response;\n },\n },\n [BaseServiceCommands.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 [BaseServiceCommands.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 [BaseServiceCommands.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 ? BaseServiceCommands.Update : BaseServiceCommands.Create;\n if (events.includes(action)) {\n await broker?.emit(`${name}.on${upperFirst(action)}`, response);\n }\n return response;\n },\n },\n [BaseServiceCommands.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(BaseServiceCommands.Update)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Update)}`, response);\n }\n return response;\n },\n },\n [BaseServiceCommands.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(BaseServiceCommands.DeleteMany)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.DeleteMany)}`, criteria);\n }\n return response;\n },\n },\n },\n});\n"],"names":[],"mappings":"4EAMA,MAAM,aAAa,GAAG;AAClB,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;AAC9B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;CACjC,CAAC;AAEW,MAAA,gBAAgB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UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBAC3F;AACD,gBAAA,OAAO,QAAQ,CAAC;aACnB;AACJ,SAAA;AACJ,KAAA;AACJ,CAAA"}
|
package/lib/mixins/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BaseServiceMixin2 } from './
|
|
1
|
+
export { BaseServiceMixin as BaseServiceMixin2 } from './BaseServiceMixin';
|
|
2
2
|
export { BaseServiceMixin } from './base-service-mixin';
|
package/lib/module.d.ts
ADDED
package/lib/module.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {Feature}from'@common-stack/server-core';import {localContainerModule,externalContainerModule}from'./containers/container.js';var module = new Feature({
|
|
2
|
+
createContainerFunc: [localContainerModule],
|
|
3
|
+
createHemeraContainerFunc: [externalContainerModule],
|
|
4
|
+
});export{module as default};//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["import { Feature } from '@common-stack/server-core';\nimport { externalContainerModule, localContainerModule } from './containers';\n\nexport default new Feature({\n createContainerFunc: [localContainerModule],\n createHemeraContainerFunc: [externalContainerModule],\n});\n"],"names":[],"mappings":"qIAGA,aAAe,IAAI,OAAO,CAAC;IACvB,mBAAmB,EAAE,CAAC,oBAAoB,CAAC;IAC3C,yBAAyB,EAAE,CAAC,uBAAuB,CAAC;AACvD,CAAA,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServiceBroker } from 'moleculer';
|
|
2
2
|
import { FilterQuery } from 'mongoose';
|
|
3
3
|
import { CdmLogger } from '@cdm-logger/core';
|
|
4
|
-
import { GetAllArgs,
|
|
4
|
+
import { GetAllArgs, IBaseService, AsDomainType, CreateType, UpdateType } from 'common/server';
|
|
5
5
|
export declare abstract class BaseProxyService2<SchemaType> implements IBaseService<SchemaType> {
|
|
6
6
|
private readonly broker;
|
|
7
7
|
protected abstract logger?: CdmLogger.ILogger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {__decorate,__param,__metadata}from'tslib';import {injectable,inject,optional}from'inversify';import {ServiceBroker}from'moleculer';import'@cdm-logger/core';import {CommonType}from'@common-stack/core';import {BaseServiceCommands}from'common';let BaseProxyService2 = class BaseProxyService2 {
|
|
1
|
+
import {__decorate,__param,__metadata}from'tslib';import {injectable,inject,optional}from'inversify';import {ServiceBroker}from'moleculer';import'@cdm-logger/core';import {CommonType}from'@common-stack/core';import {BaseServiceCommands}from'common/server';let BaseProxyService2 = class BaseProxyService2 {
|
|
2
2
|
broker;
|
|
3
3
|
constructor(broker, logger) {
|
|
4
4
|
this.broker = broker;
|
|
@@ -49,4 +49,4 @@ BaseProxyService2 = __decorate([
|
|
|
49
49
|
__param(1, inject(CommonType.LOGGER)),
|
|
50
50
|
__param(1, optional()),
|
|
51
51
|
__metadata("design:paramtypes", [ServiceBroker, Object])
|
|
52
|
-
], BaseProxyService2);export{BaseProxyService2};//# sourceMappingURL=
|
|
52
|
+
], BaseProxyService2);export{BaseProxyService2};//# sourceMappingURL=BaseProxyService.js.map
|
|
@@ -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,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,EAAA;AACtC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KAChE;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;KAC9D;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;AACxC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;KACxE;AAED,IAAA,GAAG,CAAC,EAAqC,EAAA;AACrC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,EAAE,EAAE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AAA;qCAFc,aAAa,EAAA,MAAA,CAAA,CAAA;AAPxB,CAAA,EAAA,iBAAiB,CAsEtC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FilterQuery } from 'mongoose';
|
|
2
|
-
import { GetAllArgs, AsDomainType, CreateType, UpdateType } from '
|
|
3
|
-
export
|
|
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>);
|
|
4
6
|
getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{
|
|
5
7
|
data: AsDomainType<SchemaType>[];
|
|
6
8
|
totalCount: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';
|
|
1
|
+
import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';import {IBaseMongoRepository}from'common/server';var _a;
|
|
2
|
+
let BaseService2 = class BaseService2 {
|
|
2
3
|
repository;
|
|
3
4
|
constructor(repository) {
|
|
4
5
|
this.repository = repository;
|
|
@@ -60,5 +61,5 @@ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';let
|
|
|
60
61
|
};
|
|
61
62
|
BaseService2 = __decorate([
|
|
62
63
|
injectable(),
|
|
63
|
-
__metadata("design:paramtypes", [Object])
|
|
64
|
-
], BaseService2);export{BaseService2};//# sourceMappingURL=
|
|
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,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,UAA4C,EAAA;AAC5C,QAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAA6B,CAAC,CAAC;SAC7E;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1C;AAED,IAAA,SAAS,CAAC,IAAY,EAAA;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAS,CAAC,CAAC;KAC/C;AAED,IAAA,MAAM,CAAC,OAA+B,EAAA;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,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U,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,7 +1,8 @@
|
|
|
1
1
|
import { ServiceBroker } from 'moleculer';
|
|
2
2
|
import { FilterQuery } from 'mongoose';
|
|
3
3
|
import { CdmLogger } from '@cdm-logger/core';
|
|
4
|
-
import { GetAllArgs
|
|
4
|
+
import { GetAllArgs } from '../interfaces';
|
|
5
|
+
import { IBaseService } from '../interfaces/index.old';
|
|
5
6
|
type MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;
|
|
6
7
|
type MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;
|
|
7
8
|
export declare abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-proxy-service.js","sources":["../../src/services/base-proxy-service.ts"],"sourcesContent":[
|
|
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 } from '../interfaces';\nimport { IBaseService } from '../interfaces/index.old';\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":"yPAasB,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,CAAC,IAAS,EAAA;AAChB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAqB,mBAAmB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACxF;AAED,IAAA,KAAK,CAAC,QAAgC,EAAA;AAClC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;KACnE;AAED,IAAA,MAAM,CAAC,IAAO,EAAA;AACV,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KAChE;AAED,IAAA,MAAM,CAAC,EAAkC,EAAA;AACrC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;KAC9D;AAED,IAAA,GAAG,CAAC,EAAmC,EAAA;AACnC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;KAC3D;AAED,IAAA,MAAM,CAAC,OAA8B,EAAA;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/D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
-
import { GetAllArgs
|
|
2
|
+
import { GetAllArgs } from '../interfaces';
|
|
3
|
+
import { IBaseRepository, IBaseService } from '../interfaces/index.old';
|
|
3
4
|
export declare class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {
|
|
4
5
|
protected repository: IBaseRepository<T>;
|
|
5
6
|
constructor(repository: IBaseRepository<T>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-service.js","sources":["../../src/services/base-service.ts"],"sourcesContent":[
|
|
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 } from '../interfaces';\nimport { IBaseRepository, IBaseService } from '../interfaces/index.old';\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":"6EAMa,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,UAAU,KAAK,QAAQ,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1C;AAED,IAAA,SAAS,CAAC,IAAY,EAAA;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACxC;AAED,IAAA,MAAM,CAAC,OAAgC,EAAA;QACnC,O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AC,EAAE,CAAC,CAAC;KACrC;EACJ;AAlEY,WAAW,GAAA,UAAA,CAAA;AADvB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,WAAW,CAkEvB"}
|
package/lib/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-options-v2.js","sources":["../../../src/store/models/common-options-v2.ts"],"sourcesContent":[
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-options.js","sources":["../../../src/store/models/common-options.ts"],"sourcesContent":[
|
|
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,11 +1,13 @@
|
|
|
1
1
|
import { CdmLogger } from '@cdm-logger/core';
|
|
2
2
|
import { Connection, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';
|
|
3
|
-
import { GetAllArgs, ISort,
|
|
4
|
-
export declare class
|
|
3
|
+
import { GetAllArgs, ISort, IBaseMongoRepository, IMongoOptions, AsDomainType, CreateType, UpdateType } from 'common/server';
|
|
4
|
+
export declare class BaseMongoRepository<SchemaType> implements IBaseMongoRepository<SchemaType> {
|
|
5
5
|
private modelFunc;
|
|
6
6
|
private options;
|
|
7
7
|
protected logger: CdmLogger.ILogger;
|
|
8
|
-
model: Model<SchemaType
|
|
8
|
+
model: Model<SchemaType & {
|
|
9
|
+
id: string;
|
|
10
|
+
}>;
|
|
9
11
|
constructor(modelFunc: (db: Connection) => Model<SchemaType>, db: Connection, logger: CdmLogger.ILogger, options?: IMongoOptions);
|
|
10
12
|
/**
|
|
11
13
|
* Transforms a document to the domain model format
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'
|
|
2
|
-
|
|
1
|
+
import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {IMongoOptions,PAGINATION_OPTIONS}from'common/server';var BaseMongoRepository_1;
|
|
2
|
+
var _a;
|
|
3
|
+
let BaseMongoRepository = BaseMongoRepository_1 = class BaseMongoRepository {
|
|
3
4
|
modelFunc;
|
|
4
5
|
options;
|
|
5
6
|
logger;
|
|
@@ -8,7 +9,7 @@ let BaseRepository2 = BaseRepository2_1 = class BaseRepository2 {
|
|
|
8
9
|
this.modelFunc = modelFunc;
|
|
9
10
|
this.model = modelFunc(db);
|
|
10
11
|
this.options = options;
|
|
11
|
-
this.logger = logger.child({ className:
|
|
12
|
+
this.logger = logger.child({ className: BaseMongoRepository_1.name });
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Transforms a document to the domain model format
|
|
@@ -356,7 +357,7 @@ let BaseRepository2 = BaseRepository2_1 = class BaseRepository2 {
|
|
|
356
357
|
// Create a query that handles both ObjectId and string IDs
|
|
357
358
|
const query = { _id: { $in: [] } };
|
|
358
359
|
// Process each ID
|
|
359
|
-
ids
|
|
360
|
+
ids?.forEach((id) => {
|
|
360
361
|
if (Types.ObjectId.isValid(id)) {
|
|
361
362
|
query._id.$in.push(new Types.ObjectId(id));
|
|
362
363
|
}
|
|
@@ -364,7 +365,12 @@ let BaseRepository2 = BaseRepository2_1 = class BaseRepository2 {
|
|
|
364
365
|
query._id.$in.push(id); // Add as string
|
|
365
366
|
}
|
|
366
367
|
});
|
|
367
|
-
|
|
368
|
+
let findQuery = this.model.find(query);
|
|
369
|
+
// apply select if selectedFields is provided
|
|
370
|
+
if (selectedFields) {
|
|
371
|
+
findQuery = findQuery.select(selectedFields);
|
|
372
|
+
}
|
|
373
|
+
const results = await findQuery.lean().exec();
|
|
368
374
|
// Ensure id exists for each document
|
|
369
375
|
return results.map((doc) => {
|
|
370
376
|
if (doc._id && !doc.id) {
|
|
@@ -379,11 +385,10 @@ let BaseRepository2 = BaseRepository2_1 = class BaseRepository2 {
|
|
|
379
385
|
}
|
|
380
386
|
}
|
|
381
387
|
};
|
|
382
|
-
|
|
388
|
+
BaseMongoRepository = BaseMongoRepository_1 = __decorate([
|
|
383
389
|
injectable(),
|
|
384
390
|
__param(0, unmanaged()),
|
|
385
|
-
__param(1, unmanaged()),
|
|
386
391
|
__param(2, unmanaged()),
|
|
387
392
|
__param(3, unmanaged()),
|
|
388
|
-
__metadata("design:paramtypes", [Function, Connection, Object, Object])
|
|
389
|
-
],
|
|
393
|
+
__metadata("design:paramtypes", [Function, Connection, Object, typeof (_a = typeof IMongoOptions !== "undefined" && IMongoOptions) === "function" ? _a : Object])
|
|
394
|
+
], BaseMongoRepository);export{BaseMongoRepository};//# sourceMappingURL=BaseMongoRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseMongoRepository.js","sources":["../../../src/store/repositories/BaseMongoRepository.ts"],"sourcesContent":["/* eslint-disable import/no-unresolved */\n/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable no-param-reassign */\n/* eslint-disable no-underscore-dangle */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable class-methods-use-this */\nimport { isObject } from 'lodash-es';\nimport { CdmLogger } from '@cdm-logger/core';\nimport { Connection, FilterQuery, Model, PipelineStage, Types, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport {\n GetAllArgs,\n ISort,\n IBaseMongoRepository,\n IMongoOptions,\n PAGINATION_OPTIONS,\n AsDomainType,\n CreateType,\n UpdateType,\n} from 'common/server';\n\n@injectable()\nexport class BaseMongoRepository<SchemaType> implements IBaseMongoRepository<SchemaType> {\n private options: IMongoOptions;\n\n protected logger: CdmLogger.ILogger;\n\n model: Model<SchemaType & { id: string }>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<SchemaType>,\n\n db: Connection,\n @unmanaged()\n logger: CdmLogger.ILogger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db) as Model<SchemaType & { id: string }>;\n this.options = options;\n this.logger = logger.child({ className: BaseMongoRepository.name });\n }\n\n /**\n * Transforms a document to the domain model format\n */\n protected transformDocument(doc: any): AsDomainType<SchemaType> | null {\n if (!doc) return null;\n\n // If it's already a plain object (not a Mongoose document)\n if (!doc.toObject) {\n // Ensure id exists if _id is present\n if (doc._id && !doc.id) {\n doc.id = typeof doc._id === 'object' && doc._id.toString ? doc._id.toString() : doc._id;\n }\n return doc as unknown as AsDomainType<SchemaType>;\n }\n\n // For Mongoose documents, use the built-in toObject transformation\n return doc.toObject() as AsDomainType<SchemaType>;\n }\n\n /**\n * Transforms an array of documents\n */\n protected transformDocuments(docs: SchemaType[]): AsDomainType<SchemaType>[] {\n if (!docs || !Array.isArray(docs)) return [];\n return docs.map((doc) => this.transformDocument(doc)).filter(Boolean) as AsDomainType<SchemaType>[];\n }\n\n /**\n * Maps API criteria with 'id' to MongoDB criteria with '_id'\n */\n private mapConditions(conditions?: FilterQuery<SchemaType>): FilterQuery<SchemaType> {\n if (!conditions) return {};\n\n const { id, ...remaining } = conditions as any;\n\n if (!id) return remaining as FilterQuery<SchemaType>;\n\n // Handle custom _id that might not be an ObjectId\n let _id;\n if (Types.ObjectId.isValid(id)) {\n _id = new Types.ObjectId(id);\n } else {\n _id = id; // Use the id as-is if it's not a valid ObjectId\n }\n\n return {\n _id,\n ...remaining,\n } as FilterQuery<SchemaType>;\n }\n\n /**\n * Computes sort object from GetAllArgs sort parameter\n * Handles both string-based and object-based sort specifications\n */\n protected computeSort(sort: ISort | string | ISort[]): Record<string, 1 | -1> {\n // Default sort by createdAt descending if available, otherwise empty sort\n if (!sort) {\n return { createdAt: -1 };\n }\n\n // Handle object-based sort { key: 'fieldName', value: 'asc'|'desc' }\n if (isObject(sort) && 'key' in sort) {\n return {\n [sort.key]: sort.value?.toLowerCase() === 'asc' ? 1 : -1,\n };\n }\n\n // Handle string-based sort 'fieldName:asc' or 'fieldName:desc'\n if (typeof sort === 'string') {\n const [field, direction] = sort.split(':');\n if (field) {\n return {\n [field]: direction?.toLowerCase() === 'asc' ? 1 : -1,\n };\n }\n }\n\n // Handle array of sort specifications\n if (Array.isArray(sort)) {\n return sort.reduce((acc, sortItem) => {\n if (isObject(sortItem) && sortItem.key) {\n acc[sortItem.key] = sortItem.value?.toLowerCase() === 'asc' ? 1 : -1;\n }\n return acc;\n }, {});\n }\n\n // Fallback to default sort\n return { createdAt: -1 };\n }\n\n /**\n * Prepares an aggregation pipeline with standard stages\n * @param options Query options including filtering, sorting, pagination\n * @param customPipeline Optional custom pipeline stages to include\n * @returns Complete MongoDB aggregation pipeline\n */\n protected preparePipeline(options: GetAllArgs<SchemaType>, customPipeline: PipelineStage[] = []): PipelineStage[] {\n const { criteria, sort, limit, skip } = options;\n const pipeline: PipelineStage[] = [];\n\n // Match stage (filtering)\n if (criteria) {\n pipeline.push({\n $match: this.mapConditions(criteria),\n });\n }\n\n // Add custom pipeline stages\n if (customPipeline.length > 0) {\n pipeline.push(...customPipeline);\n }\n\n // Sort stage\n const sortBy = this.computeSort(sort);\n if (Object.keys(sortBy).length > 0) {\n pipeline.push({ $sort: sortBy });\n }\n\n // Pagination stages\n if (skip !== undefined) {\n pipeline.push({ $skip: skip || PAGINATION_OPTIONS.skip });\n }\n\n if (limit !== undefined) {\n pipeline.push({ $limit: limit || PAGINATION_OPTIONS.limit });\n }\n\n return pipeline;\n }\n\n /**\n * Execute an aggregation pipeline and transform the results\n */\n protected async aggregate(pipeline: PipelineStage[]): Promise<AsDomainType<SchemaType>[]> {\n try {\n const results = await this.model.aggregate(pipeline).exec();\n return this.transformDocuments(results);\n } catch (e) {\n this.logger.error(e, 'Error executing aggregation pipeline: %j', pipeline);\n throw e;\n }\n }\n\n public async count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.model.count(this.mapConditions(conditions)).exec();\n }\n\n public async get(\n conditions?: FilterQuery<SchemaType>,\n selectedFields?: string,\n ): Promise<AsDomainType<SchemaType> | null> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).lean().exec();\n\n if (!response) return null;\n\n // Ensure id exists\n if (response && (response as any)._id && !(response as any).id) {\n (response as any).id = (response as any)._id.toString();\n }\n\n return response as AsDomainType<SchemaType>;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async find(\n conditions: Partial<FilterQuery<SchemaType>>,\n selectedFields?: string,\n ): Promise<AsDomainType<SchemaType> | null> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).lean().exec();\n\n if (!response) return null;\n\n // Ensure id exists\n if (response && (response as any)._id && !(response as any).id) {\n (response as any).id = (response as any)._id.toString();\n }\n\n return response as AsDomainType<SchemaType>;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n const mappedCriteria = this.mapConditions(criteria);\n const sortBy = this.computeSort(sort);\n\n const response = await this.model\n .find(mappedCriteria, selectedFields)\n .sort(sortBy as any)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .lean()\n .exec();\n\n // Ensure id exists for each document\n return response.map((doc) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);\n throw e;\n }\n }\n\n /**\n * Get all documents using aggregation pipeline\n */\n public async getAllWithPipeline(\n options: GetAllArgs<SchemaType>,\n customPipeline: PipelineStage[] = [],\n ): Promise<AsDomainType<SchemaType>[]> {\n try {\n const pipeline = this.preparePipeline(options, customPipeline);\n return this.aggregate(pipeline);\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with pipeline [%j]', customPipeline);\n throw e;\n }\n }\n\n public async getAllWithCount(options: GetAllArgs<SchemaType>): Promise<{\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n }> {\n const data = await this.getAll(options);\n const totalCount = await this.count(options.criteria);\n return { totalCount, data };\n }\n\n /**\n * Get all documents with count using aggregation pipeline\n */\n public async getAllWithCountAndPipeline(\n options: GetAllArgs<SchemaType>,\n customPipeline: PipelineStage[] = [],\n ): Promise<{\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n }> {\n // Clone options to avoid modifying the original\n const countOptions = { ...options };\n\n // Remove pagination for count\n delete countOptions.limit;\n delete countOptions.skip;\n\n // Prepare count pipeline (without pagination)\n const countPipeline = this.preparePipeline(countOptions, customPipeline);\n countPipeline.push({ $count: 'total' });\n\n // Execute both queries in parallel\n const [data, countResult] = await Promise.all([\n this.getAllWithPipeline(options, customPipeline),\n this.model.aggregate(countPipeline).exec(),\n ]);\n\n const totalCount = countResult?.[0]?.total || 0;\n return { data, totalCount };\n }\n\n public async create<T = CreateType<SchemaType>>(data: T): Promise<AsDomainType<SchemaType>> {\n try {\n // Handle custom _id if provided in the data\n const createData = { ...data } as any;\n\n // If id is provided but _id is not, map id to _id\n if (createData.id && !createData._id) {\n createData._id = Types.ObjectId.isValid(createData.id)\n ? new Types.ObjectId(createData.id)\n : createData.id;\n delete createData.id; // Remove id to avoid conflicts\n }\n\n const response = await this.model.create(createData);\n return this.transformDocument(response);\n } catch (e) {\n this.logger.error(e, 'Unable to create Model with data [%j]', data);\n throw e;\n }\n }\n\n public async bulkCreate<T = CreateType<SchemaType>>(data: T[]): Promise<AsDomainType<SchemaType>[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n\n // Ensure id exists for each document\n return response.map((doc: any) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);\n throw e;\n }\n }\n\n public async upsert<T = UpdateType<SchemaType>>(\n conditions: FilterQuery<SchemaType>,\n update: T,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>> {\n return this.update(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async update<T = UpdateType<SchemaType>>(\n criteria: FilterQuery<SchemaType>,\n update: T | UpdateQuery<SchemaType>,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n\n const { id } = criteria as any;\n let response;\n\n if (id) {\n response = await this.model.findByIdAndUpdate(id, update as any, mergedOptions).exec();\n } else {\n response = await this.model.findOneAndUpdate(mappedCriteria, update as any, mergedOptions).exec();\n }\n\n return this.transformDocument(response);\n } catch (e) {\n this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async bulkUpdate<T = UpdateType<SchemaType>>(\n criteria: FilterQuery<SchemaType>,\n update: T | UpdateQuery<SchemaType>,\n options: Record<string, unknown> = {},\n ): Promise<AsDomainType<SchemaType>[]> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n await this.model.updateMany(mappedCriteria, update as any, options);\n\n // Fetch the updated documents\n const response = await this.model.find(mappedCriteria).lean().exec();\n\n // Ensure id exists for each document\n return response.map((doc) => {\n if (doc._id && !doc.id) {\n doc.id = doc._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<SchemaType>): Promise<boolean> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n let deleted;\n\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(mappedCriteria);\n }\n\n return !!deleted;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n try {\n const mappedCriteria = this.mapConditions(criteria);\n const deleted = await this.model.deleteMany(mappedCriteria);\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[], selectedFields?: string): Promise<AsDomainType<SchemaType>[]> {\n try {\n // Create a query that handles both ObjectId and string IDs\n const query: any = { _id: { $in: [] } };\n\n // Process each ID\n ids?.forEach((id) => {\n if (Types.ObjectId.isValid(id)) {\n query._id.$in.push(new Types.ObjectId(id));\n } else {\n query._id.$in.push(id); // Add as string\n }\n });\n\n let findQuery = this.model.find(query);\n\n // apply select if selectedFields is provided\n if (selectedFields) {\n findQuery = findQuery.select(selectedFields);\n }\n\n const results = await findQuery.lean().exec();\n\n // Ensure id exists for each document\n return results.map((doc) => {\n if ((doc as any)._id && !(doc as any).id) {\n (doc as any).id = (doc as any)._id.toString();\n }\n return doc as AsDomainType<SchemaType>;\n });\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);\n throw e;\n }\n }\n}\n"],"names":[],"mappings":";;AAsBa,IAAA,mBAAmB,GAAzB,qBAAA,GAAA,MAAM,mBAAmB,CAAA;AAShB,IAAA,SAAA,CAAA;AARJ,IAAA,OAAO,CAAgB;AAErB,IAAA,MAAM,CAAoB;AAEpC,IAAA,KAAK,CAAqC;AAE1C,IAAA,WAAA,CAEY,SAAgD,EAExD,EAAc,EAEd,MAAyB,EAEzB,OAAuB,EAAA;QANf,IAAS,CAAA,SAAA,GAAT,SAAS,CAAuC;AAQxD,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,CAAuC,CAAC;AACjE,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAA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AAA,UAAA,CAAA;AAD/B,IAAA,UAAU,EAAE;IASJ,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAIX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;+CAHR,UAAU,EAAA,MAAA,EAAA,QAAA,EAAA,GAAA,OAIJ,aAAa,KAAA,WAAA,IAAb,aAAa,CAAA,KAAA,UAAA,GAAA,EAAA,GAAA,MAAA,CAAA,CAAA;AAflB,CAAA,EAAA,mBAAmB,CAkd/B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CdmLogger } from '@cdm-logger/core';
|
|
2
2
|
import { Connection, Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';
|
|
3
|
-
import { GetAllArgs,
|
|
3
|
+
import { GetAllArgs, IMongoOptions } from '../../interfaces';
|
|
4
|
+
import { IBaseRepository } from 'src/interfaces/index.old';
|
|
4
5
|
export declare class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {
|
|
5
6
|
private modelFunc;
|
|
6
7
|
private options;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'../../interfaces/
|
|
1
|
+
import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import'@cdm-logger/core';import {Connection,Types}from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'../../interfaces/getAllArgs.js';var BaseRepository_1;
|
|
2
2
|
let BaseRepository = BaseRepository_1 = class BaseRepository {
|
|
3
3
|
modelFunc;
|
|
4
4
|
options;
|