@envelop/resource-limitations 0.1.1-alpha-e19f3a5.0 → 0.3.0-alpha-e8998c9.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/README.md CHANGED
@@ -19,6 +19,9 @@ const getEnveloped = envelop({
19
19
  // ... other plugins ...
20
20
  useResourceLimitations({
21
21
  nodeCostLimit: 500000, // optional, default to 500000
22
+ paginationArgumentMaximum: 100, // optional, default to 100
23
+ paginationArgumentMinimum: 1, // optional, default to 1
24
+ paginationArgumentScalars: ['ConnectionInt'], // optional, use if connections use a different scalar type as the argument instead of `Int`
22
25
  extensions: false, // set this to `true` in order to add the calculated const to the response of queries
23
26
  }),
24
27
  ],
package/index.d.ts CHANGED
@@ -2,8 +2,13 @@ import { Plugin } from '@envelop/types';
2
2
  import { ExtendedValidationRule } from '@envelop/extended-validation';
3
3
  import { ExecutionArgs } from 'graphql';
4
4
  export declare const defaultNodeCostLimit = 500000;
5
+ export declare const defaultPaginationArgumentMaximum = 100;
6
+ export declare const defaultPaginationArgumentMinimum = 1;
5
7
  export declare type ResourceLimitationValidationRuleParams = {
6
8
  nodeCostLimit: number;
9
+ paginationArgumentMaximum: number;
10
+ paginationArgumentMinimum: number;
11
+ paginationArgumentTypes?: string[];
7
12
  reportNodeCost?: (cost: number, executionArgs: ExecutionArgs) => void;
8
13
  };
9
14
  /**
@@ -16,6 +21,20 @@ declare type UseResourceLimitationsParams = {
16
21
  * @default 500000
17
22
  */
18
23
  nodeCostLimit?: number;
24
+ /**
25
+ * The custom scalar types accepted for connection arguments.
26
+ */
27
+ paginationArgumentScalars?: string[];
28
+ /**
29
+ * The maximum value accepted for connection arguments.
30
+ * @default 100
31
+ */
32
+ paginationArgumentMaximum?: number;
33
+ /**
34
+ * The minimum value accepted for connection arguments.
35
+ * @default 1
36
+ */
37
+ paginationArgumentMinimum?: number;
19
38
  /**
20
39
  * Whether the resourceLimitations.nodeCost field should be included within the execution result extensions map.
21
40
  * @default false
package/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const graphql = require('graphql');
6
- require('graphql/execution/values');
7
6
  const values_js = require('graphql/execution/values.js');
8
7
 
9
8
  /**
@@ -28,6 +27,7 @@ function handleStreamOrSingleExecutionResult(payload, fn) {
28
27
  }
29
28
  else {
30
29
  fn({
30
+ args: payload.args,
31
31
  result: payload.result,
32
32
  setResult: payload.setResult,
33
33
  });
@@ -82,14 +82,15 @@ const getWrappedType = (graphqlType) => {
82
82
  }
83
83
  return graphqlType;
84
84
  };
85
- const hasFieldDefConnectionArgs = (field) => {
85
+ const isValidArgType = (type, paginationArgumentTypes) => type === graphql.GraphQLInt || (graphql.isScalarType(type) && !!paginationArgumentTypes && paginationArgumentTypes.includes(type.name));
86
+ const hasFieldDefConnectionArgs = (field, argumentTypes) => {
86
87
  let hasFirst = false;
87
88
  let hasLast = false;
88
89
  for (const arg of field.args) {
89
- if (arg.name === 'first' && arg.type === graphql.GraphQLInt) {
90
+ if (arg.name === 'first' && isValidArgType(arg.type, argumentTypes)) {
90
91
  hasFirst = true;
91
92
  }
92
- else if (arg.name === 'last' && arg.type === graphql.GraphQLInt) {
93
+ else if (arg.name === 'last' && isValidArgType(arg.type, argumentTypes)) {
93
94
  hasLast = true;
94
95
  }
95
96
  else if (hasLast && hasFirst) {
@@ -103,12 +104,15 @@ const buildMissingPaginationFieldErrorMessage = (params) => `Missing pagination
103
104
  (params.hasFirst && params.hasLast ? "either the 'first' or 'last'" : params.hasFirst ? "the 'first'" : "the 'last'") +
104
105
  ' field argument.';
105
106
  const buildInvalidPaginationRangeErrorMessage = (params) => `Invalid pagination argument for field ${params.fieldName}. ` +
106
- `The value for the '${params.argumentName}' argument must be an integer within 1-100.`;
107
+ `The value for the '${params.argumentName}' argument must be an integer within ${params.paginationArgumentMinimum}-${params.paginationArgumentMaximum}.`;
107
108
  const defaultNodeCostLimit = 500000;
109
+ const defaultPaginationArgumentMaximum = 100;
110
+ const defaultPaginationArgumentMinimum = 1;
108
111
  /**
109
112
  * Validate whether a user is allowed to execute a certain GraphQL operation.
110
113
  */
111
114
  const ResourceLimitationValidationRule = (params) => (context, executionArgs) => {
115
+ const { paginationArgumentMaximum, paginationArgumentMinimum } = params;
112
116
  const nodeCostStack = [];
113
117
  let totalNodeCost = 0;
114
118
  const connectionFieldMap = new WeakSet();
@@ -123,7 +127,7 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
123
127
  if (type instanceof graphql.GraphQLObjectType && type.name.endsWith('Connection')) {
124
128
  let nodeCost = 1;
125
129
  connectionFieldMap.add(fieldNode);
126
- const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef);
130
+ const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef, params.paginationArgumentTypes);
127
131
  if (hasFirst === false && hasLast === false) {
128
132
  // eslint-disable-next-line no-console
129
133
  console.warn('Encountered paginated field without pagination arguments.');
@@ -137,11 +141,12 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
137
141
  }), fieldNode));
