@lenne.tech/nest-server 10.0.0 → 10.0.3
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 +29 -17
- package/dist/config.env.js.map +1 -1
- package/dist/core/common/args/filter.args.js +3 -3
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.js +6 -6
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/restricted.decorator.js +15 -17
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/filters/http-exception-log.filter.js +1 -3
- package/dist/core/common/filters/http-exception-log.filter.js.map +1 -1
- package/dist/core/common/helpers/db.helper.js +14 -14
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/file.helper.js +2 -2
- package/dist/core/common/helpers/file.helper.js.map +1 -1
- package/dist/core/common/helpers/filter.helper.d.ts +2 -2
- package/dist/core/common/helpers/filter.helper.js +1 -1
- package/dist/core/common/helpers/filter.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.js +1 -1
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.js +31 -38
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/model.helper.js +7 -7
- package/dist/core/common/helpers/model.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.js +2 -2
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +3 -3
- 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/inputs/filter.input.js +3 -3
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +4 -4
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +1 -1
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/interceptors/check-security.interceptor.d.ts +1 -1
- package/dist/core/common/interceptors/check-security.interceptor.js +2 -2
- package/dist/core/common/interceptors/check-security.interceptor.js.map +1 -1
- package/dist/core/common/interfaces/server-options.interface.d.ts +27 -0
- package/dist/core/common/models/core-model.model.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.js +3 -3
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.d.ts +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/scalars/any.scalar.js +2 -2
- package/dist/core/common/scalars/any.scalar.js.map +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js +1 -1
- package/dist/core/common/scalars/date-timestamp.scalar.js.map +1 -1
- package/dist/core/common/scalars/date.scalar.js +1 -1
- package/dist/core/common/scalars/date.scalar.js.map +1 -1
- package/dist/core/common/scalars/json.scalar.js +2 -2
- package/dist/core/common/scalars/json.scalar.js.map +1 -1
- package/dist/core/common/services/config.service.js +7 -7
- package/dist/core/common/services/config.service.js.map +1 -1
- package/dist/core/common/services/core-cron-jobs.service.js +5 -5
- package/dist/core/common/services/core-cron-jobs.service.js.map +1 -1
- package/dist/core/common/services/crud.service.js +1 -1
- package/dist/core/common/services/crud.service.js.map +1 -1
- package/dist/core/common/services/mailjet.service.js +5 -5
- package/dist/core/common/services/mailjet.service.js.map +1 -1
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/services/template.service.js +3 -3
- package/dist/core/common/services/template.service.js.map +1 -1
- package/dist/core/common/types/core-model-constructor.type.d.ts +2 -2
- package/dist/core/modules/auth/core-auth.module.js +3 -3
- package/dist/core/modules/auth/core-auth.module.js.map +1 -1
- package/dist/core/modules/auth/core-auth.resolver.js +5 -5
- package/dist/core/modules/auth/core-auth.resolver.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +4 -4
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js +1 -1
- package/dist/core/modules/auth/guards/roles.guard.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth.service.js +5 -5
- package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
- package/dist/core/modules/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/core/modules/auth/tokens.decorator.js +2 -2
- package/dist/core/modules/auth/tokens.decorator.js.map +1 -1
- package/dist/core/modules/file/core-file-info.model.js +2 -2
- package/dist/core/modules/file/core-file-info.model.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.d.ts +1 -2
- package/dist/core/modules/file/core-file.controller.js +3 -6
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.service.js +1 -1
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/core/modules/file/interfaces/file-upload.interface.d.ts +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.d.ts +8 -0
- package/dist/core/modules/health-check/core-health-check-result.model.js +53 -0
- package/dist/core/modules/health-check/core-health-check-result.model.js.map +1 -0
- package/dist/core/modules/health-check/core-health-check.controller.d.ts +6 -0
- package/dist/core/modules/health-check/core-health-check.controller.js +33 -0
- package/dist/core/modules/health-check/core-health-check.controller.js.map +1 -0
- package/dist/core/modules/health-check/core-health-check.module.d.ts +2 -0
- package/dist/core/modules/health-check/core-health-check.module.js +24 -0
- package/dist/core/modules/health-check/core-health-check.module.js.map +1 -0
- package/dist/core/modules/health-check/core-health-check.resolver.d.ts +6 -0
- package/dist/core/modules/health-check/core-health-check.resolver.js +38 -0
- package/dist/core/modules/health-check/core-health-check.resolver.js.map +1 -0
- package/dist/core/modules/health-check/core-health-check.service.d.ts +11 -0
- package/dist/core/modules/health-check/core-health-check.service.js +52 -0
- package/dist/core/modules/health-check/core-health-check.service.js.map +1 -0
- package/dist/core/modules/user/core-user.model.js +4 -4
- package/dist/core/modules/user/core-user.model.js.map +1 -1
- package/dist/core/modules/user/core-user.service.js +2 -2
- package/dist/core/modules/user/core-user.service.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/core.module.js +10 -5
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/server/modules/auth/auth.service.js +1 -1
- package/dist/server/modules/auth/auth.service.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/file/file.resolver.js +2 -2
- package/dist/server/modules/file/file.resolver.js.map +1 -1
- package/dist/server/modules/file/file.service.js +1 -1
- package/dist/server/modules/file/file.service.js.map +1 -1
- package/dist/server/modules/file/multer-config.service.js +1 -1
- package/dist/server/modules/file/multer-config.service.js.map +1 -1
- package/dist/server/modules/user/avatar.controller.js +1 -1
- package/dist/server/modules/user/avatar.controller.js.map +1 -1
- package/dist/server/modules/user/user.resolver.js +1 -1
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/server/modules/user/user.service.js +3 -3
- package/dist/server/modules/user/user.service.js.map +1 -1
- package/dist/templates/index.ejs +2 -0
- package/dist/templates/password-reset.ejs +3 -0
- package/dist/templates/welcome.ejs +3 -0
- package/dist/test/test.helper.d.ts +1 -1
- package/dist/test/test.helper.js +7 -7
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +28 -25
- package/src/config.env.ts +32 -20
- package/src/core/common/args/filter.args.ts +4 -4
- package/src/core/common/args/pagination.args.ts +7 -7
- package/src/core/common/decorators/graphql-service-options.decorator.ts +2 -2
- package/src/core/common/decorators/graphql-user.decorator.ts +1 -1
- package/src/core/common/decorators/rest-user.decorator.ts +1 -1
- package/src/core/common/decorators/restricted.decorator.ts +18 -18
- package/src/core/common/filters/http-exception-log.filter.ts +4 -4
- package/src/core/common/helpers/db.helper.ts +35 -40
- package/src/core/common/helpers/decorator.helper.ts +1 -1
- package/src/core/common/helpers/file.helper.ts +2 -2
- package/src/core/common/helpers/filter.helper.ts +7 -8
- package/src/core/common/helpers/graphql.helper.ts +6 -6
- package/src/core/common/helpers/input.helper.ts +54 -61
- package/src/core/common/helpers/model.helper.ts +33 -41
- package/src/core/common/helpers/service.helper.ts +8 -8
- package/src/core/common/inputs/combined-filter.input.ts +4 -4
- package/src/core/common/inputs/core-input.input.ts +2 -2
- package/src/core/common/inputs/filter.input.ts +4 -4
- package/src/core/common/inputs/single-filter.input.ts +4 -4
- package/src/core/common/inputs/sort.input.ts +1 -1
- package/src/core/common/interceptors/check-response.interceptor.ts +1 -1
- package/src/core/common/interceptors/check-security.interceptor.ts +5 -5
- package/src/core/common/interfaces/server-options.interface.ts +31 -0
- package/src/core/common/models/core-model.model.ts +6 -4
- package/src/core/common/models/core-persistence.model.ts +3 -3
- package/src/core/common/pipes/map-and-validate.pipe.ts +2 -2
- package/src/core/common/scalars/any.scalar.ts +2 -2
- package/src/core/common/scalars/date-timestamp.scalar.ts +1 -2
- package/src/core/common/scalars/date.scalar.ts +1 -2
- package/src/core/common/scalars/json.scalar.ts +4 -4
- package/src/core/common/services/config.service.ts +16 -16
- package/src/core/common/services/core-cron-jobs.service.ts +7 -7
- package/src/core/common/services/crud.service.ts +22 -22
- package/src/core/common/services/email.service.ts +1 -1
- package/src/core/common/services/mailjet.service.ts +8 -8
- package/src/core/common/services/module.service.ts +5 -6
- package/src/core/common/services/template.service.ts +4 -4
- package/src/core/common/types/core-model-constructor.type.ts +2 -2
- package/src/core/modules/auth/core-auth.controller.ts +2 -2
- package/src/core/modules/auth/core-auth.module.ts +4 -4
- package/src/core/modules/auth/core-auth.resolver.ts +9 -9
- package/src/core/modules/auth/guards/auth.guard.ts +8 -7
- package/src/core/modules/auth/guards/roles.guard.ts +1 -1
- package/src/core/modules/auth/services/core-auth.service.ts +9 -9
- package/src/core/modules/auth/strategies/jwt-refresh.strategy.ts +1 -1
- package/src/core/modules/auth/strategies/jwt.strategy.ts +1 -1
- package/src/core/modules/auth/tokens.decorator.ts +6 -7
- package/src/core/modules/file/core-file-info.model.ts +2 -2
- package/src/core/modules/file/core-file.controller.ts +2 -4
- package/src/core/modules/file/core-file.service.ts +6 -5
- package/src/core/modules/file/interfaces/file-upload.interface.ts +1 -1
- package/src/core/modules/health-check/core-health-check-result.model.ts +46 -0
- package/src/core/modules/health-check/core-health-check.controller.ts +24 -0
- package/src/core/modules/health-check/core-health-check.module.ts +17 -0
- package/src/core/modules/health-check/core-health-check.resolver.ts +32 -0
- package/src/core/modules/health-check/core-health-check.service.ts +60 -0
- package/src/core/modules/user/core-user.model.ts +5 -5
- package/src/core/modules/user/core-user.service.ts +10 -9
- package/src/core/modules/user/inputs/core-user.input.ts +1 -2
- package/src/core.module.ts +16 -10
- package/src/index.ts +10 -0
- package/src/main.ts +2 -2
- package/src/server/modules/auth/auth.controller.ts +1 -1
- package/src/server/modules/auth/auth.resolver.ts +3 -3
- package/src/server/modules/auth/auth.service.ts +2 -2
- package/src/server/modules/file/file.controller.ts +1 -2
- package/src/server/modules/file/file.module.ts +1 -1
- package/src/server/modules/file/file.resolver.ts +4 -3
- package/src/server/modules/file/file.service.ts +1 -1
- package/src/server/modules/file/multer-config.service.ts +1 -1
- package/src/server/modules/user/avatar.controller.ts +3 -3
- package/src/server/modules/user/user.model.ts +1 -1
- package/src/server/modules/user/user.resolver.ts +4 -4
- package/src/server/modules/user/user.service.ts +4 -4
- package/src/test/test.helper.ts +11 -11
|
@@ -33,7 +33,7 @@ export default class ServiceHelper {
|
|
|
33
33
|
removeUndefined?: boolean;
|
|
34
34
|
sha256?: boolean;
|
|
35
35
|
targetModel?: new (...args: any[]) => T;
|
|
36
|
-
} = {}
|
|
36
|
+
} = {},
|
|
37
37
|
): Promise<T> {
|
|
38
38
|
return prepareInput(input, currentUser, options);
|
|
39
39
|
}
|
|
@@ -51,7 +51,7 @@ export default class ServiceHelper {
|
|
|
51
51
|
removeSecrets?: boolean;
|
|
52
52
|
removeUndefined?: boolean;
|
|
53
53
|
targetModel?: new (...args: any[]) => T;
|
|
54
|
-
} = {}
|
|
54
|
+
} = {},
|
|
55
55
|
): Promise<T | T[] | any> {
|
|
56
56
|
return prepareOutput(output, options);
|
|
57
57
|
}
|
|
@@ -75,7 +75,7 @@ export async function prepareInput<T = any>(
|
|
|
75
75
|
removeUndefined?: boolean;
|
|
76
76
|
sha256?: boolean;
|
|
77
77
|
targetModel?: new (...args: any[]) => T;
|
|
78
|
-
} = {}
|
|
78
|
+
} = {},
|
|
79
79
|
): Promise<T> {
|
|
80
80
|
// Configuration
|
|
81
81
|
const config = {
|
|
@@ -127,7 +127,7 @@ export async function prepareInput<T = any>(
|
|
|
127
127
|
}
|
|
128
128
|
return property;
|
|
129
129
|
},
|
|
130
|
-
{ specialClasses: ['ObjectId'] }
|
|
130
|
+
{ specialClasses: ['ObjectId'] },
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -153,7 +153,7 @@ export async function prepareInput<T = any>(
|
|
|
153
153
|
const allowedRoles = _.intersection((input as Record<string, any>).roles, (currentUser as any).roles);
|
|
154
154
|
if (allowedRoles.length !== (input as Record<string, any>).roles.length) {
|
|
155
155
|
const missingRoles = _.difference((input as Record<string, any>).roles, (currentUser as any).roles);
|
|
156
|
-
throw new UnauthorizedException(
|
|
156
|
+
throw new UnauthorizedException(`Current user not allowed setting roles: ${missingRoles}`);
|
|
157
157
|
}
|
|
158
158
|
(input as Record<string, any>).roles = allowedRoles;
|
|
159
159
|
}
|
|
@@ -190,7 +190,7 @@ export async function prepareOutput<T = { [key: string]: any; map: (...args: any
|
|
|
190
190
|
removeSecrets?: boolean;
|
|
191
191
|
removeUndefined?: boolean;
|
|
192
192
|
targetModel?: new (...args: any[]) => T;
|
|
193
|
-
} = {}
|
|
193
|
+
} = {},
|
|
194
194
|
): Promise<T | T[] | any> {
|
|
195
195
|
// Configuration
|
|
196
196
|
const config = {
|
|
@@ -289,7 +289,7 @@ export function prepareServiceOptions(
|
|
|
289
289
|
proto?: boolean;
|
|
290
290
|
prepareInput?: PrepareInputOptions;
|
|
291
291
|
prepareOutput?: PrepareOutputOptions;
|
|
292
|
-
}
|
|
292
|
+
},
|
|
293
293
|
): ServiceOptions {
|
|
294
294
|
// Set default values
|
|
295
295
|
const config = {
|
|
@@ -322,7 +322,7 @@ export function prepareServiceOptions(
|
|
|
322
322
|
// Set subfield selection
|
|
323
323
|
if (config.subFieldSelection) {
|
|
324
324
|
if ((serviceOptions.fieldSelection as ResolveSelector)?.select) {
|
|
325
|
-
(serviceOptions.fieldSelection as ResolveSelector).select +=
|
|
325
|
+
(serviceOptions.fieldSelection as ResolveSelector).select += `.${config.subFieldSelection}`;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -11,7 +11,7 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
11
11
|
/**
|
|
12
12
|
* Logical Operator to combine filters
|
|
13
13
|
*/
|
|
14
|
-
@Field(
|
|
14
|
+
@Field(type => LogicalOperatorEnum, {
|
|
15
15
|
description: 'Logical Operator to combine filters',
|
|
16
16
|
})
|
|
17
17
|
logicalOperator: LogicalOperatorEnum = undefined;
|
|
@@ -19,7 +19,7 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
19
19
|
/**
|
|
20
20
|
* Filters to combine via logical operator
|
|
21
21
|
*/
|
|
22
|
-
@Field(
|
|
22
|
+
@Field(type => [FilterInput], {
|
|
23
23
|
description: 'Filters to combine via logical operator',
|
|
24
24
|
})
|
|
25
25
|
filters: FilterInput[] = undefined;
|
|
@@ -37,11 +37,11 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
37
37
|
cloneDeep?: boolean;
|
|
38
38
|
funcAllowed?: boolean;
|
|
39
39
|
mapId?: boolean;
|
|
40
|
-
} = {}
|
|
40
|
+
} = {},
|
|
41
41
|
): this {
|
|
42
42
|
super.map(data, options);
|
|
43
43
|
this.filters = maps(data.filters, FilterInput, options.cloneDeep);
|
|
44
|
-
Object.keys(this).forEach(
|
|
44
|
+
Object.keys(this).forEach(key => this[key] === undefined && delete this[key]);
|
|
45
45
|
return this;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -21,7 +21,7 @@ export abstract class CoreInput extends CoreModel {
|
|
|
21
21
|
cloneDeep?: boolean;
|
|
22
22
|
funcAllowed?: boolean;
|
|
23
23
|
mapId?: boolean;
|
|
24
|
-
} = {}
|
|
24
|
+
} = {},
|
|
25
25
|
): this {
|
|
26
26
|
const config = {
|
|
27
27
|
cloneDeep: false,
|
|
@@ -30,7 +30,7 @@ export abstract class CoreInput extends CoreModel {
|
|
|
30
30
|
...options,
|
|
31
31
|
};
|
|
32
32
|
const coreInput = map(data, this, config);
|
|
33
|
-
Object.keys(coreInput).forEach(
|
|
33
|
+
Object.keys(coreInput).forEach(key => coreInput[key] === undefined && delete coreInput[key]);
|
|
34
34
|
return coreInput;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -13,7 +13,7 @@ export class FilterInput extends CoreInput {
|
|
|
13
13
|
/**
|
|
14
14
|
* Combination of multiple filters via logical operator
|
|
15
15
|
*/
|
|
16
|
-
@Field(
|
|
16
|
+
@Field(type => CombinedFilterInput, {
|
|
17
17
|
description: 'Combination of multiple filters via logical operator',
|
|
18
18
|
nullable: true,
|
|
19
19
|
})
|
|
@@ -22,7 +22,7 @@ export class FilterInput extends CoreInput {
|
|
|
22
22
|
/**
|
|
23
23
|
* Filter for a single property
|
|
24
24
|
*/
|
|
25
|
-
@Field(
|
|
25
|
+
@Field(type => SingleFilterInput, {
|
|
26
26
|
description: 'Filter for a single property',
|
|
27
27
|
nullable: true,
|
|
28
28
|
})
|
|
@@ -41,12 +41,12 @@ export class FilterInput extends CoreInput {
|
|
|
41
41
|
cloneDeep?: boolean;
|
|
42
42
|
funcAllowed?: boolean;
|
|
43
43
|
mapId?: boolean;
|
|
44
|
-
} = {}
|
|
44
|
+
} = {},
|
|
45
45
|
): this {
|
|
46
46
|
super.map(data, options);
|
|
47
47
|
this.combinedFilter = data.combinedFilter ? CombinedFilterInput.map(data.combinedFilter, options) : undefined;
|
|
48
48
|
this.singleFilter = data.singleFilter ? SingleFilterInput.map(data.singleFilter, options) : undefined;
|
|
49
|
-
Object.keys(this).forEach(
|
|
49
|
+
Object.keys(this).forEach(key => this[key] === undefined && delete this[key]);
|
|
50
50
|
return this;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -44,7 +44,7 @@ export class SingleFilterInput extends CoreInput {
|
|
|
44
44
|
/**
|
|
45
45
|
* [Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)
|
|
46
46
|
*/
|
|
47
|
-
@Field(
|
|
47
|
+
@Field(type => ComparisonOperatorEnum, {
|
|
48
48
|
description: '[Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)',
|
|
49
49
|
})
|
|
50
50
|
operator: ComparisonOperatorEnum = undefined;
|
|
@@ -55,12 +55,12 @@ export class SingleFilterInput extends CoreInput {
|
|
|
55
55
|
*/
|
|
56
56
|
@Field({
|
|
57
57
|
description:
|
|
58
|
-
'[Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for '
|
|
59
|
-
'[REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator',
|
|
58
|
+
'[Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for '
|
|
59
|
+
+ '[REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator',
|
|
60
60
|
nullable: true,
|
|
61
61
|
})
|
|
62
62
|
options?: string = undefined;
|
|
63
63
|
|
|
64
|
-
@Field(
|
|
64
|
+
@Field(type => JSON, { description: 'Value of the property' })
|
|
65
65
|
value: any = undefined;
|
|
66
66
|
}
|
|
@@ -16,6 +16,6 @@ export class SortInput extends CoreInput {
|
|
|
16
16
|
/**
|
|
17
17
|
* SortInput order of the field
|
|
18
18
|
*/
|
|
19
|
-
@Field(
|
|
19
|
+
@Field(type => SortOrderEnum, { description: 'SortInput order of the field' })
|
|
20
20
|
order: SortOrderEnum = undefined;
|
|
21
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { map } from 'rxjs/operators';
|
|
4
4
|
import { getContextData } from '../helpers/context.helper';
|
|
@@ -33,7 +33,7 @@ export class CheckSecurityInterceptor implements NestInterceptor {
|
|
|
33
33
|
|
|
34
34
|
// Check if data is writeable (e.g. objects from direct access to json files via http are not writable)
|
|
35
35
|
if (data && typeof data === 'object') {
|
|
36
|
-
const writeable = !Object.keys(data).find(
|
|
36
|
+
const writeable = !Object.keys(data).find(key => !Object.getOwnPropertyDescriptor(data, key).writable);
|
|
37
37
|
if (!writeable) {
|
|
38
38
|
return data;
|
|
39
39
|
}
|
|
@@ -45,15 +45,15 @@ export class CheckSecurityInterceptor implements NestInterceptor {
|
|
|
45
45
|
(item) => {
|
|
46
46
|
if (!item || typeof item !== 'object' || typeof item.securityCheck !== 'function') {
|
|
47
47
|
if (Array.isArray(item)) {
|
|
48
|
-
return item.filter(
|
|
48
|
+
return item.filter(i => i !== undefined);
|
|
49
49
|
}
|
|
50
50
|
return item;
|
|
51
51
|
}
|
|
52
52
|
return item.securityCheck(user, force);
|
|
53
53
|
},
|
|
54
|
-
{ specialFunctions: ['securityCheck'] }
|
|
54
|
+
{ specialFunctions: ['securityCheck'] },
|
|
55
55
|
);
|
|
56
|
-
})
|
|
56
|
+
}),
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -8,6 +8,8 @@ import { CronExpression } from '@nestjs/schedule';
|
|
|
8
8
|
import compression from 'compression';
|
|
9
9
|
import { CollationOptions } from 'mongodb';
|
|
10
10
|
import * as SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
11
|
+
import { MongoosePingCheckSettings } from '@nestjs/terminus/dist/health-indicator/database/mongoose.health';
|
|
12
|
+
import { DiskHealthIndicatorOptions } from '@nestjs/terminus/dist/health-indicator/disk/disk-health-options.type';
|
|
11
13
|
import { Falsy } from '../types/falsy.type';
|
|
12
14
|
import { CronJobConfig } from './cron-job-config.interface';
|
|
13
15
|
import { MailjetOptions } from './mailjet-options.interface';
|
|
@@ -170,6 +172,35 @@ export interface IServerOptions {
|
|
|
170
172
|
options?: GqlModuleAsyncOptions;
|
|
171
173
|
};
|
|
172
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Whether to activate health check endpoints
|
|
177
|
+
*/
|
|
178
|
+
healthCheck?: {
|
|
179
|
+
enabled?: boolean;
|
|
180
|
+
configs?: {
|
|
181
|
+
database?: {
|
|
182
|
+
disabled?: boolean;
|
|
183
|
+
key?: string;
|
|
184
|
+
options?: MongoosePingCheckSettings;
|
|
185
|
+
};
|
|
186
|
+
memoryHeap?: {
|
|
187
|
+
disabled?: boolean;
|
|
188
|
+
key?: string;
|
|
189
|
+
heapUsedThreshold?: number;
|
|
190
|
+
};
|
|
191
|
+
memoryRss?: {
|
|
192
|
+
disabled?: boolean;
|
|
193
|
+
key?: string;
|
|
194
|
+
rssThreshold?: number;
|
|
195
|
+
};
|
|
196
|
+
storage?: {
|
|
197
|
+
disabled?: boolean;
|
|
198
|
+
key?: string;
|
|
199
|
+
options?: DiskHealthIndicatorOptions;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
|
|
173
204
|
/**
|
|
174
205
|
* Ignore selections in fieldSelection
|
|
175
206
|
* [ConfigService must be integrated in ModuleService]
|
|
@@ -32,7 +32,7 @@ export abstract class CoreModel {
|
|
|
32
32
|
init?: any;
|
|
33
33
|
item?: T;
|
|
34
34
|
mapId?: boolean;
|
|
35
|
-
} = {}
|
|
35
|
+
} = {},
|
|
36
36
|
): T {
|
|
37
37
|
const item = options.item || new this();
|
|
38
38
|
delete options.item;
|
|
@@ -57,7 +57,7 @@ export abstract class CoreModel {
|
|
|
57
57
|
init?: any;
|
|
58
58
|
item?: T;
|
|
59
59
|
mapId?: boolean;
|
|
60
|
-
} = {}
|
|
60
|
+
} = {},
|
|
61
61
|
): T {
|
|
62
62
|
const item = options.item || new this();
|
|
63
63
|
delete options.item;
|
|
@@ -68,6 +68,7 @@ export abstract class CoreModel {
|
|
|
68
68
|
* Initialize instance with default values instead of undefined
|
|
69
69
|
* Should be overwritten in child class to organize the defaults
|
|
70
70
|
*/
|
|
71
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
71
72
|
public init(...args: any[]): this {
|
|
72
73
|
return this;
|
|
73
74
|
}
|
|
@@ -83,7 +84,7 @@ export abstract class CoreModel {
|
|
|
83
84
|
funcAllowed?: boolean;
|
|
84
85
|
init?: any;
|
|
85
86
|
mapId?: boolean;
|
|
86
|
-
} = {}
|
|
87
|
+
} = {},
|
|
87
88
|
): this {
|
|
88
89
|
const config = {
|
|
89
90
|
cloneDeep: false,
|
|
@@ -114,7 +115,7 @@ export abstract class CoreModel {
|
|
|
114
115
|
funcAllowed?: boolean;
|
|
115
116
|
init?: any;
|
|
116
117
|
mapId?: boolean;
|
|
117
|
-
} = {}
|
|
118
|
+
} = {},
|
|
118
119
|
): this {
|
|
119
120
|
const config = {
|
|
120
121
|
cloneDeep: true,
|
|
@@ -129,6 +130,7 @@ export abstract class CoreModel {
|
|
|
129
130
|
/**
|
|
130
131
|
* Verification of the user's rights to access the properties of this object
|
|
131
132
|
*/
|
|
133
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
132
134
|
public securityCheck(user: any, force?: boolean): this {
|
|
133
135
|
return this;
|
|
134
136
|
}
|
|
@@ -36,7 +36,7 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
36
36
|
/**
|
|
37
37
|
* ID of the persistence object as string
|
|
38
38
|
*/
|
|
39
|
-
@Field(
|
|
39
|
+
@Field(type => ID, {
|
|
40
40
|
description: 'ID of the persistence object',
|
|
41
41
|
nullable: true,
|
|
42
42
|
})
|
|
@@ -52,7 +52,7 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
52
52
|
/**
|
|
53
53
|
* Labels of the object
|
|
54
54
|
*/
|
|
55
|
-
@Field(
|
|
55
|
+
@Field(type => [String], {
|
|
56
56
|
description: 'Labels of the object',
|
|
57
57
|
nullable: true,
|
|
58
58
|
})
|
|
@@ -62,7 +62,7 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
62
62
|
/**
|
|
63
63
|
* Tags for the object
|
|
64
64
|
*/
|
|
65
|
-
@Field(
|
|
65
|
+
@Field(type => [String], {
|
|
66
66
|
description: 'Tags for the object',
|
|
67
67
|
nullable: true,
|
|
68
68
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
|
|
2
2
|
import { plainToInstance } from 'class-transformer';
|
|
3
3
|
import { validate } from 'class-validator';
|
|
4
4
|
import { isBasicType } from '../helpers/input.helper';
|
|
@@ -24,7 +24,7 @@ export class MapAndValidatePipe implements PipeTransform {
|
|
|
24
24
|
// Validate
|
|
25
25
|
const errors = await validate(value, { forbidUnknownValues: false });
|
|
26
26
|
if (errors.length > 0) {
|
|
27
|
-
throw new BadRequestException(
|
|
27
|
+
throw new BadRequestException(`Input validation failed:${errors.join('; ')}`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return value;
|
|
@@ -4,7 +4,7 @@ import { Kind, ValueNode } from 'graphql';
|
|
|
4
4
|
/**
|
|
5
5
|
* Any scalar (is equivalent to the JSON scalar)
|
|
6
6
|
*/
|
|
7
|
-
@Scalar('Any',
|
|
7
|
+
@Scalar('Any', type => Any)
|
|
8
8
|
export class Any implements CustomScalar<string, any> {
|
|
9
9
|
/**
|
|
10
10
|
* Description of the scalar
|
|
@@ -45,7 +45,7 @@ export class Any implements CustomScalar<string, any> {
|
|
|
45
45
|
return value;
|
|
46
46
|
}
|
|
47
47
|
case Kind.LIST:
|
|
48
|
-
return ast.values.map(
|
|
48
|
+
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
49
49
|
case Kind.NULL:
|
|
50
50
|
return null;
|
|
51
51
|
case Kind.VARIABLE: {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { CustomScalar, Scalar } from '@nestjs/graphql';
|
|
2
|
-
import { Kind } from 'graphql';
|
|
3
2
|
import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Date-Timestamp-Scalar to convert timestamp to date and vice versa
|
|
7
6
|
*/
|
|
8
|
-
@Scalar('Date',
|
|
7
|
+
@Scalar('Date', type => Date)
|
|
9
8
|
export class DateTimestampScalar implements CustomScalar<number, Date> {
|
|
10
9
|
description = 'Date (by Timestamp) custom scalar type';
|
|
11
10
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { CustomScalar, Scalar } from '@nestjs/graphql';
|
|
2
|
-
import { Kind } from 'graphql';
|
|
3
2
|
import { checkAndGetDate, getDateFromGraphQL } from '../helpers/input.helper';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Date scalar to convert string into date
|
|
7
6
|
*/
|
|
8
|
-
@Scalar('Date',
|
|
7
|
+
@Scalar('Date', type => Date)
|
|
9
8
|
export class DateScalar implements CustomScalar<string, Date> {
|
|
10
9
|
description = 'Date custom scalar type';
|
|
11
10
|
|
|
@@ -4,13 +4,13 @@ import { Kind, ValueNode } from 'graphql';
|
|
|
4
4
|
/**
|
|
5
5
|
* JSON scalar (is equivalent to the Any scalar)
|
|
6
6
|
*/
|
|
7
|
-
@Scalar('JSON',
|
|
7
|
+
@Scalar('JSON', type => JSON)
|
|
8
8
|
export class JSON implements CustomScalar<string, any> {
|
|
9
9
|
/**
|
|
10
10
|
* Description of the scalar
|
|
11
11
|
*/
|
|
12
|
-
description
|
|
13
|
-
'JSON scalar type. Information on the exact schema of the JSON object is contained in the description of the field.';
|
|
12
|
+
description
|
|
13
|
+
= 'JSON scalar type. Information on the exact schema of the JSON object is contained in the description of the field.';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Parse value from the client input variables
|
|
@@ -46,7 +46,7 @@ export class JSON implements CustomScalar<string, any> {
|
|
|
46
46
|
return value;
|
|
47
47
|
}
|
|
48
48
|
case Kind.LIST:
|
|
49
|
-
return ast.values.map(
|
|
49
|
+
return ast.values.map(n => this.parseLiteral(n, variables));
|
|
50
50
|
case Kind.NULL:
|
|
51
51
|
return null;
|
|
52
52
|
case Kind.VARIABLE: {
|
|
@@ -37,14 +37,14 @@ export class ConfigService {
|
|
|
37
37
|
/**
|
|
38
38
|
* BehaviorSubject for config
|
|
39
39
|
*/
|
|
40
|
-
protected static _configSubject$: BehaviorSubject<{ [key: string]: any } & Partial<IServerOptions>>
|
|
41
|
-
new BehaviorSubject(undefined);
|
|
40
|
+
protected static _configSubject$: BehaviorSubject<{ [key: string]: any } & Partial<IServerOptions>>
|
|
41
|
+
= new BehaviorSubject(undefined);
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* BehaviorSubject for frozen config
|
|
45
45
|
*/
|
|
46
|
-
protected static _frozenConfigSubject$: BehaviorSubject<{ [key: string]: any } & Partial<IServerOptions>>
|
|
47
|
-
new BehaviorSubject(undefined);
|
|
46
|
+
protected static _frozenConfigSubject$: BehaviorSubject<{ [key: string]: any } & Partial<IServerOptions>>
|
|
47
|
+
= new BehaviorSubject(undefined);
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Singleton instance of ConfigService
|
|
@@ -60,7 +60,7 @@ export class ConfigService {
|
|
|
60
60
|
*/
|
|
61
61
|
constructor(
|
|
62
62
|
configObject?: { [key: string]: any } & Partial<IServerOptions>,
|
|
63
|
-
options?: { reInit?: boolean; warn?: boolean }
|
|
63
|
+
options?: { reInit?: boolean; warn?: boolean },
|
|
64
64
|
) {
|
|
65
65
|
const config = {
|
|
66
66
|
reInit: false,
|
|
@@ -180,8 +180,8 @@ export class ConfigService {
|
|
|
180
180
|
*/
|
|
181
181
|
static get observable() {
|
|
182
182
|
return ConfigService._configSubject$.asObservable().pipe(
|
|
183
|
-
filter(
|
|
184
|
-
map(
|
|
183
|
+
filter(config => !config),
|
|
184
|
+
map(config => clone(config, { circles: false })),
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -196,7 +196,7 @@ export class ConfigService {
|
|
|
196
196
|
* Get observable for faster but read-only deep-frozen configuration
|
|
197
197
|
*/
|
|
198
198
|
static get observableFastButReadOnly() {
|
|
199
|
-
return ConfigService._frozenConfigSubject$.asObservable().pipe(filter(
|
|
199
|
+
return ConfigService._frozenConfigSubject$.asObservable().pipe(filter(config => !config));
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
@@ -243,7 +243,7 @@ export class ConfigService {
|
|
|
243
243
|
*/
|
|
244
244
|
static mergeConfig(
|
|
245
245
|
configData: { [key: string]: any } & Partial<IServerOptions>,
|
|
246
|
-
options?: { init?: boolean; warn?: boolean }
|
|
246
|
+
options?: { init?: boolean; warn?: boolean },
|
|
247
247
|
) {
|
|
248
248
|
const config = {
|
|
249
249
|
init: true,
|
|
@@ -266,7 +266,7 @@ export class ConfigService {
|
|
|
266
266
|
|
|
267
267
|
// Warn if requested
|
|
268
268
|
if (config.warn) {
|
|
269
|
-
console.warn(
|
|
269
|
+
console.warn(`ConfigService ${activity}`, JSON.stringify(merged, null, 2));
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// Return configuration
|
|
@@ -305,7 +305,7 @@ export class ConfigService {
|
|
|
305
305
|
|
|
306
306
|
// Warn if requested
|
|
307
307
|
if (config.warn) {
|
|
308
|
-
console.warn(
|
|
308
|
+
console.warn(`ConfigService ${key}:`, JSON.stringify(current[key], null, 2));
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
// Return configuration
|
|
@@ -317,7 +317,7 @@ export class ConfigService {
|
|
|
317
317
|
*/
|
|
318
318
|
setConfig(
|
|
319
319
|
configData: { [key: string]: any } & Partial<IServerOptions>,
|
|
320
|
-
options?: { reInit?: boolean; warn?: boolean }
|
|
320
|
+
options?: { reInit?: boolean; warn?: boolean },
|
|
321
321
|
) {
|
|
322
322
|
return ConfigService.setConfig(configData, options);
|
|
323
323
|
}
|
|
@@ -327,7 +327,7 @@ export class ConfigService {
|
|
|
327
327
|
*/
|
|
328
328
|
static setConfig(
|
|
329
329
|
configObject: { [key: string]: any } & Partial<IServerOptions>,
|
|
330
|
-
options?: { init?: boolean; reInit?: boolean; warn?: boolean }
|
|
330
|
+
options?: { init?: boolean; reInit?: boolean; warn?: boolean },
|
|
331
331
|
) {
|
|
332
332
|
const config = {
|
|
333
333
|
init: true,
|
|
@@ -342,8 +342,8 @@ export class ConfigService {
|
|
|
342
342
|
// Check for unintentional overwriting
|
|
343
343
|
if (!firstInitialization && !config.reInit) {
|
|
344
344
|
throw new Error(
|
|
345
|
-
'Unintentional overwriting of the configuration. '
|
|
346
|
-
'If overwriting is desired, please set `reInit` in setConfig of ConfigService to `true`.'
|
|
345
|
+
'Unintentional overwriting of the configuration. '
|
|
346
|
+
+ 'If overwriting is desired, please set `reInit` in setConfig of ConfigService to `true`.',
|
|
347
347
|
);
|
|
348
348
|
}
|
|
349
349
|
|
|
@@ -392,7 +392,7 @@ export class ConfigService {
|
|
|
392
392
|
current[key] = value;
|
|
393
393
|
ConfigService._configSubject$.next(current);
|
|
394
394
|
if (config.warn) {
|
|
395
|
-
console.warn(
|
|
395
|
+
console.warn(`ConfigService ${key}:`, JSON.stringify(value, null, 2));
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
// Return config
|
|
@@ -31,7 +31,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
31
31
|
protected constructor(
|
|
32
32
|
protected schedulerRegistry: SchedulerRegistry,
|
|
33
33
|
protected cronJobs: Record<string, CronExpression | string | Date | Falsy | CronJobConfig>,
|
|
34
|
-
options?: { log?: boolean }
|
|
34
|
+
options?: { log?: boolean },
|
|
35
35
|
) {
|
|
36
36
|
this.config = {
|
|
37
37
|
log: true,
|
|
@@ -91,7 +91,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
91
91
|
// check if cron job exists
|
|
92
92
|
if (!this[name]) {
|
|
93
93
|
if (this.config.log) {
|
|
94
|
-
console.info(
|
|
94
|
+
console.info(`Missing cron job function ${name}`);
|
|
95
95
|
}
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
@@ -105,8 +105,8 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
105
105
|
|
|
106
106
|
// Check if parallel execution is allowed and if so how many can run in parallel
|
|
107
107
|
if (
|
|
108
|
-
dates?.length
|
|
109
|
-
(!config.runParallel || (typeof config.runParallel === 'number' && dates.length >= config.runParallel))
|
|
108
|
+
dates?.length
|
|
109
|
+
&& (!config.runParallel || (typeof config.runParallel === 'number' && dates.length >= config.runParallel))
|
|
110
110
|
) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
@@ -123,7 +123,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
123
123
|
await this[name]();
|
|
124
124
|
} catch (e) {
|
|
125
125
|
// Remove job from running list
|
|
126
|
-
this.runningJobs[name] = this.runningJobs[name].filter(
|
|
126
|
+
this.runningJobs[name] = this.runningJobs[name].filter(item => item !== date);
|
|
127
127
|
if (config.throwException) {
|
|
128
128
|
throw e;
|
|
129
129
|
} else {
|
|
@@ -132,7 +132,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// Remove job from running list
|
|
135
|
-
this.runningJobs[name] = this.runningJobs[name].filter(
|
|
135
|
+
this.runningJobs[name] = this.runningJobs[name].filter(item => item !== date);
|
|
136
136
|
},
|
|
137
137
|
null,
|
|
138
138
|
true,
|
|
@@ -140,7 +140,7 @@ export abstract class CoreCronJobs implements OnApplicationBootstrap {
|
|
|
140
140
|
config.context,
|
|
141
141
|
config.runOnInit,
|
|
142
142
|
config.utcOffset,
|
|
143
|
-
config.unrefTimeout
|
|
143
|
+
config.unrefTimeout,
|
|
144
144
|
);
|
|
145
145
|
this.schedulerRegistry.addCronJob(name, job);
|
|
146
146
|
if (this.config.log && this.schedulerRegistry.getCronJob(name)) {
|