@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,148 @@
|
|
|
1
|
+
import ts, {factory} from "typescript";
|
|
2
|
+
import {
|
|
3
|
+
Kind
|
|
4
|
+
} from "graphql";
|
|
5
|
+
const SPECIFIED_SCALARS = {
|
|
6
|
+
ID: "GraphQLID",
|
|
7
|
+
String: "GraphQLString",
|
|
8
|
+
Int: "GraphQLInt",
|
|
9
|
+
Float: "GraphQLFloat",
|
|
10
|
+
Boolean: "GraphQLBoolean"
|
|
11
|
+
};
|
|
12
|
+
function extractImplicitTypesToTypescript(document) {
|
|
13
|
+
const definitions = [];
|
|
14
|
+
const imports = [
|
|
15
|
+
"GraphQLList",
|
|
16
|
+
"GraphQLNonNull",
|
|
17
|
+
"GraphQLID",
|
|
18
|
+
"GraphQLString",
|
|
19
|
+
"GraphQLInt",
|
|
20
|
+
"GraphQLFloat",
|
|
21
|
+
"GraphQLBoolean"
|
|
22
|
+
];
|
|
23
|
+
const identifiers = [];
|
|
24
|
+
for (let astNode of document.definitions) {
|
|
25
|
+
if (astNode.kind === Kind.SCALAR_TYPE_DEFINITION) {
|
|
26
|
+
definitions.push(createScalarType(astNode));
|
|
27
|
+
addToSetArray(imports, "GraphQLScalarType");
|
|
28
|
+
addToSetArray(identifiers, astNode.name.value);
|
|
29
|
+
} else if (astNode.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
30
|
+
definitions.push(createInputObjectType(astNode));
|
|
31
|
+
addToSetArray(imports, "GraphQLInputObjectType");
|
|
32
|
+
addToSetArray(identifiers, astNode.name.value);
|
|
33
|
+
} else if (astNode.kind === Kind.ENUM_TYPE_DEFINITION) {
|
|
34
|
+
definitions.push(createEnumType(astNode));
|
|
35
|
+
addToSetArray(imports, "GraphQLEnumType");
|
|
36
|
+
addToSetArray(identifiers, astNode.name.value);
|
|
37
|
+
} else if (astNode.kind === Kind.UNION_TYPE_DEFINITION || astNode.kind === Kind.INTERFACE_TYPE_DEFINITION) {
|
|
38
|
+
definitions.push(createAbstractType(astNode));
|
|
39
|
+
addToSetArray(identifiers, astNode.name.value);
|
|
40
|
+
} else if (astNode.kind === Kind.OBJECT_TYPE_DEFINITION) {
|
|
41
|
+
definitions.push(createObjectType(astNode));
|
|
42
|
+
addToSetArray(identifiers, astNode.name.value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const importDefinition = factory.createImportDeclaration(void 0, void 0, factory.createImportClause(false, void 0, factory.createNamedImports(imports.map((imp) => factory.createImportSpecifier(void 0, factory.createIdentifier(imp))))), factory.createStringLiteral("graphql"));
|
|
46
|
+
const exportDefinition = factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([
|
|
47
|
+
factory.createVariableDeclaration(factory.createIdentifier("resolvers"), void 0, void 0, factory.createObjectLiteralExpression(identifiers.map((def) => factory.createShorthandPropertyAssignment(factory.createIdentifier(def), void 0))))
|
|
48
|
+
], ts.NodeFlags.Const));
|
|
49
|
+
return factory.createSourceFile([importDefinition, ...definitions, exportDefinition], factory.createToken(ts.SyntaxKind.EndOfFileToken), 0);
|
|
50
|
+
}
|
|
51
|
+
function createDeclaration(name, decl) {
|
|
52
|
+
return factory.createVariableStatement(void 0, factory.createVariableDeclarationList([
|
|
53
|
+
factory.createVariableDeclaration(factory.createIdentifier(name), void 0, void 0, decl)
|
|
54
|
+
], ts.NodeFlags.Const));
|
|
55
|
+
}
|
|
56
|
+
function createScalarType(astNode) {
|
|
57
|
+
var _a;
|
|
58
|
+
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLScalarType"), void 0, [
|
|
59
|
+
factory.createObjectLiteralExpression([
|
|
60
|
+
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
61
|
+
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || ""))
|
|
62
|
+
], true)
|
|
63
|
+
]));
|
|
64
|
+
}
|
|
65
|
+
function createInputObjectType(astNode) {
|
|
66
|
+
var _a;
|
|
67
|
+
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLInputObjectType"), void 0, [
|
|
68
|
+
factory.createObjectLiteralExpression([
|
|
69
|
+
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
70
|
+
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || "")),
|
|
71
|
+
factory.createPropertyAssignment(factory.createIdentifier("fields"), factory.createArrowFunction(void 0, void 0, [], void 0, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), factory.createParenthesizedExpression(factory.createObjectLiteralExpression(createInputFields(astNode.fields || []), true))))
|
|
72
|
+
], true)
|
|
73
|
+
]));
|
|
74
|
+
}
|
|
75
|
+
function createInputFields(astNodes) {
|
|
76
|
+
return astNodes.map((astNode) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const fields = [
|
|
79
|
+
factory.createPropertyAssignment(factory.createIdentifier("type"), createType(astNode.type)),
|
|
80
|
+
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || ""))
|
|
81
|
+
];
|
|
82
|
+
if (astNode.defaultValue) {
|
|
83
|
+
fields.push(factory.createPropertyAssignment(factory.createIdentifier("defaultValue"), createValue(astNode.defaultValue)));
|
|
84
|
+
}
|
|
85
|
+
return factory.createPropertyAssignment(factory.createIdentifier(astNode.name.value), factory.createObjectLiteralExpression(fields, true));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function createEnumType(astNode) {
|
|
89
|
+
var _a;
|
|
90
|
+
return createDeclaration(astNode.name.value, factory.createNewExpression(factory.createIdentifier("GraphQLEnumType"), void 0, [
|
|
91
|
+
factory.createObjectLiteralExpression([
|
|
92
|
+
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(astNode.name.value)),
|
|
93
|
+
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a = astNode.description) == null ? void 0 : _a.value) || "")),
|
|
94
|
+
factory.createPropertyAssignment(factory.createIdentifier("values"), factory.createObjectLiteralExpression((astNode.values || []).map((valueNode) => {
|
|
95
|
+
var _a2;
|
|
96
|
+
return factory.createPropertyAssignment(factory.createIdentifier(valueNode.name.value), factory.createObjectLiteralExpression([
|
|
97
|
+
factory.createPropertyAssignment(factory.createIdentifier("description"), factory.createStringLiteral(((_a2 = valueNode.description) == null ? void 0 : _a2.value) || ""))
|
|
98
|
+
]));
|
|
99
|
+
})))
|
|
100
|
+
])
|
|
101
|
+
]));
|
|
102
|
+
}
|
|
103
|
+
function createAbstractType(astNode) {
|
|
104
|
+
return createDeclaration(astNode.name.value, factory.createObjectLiteralExpression([
|
|
105
|
+
factory.createPropertyAssignment(factory.createIdentifier("__resolveType"), factory.createIdentifier("undefined"))
|
|
106
|
+
]));
|
|
107
|
+
}
|
|
108
|
+
function createObjectType(astNode) {
|
|
109
|
+
return createDeclaration(astNode.name.value, factory.createObjectLiteralExpression());
|
|
110
|
+
}
|
|
111
|
+
function createType(astNode) {
|
|
112
|
+
if (astNode.kind === Kind.LIST_TYPE) {
|
|
113
|
+
return factory.createNewExpression(factory.createIdentifier("GraphQLList"), void 0, [createType(astNode.type)]);
|
|
114
|
+
} else if (astNode.kind === Kind.NON_NULL_TYPE) {
|
|
115
|
+
return factory.createNewExpression(factory.createIdentifier("GraphQLNonNull"), void 0, [createType(astNode.type)]);
|
|
116
|
+
} else {
|
|
117
|
+
if (SPECIFIED_SCALARS[astNode.name.value]) {
|
|
118
|
+
return factory.createIdentifier(SPECIFIED_SCALARS[astNode.name.value]);
|
|
119
|
+
} else {
|
|
120
|
+
return factory.createIdentifier(astNode.name.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function createValue(astNode) {
|
|
125
|
+
if (astNode.kind === Kind.INT || astNode.kind === Kind.FLOAT) {
|
|
126
|
+
return factory.createNumericLiteral(astNode.value);
|
|
127
|
+
} else if (astNode.kind === Kind.BOOLEAN) {
|
|
128
|
+
return astNode.value ? factory.createTrue() : factory.createFalse();
|
|
129
|
+
} else if (astNode.kind === Kind.STRING || astNode.kind === Kind.ENUM) {
|
|
130
|
+
return factory.createStringLiteral(astNode.value);
|
|
131
|
+
} else if (astNode.kind === Kind.NULL) {
|
|
132
|
+
return factory.createNull();
|
|
133
|
+
} else if (astNode.kind === Kind.LIST) {
|
|
134
|
+
return factory.createArrayLiteralExpression(astNode.values.map((valueNode) => createValue(valueNode)));
|
|
135
|
+
} else if (astNode.kind === Kind.OBJECT) {
|
|
136
|
+
return factory.createObjectLiteralExpression(astNode.fields.map((fieldNode) => factory.createPropertyAssignment(fieldNode.name.value, createValue(fieldNode.value))));
|
|
137
|
+
} else {
|
|
138
|
+
throw new Error("Invalid value");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function addToSetArray(array, item) {
|
|
142
|
+
if (array.indexOf(item) === -1) {
|
|
143
|
+
array.push(item);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
extractImplicitTypesToTypescript
|
|
148
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { executeWithoutSchema } from "./executeWithoutSchema";
|
|
2
|
+
export { executeWithSchema } from "./executeWithSchema";
|
|
3
|
+
export { Resolvers } from "./types";
|
|
4
|
+
export { addTypesToRequestDocument } from "./ast/addTypesToRequestDocument";
|
|
5
|
+
export { extractImplicitTypes } from "./extractImplicitTypesRuntime";
|
|
6
|
+
export { specifiedScalars } from "./values";
|
|
7
|
+
export { annotateDocumentGraphQLTransform } from "./transforms/annotateDocumentGraphQLTransform";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -20,35 +20,20 @@ var __reExport = (target, module2, desc) => {
|
|
|
20
20
|
var __toModule = (module2) => {
|
|
21
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
22
|
};
|
|
23
|
-
var __async = (__this, __arguments, generator) => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
var fulfilled = (value) => {
|
|
26
|
-
try {
|
|
27
|
-
step(generator.next(value));
|
|
28
|
-
} catch (e) {
|
|
29
|
-
reject(e);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var rejected = (value) => {
|
|
33
|
-
try {
|
|
34
|
-
step(generator.throw(value));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject(e);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
40
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
23
|
__markAsModule(exports);
|
|
44
24
|
__export(exports, {
|
|
45
|
-
|
|
25
|
+
Resolvers: () => import_types.Resolvers,
|
|
26
|
+
addTypesToRequestDocument: () => import_addTypesToRequestDocument.addTypesToRequestDocument,
|
|
27
|
+
annotateDocumentGraphQLTransform: () => import_annotateDocumentGraphQLTransform.annotateDocumentGraphQLTransform,
|
|
28
|
+
executeWithSchema: () => import_executeWithSchema.executeWithSchema,
|
|
29
|
+
executeWithoutSchema: () => import_executeWithoutSchema.executeWithoutSchema,
|
|
30
|
+
extractImplicitTypes: () => import_extractImplicitTypesRuntime.extractImplicitTypes,
|
|
31
|
+
specifiedScalars: () => import_values.specifiedScalars
|
|
46
32
|
});
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
33
|
+
var import_executeWithoutSchema = __toModule(require("./executeWithoutSchema"));
|
|
34
|
+
var import_executeWithSchema = __toModule(require("./executeWithSchema"));
|
|
35
|
+
var import_types = __toModule(require("./types"));
|
|
36
|
+
var import_addTypesToRequestDocument = __toModule(require("./ast/addTypesToRequestDocument"));
|
|
37
|
+
var import_extractImplicitTypesRuntime = __toModule(require("./extractImplicitTypesRuntime"));
|
|
38
|
+
var import_values = __toModule(require("./values"));
|
|
39
|
+
var import_annotateDocumentGraphQLTransform = __toModule(require("./transforms/annotateDocumentGraphQLTransform"));
|
package/lib/index.mjs
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import {GraphQLError} from "graphql";
|
|
22
|
-
function execute(args) {
|
|
23
|
-
return __async(this, null, function* () {
|
|
24
|
-
return {
|
|
25
|
-
errors: [new GraphQLError("Not implemented")]
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
}
|
|
1
|
+
import {executeWithoutSchema} from "./executeWithoutSchema";
|
|
2
|
+
import {executeWithSchema} from "./executeWithSchema";
|
|
3
|
+
import {Resolvers} from "./types";
|
|
4
|
+
import {addTypesToRequestDocument} from "./ast/addTypesToRequestDocument";
|
|
5
|
+
import {extractImplicitTypes} from "./extractImplicitTypesRuntime";
|
|
6
|
+
import {specifiedScalars} from "./values";
|
|
7
|
+
import {annotateDocumentGraphQLTransform} from "./transforms/annotateDocumentGraphQLTransform";
|
|
29
8
|
export {
|
|
30
|
-
|
|
9
|
+
Resolvers,
|
|
10
|
+
addTypesToRequestDocument,
|
|
11
|
+
annotateDocumentGraphQLTransform,
|
|
12
|
+
executeWithSchema,
|
|
13
|
+
executeWithoutSchema,
|
|
14
|
+
extractImplicitTypes,
|
|
15
|
+
specifiedScalars
|
|
31
16
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Maybe.d.ts","sourceRoot":"","sources":["../../src/jsutils/Maybe.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oBAAY,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,SAAS,GAAG,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ObjMap<T> {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
}
|
|
4
|
+
export declare type ObjMapLike<T> = ObjMap<T> | {
|
|
5
|
+
[key: string]: T;
|
|
6
|
+
};
|
|
7
|
+
export interface ReadOnlyObjMap<T> {
|
|
8
|
+
readonly [key: string]: T;
|
|
9
|
+
}
|
|
10
|
+
export declare type ReadOnlyObjMapLike<T> = ReadOnlyObjMap<T> | {
|
|
11
|
+
readonly [key: string]: T;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ObjMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjMap.d.ts","sourceRoot":"","sources":["../../src/jsutils/ObjMap.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClB;AAED,oBAAY,UAAU,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAC3B;AAED,oBAAY,kBAAkB,CAAC,CAAC,IAC5B,cAAc,CAAC,CAAC,CAAC,GACjB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Maybe } from './Maybe';
|
|
2
|
+
export interface Path {
|
|
3
|
+
readonly prev: Path | undefined;
|
|
4
|
+
readonly key: string | number;
|
|
5
|
+
readonly typename: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Given a Path and a key, return a new Path containing the new key.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addPath(prev: Readonly<Path> | undefined, key: string | number, typename: string | undefined): Path;
|
|
11
|
+
/**
|
|
12
|
+
* Given a Path, return an Array of the path keys.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pathToArray(path: Maybe<Readonly<Path>>): Array<string | number>;
|
|
15
|
+
//# sourceMappingURL=Path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../../src/jsutils/Path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAC1B,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAQxB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
__markAsModule(exports);
|
|
8
|
+
__export(exports, {
|
|
9
|
+
addPath: () => addPath,
|
|
10
|
+
pathToArray: () => pathToArray
|
|
11
|
+
});
|
|
12
|
+
function addPath(prev, key, typename) {
|
|
13
|
+
return {prev, key, typename};
|
|
14
|
+
}
|
|
15
|
+
function pathToArray(path) {
|
|
16
|
+
const flattened = [];
|
|
17
|
+
let curr = path;
|
|
18
|
+
while (curr) {
|
|
19
|
+
flattened.push(curr.key);
|
|
20
|
+
curr = curr.prev;
|
|
21
|
+
}
|
|
22
|
+
return flattened.reverse();
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function addPath(prev, key, typename) {
|
|
2
|
+
return {prev, key, typename};
|
|
3
|
+
}
|
|
4
|
+
function pathToArray(path) {
|
|
5
|
+
const flattened = [];
|
|
6
|
+
let curr = path;
|
|
7
|
+
while (curr) {
|
|
8
|
+
flattened.push(curr.key);
|
|
9
|
+
curr = curr.prev;
|
|
10
|
+
}
|
|
11
|
+
return flattened.reverse();
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
addPath,
|
|
15
|
+
pathToArray
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromiseOrValue.d.ts","sourceRoot":"","sources":["../../src/jsutils/PromiseOrValue.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devAssert.d.ts","sourceRoot":"","sources":["../../src/jsutils/devAssert.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMnE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
__markAsModule(exports);
|
|
8
|
+
__export(exports, {
|
|
9
|
+
devAssert: () => devAssert
|
|
10
|
+
});
|
|
11
|
+
function devAssert(condition, message) {
|
|
12
|
+
const booleanCondition = Boolean(condition);
|
|
13
|
+
if (!booleanCondition) {
|
|
14
|
+
throw new Error(message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
|
|
3
|
+
*/
|
|
4
|
+
export declare function didYouMean(suggestions: ReadonlyArray<string>): string;
|
|
5
|
+
export declare function didYouMean(subMessage: string, suggestions: ReadonlyArray<string>): string;
|
|
6
|
+
//# sourceMappingURL=didYouMean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"didYouMean.d.ts","sourceRoot":"","sources":["../../src/jsutils/didYouMean.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACvE,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,GACjC,MAAM,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
__markAsModule(exports);
|
|
8
|
+
__export(exports, {
|
|
9
|
+
didYouMean: () => didYouMean
|
|
10
|
+
});
|
|
11
|
+
const MAX_SUGGESTIONS = 5;
|
|
12
|
+
function didYouMean(firstArg, secondArg) {
|
|
13
|
+
const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
|
|
14
|
+
let message = " Did you mean ";
|
|
15
|
+
if (subMessage) {
|
|
16
|
+
message += subMessage + " ";
|
|
17
|
+
}
|
|
18
|
+
const suggestions = suggestionsArg.map((x) => `"${x}"`);
|
|
19
|
+
switch (suggestions.length) {
|
|
20
|
+
case 0:
|
|
21
|
+
return "";
|
|
22
|
+
case 1:
|
|
23
|
+
return message + suggestions[0] + "?";
|
|
24
|
+
case 2:
|
|
25
|
+
return message + suggestions[0] + " or " + suggestions[1] + "?";
|
|
26
|
+
}
|
|
27
|
+
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
|
|
28
|
+
const lastItem = selected.pop();
|
|
29
|
+
return message + selected.join(", ") + ", or " + lastItem + "?";
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const MAX_SUGGESTIONS = 5;
|
|
2
|
+
function didYouMean(firstArg, secondArg) {
|
|
3
|
+
const [subMessage, suggestionsArg] = secondArg ? [firstArg, secondArg] : [void 0, firstArg];
|
|
4
|
+
let message = " Did you mean ";
|
|
5
|
+
if (subMessage) {
|
|
6
|
+
message += subMessage + " ";
|
|
7
|
+
}
|
|
8
|
+
const suggestions = suggestionsArg.map((x) => `"${x}"`);
|
|
9
|
+
switch (suggestions.length) {
|
|
10
|
+
case 0:
|
|
11
|
+
return "";
|
|
12
|
+
case 1:
|
|
13
|
+
return message + suggestions[0] + "?";
|
|
14
|
+
case 2:
|
|
15
|
+
return message + suggestions[0] + " or " + suggestions[1] + "?";
|
|
16
|
+
}
|
|
17
|
+
const selected = suggestions.slice(0, MAX_SUGGESTIONS);
|
|
18
|
+
const lastItem = selected.pop();
|
|
19
|
+
return message + selected.join(", ") + ", or " + lastItem + "?";
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
didYouMean
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityFunc.d.ts","sourceRoot":"","sources":["../../src/jsutils/identityFunc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAEvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
__markAsModule(exports);
|
|
8
|
+
__export(exports, {
|
|
9
|
+
identityFunc: () => identityFunc
|
|
10
|
+
});
|
|
11
|
+
function identityFunc(x) {
|
|
12
|
+
return x;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/jsutils/inspect.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
__markAsModule(exports);
|
|
8
|
+
__export(exports, {
|
|
9
|
+
inspect: () => inspect
|
|
10
|
+
});
|
|
11
|
+
const MAX_ARRAY_LENGTH = 10;
|
|
12
|
+
const MAX_RECURSIVE_DEPTH = 2;
|
|
13
|
+
function inspect(value) {
|
|
14
|
+
return formatValue(value, []);
|
|
15
|
+
}
|
|
16
|
+
function formatValue(value, seenValues) {
|
|
17
|
+
switch (typeof value) {
|
|
18
|
+
case "string":
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
case "function":
|
|
21
|
+
return value.name ? `[function ${value.name}]` : "[function]";
|
|
22
|
+
case "object":
|
|
23
|
+
return formatObjectValue(value, seenValues);
|
|
24
|
+
default:
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
29
|
+
if (value === null) {
|
|
30
|
+
return "null";
|
|
31
|
+
}
|
|
32
|
+
if (previouslySeenValues.includes(value)) {
|
|
33
|
+
return "[Circular]";
|
|
34
|
+
}
|
|
35
|
+
const seenValues = [...previouslySeenValues, value];
|
|
36
|
+
if (isJSONable(value)) {
|
|
37
|
+
const jsonValue = value.toJSON();
|
|
38
|
+
if (jsonValue !== value) {
|
|
39
|
+
return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
|
|
40
|
+
}
|
|
41
|
+
} else if (Array.isArray(value)) {
|
|
42
|
+
return formatArray(value, seenValues);
|
|
43
|
+
}
|
|
44
|
+
return formatObject(value, seenValues);
|
|
45
|
+
}
|
|
46
|
+
function isJSONable(value) {
|
|
47
|
+
return typeof value.toJSON === "function";
|
|
48
|
+
}
|
|
49
|
+
function formatObject(object, seenValues) {
|
|
50
|
+
const entries = Object.entries(object);
|
|
51
|
+
if (entries.length === 0) {
|
|
52
|
+
return "{}";
|
|
53
|
+
}
|
|
54
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
55
|
+
return "[" + getObjectTag(object) + "]";
|
|
56
|
+
}
|
|
57
|
+
const properties = entries.map(([key, value]) => key + ": " + formatValue(value, seenValues));
|
|
58
|
+
return "{ " + properties.join(", ") + " }";
|
|
59
|
+
}
|
|
60
|
+
function formatArray(array, seenValues) {
|
|
61
|
+
if (array.length === 0) {
|
|
62
|
+
return "[]";
|
|
63
|
+
}
|
|
64
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
65
|
+
return "[Array]";
|
|
66
|
+
}
|
|
67
|
+
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
68
|
+
const remaining = array.length - len;
|
|
69
|
+
const items = [];
|
|
70
|
+
for (let i = 0; i < len; ++i) {
|
|
71
|
+
items.push(formatValue(array[i], seenValues));
|
|
72
|
+
}
|
|
73
|
+
if (remaining === 1) {
|
|
74
|
+
items.push("... 1 more item");
|
|
75
|
+
} else if (remaining > 1) {
|
|
76
|
+
items.push(`... ${remaining} more items`);
|
|
77
|
+
}
|
|
78
|
+
return "[" + items.join(", ") + "]";
|
|
79
|
+
}
|
|
80
|
+
function getObjectTag(object) {
|
|
81
|
+
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
82
|
+
if (tag === "Object" && typeof object.constructor === "function") {
|
|
83
|
+
const name = object.constructor.name;
|
|
84
|
+
if (typeof name === "string" && name !== "") {
|
|
85
|
+
return name;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return tag;
|
|
89
|
+
}
|