@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,96 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Filter = void 0;
|
|
3
|
+
exports.generateFindOptions = exports.generateFilterQuery = exports.convertFilterArgsToQuery = exports.Filter = void 0;
|
|
4
4
|
const comparison_operator_enum_1 = require("../enums/comparison-operator.enum");
|
|
5
5
|
const logical_operator_enum_1 = require("../enums/logical-operator.enum");
|
|
6
6
|
class Filter {
|
|
7
7
|
static convertFilterArgsToQuery(filterArgs) {
|
|
8
|
-
return
|
|
8
|
+
return convertFilterArgsToQuery(filterArgs);
|
|
9
9
|
}
|
|
10
10
|
static generateFilterQuery(filter) {
|
|
11
|
-
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
const result = {};
|
|
15
|
-
if (filter.combinedFilter) {
|
|
16
|
-
switch (filter.combinedFilter.logicalOperator) {
|
|
17
|
-
case logical_operator_enum_1.LogicalOperatorEnum.AND:
|
|
18
|
-
return {
|
|
19
|
-
$and: filter.combinedFilter.filters.map((item) => Filter.generateFilterQuery(item)),
|
|
20
|
-
};
|
|
21
|
-
case logical_operator_enum_1.LogicalOperatorEnum.NOR:
|
|
22
|
-
return {
|
|
23
|
-
$nor: filter.combinedFilter.filters.map((item) => Filter.generateFilterQuery(item)),
|
|
24
|
-
};
|
|
25
|
-
case logical_operator_enum_1.LogicalOperatorEnum.OR:
|
|
26
|
-
return {
|
|
27
|
-
$or: filter.combinedFilter.filters.map((item) => Filter.generateFilterQuery(item)),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (filter.singleFilter) {
|
|
32
|
-
const { not, options, field, value } = filter.singleFilter;
|
|
33
|
-
switch (filter.singleFilter.operator) {
|
|
34
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.EQ:
|
|
35
|
-
result[field] = not ? { $ne: value } : value;
|
|
36
|
-
break;
|
|
37
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.GT:
|
|
38
|
-
result[field] = not ? { $not: { $gt: value } } : { $gt: value };
|
|
39
|
-
break;
|
|
40
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.GTE:
|
|
41
|
-
result[field] = not ? { $not: { $gte: value } } : { $gte: value };
|
|
42
|
-
break;
|
|
43
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.IN:
|
|
44
|
-
result[field] = not ? { $nin: value } : { $in: value };
|
|
45
|
-
break;
|
|
46
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.LT:
|
|
47
|
-
result[field] = not ? { $not: { $lt: value } } : { $lt: value };
|
|
48
|
-
break;
|
|
49
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.LTE:
|
|
50
|
-
result[field] = not ? { $not: { $lte: value } } : { $lte: value };
|
|
51
|
-
break;
|
|
52
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.NE:
|
|
53
|
-
result[field] = not ? value : { $ne: value };
|
|
54
|
-
break;
|
|
55
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.NIN:
|
|
56
|
-
result[field] = not ? { $in: value } : { $nin: value };
|
|
57
|
-
break;
|
|
58
|
-
case comparison_operator_enum_1.ComparisonOperatorEnum.REGEX:
|
|
59
|
-
result[field] = not
|
|
60
|
-
? {
|
|
61
|
-
$not: {
|
|
62
|
-
$regex: new RegExp(value),
|
|
63
|
-
$options: options || '',
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
: { $regex: new RegExp(value), $options: options || '' };
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
11
|
+
return generateFilterQuery(filter);
|
|
71
12
|
}
|
|
72
13
|
static generateFindOptions(filterArgs) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
14
|
+
return generateFindOptions(filterArgs);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Filter = Filter;
|
|
18
|
+
function convertFilterArgsToQuery(filterArgs) {
|
|
19
|
+
return [generateFilterQuery(filterArgs === null || filterArgs === void 0 ? void 0 : filterArgs.filter), generateFindOptions(filterArgs)];
|
|
20
|
+
}
|
|
21
|
+
exports.convertFilterArgsToQuery = convertFilterArgsToQuery;
|
|
22
|
+
function generateFilterQuery(filter) {
|
|
23
|
+
if (!filter) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const result = {};
|
|
27
|
+
if (filter.combinedFilter) {
|
|
28
|
+
switch (filter.combinedFilter.logicalOperator) {
|
|
29
|
+
case logical_operator_enum_1.LogicalOperatorEnum.AND:
|
|
30
|
+
return {
|
|
31
|
+
$and: filter.combinedFilter.filters.map((item) => generateFilterQuery(item)),
|
|
32
|
+
};
|
|
33
|
+
case logical_operator_enum_1.LogicalOperatorEnum.NOR:
|
|
34
|
+
return {
|
|
35
|
+
$nor: filter.combinedFilter.filters.map((item) => generateFilterQuery(item)),
|
|
36
|
+
};
|
|
37
|
+
case logical_operator_enum_1.LogicalOperatorEnum.OR:
|
|
38
|
+
return {
|
|
39
|
+
$or: filter.combinedFilter.filters.map((item) => generateFilterQuery(item)),
|
|
40
|
+
};
|
|
85
41
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
42
|
+
}
|
|
43
|
+
if (filter.singleFilter) {
|
|
44
|
+
const { not, options, field, value } = filter.singleFilter;
|
|
45
|
+
switch (filter.singleFilter.operator) {
|
|
46
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.EQ:
|
|
47
|
+
result[field] = not ? { $ne: value } : value;
|
|
48
|
+
break;
|
|
49
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.GT:
|
|
50
|
+
result[field] = not ? { $not: { $gt: value } } : { $gt: value };
|
|
51
|
+
break;
|
|
52
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.GTE:
|
|
53
|
+
result[field] = not ? { $not: { $gte: value } } : { $gte: value };
|
|
54
|
+
break;
|
|
55
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.IN:
|
|
56
|
+
result[field] = not ? { $nin: value } : { $in: value };
|
|
57
|
+
break;
|
|
58
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.LT:
|
|
59
|
+
result[field] = not ? { $not: { $lt: value } } : { $lt: value };
|
|
60
|
+
break;
|
|
61
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.LTE:
|
|
62
|
+
result[field] = not ? { $not: { $lte: value } } : { $lte: value };
|
|
63
|
+
break;
|
|
64
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.NE:
|
|
65
|
+
result[field] = not ? value : { $ne: value };
|
|
66
|
+
break;
|
|
67
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.NIN:
|
|
68
|
+
result[field] = not ? { $in: value } : { $nin: value };
|
|
69
|
+
break;
|
|
70
|
+
case comparison_operator_enum_1.ComparisonOperatorEnum.REGEX:
|
|
71
|
+
result[field] = not
|
|
72
|
+
? {
|
|
73
|
+
$not: {
|
|
74
|
+
$regex: new RegExp(value),
|
|
75
|
+
$options: options || '',
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
: { $regex: new RegExp(value), $options: options || '' };
|
|
79
|
+
break;
|
|
91
80
|
}
|
|
92
|
-
return options;
|
|
93
81
|
}
|
|
82
|
+
return result;
|
|
94
83
|
}
|
|
95
|
-
exports.
|
|
84
|
+
exports.generateFilterQuery = generateFilterQuery;
|
|
85
|
+
function generateFindOptions(filterArgs) {
|
|
86
|
+
if (!filterArgs) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
const { limit, offset, skip, sort, take } = filterArgs;
|
|
90
|
+
const options = {
|
|
91
|
+
limit: limit ? limit : take,
|
|
92
|
+
};
|
|
93
|
+
if (skip > 0 || offset > 0) {
|
|
94
|
+
options.skip = offset ? offset : skip;
|
|
95
|
+
}
|
|
96
|
+
if (!options.limit || options.limit > 100) {
|
|
97
|
+
options.limit = 25;
|
|
98
|
+
}
|
|
99
|
+
if (sort) {
|
|
100
|
+
options.sort = {};
|
|
101
|
+
sort.forEach((item) => {
|
|
102
|
+
options.sort[item.field] = item.order;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return options;
|
|
106
|
+
}
|
|
107
|
+
exports.generateFindOptions = generateFindOptions;
|
|
96
108
|
//# sourceMappingURL=filter.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/filter.helper.ts"],"names":[],"mappings":";;;AAEA,gFAA2E;AAC3E,0EAAqE;
|
|
1
|
+
{"version":3,"file":"filter.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/filter.helper.ts"],"names":[],"mappings":";;;AAEA,gFAA2E;AAC3E,0EAAqE;AAQrE,MAAa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AC5B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;KAC5B,CAAC;IAEF,IAAI,IAAI,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;QAC1B,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;KACvC;IAGD,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE;QACzC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;KACpB;IAGD,IAAI,IAAI,EAAE;QACR,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,CAAC,IAAe,EAAE,EAAE;YAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACxC,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAhCD,kDAgCC"}
|
|
@@ -4,7 +4,7 @@ export interface GraphQLFieldsConfig {
|
|
|
4
4
|
excludedFields: string[];
|
|
5
5
|
}
|
|
6
6
|
export declare type ValueNodeWithValueField = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | EnumValueNode;
|
|
7
|
-
export
|
|
7
|
+
export default class GraphQLHelper {
|
|
8
8
|
static isFieldNode(ast: SelectionNode): ast is FieldNode;
|
|
9
9
|
static isValueNodeWithValueField(value: ValueNode): value is ValueNodeWithValueField;
|
|
10
10
|
static isListValueNode(value: ValueNode): value is ListValueNode;
|
|
@@ -29,3 +29,26 @@ export declare class GraphQLHelper {
|
|
|
29
29
|
static isInGraphQLResolveInfo(path: any, info: GraphQLResolveInfo, config?: Partial<GraphQLFieldsConfig>): boolean;
|
|
30
30
|
static isInFields(path: any, fields: any): boolean;
|
|
31
31
|
}
|
|
32
|
+
export declare function isFieldNode(ast: SelectionNode): ast is FieldNode;
|
|
33
|
+
export declare function isValueNodeWithValueField(value: ValueNode): value is ValueNodeWithValueField;
|
|
34
|
+
export declare function isListValueNode(value: ValueNode): value is ListValueNode;
|
|
35
|
+
export declare function getASTSelections(ast: FieldNode): readonly SelectionNode[];
|
|
36
|
+
export declare function getAST(ast: any, info: any): any;
|
|
37
|
+
export declare function getArguments(ast: FieldNode): {
|
|
38
|
+
[x: string]: {
|
|
39
|
+
kind: import("graphql").Kind.VARIABLE | import("graphql").Kind.INT | import("graphql").Kind.FLOAT | import("graphql").Kind.STRING | import("graphql").Kind.BOOLEAN | import("graphql").Kind.NULL | import("graphql").Kind.ENUM | import("graphql").Kind.LIST | import("graphql").Kind.OBJECT;
|
|
40
|
+
value: any;
|
|
41
|
+
};
|
|
42
|
+
}[];
|
|
43
|
+
export declare function getDirectiveValue(directive: DirectiveNode, info: GraphQLResolveInfo): unknown;
|
|
44
|
+
export declare function getDirectiveResults(ast: SelectionNode, info: GraphQLResolveInfo): {
|
|
45
|
+
shouldInclude: unknown;
|
|
46
|
+
shouldSkip: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
shouldSkip: unknown;
|
|
49
|
+
shouldInclude: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare function flattenAST(ast: FieldNode, info: GraphQLResolveInfo, obj?: any, config?: Partial<GraphQLFieldsConfig>): any;
|
|
52
|
+
export declare function getFields(info: GraphQLResolveInfo, obj?: Record<string, any>, config?: Partial<GraphQLFieldsConfig>): any;
|
|
53
|
+
export declare function isInGraphQLResolveInfo(path: any, info: GraphQLResolveInfo, config?: Partial<GraphQLFieldsConfig>): boolean;
|
|
54
|
+
export declare function isInFields(path: any, fields: any): boolean;
|
|
@@ -1,126 +1,174 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isInFields = exports.isInGraphQLResolveInfo = exports.getFields = exports.flattenAST = exports.getDirectiveResults = exports.getDirectiveValue = exports.getArguments = exports.getAST = exports.getASTSelections = exports.isListValueNode = exports.isValueNodeWithValueField = exports.isFieldNode = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
class GraphQLHelper {
|
|
6
6
|
static isFieldNode(ast) {
|
|
7
|
-
return ast
|
|
7
|
+
return isFieldNode(ast);
|
|
8
8
|
}
|
|
9
9
|
static isValueNodeWithValueField(value) {
|
|
10
|
-
return value
|
|
10
|
+
return isValueNodeWithValueField(value);
|
|
11
11
|
}
|
|
12
12
|
static isListValueNode(value) {
|
|
13
|
-
return value
|
|
13
|
+
return isListValueNode(value);
|
|
14
14
|
}
|
|
15
15
|
static getSelections(ast) {
|
|
16
|
-
|
|
17
|
-
return ast.selectionSet.selections;
|
|
18
|
-
}
|
|
19
|
-
return [];
|
|
16
|
+
return getASTSelections(ast);
|
|
20
17
|
}
|
|
21
18
|
static getAST(ast, info) {
|
|
22
|
-
|
|
23
|
-
const fragmentName = ast.name.value;
|
|
24
|
-
return info.fragments[fragmentName];
|
|
25
|
-
}
|
|
26
|
-
return ast;
|
|
19
|
+
return getAST(ast, info);
|
|
27
20
|
}
|
|
28
21
|
static getArguments(ast) {
|
|
29
|
-
|
|
30
|
-
return (_a = ast.arguments) === null || _a === void 0 ? void 0 : _a.map((argument) => {
|
|
31
|
-
const valueNode = argument.value;
|
|
32
|
-
const argumentValue = !GraphQLHelper.isListValueNode(valueNode)
|
|
33
|
-
? valueNode.value
|
|
34
|
-
: valueNode.values.map((value) => value.value);
|
|
35
|
-
return {
|
|
36
|
-
[argument.name.value]: {
|
|
37
|
-
kind: argument.value.kind,
|
|
38
|
-
value: argumentValue,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
});
|
|
22
|
+
return getArguments(ast);
|
|
42
23
|
}
|
|
43
24
|
static getDirectiveValue(directive, info) {
|
|
44
|
-
|
|
45
|
-
const arg = (_a = directive.arguments) === null || _a === void 0 ? void 0 : _a[0];
|
|
46
|
-
if (!arg) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (arg.value.kind !== 'Variable') {
|
|
50
|
-
const valueNode = arg.value;
|
|
51
|
-
return GraphQLHelper.isValueNodeWithValueField(valueNode) ? !!valueNode.value : false;
|
|
52
|
-
}
|
|
53
|
-
return info.variableValues[arg.value.name.value];
|
|
25
|
+
return getDirectiveValue(directive, info);
|
|
54
26
|
}
|
|
55
27
|
static getDirectiveResults(ast, info) {
|
|
56
|
-
|
|
57
|
-
const directiveResult = {
|
|
58
|
-
shouldInclude: true,
|
|
59
|
-
shouldSkip: false,
|
|
60
|
-
};
|
|
61
|
-
return (_a = ast.directives) === null || _a === void 0 ? void 0 : _a.reduce((result, directive) => {
|
|
62
|
-
switch (directive.name.value) {
|
|
63
|
-
case 'include':
|
|
64
|
-
return Object.assign(Object.assign({}, result), { shouldInclude: GraphQLHelper.getDirectiveValue(directive, info) });
|
|
65
|
-
case 'skip':
|
|
66
|
-
return Object.assign(Object.assign({}, result), { shouldSkip: GraphQLHelper.getDirectiveValue(directive, info) });
|
|
67
|
-
default:
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
}, directiveResult);
|
|
28
|
+
return getDirectiveResults(ast, info);
|
|
71
29
|
}
|
|
72
30
|
static flattenAST(ast, info, obj = {}, config = {}) {
|
|
73
|
-
|
|
74
|
-
processArguments: false,
|
|
75
|
-
excludedFields: [],
|
|
76
|
-
}, config);
|
|
77
|
-
return GraphQLHelper.getSelections(ast).reduce((flattened, a) => {
|
|
78
|
-
if (a.directives && a.directives.length) {
|
|
79
|
-
const { shouldInclude, shouldSkip } = GraphQLHelper.getDirectiveResults(a, info);
|
|
80
|
-
if (shouldSkip || !shouldInclude) {
|
|
81
|
-
return flattened;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (GraphQLHelper.isFieldNode(a)) {
|
|
85
|
-
const name = a.name.value;
|
|
86
|
-
if (config.excludedFields.indexOf(name) !== -1) {
|
|
87
|
-
return flattened;
|
|
88
|
-
}
|
|
89
|
-
if (flattened[name] && flattened[name] !== '__arguments') {
|
|
90
|
-
Object.assign(flattened[name], GraphQLHelper.flattenAST(a, info, flattened[name]));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
flattened[name] = GraphQLHelper.flattenAST(a, info);
|
|
94
|
-
}
|
|
95
|
-
if (config.processArguments) {
|
|
96
|
-
if (a.arguments && a.arguments.length) {
|
|
97
|
-
Object.assign(flattened[name], {
|
|
98
|
-
__arguments: GraphQLHelper.getArguments(a),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
flattened = GraphQLHelper.flattenAST(GraphQLHelper.getAST(a, info), info, flattened);
|
|
105
|
-
}
|
|
106
|
-
return flattened;
|
|
107
|
-
}, obj);
|
|
31
|
+
return flattenAST(ast, info, obj, config);
|
|
108
32
|
}
|
|
109
33
|
static getFields(info, obj = {}, config = {}) {
|
|
110
|
-
|
|
111
|
-
return {};
|
|
112
|
-
}
|
|
113
|
-
const fields = info.fieldNodes || info.fieldASTs;
|
|
114
|
-
return (fields.reduce((o, ast) => {
|
|
115
|
-
return GraphQLHelper.flattenAST(ast, info, o, config);
|
|
116
|
-
}, obj) || {});
|
|
34
|
+
return getFields(info, obj, config);
|
|
117
35
|
}
|
|
118
36
|
static isInGraphQLResolveInfo(path, info, config = {}) {
|
|
119
|
-
return
|
|
37
|
+
return isInGraphQLResolveInfo(path, info, config);
|
|
120
38
|
}
|
|
121
39
|
static isInFields(path, fields) {
|
|
122
|
-
return
|
|
40
|
+
return isInFields(path, fields);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = GraphQLHelper;
|
|
44
|
+
function isFieldNode(ast) {
|
|
45
|
+
return ast.kind === 'Field';
|
|
46
|
+
}
|
|
47
|
+
exports.isFieldNode = isFieldNode;
|
|
48
|
+
function isValueNodeWithValueField(value) {
|
|
49
|
+
return value.kind !== 'NullValue' && value.kind !== 'ListValue' && value.kind !== 'ObjectValue';
|
|
50
|
+
}
|
|
51
|
+
exports.isValueNodeWithValueField = isValueNodeWithValueField;
|
|
52
|
+
function isListValueNode(value) {
|
|
53
|
+
return value.kind === 'ListValue';
|
|
54
|
+
}
|
|
55
|
+
exports.isListValueNode = isListValueNode;
|
|
56
|
+
function getASTSelections(ast) {
|
|
57
|
+
if (ast && ast.selectionSet && ast.selectionSet.selections && ast.selectionSet.selections.length) {
|
|
58
|
+
return ast.selectionSet.selections;
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
exports.getASTSelections = getASTSelections;
|
|
63
|
+
function getAST(ast, info) {
|
|
64
|
+
if (ast.kind === 'FragmentSpread') {
|
|
65
|
+
const fragmentName = ast.name.value;
|
|
66
|
+
return info.fragments[fragmentName];
|
|
123
67
|
}
|
|
68
|
+
return ast;
|
|
69
|
+
}
|
|
70
|
+
exports.getAST = getAST;
|
|
71
|
+
function getArguments(ast) {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = ast.arguments) === null || _a === void 0 ? void 0 : _a.map((argument) => {
|
|
74
|
+
const valueNode = argument.value;
|
|
75
|
+
const argumentValue = !isListValueNode(valueNode)
|
|
76
|
+
? valueNode.value
|
|
77
|
+
: valueNode.values.map((value) => value.value);
|
|
78
|
+
return {
|
|
79
|
+
[argument.name.value]: {
|
|
80
|
+
kind: argument.value.kind,
|
|
81
|
+
value: argumentValue,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getArguments = getArguments;
|
|
87
|
+
function getDirectiveValue(directive, info) {
|
|
88
|
+
var _a;
|
|
89
|
+
const arg = (_a = directive.arguments) === null || _a === void 0 ? void 0 : _a[0];
|
|
90
|
+
if (!arg) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (arg.value.kind !== 'Variable') {
|
|
94
|
+
const valueNode = arg.value;
|
|
95
|
+
return isValueNodeWithValueField(valueNode) ? !!valueNode.value : false;
|
|
96
|
+
}
|
|
97
|
+
return info.variableValues[arg.value.name.value];
|
|
98
|
+
}
|
|
99
|
+
exports.getDirectiveValue = getDirectiveValue;
|
|
100
|
+
function getDirectiveResults(ast, info) {
|
|
101
|
+
var _a;
|
|
102
|
+
const directiveResult = {
|
|
103
|
+
shouldInclude: true,
|
|
104
|
+
shouldSkip: false,
|
|
105
|
+
};
|
|
106
|
+
return (_a = ast.directives) === null || _a === void 0 ? void 0 : _a.reduce((result, directive) => {
|
|
107
|
+
switch (directive.name.value) {
|
|
108
|
+
case 'include':
|
|
109
|
+
return Object.assign(Object.assign({}, result), { shouldInclude: getDirectiveValue(directive, info) });
|
|
110
|
+
case 'skip':
|
|
111
|
+
return Object.assign(Object.assign({}, result), { shouldSkip: getDirectiveValue(directive, info) });
|
|
112
|
+
default:
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
}, directiveResult);
|
|
116
|
+
}
|
|
117
|
+
exports.getDirectiveResults = getDirectiveResults;
|
|
118
|
+
function flattenAST(ast, info, obj = {}, config = {}) {
|
|
119
|
+
config = Object.assign({
|
|
120
|
+
processArguments: false,
|
|
121
|
+
excludedFields: [],
|
|
122
|
+
}, config);
|
|
123
|
+
return getASTSelections(ast).reduce((flattened, a) => {
|
|
124
|
+
if (a.directives && a.directives.length) {
|
|
125
|
+
const { shouldInclude, shouldSkip } = getDirectiveResults(a, info);
|
|
126
|
+
if (shouldSkip || !shouldInclude) {
|
|
127
|
+
return flattened;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (isFieldNode(a)) {
|
|
131
|
+
const name = a.name.value;
|
|
132
|
+
if (config.excludedFields.indexOf(name) !== -1) {
|
|
133
|
+
return flattened;
|
|
134
|
+
}
|
|
135
|
+
if (flattened[name] && flattened[name] !== '__arguments') {
|
|
136
|
+
Object.assign(flattened[name], flattenAST(a, info, flattened[name]));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
flattened[name] = flattenAST(a, info);
|
|
140
|
+
}
|
|
141
|
+
if (config.processArguments) {
|
|
142
|
+
if (a.arguments && a.arguments.length) {
|
|
143
|
+
Object.assign(flattened[name], {
|
|
144
|
+
__arguments: getArguments(a),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
flattened = flattenAST(getAST(a, info), info, flattened);
|
|
151
|
+
}
|
|
152
|
+
return flattened;
|
|
153
|
+
}, obj);
|
|
154
|
+
}
|
|
155
|
+
exports.flattenAST = flattenAST;
|
|
156
|
+
function getFields(info, obj = {}, config = {}) {
|
|
157
|
+
if (!info || (!info.fieldNodes && !info.fieldASTs)) {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
const fields = info.fieldNodes || info.fieldASTs;
|
|
161
|
+
return (fields.reduce((o, ast) => {
|
|
162
|
+
return flattenAST(ast, info, o, config);
|
|
163
|
+
}, obj) || {});
|
|
164
|
+
}
|
|
165
|
+
exports.getFields = getFields;
|
|
166
|
+
function isInGraphQLResolveInfo(path, info, config = {}) {
|
|
167
|
+
return _.has(getFields(info, config), path);
|
|
168
|
+
}
|
|
169
|
+
exports.isInGraphQLResolveInfo = isInGraphQLResolveInfo;
|
|
170
|
+
function isInFields(path, fields) {
|
|
171
|
+
return _.has(fields, path);
|
|
124
172
|
}
|
|
125
|
-
exports.
|
|
173
|
+
exports.isInFields = isInFields;
|
|
126
174
|
//# sourceMappingURL=graphql.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/graphql.helper.ts"],"names":[],"mappings":";;;AAcA,4BAA4B;
|
|
1
|
+
{"version":3,"file":"graphql.helper.js","sourceRoot":"","sources":["../../../../src/core/common/helpers/graphql.helper.ts"],"names":[],"mappings":";;;AAcA,4BAA4B;AAyB5B,MAAqB,aAAa;IAKzB,MAAM,CAAC,WAAW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G,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AAFD,wDAEC;AAKD,SAAgB,UAAU,CAAC,IAAS,EAAE,MAAW;IAC/C,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAFD,gCAEC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { IdsType } from '../types/ids.type';
|
|
2
|
+
export default class InputHelper {
|
|
2
3
|
static check(value: any, user: {
|
|
3
4
|
id: any;
|
|
4
5
|
hasRole: (roles: string[]) => boolean;
|
|
5
|
-
},
|
|
6
|
-
|
|
6
|
+
}, options?: {
|
|
7
|
+
creator?: IdsType;
|
|
8
|
+
metatype?: any;
|
|
9
|
+
ownerIds?: IdsType;
|
|
10
|
+
roles?: string | string[];
|
|
11
|
+
}): Promise<any>;
|
|
12
|
+
static errorFunction(caller: (...params: any[]) => any, message?: string): void;
|
|
7
13
|
static isArray(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
8
14
|
static isBasicType(metatype: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
9
15
|
static isBetween(parameter: number, min: number, max: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
@@ -14,7 +20,7 @@ export declare class InputHelper {
|
|
|
14
20
|
static isFunction(parameter: (...params: any[]) => any, falseFunction?: (...params: any[]) => any): boolean;
|
|
15
21
|
static isGreater(parameter: number, compare: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
16
22
|
static isLower(parameter: number, compare: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
17
|
-
static isNonEmptyArray(parameter: any,
|
|
23
|
+
static isNonEmptyArray(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
18
24
|
static isNonEmptyObject(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
19
25
|
static isNonEmptyString(parameter: string, falseFunction?: (...params: any[]) => any): boolean;
|
|
20
26
|
static isNumber(parameter: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
@@ -24,3 +30,35 @@ export declare class InputHelper {
|
|
|
24
30
|
static returnFalse(): boolean;
|
|
25
31
|
static map<T>(values: Partial<T>, ctor: new () => T, cloneDeep?: boolean): T;
|
|
26
32
|
}
|
|
33
|
+
export declare function check(value: any, user: {
|
|
34
|
+
id: any;
|
|
35
|
+
hasRole: (roles: string[]) => boolean;
|
|
36
|
+
}, options?: {
|
|
37
|
+
creator?: IdsType;
|
|
38
|
+
metatype?: any;
|
|
39
|
+
ownerIds?: IdsType;
|
|
40
|
+
roles?: string | string[];
|
|
41
|
+
throwError?: boolean;
|
|
42
|
+
}): Promise<any>;
|
|
43
|
+
export declare function errorFunction(caller: (...params: any[]) => any, message?: string): void;
|
|
44
|
+
export declare function isArray(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
45
|
+
export declare function isBasicType(metatype: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
46
|
+
export declare function isBetween(parameter: number, min: number, max: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
47
|
+
export declare function isDate(parameter: Date, falseFunction?: (...params: any[]) => any): boolean;
|
|
48
|
+
export declare function isEmail(parameter: string, falseFunction?: (...params: any[]) => any): boolean;
|
|
49
|
+
export declare function isFalse(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
50
|
+
export declare function isFile(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
51
|
+
export declare function isFunction(parameter: (...params: any[]) => any, falseFunction?: (...params: any[]) => any): boolean;
|
|
52
|
+
export declare function isGreater(parameter: number, compare: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
53
|
+
export declare function isLower(parameter: number, compare: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
54
|
+
export declare function isNonEmptyArray(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
55
|
+
export declare function isNonEmptyObject(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
56
|
+
export declare function isNonEmptyString(parameter: string, falseFunction?: (...params: any[]) => any): boolean;
|
|
57
|
+
export declare function isNumber(parameter: number, falseFunction?: (...params: any[]) => any): boolean;
|
|
58
|
+
export declare function isObject(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
59
|
+
export declare function isTrue(parameter: any, falseFunction?: (...params: any[]) => any): boolean;
|
|
60
|
+
export declare function isString(parameter: string, falseFunction?: (...params: any[]) => any): boolean;
|
|
61
|
+
export declare function returnFalse(): boolean;
|
|
62
|
+
export declare function mapClass<T>(values: Partial<T>, ctor: new () => T, cloneDeep?: boolean): T;
|
|
63
|
+
export declare function typeofArray(arr: any[], strict?: boolean): string;
|
|
64
|
+
export declare function instanceofArray(arr: any[], strict?: boolean): string;
|