@lenne.tech/nest-server 8.0.2 → 8.3.0
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/config.env.js +3 -2
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/args/pagination.args.js +1 -1
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/restricted.decorator.d.ts +3 -0
- package/dist/core/common/decorators/restricted.decorator.js +14 -8
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/enums/role.enum.d.ts +3 -2
- package/dist/core/common/enums/role.enum.js +3 -2
- package/dist/core/common/enums/role.enum.js.map +1 -1
- package/dist/core/common/helpers/config.helper.d.ts +2 -1
- package/dist/core/common/helpers/config.helper.js +11 -7
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/helpers/context.helper.d.ts +7 -1
- package/dist/core/common/helpers/context.helper.js +33 -29
- package/dist/core/common/helpers/context.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.d.ts +37 -0
- package/dist/core/common/helpers/db.helper.js +356 -0
- package/dist/core/common/helpers/db.helper.js.map +1 -0
- package/dist/core/common/helpers/file.helper.d.ts +8 -1
- package/dist/core/common/helpers/file.helper.js +43 -31
- package/dist/core/common/helpers/file.helper.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.d.ts +3 -0
- package/dist/core/common/helpers/filter.helper.js +93 -81
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.d.ts +24 -1
- package/dist/core/common/helpers/graphql.helper.js +144 -96
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.d.ts +42 -4
- package/dist/core/common/helpers/input.helper.js +256 -97
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/model.helper.d.ts +11 -0
- package/dist/core/common/helpers/model.helper.js +41 -29
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.d.ts +21 -1
- package/dist/core/common/helpers/service.helper.js +80 -72
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +1 -1
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/core-input.input.js +1 -1
- package/dist/core/common/inputs/core-input.input.js.map +1 -1
- package/dist/core/common/interceptors/check-response.interceptor.js +1 -1
- package/dist/core/common/interceptors/check-response.interceptor.js.map +1 -1
- package/dist/core/common/interfaces/resolve-selector.interface.d.ts +5 -0
- package/dist/core/common/interfaces/resolve-selector.interface.js +3 -0
- package/dist/core/common/interfaces/resolve-selector.interface.js.map +1 -0
- package/dist/core/common/interfaces/service-options.interface.d.ts +36 -0
- package/dist/core/common/interfaces/service-options.interface.js +3 -0
- package/dist/core/common/interfaces/service-options.interface.js.map +1 -0
- package/dist/core/common/models/core-model.model.d.ts +5 -1
- package/dist/core/common/models/core-model.model.js +1 -1
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/pipes/check-input.pipe.js +2 -2
- package/dist/core/common/pipes/check-input.pipe.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/core/common/services/crud.service.d.ts +13 -0
- package/dist/core/common/services/crud.service.js +57 -0
- package/dist/core/common/services/crud.service.js.map +1 -0
- package/dist/core/common/services/email.service.js +8 -8
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/module.service.d.ts +40 -0
- package/dist/core/common/services/module.service.js +80 -0
- package/dist/core/common/services/module.service.js.map +1 -0
- package/dist/core/common/types/core-model-constructor.type.d.ts +21 -0
- package/dist/core/common/types/core-model-constructor.type.js +3 -0
- package/dist/core/common/types/core-model-constructor.type.js.map +1 -0
- package/dist/core/common/types/field-selection.type.d.ts +4 -0
- package/dist/core/common/types/field-selection.type.js +3 -0
- package/dist/core/common/types/field-selection.type.js.map +1 -0
- package/dist/core/common/types/ids.type.d.ts +8 -0
- package/dist/core/common/types/ids.type.js +3 -0
- package/dist/core/common/types/ids.type.js.map +1 -0
- package/dist/core/common/types/string-or-object-id.type.d.ts +2 -0
- package/dist/core/common/types/string-or-object-id.type.js +3 -0
- package/dist/core/common/types/string-or-object-id.type.js.map +1 -0
- package/dist/core/modules/auth/core-auth.resolver.d.ts +2 -1
- package/dist/core/modules/auth/core-auth.resolver.js +4 -3
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js +1 -2
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth-user.service.d.ts +3 -1
- package/dist/core/modules/auth/services/core-auth-user.service.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth.service.d.ts +2 -1
- package/dist/core/modules/auth/services/core-auth.service.js +6 -4
- package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
- package/dist/core/modules/user/core-user.model.js +1 -1
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.d.ts +16 -25
- package/dist/core/modules/user/core-user.service.js +69 -90
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core.module.js +1 -1
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/server/modules/auth/auth.resolver.d.ts +2 -1
- package/dist/server/modules/auth/auth.resolver.js +4 -3
- package/dist/server/modules/auth/auth.resolver.js.map +1 -1
- package/dist/server/modules/file/file.controller.js +1 -1
- package/dist/server/modules/file/file.controller.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +2 -2
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/user.model.d.ts +2 -1
- package/dist/server/modules/user/user.module.js +7 -3
- package/dist/server/modules/user/user.module.js.map +1 -1
- package/dist/server/modules/user/user.resolver.d.ts +8 -7
- package/dist/server/modules/user/user.resolver.js +85 -49
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.d.ts +9 -18
- package/dist/server/modules/user/user.service.js +23 -30
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/test/test.helper.d.ts +1 -2
- package/dist/test/test.helper.js +1 -16
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +58 -59
- package/src/config.env.ts +3 -2
- package/src/core/common/args/pagination.args.ts +2 -2
- package/src/core/common/decorators/restricted.decorator.ts +24 -12
- package/src/core/common/enums/role.enum.ts +23 -5
- package/src/core/common/helpers/config.helper.ts +26 -6
- package/src/core/common/helpers/context.helper.ts +42 -33
- package/src/core/common/helpers/db.helper.ts +595 -0
- package/src/core/common/helpers/file.helper.ts +76 -49
- package/src/core/common/helpers/filter.helper.ts +119 -96
- package/src/core/common/helpers/graphql.helper.ts +219 -117
- package/src/core/common/helpers/input.helper.ts +349 -108
- package/src/core/common/helpers/model.helper.ts +102 -57
- package/src/core/common/helpers/service.helper.ts +149 -117
- package/src/core/common/inputs/combined-filter.input.ts +2 -2
- package/src/core/common/inputs/core-input.input.ts +2 -2
- package/src/core/common/interceptors/check-response.interceptor.ts +2 -2
- package/src/core/common/interfaces/resolve-selector.interface.ts +9 -0
- package/src/core/common/interfaces/service-options.interface.ts +71 -0
- package/src/core/common/models/core-model.model.ts +7 -3
- package/src/core/common/pipes/check-input.pipe.ts +4 -4
- package/src/core/common/pipes/map-and-validate.pipe.ts +2 -2
- package/src/core/common/services/crud.service.ts +100 -0
- package/src/core/common/services/email.service.ts +9 -9
- package/src/core/common/services/module.service.ts +188 -0
- package/src/core/common/types/core-model-constructor.type.ts +30 -0
- package/src/core/common/types/field-selection.type.ts +8 -0
- package/src/core/common/types/ids.type.ts +7 -0
- package/src/core/common/types/string-or-object-id.type.ts +3 -0
- package/src/core/modules/auth/core-auth.module.ts +1 -1
- package/src/core/modules/auth/core-auth.resolver.ts +8 -3
- package/src/core/modules/auth/guards/roles.guard.ts +5 -7
- package/src/core/modules/auth/services/core-auth-user.service.ts +7 -1
- package/src/core/modules/auth/services/core-auth.service.ts +14 -4
- package/src/core/modules/user/core-user.model.ts +2 -1
- package/src/core/modules/user/core-user.service.ts +115 -185
- package/src/core.module.ts +2 -2
- package/src/index.ts +9 -1
- package/src/main.ts +1 -1
- package/src/server/modules/auth/auth.resolver.ts +8 -3
- package/src/server/modules/file/file.controller.ts +2 -2
- package/src/server/modules/user/avatar.controller.ts +3 -3
- package/src/server/modules/user/user.module.ts +7 -3
- package/src/server/modules/user/user.resolver.ts +74 -43
- package/src/server/modules/user/user.service.ts +30 -53
- package/src/test/test.helper.ts +31 -30
- package/dist/core/modules/user/core-basic-user.service.d.ts +0 -17
- package/dist/core/modules/user/core-basic-user.service.js +0 -73
- package/dist/core/modules/user/core-basic-user.service.js.map +0 -1
- package/src/core/modules/user/core-basic-user.service.ts +0 -138
|
@@ -1,91 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.prepareOutput = exports.prepareInput = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const bcrypt = require("bcrypt");
|
|
6
6
|
const _ = require("lodash");
|
|
7
7
|
const role_enum_1 = require("../enums/role.enum");
|
|
8
8
|
class ServiceHelper {
|
|
9
9
|
static async prepareInput(input, currentUser, options = {}) {
|
|
10
|
-
|
|
11
|
-
if (typeof input !== 'object') {
|
|
12
|
-
return input;
|
|
13
|
-
}
|
|
14
|
-
if (Array.isArray(input)) {
|
|
15
|
-
const processedArray = input.map(async (item) => await ServiceHelper.prepareInput(item, currentUser, options));
|
|
16
|
-
return config.getNewArray ? processedArray : input;
|
|
17
|
-
}
|
|
18
|
-
if (config.clone) {
|
|
19
|
-
if (input.mapDeep && typeof input.mapDeep === 'function') {
|
|
20
|
-
input = await Object.getPrototypeOf(input).mapDeep(input);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
input = _.cloneDeep(input);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (config.removeUndefined) {
|
|
27
|
-
Object.keys(input).forEach((key) => input[key] === undefined && delete input[key]);
|
|
28
|
-
}
|
|
29
|
-
if (config.checkRoles &&
|
|
30
|
-
input.roles &&
|
|
31
|
-
(!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.hasRole) || !currentUser.hasRole(role_enum_1.RoleEnum.ADMIN))) {
|
|
32
|
-
if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.roles)) {
|
|
33
|
-
throw new common_1.UnauthorizedException('Missing roles of current user');
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const allowedRoles = _.intersection(input.roles, currentUser.roles);
|
|
37
|
-
if (allowedRoles.length !== input.roles.length) {
|
|
38
|
-
const missingRoles = _.difference(input.roles, currentUser.roles);
|
|
39
|
-
throw new common_1.UnauthorizedException('Current user not allowed setting roles: ' + missingRoles);
|
|
40
|
-
}
|
|
41
|
-
input.roles = allowedRoles;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (input.password) {
|
|
45
|
-
input.password = await bcrypt.hash(input.password, 10);
|
|
46
|
-
}
|
|
47
|
-
if (config.create && currentUser) {
|
|
48
|
-
input.createdBy = currentUser.id;
|
|
49
|
-
}
|
|
50
|
-
if (currentUser) {
|
|
51
|
-
input.updatedBy = currentUser.id;
|
|
52
|
-
}
|
|
53
|
-
return input;
|
|
10
|
+
return prepareInput(input, currentUser, options);
|
|
54
11
|
}
|
|
55
12
|
static async prepareOutput(output, options = {}) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
13
|
+
return prepareOutput(output, options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = ServiceHelper;
|
|
17
|
+
async function prepareInput(input, currentUser, options = {}) {
|
|
18
|
+
const config = Object.assign({ checkRoles: false, clone: false, create: false, getNewArray: false, removeUndefined: false }, options);
|
|
19
|
+
if (typeof input !== 'object') {
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(input)) {
|
|
23
|
+
const processedArray = input.map(async (item) => await prepareInput(item, currentUser, options));
|
|
24
|
+
return config.getNewArray ? processedArray : input;
|
|
25
|
+
}
|
|
26
|
+
if (config.clone) {
|
|
27
|
+
if (input.mapDeep && typeof input.mapDeep === 'function') {
|
|
28
|
+
input = await Object.getPrototypeOf(input).mapDeep(input);
|
|
59
29
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return config.getNewArray ? processedArray : output;
|
|
30
|
+
else {
|
|
31
|
+
input = _.cloneDeep(input);
|
|
63
32
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
}
|
|
34
|
+
if (config.removeUndefined) {
|
|
35
|
+
Object.keys(input).forEach((key) => input[key] === undefined && delete input[key]);
|
|
36
|
+
}
|
|
37
|
+
if (config.checkRoles &&
|
|
38
|
+
input.roles &&
|
|
39
|
+
(!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.hasRole) || !currentUser.hasRole(role_enum_1.RoleEnum.ADMIN))) {
|
|
40
|
+
if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.roles)) {
|
|
41
|
+
throw new common_1.UnauthorizedException('Missing roles of current user');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const allowedRoles = _.intersection(input.roles, currentUser.roles);
|
|
45
|
+
if (allowedRoles.length !== input.roles.length) {
|
|
46
|
+
const missingRoles = _.difference(input.roles, currentUser.roles);
|
|
47
|
+
throw new common_1.UnauthorizedException('Current user not allowed setting roles: ' + missingRoles);
|
|
70
48
|
}
|
|
49
|
+
input.roles = allowedRoles;
|
|
71
50
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
51
|
+
}
|
|
52
|
+
if (input.password) {
|
|
53
|
+
input.password = await bcrypt.hash(input.password, 10);
|
|
54
|
+
}
|
|
55
|
+
if (config.create && currentUser) {
|
|
56
|
+
input.createdBy = currentUser.id;
|
|
57
|
+
}
|
|
58
|
+
if (currentUser) {
|
|
59
|
+
input.updatedBy = currentUser.id;
|
|
60
|
+
}
|
|
61
|
+
return input;
|
|
62
|
+
}
|
|
63
|
+
exports.prepareInput = prepareInput;
|
|
64
|
+
async function prepareOutput(output, options = {}) {
|
|
65
|
+
const config = Object.assign({ clone: false, getNewArray: false, removeUndefined: false, targetModel: undefined }, options);
|
|
66
|
+
if (typeof output !== 'object') {
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(output)) {
|
|
70
|
+
const processedArray = output.map(async (item) => await prepareOutput(item, options));
|
|
71
|
+
return config.getNewArray ? processedArray : output;
|
|
72
|
+
}
|
|
73
|
+
if (config.clone) {
|
|
74
|
+
if (output.mapDeep && typeof output.mapDeep === 'function') {
|
|
75
|
+
output = await Object.getPrototypeOf(output).mapDeep(output);
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
else {
|
|
78
|
+
output = _.cloneDeep(output);
|
|
86
79
|
}
|
|
87
|
-
return output;
|
|
88
80
|
}
|
|
81
|
+
if (config.targetModel) {
|
|
82
|
+
output = await config.targetModel.map(output);
|
|
83
|
+
}
|
|
84
|
+
if (output.password) {
|
|
85
|
+
output.password = undefined;
|
|
86
|
+
}
|
|
87
|
+
if (output.verificationToken) {
|
|
88
|
+
output.verificationToken = undefined;
|
|
89
|
+
}
|
|
90
|
+
if (output.passwordResetToken) {
|
|
91
|
+
output.passwordResetToken = undefined;
|
|
92
|
+
}
|
|
93
|
+
if (config.removeUndefined) {
|
|
94
|
+
Object.keys(output).forEach((key) => output[key] === undefined && delete output[key]);
|
|
95
|
+
}
|
|
96
|
+
return output;
|
|
89
97
|
}
|
|
90
|
-
exports.
|
|
98
|
+
exports.prepareOutput = prepareOutput;
|
|
91
99
|
//# sourceMappingURL=service.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/service.helper.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,iCAAiC;AACjC,4BAA4B;AAC5B,kDAA8C;
|
|
1
|
+
{"version":3,"file":"service.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/service.helper.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,iCAAiC;AACjC,4BAA4B;AAC5B,kDAA8C;AAM9C,MAAqB,aAAa;IAIhC,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,KAAQ,EACR,WAA+C,EAC/C,UAMI,EAAE;QAEN,OAAO,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAKD,MAAM,CAAC,KAAK,CAAC,aAAa,CACxB,MAAW,EACX,UAMI,EAAE;QAEN,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF;AAjCD,gCAiCC;AAKM,KAAK,UAAU,YAAY,CAChC,KAAQ,EACR,WAA+C,EAC/C,UAMI,EAAE;IAGN,MAAM,MAAM,mBACV,UAAU,EAAE,KAAK,EACjB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,KAAK,EAClB,eAAe,EAAE,KAAK,IACnB,OAAO,CACX,CAAC;IAGF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IAGD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE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O,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE;YAC1D,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC9D;aAAM;YACL,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;SAC9B;KACF;IAGD,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,MAAM,GAAG,MAAO,MAAM,CAAC,WAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACxD;IAGD,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;KAC7B;IAGD,IAAI,MAAM,CAAC,iBAAiB,EAAE;QAC5B,MAAM,CAAC,iBAAiB,GAAG,SAAS,CAAC;KACtC;IAGD,IAAI,MAAM,CAAC,kBAAkB,EAAE;QAC7B,MAAM,CAAC,kBAAkB,GAAG,SAAS,CAAC;KACvC;IAGD,IAAI,MAAM,CAAC,eAAe,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;KACvF;IAGD,OAAO,MAAM,CAAC;AAChB,CAAC;AAlED,sCAkEC"}
|
|
@@ -23,7 +23,7 @@ let CombinedFilterInput = class CombinedFilterInput extends core_input_input_1.C
|
|
|
23
23
|
}
|
|
24
24
|
map(data, options = {}) {
|
|
25
25
|
super.map(data, options);
|
|
26
|
-
this.filters = model_helper_1.
|
|
26
|
+
this.filters = (0, model_helper_1.maps)(data.filters, filter_input_1.FilterInput, options.cloneDeep);
|
|
27
27
|
Object.keys(this).forEach((key) => this[key] === undefined && delete this[key]);
|
|
28
28
|
return this;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combined-filter.input.js","sourceRoot":"","sources":["../../../../src/core/common/inputs/combined-filter.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AACnD,0EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"combined-filter.input.js","sourceRoot":"","sources":["../../../../src/core/common/inputs/combined-filter.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AACnD,0EAAqE;AACrE,0DAA+C;AAC/C,yDAA+C;AAC/C,iDAA6C;AAK7C,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,4BAAS;IAAlD;;QAOE,oBAAe,GAAwB,SAAS,CAAC;QAQjD,YAAO,GAAkB,SAAS,CAAC;IAsBrC,CAAC;IAbC,GAAG,CACD,IAAyC,EACzC,UAII,EAAE;QAEN,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAI,EAAC,IAAI,CAAC,OAAO,EAAE,0BAAW,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAClE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA9BC;IAHC,IAAA,eAAK,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,2CAAmB,EAAE;QACpC,WAAW,EAAE,qCAAqC;KACnD,CAAC;;4DAC+C;AAQjD;IAHC,IAAA,eAAK,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,0BAAW,CAAC,EAAE;QAC9B,WAAW,EAAE,yCAAyC;KACvD,CAAC;;oDACiC;AAfxB,mBAAmB;IAH/B,IAAA,mBAAS,EAAC;QACT,WAAW,EAAE,sDAAsD;KACpE,CAAC;GACW,mBAAmB,CAqC/B;AArCY,kDAAmB"}
|
|
@@ -6,7 +6,7 @@ const core_model_model_1 = require("../models/core-model.model");
|
|
|
6
6
|
class CoreInput extends core_model_model_1.CoreModel {
|
|
7
7
|
map(data, options = {}) {
|
|
8
8
|
const config = Object.assign({ cloneDeep: false, funcAllowed: false, mapId: false }, options);
|
|
9
|
-
const coreInput = model_helper_1.
|
|
9
|
+
const coreInput = (0, model_helper_1.map)(data, this, config);
|
|
10
10
|
Object.keys(coreInput).forEach((key) => coreInput[key] === undefined && delete coreInput[key]);
|
|
11
11
|
return coreInput;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-input.input.js","sourceRoot":"","sources":["../../../../src/core/common/inputs/core-input.input.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"core-input.input.js","sourceRoot":"","sources":["../../../../src/core/common/inputs/core-input.input.ts"],"names":[],"mappings":";;;AAAA,0DAA8C;AAC9C,iEAAuD;AAYvD,MAAsB,SAAU,SAAQ,4BAAS;IAIxC,GAAG,CACR,IAAyC,EACzC,UAII,EAAE;QAEN,MAAM,MAAM,mBACV,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,KAAK,EAClB,KAAK,EAAE,KAAK,IACT,OAAO,CACX,CAAC;QACF,MAAM,SAAS,GAAG,IAAA,kBAAG,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/F,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAtBD,8BAsBC"}
|
|
@@ -13,7 +13,7 @@ const restricted_decorator_1 = require("../decorators/restricted.decorator");
|
|
|
13
13
|
const context_helper_1 = require("../helpers/context.helper");
|
|
14
14
|
let CheckResponseInterceptor = class CheckResponseInterceptor {
|
|
15
15
|
intercept(context, next) {
|
|
16
|
-
const { currentUser } = context_helper_1.
|
|
16
|
+
const { currentUser } = (0, context_helper_1.getContextData)(context);
|
|
17
17
|
return next.handle().pipe((0, operators_1.map)((data) => {
|
|
18
18
|
return (0, restricted_decorator_1.checkRestricted)(data, currentUser, { throwError: false });
|
|
19
19
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-response.interceptor.js","sourceRoot":"","sources":["../../../../src/core/common/interceptors/check-response.interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4F;AAE5F,8CAAqC;AACrC,6EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"check-response.interceptor.js","sourceRoot":"","sources":["../../../../src/core/common/interceptors/check-response.interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4F;AAE5F,8CAAqC;AACrC,6EAAqE;AACrE,8DAA2D;AAM3D,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAInC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAEpD,MAAM,EAAE,WAAW,EAAE,GAAQ,IAAA,+BAAc,EAAC,OAAO,CAAC,CAAC;QAGrD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,eAAG,EAAC,CAAC,IAAI,EAAE,EAAE;YAEX,OAAO,IAAA,sCAAe,EAAC,IAAI,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAgBpC;AAhBY,4DAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-selector.interface.js","sourceRoot":"","sources":["../../../../src/core/common/interfaces/resolve-selector.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { FieldSelection } from '../types/field-selection.type';
|
|
3
|
+
import { IdsType } from '../types/ids.type';
|
|
4
|
+
export interface ServiceOptions {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
checkRights?: boolean;
|
|
7
|
+
currentUser?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
id: string;
|
|
10
|
+
roles?: string[];
|
|
11
|
+
};
|
|
12
|
+
fieldSelection?: FieldSelection;
|
|
13
|
+
inputType?: new (...params: any[]) => any;
|
|
14
|
+
ownerIds?: IdsType;
|
|
15
|
+
processFieldSelection?: {
|
|
16
|
+
model?: new (...args: any[]) => any;
|
|
17
|
+
dbModel?: Model<any>;
|
|
18
|
+
};
|
|
19
|
+
prepareInput?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
create?: boolean;
|
|
22
|
+
clone?: boolean;
|
|
23
|
+
getNewArray?: boolean;
|
|
24
|
+
removeUndefined?: boolean;
|
|
25
|
+
};
|
|
26
|
+
prepareOutput?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
clone?: boolean;
|
|
29
|
+
getNewArray?: boolean;
|
|
30
|
+
removeUndefined?: boolean;
|
|
31
|
+
targetModel?: new (...args: any[]) => any;
|
|
32
|
+
};
|
|
33
|
+
pubSub?: boolean;
|
|
34
|
+
resultType?: new (...params: any[]) => any;
|
|
35
|
+
roles?: string | string[];
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-options.interface.js","sourceRoot":"","sources":["../../../../src/core/common/interfaces/service-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare abstract class CoreModel {
|
|
2
2
|
static init<T extends CoreModel>(this: new (...args: any[]) => T, ...args: any[]): T;
|
|
3
3
|
static map<T extends CoreModel>(this: new (...args: any[]) => T, data: Partial<T> | Record<string, any>, options?: {
|
|
4
|
+
[key: string]: any;
|
|
4
5
|
cloneDeep?: boolean;
|
|
5
6
|
funcAllowed?: boolean;
|
|
6
7
|
init?: any;
|
|
@@ -8,20 +9,23 @@ export declare abstract class CoreModel {
|
|
|
8
9
|
mapId?: boolean;
|
|
9
10
|
}): T;
|
|
10
11
|
static mapDeep<T extends CoreModel>(this: new (...args: any[]) => T, data: Partial<T> | Record<string, any>, options?: {
|
|
12
|
+
[key: string]: any;
|
|
11
13
|
cloneDeep?: boolean;
|
|
12
14
|
funcAllowed?: boolean;
|
|
13
15
|
init?: any;
|
|
14
16
|
item?: T;
|
|
15
17
|
mapId?: boolean;
|
|
16
18
|
}): T;
|
|
17
|
-
init
|
|
19
|
+
init(...args: any[]): this;
|
|
18
20
|
map(data: Partial<this> | Record<string, any>, options?: {
|
|
21
|
+
[key: string]: any;
|
|
19
22
|
cloneDeep?: boolean;
|
|
20
23
|
funcAllowed?: boolean;
|
|
21
24
|
init?: any;
|
|
22
25
|
mapId?: boolean;
|
|
23
26
|
}): this;
|
|
24
27
|
mapDeep(data: Partial<this> | Record<string, any>, options?: {
|
|
28
|
+
[key: string]: any;
|
|
25
29
|
cloneDeep?: boolean;
|
|
26
30
|
funcAllowed?: boolean;
|
|
27
31
|
init?: any;
|
|
@@ -24,7 +24,7 @@ class CoreModel {
|
|
|
24
24
|
}
|
|
25
25
|
map(data, options = {}) {
|
|
26
26
|
const config = Object.assign({ cloneDeep: false, funcAllowed: false, init: undefined, mapId: false }, options);
|
|
27
|
-
return config.init ? model_helper_1.
|
|
27
|
+
return config.init ? (0, model_helper_1.map)(data, this, config).init(config.init) : (0, model_helper_1.map)(data, this, config);
|
|
28
28
|
}
|
|
29
29
|
mapDeep(data, options = {}) {
|
|
30
30
|
const config = Object.assign({ cloneDeep: true, funcAllowed: false, init: undefined, mapId: false }, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-model.model.js","sourceRoot":"","sources":["../../../../src/core/common/models/core-model.model.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"core-model.model.js","sourceRoot":"","sources":["../../../../src/core/common/models/core-model.model.ts"],"names":[],"mappings":";;;AAAA,0DAA8C;AAY9C,MAAsB,SAAS;IAItB,MAAM,CAAC,IAAI,CAAuD,GAAG,IAAW;QACrF,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAKM,MAAM,CAAC,GAAG,CAEf,IAAsC,EACtC,UAOI,EAAE;QAEN,MAAM,MAAM,mBACV,IAAI,EAAE,IAAI,IACP,OAAO,CACX,CAAC;QAEF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAUM,MAAM,CAAC,OAAO,CAEnB,IAAsC,EACtC,UAOI,EAAE;QAEN,MAAM,MAAM,mBACV,IAAI,EAAE,IAAI,IACP,OAAO,CACX,CAAC;QAEF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAMM,IAAI,CAAC,GAAG,IAAW;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAKM,GAAG,CACR,IAAyC,EACzC,UAMI,EAAE;QAEN,MAAM,MAAM,mBACV,SAAS,EAAE,KAAK,EAChB,WAAW,EAAE,KAAK,EAClB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,KAAK,IACT,OAAO,CACX,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,kBAAG,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAG,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3F,CAAC;IAUM,OAAO,CACZ,IAAyC,EACzC,UAMI,EAAE;QAEN,MAAM,MAAM,mBACV,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,KAAK,EAClB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,KAAK,IACT,OAAO,CACX,CAAC;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;CACF;AA1HD,8BA0HC"}
|
|
@@ -23,8 +23,8 @@ let CheckInputPipe = class CheckInputPipe {
|
|
|
23
23
|
}
|
|
24
24
|
async transform(value, metadata) {
|
|
25
25
|
const metatype = metadata === null || metadata === void 0 ? void 0 : metadata.metatype;
|
|
26
|
-
const { user } = context_helper_1.
|
|
27
|
-
return input_helper_1.
|
|
26
|
+
const { user } = (0, context_helper_1.getContextData)(this.context);
|
|
27
|
+
return (0, input_helper_1.check)(value, user, { metatype });
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
CheckInputPipe = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-input.pipe.js","sourceRoot":"","sources":["../../../../src/core/common/pipes/check-input.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,6CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"check-input.pipe.js","sourceRoot":"","sources":["../../../../src/core/common/pipes/check-input.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,6CAA0C;AAC1C,8DAA2D;AAC3D,0DAAgD;AAUhD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIzB,YAAgD,OAAO;QAAP,YAAO,GAAP,OAAO,CAAA;IAAG,CAAC;IAK3D,KAAK,CAAC,SAAS,CAAC,KAAU,EAAE,QAA0B;QAEpD,MAAM,QAAQ,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC;QAGpC,MAAM,EAAE,IAAI,EAAE,GAAQ,IAAA,+BAAc,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAGnD,OAAO,IAAA,oBAAK,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AAnBY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAKE,WAAA,IAAA,eAAM,EAAC,iBAAO,CAAC,CAAA;;GAJjB,cAAc,CAmB1B;AAnBY,wCAAc"}
|
|
@@ -14,7 +14,7 @@ const input_helper_1 = require("../helpers/input.helper");
|
|
|
14
14
|
let MapAndValidatePipe = class MapAndValidatePipe {
|
|
15
15
|
async transform(value, metadata) {
|
|
16
16
|
const { metatype } = metadata;
|
|
17
|
-
if (typeof value !== 'object' || !metatype || input_helper_1.
|
|
17
|
+
if (typeof value !== 'object' || !metatype || (0, input_helper_1.isBasicType)(metatype)) {
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
20
|
if (!(value instanceof metatype)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-and-validate.pipe.js","sourceRoot":"","sources":["../../../../src/core/common/pipes/map-and-validate.pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkG;AAClG,yDAAoD;AACpD,qDAA2C;AAC3C,0DAAsD;AAGtD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC7B,KAAK,CAAC,SAAS,CAAC,KAAU,EAAE,QAA0B;QACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,IAAI,0BAAW,
|
|
1
|
+
{"version":3,"file":"map-and-validate.pipe.js","sourceRoot":"","sources":["../../../../src/core/common/pipes/map-and-validate.pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkG;AAClG,yDAAoD;AACpD,qDAA2C;AAC3C,0DAAsD;AAGtD,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAC7B,KAAK,CAAC,SAAS,CAAC,KAAU,EAAE,QAA0B;QACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,IAAI,IAAA,0BAAW,EAAC,QAAQ,CAAC,EAAE;YACnE,OAAO,KAAK,CAAC;SACd;QAGD,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,EAAE;YAChC,IAAK,QAAgB,aAAhB,QAAQ,uBAAR,QAAQ,CAAU,GAAG,EAAE;gBAC1B,KAAK,GAAI,QAAgB,aAAhB,QAAQ,uBAAR,QAAQ,CAAU,GAAG,CAAC,KAAK,CAAC,CAAC;aACvC;iBAAM;gBACL,KAAK,GAAG,IAAA,mCAAe,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;aAC1C;SACF;QAGD,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,KAAK,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB,MAAM,IAAI,4BAAmB,CAAC,yBAAyB,CAAC,CAAC;SAC1D;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAzBY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAyB9B;AAzBY,gDAAkB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FilterArgs } from '../args/filter.args';
|
|
2
|
+
import { ServiceOptions } from '../interfaces/service-options.interface';
|
|
3
|
+
import { CoreModel } from '../models/core-model.model';
|
|
4
|
+
import { ModuleService } from './module.service';
|
|
5
|
+
export declare abstract class CrudService<T extends CoreModel = any> extends ModuleService<T> {
|
|
6
|
+
create(input: any, serviceOptions?: ServiceOptions): Promise<T>;
|
|
7
|
+
get(id: string, serviceOptions?: ServiceOptions): Promise<T>;
|
|
8
|
+
find(filterArgs?: FilterArgs, serviceOptions?: ServiceOptions): Promise<T[]>;
|
|
9
|
+
read(id: string, serviceOptions?: ServiceOptions): Promise<T>;
|
|
10
|
+
read(filterArgs?: FilterArgs, serviceOptions?: ServiceOptions): Promise<T[]>;
|
|
11
|
+
update(id: string, input: any, serviceOptions?: ServiceOptions): Promise<T>;
|
|
12
|
+
delete(id: string, serviceOptions?: ServiceOptions): Promise<T>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudService = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const config_helper_1 = require("../helpers/config.helper");
|
|
6
|
+
const filter_helper_1 = require("../helpers/filter.helper");
|
|
7
|
+
const module_service_1 = require("./module.service");
|
|
8
|
+
class CrudService extends module_service_1.ModuleService {
|
|
9
|
+
async create(input, serviceOptions) {
|
|
10
|
+
(0, config_helper_1.merge)({ prepareInput: { create: true } }, serviceOptions);
|
|
11
|
+
return this.process(async (data) => {
|
|
12
|
+
return new this.mainDbModel(Object.assign({}, data.input)).save();
|
|
13
|
+
}, { input, serviceOptions });
|
|
14
|
+
}
|
|
15
|
+
async get(id, serviceOptions) {
|
|
16
|
+
const dbObject = await this.mainDbModel.findById(id).exec();
|
|
17
|
+
if (!dbObject) {
|
|
18
|
+
throw new common_1.NotFoundException(`No ${this.mainModelConstructor.name} found with ID: ${id}`);
|
|
19
|
+
}
|
|
20
|
+
return this.process(async () => dbObject, { dbObject, serviceOptions });
|
|
21
|
+
}
|
|
22
|
+
async find(filterArgs, serviceOptions) {
|
|
23
|
+
return this.process(async (data) => {
|
|
24
|
+
const filterQuery = (0, filter_helper_1.convertFilterArgsToQuery)(data.input);
|
|
25
|
+
return this.mainDbModel.find(filterQuery[0], null, filterQuery[1]).exec();
|
|
26
|
+
}, { input: filterArgs, serviceOptions });
|
|
27
|
+
}
|
|
28
|
+
async read(input, serviceOptions) {
|
|
29
|
+
if (typeof input === 'string') {
|
|
30
|
+
return this.get(input, serviceOptions);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this.find(input, serviceOptions);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async update(id, input, serviceOptions) {
|
|
37
|
+
const dbObject = await this.mainDbModel.findById(id).exec();
|
|
38
|
+
if (!dbObject) {
|
|
39
|
+
throw new common_1.NotFoundException(`No ${this.mainModelConstructor.name} found with ID: ${id}`);
|
|
40
|
+
}
|
|
41
|
+
return this.process(async (data) => {
|
|
42
|
+
return await Object.assign(dbObject, data.input).save();
|
|
43
|
+
}, { dbObject, input, serviceOptions });
|
|
44
|
+
}
|
|
45
|
+
async delete(id, serviceOptions) {
|
|
46
|
+
const dbObject = await this.mainDbModel.findById(id).exec();
|
|
47
|
+
if (!dbObject) {
|
|
48
|
+
throw new common_1.NotFoundException(`No ${this.mainModelConstructor.name} found with ID: ${id}`);
|
|
49
|
+
}
|
|
50
|
+
return this.process(async (data) => {
|
|
51
|
+
await this.mainDbModel.findByIdAndDelete(id).exec();
|
|
52
|
+
return dbObject;
|
|
53
|
+
}, { dbObject, input: id, serviceOptions });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CrudService = CrudService;
|
|
57
|
+
//# sourceMappingURL=crud.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.service.js","sourceRoot":"","sources":["../../../../src/core/common/services/crud.service.ts"],"names":[],"mappings":";;;AAAA,2CAAmD;AAEnD,4DAAiD;AACjD,4DAAoE;AAGpE,qDAAiD;AAEjD,MAAsB,WAAuC,SAAQ,8BAAgB;IAInF,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,cAA+B;QACtD,IAAA,qBAAK,EAAC,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AQ,EAAE,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,CACxC,CAAC;IACJ,CAAC;CACF;AA3FD,kCA2FC"}
|
|
@@ -24,21 +24,21 @@ let EmailService = class EmailService {
|
|
|
24
24
|
const { attachments, htmlTemplate, senderName, senderEmail, templateData, textTemplate } = Object.assign({ senderEmail: this.configService.get('email.defaultSender.email'), senderName: this.configService.get('email.defaultSender.name') }, config);
|
|
25
25
|
let html = config.html;
|
|
26
26
|
let text = config.text;
|
|
27
|
-
input_helper_1.
|
|
28
|
-
input_helper_1.
|
|
29
|
-
input_helper_1.
|
|
30
|
-
input_helper_1.
|
|
27
|
+
(0, input_helper_1.isTrue)(recipients);
|
|
28
|
+
(0, input_helper_1.isNonEmptyString)(subject);
|
|
29
|
+
(0, input_helper_1.isNonEmptyString)(senderName);
|
|
30
|
+
(0, input_helper_1.isNonEmptyString)(senderEmail);
|
|
31
31
|
if (htmlTemplate) {
|
|
32
32
|
html = await this.templateService.renderTemplate(htmlTemplate, templateData);
|
|
33
33
|
}
|
|
34
34
|
if (textTemplate) {
|
|
35
35
|
text = await this.templateService.renderTemplate(textTemplate, templateData);
|
|
36
36
|
}
|
|
37
|
-
if (!input_helper_1.
|
|
38
|
-
input_helper_1.
|
|
37
|
+
if (!(0, input_helper_1.isNonEmptyString)(html, input_helper_1.returnFalse)) {
|
|
38
|
+
(0, input_helper_1.isNonEmptyString)(text);
|
|
39
39
|
}
|
|
40
|
-
if (!input_helper_1.
|
|
41
|
-
input_helper_1.
|
|
40
|
+
if (!(0, input_helper_1.isNonEmptyString)(text, input_helper_1.returnFalse)) {
|
|
41
|
+
(0, input_helper_1.isNonEmptyString)(html);
|
|
42
42
|
}
|
|
43
43
|
const transporter = nodemailer.createTransport(this.configService.get('email.smtp'));
|
|
44
44
|
return transporter.sendMail({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/core/common/services/email.service.ts"],"names":[],"mappings":";;;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+BAAgB,EAAC,IAAI,EAAE,0BAAW,CAAC,EAAE;YACxC,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;SACxB;QACD,IAAI,CAAC,IAAA,+BAAgB,EAAC,IAAI,EAAE,0BAAW,CAAC,EAAE;YACxC,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;SACxB;QAGD,MAAM,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QAGrF,OAAO,WAAW,CAAC,QAAQ,CAAC;YAC1B,IAAI,EAAE,IAAI,UAAU,MAAM,WAAW,GAAG;YACxC,EAAE,EAAE,UAAU;YACd,OAAO;YACP,IAAI;YACJ,IAAI;YACJ,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtEY,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAK0B,8BAAa,EAA6B,kCAAe;GAJnF,YAAY,CAsExB;AAtEY,oCAAY"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Document, Model, Types } from 'mongoose';
|
|
2
|
+
import { ServiceOptions } from '../interfaces/service-options.interface';
|
|
3
|
+
import { CoreModel } from '../models/core-model.model';
|
|
4
|
+
import { FieldSelection } from '../types/field-selection.type';
|
|
5
|
+
import { IdsType } from '../types/ids.type';
|
|
6
|
+
export declare abstract class ModuleService<T extends CoreModel = any> {
|
|
7
|
+
protected mainModelConstructor: new (...args: any[]) => T;
|
|
8
|
+
protected mainDbModel: Model<T & Document>;
|
|
9
|
+
protected constructor(options?: {
|
|
10
|
+
mainDbModel: Model<T & Document>;
|
|
11
|
+
mainModelConstructor?: new (...args: any[]) => T;
|
|
12
|
+
});
|
|
13
|
+
checkRights(input: any, currentUser: {
|
|
14
|
+
id: any;
|
|
15
|
+
hasRole: (roles: string[]) => boolean;
|
|
16
|
+
}, options?: {
|
|
17
|
+
creator?: IdsType;
|
|
18
|
+
metatype?: any;
|
|
19
|
+
ownerIds?: IdsType;
|
|
20
|
+
roles?: string | string[];
|
|
21
|
+
throwError?: boolean;
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
abstract get(id: any, ...args: any[]): any;
|
|
24
|
+
process(serviceFunc: (options?: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
input?: any;
|
|
27
|
+
serviceOptions?: ServiceOptions;
|
|
28
|
+
}) => any, options?: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
dbObject?: string | Types.ObjectId | any;
|
|
31
|
+
input?: any;
|
|
32
|
+
serviceOptions?: ServiceOptions;
|
|
33
|
+
}): Promise<any>;
|
|
34
|
+
prepareInput(input: Record<string, any>, options?: ServiceOptions): Promise<Record<string, any>>;
|
|
35
|
+
prepareOutput(output: any, options?: ServiceOptions): Promise<any>;
|
|
36
|
+
processFieldSelection(data: any, fieldsSelection: FieldSelection, options?: {
|
|
37
|
+
model?: new (...args: any[]) => T;
|
|
38
|
+
dbModel?: Model<T & Document>;
|
|
39
|
+
}): Promise<T | T[]>;
|
|
40
|
+
}
|