@graphitation/supermassive 2.6.1 → 3.0.0-alpha.3
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/.eslintcache +1 -1
- package/CHANGELOG.md +17 -1
- package/lib/__testUtils__/execute.d.ts +13 -0
- package/lib/__testUtils__/execute.d.ts.map +1 -0
- package/lib/__testUtils__/execute.js +196 -0
- package/lib/__testUtils__/execute.js.map +7 -0
- package/lib/__testUtils__/execute.mjs +174 -0
- package/lib/__testUtils__/execute.mjs.map +7 -0
- package/lib/benchmarks/index.js +11 -20
- package/lib/benchmarks/index.js.map +3 -3
- package/lib/benchmarks/index.mjs +12 -23
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/index.d.ts +4 -2
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +8 -2
- package/lib/benchmarks/swapi-schema/index.js.map +2 -2
- package/lib/benchmarks/swapi-schema/index.mjs +8 -2
- package/lib/benchmarks/swapi-schema/index.mjs.map +2 -2
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.d.ts.map +1 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js +916 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.js.map +7 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs +903 -0
- package/lib/benchmarks/swapi-schema/makeExecutableSchema.mjs.map +7 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +53 -17
- package/lib/benchmarks/swapi-schema/resolvers.js.map +2 -2
- package/lib/benchmarks/swapi-schema/resolvers.mjs +54 -18
- package/lib/benchmarks/swapi-schema/resolvers.mjs.map +2 -2
- package/lib/collectFields.d.ts +27 -10
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +146 -80
- package/lib/collectFields.js.map +3 -3
- package/lib/collectFields.mjs +143 -81
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithSchema.d.ts +1 -1
- package/lib/executeWithSchema.d.ts.map +1 -1
- package/lib/executeWithSchema.js +7 -13
- package/lib/executeWithSchema.js.map +2 -2
- package/lib/executeWithSchema.mjs +9 -20
- package/lib/executeWithSchema.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +53 -16
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +1076 -274
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +1092 -281
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/index.d.ts +3 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -7
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +3 -10
- package/lib/index.mjs.map +2 -2
- package/lib/jsutils/AccumulatorMap.d.ts +8 -0
- package/lib/jsutils/AccumulatorMap.d.ts.map +1 -0
- package/lib/jsutils/AccumulatorMap.js +36 -0
- package/lib/jsutils/AccumulatorMap.js.map +7 -0
- package/lib/jsutils/AccumulatorMap.mjs +17 -0
- package/lib/jsutils/AccumulatorMap.mjs.map +7 -0
- package/lib/jsutils/didYouMean.d.ts +1 -2
- package/lib/jsutils/didYouMean.d.ts.map +1 -1
- package/lib/jsutils/didYouMean.js.map +2 -2
- package/lib/jsutils/didYouMean.mjs.map +2 -2
- package/lib/jsutils/instanceOf.js.map +2 -2
- package/lib/jsutils/instanceOf.mjs.map +2 -2
- package/lib/schema/definition.d.ts +95 -0
- package/lib/schema/definition.d.ts.map +1 -0
- package/lib/schema/definition.js +77 -0
- package/lib/schema/definition.js.map +7 -0
- package/lib/schema/definition.mjs +58 -0
- package/lib/schema/definition.mjs.map +7 -0
- package/lib/schema/directives.d.ts +41 -0
- package/lib/schema/directives.d.ts.map +1 -0
- package/lib/schema/directives.js +82 -0
- package/lib/schema/directives.js.map +7 -0
- package/lib/schema/directives.mjs +65 -0
- package/lib/schema/directives.mjs.map +7 -0
- package/lib/schema/fragment.d.ts +41 -0
- package/lib/schema/fragment.d.ts.map +1 -0
- package/lib/schema/fragment.js +270 -0
- package/lib/schema/fragment.js.map +7 -0
- package/lib/schema/fragment.mjs +267 -0
- package/lib/schema/fragment.mjs.map +7 -0
- package/lib/schema/reference.d.ts +12 -0
- package/lib/schema/reference.d.ts.map +1 -0
- package/lib/schema/reference.js +137 -0
- package/lib/schema/reference.js.map +7 -0
- package/lib/schema/reference.mjs +118 -0
- package/lib/schema/reference.mjs.map +7 -0
- package/lib/schema/resolvers.d.ts +9 -0
- package/lib/schema/resolvers.d.ts.map +1 -0
- package/lib/schema/resolvers.js +47 -0
- package/lib/schema/resolvers.js.map +7 -0
- package/lib/schema/resolvers.mjs +35 -0
- package/lib/schema/resolvers.mjs.map +7 -0
- package/lib/subscribeWithSchema.d.ts +3 -2
- package/lib/subscribeWithSchema.d.ts.map +1 -1
- package/lib/subscribeWithSchema.js +7 -13
- package/lib/subscribeWithSchema.js.map +2 -2
- package/lib/subscribeWithSchema.mjs +9 -20
- package/lib/subscribeWithSchema.mjs.map +2 -2
- package/lib/subscribeWithoutSchema.d.ts +3 -35
- package/lib/subscribeWithoutSchema.d.ts.map +1 -1
- package/lib/subscribeWithoutSchema.js +1 -163
- package/lib/subscribeWithoutSchema.js.map +2 -2
- package/lib/subscribeWithoutSchema.mjs +2 -175
- package/lib/subscribeWithoutSchema.mjs.map +2 -2
- package/lib/types.d.ts +71 -29
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +14 -0
- package/lib/types.js.map +2 -2
- package/lib/types.mjs +11 -0
- package/lib/types.mjs.map +3 -3
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts +9 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.d.ts.map +1 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js +303 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.js.map +7 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs +317 -0
- package/lib/utilities/addMinimalViableSchemaToRequestDocument.mjs.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.js +34 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.js.map +7 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs +17 -0
- package/lib/utilities/annotateDocumentGraphQLTransform.mjs.map +7 -0
- package/lib/utilities/coerceInputValue.d.ts +10 -0
- package/lib/utilities/coerceInputValue.d.ts.map +1 -0
- package/lib/utilities/coerceInputValue.js +181 -0
- package/lib/utilities/coerceInputValue.js.map +7 -0
- package/lib/utilities/coerceInputValue.mjs +167 -0
- package/lib/utilities/coerceInputValue.mjs.map +7 -0
- package/lib/utilities/decodeASTSchema.d.ts +7 -0
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/decodeASTSchema.js +243 -0
- package/lib/utilities/decodeASTSchema.js.map +7 -0
- package/lib/utilities/decodeASTSchema.mjs +242 -0
- package/lib/utilities/decodeASTSchema.mjs.map +7 -0
- package/lib/utilities/encodeASTSchema.d.ts +4 -0
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -0
- package/lib/utilities/encodeASTSchema.js +122 -0
- package/lib/utilities/encodeASTSchema.js.map +7 -0
- package/lib/utilities/encodeASTSchema.mjs +105 -0
- package/lib/utilities/encodeASTSchema.mjs.map +7 -0
- package/lib/utilities/getSchemaFragment.d.ts +4 -0
- package/lib/utilities/getSchemaFragment.d.ts.map +1 -0
- package/lib/utilities/getSchemaFragment.js +38 -0
- package/lib/utilities/getSchemaFragment.js.map +7 -0
- package/lib/utilities/getSchemaFragment.mjs +22 -0
- package/lib/utilities/getSchemaFragment.mjs.map +7 -0
- package/lib/utilities/makeReadableErrorPath.d.ts +3 -0
- package/lib/utilities/makeReadableErrorPath.d.ts.map +1 -0
- package/lib/utilities/makeReadableErrorPath.js +47 -0
- package/lib/utilities/makeReadableErrorPath.js.map +7 -0
- package/lib/utilities/makeReadableErrorPath.mjs +28 -0
- package/lib/utilities/makeReadableErrorPath.mjs.map +7 -0
- package/lib/utilities/mergeDefinitions.d.ts +8 -0
- package/lib/utilities/mergeDefinitions.d.ts.map +1 -0
- package/lib/utilities/mergeDefinitions.js +126 -0
- package/lib/utilities/mergeDefinitions.js.map +7 -0
- package/lib/utilities/mergeDefinitions.mjs +114 -0
- package/lib/utilities/mergeDefinitions.mjs.map +7 -0
- package/lib/utilities/mergeResolvers.d.ts +1 -1
- package/lib/utilities/mergeResolvers.d.ts.map +1 -1
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/typeNameFromAST.d.ts +1 -1
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -1
- package/lib/utilities/typeNameFromAST.js.map +2 -2
- package/lib/utilities/typeNameFromAST.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +27 -0
- package/lib/utilities/valueFromAST.d.ts.map +1 -0
- package/lib/utilities/valueFromAST.js +139 -0
- package/lib/utilities/valueFromAST.js.map +7 -0
- package/lib/utilities/valueFromAST.mjs +125 -0
- package/lib/utilities/valueFromAST.mjs.map +7 -0
- package/lib/utilities/valueFromASTUntyped.d.ts +21 -0
- package/lib/utilities/valueFromASTUntyped.d.ts.map +1 -0
- package/lib/utilities/valueFromASTUntyped.js +51 -0
- package/lib/utilities/valueFromASTUntyped.js.map +7 -0
- package/lib/utilities/valueFromASTUntyped.mjs +32 -0
- package/lib/utilities/valueFromASTUntyped.mjs.map +7 -0
- package/lib/values.d.ts +8 -13
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +83 -75
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +85 -83
- package/lib/values.mjs.map +2 -2
- package/package.json +8 -9
- package/lib/definition.d.ts +0 -7
- package/lib/definition.d.ts.map +0 -1
- package/lib/definition.js +0 -59
- package/lib/definition.js.map +0 -7
- package/lib/definition.mjs +0 -40
- package/lib/definition.mjs.map +0 -7
- package/lib/directives.d.ts +0 -79
- package/lib/directives.d.ts.map +0 -1
- package/lib/directives.js +0 -160
- package/lib/directives.js.map +0 -7
- package/lib/directives.mjs +0 -146
- package/lib/directives.mjs.map +0 -7
- package/lib/extractImplicitTypesRuntime.d.ts +0 -4
- package/lib/extractImplicitTypesRuntime.d.ts.map +0 -1
- package/lib/extractImplicitTypesRuntime.js +0 -123
- package/lib/extractImplicitTypesRuntime.js.map +0 -7
- package/lib/extractImplicitTypesRuntime.mjs +0 -114
- package/lib/extractImplicitTypesRuntime.mjs.map +0 -7
package/lib/directives.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { GraphQLArgument, DirectiveLocationEnum, GraphQLFieldConfigArgumentMap } from "graphql";
|
|
2
|
-
import type { Maybe } from "./jsutils/Maybe";
|
|
3
|
-
import type { DirectiveDefinitionNode } from "@graphitation/supermassive-ast";
|
|
4
|
-
/**
|
|
5
|
-
* Test if the given value is a GraphQL directive.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isDirective(directive: unknown): directive is GraphQLDirective;
|
|
8
|
-
export declare function assertDirective(directive: unknown): GraphQLDirective;
|
|
9
|
-
/**
|
|
10
|
-
* Custom extensions
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* Use a unique identifier name for your extension, for example the name of
|
|
14
|
-
* your library or project. Do not use a shortened identifier as this increases
|
|
15
|
-
* the risk of conflicts. We recommend you add at most one extension field,
|
|
16
|
-
* an object which can contain all the values you need.
|
|
17
|
-
*/
|
|
18
|
-
export interface GraphQLDirectiveExtensions {
|
|
19
|
-
[attributeName: string]: unknown;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Directives are used by the GraphQL runtime as a way of modifying execution
|
|
23
|
-
* behavior. Type system creators will usually not create these directly.
|
|
24
|
-
*/
|
|
25
|
-
export declare class GraphQLDirective {
|
|
26
|
-
name: string;
|
|
27
|
-
description: Maybe<string>;
|
|
28
|
-
locations: ReadonlyArray<DirectiveLocationEnum>;
|
|
29
|
-
args: ReadonlyArray<GraphQLArgument>;
|
|
30
|
-
isRepeatable: boolean;
|
|
31
|
-
extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
32
|
-
astNode: Maybe<DirectiveDefinitionNode>;
|
|
33
|
-
constructor(config: Readonly<GraphQLDirectiveConfig>);
|
|
34
|
-
toConfig(): GraphQLDirectiveNormalizedConfig;
|
|
35
|
-
toString(): string;
|
|
36
|
-
toJSON(): string;
|
|
37
|
-
get [Symbol.toStringTag](): string;
|
|
38
|
-
}
|
|
39
|
-
export interface GraphQLDirectiveConfig {
|
|
40
|
-
name: string;
|
|
41
|
-
description?: Maybe<string>;
|
|
42
|
-
locations: ReadonlyArray<DirectiveLocationEnum>;
|
|
43
|
-
args?: Maybe<GraphQLFieldConfigArgumentMap>;
|
|
44
|
-
isRepeatable?: Maybe<boolean>;
|
|
45
|
-
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
46
|
-
astNode?: Maybe<DirectiveDefinitionNode>;
|
|
47
|
-
}
|
|
48
|
-
interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
|
|
49
|
-
args: GraphQLFieldConfigArgumentMap;
|
|
50
|
-
isRepeatable: boolean;
|
|
51
|
-
extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Used to conditionally include fields or fragments.
|
|
55
|
-
*/
|
|
56
|
-
export declare const GraphQLIncludeDirective: GraphQLDirective;
|
|
57
|
-
/**
|
|
58
|
-
* Used to conditionally skip (exclude) fields or fragments.
|
|
59
|
-
*/
|
|
60
|
-
export declare const GraphQLSkipDirective: GraphQLDirective;
|
|
61
|
-
/**
|
|
62
|
-
* Constant string used for default reason for a deprecation.
|
|
63
|
-
*/
|
|
64
|
-
export declare const DEFAULT_DEPRECATION_REASON = "No longer supported";
|
|
65
|
-
/**
|
|
66
|
-
* Used to declare element of a GraphQL schema as deprecated.
|
|
67
|
-
*/
|
|
68
|
-
export declare const GraphQLDeprecatedDirective: GraphQLDirective;
|
|
69
|
-
/**
|
|
70
|
-
* Used to provide a URL for specifying the behaviour of custom scalar definitions.
|
|
71
|
-
*/
|
|
72
|
-
export declare const GraphQLSpecifiedByDirective: GraphQLDirective;
|
|
73
|
-
/**
|
|
74
|
-
* The full list of specified directives.
|
|
75
|
-
*/
|
|
76
|
-
export declare const specifiedDirectives: ReadonlyArray<GraphQLDirective>;
|
|
77
|
-
export declare function isSpecifiedDirective(directive: GraphQLDirective): boolean;
|
|
78
|
-
export {};
|
|
79
|
-
//# sourceMappingURL=directives.d.ts.map
|
package/lib/directives.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEf,qBAAqB,EAErB,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AAMjB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAI9E;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,gBAAgB,CAE7E;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,gBAAgB,CAOpE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,0BAA0B;IACzC,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,aA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L;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,gBAWtC,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,gBAAgB,CAM5D,CAAC;AAEL,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAEzE"}
|
package/lib/directives.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var directives_exports = {};
|
|
20
|
-
__export(directives_exports, {
|
|
21
|
-
DEFAULT_DEPRECATION_REASON: () => DEFAULT_DEPRECATION_REASON,
|
|
22
|
-
GraphQLDeprecatedDirective: () => GraphQLDeprecatedDirective,
|
|
23
|
-
GraphQLDirective: () => GraphQLDirective,
|
|
24
|
-
GraphQLIncludeDirective: () => GraphQLIncludeDirective,
|
|
25
|
-
GraphQLSkipDirective: () => GraphQLSkipDirective,
|
|
26
|
-
GraphQLSpecifiedByDirective: () => GraphQLSpecifiedByDirective,
|
|
27
|
-
assertDirective: () => assertDirective,
|
|
28
|
-
isDirective: () => isDirective,
|
|
29
|
-
isSpecifiedDirective: () => isSpecifiedDirective,
|
|
30
|
-
specifiedDirectives: () => specifiedDirectives
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(directives_exports);
|
|
33
|
-
var import_graphql = require("graphql");
|
|
34
|
-
var import_inspect = require("./jsutils/inspect");
|
|
35
|
-
var import_toObjMap = require("./jsutils/toObjMap");
|
|
36
|
-
var import_devAssert = require("./jsutils/devAssert");
|
|
37
|
-
var import_instanceOf = require("./jsutils/instanceOf");
|
|
38
|
-
var import_isObjectLike = require("./jsutils/isObjectLike");
|
|
39
|
-
var import_definition = require("./definition");
|
|
40
|
-
function isDirective(directive) {
|
|
41
|
-
return (0, import_instanceOf.instanceOf)(directive, GraphQLDirective);
|
|
42
|
-
}
|
|
43
|
-
function assertDirective(directive) {
|
|
44
|
-
if (!isDirective(directive)) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Expected ${(0, import_inspect.inspect)(directive)} to be a GraphQL directive.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return directive;
|
|
50
|
-
}
|
|
51
|
-
class GraphQLDirective {
|
|
52
|
-
constructor(config) {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
this.name = config.name;
|
|
55
|
-
this.description = config.description;
|
|
56
|
-
this.locations = config.locations;
|
|
57
|
-
this.isRepeatable = (_a = config.isRepeatable) != null ? _a : false;
|
|
58
|
-
this.extensions = config.extensions && (0, import_toObjMap.toObjMap)(config.extensions);
|
|
59
|
-
this.astNode = config.astNode;
|
|
60
|
-
(0, import_devAssert.devAssert)(config.name, "Directive must be named.");
|
|
61
|
-
(0, import_devAssert.devAssert)(
|
|
62
|
-
Array.isArray(config.locations),
|
|
63
|
-
`@${config.name} locations must be an Array.`
|
|
64
|
-
);
|
|
65
|
-
const args = (_b = config.args) != null ? _b : {};
|
|
66
|
-
(0, import_devAssert.devAssert)(
|
|
67
|
-
(0, import_isObjectLike.isObjectLike)(args) && !Array.isArray(args),
|
|
68
|
-
`@${config.name} args must be an object with argument names as keys.`
|
|
69
|
-
);
|
|
70
|
-
this.args = (0, import_definition.defineArguments)(args);
|
|
71
|
-
}
|
|
72
|
-
toConfig() {
|
|
73
|
-
return {
|
|
74
|
-
name: this.name,
|
|
75
|
-
description: this.description,
|
|
76
|
-
locations: this.locations,
|
|
77
|
-
args: (0, import_definition.argsToArgsConfig)(this.args),
|
|
78
|
-
isRepeatable: this.isRepeatable,
|
|
79
|
-
extensions: this.extensions,
|
|
80
|
-
astNode: this.astNode
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
toString() {
|
|
84
|
-
return "@" + this.name;
|
|
85
|
-
}
|
|
86
|
-
toJSON() {
|
|
87
|
-
return this.toString();
|
|
88
|
-
}
|
|
89
|
-
get [Symbol.toStringTag]() {
|
|
90
|
-
return "GraphQLDirective";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const GraphQLIncludeDirective = new GraphQLDirective({
|
|
94
|
-
name: "include",
|
|
95
|
-
description: "Directs the executor to include this field or fragment only when the `if` argument is true.",
|
|
96
|
-
locations: [
|
|
97
|
-
import_graphql.DirectiveLocation.FIELD,
|
|
98
|
-
import_graphql.DirectiveLocation.FRAGMENT_SPREAD,
|
|
99
|
-
import_graphql.DirectiveLocation.INLINE_FRAGMENT
|
|
100
|
-
],
|
|
101
|
-
args: {
|
|
102
|
-
if: {
|
|
103
|
-
type: new import_graphql.GraphQLNonNull(import_graphql.GraphQLBoolean),
|
|
104
|
-
description: "Included when true."
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
const GraphQLSkipDirective = new GraphQLDirective({
|
|
109
|
-
name: "skip",
|
|
110
|
-
description: "Directs the executor to skip this field or fragment when the `if` argument is true.",
|
|
111
|
-
locations: [
|
|
112
|
-
import_graphql.DirectiveLocation.FIELD,
|
|
113
|
-
import_graphql.DirectiveLocation.FRAGMENT_SPREAD,
|
|
114
|
-
import_graphql.DirectiveLocation.INLINE_FRAGMENT
|
|
115
|
-
],
|
|
116
|
-
args: {
|
|
117
|
-
if: {
|
|
118
|
-
type: new import_graphql.GraphQLNonNull(import_graphql.GraphQLBoolean),
|
|
119
|
-
description: "Skipped when true."
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
const DEFAULT_DEPRECATION_REASON = "No longer supported";
|
|
124
|
-
const GraphQLDeprecatedDirective = new GraphQLDirective({
|
|
125
|
-
name: "deprecated",
|
|
126
|
-
description: "Marks an element of a GraphQL schema as no longer supported.",
|
|
127
|
-
locations: [
|
|
128
|
-
import_graphql.DirectiveLocation.FIELD_DEFINITION,
|
|
129
|
-
import_graphql.DirectiveLocation.ARGUMENT_DEFINITION,
|
|
130
|
-
import_graphql.DirectiveLocation.INPUT_FIELD_DEFINITION,
|
|
131
|
-
import_graphql.DirectiveLocation.ENUM_VALUE
|
|
132
|
-
],
|
|
133
|
-
args: {
|
|
134
|
-
reason: {
|
|
135
|
-
type: import_graphql.GraphQLString,
|
|
136
|
-
description: "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",
|
|
137
|
-
defaultValue: DEFAULT_DEPRECATION_REASON
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
const GraphQLSpecifiedByDirective = new GraphQLDirective({
|
|
142
|
-
name: "specifiedBy",
|
|
143
|
-
description: "Exposes a URL that specifies the behaviour of this scalar.",
|
|
144
|
-
locations: [import_graphql.DirectiveLocation.SCALAR],
|
|
145
|
-
args: {
|
|
146
|
-
url: {
|
|
147
|
-
type: new import_graphql.GraphQLNonNull(import_graphql.GraphQLString),
|
|
148
|
-
description: "The URL that specifies the behaviour of this scalar."
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
const specifiedDirectives = Object.freeze([
|
|
153
|
-
GraphQLIncludeDirective,
|
|
154
|
-
GraphQLSkipDirective,
|
|
155
|
-
GraphQLDeprecatedDirective,
|
|
156
|
-
GraphQLSpecifiedByDirective
|
|
157
|
-
]);
|
|
158
|
-
function isSpecifiedDirective(directive) {
|
|
159
|
-
return specifiedDirectives.some(({ name }) => name === directive.name);
|
|
160
|
-
}
|
package/lib/directives.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/directives.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n GraphQLString,\n GraphQLBoolean,\n GraphQLArgument,\n GraphQLNonNull,\n DirectiveLocationEnum,\n DirectiveLocation,\n GraphQLFieldConfigArgumentMap,\n} from \"graphql\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { toObjMap } from \"./jsutils/toObjMap\";\nimport { devAssert } from \"./jsutils/devAssert\";\nimport { instanceOf } from \"./jsutils/instanceOf\";\nimport { isObjectLike } from \"./jsutils/isObjectLike\";\nimport type { Maybe } from \"./jsutils/Maybe\";\n\nimport type { DirectiveDefinitionNode } from \"@graphitation/supermassive-ast\";\n\nimport { defineArguments, argsToArgsConfig } from \"./definition\";\n\n/**\n * Test if the given value is a GraphQL directive.\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, GraphQLDirective);\n}\n\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective {\n name: string;\n description: Maybe<string>;\n locations: ReadonlyArray<DirectiveLocationEnum>;\n args: ReadonlyArray<GraphQLArgument>;\n isRepeatable: boolean;\n extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n astNode: Maybe<DirectiveDefinitionNode>;\n\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.name = config.name;\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n\n devAssert(config.name, \"Directive must be named.\");\n devAssert(\n Array.isArray(config.locations),\n `@${config.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${config.name} args must be an object with argument names as keys.`,\n );\n\n this.args = defineArguments(args);\n }\n\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: argsToArgsConfig(this.args),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return \"@\" + this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n get [Symbol.toStringTag]() {\n return \"GraphQLDirective\";\n }\n}\n\nexport interface GraphQLDirectiveConfig {\n name: string;\n description?: Maybe<string>;\n locations: ReadonlyArray<DirectiveLocationEnum>;\n args?: Maybe<GraphQLFieldConfigArgumentMap>;\n isRepeatable?: Maybe<boolean>;\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n astNode?: Maybe<DirectiveDefinitionNode>;\n}\n\ninterface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: \"include\",\n description:\n \"Directs the executor to include this field or fragment only when the `if` argument is true.\",\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: \"Included when true.\",\n },\n },\n});\n\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: \"skip\",\n description:\n \"Directs the executor to skip this field or fragment when the `if` argument is true.\",\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: \"Skipped when true.\",\n },\n },\n});\n\n/**\n * Constant string used for default reason for a deprecation.\n */\nexport const DEFAULT_DEPRECATION_REASON = \"No longer supported\";\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: \"deprecated\",\n description: \"Marks an element of a GraphQL schema as no longer supported.\",\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n ],\n args: {\n reason: {\n type: GraphQLString,\n description:\n \"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).\",\n defaultValue: DEFAULT_DEPRECATION_REASON,\n },\n },\n });\n\n/**\n * Used to provide a URL for specifying the behaviour of custom scalar definitions.\n */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: \"specifiedBy\",\n description: \"Exposes a URL that specifies the behaviour of this scalar.\",\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: \"The URL that specifies the behaviour of this scalar.\",\n },\n },\n });\n\n/**\n * The full list of specified directives.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n ]);\n\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAQO;AACP,qBAAwB;AACxB,sBAAyB;AACzB,uBAA0B;AAC1B,wBAA2B;AAC3B,0BAA6B;AAK7B,wBAAkD;AAK3C,SAAS,YAAY,WAAmD;AAC7E,aAAO,8BAAW,WAAW,gBAAgB;AAC/C;AAEO,SAAS,gBAAgB,WAAsC;AACpE,MAAI,CAAC,YAAY,SAAS,GAAG;AAC3B,UAAM,IAAI;AAAA,MACR,gBAAY,wBAAQ,SAAS;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;AAmBO,MAAM,iBAAiB;AAAA,EAS5B,YAAY,QAA0C;AA9DxD;AA+DI,SAAK,OAAO,OAAO;AACnB,SAAK,cAAc,OAAO;AAC1B,SAAK,YAAY,OAAO;AACxB,SAAK,gBAAe,YAAO,iBAAP,YAAuB;AAC3C,SAAK,aAAa,OAAO,kBAAc,0BAAS,OAAO,UAAU;AACjE,SAAK,UAAU,OAAO;AAEtB,oCAAU,OAAO,MAAM,0BAA0B;AACjD;AAAA,MACE,MAAM,QAAQ,OAAO,SAAS;AAAA,MAC9B,IAAI,OAAO;AAAA,IACb;AAEA,UAAM,QAAO,YAAO,SAAP,YAAe,CAAC;AAC7B;AAAA,UACE,kCAAa,IAAI,KAAK,CAAC,MAAM,QAAQ,IAAI;AAAA,MACzC,IAAI,OAAO;AAAA,IACb;AAEA,SAAK,WAAO,mCAAgB,IAAI;AAAA,EAClC;AAAA,EAE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AA,MACF,cAAc;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAKI,MAAM,8BACX,IAAI,iBAAiB;AAAA,EACnB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,WAAW,CAAC,iCAAkB,MAAM;AAAA,EACpC,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,MAAM,IAAI,8BAAe,4BAAa;AAAA,MACtC,aAAa;AAAA,IACf;AAAA,EACF;AACF,CAAC;AAKI,MAAM,sBACX,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEI,SAAS,qBAAqB,WAAsC;AACzE,SAAO,oBAAoB,KAAK,CAAC,EAAE,KAAK,MAAM,SAAS,UAAU,IAAI;AACvE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/lib/directives.mjs
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// src/directives.ts
|
|
2
|
-
import {
|
|
3
|
-
GraphQLString,
|
|
4
|
-
GraphQLBoolean,
|
|
5
|
-
GraphQLNonNull,
|
|
6
|
-
DirectiveLocation
|
|
7
|
-
} from "graphql";
|
|
8
|
-
import { inspect } from "./jsutils/inspect.mjs";
|
|
9
|
-
import { toObjMap } from "./jsutils/toObjMap.mjs";
|
|
10
|
-
import { devAssert } from "./jsutils/devAssert.mjs";
|
|
11
|
-
import { instanceOf } from "./jsutils/instanceOf.mjs";
|
|
12
|
-
import { isObjectLike } from "./jsutils/isObjectLike.mjs";
|
|
13
|
-
import { defineArguments, argsToArgsConfig } from "./definition.mjs";
|
|
14
|
-
function isDirective(directive) {
|
|
15
|
-
return instanceOf(directive, GraphQLDirective);
|
|
16
|
-
}
|
|
17
|
-
function assertDirective(directive) {
|
|
18
|
-
if (!isDirective(directive)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`Expected ${inspect(directive)} to be a GraphQL directive.`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return directive;
|
|
24
|
-
}
|
|
25
|
-
var GraphQLDirective = class {
|
|
26
|
-
constructor(config) {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
this.name = config.name;
|
|
29
|
-
this.description = config.description;
|
|
30
|
-
this.locations = config.locations;
|
|
31
|
-
this.isRepeatable = (_a = config.isRepeatable) != null ? _a : false;
|
|
32
|
-
this.extensions = config.extensions && toObjMap(config.extensions);
|
|
33
|
-
this.astNode = config.astNode;
|
|
34
|
-
devAssert(config.name, "Directive must be named.");
|
|
35
|
-
devAssert(
|
|
36
|
-
Array.isArray(config.locations),
|
|
37
|
-
`@${config.name} locations must be an Array.`
|
|
38
|
-
);
|
|
39
|
-
const args = (_b = config.args) != null ? _b : {};
|
|
40
|
-
devAssert(
|
|
41
|
-
isObjectLike(args) && !Array.isArray(args),
|
|
42
|
-
`@${config.name} args must be an object with argument names as keys.`
|
|
43
|
-
);
|
|
44
|
-
this.args = defineArguments(args);
|
|
45
|
-
}
|
|
46
|
-
toConfig() {
|
|
47
|
-
return {
|
|
48
|
-
name: this.name,
|
|
49
|
-
description: this.description,
|
|
50
|
-
locations: this.locations,
|
|
51
|
-
args: argsToArgsConfig(this.args),
|
|
52
|
-
isRepeatable: this.isRepeatable,
|
|
53
|
-
extensions: this.extensions,
|
|
54
|
-
astNode: this.astNode
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
toString() {
|
|
58
|
-
return "@" + this.name;
|
|
59
|
-
}
|
|
60
|
-
toJSON() {
|
|
61
|
-
return this.toString();
|
|
62
|
-
}
|
|
63
|
-
get [Symbol.toStringTag]() {
|
|
64
|
-
return "GraphQLDirective";
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var GraphQLIncludeDirective = new GraphQLDirective({
|
|
68
|
-
name: "include",
|
|
69
|
-
description: "Directs the executor to include this field or fragment only when the `if` argument is true.",
|
|
70
|
-
locations: [
|
|
71
|
-
DirectiveLocation.FIELD,
|
|
72
|
-
DirectiveLocation.FRAGMENT_SPREAD,
|
|
73
|
-
DirectiveLocation.INLINE_FRAGMENT
|
|
74
|
-
],
|
|
75
|
-
args: {
|
|
76
|
-
if: {
|
|
77
|
-
type: new GraphQLNonNull(GraphQLBoolean),
|
|
78
|
-
description: "Included when true."
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
var GraphQLSkipDirective = new GraphQLDirective({
|
|
83
|
-
name: "skip",
|
|
84
|
-
description: "Directs the executor to skip this field or fragment when the `if` argument is true.",
|
|
85
|
-
locations: [
|
|
86
|
-
DirectiveLocation.FIELD,
|
|
87
|
-
DirectiveLocation.FRAGMENT_SPREAD,
|
|
88
|
-
DirectiveLocation.INLINE_FRAGMENT
|
|
89
|
-
],
|
|
90
|
-
args: {
|
|
91
|
-
if: {
|
|
92
|
-
type: new GraphQLNonNull(GraphQLBoolean),
|
|
93
|
-
description: "Skipped when true."
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
var DEFAULT_DEPRECATION_REASON = "No longer supported";
|
|
98
|
-
var GraphQLDeprecatedDirective = new GraphQLDirective({
|
|
99
|
-
name: "deprecated",
|
|
100
|
-
description: "Marks an element of a GraphQL schema as no longer supported.",
|
|
101
|
-
locations: [
|
|
102
|
-
DirectiveLocation.FIELD_DEFINITION,
|
|
103
|
-
DirectiveLocation.ARGUMENT_DEFINITION,
|
|
104
|
-
DirectiveLocation.INPUT_FIELD_DEFINITION,
|
|
105
|
-
DirectiveLocation.ENUM_VALUE
|
|
106
|
-
],
|
|
107
|
-
args: {
|
|
108
|
-
reason: {
|
|
109
|
-
type: GraphQLString,
|
|
110
|
-
description: "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",
|
|
111
|
-
defaultValue: DEFAULT_DEPRECATION_REASON
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
var GraphQLSpecifiedByDirective = new GraphQLDirective({
|
|
116
|
-
name: "specifiedBy",
|
|
117
|
-
description: "Exposes a URL that specifies the behaviour of this scalar.",
|
|
118
|
-
locations: [DirectiveLocation.SCALAR],
|
|
119
|
-
args: {
|
|
120
|
-
url: {
|
|
121
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
122
|
-
description: "The URL that specifies the behaviour of this scalar."
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
var specifiedDirectives = Object.freeze([
|
|
127
|
-
GraphQLIncludeDirective,
|
|
128
|
-
GraphQLSkipDirective,
|
|
129
|
-
GraphQLDeprecatedDirective,
|
|
130
|
-
GraphQLSpecifiedByDirective
|
|
131
|
-
]);
|
|
132
|
-
function isSpecifiedDirective(directive) {
|
|
133
|
-
return specifiedDirectives.some(({ name }) => name === directive.name);
|
|
134
|
-
}
|
|
135
|
-
export {
|
|
136
|
-
DEFAULT_DEPRECATION_REASON,
|
|
137
|
-
GraphQLDeprecatedDirective,
|
|
138
|
-
GraphQLDirective,
|
|
139
|
-
GraphQLIncludeDirective,
|
|
140
|
-
GraphQLSkipDirective,
|
|
141
|
-
GraphQLSpecifiedByDirective,
|
|
142
|
-
assertDirective,
|
|
143
|
-
isDirective,
|
|
144
|
-
isSpecifiedDirective,
|
|
145
|
-
specifiedDirectives
|
|
146
|
-
};
|
package/lib/directives.mjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/directives.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n GraphQLString,\n GraphQLBoolean,\n GraphQLArgument,\n GraphQLNonNull,\n DirectiveLocationEnum,\n DirectiveLocation,\n GraphQLFieldConfigArgumentMap,\n} from \"graphql\";\nimport { inspect } from \"./jsutils/inspect\";\nimport { toObjMap } from \"./jsutils/toObjMap\";\nimport { devAssert } from \"./jsutils/devAssert\";\nimport { instanceOf } from \"./jsutils/instanceOf\";\nimport { isObjectLike } from \"./jsutils/isObjectLike\";\nimport type { Maybe } from \"./jsutils/Maybe\";\n\nimport type { DirectiveDefinitionNode } from \"@graphitation/supermassive-ast\";\n\nimport { defineArguments, argsToArgsConfig } from \"./definition\";\n\n/**\n * Test if the given value is a GraphQL directive.\n */\nexport function isDirective(directive: unknown): directive is GraphQLDirective {\n return instanceOf(directive, GraphQLDirective);\n}\n\nexport function assertDirective(directive: unknown): GraphQLDirective {\n if (!isDirective(directive)) {\n throw new Error(\n `Expected ${inspect(directive)} to be a GraphQL directive.`,\n );\n }\n return directive;\n}\n\n/**\n * Custom extensions\n *\n * @remarks\n * Use a unique identifier name for your extension, for example the name of\n * your library or project. Do not use a shortened identifier as this increases\n * the risk of conflicts. We recommend you add at most one extension field,\n * an object which can contain all the values you need.\n */\nexport interface GraphQLDirectiveExtensions {\n [attributeName: string]: unknown;\n}\n\n/**\n * Directives are used by the GraphQL runtime as a way of modifying execution\n * behavior. Type system creators will usually not create these directly.\n */\nexport class GraphQLDirective {\n name: string;\n description: Maybe<string>;\n locations: ReadonlyArray<DirectiveLocationEnum>;\n args: ReadonlyArray<GraphQLArgument>;\n isRepeatable: boolean;\n extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n astNode: Maybe<DirectiveDefinitionNode>;\n\n constructor(config: Readonly<GraphQLDirectiveConfig>) {\n this.name = config.name;\n this.description = config.description;\n this.locations = config.locations;\n this.isRepeatable = config.isRepeatable ?? false;\n this.extensions = config.extensions && toObjMap(config.extensions);\n this.astNode = config.astNode;\n\n devAssert(config.name, \"Directive must be named.\");\n devAssert(\n Array.isArray(config.locations),\n `@${config.name} locations must be an Array.`,\n );\n\n const args = config.args ?? {};\n devAssert(\n isObjectLike(args) && !Array.isArray(args),\n `@${config.name} args must be an object with argument names as keys.`,\n );\n\n this.args = defineArguments(args);\n }\n\n toConfig(): GraphQLDirectiveNormalizedConfig {\n return {\n name: this.name,\n description: this.description,\n locations: this.locations,\n args: argsToArgsConfig(this.args),\n isRepeatable: this.isRepeatable,\n extensions: this.extensions,\n astNode: this.astNode,\n };\n }\n\n toString(): string {\n return \"@\" + this.name;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n get [Symbol.toStringTag]() {\n return \"GraphQLDirective\";\n }\n}\n\nexport interface GraphQLDirectiveConfig {\n name: string;\n description?: Maybe<string>;\n locations: ReadonlyArray<DirectiveLocationEnum>;\n args?: Maybe<GraphQLFieldConfigArgumentMap>;\n isRepeatable?: Maybe<boolean>;\n extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n astNode?: Maybe<DirectiveDefinitionNode>;\n}\n\ninterface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {\n args: GraphQLFieldConfigArgumentMap;\n isRepeatable: boolean;\n extensions: Maybe<Readonly<GraphQLDirectiveExtensions>>;\n}\n\n/**\n * Used to conditionally include fields or fragments.\n */\nexport const GraphQLIncludeDirective: GraphQLDirective = new GraphQLDirective({\n name: \"include\",\n description:\n \"Directs the executor to include this field or fragment only when the `if` argument is true.\",\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: \"Included when true.\",\n },\n },\n});\n\n/**\n * Used to conditionally skip (exclude) fields or fragments.\n */\nexport const GraphQLSkipDirective: GraphQLDirective = new GraphQLDirective({\n name: \"skip\",\n description:\n \"Directs the executor to skip this field or fragment when the `if` argument is true.\",\n locations: [\n DirectiveLocation.FIELD,\n DirectiveLocation.FRAGMENT_SPREAD,\n DirectiveLocation.INLINE_FRAGMENT,\n ],\n args: {\n if: {\n type: new GraphQLNonNull(GraphQLBoolean),\n description: \"Skipped when true.\",\n },\n },\n});\n\n/**\n * Constant string used for default reason for a deprecation.\n */\nexport const DEFAULT_DEPRECATION_REASON = \"No longer supported\";\n\n/**\n * Used to declare element of a GraphQL schema as deprecated.\n */\nexport const GraphQLDeprecatedDirective: GraphQLDirective =\n new GraphQLDirective({\n name: \"deprecated\",\n description: \"Marks an element of a GraphQL schema as no longer supported.\",\n locations: [\n DirectiveLocation.FIELD_DEFINITION,\n DirectiveLocation.ARGUMENT_DEFINITION,\n DirectiveLocation.INPUT_FIELD_DEFINITION,\n DirectiveLocation.ENUM_VALUE,\n ],\n args: {\n reason: {\n type: GraphQLString,\n description:\n \"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).\",\n defaultValue: DEFAULT_DEPRECATION_REASON,\n },\n },\n });\n\n/**\n * Used to provide a URL for specifying the behaviour of custom scalar definitions.\n */\nexport const GraphQLSpecifiedByDirective: GraphQLDirective =\n new GraphQLDirective({\n name: \"specifiedBy\",\n description: \"Exposes a URL that specifies the behaviour of this scalar.\",\n locations: [DirectiveLocation.SCALAR],\n args: {\n url: {\n type: new GraphQLNonNull(GraphQLString),\n description: \"The URL that specifies the behaviour of this scalar.\",\n },\n },\n });\n\n/**\n * The full list of specified directives.\n */\nexport const specifiedDirectives: ReadonlyArray<GraphQLDirective> =\n Object.freeze([\n GraphQLIncludeDirective,\n GraphQLSkipDirective,\n GraphQLDeprecatedDirective,\n GraphQLSpecifiedByDirective,\n ]);\n\nexport function isSpecifiedDirective(directive: GraphQLDirective): boolean {\n return specifiedDirectives.some(({ name }) => name === directive.name);\n}\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAK7B,SAAS,iBAAiB,wBAAwB;AAK3C,SAAS,YAAY,WAAmD;AAC7E,SAAO,WAAW,WAAW,gBAAgB;AAC/C;AAEO,SAAS,gBAAgB,WAAsC;AACpE,MAAI,CAAC,YAAY,SAAS,GAAG;AAC3B,UAAM,IAAI;AAAA,MACR,YAAY,QAAQ,SAAS;AAAA,IAC/B;AAAA,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;AAAA,EACF;AACF,CAAC;AAKM,IAAM,uBAAyC,IAAI,iBAAiB;AAAA,EACzE,MAAM;AAAA,EACN,aACE;AAAA,EACF,WAAW;AAAA,IACT,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,EACpB;AAAA,EACA,MAAM;AAAA,IACJ,IAAI;AAAA,MACF,MAAM,IAAI,eAAe,cAAc;AAAA,MACvC,aAAa;AAAA,IACf;AAAA,EACF;AACF,CAAC;AAKM,IAAM,6BAA6B;AAKnC,IAAM,6BACX,IAAI,iBAAiB;AAAA,EACnB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,WAAW;AAAA,IACT,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,EACpB;AAAA,EACA,MAAM;AAAA,IACJ,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,aACE;AAAA,MACF,cAAc;AAAA,IAChB;AAAA,EACF;AACF,CAAC;AAKI,IAAM,8BACX,IAAI,iBAAiB;AAAA,EACnB,MAAM;AAAA,EACN,aAAa;AAAA,EACb,WAAW,CAAC,kBAAkB,MAAM;AAAA,EACpC,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,MAAM,IAAI,eAAe,aAAa;AAAA,MACtC,aAAa;AAAA,IACf;AAAA,EACF;AACF,CAAC;AAKI,IAAM,sBACX,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEI,SAAS,qBAAqB,WAAsC;AACzE,SAAO,oBAAoB,KAAK,CAAC,EAAE,KAAK,MAAM,SAAS,UAAU,IAAI;AACvE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { DocumentNode, GraphQLInputType } from "graphql";
|
|
2
|
-
import { Resolvers } from "./types";
|
|
3
|
-
export declare function extractImplicitTypes<TSource = unknown, TContext = unknown>(document: DocumentNode, getTypeByName: (name: string) => GraphQLInputType): Resolvers<TSource, TContext>;
|
|
4
|
-
//# sourceMappingURL=extractImplicitTypesRuntime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractImplicitTypesRuntime.d.ts","sourceRoot":"","sources":["../src/extractImplicitTypesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAgBZ,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,SAAS,EAA4C,MAAM,SAAS,CAAC;AAE9E,wBAAgB,oBAAoB,CAAC,OAAO,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,EACxE,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAChD,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CA6C9B"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var extractImplicitTypesRuntime_exports = {};
|
|
20
|
-
__export(extractImplicitTypesRuntime_exports, {
|
|
21
|
-
extractImplicitTypes: () => extractImplicitTypes
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(extractImplicitTypesRuntime_exports);
|
|
24
|
-
var import_graphql = require("graphql");
|
|
25
|
-
function extractImplicitTypes(document, getTypeByName) {
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
28
|
-
const implementedBy = {};
|
|
29
|
-
for (const astNode of document.definitions) {
|
|
30
|
-
if (astNode.kind === import_graphql.Kind.SCALAR_TYPE_DEFINITION) {
|
|
31
|
-
const name = astNode.name.value;
|
|
32
|
-
result[name] = new import_graphql.GraphQLScalarType({
|
|
33
|
-
name,
|
|
34
|
-
description: (_a = astNode.description) == null ? void 0 : _a.value
|
|
35
|
-
});
|
|
36
|
-
} else if (astNode.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
37
|
-
result[astNode.name.value] = makeInputObject(astNode, getTypeByName);
|
|
38
|
-
} else if (astNode.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION) {
|
|
39
|
-
result[astNode.name.value] = makeEnum(astNode);
|
|
40
|
-
} else if (astNode.kind === import_graphql.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
41
|
-
if (!implementedBy[astNode.name.value]) {
|
|
42
|
-
implementedBy[astNode.name.value] = [];
|
|
43
|
-
}
|
|
44
|
-
result[astNode.name.value] = {
|
|
45
|
-
__resolveType: void 0,
|
|
46
|
-
__implementedBy: implementedBy[astNode.name.value]
|
|
47
|
-
};
|
|
48
|
-
} else if (astNode.kind === import_graphql.Kind.UNION_TYPE_DEFINITION) {
|
|
49
|
-
const types = (_b = astNode.types) == null ? void 0 : _b.map((typeNode) => {
|
|
50
|
-
return typeNode.name.value;
|
|
51
|
-
});
|
|
52
|
-
result[astNode.name.value] = {
|
|
53
|
-
__resolveType: void 0,
|
|
54
|
-
__types: types || []
|
|
55
|
-
};
|
|
56
|
-
} else if (astNode.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION) {
|
|
57
|
-
(_c = astNode.interfaces) == null ? void 0 : _c.forEach((node) => {
|
|
58
|
-
if (!implementedBy[node.name.value]) {
|
|
59
|
-
implementedBy[node.name.value] = [];
|
|
60
|
-
}
|
|
61
|
-
implementedBy[node.name.value].push(
|
|
62
|
-
astNode.name.value
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
result[astNode.name.value] = {};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
function makeEnum(astNode) {
|
|
71
|
-
var _a, _b;
|
|
72
|
-
const enumValueMap = /* @__PURE__ */ Object.create(null);
|
|
73
|
-
for (const value of astNode.values || []) {
|
|
74
|
-
enumValueMap[value.name.value] = {
|
|
75
|
-
description: (_a = value.description) == null ? void 0 : _a.value,
|
|
76
|
-
deprecationReason: getDeprecationReason(value),
|
|
77
|
-
astNode: value
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return new import_graphql.GraphQLEnumType({
|
|
81
|
-
name: astNode.name.value,
|
|
82
|
-
description: (_b = astNode.description) == null ? void 0 : _b.value,
|
|
83
|
-
values: enumValueMap
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function makeInputObject(astNode, getTypeByName) {
|
|
87
|
-
var _a;
|
|
88
|
-
const name = astNode.name.value;
|
|
89
|
-
return new import_graphql.GraphQLInputObjectType({
|
|
90
|
-
name,
|
|
91
|
-
description: (_a = astNode.description) == null ? void 0 : _a.value,
|
|
92
|
-
fields: () => buildInputFieldMap(astNode.fields || [], getTypeByName),
|
|
93
|
-
astNode
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
function buildInputFieldMap(fieldNodes, getTypeByName) {
|
|
97
|
-
var _a;
|
|
98
|
-
const inputFieldMap = /* @__PURE__ */ Object.create(null);
|
|
99
|
-
for (const field of fieldNodes) {
|
|
100
|
-
const type = getWrappedType(field.type, getTypeByName);
|
|
101
|
-
inputFieldMap[field.name.value] = {
|
|
102
|
-
type,
|
|
103
|
-
description: (_a = field.description) == null ? void 0 : _a.value,
|
|
104
|
-
defaultValue: (0, import_graphql.valueFromAST)(field.defaultValue, type),
|
|
105
|
-
deprecationReason: getDeprecationReason(field),
|
|
106
|
-
astNode: field
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return inputFieldMap;
|
|
110
|
-
}
|
|
111
|
-
function getWrappedType(type, getTypeByName) {
|
|
112
|
-
if (type.kind === import_graphql.Kind.LIST_TYPE) {
|
|
113
|
-
return new import_graphql.GraphQLList(getWrappedType(type.type, getTypeByName));
|
|
114
|
-
} else if (type.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
115
|
-
return new import_graphql.GraphQLNonNull(getWrappedType(type.type, getTypeByName));
|
|
116
|
-
} else {
|
|
117
|
-
return getTypeByName(type.name.value);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function getDeprecationReason(node) {
|
|
121
|
-
const deprecated = (0, import_graphql.getDirectiveValues)(import_graphql.GraphQLDeprecatedDirective, node);
|
|
122
|
-
return deprecated == null ? void 0 : deprecated.reason;
|
|
123
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/extractImplicitTypesRuntime.ts"],
|
|
4
|
-
"sourcesContent": ["// Given a GraphQL document with type definitions, extract all types that can be defined implicitly.\nimport {\n DocumentNode,\n EnumValueDefinitionNode,\n FieldDefinitionNode,\n getDirectiveValues,\n ObjectTypeDefinitionNode,\n GraphQLDeprecatedDirective,\n NamedTypeNode,\n GraphQLEnumType,\n GraphQLEnumValueConfigMap,\n GraphQLScalarType,\n InputValueDefinitionNode,\n Kind,\n EnumTypeDefinitionNode,\n InputObjectTypeDefinitionNode,\n GraphQLInputObjectType,\n GraphQLInputFieldConfigMap,\n GraphQLInputType,\n valueFromAST,\n TypeNode,\n GraphQLNonNull,\n GraphQLList,\n} from \"graphql\";\nimport { Maybe } from \"./jsutils/Maybe\";\nimport { Resolvers, UnionTypeResolver, InterfaceTypeResolver } from \"./types\";\n\nexport function extractImplicitTypes<TSource = unknown, TContext = unknown>(\n document: DocumentNode,\n getTypeByName: (name: string) => GraphQLInputType,\n): Resolvers<TSource, TContext> {\n const result: Resolvers<TSource, TContext> = Object.create(null);\n const implementedBy: Record<string, Array<string>> = {};\n for (const astNode of document.definitions) {\n if (astNode.kind === Kind.SCALAR_TYPE_DEFINITION) {\n const name = astNode.name.value;\n result[name] = new GraphQLScalarType({\n name,\n description: astNode.description?.value,\n });\n } else if (astNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION) {\n result[astNode.name.value] = makeInputObject(astNode, getTypeByName);\n } else if (astNode.kind === Kind.ENUM_TYPE_DEFINITION) {\n result[astNode.name.value] = makeEnum(astNode);\n } else if (astNode.kind === Kind.INTERFACE_TYPE_DEFINITION) {\n if (!implementedBy[astNode.name.value]) {\n implementedBy[astNode.name.value] = [];\n }\n result[astNode.name.value] = {\n __resolveType: undefined,\n __implementedBy: implementedBy[astNode.name.value],\n } as InterfaceTypeResolver;\n } else if (astNode.kind === Kind.UNION_TYPE_DEFINITION) {\n const types = astNode.types?.map((typeNode) => {\n return typeNode.name.value;\n });\n\n result[astNode.name.value] = {\n __resolveType: undefined,\n __types: types || [],\n } as UnionTypeResolver;\n } else if (astNode.kind === Kind.OBJECT_TYPE_DEFINITION) {\n astNode.interfaces?.forEach((node: NamedTypeNode) => {\n if (!implementedBy[node.name.value]) {\n implementedBy[node.name.value] = [];\n }\n implementedBy[node.name.value].push(\n (astNode as ObjectTypeDefinitionNode).name.value,\n );\n });\n\n result[astNode.name.value] = {};\n }\n }\n return result;\n}\n\nfunction makeEnum(astNode: EnumTypeDefinitionNode) {\n const enumValueMap: GraphQLEnumValueConfigMap = Object.create(null);\n for (const value of astNode.values || []) {\n enumValueMap[value.name.value] = {\n description: value.description?.value,\n deprecationReason: getDeprecationReason(value),\n astNode: value,\n };\n }\n\n return new GraphQLEnumType({\n name: astNode.name.value,\n description: astNode.description?.value,\n values: enumValueMap,\n });\n}\n\nfunction makeInputObject(\n astNode: InputObjectTypeDefinitionNode,\n getTypeByName: (name: string) => GraphQLInputType,\n) {\n const name = astNode.name.value;\n\n return new GraphQLInputObjectType({\n name,\n description: astNode.description?.value,\n fields: () => buildInputFieldMap(astNode.fields || [], getTypeByName),\n astNode,\n });\n}\n\nfunction buildInputFieldMap(\n fieldNodes: ReadonlyArray<InputValueDefinitionNode>,\n getTypeByName: (name: string) => GraphQLInputType,\n): GraphQLInputFieldConfigMap {\n const inputFieldMap = Object.create(null);\n for (const field of fieldNodes) {\n // Note: While this could make assertions to get the correctly typed\n // value, that would throw immediately while type system validation\n // with validateSchema() will produce more actionable results.\n const type: GraphQLInputType = getWrappedType(field.type, getTypeByName);\n\n inputFieldMap[field.name.value] = {\n type,\n description: field.description?.value,\n defaultValue: valueFromAST(field.defaultValue, type),\n deprecationReason: getDeprecationReason(field),\n astNode: field,\n };\n }\n return inputFieldMap;\n}\n\nfunction getWrappedType(\n type: TypeNode,\n getTypeByName: (name: string) => GraphQLInputType,\n): GraphQLInputType {\n if (type.kind === Kind.LIST_TYPE) {\n return new GraphQLList(getWrappedType(type.type, getTypeByName));\n } else if (type.kind === Kind.NON_NULL_TYPE) {\n return new GraphQLNonNull(getWrappedType(type.type, getTypeByName));\n } else {\n return getTypeByName(type.name.value);\n }\n}\n\nfunction getDeprecationReason(\n node:\n | EnumValueDefinitionNode\n | FieldDefinitionNode\n | InputValueDefinitionNode,\n): Maybe<string> {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n return deprecated?.reason;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAsBO;AAIA,SAAS,qBACd,UACA,eAC8B;AA9BhC;AA+BE,QAAM,SAAuC,uBAAO,OAAO,IAA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