@vendure/harden-plugin 2.0.0-next.28 → 2.0.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/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/src/harden.plugin.d.ts +4 -3
- package/lib/src/harden.plugin.js +6 -4
- package/lib/src/harden.plugin.js.map +1 -1
- package/lib/src/middleware/query-complexity-plugin.d.ts +1 -1
- package/lib/src/middleware/query-complexity-plugin.js +2 -2
- package/lib/src/types.d.ts +1 -1
- package/package.json +26 -26
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,8CAA4B;AAC5B,2EAAyD"}
|
|
@@ -29,7 +29,7 @@ import { HardenPluginOptions } from './types';
|
|
|
29
29
|
* plugins: [
|
|
30
30
|
* HardenPlugin.init({
|
|
31
31
|
* maxQueryComplexity: 650,
|
|
32
|
-
* apiMode: process.env.
|
|
32
|
+
* apiMode: process.env.APP_ENV === 'dev' ? 'dev' : 'prod',
|
|
33
33
|
* }),
|
|
34
34
|
* ],
|
|
35
35
|
* };
|
|
@@ -82,7 +82,8 @@ import { HardenPluginOptions } from './types';
|
|
|
82
82
|
* - The requirements of your storefront and other clients using the Shop API
|
|
83
83
|
* - The resources available to your server
|
|
84
84
|
*
|
|
85
|
-
* You should aim to set the maximum as low as possible while still being able to service all the requests required.
|
|
85
|
+
* You should aim to set the maximum as low as possible while still being able to service all the requests required.
|
|
86
|
+
* This will take some manual tuning.
|
|
86
87
|
* While tuning the max, you can turn on the `logComplexityScore` to get a detailed breakdown of the complexity of each query, as well as how
|
|
87
88
|
* that total score is derived from its child fields:
|
|
88
89
|
*
|
|
@@ -130,7 +131,7 @@ import { HardenPluginOptions } from './types';
|
|
|
130
131
|
* verbose 16/12/22, 14:12 - [HardenPlugin] Query complexity [ProductList]: 35
|
|
131
132
|
* ```
|
|
132
133
|
*
|
|
133
|
-
* @docsCategory HardenPlugin
|
|
134
|
+
* @docsCategory core plugins/HardenPlugin
|
|
134
135
|
*/
|
|
135
136
|
export declare class HardenPlugin {
|
|
136
137
|
static options: HardenPluginOptions;
|
package/lib/src/harden.plugin.js
CHANGED
|
@@ -42,7 +42,7 @@ const query_complexity_plugin_1 = require("./middleware/query-complexity-plugin"
|
|
|
42
42
|
* plugins: [
|
|
43
43
|
* HardenPlugin.init({
|
|
44
44
|
* maxQueryComplexity: 650,
|
|
45
|
-
* apiMode: process.env.
|
|
45
|
+
* apiMode: process.env.APP_ENV === 'dev' ? 'dev' : 'prod',
|
|
46
46
|
* }),
|
|
47
47
|
* ],
|
|
48
48
|
* };
|
|
@@ -95,7 +95,8 @@ const query_complexity_plugin_1 = require("./middleware/query-complexity-plugin"
|
|
|
95
95
|
* - The requirements of your storefront and other clients using the Shop API
|
|
96
96
|
* - The resources available to your server
|
|
97
97
|
*
|
|
98
|
-
* You should aim to set the maximum as low as possible while still being able to service all the requests required.
|
|
98
|
+
* You should aim to set the maximum as low as possible while still being able to service all the requests required.
|
|
99
|
+
* This will take some manual tuning.
|
|
99
100
|
* While tuning the max, you can turn on the `logComplexityScore` to get a detailed breakdown of the complexity of each query, as well as how
|
|
100
101
|
* that total score is derived from its child fields:
|
|
101
102
|
*
|
|
@@ -143,7 +144,7 @@ const query_complexity_plugin_1 = require("./middleware/query-complexity-plugin"
|
|
|
143
144
|
* verbose 16/12/22, 14:12 - [HardenPlugin] Query complexity [ProductList]: 35
|
|
144
145
|
* ```
|
|
145
146
|
*
|
|
146
|
-
* @docsCategory HardenPlugin
|
|
147
|
+
* @docsCategory core plugins/HardenPlugin
|
|
147
148
|
*/
|
|
148
149
|
let HardenPlugin = HardenPlugin_1 = class HardenPlugin {
|
|
149
150
|
static init(options) {
|
|
@@ -161,7 +162,7 @@ HardenPlugin = HardenPlugin_1 = __decorate([
|
|
|
161
162
|
],
|
|
162
163
|
configuration: config => {
|
|
163
164
|
if (HardenPlugin_1.options.hideFieldSuggestions !== false) {
|
|
164
|
-
core_1.Logger.verbose(
|
|
165
|
+
core_1.Logger.verbose('Configuring HideValidationErrorsPlugin', constants_1.loggerCtx);
|
|
165
166
|
config.apiOptions.apolloServerPlugins.push(new hide_validation_errors_plugin_1.HideValidationErrorsPlugin());
|
|
166
167
|
}
|
|
167
168
|
config.apiOptions.apolloServerPlugins.push(new query_complexity_plugin_1.QueryComplexityPlugin(HardenPlugin_1.options));
|
|
@@ -172,6 +173,7 @@ HardenPlugin = HardenPlugin_1 = __decorate([
|
|
|
172
173
|
}
|
|
173
174
|
return config;
|
|
174
175
|
},
|
|
176
|
+
compatibility: '^2.0.0',
|
|
175
177
|
})
|
|
176
178
|
], HardenPlugin);
|
|
177
179
|
exports.HardenPlugin = HardenPlugin;
|
|
@@ -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,kFAA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AC,aAAa,GAAG,KAAK,CAAC;aAC3C;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,aAAa,EAAE,QAAQ;KAC1B,CAAC;GACW,YAAY,CAOxB;AAPY,oCAAY"}
|
|
@@ -19,7 +19,7 @@ export declare class QueryComplexityPlugin implements ApolloServerPlugin {
|
|
|
19
19
|
* When selecting PaginatedList types, the "take" argument is used to estimate a complexity
|
|
20
20
|
* factor. If the "take" argument is omitted, a default factor of 1000 is applied.
|
|
21
21
|
*
|
|
22
|
-
* @docsCategory HardenPlugin
|
|
22
|
+
* @docsCategory core plugins/HardenPlugin
|
|
23
23
|
*/
|
|
24
24
|
export declare function defaultVendureComplexityEstimator(customComplexityFactors: {
|
|
25
25
|
[path: string]: number;
|
|
@@ -45,7 +45,7 @@ class QueryComplexityPlugin {
|
|
|
45
45
|
}
|
|
46
46
|
if (complexity >= maxQueryComplexity) {
|
|
47
47
|
core_1.Logger.error(`Query complexity of "${(_f = request.operationName) !== null && _f !== void 0 ? _f : 'anonymous'}" is ${complexity}, which exceeds the maximum of ${maxQueryComplexity}`, constants_1.loggerCtx);
|
|
48
|
-
throw new core_1.InternalServerError(
|
|
48
|
+
throw new core_1.InternalServerError('Query is too complex');
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
};
|
|
@@ -67,7 +67,7 @@ function isAdminApi(schema) {
|
|
|
67
67
|
* When selecting PaginatedList types, the "take" argument is used to estimate a complexity
|
|
68
68
|
* factor. If the "take" argument is omitted, a default factor of 1000 is applied.
|
|
69
69
|
*
|
|
70
|
-
* @docsCategory HardenPlugin
|
|
70
|
+
* @docsCategory core plugins/HardenPlugin
|
|
71
71
|
*/
|
|
72
72
|
function defaultVendureComplexityEstimator(customComplexityFactors, logFieldScores) {
|
|
73
73
|
return (options) => {
|
package/lib/src/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ComplexityEstimator } from 'graphql-query-complexity/dist/cjs/QueryComp
|
|
|
3
3
|
* @description
|
|
4
4
|
* Options that can be passed to the `.init()` static method of the HardenPlugin.
|
|
5
5
|
*
|
|
6
|
-
* @docsCategory HardenPlugin
|
|
6
|
+
* @docsCategory core plugins/HardenPlugin
|
|
7
7
|
*/
|
|
8
8
|
export interface HardenPluginOptions {
|
|
9
9
|
/**
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
"name": "@vendure/harden-plugin",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
12
|
+
"build": "rimraf lib && tsc -p ./tsconfig.build.json",
|
|
13
|
+
"lint": "eslint --fix ."
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://www.vendure.io/",
|
|
16
|
+
"funding": "https://github.com/sponsors/michaelbromley",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"graphql-query-complexity": "^0.12.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vendure/common": "^2.0.0",
|
|
25
|
+
"@vendure/core": "^2.0.0"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "302bd68796e0136f70dd199369616d362c920ea4"
|
|
28
28
|
}
|