@vendure/harden-plugin 1.9.2 → 2.0.0-next.28
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/lib/src/harden.plugin.js +1 -1
- package/lib/src/harden.plugin.js.map +1 -1
- package/lib/src/middleware/hide-validation-errors-plugin.d.ts +1 -1
- package/lib/src/middleware/hide-validation-errors-plugin.js +1 -1
- package/lib/src/middleware/hide-validation-errors-plugin.js.map +1 -1
- package/lib/src/middleware/query-complexity-plugin.d.ts +1 -1
- package/lib/src/middleware/query-complexity-plugin.js +7 -7
- package/lib/src/middleware/query-complexity-plugin.js.map +1 -1
- package/package.json +4 -4
package/lib/src/harden.plugin.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harden.plugin.js","sourceRoot":"","sources":["../../src/harden.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsD;AAEtD,2CAA+D;AAC/D,8FAAwF;AACxF,kFAA6E;AAG7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AAuBH,IAAa,YAAY,oBAAzB,MAAa,YAAY;IAGrB,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACxB,CAAC;CACJ,CAAA;AAPY,YAAY;IAtBxB,oBAAa,
|
|
1
|
+
{"version":3,"file":"harden.plugin.js","sourceRoot":"","sources":["../../src/harden.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsD;AAEtD,2CAA+D;AAC/D,8FAAwF;AACxF,kFAA6E;AAG7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AAuBH,IAAa,YAAY,oBAAzB,MAAa,YAAY;IAGrB,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACxB,CAAC;CACJ,CAAA;AAPY,YAAY;IAtBxB,IAAA,oBAAa,EAAC;QACX,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,iCAAqB;gBAC9B,UAAU,EAAE,GAAG,EAAE,CAAC,cAAY,CAAC,OAAO;aACzC;SACJ;QACD,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,IAAI,cAAY,CAAC,OAAO,CAAC,oBAAoB,KAAK,KAAK,EAAE;gBACrD,aAAM,CAAC,OAAO,CAAC,wCAAwC,EAAE,qBAAS,CAAC,CAAC;gBACpE,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,0DAA0B,EAAE,CAAC,CAAC;aAChF;YACD,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,+CAAqB,CAAC,cAAY,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5F,IAAI,cAAY,CAAC,OAAO,CAAC,OAAO,KAAK,KAAK,EAAE;gBACxC,MAAM,CAAC,UAAU,CAAC,aAAa,GAAG,KAAK,CAAC;gBACxC,MAAM,CAAC,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;gBACvC,MAAM,CAAC,UAAU,CAAC,aAAa,GAAG,KAAK,CAAC;aAC3C;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;GACW,YAAY,CAOxB;AAPY,oCAAY"}
|
|
@@ -5,5 +5,5 @@ import { ApolloServerPlugin, GraphQLRequestListener } from 'apollo-server-plugin
|
|
|
5
5
|
* Based on ideas discussed in https://github.com/apollographql/apollo-server/issues/3919
|
|
6
6
|
*/
|
|
7
7
|
export declare class HideValidationErrorsPlugin implements ApolloServerPlugin {
|
|
8
|
-
requestDidStart(): GraphQLRequestListener
|
|
8
|
+
requestDidStart(): Promise<GraphQLRequestListener>;
|
|
9
9
|
}
|
|
@@ -8,7 +8,7 @@ const apollo_server_core_1 = require("apollo-server-core");
|
|
|
8
8
|
* Based on ideas discussed in https://github.com/apollographql/apollo-server/issues/3919
|
|
9
9
|
*/
|
|
10
10
|
class HideValidationErrorsPlugin {
|
|
11
|
-
requestDidStart() {
|
|
11
|
+
async requestDidStart() {
|
|
12
12
|
return {
|
|
13
13
|
willSendResponse: async (requestContext) => {
|
|
14
14
|
const { errors, context } = requestContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hide-validation-errors-plugin.js","sourceRoot":"","sources":["../../../src/middleware/hide-validation-errors-plugin.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAGrD;;;;GAIG;AACH,MAAa,0BAA0B;IACnC,eAAe;
|
|
1
|
+
{"version":3,"file":"hide-validation-errors-plugin.js","sourceRoot":"","sources":["../../../src/middleware/hide-validation-errors-plugin.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAGrD;;;;GAIG;AACH,MAAa,0BAA0B;IACnC,KAAK,CAAC,eAAe;QACjB,OAAO;YACH,gBAAgB,EAAE,KAAK,EAAC,cAAc,EAAC,EAAE;gBACrC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;gBAC3C,IAAI,MAAM,EAAE;oBACP,cAAc,CAAC,QAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;wBACvD,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;4BACtC,OAAO,IAAI,oCAAe,CAAC,iBAAiB,CAAC,CAAC;yBACjD;6BAAM;4BACH,OAAO,GAAG,CAAC;yBACd;oBACL,CAAC,CAAC,CAAC;iBACN;YACL,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AAjBD,gEAiBC"}
|
|
@@ -9,7 +9,7 @@ import { HardenPluginOptions } from '../types';
|
|
|
9
9
|
export declare class QueryComplexityPlugin implements ApolloServerPlugin {
|
|
10
10
|
private options;
|
|
11
11
|
constructor(options: HardenPluginOptions);
|
|
12
|
-
requestDidStart({ schema }: GraphQLRequestContext): GraphQLRequestListener
|
|
12
|
+
requestDidStart({ schema }: GraphQLRequestContext): Promise<GraphQLRequestListener>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* @description
|
|
@@ -13,7 +13,7 @@ class QueryComplexityPlugin {
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.options = options;
|
|
15
15
|
}
|
|
16
|
-
requestDidStart({ schema }) {
|
|
16
|
+
async requestDidStart({ schema }) {
|
|
17
17
|
var _a;
|
|
18
18
|
const maxQueryComplexity = (_a = this.options.maxQueryComplexity) !== null && _a !== void 0 ? _a : 1000;
|
|
19
19
|
return {
|
|
@@ -26,18 +26,18 @@ class QueryComplexityPlugin {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
const query = request.operationName
|
|
29
|
-
? graphql_1.separateOperations(document)[request.operationName]
|
|
29
|
+
? (0, graphql_1.separateOperations)(document)[request.operationName]
|
|
30
30
|
: document;
|
|
31
31
|
if (this.options.logComplexityScore === true) {
|
|
32
32
|
core_1.Logger.debug(`Calculating complexity of "${(_a = request.operationName) !== null && _a !== void 0 ? _a : 'anonymous'}"`, constants_1.loggerCtx);
|
|
33
33
|
}
|
|
34
|
-
const complexity = graphql_query_complexity_1.getComplexity({
|
|
34
|
+
const complexity = (0, graphql_query_complexity_1.getComplexity)({
|
|
35
35
|
schema,
|
|
36
36
|
query,
|
|
37
37
|
variables: request.variables,
|
|
38
38
|
estimators: (_b = this.options.queryComplexityEstimators) !== null && _b !== void 0 ? _b : [
|
|
39
39
|
defaultVendureComplexityEstimator((_c = this.options.customComplexityFactors) !== null && _c !== void 0 ? _c : {}, (_d = this.options.logComplexityScore) !== null && _d !== void 0 ? _d : false),
|
|
40
|
-
graphql_query_complexity_1.simpleEstimator({ defaultComplexity: 1 }),
|
|
40
|
+
(0, graphql_query_complexity_1.simpleEstimator)({ defaultComplexity: 1 }),
|
|
41
41
|
],
|
|
42
42
|
});
|
|
43
43
|
if (this.options.logComplexityScore === true) {
|
|
@@ -73,7 +73,7 @@ function defaultVendureComplexityEstimator(customComplexityFactors, logFieldScor
|
|
|
73
73
|
return (options) => {
|
|
74
74
|
var _a, _b;
|
|
75
75
|
const { type, args, childComplexity, field } = options;
|
|
76
|
-
const namedType = graphql_1.getNamedType(field.type);
|
|
76
|
+
const namedType = (0, graphql_1.getNamedType)(field.type);
|
|
77
77
|
const path = `${type.name}.${field.name}`;
|
|
78
78
|
let result = childComplexity + 1;
|
|
79
79
|
const customFactor = customComplexityFactors[path];
|
|
@@ -81,14 +81,14 @@ function defaultVendureComplexityEstimator(customComplexityFactors, logFieldScor
|
|
|
81
81
|
result = Math.max(childComplexity, 1) * customFactor;
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
if (graphql_1.isObjectType(namedType)) {
|
|
84
|
+
if ((0, graphql_1.isObjectType)(namedType)) {
|
|
85
85
|
const isPaginatedList = !!namedType.getInterfaces().find(i => i.name === 'PaginatedList');
|
|
86
86
|
if (isPaginatedList) {
|
|
87
87
|
const take = (_b = (_a = args.options) === null || _a === void 0 ? void 0 : _a.take) !== null && _b !== void 0 ? _b : 1000;
|
|
88
88
|
result = childComplexity + Math.round(Math.log(childComplexity) * take);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
if (graphql_1.isListType(graphql_1.getNullableType(field.type))) {
|
|
91
|
+
if ((0, graphql_1.isListType)((0, graphql_1.getNullableType)(field.type))) {
|
|
92
92
|
result = childComplexity * 5;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-complexity-plugin.js","sourceRoot":"","sources":["../../../src/middleware/query-complexity-plugin.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAG5D,qCAOiB;AACjB,uEAAmG;AAEnG,4CAAyC;AAGzC;;;GAGG;AACH,MAAa,qBAAqB;IAC9B,YAAoB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAEpD,eAAe,CAAC,EAAE,MAAM,EAAyB;;
|
|
1
|
+
{"version":3,"file":"query-complexity-plugin.js","sourceRoot":"","sources":["../../../src/middleware/query-complexity-plugin.ts"],"names":[],"mappings":";;;AAAA,wCAA4D;AAG5D,qCAOiB;AACjB,uEAAmG;AAEnG,4CAAyC;AAGzC;;;GAGG;AACH,MAAa,qBAAqB;IAC9B,YAAoB,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAEpD,KAAK,CAAC,eAAe,CAAC,EAAE,MAAM,EAAyB;;QACnD,MAAM,kBAAkB,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,kBAAkB,mCAAI,IAAI,CAAC;QACnE,OAAO;YACH,mBAAmB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;;gBACjD,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;oBACpB,kDAAkD;oBAClD,0DAA0D;oBAC1D,4BAA4B;oBAC5B,OAAO;iBACV;gBACD,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa;oBAC/B,CAAC,CAAC,IAAA,4BAAkB,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;oBACrD,CAAC,CAAC,QAAQ,CAAC;gBAEf,IAAI,IAAI,CAAC,OAAO,CAAC,kBAAkB,KAAK,IAAI,EAAE;oBAC1C,aAAM,CAAC,KAAK,CACR,8BAA8B,MAAA,OAAO,CAAC,aAAa,mCAAI,WAAW,GAAG,EACrE,qBAAS,CACZ,CAAC;iBACL;gBACD,MAAM,UAAU,GAAG,IAAA,wCAAa,EAAC;oBAC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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/harden-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.28",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"graphql-query-complexity": "^0.12.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@vendure/common": "^
|
|
25
|
-
"@vendure/core": "^
|
|
24
|
+
"@vendure/common": "^2.0.0-next.28",
|
|
25
|
+
"@vendure/core": "^2.0.0-next.28"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "6811d6554afbb0e0d993da4788499bcd3563d5ab"
|
|
28
28
|
}
|