@envelop/resource-limitations 3.0.0-alpha-ccec0fc.0 → 3.0.0-alpha-7ed14a0a.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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@envelop/resource-limitations",
3
- "version": "3.0.0-alpha-ccec0fc.0",
3
+ "version": "3.0.0-alpha-7ed14a0a.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
- "@envelop/core": "3.0.0-alpha-ccec0fc.0",
8
- "@graphql-tools/graphql": "0.1.0-alpha-e7752ba5.0"
7
+ "@envelop/core": "3.0.0-alpha-7ed14a0a.0",
8
+ "@graphql-tools/graphql": "0.1.0-alpha-25f2d2c4.0"
9
9
  },
10
10
  "dependencies": {
11
- "@envelop/extended-validation": "2.0.0-alpha-ccec0fc.0",
12
- "@graphql-tools/utils": "8.9.1-alpha-e7752ba5.0"
11
+ "@envelop/extended-validation": "2.0.0-alpha-7ed14a0a.0",
12
+ "@graphql-tools/utils": "8.9.1-alpha-25f2d2c4.0"
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "exports": {
29
29
  ".": {
30
30
  "require": {
31
- "types": "./typings/index.d.ts",
31
+ "types": "./typings/index.d.cts",
32
32
  "default": "./cjs/index.js"
33
33
  },
34
34
  "import": {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "./*": {
44
44
  "require": {
45
- "types": "./typings/*.d.ts",
45
+ "types": "./typings/*.d.cts",
46
46
  "default": "./cjs/*.js"
47
47
  },
48
48
  "import": {
@@ -0,0 +1,45 @@
1
+ import { Plugin } from '@envelop/core';
2
+ import { ExtendedValidationRule } from '@envelop/extended-validation';
3
+ import { ExecutionArgs } from '@graphql-tools/graphql';
4
+ export declare const defaultNodeCostLimit = 500000;
5
+ export declare const defaultPaginationArgumentMaximum = 100;
6
+ export declare const defaultPaginationArgumentMinimum = 1;
7
+ export declare type ResourceLimitationValidationRuleParams = {
8
+ nodeCostLimit: number;
9
+ paginationArgumentMaximum: number;
10
+ paginationArgumentMinimum: number;
11
+ paginationArgumentTypes?: string[];
12
+ reportNodeCost?: (cost: number, executionArgs: ExecutionArgs) => void;
13
+ };
14
+ /**
15
+ * Validate whether a user is allowed to execute a certain GraphQL operation.
16
+ */
17
+ export declare const ResourceLimitationValidationRule: (params: ResourceLimitationValidationRuleParams) => ExtendedValidationRule;
18
+ declare type UseResourceLimitationsParams = {
19
+ /**
20
+ * The node cost limit for rejecting a operation.
21
+ * @default 500000
22
+ */
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;
38
+ /**
39
+ * Whether the resourceLimitations.nodeCost field should be included within the execution result extensions map.
40
+ * @default false
41
+ */
42
+ extensions?: boolean;
43
+ };
44
+ export declare const useResourceLimitations: (params?: UseResourceLimitationsParams) => Plugin;
45
+ export {};