@lenne.tech/nest-server 8.6.1 → 8.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/common/decorators/restricted.decorator.js +2 -1
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/models/core-model.model.js +2 -4
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/services/module.service.js +1 -1
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +3 -2
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/server/modules/user/user.service.js +1 -1
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/core/common/decorators/restricted.decorator.ts +1 -1
- package/src/core/common/models/core-model.model.ts +2 -12
- package/src/core/common/services/module.service.ts +1 -1
- package/src/core/modules/user/inputs/core-user.input.ts +3 -2
- package/src/server/modules/user/user.service.ts +1 -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.4",
|
|
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",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "NODE_ENV=local jest",
|
|
33
33
|
"test:cov": "NODE_ENV=local jest --coverage",
|
|
34
34
|
"test:debug": "NODE_ENV=local node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
35
|
-
"test:e2e": "NODE_ENV=local jest --config jest-e2e.json",
|
|
36
|
-
"test:e2e-cov": "NODE_ENV=local jest --config jest-e2e.json --coverage",
|
|
37
|
-
"test:ci": "NODE_ENV=local jest --config jest-e2e.json --ci",
|
|
35
|
+
"test:e2e": "NODE_ENV=local jest --config jest-e2e.json --forceExit --detectOpenHandles",
|
|
36
|
+
"test:e2e-cov": "NODE_ENV=local jest --config jest-e2e.json --coverage --forceExit --detectOpenHandles",
|
|
37
|
+
"test:ci": "NODE_ENV=local jest --config jest-e2e.json --ci --forceExit --detectOpenHandles",
|
|
38
38
|
"test:watch": "NODE_ENV=local jest --watch",
|
|
39
39
|
"prepack": "npm run prestart:prod",
|
|
40
40
|
"prepare": "husky install",
|
|
@@ -134,7 +134,7 @@ export const checkRestricted = (
|
|
|
134
134
|
return (
|
|
135
135
|
typeof item === 'object' &&
|
|
136
136
|
// Check if object is valid
|
|
137
|
-
item.memberOf
|
|
137
|
+
item.memberOf?.length &&
|
|
138
138
|
// Check if processType is specified and is valid for current process
|
|
139
139
|
(config.processType && item.processType ? config.processType === item.processType : true)
|
|
140
140
|
);
|
|
@@ -34,14 +34,9 @@ export abstract class CoreModel {
|
|
|
34
34
|
mapId?: boolean;
|
|
35
35
|
} = {}
|
|
36
36
|
): T {
|
|
37
|
-
const config = {
|
|
38
|
-
init: true,
|
|
39
|
-
...options,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
37
|
const item = options.item || new this();
|
|
43
38
|
delete options.item;
|
|
44
|
-
return item.map(data,
|
|
39
|
+
return item.map(data, options);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
/**
|
|
@@ -64,14 +59,9 @@ export abstract class CoreModel {
|
|
|
64
59
|
mapId?: boolean;
|
|
65
60
|
} = {}
|
|
66
61
|
): T {
|
|
67
|
-
const config = {
|
|
68
|
-
init: true,
|
|
69
|
-
...options,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
62
|
const item = options.item || new this();
|
|
73
63
|
delete options.item;
|
|
74
|
-
return item.mapDeep(data,
|
|
64
|
+
return item.mapDeep(data, options);
|
|
75
65
|
}
|
|
76
66
|
|
|
77
67
|
/**
|
|
@@ -88,7 +88,7 @@ export abstract class ModuleService<T extends CoreModel = any> {
|
|
|
88
88
|
if (!opts.targetModel && config.inputType) {
|
|
89
89
|
opts.targetModel = config.inputType;
|
|
90
90
|
}
|
|
91
|
-
await this.prepareInput(config.input, opts);
|
|
91
|
+
config.input = await this.prepareInput(config.input, opts);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// Get DB object
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IsEmail, IsOptional } from 'class-validator';
|
|
2
1
|
import { Field, InputType } from '@nestjs/graphql';
|
|
2
|
+
import { IsEmail, IsOptional } from 'class-validator';
|
|
3
3
|
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
4
|
+
import { ProcessType } from '../../../common/enums/process-type.enum';
|
|
4
5
|
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
5
6
|
import { CoreInput } from '../../../common/inputs/core-input.input';
|
|
6
7
|
|
|
@@ -38,7 +39,7 @@ export abstract class CoreUserInput extends CoreInput {
|
|
|
38
39
|
/**
|
|
39
40
|
* Roles of the user
|
|
40
41
|
*/
|
|
41
|
-
@Restricted(RoleEnum.ADMIN)
|
|
42
|
+
@Restricted({ roles: RoleEnum.ADMIN, processType: ProcessType.INPUT })
|
|
42
43
|
@Field((type) => [String], { description: 'Roles of the user', nullable: true })
|
|
43
44
|
@IsOptional()
|
|
44
45
|
roles?: string[] = undefined;
|
|
@@ -50,7 +50,7 @@ export class UserService extends CoreUserService<User, UserInput, UserCreateInpu
|
|
|
50
50
|
// and could not exist as currentUser before
|
|
51
51
|
if (!user.createdBy) {
|
|
52
52
|
await this.mainDbModel.findByIdAndUpdate(user.id, { createdBy: user.id });
|
|
53
|
-
user = await this.get(user.id, { ...serviceOptions, currentUser: serviceOptions
|
|
53
|
+
user = await this.get(user.id, { ...serviceOptions, currentUser: serviceOptions?.currentUser || user });
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Publish action
|