@lenne.tech/nest-server 11.0.0 → 11.1.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/core/common/args/filter.args.js +6 -8
- package/dist/core/common/args/filter.args.js.map +1 -1
- package/dist/core/common/args/pagination.args.js +16 -16
- package/dist/core/common/args/pagination.args.js.map +1 -1
- package/dist/core/common/decorators/graphql-service-options.decorator.js +5 -0
- package/dist/core/common/decorators/graphql-service-options.decorator.js.map +1 -1
- package/dist/core/common/decorators/rest-service-options.decorator.d.ts +2 -0
- package/dist/core/common/decorators/rest-service-options.decorator.js +14 -0
- package/dist/core/common/decorators/rest-service-options.decorator.js.map +1 -0
- package/dist/core/common/decorators/restricted.decorator.js +1 -1
- package/dist/core/common/decorators/restricted.decorator.js.map +1 -1
- package/dist/core/common/decorators/translatable.decorator.d.ts +3 -0
- package/dist/core/common/decorators/translatable.decorator.js +22 -0
- package/dist/core/common/decorators/translatable.decorator.js.map +1 -0
- package/dist/core/common/decorators/unified-field.decorator.d.ts +25 -0
- package/dist/core/common/decorators/unified-field.decorator.js +144 -0
- package/dist/core/common/decorators/unified-field.decorator.js.map +1 -0
- package/dist/core/common/helpers/config.helper.js +1 -1
- package/dist/core/common/helpers/config.helper.js.map +1 -1
- package/dist/core/common/helpers/db.helper.js +1 -1
- package/dist/core/common/helpers/db.helper.js.map +1 -1
- package/dist/core/common/helpers/graphql.helper.js.map +1 -1
- package/dist/core/common/helpers/input.helper.js +2 -2
- package/dist/core/common/helpers/input.helper.js.map +1 -1
- package/dist/core/common/helpers/service.helper.d.ts +1 -0
- package/dist/core/common/helpers/service.helper.js +14 -2
- package/dist/core/common/helpers/service.helper.js.map +1 -1
- package/dist/core/common/inputs/combined-filter.input.js +8 -4
- package/dist/core/common/inputs/combined-filter.input.js.map +1 -1
- package/dist/core/common/inputs/filter.input.js +10 -7
- package/dist/core/common/inputs/filter.input.js.map +1 -1
- package/dist/core/common/inputs/single-filter.input.js +26 -18
- package/dist/core/common/inputs/single-filter.input.js.map +1 -1
- package/dist/core/common/inputs/sort.input.js +10 -4
- package/dist/core/common/inputs/sort.input.js.map +1 -1
- package/dist/core/common/models/core-persistence.model.js +18 -11
- package/dist/core/common/models/core-persistence.model.js.map +1 -1
- package/dist/core/common/pipes/map-and-validate.pipe.js +12 -3
- package/dist/core/common/pipes/map-and-validate.pipe.js.map +1 -1
- package/dist/core/common/services/brevo.service.js +1 -1
- package/dist/core/common/services/brevo.service.js.map +1 -1
- package/dist/core/common/services/config.service.js +1 -1
- package/dist/core/common/services/config.service.js.map +1 -1
- package/dist/core/common/services/email.service.js +1 -1
- package/dist/core/common/services/email.service.js.map +1 -1
- package/dist/core/common/services/model-doc.service.js +1 -1
- package/dist/core/common/services/model-doc.service.js.map +1 -1
- package/dist/core/common/services/module.service.js +2 -1
- package/dist/core/common/services/module.service.js.map +1 -1
- package/dist/core/common/services/template.service.js +2 -2
- package/dist/core/common/services/template.service.js.map +1 -1
- package/dist/core/modules/auth/core-auth.model.js +10 -11
- package/dist/core/modules/auth/core-auth.model.js.map +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js +1 -1
- package/dist/core/modules/auth/guards/auth.guard.js.map +1 -1
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js +25 -21
- package/dist/core/modules/auth/inputs/core-auth-sign-in.input.js.map +1 -1
- package/dist/core/modules/auth/services/core-auth.service.js +1 -1
- package/dist/core/modules/auth/services/core-auth.service.js.map +1 -1
- package/dist/core/modules/health-check/core-health-check-result.model.js +18 -11
- package/dist/core/modules/health-check/core-health-check-result.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-create.input.js +6 -3
- package/dist/core/modules/user/inputs/core-user-create.input.js.map +1 -1
- package/dist/core/modules/user/inputs/core-user.input.js +32 -18
- package/dist/core/modules/user/inputs/core-user.input.js.map +1 -1
- package/dist/core.module.js +1 -1
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/server/common/models/persistence.model.js +1 -1
- package/dist/server/common/models/persistence.model.js.map +1 -1
- package/dist/server/modules/auth/inputs/auth-sign-up.input.js +11 -4
- package/dist/server/modules/auth/inputs/auth-sign-up.input.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/user/outputs/find-and-count-users-result.output.js +11 -4
- package/dist/server/modules/user/outputs/find-and-count-users-result.output.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/test/test.helper.js +1 -1
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/core/common/args/filter.args.ts +7 -10
- package/src/core/common/args/pagination.args.ts +17 -17
- package/src/core/common/decorators/graphql-service-options.decorator.ts +8 -0
- package/src/core/common/decorators/rest-service-options.decorator.ts +22 -0
- package/src/core/common/decorators/restricted.decorator.ts +1 -2
- package/src/core/common/decorators/translatable.decorator.ts +24 -0
- package/src/core/common/decorators/unified-field.decorator.ts +243 -0
- package/src/core/common/helpers/config.helper.ts +1 -4
- package/src/core/common/helpers/db.helper.ts +1 -2
- package/src/core/common/helpers/graphql.helper.ts +0 -1
- package/src/core/common/helpers/input.helper.ts +2 -3
- package/src/core/common/helpers/service.helper.ts +18 -3
- package/src/core/common/inputs/combined-filter.input.ts +9 -5
- package/src/core/common/inputs/filter.input.ts +14 -11
- package/src/core/common/inputs/single-filter.input.ts +28 -19
- package/src/core/common/inputs/sort.input.ts +11 -5
- package/src/core/common/models/core-persistence.model.ts +19 -12
- package/src/core/common/pipes/map-and-validate.pipe.ts +15 -4
- package/src/core/common/services/brevo.service.ts +1 -2
- package/src/core/common/services/config.service.ts +1 -2
- package/src/core/common/services/email.service.ts +1 -2
- package/src/core/common/services/model-doc.service.ts +1 -2
- package/src/core/common/services/module.service.ts +2 -2
- package/src/core/common/services/template.service.ts +2 -3
- package/src/core/modules/auth/core-auth.model.ts +11 -12
- package/src/core/modules/auth/guards/auth.guard.ts +1 -2
- package/src/core/modules/auth/inputs/core-auth-sign-in.input.ts +27 -23
- package/src/core/modules/auth/services/core-auth.service.ts +1 -2
- package/src/core/modules/health-check/core-health-check-result.model.ts +19 -12
- package/src/core/modules/user/core-user.service.ts +2 -3
- package/src/core/modules/user/inputs/core-user-create.input.ts +7 -4
- package/src/core/modules/user/inputs/core-user.input.ts +34 -20
- package/src/core.module.ts +1 -2
- package/src/index.ts +3 -0
- package/src/main.ts +2 -3
- package/src/server/common/models/persistence.model.ts +1 -2
- package/src/server/modules/auth/inputs/auth-sign-up.input.ts +12 -5
- package/src/server/modules/file/file.resolver.ts +2 -3
- package/src/server/modules/user/outputs/find-and-count-users-result.output.ts +12 -5
- package/src/server/modules/user/user.service.ts +1 -2
- package/src/test/test.helper.ts +2 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
3
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../decorators/unified-field.decorator';
|
|
4
5
|
import { LogicalOperatorEnum } from '../enums/logical-operator.enum';
|
|
5
6
|
import { RoleEnum } from '../enums/role.enum';
|
|
6
7
|
import { maps } from '../helpers/model.helper';
|
|
@@ -15,19 +16,22 @@ export class CombinedFilterInput extends CoreInput {
|
|
|
15
16
|
/**
|
|
16
17
|
* Logical Operator to combine filters
|
|
17
18
|
*/
|
|
18
|
-
@
|
|
19
|
+
@UnifiedField({
|
|
19
20
|
description: 'Logical Operator to combine filters',
|
|
21
|
+
enum: { enum: LogicalOperatorEnum },
|
|
22
|
+
roles: RoleEnum.S_EVERYONE,
|
|
20
23
|
})
|
|
21
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
22
24
|
logicalOperator: LogicalOperatorEnum = undefined;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Filters to combine via logical operator
|
|
26
28
|
*/
|
|
27
|
-
@
|
|
29
|
+
@UnifiedField({
|
|
28
30
|
description: 'Filters to combine via logical operator',
|
|
31
|
+
isOptional: true,
|
|
32
|
+
roles: RoleEnum.S_EVERYONE,
|
|
33
|
+
type: () => FilterInput,
|
|
29
34
|
})
|
|
30
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
31
35
|
filters: FilterInput[] = undefined;
|
|
32
36
|
|
|
33
37
|
// ===================================================================================================================
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
3
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../decorators/unified-field.decorator';
|
|
4
5
|
import { RoleEnum } from '../enums/role.enum';
|
|
5
6
|
import { CombinedFilterInput } from './combined-filter.input';
|
|
6
7
|
import { CoreInput } from './core-input.input';
|
|
@@ -17,21 +18,23 @@ export class FilterInput extends CoreInput {
|
|
|
17
18
|
/**
|
|
18
19
|
* Combination of multiple filters via logical operator
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
@UnifiedField({
|
|
22
|
+
description: 'Filter for a single property',
|
|
23
|
+
isOptional: true,
|
|
24
|
+
roles: RoleEnum.S_EVERYONE,
|
|
25
|
+
type: CombinedFilterInput,
|
|
26
|
+
})
|
|
25
27
|
combinedFilter?: CombinedFilterInput = undefined;
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Filter for a single property
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
@UnifiedField({
|
|
33
|
+
description: 'Filter for a single property',
|
|
34
|
+
isOptional: true,
|
|
35
|
+
roles: RoleEnum.S_EVERYONE,
|
|
36
|
+
type: SingleFilterInput,
|
|
37
|
+
})
|
|
35
38
|
singleFilter?: SingleFilterInput = undefined;
|
|
36
39
|
|
|
37
40
|
// ===================================================================================================================
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
3
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../decorators/unified-field.decorator';
|
|
4
5
|
import { ComparisonOperatorEnum } from '../enums/comparison-operator.enum';
|
|
5
6
|
import { RoleEnum } from '../enums/role.enum';
|
|
6
7
|
import { JSON } from '../scalars/json.scalar';
|
|
@@ -15,63 +16,71 @@ export class SingleFilterInput extends CoreInput {
|
|
|
15
16
|
/**
|
|
16
17
|
* Convert value to ObjectId
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
@UnifiedField({
|
|
19
21
|
description: 'Convert value to ObjectId',
|
|
20
|
-
|
|
22
|
+
isOptional: true,
|
|
23
|
+
roles: RoleEnum.S_EVERYONE,
|
|
21
24
|
})
|
|
22
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
23
25
|
convertToObjectId?: boolean = undefined;
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Name of the property to be used for the filter
|
|
27
29
|
*/
|
|
28
|
-
@
|
|
29
|
-
|
|
30
|
+
@UnifiedField({
|
|
31
|
+
description: 'Name of the property to be used for the filter',
|
|
32
|
+
roles: RoleEnum.S_EVERYONE,
|
|
33
|
+
})
|
|
30
34
|
field: string = undefined;
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* Process value as reference
|
|
34
38
|
*/
|
|
35
|
-
@
|
|
39
|
+
@UnifiedField({
|
|
36
40
|
description: 'Process value as reference',
|
|
37
|
-
|
|
41
|
+
isOptional: true,
|
|
42
|
+
roles: RoleEnum.S_EVERYONE,
|
|
38
43
|
})
|
|
39
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
40
44
|
isReference?: boolean = undefined;
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* [Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)
|
|
44
48
|
*/
|
|
45
|
-
@
|
|
49
|
+
@UnifiedField({
|
|
46
50
|
description: '[Negate operator](https://docs.mongodb.com/manual/reference/operator/query/not/)',
|
|
47
|
-
|
|
51
|
+
isOptional: true,
|
|
52
|
+
roles: RoleEnum.S_EVERYONE,
|
|
48
53
|
})
|
|
49
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
50
54
|
not?: boolean = undefined;
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
57
|
* [Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)
|
|
54
58
|
*/
|
|
55
|
-
@
|
|
59
|
+
@UnifiedField({
|
|
56
60
|
description: '[Comparison operator](https://docs.mongodb.com/manual/reference/operator/query-comparison/)',
|
|
61
|
+
enum: { enum: ComparisonOperatorEnum },
|
|
62
|
+
roles: RoleEnum.S_EVERYONE,
|
|
57
63
|
})
|
|
58
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
59
64
|
operator: ComparisonOperatorEnum = undefined;
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
67
|
* [Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for
|
|
63
68
|
* [REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator
|
|
64
69
|
*/
|
|
65
|
-
@
|
|
70
|
+
@UnifiedField({
|
|
66
71
|
description:
|
|
67
72
|
'[Options](https://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_options) for '
|
|
68
73
|
+ '[REGEX](https://docs.mongodb.com/manual/reference/operator/query/regex/) operator',
|
|
69
|
-
|
|
74
|
+
isOptional: true,
|
|
75
|
+
roles: RoleEnum.S_EVERYONE,
|
|
70
76
|
})
|
|
71
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
72
77
|
options?: string = undefined;
|
|
73
78
|
|
|
74
|
-
@
|
|
75
|
-
|
|
79
|
+
@UnifiedField({
|
|
80
|
+
description: 'Value of the property',
|
|
81
|
+
isOptional: true,
|
|
82
|
+
roles: RoleEnum.S_EVERYONE,
|
|
83
|
+
type: () => JSON,
|
|
84
|
+
})
|
|
76
85
|
value: any = undefined;
|
|
77
86
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
3
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../decorators/unified-field.decorator';
|
|
4
5
|
import { RoleEnum } from '../enums/role.enum';
|
|
5
6
|
import { SortOrderEnum } from '../enums/sort-order.emum';
|
|
6
7
|
import { CoreInput } from './core-input.input';
|
|
@@ -14,14 +15,19 @@ export class SortInput extends CoreInput {
|
|
|
14
15
|
/**
|
|
15
16
|
* Field that is to be used for sorting
|
|
16
17
|
*/
|
|
17
|
-
@
|
|
18
|
-
|
|
18
|
+
@UnifiedField({
|
|
19
|
+
description: 'Field that is to be used for sorting',
|
|
20
|
+
roles: RoleEnum.S_EVERYONE,
|
|
21
|
+
})
|
|
19
22
|
field: string = undefined;
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* SortInput order of the field
|
|
23
26
|
*/
|
|
24
|
-
@
|
|
25
|
-
|
|
27
|
+
@UnifiedField({
|
|
28
|
+
description: 'SortInput order of the field',
|
|
29
|
+
enum: { enum: SortOrderEnum },
|
|
30
|
+
roles: RoleEnum.S_EVERYONE,
|
|
31
|
+
})
|
|
26
32
|
order: SortOrderEnum = undefined;
|
|
27
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectType } from '@nestjs/graphql';
|
|
2
2
|
import { Prop, Schema } from '@nestjs/mongoose';
|
|
3
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
4
3
|
import { Types } from 'mongoose';
|
|
5
4
|
|
|
6
5
|
import { Restricted } from '../decorators/restricted.decorator';
|
|
6
|
+
import { UnifiedField } from '../decorators/unified-field.decorator';
|
|
7
7
|
import { RoleEnum } from '../enums/role.enum';
|
|
8
8
|
import { getStringIds } from '../helpers/db.helper';
|
|
9
9
|
import { CoreModel } from './core-model.model';
|
|
@@ -43,30 +43,37 @@ export abstract class CorePersistenceModel extends CoreModel {
|
|
|
43
43
|
/**
|
|
44
44
|
* ID of the persistence object as string
|
|
45
45
|
*/
|
|
46
|
-
@
|
|
47
|
-
@Field(() => ID, {
|
|
46
|
+
@UnifiedField({
|
|
48
47
|
description: 'ID of the persistence object',
|
|
49
|
-
|
|
48
|
+
isOptional: true,
|
|
49
|
+
roles: RoleEnum.S_EVERYONE,
|
|
50
50
|
})
|
|
51
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
52
51
|
id: string = undefined;
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* Created date, is set automatically by mongoose
|
|
56
55
|
*/
|
|
57
|
-
@ApiProperty({ example: 1740037703939, format: 'int64', type: Date })
|
|
58
|
-
@Field({ description: 'Created date', nullable: true })
|
|
59
56
|
@Prop({ onCreate: () => new Date() })
|
|
60
|
-
@
|
|
57
|
+
@UnifiedField({
|
|
58
|
+
description: 'Created date',
|
|
59
|
+
isOptional: true,
|
|
60
|
+
roles: RoleEnum.S_EVERYONE,
|
|
61
|
+
swaggerApiOptions: { example: 1740037703939, format: 'int64', type: Date },
|
|
62
|
+
type: Date,
|
|
63
|
+
})
|
|
61
64
|
createdAt: Date = undefined;
|
|
62
65
|
|
|
63
66
|
/**
|
|
64
67
|
* Updated date is set automatically by mongoose
|
|
65
68
|
*/
|
|
66
|
-
@ApiProperty({ example: 1740037703939, format: 'int64', type: String })
|
|
67
|
-
@Field({ description: 'Updated date', nullable: true })
|
|
68
69
|
@Prop({ onUpdate: () => new Date() })
|
|
69
|
-
@
|
|
70
|
+
@UnifiedField({
|
|
71
|
+
description: 'Updated date',
|
|
72
|
+
isOptional: true,
|
|
73
|
+
roles: RoleEnum.S_EVERYONE,
|
|
74
|
+
swaggerApiOptions: { example: 1740037703939, format: 'int64', type: Date },
|
|
75
|
+
type: Date,
|
|
76
|
+
})
|
|
70
77
|
updatedAt: Date = undefined;
|
|
71
78
|
|
|
72
79
|
// ===========================================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArgumentMetadata, BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
|
|
2
2
|
import { plainToInstance } from 'class-transformer';
|
|
3
|
-
import { validate } from 'class-validator';
|
|
3
|
+
import { validate, ValidationError } from 'class-validator';
|
|
4
4
|
|
|
5
5
|
import { isBasicType } from '../helpers/input.helper';
|
|
6
6
|
|
|
@@ -26,9 +26,20 @@ export class MapAndValidatePipe implements PipeTransform {
|
|
|
26
26
|
const errors = await validate(value, { forbidUnknownValues: false });
|
|
27
27
|
if (errors.length > 0) {
|
|
28
28
|
const result = {};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
|
|
30
|
+
const processErrors = (errorList: ValidationError[], parentKey = '') => {
|
|
31
|
+
errorList.forEach((e) => {
|
|
32
|
+
const key = parentKey ? `${parentKey}.${e.property}` : e.property;
|
|
33
|
+
|
|
34
|
+
if (e.children && e.children.length > 0) {
|
|
35
|
+
processErrors(e.children, key);
|
|
36
|
+
} else {
|
|
37
|
+
result[key] = e.constraints;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
processErrors(errors);
|
|
32
43
|
throw new BadRequestException(result);
|
|
33
44
|
}
|
|
34
45
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash';
|
|
2
|
+
import _ = require('lodash');
|
|
2
3
|
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
|
3
4
|
import { filter, map } from 'rxjs/operators';
|
|
4
5
|
|
|
@@ -6,8 +7,6 @@ import { merge } from '../helpers/config.helper';
|
|
|
6
7
|
import { clone, deepFreeze } from '../helpers/input.helper';
|
|
7
8
|
import { IServerOptions } from '../interfaces/server-options.interface';
|
|
8
9
|
|
|
9
|
-
import _ = require('lodash');
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Config service can be used as provider (after initialization in CoreModule.forRoot)
|
|
13
12
|
*
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import nodemailer = require('nodemailer');
|
|
2
3
|
import { Attachment } from 'nodemailer/lib/mailer';
|
|
3
4
|
|
|
4
5
|
import { isNonEmptyString, isTrue, returnFalse } from '../helpers/input.helper';
|
|
5
6
|
import { ConfigService } from './config.service';
|
|
6
7
|
import { TemplateService } from './template.service';
|
|
7
8
|
|
|
8
|
-
import nodemailer = require('nodemailer');
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* Email service
|
|
12
11
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
2
|
import { InjectConnection } from '@nestjs/mongoose';
|
|
3
|
-
import { Connection } from 'mongoose';
|
|
4
|
-
|
|
5
3
|
import fs = require('fs');
|
|
4
|
+
import { Connection } from 'mongoose';
|
|
6
5
|
import YumlDiagram = require('yuml-diagram');
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ = require('lodash');
|
|
1
2
|
import { Document, Model, Types } from 'mongoose';
|
|
2
3
|
|
|
3
4
|
import { ProcessType } from '../enums/process-type.enum';
|
|
@@ -9,8 +10,6 @@ import { CoreModel } from '../models/core-model.model';
|
|
|
9
10
|
import { FieldSelection } from '../types/field-selection.type';
|
|
10
11
|
import { ConfigService } from './config.service';
|
|
11
12
|
|
|
12
|
-
import _ = require('lodash');
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* Module service class to be extended by concrete module services
|
|
16
15
|
*/
|
|
@@ -258,6 +257,7 @@ export abstract class ModuleService<T extends CoreModel = any> {
|
|
|
258
257
|
*/
|
|
259
258
|
async prepareOutput(output: any, options: ServiceOptions = {}) {
|
|
260
259
|
const config = {
|
|
260
|
+
language: options?.language,
|
|
261
261
|
targetModel: this.mainModelConstructor,
|
|
262
262
|
...options?.prepareOutput,
|
|
263
263
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { TemplateFunction } from 'ejs';
|
|
3
|
+
import ejs = require('ejs');
|
|
4
|
+
import fs = require('fs');
|
|
3
5
|
import { join } from 'path';
|
|
4
6
|
|
|
5
7
|
import { ConfigService } from './config.service';
|
|
6
8
|
|
|
7
|
-
import ejs = require('ejs');
|
|
8
|
-
import fs = require('fs');
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* Template service
|
|
12
11
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
1
|
+
import { ObjectType } from '@nestjs/graphql';
|
|
3
2
|
|
|
4
3
|
import { Restricted } from '../../common/decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../../common/decorators/unified-field.decorator';
|
|
5
5
|
import { RoleEnum } from '../../common/enums/role.enum';
|
|
6
6
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
7
7
|
import { CoreUserModel } from '../user/core-user.model';
|
|
@@ -19,35 +19,34 @@ export class CoreAuthModel extends CoreModel {
|
|
|
19
19
|
/**
|
|
20
20
|
* JSON Web Token(JWT)
|
|
21
21
|
*/
|
|
22
|
-
@
|
|
22
|
+
@UnifiedField({
|
|
23
23
|
description: 'JSON Web Token(JWT) used for auth',
|
|
24
24
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
25
|
+
isOptional: true,
|
|
26
|
+
roles: RoleEnum.S_EVERYONE,
|
|
25
27
|
})
|
|
26
|
-
@Field({ description: 'JSON Web Token(JWT)', nullable: true })
|
|
27
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
28
28
|
token?: string = undefined;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Refresh token
|
|
32
32
|
*/
|
|
33
|
-
@
|
|
33
|
+
@UnifiedField({
|
|
34
34
|
description: 'Refresh JSON Web Token(JWT) used for auth',
|
|
35
35
|
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
36
|
+
isOptional: true,
|
|
37
|
+
roles: RoleEnum.S_EVERYONE,
|
|
36
38
|
})
|
|
37
|
-
@Field({ description: 'Refresh token', nullable: true })
|
|
38
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
39
39
|
refreshToken?: string = undefined;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Current user
|
|
43
43
|
*/
|
|
44
|
-
@
|
|
44
|
+
@UnifiedField({
|
|
45
45
|
description: 'User who signed in',
|
|
46
|
-
|
|
46
|
+
isOptional: false,
|
|
47
|
+
roles: RoleEnum.S_EVERYONE,
|
|
47
48
|
type: () => CoreUserModel,
|
|
48
49
|
})
|
|
49
|
-
@Field({ description: 'Current user' })
|
|
50
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
51
50
|
user: CoreUserModel = undefined;
|
|
52
51
|
|
|
53
52
|
// ===================================================================================================================
|
|
@@ -3,14 +3,13 @@ import { GqlExecutionContext } from '@nestjs/graphql';
|
|
|
3
3
|
import { AuthModuleOptions, Type } from '@nestjs/passport';
|
|
4
4
|
import { defaultOptions } from '@nestjs/passport/dist/options';
|
|
5
5
|
import { memoize } from '@nestjs/passport/dist/utils/memoize.util';
|
|
6
|
+
import passport = require('passport');
|
|
6
7
|
|
|
7
8
|
import { AuthGuardStrategy } from '../auth-guard-strategy.enum';
|
|
8
9
|
import { ExpiredRefreshTokenException } from '../exceptions/expired-refresh-token.exception';
|
|
9
10
|
import { ExpiredTokenException } from '../exceptions/expired-token.exception';
|
|
10
11
|
import { InvalidTokenException } from '../exceptions/invalid-token.exception';
|
|
11
12
|
|
|
12
|
-
import passport = require('passport');
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* Missing strategy error
|
|
16
15
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
|
+
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
|
4
3
|
|
|
5
4
|
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
5
|
+
import { UnifiedField } from '../../../common/decorators/unified-field.decorator';
|
|
6
6
|
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
7
7
|
import { CoreInput } from '../../../common/inputs/core-input.input';
|
|
8
8
|
|
|
@@ -16,31 +16,35 @@ export class CoreAuthSignInInput extends CoreInput {
|
|
|
16
16
|
// Properties
|
|
17
17
|
// ===================================================================================================================
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
@UnifiedField({
|
|
20
|
+
description: 'Device ID (is created automatically if it is not set)',
|
|
21
|
+
isOptional: true,
|
|
22
|
+
roles: RoleEnum.S_EVERYONE,
|
|
23
|
+
validator: () => [IsString()],
|
|
24
|
+
})
|
|
24
25
|
deviceId?: string = undefined;
|
|
25
26
|
|
|
26
|
-
@
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
@UnifiedField({
|
|
28
|
+
description: 'Device description',
|
|
29
|
+
isOptional: true,
|
|
30
|
+
roles: RoleEnum.S_EVERYONE,
|
|
31
|
+
validator: () => [IsString()],
|
|
32
|
+
})
|
|
31
33
|
deviceDescription?: string = undefined;
|
|
32
34
|
|
|
33
|
-
@
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
@UnifiedField({
|
|
36
|
+
description: 'Email',
|
|
37
|
+
isOptional: false,
|
|
38
|
+
roles: RoleEnum.S_EVERYONE,
|
|
39
|
+
validator: () => [IsEmail(), IsString(), IsNotEmpty()],
|
|
40
|
+
})
|
|
38
41
|
email: string = undefined;
|
|
39
42
|
|
|
40
|
-
@
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
@UnifiedField({
|
|
44
|
+
description: 'Password',
|
|
45
|
+
isOptional: false,
|
|
46
|
+
roles: RoleEnum.S_EVERYONE,
|
|
47
|
+
validator: () => [IsString(), IsNotEmpty()],
|
|
48
|
+
})
|
|
45
49
|
password: string = undefined;
|
|
46
50
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BadRequestException, Injectable, UnauthorizedException } from '@nestjs/common';
|
|
2
2
|
import { JwtService } from '@nestjs/jwt';
|
|
3
|
+
import bcrypt = require('bcrypt');
|
|
3
4
|
import { randomUUID } from 'crypto';
|
|
4
5
|
import { sha256 } from 'js-sha256';
|
|
5
6
|
|
|
@@ -14,8 +15,6 @@ import { ICoreAuthUser } from '../interfaces/core-auth-user.interface';
|
|
|
14
15
|
import { JwtPayload } from '../interfaces/jwt-payload.interface';
|
|
15
16
|
import { CoreAuthUserService } from './core-auth-user.service';
|
|
16
17
|
|
|
17
|
-
import bcrypt = require('bcrypt');
|
|
18
|
-
|
|
19
18
|
/**
|
|
20
19
|
* CoreAuthService to handle user authentication
|
|
21
20
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectType } from '@nestjs/graphql';
|
|
2
2
|
|
|
3
3
|
import { Restricted } from '../../common/decorators/restricted.decorator';
|
|
4
|
+
import { UnifiedField } from '../../common/decorators/unified-field.decorator';
|
|
4
5
|
import { RoleEnum } from '../../common/enums/role.enum';
|
|
5
6
|
import { CoreModel } from '../../common/models/core-model.model';
|
|
6
7
|
import { JSON } from '../../common/scalars/json.scalar';
|
|
@@ -18,37 +19,43 @@ export abstract class CoreHealthCheckResult extends CoreModel {
|
|
|
18
19
|
/**
|
|
19
20
|
* The overall status of the Health Check
|
|
20
21
|
*/
|
|
21
|
-
@
|
|
22
|
-
|
|
22
|
+
@UnifiedField({
|
|
23
|
+
description: 'The overall status of the Health Check',
|
|
24
|
+
isOptional: false,
|
|
25
|
+
roles: RoleEnum.S_EVERYONE,
|
|
26
|
+
})
|
|
23
27
|
status: 'error' | 'ok' | 'shutting_down' = undefined;
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* The info object contains information of each health indicator which is of status “up”
|
|
27
31
|
*/
|
|
28
|
-
@
|
|
32
|
+
@UnifiedField({
|
|
29
33
|
description: 'The info object contains information of each health indicator which is of status “up”',
|
|
30
|
-
|
|
34
|
+
isOptional: true,
|
|
35
|
+
roles: RoleEnum.S_EVERYONE,
|
|
36
|
+
type: () => JSON,
|
|
31
37
|
})
|
|
32
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
33
38
|
info: JSON = undefined;
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* The error object contains information of each health indicator which is of status “down”
|
|
37
42
|
*/
|
|
38
|
-
@
|
|
43
|
+
@UnifiedField({
|
|
39
44
|
description: 'The error object contains information of each health indicator which is of status “down”',
|
|
40
|
-
|
|
45
|
+
isOptional: true,
|
|
46
|
+
roles: RoleEnum.S_EVERYONE,
|
|
47
|
+
type: () => JSON,
|
|
41
48
|
})
|
|
42
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
43
49
|
error: JSON = undefined;
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* The details object contains information of every health indicator
|
|
47
53
|
*/
|
|
48
|
-
@
|
|
54
|
+
@UnifiedField({
|
|
49
55
|
description: 'The details object contains information of every health indicator',
|
|
50
|
-
|
|
56
|
+
isOptional: true,
|
|
57
|
+
roles: RoleEnum.S_EVERYONE,
|
|
58
|
+
type: () => JSON,
|
|
51
59
|
})
|
|
52
|
-
@Restricted(RoleEnum.S_EVERYONE)
|
|
53
60
|
details: JSON = undefined;
|
|
54
61
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BadRequestException, NotFoundException, UnprocessableEntityException } from '@nestjs/common';
|
|
2
|
+
import bcrypt = require('bcrypt');
|
|
3
|
+
import crypto = require('crypto');
|
|
2
4
|
import { sha256 } from 'js-sha256';
|
|
3
5
|
import { Document, Model } from 'mongoose';
|
|
4
6
|
|
|
@@ -12,9 +14,6 @@ import { CoreUserModel } from './core-user.model';
|
|
|
12
14
|
import { CoreUserCreateInput } from './inputs/core-user-create.input';
|
|
13
15
|
import { CoreUserInput } from './inputs/core-user.input';
|
|
14
16
|
|
|
15
|
-
import bcrypt = require('bcrypt');
|
|
16
|
-
import crypto = require('crypto');
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* User service
|
|
20
19
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputType } from '@nestjs/graphql';
|
|
2
2
|
import { IsEmail } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
import { Restricted } from '../../../common/decorators/restricted.decorator';
|
|
5
|
+
import { UnifiedField } from '../../../common/decorators/unified-field.decorator';
|
|
5
6
|
import { RoleEnum } from '../../../common/enums/role.enum';
|
|
6
7
|
import { CoreUserInput } from './core-user.input';
|
|
7
8
|
|
|
@@ -15,8 +16,10 @@ import { CoreUserInput } from './core-user.input';
|
|
|
15
16
|
@InputType({ description: 'User input to create a new user', isAbstract: true })
|
|
16
17
|
@Restricted(RoleEnum.S_EVERYONE)
|
|
17
18
|
export abstract class CoreUserCreateInput extends CoreUserInput {
|
|
18
|
-
@
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
@UnifiedField({
|
|
20
|
+
description: 'Email of the user',
|
|
21
|
+
roles: RoleEnum.S_EVERYONE,
|
|
22
|
+
validator: () => [IsEmail()],
|
|
23
|
+
})
|
|
21
24
|
override email: string = undefined;
|
|
22
25
|
}
|