@lenne.tech/nest-server 8.6.20 → 8.6.21
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/dist/core/common/helpers/model.helper.js +16 -12
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/services/module.service.js +4 -1
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/common/helpers/model.helper.ts +14 -14
- package/src/core/common/services/module.service.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.21",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -186,13 +186,12 @@ export function mapClasses<T = Record<string, any>>(
|
|
|
186
186
|
for (const item of value) {
|
|
187
187
|
if (value instanceof targetClass) {
|
|
188
188
|
arr.push(value);
|
|
189
|
-
}
|
|
190
|
-
if (value instanceof Types.ObjectId) {
|
|
189
|
+
} else if (value instanceof Types.ObjectId) {
|
|
191
190
|
arr.push(value);
|
|
192
191
|
} else if (typeof value === 'object') {
|
|
193
192
|
if (targetClass.map) {
|
|
194
193
|
arr.push(targetClass.map(item));
|
|
195
|
-
} else
|
|
194
|
+
} else {
|
|
196
195
|
arr.push(plainToInstance(targetClass, item));
|
|
197
196
|
}
|
|
198
197
|
} else {
|
|
@@ -211,11 +210,12 @@ export function mapClasses<T = Record<string, any>>(
|
|
|
211
210
|
else if (typeof value === 'object') {
|
|
212
211
|
if (value instanceof targetClass) {
|
|
213
212
|
target[prop] = value as any;
|
|
214
|
-
}
|
|
215
|
-
if (targetClass.map) {
|
|
216
|
-
target[prop] = targetClass.map(value);
|
|
217
213
|
} else {
|
|
218
|
-
|
|
214
|
+
if (targetClass.map) {
|
|
215
|
+
target[prop] = targetClass.map(value);
|
|
216
|
+
} else {
|
|
217
|
+
target[prop] = plainToInstance(targetClass, value) as any;
|
|
218
|
+
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
@@ -262,13 +262,12 @@ export async function mapClassesAsync<T = Record<string, any>>(
|
|
|
262
262
|
for (const item of value) {
|
|
263
263
|
if (value instanceof targetClass) {
|
|
264
264
|
arr.push(value);
|
|
265
|
-
}
|
|
266
|
-
if (value instanceof Types.ObjectId) {
|
|
265
|
+
} else if (value instanceof Types.ObjectId) {
|
|
267
266
|
arr.push(value);
|
|
268
267
|
} else if (typeof value === 'object') {
|
|
269
268
|
if (targetClass.map) {
|
|
270
269
|
arr.push(await targetClass.map(item));
|
|
271
|
-
} else
|
|
270
|
+
} else {
|
|
272
271
|
arr.push(plainToInstance(targetClass, item));
|
|
273
272
|
}
|
|
274
273
|
} else {
|
|
@@ -287,11 +286,12 @@ export async function mapClassesAsync<T = Record<string, any>>(
|
|
|
287
286
|
else if (typeof value === 'object') {
|
|
288
287
|
if (value instanceof targetClass) {
|
|
289
288
|
target[prop] = value as any;
|
|
290
|
-
}
|
|
291
|
-
if (targetClass.map) {
|
|
292
|
-
target[prop] = await targetClass.map(value);
|
|
293
289
|
} else {
|
|
294
|
-
|
|
290
|
+
if (targetClass.map) {
|
|
291
|
+
target[prop] = await targetClass.map(value);
|
|
292
|
+
} else {
|
|
293
|
+
target[prop] = plainToInstance(targetClass, value) as any;
|
|
294
|
+
}
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
@@ -107,6 +107,11 @@ export abstract class ModuleService<T extends CoreModel = any> {
|
|
|
107
107
|
config.input = await this.prepareInput(config.input, opts);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// Check rights
|
|
111
|
+
if (config.checkRights && this.checkRights) {
|
|
112
|
+
await this.checkRights(undefined, config.currentUser as any, config);
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
// Get DB object
|
|
111
116
|
if (config.dbObject && config.checkRights && this.checkRights) {
|
|
112
117
|
if (typeof config.dbObject === 'string' || config.dbObject instanceof Types.ObjectId) {
|
|
@@ -144,7 +149,7 @@ export abstract class ModuleService<T extends CoreModel = any> {
|
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
// Check output rights
|
|
147
|
-
if (config.checkRights && this.checkRights) {
|
|
152
|
+
if (config.checkRights && (await this.checkRights(undefined, config.currentUser as any, config))) {
|
|
148
153
|
const opts: any = {
|
|
149
154
|
dbObject: config.dbObject,
|
|
150
155
|
processType: ProcessType.OUTPUT,
|