@graphitation/supermassive 0.1.3 → 0.2.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/.eslintcache +1 -1
- package/CHANGELOG.md +10 -2
- package/README.md +88 -0
- package/bin/supermassive.js +5 -0
- package/graphitation-supermassive-0.1.3-1.tgz +0 -0
- package/graphitation-supermassive-0.1.3-2.tgz +0 -0
- package/graphitation-supermassive-0.1.3.tgz +0 -0
- package/lib/{src/ast → ast}/TypedAST.d.ts +2 -0
- package/lib/ast/TypedAST.d.ts.map +1 -0
- package/lib/{src/ast → ast}/addTypesToRequestDocument.d.ts +0 -0
- package/lib/ast/addTypesToRequestDocument.d.ts.map +1 -0
- package/lib/ast/addTypesToRequestDocument.js +8 -5
- package/lib/ast/addTypesToRequestDocument.mjs +9 -5
- package/lib/benchmarks/index.d.ts.map +1 -1
- package/lib/benchmarks/index.js +127 -0
- package/lib/benchmarks/index.mjs +109 -0
- package/lib/benchmarks/nice-benchmark.d.ts +1 -1
- package/lib/benchmarks/nice-benchmark.d.ts.map +1 -1
- package/lib/benchmarks/nice-benchmark.js +72 -0
- package/lib/benchmarks/nice-benchmark.mjs +49 -0
- package/lib/benchmarks/swapi-schema/index.d.ts +1 -0
- package/lib/benchmarks/swapi-schema/index.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/index.js +39 -0
- package/lib/benchmarks/swapi-schema/index.mjs +16 -0
- package/lib/benchmarks/swapi-schema/models.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/models.js +29 -0
- package/lib/benchmarks/swapi-schema/models.mjs +6 -0
- package/lib/benchmarks/swapi-schema/resolvers.d.ts.map +1 -1
- package/lib/benchmarks/swapi-schema/resolvers.js +237 -0
- package/lib/benchmarks/swapi-schema/resolvers.mjs +231 -0
- package/lib/bin/supermassive.d.ts +3 -0
- package/lib/bin/supermassive.d.ts.map +1 -0
- package/lib/bin/supermassive.js +83 -0
- package/lib/bin/supermassive.mjs +60 -0
- package/lib/bin/typeDefsToImplicitResolvers.d.ts +3 -0
- package/lib/bin/typeDefsToImplicitResolvers.d.ts.map +1 -0
- package/lib/bin/typeDefsToImplicitResolvers.js +82 -0
- package/lib/bin/typeDefsToImplicitResolvers.mjs +59 -0
- package/lib/collectFields.d.ts +17 -0
- package/lib/collectFields.d.ts.map +1 -0
- package/lib/collectFields.js +83 -0
- package/lib/collectFields.mjs +60 -0
- package/lib/compiledQuery.d.ts +1 -0
- package/lib/compiledQuery.d.ts.map +1 -0
- package/lib/compiledQuery.js +0 -0
- package/lib/compiledQuery.mjs +0 -0
- package/lib/execute.d.ts +128 -0
- package/lib/execute.d.ts.map +1 -0
- package/lib/execute.js +376 -0
- package/lib/execute.mjs +365 -0
- package/lib/executeWithSchema.d.ts +4 -0
- package/lib/executeWithSchema.d.ts.map +1 -0
- package/lib/{index.test.js → executeWithSchema.js} +44 -45
- package/lib/executeWithSchema.mjs +62 -0
- package/lib/executeWithoutSchema.d.ts +99 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -0
- package/lib/executeWithoutSchema.js +376 -0
- package/lib/executeWithoutSchema.mjs +365 -0
- package/lib/extractImplicitTypes.d.ts +6 -0
- package/lib/extractImplicitTypes.d.ts.map +1 -0
- package/lib/extractImplicitTypes.js +246 -0
- package/lib/extractImplicitTypes.mjs +233 -0
- package/lib/extractImplicitTypesRuntime.d.ts +4 -0
- package/lib/extractImplicitTypesRuntime.d.ts.map +1 -0
- package/lib/extractImplicitTypesRuntime.js +103 -0
- package/lib/extractImplicitTypesRuntime.mjs +90 -0
- package/lib/extractImplicitTypesToTypescript.d.ts +4 -0
- package/lib/extractImplicitTypesToTypescript.d.ts.map +1 -0
- package/lib/extractImplicitTypesToTypescript.js +169 -0
- package/lib/extractImplicitTypesToTypescript.mjs +148 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -29
- package/lib/index.mjs +14 -29
- package/lib/jsutils/Maybe.d.ts +3 -0
- package/lib/jsutils/Maybe.d.ts.map +1 -0
- package/lib/jsutils/Maybe.js +3 -0
- package/lib/jsutils/Maybe.mjs +0 -0
- package/lib/jsutils/ObjMap.d.ts +13 -0
- package/lib/jsutils/ObjMap.d.ts.map +1 -0
- package/lib/jsutils/ObjMap.js +3 -0
- package/lib/jsutils/ObjMap.mjs +0 -0
- package/lib/jsutils/Path.d.ts +15 -0
- package/lib/jsutils/Path.d.ts.map +1 -0
- package/lib/jsutils/Path.js +23 -0
- package/lib/jsutils/Path.mjs +16 -0
- package/lib/jsutils/PromiseOrValue.d.ts +2 -0
- package/lib/jsutils/PromiseOrValue.d.ts.map +1 -0
- package/lib/jsutils/PromiseOrValue.js +3 -0
- package/lib/jsutils/PromiseOrValue.mjs +0 -0
- package/lib/jsutils/devAssert.d.ts +2 -0
- package/lib/jsutils/devAssert.d.ts.map +1 -0
- package/lib/jsutils/devAssert.js +16 -0
- package/lib/jsutils/devAssert.mjs +9 -0
- package/lib/jsutils/didYouMean.d.ts +6 -0
- package/lib/jsutils/didYouMean.d.ts.map +1 -0
- package/lib/jsutils/didYouMean.js +30 -0
- package/lib/jsutils/didYouMean.mjs +23 -0
- package/lib/jsutils/identityFunc.d.ts +5 -0
- package/lib/jsutils/identityFunc.d.ts.map +1 -0
- package/lib/jsutils/identityFunc.js +13 -0
- package/lib/jsutils/identityFunc.mjs +6 -0
- package/lib/jsutils/inspect.d.ts +5 -0
- package/lib/jsutils/inspect.d.ts.map +1 -0
- package/lib/jsutils/inspect.js +89 -0
- package/lib/jsutils/inspect.mjs +82 -0
- package/lib/jsutils/instanceOf.d.ts +14 -0
- package/lib/jsutils/instanceOf.d.ts.map +1 -0
- package/lib/jsutils/instanceOf.js +55 -0
- package/lib/jsutils/instanceOf.mjs +32 -0
- package/lib/jsutils/invariant.d.ts +2 -0
- package/lib/jsutils/invariant.d.ts.map +1 -0
- package/lib/jsutils/invariant.js +16 -0
- package/lib/jsutils/invariant.mjs +9 -0
- package/lib/jsutils/isAsyncIterable.d.ts +6 -0
- package/lib/jsutils/isAsyncIterable.d.ts.map +1 -0
- package/lib/jsutils/isAsyncIterable.js +13 -0
- package/lib/jsutils/isAsyncIterable.mjs +6 -0
- package/lib/jsutils/isIterableObject.d.ts +18 -0
- package/lib/jsutils/isIterableObject.d.ts.map +1 -0
- package/lib/jsutils/isIterableObject.js +13 -0
- package/lib/jsutils/isIterableObject.mjs +6 -0
- package/lib/jsutils/isObjectLike.d.ts +8 -0
- package/lib/jsutils/isObjectLike.d.ts.map +1 -0
- package/lib/jsutils/isObjectLike.js +13 -0
- package/lib/jsutils/isObjectLike.mjs +6 -0
- package/lib/jsutils/isPromise.d.ts +6 -0
- package/lib/jsutils/isPromise.d.ts.map +1 -0
- package/lib/jsutils/isPromise.js +13 -0
- package/lib/jsutils/isPromise.mjs +6 -0
- package/lib/jsutils/keyMap.d.ts +26 -0
- package/lib/jsutils/keyMap.d.ts.map +1 -0
- package/lib/jsutils/keyMap.js +17 -0
- package/lib/jsutils/keyMap.mjs +10 -0
- package/lib/jsutils/keyValMap.d.ts +20 -0
- package/lib/jsutils/keyValMap.d.ts.map +1 -0
- package/lib/jsutils/keyValMap.js +17 -0
- package/lib/jsutils/keyValMap.mjs +10 -0
- package/lib/jsutils/mapValue.d.ts +7 -0
- package/lib/jsutils/mapValue.d.ts.map +1 -0
- package/lib/jsutils/mapValue.js +17 -0
- package/lib/jsutils/mapValue.mjs +10 -0
- package/lib/jsutils/memoize3.d.ts +5 -0
- package/lib/jsutils/memoize3.d.ts.map +1 -0
- package/lib/jsutils/memoize3.js +34 -0
- package/lib/jsutils/memoize3.mjs +27 -0
- package/lib/jsutils/naturalCompare.d.ts +9 -0
- package/lib/jsutils/naturalCompare.d.ts.map +1 -0
- package/lib/jsutils/naturalCompare.js +53 -0
- package/lib/jsutils/naturalCompare.mjs +46 -0
- package/lib/jsutils/printPathArray.d.ts +5 -0
- package/lib/jsutils/printPathArray.d.ts.map +1 -0
- package/lib/jsutils/printPathArray.js +13 -0
- package/lib/jsutils/printPathArray.mjs +6 -0
- package/lib/jsutils/promiseForObject.d.ts +10 -0
- package/lib/jsutils/promiseForObject.d.ts.map +1 -0
- package/lib/jsutils/promiseForObject.js +19 -0
- package/lib/jsutils/promiseForObject.mjs +12 -0
- package/lib/jsutils/promiseReduce.d.ts +10 -0
- package/lib/jsutils/promiseReduce.d.ts.map +1 -0
- package/lib/jsutils/promiseReduce.js +34 -0
- package/lib/jsutils/promiseReduce.mjs +11 -0
- package/lib/jsutils/suggestionList.d.ts +6 -0
- package/lib/jsutils/suggestionList.d.ts.map +1 -0
- package/lib/jsutils/suggestionList.js +109 -0
- package/lib/jsutils/suggestionList.mjs +86 -0
- package/lib/jsutils/toObjMap.d.ts +4 -0
- package/lib/jsutils/toObjMap.d.ts.map +1 -0
- package/lib/jsutils/toObjMap.js +20 -0
- package/lib/jsutils/toObjMap.mjs +13 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts +3 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.d.ts.map +1 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.js +37 -0
- package/lib/transforms/annotateDocumentGraphQLTransform.mjs +16 -0
- package/lib/transforms/transformerTestUtils.d.ts +79 -0
- package/lib/transforms/transformerTestUtils.d.ts.map +1 -0
- package/lib/transforms/transformerTestUtils.js +175 -0
- package/lib/transforms/transformerTestUtils.mjs +154 -0
- package/lib/types.d.ts +74 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.mjs +0 -0
- package/lib/utilities/typeNameFromAST.d.ts +3 -0
- package/lib/utilities/typeNameFromAST.d.ts.map +1 -0
- package/lib/utilities/typeNameFromAST.js +34 -0
- package/lib/utilities/typeNameFromAST.mjs +11 -0
- package/lib/values.d.ts +64 -0
- package/lib/values.d.ts.map +1 -0
- package/lib/values.js +145 -0
- package/lib/values.mjs +137 -0
- package/package.json +9 -4
- package/CHANGELOG.json +0 -65
- package/benchmarks/fixtures/query1.graphql +0 -20
- package/benchmarks/index.ts +0 -68
- package/benchmarks/nice-benchmark.ts +0 -32
- package/benchmarks/swapi-schema/index.ts +0 -13
- package/benchmarks/swapi-schema/models.ts +0 -4
- package/benchmarks/swapi-schema/resolvers.ts +0 -331
- package/benchmarks/swapi-schema/schema.graphql +0 -164
- package/benchmarks/swapi-schema/starwars.json +0 -5991
- package/lib/index.test.mjs +0 -63
- package/lib/src/ast/TypedAST.d.ts.map +0 -1
- package/lib/src/ast/addTypesToRequestDocument.d.ts.map +0 -1
- package/lib/src/index.d.ts +0 -16
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/index.test.d.ts +0 -2
- package/lib/src/index.test.d.ts.map +0 -1
- package/starwars.json +0 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
10
|
+
var __objSpread = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
25
|
+
};
|
|
26
|
+
var __reExport = (target, module2, desc) => {
|
|
27
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(module2))
|
|
29
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
30
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __toModule = (module2) => {
|
|
35
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
36
|
+
};
|
|
37
|
+
__markAsModule(exports);
|
|
38
|
+
__export(exports, {
|
|
39
|
+
Transformer: () => Transformer,
|
|
40
|
+
getCompilerOptions: () => getCompilerOptions,
|
|
41
|
+
transformFile: () => transformFile
|
|
42
|
+
});
|
|
43
|
+
var import_typescript = __toModule(require("typescript"));
|
|
44
|
+
var Path = __toModule(require("path"));
|
|
45
|
+
var import_bootstrap = __toModule(require("@ts-morph/bootstrap"));
|
|
46
|
+
class Transformer {
|
|
47
|
+
constructor() {
|
|
48
|
+
this.compilerOptions = {};
|
|
49
|
+
this.mocks = [];
|
|
50
|
+
this.sources = [];
|
|
51
|
+
this.transformers = [];
|
|
52
|
+
}
|
|
53
|
+
clone() {
|
|
54
|
+
const target = new Transformer();
|
|
55
|
+
for (const prop in this) {
|
|
56
|
+
if (this.hasOwnProperty(prop)) {
|
|
57
|
+
target[prop] = this[prop];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
addMock(moduleDescriptor) {
|
|
63
|
+
const clone = this.clone();
|
|
64
|
+
clone.mocks.push(moduleDescriptor);
|
|
65
|
+
return clone;
|
|
66
|
+
}
|
|
67
|
+
addSource(source) {
|
|
68
|
+
const clone = this.clone();
|
|
69
|
+
clone.sources.push(source);
|
|
70
|
+
return clone;
|
|
71
|
+
}
|
|
72
|
+
addTransformer(transformer) {
|
|
73
|
+
const clone = this.clone();
|
|
74
|
+
clone.transformers.push(transformer);
|
|
75
|
+
return clone;
|
|
76
|
+
}
|
|
77
|
+
addTransformers(transformers) {
|
|
78
|
+
const clone = this.clone();
|
|
79
|
+
clone.transformers.push(...transformers);
|
|
80
|
+
return clone;
|
|
81
|
+
}
|
|
82
|
+
setCompilerOptions(options) {
|
|
83
|
+
const clone = this.clone();
|
|
84
|
+
clone.compilerOptions = options;
|
|
85
|
+
if (clone.project) {
|
|
86
|
+
clone.project = (0, import_bootstrap.createProjectSync)({
|
|
87
|
+
useInMemoryFileSystem: true,
|
|
88
|
+
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return clone;
|
|
92
|
+
}
|
|
93
|
+
setFile(file) {
|
|
94
|
+
const clone = this.clone();
|
|
95
|
+
clone.file = file;
|
|
96
|
+
return clone;
|
|
97
|
+
}
|
|
98
|
+
setFilePath(filePath) {
|
|
99
|
+
const clone = this.clone();
|
|
100
|
+
clone.filePath = filePath;
|
|
101
|
+
return clone;
|
|
102
|
+
}
|
|
103
|
+
transform(input) {
|
|
104
|
+
this.project = this.project || (0, import_bootstrap.createProjectSync)({
|
|
105
|
+
useInMemoryFileSystem: true,
|
|
106
|
+
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
107
|
+
});
|
|
108
|
+
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
109
|
+
const file = typeof input === "string" ? {path: filePath, contents: input} : this.file;
|
|
110
|
+
if (!file) {
|
|
111
|
+
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
112
|
+
}
|
|
113
|
+
return transformFile(file, {
|
|
114
|
+
project: this.project,
|
|
115
|
+
compilerOptions: this.compilerOptions,
|
|
116
|
+
mocks: this.mocks,
|
|
117
|
+
sources: this.sources,
|
|
118
|
+
transforms: this.transformers
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const transformFile = (file, options) => {
|
|
123
|
+
const project = options.project || (0, import_bootstrap.createProjectSync)({
|
|
124
|
+
useInMemoryFileSystem: true,
|
|
125
|
+
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
126
|
+
});
|
|
127
|
+
project.createSourceFile(file.path, file.contents);
|
|
128
|
+
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
129
|
+
(options.mocks || []).forEach((mock) => {
|
|
130
|
+
const base = `/node_modules/${mock.name}`;
|
|
131
|
+
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
132
|
+
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({name: mock.name, main: "./src/index.ts"}));
|
|
133
|
+
});
|
|
134
|
+
const program = project.createProgram();
|
|
135
|
+
const {emitSkipped, diagnostics} = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
136
|
+
before: options.transforms.map((t) => t(program))
|
|
137
|
+
});
|
|
138
|
+
if (emitSkipped) {
|
|
139
|
+
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
140
|
+
}
|
|
141
|
+
const inFile = program.getSourceFile(file.path);
|
|
142
|
+
if (!inFile) {
|
|
143
|
+
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
144
|
+
}
|
|
145
|
+
if (!inFile) {
|
|
146
|
+
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
147
|
+
}
|
|
148
|
+
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
149
|
+
if (!fileArtifactPath) {
|
|
150
|
+
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
151
|
+
}
|
|
152
|
+
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
153
|
+
};
|
|
154
|
+
function getCompilerOptions(options) {
|
|
155
|
+
return __objSpread({
|
|
156
|
+
outDir: "/dist",
|
|
157
|
+
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
158
|
+
module: import_typescript.default.ModuleKind.ESNext,
|
|
159
|
+
moduleResolution: import_typescript.default.ModuleResolutionKind.NodeJs,
|
|
160
|
+
suppressImplicitAnyIndexErrors: true,
|
|
161
|
+
resolveJsonModule: true,
|
|
162
|
+
skipLibCheck: true,
|
|
163
|
+
target: import_typescript.default.ScriptTarget.ESNext,
|
|
164
|
+
types: [],
|
|
165
|
+
noEmitOnError: true,
|
|
166
|
+
jsx: import_typescript.default.JsxEmit.Preserve
|
|
167
|
+
}, options || {});
|
|
168
|
+
}
|
|
169
|
+
function getFileArtifactPath(file, program) {
|
|
170
|
+
const options = program.getCompilerOptions();
|
|
171
|
+
const extname = Path.extname(file.fileName);
|
|
172
|
+
const basename = Path.basename(file.fileName, extname);
|
|
173
|
+
const artifactExtname = extname === ".tsx" && options.jsx === import_typescript.default.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
174
|
+
return Path.join(options.outDir || ".", `${basename}${artifactExtname}`);
|
|
175
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
6
|
+
var __objSpread = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import Ts from "typescript";
|
|
18
|
+
import * as Path from "path";
|
|
19
|
+
import {createProjectSync} from "@ts-morph/bootstrap";
|
|
20
|
+
class Transformer {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.compilerOptions = {};
|
|
23
|
+
this.mocks = [];
|
|
24
|
+
this.sources = [];
|
|
25
|
+
this.transformers = [];
|
|
26
|
+
}
|
|
27
|
+
clone() {
|
|
28
|
+
const target = new Transformer();
|
|
29
|
+
for (const prop in this) {
|
|
30
|
+
if (this.hasOwnProperty(prop)) {
|
|
31
|
+
target[prop] = this[prop];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
addMock(moduleDescriptor) {
|
|
37
|
+
const clone = this.clone();
|
|
38
|
+
clone.mocks.push(moduleDescriptor);
|
|
39
|
+
return clone;
|
|
40
|
+
}
|
|
41
|
+
addSource(source) {
|
|
42
|
+
const clone = this.clone();
|
|
43
|
+
clone.sources.push(source);
|
|
44
|
+
return clone;
|
|
45
|
+
}
|
|
46
|
+
addTransformer(transformer) {
|
|
47
|
+
const clone = this.clone();
|
|
48
|
+
clone.transformers.push(transformer);
|
|
49
|
+
return clone;
|
|
50
|
+
}
|
|
51
|
+
addTransformers(transformers) {
|
|
52
|
+
const clone = this.clone();
|
|
53
|
+
clone.transformers.push(...transformers);
|
|
54
|
+
return clone;
|
|
55
|
+
}
|
|
56
|
+
setCompilerOptions(options) {
|
|
57
|
+
const clone = this.clone();
|
|
58
|
+
clone.compilerOptions = options;
|
|
59
|
+
if (clone.project) {
|
|
60
|
+
clone.project = createProjectSync({
|
|
61
|
+
useInMemoryFileSystem: true,
|
|
62
|
+
compilerOptions: getCompilerOptions(clone.compilerOptions)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return clone;
|
|
66
|
+
}
|
|
67
|
+
setFile(file) {
|
|
68
|
+
const clone = this.clone();
|
|
69
|
+
clone.file = file;
|
|
70
|
+
return clone;
|
|
71
|
+
}
|
|
72
|
+
setFilePath(filePath) {
|
|
73
|
+
const clone = this.clone();
|
|
74
|
+
clone.filePath = filePath;
|
|
75
|
+
return clone;
|
|
76
|
+
}
|
|
77
|
+
transform(input) {
|
|
78
|
+
this.project = this.project || createProjectSync({
|
|
79
|
+
useInMemoryFileSystem: true,
|
|
80
|
+
compilerOptions: getCompilerOptions(this.compilerOptions)
|
|
81
|
+
});
|
|
82
|
+
const filePath = typeof this.filePath === "string" ? this.filePath : "/index.ts";
|
|
83
|
+
const file = typeof input === "string" ? {path: filePath, contents: input} : this.file;
|
|
84
|
+
if (!file) {
|
|
85
|
+
throw new Error(`transform must be called on Transformer with file or with string input`);
|
|
86
|
+
}
|
|
87
|
+
return transformFile(file, {
|
|
88
|
+
project: this.project,
|
|
89
|
+
compilerOptions: this.compilerOptions,
|
|
90
|
+
mocks: this.mocks,
|
|
91
|
+
sources: this.sources,
|
|
92
|
+
transforms: this.transformers
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const transformFile = (file, options) => {
|
|
97
|
+
const project = options.project || createProjectSync({
|
|
98
|
+
useInMemoryFileSystem: true,
|
|
99
|
+
compilerOptions: getCompilerOptions(options.compilerOptions)
|
|
100
|
+
});
|
|
101
|
+
project.createSourceFile(file.path, file.contents);
|
|
102
|
+
(options.sources || []).forEach((source) => project.createSourceFile(source.path, source.contents));
|
|
103
|
+
(options.mocks || []).forEach((mock) => {
|
|
104
|
+
const base = `/node_modules/${mock.name}`;
|
|
105
|
+
project.createSourceFile(`${base}/index.ts`, mock.content);
|
|
106
|
+
project.fileSystem.writeFileSync(`${base}/package.json`, JSON.stringify({name: mock.name, main: "./src/index.ts"}));
|
|
107
|
+
});
|
|
108
|
+
const program = project.createProgram();
|
|
109
|
+
const {emitSkipped, diagnostics} = program.emit(program.getSourceFile(file.path), void 0, void 0, false, {
|
|
110
|
+
before: options.transforms.map((t) => t(program))
|
|
111
|
+
});
|
|
112
|
+
if (emitSkipped) {
|
|
113
|
+
throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics));
|
|
114
|
+
}
|
|
115
|
+
const inFile = program.getSourceFile(file.path);
|
|
116
|
+
if (!inFile) {
|
|
117
|
+
throw new Error(`Could not get SourceFile for ${file.path}`);
|
|
118
|
+
}
|
|
119
|
+
if (!inFile) {
|
|
120
|
+
throw new Error(`Could not determine ArtifactFile for ${file.path}`);
|
|
121
|
+
}
|
|
122
|
+
const fileArtifactPath = getFileArtifactPath(inFile, program);
|
|
123
|
+
if (!fileArtifactPath) {
|
|
124
|
+
throw new Error(`Could not determine fileArtifactPath for ${file.path}`);
|
|
125
|
+
}
|
|
126
|
+
return String(project.fileSystem.readFileSync(fileArtifactPath));
|
|
127
|
+
};
|
|
128
|
+
function getCompilerOptions(options) {
|
|
129
|
+
return __objSpread({
|
|
130
|
+
outDir: "/dist",
|
|
131
|
+
lib: ["/node_modules/typescript/lib/lib.esnext.full.d.ts"],
|
|
132
|
+
module: Ts.ModuleKind.ESNext,
|
|
133
|
+
moduleResolution: Ts.ModuleResolutionKind.NodeJs,
|
|
134
|
+
suppressImplicitAnyIndexErrors: true,
|
|
135
|
+
resolveJsonModule: true,
|
|
136
|
+
skipLibCheck: true,
|
|
137
|
+
target: Ts.ScriptTarget.ESNext,
|
|
138
|
+
types: [],
|
|
139
|
+
noEmitOnError: true,
|
|
140
|
+
jsx: Ts.JsxEmit.Preserve
|
|
141
|
+
}, options || {});
|
|
142
|
+
}
|
|
143
|
+
function getFileArtifactPath(file, program) {
|
|
144
|
+
const options = program.getCompilerOptions();
|
|
145
|
+
const extname = Path.extname(file.fileName);
|
|
146
|
+
const basename = Path.basename(file.fileName, extname);
|
|
147
|
+
const artifactExtname = extname === ".tsx" && options.jsx === Ts.JsxEmit.Preserve ? ".jsx" : ".js";
|
|
148
|
+
return Path.join(options.outDir || ".", `${basename}${artifactExtname}`);
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
Transformer,
|
|
152
|
+
getCompilerOptions,
|
|
153
|
+
transformFile
|
|
154
|
+
};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GraphQLEnumType, GraphQLError, GraphQLFormattedError, GraphQLInputObjectType, GraphQLScalarType, DocumentNode as UntypedDocumentNode } from "graphql";
|
|
2
|
+
import { Maybe } from "./jsutils/Maybe";
|
|
3
|
+
import { PromiseOrValue } from "./jsutils/PromiseOrValue";
|
|
4
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, TypeNode } from "./ast/TypedAST";
|
|
5
|
+
import { ObjMap } from "./jsutils/ObjMap";
|
|
6
|
+
import { Path } from "./jsutils/Path";
|
|
7
|
+
export declare type ScalarTypeResolver = GraphQLScalarType;
|
|
8
|
+
export declare type EnumTypeResolver = GraphQLEnumType;
|
|
9
|
+
export declare type FieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: ResolveInfo) => TReturn;
|
|
10
|
+
export declare type TypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: ResolveInfo) => PromiseOrValue<Maybe<string>>;
|
|
11
|
+
export declare type ObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
|
12
|
+
[key: string]: FieldResolver<TSource, TContext, TArgs>;
|
|
13
|
+
};
|
|
14
|
+
export declare type InterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
|
15
|
+
[key: string]: FieldResolver<TSource, TContext, TArgs>;
|
|
16
|
+
} & {
|
|
17
|
+
__resolveType?: TypeResolver<any, any>;
|
|
18
|
+
};
|
|
19
|
+
export declare type UnionTypeResolver = {
|
|
20
|
+
__resolveType?: TypeResolver<any, any>;
|
|
21
|
+
};
|
|
22
|
+
export declare type InputObjectTypeResolver = GraphQLInputObjectType;
|
|
23
|
+
export declare type Resolver<TSource, TContext> = ObjectTypeResolver<TSource, TContext> | InterfaceTypeResolver<TSource, TContext> | UnionTypeResolver | ScalarTypeResolver | EnumTypeResolver | InputObjectTypeResolver;
|
|
24
|
+
export declare type Resolvers<TSource = any, TContext = any> = Record<string, Resolver<TSource, TContext>>;
|
|
25
|
+
export interface ResolveInfo {
|
|
26
|
+
fieldName: string;
|
|
27
|
+
fieldNodes: Array<FieldNode>;
|
|
28
|
+
returnTypeName: string;
|
|
29
|
+
parentTypeName: string;
|
|
30
|
+
returnTypeNode: TypeNode;
|
|
31
|
+
path: Path;
|
|
32
|
+
fragments: ObjMap<FragmentDefinitionNode>;
|
|
33
|
+
rootValue: unknown;
|
|
34
|
+
operation: OperationDefinitionNode;
|
|
35
|
+
variableValues: {
|
|
36
|
+
[variable: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The result of GraphQL execution.
|
|
41
|
+
*
|
|
42
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
43
|
+
* - `data` is the result of a successful execution of the query.
|
|
44
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
45
|
+
*/
|
|
46
|
+
export interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
47
|
+
errors?: Array<GraphQLError>;
|
|
48
|
+
data?: TData | null;
|
|
49
|
+
extensions?: TExtensions;
|
|
50
|
+
}
|
|
51
|
+
export interface FormattedExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
|
|
52
|
+
errors?: Array<GraphQLFormattedError>;
|
|
53
|
+
data?: TData | null;
|
|
54
|
+
extensions?: TExtensions;
|
|
55
|
+
}
|
|
56
|
+
export interface CommonExecutionArgs {
|
|
57
|
+
resolvers: Resolvers;
|
|
58
|
+
rootValue?: unknown;
|
|
59
|
+
contextValue?: unknown;
|
|
60
|
+
variableValues?: Maybe<{
|
|
61
|
+
[variable: string]: unknown;
|
|
62
|
+
}>;
|
|
63
|
+
operationName?: Maybe<string>;
|
|
64
|
+
fieldResolver?: Maybe<FieldResolver<any, any>>;
|
|
65
|
+
typeResolver?: Maybe<TypeResolver<any, any>>;
|
|
66
|
+
}
|
|
67
|
+
export declare type ExecutionWithoutSchemaArgs = CommonExecutionArgs & {
|
|
68
|
+
document: DocumentNode;
|
|
69
|
+
};
|
|
70
|
+
export declare type ExecutionWithSchemaArgs = CommonExecutionArgs & {
|
|
71
|
+
document: UntypedDocumentNode;
|
|
72
|
+
typeDefs: UntypedDocumentNode;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAEjB,YAAY,IAAI,mBAAmB,EACpC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,oBAAY,kBAAkB,GAAG,iBAAiB,CAAC;AACnD,oBAAY,gBAAgB,GAAG,eAAe,CAAC;AAC/C,oBAAY,aAAa,CACvB,OAAO,EACP,QAAQ,EACR,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,GAAG,GAAG,IACX,CACF,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,KAAK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AAC;IAC9B,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/C,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CAC9C;AACD,oBAAY,0BAA0B,GAAG,mBAAmB,GAAG;IAC7D,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,oBAAY,uBAAuB,GAAG,mBAAmB,GAAG;IAC1D,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAAC"}
|
package/lib/types.js
ADDED
package/lib/types.mjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeNameFromAST.d.ts","sourceRoot":"","sources":["../../src/utilities/typeNameFromAST.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAMzD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
__markAsModule(exports);
|
|
24
|
+
__export(exports, {
|
|
25
|
+
typeNameFromAST: () => typeNameFromAST
|
|
26
|
+
});
|
|
27
|
+
var import_graphql = __toModule(require("graphql"));
|
|
28
|
+
function typeNameFromAST(typeAst) {
|
|
29
|
+
if (typeAst.kind === import_graphql.Kind.LIST_TYPE || typeAst.kind === import_graphql.Kind.NON_NULL_TYPE) {
|
|
30
|
+
return typeNameFromAST(typeAst.type);
|
|
31
|
+
} else {
|
|
32
|
+
return typeAst.name.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {Kind} from "graphql";
|
|
2
|
+
function typeNameFromAST(typeAst) {
|
|
3
|
+
if (typeAst.kind === Kind.LIST_TYPE || typeAst.kind === Kind.NON_NULL_TYPE) {
|
|
4
|
+
return typeNameFromAST(typeAst.type);
|
|
5
|
+
} else {
|
|
6
|
+
return typeAst.name.value;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
typeNameFromAST
|
|
11
|
+
};
|
package/lib/values.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { GraphQLError, GraphQLScalarType } from "graphql";
|
|
2
|
+
import { DirectiveNode, FieldNode, VariableDefinitionNode } from "./ast/TypedAST";
|
|
3
|
+
import type { Maybe } from "./jsutils/Maybe";
|
|
4
|
+
import type { ObjMap } from "./jsutils/ObjMap";
|
|
5
|
+
import { Resolvers } from "./types";
|
|
6
|
+
declare type CoercedVariableValues = {
|
|
7
|
+
errors: Array<GraphQLError>;
|
|
8
|
+
coerced?: never;
|
|
9
|
+
} | {
|
|
10
|
+
coerced: {
|
|
11
|
+
[variable: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
errors?: never;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Prepares an object map of variableValues of the correct type based on the
|
|
17
|
+
* provided variable definitions and arbitrary input. If the input cannot be
|
|
18
|
+
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
|
19
|
+
*
|
|
20
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
21
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
22
|
+
* Object prototype.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function getVariableValues(resolvers: Resolvers, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: {
|
|
27
|
+
[variable: string]: unknown;
|
|
28
|
+
}, options?: {
|
|
29
|
+
maxErrors?: number;
|
|
30
|
+
}): CoercedVariableValues;
|
|
31
|
+
/**
|
|
32
|
+
* Prepares an object map of argument values given a list of argument
|
|
33
|
+
* definitions and list of argument AST nodes.
|
|
34
|
+
*
|
|
35
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
36
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
37
|
+
* Object prototype.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function getArgumentValues(resolvers: Resolvers, node: FieldNode | DirectiveNode, variableValues?: Maybe<ObjMap<unknown>>): {
|
|
42
|
+
[argument: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Prepares an object map of argument values given a directive definition
|
|
46
|
+
* and a AST node which may contain directives. Optionally also accepts a map
|
|
47
|
+
* of variable values.
|
|
48
|
+
*
|
|
49
|
+
* If the directive does not exist on the node, returns undefined.
|
|
50
|
+
*
|
|
51
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
52
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
53
|
+
* Object prototype.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getDirectiveValues(resolvers: Resolvers, node: {
|
|
56
|
+
directives?: Array<DirectiveNode>;
|
|
57
|
+
}, variableValues?: Maybe<ObjMap<unknown>>): undefined | {
|
|
58
|
+
[argument: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
export declare const specifiedScalars: {
|
|
61
|
+
[key: string]: GraphQLScalarType;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAMZ,iBAAiB,EAYlB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,aAAa,EACb,SAAS,EAET,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,aAAK,qBAAqB,GACtB;IAAE,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,GAChD;IAAE,OAAO,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,aAAa,CAAC,sBAAsB,CAAC,EAClD,MAAM,EAAE;IAAE,CAAC,QAAQ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