138
142
  }
139
143
  else if ('first' in argumentValues === true && 'last' in argumentValues === false) {
140
- // eslint-disable-next-line dot-notation
141
- if (argumentValues['first'] < 1 || argumentValues['first'] > 100) {
144
+ if (argumentValues.first < paginationArgumentMinimum || argumentValues.first > paginationArgumentMaximum) {
142
145
  context.reportError(new graphql.GraphQLError(buildInvalidPaginationRangeErrorMessage({
143
- fieldName: fieldDef.name,
146
+ paginationArgumentMaximum,
147
+ paginationArgumentMinimum,
144
148
  argumentName: 'first',
149
+ fieldName: fieldDef.name,
145
150
  }), fieldNode));
146
151
  }
147
152
  else {
@@ -150,11 +155,12 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
150
155
  }
151
156
  }
152
157
  else if ('last' in argumentValues === true && 'false' in argumentValues === false) {
153
- // eslint-disable-next-line dot-notation
154
- if (argumentValues['last'] < 1 || argumentValues['last'] > 100) {
158
+ if (argumentValues.last < paginationArgumentMinimum || argumentValues.last > paginationArgumentMaximum) {
155
159
  context.reportError(new graphql.GraphQLError(buildInvalidPaginationRangeErrorMessage({
156
- fieldName: fieldDef.name,
160
+ paginationArgumentMaximum,
161
+ paginationArgumentMinimum,
157
162
  argumentName: 'last',
163
+ fieldName: fieldDef.name,
158
164
  }), fieldNode));
159
165
  }
160
166
  else {
@@ -196,9 +202,11 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
196
202
  };
197
203
  };
198
204
  const useResourceLimitations = (params) => {
199
- var _a, _b;
200
- const nodeCostLimit = (_a = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _a !== void 0 ? _a : defaultNodeCostLimit;
201
- const extensions = (_b = params === null || params === void 0 ? void 0 : params.extensions) !== null && _b !== void 0 ? _b : false;
205
+ var _a, _b, _c, _d;
206
+ const paginationArgumentMaximum = (_a = params === null || params === void 0 ? void 0 : params.paginationArgumentMaximum) !== null && _a !== void 0 ? _a : defaultPaginationArgumentMaximum;
207
+ const paginationArgumentMinimum = (_b = params === null || params === void 0 ? void 0 : params.paginationArgumentMinimum) !== null && _b !== void 0 ? _b : defaultPaginationArgumentMinimum;
208
+ const nodeCostLimit = (_c = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _c !== void 0 ? _c : defaultNodeCostLimit;
209
+ const extensions = (_d = params === null || params === void 0 ? void 0 : params.extensions) !== null && _d !== void 0 ? _d : false;
202
210
  const nodeCostMap = new WeakMap();
203
211
  const handleResult = ({ result, args }) => {
204
212
  const nodeCost = nodeCostMap.get(args);
@@ -217,6 +225,9 @@ const useResourceLimitations = (params) => {
217
225
  rules: [
218
226
  ResourceLimitationValidationRule({
219
227
  nodeCostLimit,
228
+ paginationArgumentMaximum,
229
+ paginationArgumentMinimum,
230
+ paginationArgumentTypes: params === null || params === void 0 ? void 0 : params.paginationArgumentScalars,
220
231
  reportNodeCost: extensions
221
232
  ? (nodeCost, ref) => {
222
233
  nodeCostMap.set(ref, nodeCost);
@@ -239,5 +250,6 @@ const useResourceLimitations = (params) => {
239
250
 
240
251
  exports.ResourceLimitationValidationRule = ResourceLimitationValidationRule;
241
252
  exports.defaultNodeCostLimit = defaultNodeCostLimit;
253
+ exports.defaultPaginationArgumentMaximum = defaultPaginationArgumentMaximum;
254
+ exports.defaultPaginationArgumentMinimum = defaultPaginationArgumentMinimum;
242
255
  exports.useResourceLimitations = useResourceLimitations;
243
- //# sourceMappingURL=index.js.map
package/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { TypeInfo, ValidationContext, visitInParallel, visit, visitWithTypeInfo, GraphQLObjectType, GraphQLError, GraphQLList, GraphQLNonNull, GraphQLInt } from 'graphql';
2
- import 'graphql/execution/values';
1
+ import { TypeInfo, ValidationContext, visitInParallel, visit, visitWithTypeInfo, GraphQLObjectType, GraphQLError, GraphQLList, GraphQLNonNull, GraphQLInt, isScalarType } from 'graphql';
3
2
  import { getArgumentValues } from 'graphql/execution/values.js';
4
3
 
5
4
  /**
@@ -24,6 +23,7 @@ function handleStreamOrSingleExecutionResult(payload, fn) {
24
23
  }
25
24
  else {
26
25
  fn({
26
+ args: payload.args,
27
27
  result: payload.result,
28
28
  setResult: payload.setResult,
29
29
  });
@@ -78,14 +78,15 @@ const getWrappedType = (graphqlType) => {
78
78
  }
79
79
  return graphqlType;
80
80
  };
81
- const hasFieldDefConnectionArgs = (field) => {
81
+ const isValidArgType = (type, paginationArgumentTypes) => type === GraphQLInt || (isScalarType(type) && !!paginationArgumentTypes && paginationArgumentTypes.includes(type.name));
82
+ const hasFieldDefConnectionArgs = (field, argumentTypes) => {
82
83
  let hasFirst = false;
83
84
  let hasLast = false;
84
85
  for (const arg of field.args) {
85
- if (arg.name === 'first' && arg.type === GraphQLInt) {
86
+ if (arg.name === 'first' && isValidArgType(arg.type, argumentTypes)) {
86
87
  hasFirst = true;
87
88
  }
88
- else if (arg.name === 'last' && arg.type === GraphQLInt) {
89
+ else if (arg.name === 'last' && isValidArgType(arg.type, argumentTypes)) {
89
90
  hasLast = true;
90
91
  }
91
92
  else if (hasLast && hasFirst) {
@@ -99,12 +100,15 @@ const buildMissingPaginationFieldErrorMessage = (params) => `Missing pagination
99
100
  (params.hasFirst && params.hasLast ? "either the 'first' or 'last'" : params.hasFirst ? "the 'first'" : "the 'last'") +
100
101
  ' field argument.';
101
102
  const buildInvalidPaginationRangeErrorMessage = (params) => `Invalid pagination argument for field ${params.fieldName}. ` +
102
- `The value for the '${params.argumentName}' argument must be an integer within 1-100.`;
103
+ `The value for the '${params.argumentName}' argument must be an integer within ${params.paginationArgumentMinimum}-${params.paginationArgumentMaximum}.`;
103
104
  const defaultNodeCostLimit = 500000;
105
+ const defaultPaginationArgumentMaximum = 100;
106
+ const defaultPaginationArgumentMinimum = 1;
104
107
  /**
105
108
  * Validate whether a user is allowed to execute a certain GraphQL operation.
106
109
  */
107
110
  const ResourceLimitationValidationRule = (params) => (context, executionArgs) => {
111
+ const { paginationArgumentMaximum, paginationArgumentMinimum } = params;
108
112
  const nodeCostStack = [];
109
113
  let totalNodeCost = 0;
110
114
  const connectionFieldMap = new WeakSet();
@@ -119,7 +123,7 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
119
123
  if (type instanceof GraphQLObjectType && type.name.endsWith('Connection')) {
120
124
  let nodeCost = 1;
121
125
  connectionFieldMap.add(fieldNode);
122
- const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef);
126
+ const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef, params.paginationArgumentTypes);
123
127
  if (hasFirst === false && hasLast === false) {
124
128
  // eslint-disable-next-line no-console
125
129
  console.warn('Encountered paginated field without pagination arguments.');
@@ -133,11 +137,12 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
133
137
  }), fieldNode));
134
138
  }
135
139
  else if ('first' in argumentValues === true && 'last' in argumentValues === false) {
136
- // eslint-disable-next-line dot-notation
137
- if (argumentValues['first'] < 1 || argumentValues['first'] > 100) {
140
+ if (argumentValues.first < paginationArgumentMinimum || argumentValues.first > paginationArgumentMaximum) {
138
141
  context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({
139
- fieldName: fieldDef.name,
142
+ paginationArgumentMaximum,
143
+ paginationArgumentMinimum,
140
144
  argumentName: 'first',
145
+ fieldName: fieldDef.name,
141
146
  }), fieldNode));
142
147
  }
143
148
  else {
@@ -146,11 +151,12 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
146
151
  }
147
152
  }
148
153
  else if ('last' in argumentValues === true && 'false' in argumentValues === false) {
149
- // eslint-disable-next-line dot-notation
150
- if (argumentValues['last'] < 1 || argumentValues['last'] > 100) {
154
+ if (argumentValues.last < paginationArgumentMinimum || argumentValues.last > paginationArgumentMaximum) {
151
155
  context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({
152
- fieldName: fieldDef.name,
156
+ paginationArgumentMaximum,
157
+ paginationArgumentMinimum,
153
158
  argumentName: 'last',
159
+ fieldName: fieldDef.name,
154
160
  }), fieldNode));
155
161
  }
156
162
  else {
@@ -192,9 +198,11 @@ const ResourceLimitationValidationRule = (params) => (context, executionArgs) =>
192
198
  };
193
199
  };
194
200
  const useResourceLimitations = (params) => {
195
- var _a, _b;
196
- const nodeCostLimit = (_a = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _a !== void 0 ? _a : defaultNodeCostLimit;
197
- const extensions = (_b = params === null || params === void 0 ? void 0 : params.extensions) !== null && _b !== void 0 ? _b : false;
201
+ var _a, _b, _c, _d;
202
+ const paginationArgumentMaximum = (_a = params === null || params === void 0 ? void 0 : params.paginationArgumentMaximum) !== null && _a !== void 0 ? _a : defaultPaginationArgumentMaximum;
203
+ const paginationArgumentMinimum = (_b = params === null || params === void 0 ? void 0 : params.paginationArgumentMinimum) !== null && _b !== void 0 ? _b : defaultPaginationArgumentMinimum;
204
+ const nodeCostLimit = (_c = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _c !== void 0 ? _c : defaultNodeCostLimit;
205
+ const extensions = (_d = params === null || params === void 0 ? void 0 : params.extensions) !== null && _d !== void 0 ? _d : false;
198
206
  const nodeCostMap = new WeakMap();
199
207
  const handleResult = ({ result, args }) => {
200
208
  const nodeCost = nodeCostMap.get(args);
@@ -213,6 +221,9 @@ const useResourceLimitations = (params) => {
213
221
  rules: [
214
222
  ResourceLimitationValidationRule({
215
223
  nodeCostLimit,
224
+ paginationArgumentMaximum,
225
+ paginationArgumentMinimum,
226
+ paginationArgumentTypes: params === null || params === void 0 ? void 0 : params.paginationArgumentScalars,
216
227
  reportNodeCost: extensions
217
228
  ? (nodeCost, ref) => {
218
229
  nodeCostMap.set(ref, nodeCost);
@@ -233,5 +244,4 @@ const useResourceLimitations = (params) => {
233
244
  };
234
245
  };
235
246
 
236
- export { ResourceLimitationValidationRule, defaultNodeCostLimit, useResourceLimitations };
237
- //# sourceMappingURL=index.mjs.map
247
+ export { ResourceLimitationValidationRule, defaultNodeCostLimit, defaultPaginationArgumentMaximum, defaultPaginationArgumentMinimum, useResourceLimitations };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/resource-limitations",
3
- "version": "0.1.1-alpha-e19f3a5.0",
3
+ "version": "0.3.0-alpha-e8998c9.0",
4
4
  "description": "A rate-limit implementation based on resource limitations and static calculation of the score (similar to GitHub GraphQL API)",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "graphql": "^14.0.0 || ^15.0.0"
7
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../packages/types/dist/index.mjs","../../../packages/plugins/extended-validation/dist/index.mjs","../../../dist/plugins/resource-limitations/src/index.js"],"sourcesContent":["/**\n * Returns true if the provided object implements the AsyncIterator protocol via\n * implementing a `Symbol.asyncIterator` method.\n *\n * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts\n */\nfunction isAsyncIterable(maybeAsyncIterable) {\n return typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 ? void 0 : maybeAsyncIterable[Symbol.asyncIterator]) === 'function';\n}\n/**\n * A utility function for hanlding `onExecuteDone` hook result, for simplifying the hanlding of AsyncIterable returned from `execute`.\n *\n * @param payload The payload send to `onExecuteDone` hook function\n * @param fn The handler to be executed on each result\n * @returns a subscription for streamed results, or undefined in case of an non-async\n */\nfunction handleStreamOrSingleExecutionResult(payload, fn) {\n if (isAsyncIterable(payload.result)) {\n return { onNext: fn };\n }\n else {\n fn({\n result: payload.result,\n setResult: payload.setResult,\n });\n return undefined;\n }\n}\n\nexport { handleStreamOrSingleExecutionResult, isAsyncIterable };\n//# sourceMappingURL=index.mjs.map\n","import { TypeInfo, ValidationContext, visitInParallel, visit, visitWithTypeInfo, isNonNullType, isListType, GraphQLError, GraphQLInputObjectType } from 'graphql';\nimport { getArgumentValues } from 'graphql/execution/values';\n\nconst SYMBOL_EXTENDED_VALIDATION_RULES = Symbol('SYMBOL_EXTENDED_VALIDATION_RULES');\nconst useExtendedValidation = (options) => {\n let schemaTypeInfo;\n return {\n onSchemaChange({ schema }) {\n schemaTypeInfo = new TypeInfo(schema);\n },\n onParse({ context, extendContext }) {\n var _a;\n const rules = (_a = context === null || context === void 0 ? void 0 : context[SYMBOL_EXTENDED_VALIDATION_RULES]) !== null && _a !== void 0 ? _a : [];\n rules.push(...options.rules);\n extendContext({\n [SYMBOL_EXTENDED_VALIDATION_RULES]: rules,\n });\n },\n onExecute({ args, setResultAndStopExecution }) {\n const rules = args.contextValue[SYMBOL_EXTENDED_VALIDATION_RULES];\n const errors = [];\n const typeInfo = schemaTypeInfo || new TypeInfo(args.schema);\n const validationContext = new ValidationContext(args.schema, args.document, typeInfo, e => {\n errors.push(e);\n });\n const visitor = visitInParallel(rules.map(rule => rule(validationContext, args)));\n visit(args.document, visitWithTypeInfo(typeInfo, visitor));\n for (const rule of rules) {\n rule(validationContext, args);\n }\n if (errors.length > 0) {\n let result = {\n data: null,\n errors,\n };\n if (options.onValidationFailed) {\n options.onValidationFailed({ args, result, setResult: newResult => (result = newResult) });\n }\n return setResultAndStopExecution(result);\n }\n },\n };\n};\n\nfunction getDirectiveFromAstNode(astNode, names) {\n const directives = astNode.directives || [];\n const namesArr = Array.isArray(names) ? names : [names];\n const authDirective = directives.find(d => namesArr.includes(d.name.value));\n return authDirective || null;\n}\nfunction unwrapType(type) {\n if (isNonNullType(type) || isListType(type)) {\n return unwrapType(type.ofType);\n }\n return type;\n}\n\nconst ONE_OF_DIRECTIVE_SDL = /* GraphQL */ `\n directive @oneOf on INPUT_OBJECT | FIELD_DEFINITION\n`;\nconst OneOfInputObjectsRule = (validationContext, executionArgs) => {\n return {\n Field: node => {\n var _a, _b;\n if ((_a = node.arguments) === null || _a === void 0 ? void 0 : _a.length) {\n const fieldType = validationContext.getFieldDef();\n if (!fieldType) {\n return;\n }\n const values = getArgumentValues(fieldType, node, executionArgs.variableValues);\n if (fieldType) {\n const isOneOfFieldType = ((_b = fieldType.extensions) === null || _b === void 0 ? void 0 : _b.oneOf) || (fieldType.astNode && getDirectiveFromAstNode(fieldType.astNode, 'oneOf'));\n if (isOneOfFieldType) {\n if (Object.keys(values).length !== 1) {\n validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input for field \"${fieldType.type.toString()}.${node.name.value}\"`, [node]));\n }\n }\n }\n for (const arg of node.arguments) {\n const argType = fieldType.args.find(typeArg => typeArg.name === arg.name.value);\n if (argType) {\n traverseVariables(validationContext, arg, argType.type, values[arg.name.value]);\n }\n }\n }\n },\n };\n};\nfunction traverseVariables(validationContext, arg, graphqlType, currentValue) {\n var _a;\n // if the current value is empty we don't need to traverse deeper\n // if it shouldn't be empty, the \"original\" validation phase should complain.\n if (currentValue == null) {\n return;\n }\n if (isListType(graphqlType)) {\n if (!Array.isArray(currentValue)) {\n // because of graphql type coercion a single object should be treated as an array of one object\n currentValue = [currentValue];\n }\n currentValue.forEach(value => {\n traverseVariables(validationContext, arg, graphqlType.ofType, value);\n });\n return;\n }\n if (typeof currentValue !== 'object' || currentValue == null) {\n // in case the value is not an object, the \"original\" validation phase should complain.\n return;\n }\n const inputType = unwrapType(graphqlType);\n const isOneOfInputType = ((_a = inputType.extensions) === null || _a === void 0 ? void 0 : _a.oneOf) || (inputType.astNode && getDirectiveFromAstNode(inputType.astNode, 'oneOf'));\n if (isOneOfInputType) {\n if (Object.keys(currentValue).length !== 1) {\n validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input type \"${inputType.name}\"`, [arg]));\n }\n }\n if (inputType instanceof GraphQLInputObjectType) {\n for (const [name, fieldConfig] of Object.entries(inputType.getFields())) {\n traverseVariables(validationContext, arg, fieldConfig.type, currentValue[name]);\n }\n }\n}\n\nexport { ONE_OF_DIRECTIVE_SDL, OneOfInputObjectsRule, getDirectiveFromAstNode, unwrapType, useExtendedValidation };\n//# sourceMappingURL=index.mjs.map\n","import { handleStreamOrSingleExecutionResult } from '@envelop/types';\nimport { useExtendedValidation } from '@envelop/extended-validation';\nimport { GraphQLError, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, } from 'graphql';\nimport { getArgumentValues } from 'graphql/execution/values.js';\nconst getWrappedType = (graphqlType) => {\n if (graphqlType instanceof GraphQLList || graphqlType instanceof GraphQLNonNull) {\n return getWrappedType(graphqlType.ofType);\n }\n return graphqlType;\n};\nconst hasFieldDefConnectionArgs = (field) => {\n let hasFirst = false;\n let hasLast = false;\n for (const arg of field.args) {\n if (arg.name === 'first' && arg.type === GraphQLInt) {\n hasFirst = true;\n }\n else if (arg.name === 'last' && arg.type === GraphQLInt) {\n hasLast = true;\n }\n else if (hasLast && hasFirst) {\n break;\n }\n }\n return { hasFirst, hasLast };\n};\nconst buildMissingPaginationFieldErrorMessage = (params) => `Missing pagination argument for field '${params.fieldName}'. ` +\n `Please provide ` +\n (params.hasFirst && params.hasLast ? \"either the 'first' or 'last'\" : params.hasFirst ? \"the 'first'\" : \"the 'last'\") +\n ' field argument.';\nconst buildInvalidPaginationRangeErrorMessage = (params) => `Invalid pagination argument for field ${params.fieldName}. ` +\n `The value for the '${params.argumentName}' argument must be an integer within 1-100.`;\nexport const defaultNodeCostLimit = 500000;\n/**\n * Validate whether a user is allowed to execute a certain GraphQL operation.\n */\nexport const ResourceLimitationValidationRule = (params) => (context, executionArgs) => {\n const nodeCostStack = [];\n let totalNodeCost = 0;\n const connectionFieldMap = new WeakSet();\n return {\n Field: {\n enter(fieldNode) {\n const fieldDef = context.getFieldDef();\n // if it is not found the query is invalid and graphql validation will complain\n if (fieldDef != null) {\n const argumentValues = getArgumentValues(fieldDef, fieldNode, executionArgs.variableValues);\n const type = getWrappedType(fieldDef.type);\n if (type instanceof GraphQLObjectType && type.name.endsWith('Connection')) {\n let nodeCost = 1;\n connectionFieldMap.add(fieldNode);\n const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef);\n if (hasFirst === false && hasLast === false) {\n // eslint-disable-next-line no-console\n console.warn('Encountered paginated field without pagination arguments.');\n }\n else if (hasFirst === true || hasLast === true) {\n if ('first' in argumentValues === false && 'last' in argumentValues === false) {\n context.reportError(new GraphQLError(buildMissingPaginationFieldErrorMessage({\n fieldName: fieldDef.name,\n hasFirst,\n hasLast,\n }), fieldNode));\n }\n else if ('first' in argumentValues === true && 'last' in argumentValues === false) {\n // eslint-disable-next-line dot-notation\n if (argumentValues['first'] < 1 || argumentValues['first'] > 100) {\n context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({\n fieldName: fieldDef.name,\n argumentName: 'first',\n }), fieldNode));\n }\n else {\n // eslint-disable-next-line dot-notation\n nodeCost = argumentValues['first'];\n }\n }\n else if ('last' in argumentValues === true && 'false' in argumentValues === false) {\n // eslint-disable-next-line dot-notation\n if (argumentValues['last'] < 1 || argumentValues['last'] > 100) {\n context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({\n fieldName: fieldDef.name,\n argumentName: 'last',\n }), fieldNode));\n }\n else {\n // eslint-disable-next-line dot-notation\n nodeCost = argumentValues['last'];\n }\n }\n else {\n context.reportError(new GraphQLError(buildMissingPaginationFieldErrorMessage({\n fieldName: fieldDef.name,\n hasFirst,\n hasLast,\n }), fieldNode));\n }\n }\n nodeCostStack.push(nodeCost);\n }\n }\n },\n leave(node) {\n if (connectionFieldMap.delete(node)) {\n totalNodeCost = totalNodeCost + nodeCostStack.reduce((a, b) => a * b, 1);\n nodeCostStack.pop();\n }\n },\n },\n Document: {\n leave(documentNode) {\n var _a;\n if (totalNodeCost === 0) {\n totalNodeCost = 1;\n }\n if (totalNodeCost > params.nodeCostLimit) {\n context.reportError(new GraphQLError(`Cannot request more than ${params.nodeCostLimit} nodes in a single document. Please split your operation into multiple sub operations or reduce the amount of requested nodes.`, documentNode));\n }\n (_a = params.reportNodeCost) === null || _a === void 0 ? void 0 : _a.call(params, totalNodeCost, executionArgs);\n },\n },\n };\n};\nexport const useResourceLimitations = (params) => {\n var _a, _b;\n const nodeCostLimit = (_a = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _a !== void 0 ? _a : defaultNodeCostLimit;\n const extensions = (_b = params === null || params === void 0 ? void 0 : params.extensions) !== null && _b !== void 0 ? _b : false;\n const nodeCostMap = new WeakMap();\n const handleResult = ({ result, args }) => {\n const nodeCost = nodeCostMap.get(args);\n if (nodeCost != null) {\n result.extensions = {\n ...result.extensions,\n resourceLimitations: {\n nodeCost,\n },\n };\n }\n };\n return {\n onPluginInit({ addPlugin }) {\n addPlugin(useExtendedValidation({\n rules: [\n ResourceLimitationValidationRule({\n nodeCostLimit,\n reportNodeCost: extensions\n ? (nodeCost, ref) => {\n nodeCostMap.set(ref, nodeCost);\n }\n : undefined,\n }),\n ],\n onValidationFailed: params => handleResult(params),\n }));\n },\n onExecute({ args }) {\n return {\n onExecuteDone(payload) {\n return handleStreamOrSingleExecutionResult(payload, ({ result }) => handleResult({ result, args }));\n },\n };\n },\n };\n};\n//# sourceMappingURL=index.js.map"],"names":["TypeInfo","ValidationContext","visitInParallel","visit","visitWithTypeInfo","GraphQLList","GraphQLNonNull","GraphQLInt","getArgumentValues","GraphQLObjectType","GraphQLError"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,kBAAkB,EAAE;AAC7C,IAAI,OAAO,QAAQ,kBAAkB,KAAK,IAAI,IAAI,kBAAkB,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,UAAU,CAAC;AACpJ,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,mCAAmC,CAAC,OAAO,EAAE,EAAE,EAAE;AAC1D,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzC,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9B,KAAK;AACL,SAAS;AACT,QAAQ,EAAE,CAAC;AACX,YAAY,MAAM,EAAE,OAAO,CAAC,MAAM;AAClC,YAAY,SAAS,EAAE,OAAO,CAAC,SAAS;AACxC,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL;;ACxBA,MAAM,gCAAgC,GAAG,MAAM,CAAC,kCAAkC,CAAC,CAAC;AACpF,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,IAAI,cAAc,CAAC;AACvB,IAAI,OAAO;AACX,QAAQ,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;AACnC,YAAY,cAAc,GAAG,IAAIA,gBAAQ,CAAC,MAAM,CAAC,CAAC;AAClD,SAAS;AACT,QAAQ,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE;AAC5C,YAAY,IAAI,EAAE,CAAC;AACnB,YAAY,MAAM,KAAK,GAAG,CAAC,EAAE,GAAG,OAAO,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js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../packages/types/dist/index.mjs","../../../packages/plugins/extended-validation/dist/index.mjs","../../../dist/plugins/resource-limitations/src/index.js"],"sourcesContent":["/**\n * Returns true if the provided object implements the AsyncIterator protocol via\n * implementing a `Symbol.asyncIterator` method.\n *\n * Source: https://github.com/graphql/graphql-js/blob/main/src/jsutils/isAsyncIterable.ts\n */\nfunction isAsyncIterable(maybeAsyncIterable) {\n return typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 ? void 0 : maybeAsyncIterable[Symbol.asyncIterator]) === 'function';\n}\n/**\n * A utility function for hanlding `onExecuteDone` hook result, for simplifying the hanlding of AsyncIterable returned from `execute`.\n *\n * @param payload The payload send to `onExecuteDone` hook function\n * @param fn The handler to be executed on each result\n * @returns a subscription for streamed results, or undefined in case of an non-async\n */\nfunction handleStreamOrSingleExecutionResult(payload, fn) {\n if (isAsyncIterable(payload.result)) {\n return { onNext: fn };\n }\n else {\n fn({\n result: payload.result,\n setResult: payload.setResult,\n });\n return undefined;\n }\n}\n\nexport { handleStreamOrSingleExecutionResult, isAsyncIterable };\n//# sourceMappingURL=index.mjs.map\n","import { TypeInfo, ValidationContext, visitInParallel, visit, visitWithTypeInfo, isNonNullType, isListType, GraphQLError, GraphQLInputObjectType } from 'graphql';\nimport { getArgumentValues } from 'graphql/execution/values';\n\nconst SYMBOL_EXTENDED_VALIDATION_RULES = Symbol('SYMBOL_EXTENDED_VALIDATION_RULES');\nconst useExtendedValidation = (options) => {\n let schemaTypeInfo;\n return {\n onSchemaChange({ schema }) {\n schemaTypeInfo = new TypeInfo(schema);\n },\n onParse({ context, extendContext }) {\n var _a;\n const rules = (_a = context === null || context === void 0 ? void 0 : context[SYMBOL_EXTENDED_VALIDATION_RULES]) !== null && _a !== void 0 ? _a : [];\n rules.push(...options.rules);\n extendContext({\n [SYMBOL_EXTENDED_VALIDATION_RULES]: rules,\n });\n },\n onExecute({ args, setResultAndStopExecution }) {\n const rules = args.contextValue[SYMBOL_EXTENDED_VALIDATION_RULES];\n const errors = [];\n const typeInfo = schemaTypeInfo || new TypeInfo(args.schema);\n const validationContext = new ValidationContext(args.schema, args.document, typeInfo, e => {\n errors.push(e);\n });\n const visitor = visitInParallel(rules.map(rule => rule(validationContext, args)));\n visit(args.document, visitWithTypeInfo(typeInfo, visitor));\n for (const rule of rules) {\n rule(validationContext, args);\n }\n if (errors.length > 0) {\n let result = {\n data: null,\n errors,\n };\n if (options.onValidationFailed) {\n options.onValidationFailed({ args, result, setResult: newResult => (result = newResult) });\n }\n return setResultAndStopExecution(result);\n }\n },\n };\n};\n\nfunction getDirectiveFromAstNode(astNode, names) {\n const directives = astNode.directives || [];\n const namesArr = Array.isArray(names) ? names : [names];\n const authDirective = directives.find(d => namesArr.includes(d.name.value));\n return authDirective || null;\n}\nfunction unwrapType(type) {\n if (isNonNullType(type) || isListType(type)) {\n return unwrapType(type.ofType);\n }\n return type;\n}\n\nconst ONE_OF_DIRECTIVE_SDL = /* GraphQL */ `\n directive @oneOf on INPUT_OBJECT | FIELD_DEFINITION\n`;\nconst OneOfInputObjectsRule = (validationContext, executionArgs) => {\n return {\n Field: node => {\n var _a, _b;\n if ((_a = node.arguments) === null || _a === void 0 ? void 0 : _a.length) {\n const fieldType = validationContext.getFieldDef();\n if (!fieldType) {\n return;\n }\n const values = getArgumentValues(fieldType, node, executionArgs.variableValues);\n if (fieldType) {\n const isOneOfFieldType = ((_b = fieldType.extensions) === null || _b === void 0 ? void 0 : _b.oneOf) || (fieldType.astNode && getDirectiveFromAstNode(fieldType.astNode, 'oneOf'));\n if (isOneOfFieldType) {\n if (Object.keys(values).length !== 1) {\n validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input for field \"${fieldType.type.toString()}.${node.name.value}\"`, [node]));\n }\n }\n }\n for (const arg of node.arguments) {\n const argType = fieldType.args.find(typeArg => typeArg.name === arg.name.value);\n if (argType) {\n traverseVariables(validationContext, arg, argType.type, values[arg.name.value]);\n }\n }\n }\n },\n };\n};\nfunction traverseVariables(validationContext, arg, graphqlType, currentValue) {\n var _a;\n // if the current value is empty we don't need to traverse deeper\n // if it shouldn't be empty, the \"original\" validation phase should complain.\n if (currentValue == null) {\n return;\n }\n if (isListType(graphqlType)) {\n if (!Array.isArray(currentValue)) {\n // because of graphql type coercion a single object should be treated as an array of one object\n currentValue = [currentValue];\n }\n currentValue.forEach(value => {\n traverseVariables(validationContext, arg, graphqlType.ofType, value);\n });\n return;\n }\n if (typeof currentValue !== 'object' || currentValue == null) {\n // in case the value is not an object, the \"original\" validation phase should complain.\n return;\n }\n const inputType = unwrapType(graphqlType);\n const isOneOfInputType = ((_a = inputType.extensions) === null || _a === void 0 ? void 0 : _a.oneOf) || (inputType.astNode && getDirectiveFromAstNode(inputType.astNode, 'oneOf'));\n if (isOneOfInputType) {\n if (Object.keys(currentValue).length !== 1) {\n validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input type \"${inputType.name}\"`, [arg]));\n }\n }\n if (inputType instanceof GraphQLInputObjectType) {\n for (const [name, fieldConfig] of Object.entries(inputType.getFields())) {\n traverseVariables(validationContext, arg, fieldConfig.type, currentValue[name]);\n }\n }\n}\n\nexport { ONE_OF_DIRECTIVE_SDL, OneOfInputObjectsRule, getDirectiveFromAstNode, unwrapType, useExtendedValidation };\n//# sourceMappingURL=index.mjs.map\n","import { handleStreamOrSingleExecutionResult } from '@envelop/types';\nimport { useExtendedValidation } from '@envelop/extended-validation';\nimport { GraphQLError, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, } from 'graphql';\nimport { getArgumentValues } from 'graphql/execution/values.js';\nconst getWrappedType = (graphqlType) => {\n if (graphqlType instanceof GraphQLList || graphqlType instanceof GraphQLNonNull) {\n return getWrappedType(graphqlType.ofType);\n }\n return graphqlType;\n};\nconst hasFieldDefConnectionArgs = (field) => {\n let hasFirst = false;\n let hasLast = false;\n for (const arg of field.args) {\n if (arg.name === 'first' && arg.type === GraphQLInt) {\n hasFirst = true;\n }\n else if (arg.name === 'last' && arg.type === GraphQLInt) {\n hasLast = true;\n }\n else if (hasLast && hasFirst) {\n break;\n }\n }\n return { hasFirst, hasLast };\n};\nconst buildMissingPaginationFieldErrorMessage = (params) => `Missing pagination argument for field '${params.fieldName}'. ` +\n `Please provide ` +\n (params.hasFirst && params.hasLast ? \"either the 'first' or 'last'\" : params.hasFirst ? \"the 'first'\" : \"the 'last'\") +\n ' field argument.';\nconst buildInvalidPaginationRangeErrorMessage = (params) => `Invalid pagination argument for field ${params.fieldName}. ` +\n `The value for the '${params.argumentName}' argument must be an integer within 1-100.`;\nexport const defaultNodeCostLimit = 500000;\n/**\n * Validate whether a user is allowed to execute a certain GraphQL operation.\n */\nexport const ResourceLimitationValidationRule = (params) => (context, executionArgs) => {\n const nodeCostStack = [];\n let totalNodeCost = 0;\n const connectionFieldMap = new WeakSet();\n return {\n Field: {\n enter(fieldNode) {\n const fieldDef = context.getFieldDef();\n // if it is not found the query is invalid and graphql validation will complain\n if (fieldDef != null) {\n const argumentValues = getArgumentValues(fieldDef, fieldNode, executionArgs.variableValues);\n const type = getWrappedType(fieldDef.type);\n if (type instanceof GraphQLObjectType && type.name.endsWith('Connection')) {\n let nodeCost = 1;\n connectionFieldMap.add(fieldNode);\n const { hasFirst, hasLast } = hasFieldDefConnectionArgs(fieldDef);\n if (hasFirst === false && hasLast === false) {\n // eslint-disable-next-line no-console\n console.warn('Encountered paginated field without pagination arguments.');\n }\n else if (hasFirst === true || hasLast === true) {\n if ('first' in argumentValues === false && 'last' in argumentValues === false) {\n context.reportError(new GraphQLError(buildMissingPaginationFieldErrorMessage({\n fieldName: fieldDef.name,\n hasFirst,\n hasLast,\n }), fieldNode));\n }\n else if ('first' in argumentValues === true && 'last' in argumentValues === false) {\n // eslint-disable-next-line dot-notation\n if (argumentValues['first'] < 1 || argumentValues['first'] > 100) {\n context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({\n fieldName: fieldDef.name,\n argumentName: 'first',\n }), fieldNode));\n }\n else {\n // eslint-disable-next-line dot-notation\n nodeCost = argumentValues['first'];\n }\n }\n else if ('last' in argumentValues === true && 'false' in argumentValues === false) {\n // eslint-disable-next-line dot-notation\n if (argumentValues['last'] < 1 || argumentValues['last'] > 100) {\n context.reportError(new GraphQLError(buildInvalidPaginationRangeErrorMessage({\n fieldName: fieldDef.name,\n argumentName: 'last',\n }), fieldNode));\n }\n else {\n // eslint-disable-next-line dot-notation\n nodeCost = argumentValues['last'];\n }\n }\n else {\n context.reportError(new GraphQLError(buildMissingPaginationFieldErrorMessage({\n fieldName: fieldDef.name,\n hasFirst,\n hasLast,\n }), fieldNode));\n }\n }\n nodeCostStack.push(nodeCost);\n }\n }\n },\n leave(node) {\n if (connectionFieldMap.delete(node)) {\n totalNodeCost = totalNodeCost + nodeCostStack.reduce((a, b) => a * b, 1);\n nodeCostStack.pop();\n }\n },\n },\n Document: {\n leave(documentNode) {\n var _a;\n if (totalNodeCost === 0) {\n totalNodeCost = 1;\n }\n if (totalNodeCost > params.nodeCostLimit) {\n context.reportError(new GraphQLError(`Cannot request more than ${params.nodeCostLimit} nodes in a single document. Please split your operation into multiple sub operations or reduce the amount of requested nodes.`, documentNode));\n }\n (_a = params.reportNodeCost) === null || _a === void 0 ? void 0 : _a.call(params, totalNodeCost, executionArgs);\n },\n },\n };\n};\nexport const useResourceLimitations = (params) => {\n var _a, _b;\n const nodeCostLimit = (_a = params === null || params === void 0 ? void 0 : params.nodeCostLimit) !== null && _a !== void 0 ? _a : defaultNodeCostLimit;\n const extensions = (_b = params === null || params === void 0 ? void 0 : params.extensions) !== null && _b !== void 0 ? _b : false;\n const nodeCostMap = new WeakMap();\n const handleResult = ({ result, args }) => {\n const nodeCost = nodeCostMap.get(args);\n if (nodeCost != null) {\n result.extensions = {\n ...result.extensions,\n resourceLimitations: {\n nodeCost,\n },\n };\n }\n };\n return {\n onPluginInit({ addPlugin }) {\n addPlugin(useExtendedValidation({\n rules: [\n ResourceLimitationValidationRule({\n nodeCostLimit,\n reportNodeCost: extensions\n ? (nodeCost, ref) => {\n nodeCostMap.set(ref, nodeCost);\n }\n : undefined,\n }),\n ],\n onValidationFailed: params => handleResult(params),\n }));\n },\n onExecute({ args }) {\n return {\n onExecuteDone(payload) {\n return handleStreamOrSingleExecutionResult(payload, ({ result }) => handleResult({ result, args }));\n },\n };\n },\n };\n};\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,kBAAkB,EAAE;AAC7C,IAAI,OAAO,QAAQ,kBAAkB,KAAK,IAAI,IAAI,kBAAkB,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,KAAK,UAAU,CAAC;AACpJ,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,mCAAmC,CAAC,OAAO,EAAE,EAAE,EAAE;AAC1D,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzC,QAAQ,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9B,KAAK;AACL,SAAS;AACT,QAAQ,EAAE,CAAC;AACX,YAAY,MAAM,EAAE,OAAO,CAAC,MAAM;AAClC,YAAY,SAAS,EAAE,OAAO,CAAC,SAAS;AACxC,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,SAAS,CAAC;AACzB,KAAK;AACL;;ACxBA,MAAM,gCAAgC,GAAG,MAAM,CAAC,kCAAkC,CAAC,CAAC;AACpF,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,IAAI,cAAc,CAAC;AACvB,IAAI,OAAO;AACX,QAAQ,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE;AACnC,YAAY,cAAc,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;AAClD,SAAS;AACT,QAAQ,OAAO,CAAC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