@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.9 → 6.2.3-dev.91
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/dist/browser/document-models/index.js +2 -1
- package/dist/browser/documents-cxt8RRxe.js +18 -0
- package/dist/browser/documents-cxt8RRxe.js.map +1 -0
- package/dist/browser/{editor-DWqW8FJ2.js → editor-DXAJ8Mqb.js} +761 -277
- package/dist/browser/editor-DXAJ8Mqb.js.map +1 -0
- package/dist/browser/{editor-CbGnfPVs.js → editor-Dmpkd8pQ.js} +4 -5
- package/dist/browser/{editor-CbGnfPVs.js.map → editor-Dmpkd8pQ.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/document-model-editor/module.js.map +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -324
- package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/module.js.map +1 -1
- package/dist/{node/folder-view-DrRUOAcf.mjs → browser/folder-view-CwIU4XEe.js} +17 -12
- package/dist/browser/folder-view-CwIU4XEe.js.map +1 -0
- package/dist/browser/graphql-editor-CGxwONKl.js +103 -0
- package/dist/browser/graphql-editor-CGxwONKl.js.map +1 -0
- package/dist/browser/hooks-D15NCia0.js +126 -0
- package/dist/browser/hooks-D15NCia0.js.map +1 -0
- package/dist/browser/index.js +6 -703
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/json-editor--jgLEwP2.js +55 -0
- package/dist/browser/json-editor--jgLEwP2.js.map +1 -0
- package/dist/browser/{schema-context-ZyeclQwy.js → schema-context-CC_WFs1x.js} +10 -6
- package/dist/browser/schema-context-CC_WFs1x.js.map +1 -0
- package/dist/browser/{state-schemas-DZB9PFEk.js → state-schemas-DSY44MOd.js} +28 -19
- package/dist/browser/state-schemas-DSY44MOd.js.map +1 -0
- package/dist/{browser/dist-BAJ5nRDl.js → node/bundle-mjs-Cuu3DEfT.mjs} +1251 -822
- package/dist/node/bundle-mjs-Cuu3DEfT.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +2 -1
- package/dist/node/{graphql-BfAoPeWM.mjs → documents-DH2fyf7U.mjs} +80 -50
- package/dist/node/documents-DH2fyf7U.mjs.map +1 -0
- package/dist/node/editor-BcvUeBW7.mjs +4761 -0
- package/dist/node/editor-BcvUeBW7.mjs.map +1 -0
- package/dist/node/editor-DJCghViS.mjs +983 -0
- package/dist/node/editor-DJCghViS.mjs.map +1 -0
- package/dist/node/editors/index.mjs +23 -2
- package/dist/node/editors/index.mjs.map +1 -0
- package/dist/node/{graphql-editor-C38uott6.mjs → graphql-editor-u9NStKLL.mjs} +5129 -63
- package/dist/node/graphql-editor-u9NStKLL.mjs.map +1 -0
- package/dist/node/{hooks-D0DcS3MV.mjs → hooks-BiLz75cj.mjs} +824 -444
- package/dist/node/{hooks-D0DcS3MV.mjs.map → hooks-BiLz75cj.mjs.map} +1 -1
- package/dist/node/index.mjs +46 -100
- package/dist/node/index.mjs.map +1 -1
- package/dist/{browser/json-editor-DqRiIY49.js → node/json-editor-BfcrckeT.mjs} +8 -9
- package/dist/node/{json-editor-BM2wc5Zz.mjs.map → json-editor-BfcrckeT.mjs.map} +1 -1
- package/dist/node/{schema-context-DL8jhi_d.mjs → schema-context-r0MTQnRC.mjs} +9 -6
- package/dist/node/schema-context-r0MTQnRC.mjs.map +1 -0
- package/dist/node/state-schemas-o3PZdBW2.mjs +1071 -0
- package/dist/node/state-schemas-o3PZdBW2.mjs.map +1 -0
- package/package.json +26 -23
- package/style.css +2 -0
- package/dist/browser/assets/entry-DSBtQnit.js +0 -314
- package/dist/browser/assets/projection-entry-Bem3exmO.js +0 -404
- package/dist/browser/button-CuO8Gh3v.js +0 -696
- package/dist/browser/button-CuO8Gh3v.js.map +0 -1
- package/dist/browser/connect-CDHt0LA4.js +0 -14328
- package/dist/browser/connect-CDHt0LA4.js.map +0 -1
- package/dist/browser/dist-B4FWbuEM.js +0 -4148
- package/dist/browser/dist-B4FWbuEM.js.map +0 -1
- package/dist/browser/dist-BAJ5nRDl.js.map +0 -1
- package/dist/browser/dist-Csb8sxU2.js +0 -4641
- package/dist/browser/dist-Csb8sxU2.js.map +0 -1
- package/dist/browser/document-drive-fcQ4o8i3.js +0 -8320
- package/dist/browser/document-drive-fcQ4o8i3.js.map +0 -1
- package/dist/browser/documents-J_l59mSV.js +0 -6188
- package/dist/browser/documents-J_l59mSV.js.map +0 -1
- package/dist/browser/editor-DWqW8FJ2.js.map +0 -1
- package/dist/browser/folder-view-DxzbfZuY.js +0 -232
- package/dist/browser/folder-view-DxzbfZuY.js.map +0 -1
- package/dist/browser/graphql-editor-CuiExsfF.js +0 -11698
- package/dist/browser/graphql-editor-CuiExsfF.js.map +0 -1
- package/dist/browser/hooks-KKcNp2X0.js +0 -24213
- package/dist/browser/hooks-KKcNp2X0.js.map +0 -1
- package/dist/browser/json-editor-DqRiIY49.js.map +0 -1
- package/dist/browser/lib-CPkPeg_u.js +0 -209
- package/dist/browser/lib-CPkPeg_u.js.map +0 -1
- package/dist/browser/parser-CkF6Qt8V.js +0 -2553
- package/dist/browser/parser-CkF6Qt8V.js.map +0 -1
- package/dist/browser/printer-CEYr4JOg.js +0 -604
- package/dist/browser/printer-CEYr4JOg.js.map +0 -1
- package/dist/browser/schema-context-ZyeclQwy.js.map +0 -1
- package/dist/browser/state-schemas-DZB9PFEk.js.map +0 -1
- package/dist/node/button-Da7CxMn7.mjs +0 -678
- package/dist/node/button-Da7CxMn7.mjs.map +0 -1
- package/dist/node/connect-D7y1D5hm.mjs +0 -15022
- package/dist/node/connect-D7y1D5hm.mjs.map +0 -1
- package/dist/node/dist-CTcqTvC6.mjs +0 -4649
- package/dist/node/dist-CTcqTvC6.mjs.map +0 -1
- package/dist/node/dist-CzYOpeXN.mjs +0 -2711
- package/dist/node/dist-CzYOpeXN.mjs.map +0 -1
- package/dist/node/dist-DT7jI9ol.mjs +0 -4148
- package/dist/node/dist-DT7jI9ol.mjs.map +0 -1
- package/dist/node/document-drive-DuGBBYw5.mjs +0 -8337
- package/dist/node/document-drive-DuGBBYw5.mjs.map +0 -1
- package/dist/node/documents-DCf53bzO.mjs +0 -747
- package/dist/node/documents-DCf53bzO.mjs.map +0 -1
- package/dist/node/editor-BU3YRt7c.mjs +0 -1809
- package/dist/node/editor-BU3YRt7c.mjs.map +0 -1
- package/dist/node/editor-DCN8dGJA.mjs +0 -25
- package/dist/node/editor-DCN8dGJA.mjs.map +0 -1
- package/dist/node/editors/document-model-editor/index.mjs +0 -1
- package/dist/node/editors/document-model-editor/module.mjs +0 -14
- package/dist/node/editors/document-model-editor/module.mjs.map +0 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +0 -456
- package/dist/node/editors/generic-drive-explorer/index.mjs.map +0 -1
- package/dist/node/editors/generic-drive-explorer/module.mjs +0 -14
- package/dist/node/editors/generic-drive-explorer/module.mjs.map +0 -1
- package/dist/node/folder-view-DrRUOAcf.mjs.map +0 -1
- package/dist/node/graphql-BfAoPeWM.mjs.map +0 -1
- package/dist/node/graphql-editor-C38uott6.mjs.map +0 -1
- package/dist/node/json-editor-BM2wc5Zz.mjs +0 -154
- package/dist/node/main-BhH_ajBM.mjs +0 -745
- package/dist/node/main-BhH_ajBM.mjs.map +0 -1
- package/dist/node/schema-context-DL8jhi_d.mjs.map +0 -1
- package/dist/node/state-schemas--x-Yb4EP.mjs +0 -299
- package/dist/node/state-schemas--x-Yb4EP.mjs.map +0 -1
|
@@ -1,2553 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/devAssert.mjs
|
|
2
|
-
function devAssert(condition, message) {
|
|
3
|
-
if (!Boolean(condition)) throw new Error(message);
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/isObjectLike.mjs
|
|
7
|
-
/**
|
|
8
|
-
* Return true if `value` is object-like. A value is object-like if it's not
|
|
9
|
-
* `null` and has a `typeof` result of "object".
|
|
10
|
-
*/
|
|
11
|
-
function isObjectLike(value) {
|
|
12
|
-
return typeof value == "object" && value !== null;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/invariant.mjs
|
|
16
|
-
function invariant(condition, message) {
|
|
17
|
-
if (!Boolean(condition)) throw new Error(message != null ? message : "Unexpected invariant triggered.");
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/location.mjs
|
|
21
|
-
const LineRegExp = /\r\n|[\n\r]/g;
|
|
22
|
-
/**
|
|
23
|
-
* Represents a location in a Source.
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Takes a Source and a UTF-8 character offset, and returns the corresponding
|
|
27
|
-
* line and column as a SourceLocation.
|
|
28
|
-
*/
|
|
29
|
-
function getLocation(source, position) {
|
|
30
|
-
let lastLineStart = 0;
|
|
31
|
-
let line = 1;
|
|
32
|
-
for (const match of source.body.matchAll(LineRegExp)) {
|
|
33
|
-
typeof match.index === "number" || invariant(false);
|
|
34
|
-
if (match.index >= position) break;
|
|
35
|
-
lastLineStart = match.index + match[0].length;
|
|
36
|
-
line += 1;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
line,
|
|
40
|
-
column: position + 1 - lastLineStart
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/printLocation.mjs
|
|
45
|
-
/**
|
|
46
|
-
* Render a helpful description of the location in the GraphQL Source document.
|
|
47
|
-
*/
|
|
48
|
-
function printLocation(location) {
|
|
49
|
-
return printSourceLocation(location.source, getLocation(location.source, location.start));
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Render a helpful description of the location in the GraphQL Source document.
|
|
53
|
-
*/
|
|
54
|
-
function printSourceLocation(source, sourceLocation) {
|
|
55
|
-
const firstLineColumnOffset = source.locationOffset.column - 1;
|
|
56
|
-
const body = "".padStart(firstLineColumnOffset) + source.body;
|
|
57
|
-
const lineIndex = sourceLocation.line - 1;
|
|
58
|
-
const lineOffset = source.locationOffset.line - 1;
|
|
59
|
-
const lineNum = sourceLocation.line + lineOffset;
|
|
60
|
-
const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
|
|
61
|
-
const columnNum = sourceLocation.column + columnOffset;
|
|
62
|
-
const locationStr = `${source.name}:${lineNum}:${columnNum}\n`;
|
|
63
|
-
const lines = body.split(/\r\n|[\n\r]/g);
|
|
64
|
-
const locationLine = lines[lineIndex];
|
|
65
|
-
if (locationLine.length > 120) {
|
|
66
|
-
const subLineIndex = Math.floor(columnNum / 80);
|
|
67
|
-
const subLineColumnNum = columnNum % 80;
|
|
68
|
-
const subLines = [];
|
|
69
|
-
for (let i = 0; i < locationLine.length; i += 80) subLines.push(locationLine.slice(i, i + 80));
|
|
70
|
-
return locationStr + printPrefixedLines([
|
|
71
|
-
[`${lineNum} |`, subLines[0]],
|
|
72
|
-
...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
|
|
73
|
-
["|", "^".padStart(subLineColumnNum)],
|
|
74
|
-
["|", subLines[subLineIndex + 1]]
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
return locationStr + printPrefixedLines([
|
|
78
|
-
[`${lineNum - 1} |`, lines[lineIndex - 1]],
|
|
79
|
-
[`${lineNum} |`, locationLine],
|
|
80
|
-
["|", "^".padStart(columnNum)],
|
|
81
|
-
[`${lineNum + 1} |`, lines[lineIndex + 1]]
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
function printPrefixedLines(lines) {
|
|
85
|
-
const existingLines = lines.filter(([_, line]) => line !== void 0);
|
|
86
|
-
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
87
|
-
return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
|
|
88
|
-
}
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/error/GraphQLError.mjs
|
|
91
|
-
function toNormalizedOptions(args) {
|
|
92
|
-
const firstArg = args[0];
|
|
93
|
-
if (firstArg == null || "kind" in firstArg || "length" in firstArg) return {
|
|
94
|
-
nodes: firstArg,
|
|
95
|
-
source: args[1],
|
|
96
|
-
positions: args[2],
|
|
97
|
-
path: args[3],
|
|
98
|
-
originalError: args[4],
|
|
99
|
-
extensions: args[5]
|
|
100
|
-
};
|
|
101
|
-
return firstArg;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* A GraphQLError describes an Error found during the parse, validate, or
|
|
105
|
-
* execute phases of performing a GraphQL operation. In addition to a message
|
|
106
|
-
* and stack trace, it also includes information about the locations in a
|
|
107
|
-
* GraphQL document and/or execution result that correspond to the Error.
|
|
108
|
-
*/
|
|
109
|
-
var GraphQLError = class GraphQLError extends Error {
|
|
110
|
-
/**
|
|
111
|
-
* An array of `{ line, column }` locations within the source GraphQL document
|
|
112
|
-
* which correspond to this error.
|
|
113
|
-
*
|
|
114
|
-
* Errors during validation often contain multiple locations, for example to
|
|
115
|
-
* point out two things with the same name. Errors during execution include a
|
|
116
|
-
* single location, the field which produced the error.
|
|
117
|
-
*
|
|
118
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
119
|
-
*/
|
|
120
|
-
/**
|
|
121
|
-
* An array describing the JSON-path into the execution response which
|
|
122
|
-
* corresponds to this error. Only included for errors during execution.
|
|
123
|
-
*
|
|
124
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
125
|
-
*/
|
|
126
|
-
/**
|
|
127
|
-
* An array of GraphQL AST Nodes corresponding to this error.
|
|
128
|
-
*/
|
|
129
|
-
/**
|
|
130
|
-
* The source GraphQL document for the first location of this error.
|
|
131
|
-
*
|
|
132
|
-
* Note that if this Error represents more than one node, the source may not
|
|
133
|
-
* represent nodes after the first node.
|
|
134
|
-
*/
|
|
135
|
-
/**
|
|
136
|
-
* An array of character offsets within the source GraphQL document
|
|
137
|
-
* which correspond to this error.
|
|
138
|
-
*/
|
|
139
|
-
/**
|
|
140
|
-
* The original error thrown from a field resolver during execution.
|
|
141
|
-
*/
|
|
142
|
-
/**
|
|
143
|
-
* Extension fields to add to the formatted error.
|
|
144
|
-
*/
|
|
145
|
-
/**
|
|
146
|
-
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
147
|
-
*/
|
|
148
|
-
constructor(message, ...rawArgs) {
|
|
149
|
-
var _this$nodes, _nodeLocations$, _ref;
|
|
150
|
-
const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
151
|
-
super(message);
|
|
152
|
-
this.name = "GraphQLError";
|
|
153
|
-
this.path = path !== null && path !== void 0 ? path : void 0;
|
|
154
|
-
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
155
|
-
this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0);
|
|
156
|
-
const nodeLocations = undefinedIfEmpty((_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null));
|
|
157
|
-
this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
|
|
158
|
-
this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
|
|
159
|
-
this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
|
|
160
|
-
const originalExtensions = isObjectLike(originalError === null || originalError === void 0 ? void 0 : originalError.extensions) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
|
|
161
|
-
this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : Object.create(null);
|
|
162
|
-
Object.defineProperties(this, {
|
|
163
|
-
message: {
|
|
164
|
-
writable: true,
|
|
165
|
-
enumerable: true
|
|
166
|
-
},
|
|
167
|
-
name: { enumerable: false },
|
|
168
|
-
nodes: { enumerable: false },
|
|
169
|
-
source: { enumerable: false },
|
|
170
|
-
positions: { enumerable: false },
|
|
171
|
-
originalError: { enumerable: false }
|
|
172
|
-
});
|
|
173
|
-
/* c8 ignore start */
|
|
174
|
-
if (originalError !== null && originalError !== void 0 && originalError.stack) Object.defineProperty(this, "stack", {
|
|
175
|
-
value: originalError.stack,
|
|
176
|
-
writable: true,
|
|
177
|
-
configurable: true
|
|
178
|
-
});
|
|
179
|
-
else if (Error.captureStackTrace) Error.captureStackTrace(this, GraphQLError);
|
|
180
|
-
else Object.defineProperty(this, "stack", {
|
|
181
|
-
value: Error().stack,
|
|
182
|
-
writable: true,
|
|
183
|
-
configurable: true
|
|
184
|
-
});
|
|
185
|
-
/* c8 ignore stop */
|
|
186
|
-
}
|
|
187
|
-
get [Symbol.toStringTag]() {
|
|
188
|
-
return "GraphQLError";
|
|
189
|
-
}
|
|
190
|
-
toString() {
|
|
191
|
-
let output = this.message;
|
|
192
|
-
if (this.nodes) {
|
|
193
|
-
for (const node of this.nodes) if (node.loc) output += "\n\n" + printLocation(node.loc);
|
|
194
|
-
} else if (this.source && this.locations) for (const location of this.locations) output += "\n\n" + printSourceLocation(this.source, location);
|
|
195
|
-
return output;
|
|
196
|
-
}
|
|
197
|
-
toJSON() {
|
|
198
|
-
const formattedError = { message: this.message };
|
|
199
|
-
if (this.locations != null) formattedError.locations = this.locations;
|
|
200
|
-
if (this.path != null) formattedError.path = this.path;
|
|
201
|
-
if (this.extensions != null && Object.keys(this.extensions).length > 0) formattedError.extensions = this.extensions;
|
|
202
|
-
return formattedError;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
function undefinedIfEmpty(array) {
|
|
206
|
-
return array === void 0 || array.length === 0 ? void 0 : array;
|
|
207
|
-
}
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/error/syntaxError.mjs
|
|
210
|
-
/**
|
|
211
|
-
* Produces a GraphQLError representing a syntax error, containing useful
|
|
212
|
-
* descriptive information about the syntax error's position in the source.
|
|
213
|
-
*/
|
|
214
|
-
function syntaxError(source, position, description) {
|
|
215
|
-
return new GraphQLError(`Syntax Error: ${description}`, {
|
|
216
|
-
source,
|
|
217
|
-
positions: [position]
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/ast.mjs
|
|
222
|
-
/**
|
|
223
|
-
* Contains a range of UTF-8 character offsets and token references that
|
|
224
|
-
* identify the region of the source from which the AST derived.
|
|
225
|
-
*/
|
|
226
|
-
var Location = class {
|
|
227
|
-
/**
|
|
228
|
-
* The character offset at which this Node begins.
|
|
229
|
-
*/
|
|
230
|
-
/**
|
|
231
|
-
* The character offset at which this Node ends.
|
|
232
|
-
*/
|
|
233
|
-
/**
|
|
234
|
-
* The Token at which this Node begins.
|
|
235
|
-
*/
|
|
236
|
-
/**
|
|
237
|
-
* The Token at which this Node ends.
|
|
238
|
-
*/
|
|
239
|
-
/**
|
|
240
|
-
* The Source document the AST represents.
|
|
241
|
-
*/
|
|
242
|
-
constructor(startToken, endToken, source) {
|
|
243
|
-
this.start = startToken.start;
|
|
244
|
-
this.end = endToken.end;
|
|
245
|
-
this.startToken = startToken;
|
|
246
|
-
this.endToken = endToken;
|
|
247
|
-
this.source = source;
|
|
248
|
-
}
|
|
249
|
-
get [Symbol.toStringTag]() {
|
|
250
|
-
return "Location";
|
|
251
|
-
}
|
|
252
|
-
toJSON() {
|
|
253
|
-
return {
|
|
254
|
-
start: this.start,
|
|
255
|
-
end: this.end
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Represents a range of characters represented by a lexical token
|
|
261
|
-
* within a Source.
|
|
262
|
-
*/
|
|
263
|
-
var Token = class {
|
|
264
|
-
/**
|
|
265
|
-
* The kind of Token.
|
|
266
|
-
*/
|
|
267
|
-
/**
|
|
268
|
-
* The character offset at which this Node begins.
|
|
269
|
-
*/
|
|
270
|
-
/**
|
|
271
|
-
* The character offset at which this Node ends.
|
|
272
|
-
*/
|
|
273
|
-
/**
|
|
274
|
-
* The 1-indexed line number on which this Token appears.
|
|
275
|
-
*/
|
|
276
|
-
/**
|
|
277
|
-
* The 1-indexed column number at which this Token begins.
|
|
278
|
-
*/
|
|
279
|
-
/**
|
|
280
|
-
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
281
|
-
*
|
|
282
|
-
* Note: is undefined for punctuation tokens, but typed as string for
|
|
283
|
-
* convenience in the parser.
|
|
284
|
-
*/
|
|
285
|
-
/**
|
|
286
|
-
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
287
|
-
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
288
|
-
* the last.
|
|
289
|
-
*/
|
|
290
|
-
constructor(kind, start, end, line, column, value) {
|
|
291
|
-
this.kind = kind;
|
|
292
|
-
this.start = start;
|
|
293
|
-
this.end = end;
|
|
294
|
-
this.line = line;
|
|
295
|
-
this.column = column;
|
|
296
|
-
this.value = value;
|
|
297
|
-
this.prev = null;
|
|
298
|
-
this.next = null;
|
|
299
|
-
}
|
|
300
|
-
get [Symbol.toStringTag]() {
|
|
301
|
-
return "Token";
|
|
302
|
-
}
|
|
303
|
-
toJSON() {
|
|
304
|
-
return {
|
|
305
|
-
kind: this.kind,
|
|
306
|
-
value: this.value,
|
|
307
|
-
line: this.line,
|
|
308
|
-
column: this.column
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* The list of all possible AST node types.
|
|
314
|
-
*/
|
|
315
|
-
/**
|
|
316
|
-
* @internal
|
|
317
|
-
*/
|
|
318
|
-
const QueryDocumentKeys = {
|
|
319
|
-
Name: [],
|
|
320
|
-
Document: ["definitions"],
|
|
321
|
-
OperationDefinition: [
|
|
322
|
-
"description",
|
|
323
|
-
"name",
|
|
324
|
-
"variableDefinitions",
|
|
325
|
-
"directives",
|
|
326
|
-
"selectionSet"
|
|
327
|
-
],
|
|
328
|
-
VariableDefinition: [
|
|
329
|
-
"description",
|
|
330
|
-
"variable",
|
|
331
|
-
"type",
|
|
332
|
-
"defaultValue",
|
|
333
|
-
"directives"
|
|
334
|
-
],
|
|
335
|
-
Variable: ["name"],
|
|
336
|
-
SelectionSet: ["selections"],
|
|
337
|
-
Field: [
|
|
338
|
-
"alias",
|
|
339
|
-
"name",
|
|
340
|
-
"arguments",
|
|
341
|
-
"directives",
|
|
342
|
-
"selectionSet"
|
|
343
|
-
],
|
|
344
|
-
Argument: ["name", "value"],
|
|
345
|
-
FragmentSpread: ["name", "directives"],
|
|
346
|
-
InlineFragment: [
|
|
347
|
-
"typeCondition",
|
|
348
|
-
"directives",
|
|
349
|
-
"selectionSet"
|
|
350
|
-
],
|
|
351
|
-
FragmentDefinition: [
|
|
352
|
-
"description",
|
|
353
|
-
"name",
|
|
354
|
-
"variableDefinitions",
|
|
355
|
-
"typeCondition",
|
|
356
|
-
"directives",
|
|
357
|
-
"selectionSet"
|
|
358
|
-
],
|
|
359
|
-
IntValue: [],
|
|
360
|
-
FloatValue: [],
|
|
361
|
-
StringValue: [],
|
|
362
|
-
BooleanValue: [],
|
|
363
|
-
NullValue: [],
|
|
364
|
-
EnumValue: [],
|
|
365
|
-
ListValue: ["values"],
|
|
366
|
-
ObjectValue: ["fields"],
|
|
367
|
-
ObjectField: ["name", "value"],
|
|
368
|
-
Directive: ["name", "arguments"],
|
|
369
|
-
NamedType: ["name"],
|
|
370
|
-
ListType: ["type"],
|
|
371
|
-
NonNullType: ["type"],
|
|
372
|
-
SchemaDefinition: [
|
|
373
|
-
"description",
|
|
374
|
-
"directives",
|
|
375
|
-
"operationTypes"
|
|
376
|
-
],
|
|
377
|
-
OperationTypeDefinition: ["type"],
|
|
378
|
-
ScalarTypeDefinition: [
|
|
379
|
-
"description",
|
|
380
|
-
"name",
|
|
381
|
-
"directives"
|
|
382
|
-
],
|
|
383
|
-
ObjectTypeDefinition: [
|
|
384
|
-
"description",
|
|
385
|
-
"name",
|
|
386
|
-
"interfaces",
|
|
387
|
-
"directives",
|
|
388
|
-
"fields"
|
|
389
|
-
],
|
|
390
|
-
FieldDefinition: [
|
|
391
|
-
"description",
|
|
392
|
-
"name",
|
|
393
|
-
"arguments",
|
|
394
|
-
"type",
|
|
395
|
-
"directives"
|
|
396
|
-
],
|
|
397
|
-
InputValueDefinition: [
|
|
398
|
-
"description",
|
|
399
|
-
"name",
|
|
400
|
-
"type",
|
|
401
|
-
"defaultValue",
|
|
402
|
-
"directives"
|
|
403
|
-
],
|
|
404
|
-
InterfaceTypeDefinition: [
|
|
405
|
-
"description",
|
|
406
|
-
"name",
|
|
407
|
-
"interfaces",
|
|
408
|
-
"directives",
|
|
409
|
-
"fields"
|
|
410
|
-
],
|
|
411
|
-
UnionTypeDefinition: [
|
|
412
|
-
"description",
|
|
413
|
-
"name",
|
|
414
|
-
"directives",
|
|
415
|
-
"types"
|
|
416
|
-
],
|
|
417
|
-
EnumTypeDefinition: [
|
|
418
|
-
"description",
|
|
419
|
-
"name",
|
|
420
|
-
"directives",
|
|
421
|
-
"values"
|
|
422
|
-
],
|
|
423
|
-
EnumValueDefinition: [
|
|
424
|
-
"description",
|
|
425
|
-
"name",
|
|
426
|
-
"directives"
|
|
427
|
-
],
|
|
428
|
-
InputObjectTypeDefinition: [
|
|
429
|
-
"description",
|
|
430
|
-
"name",
|
|
431
|
-
"directives",
|
|
432
|
-
"fields"
|
|
433
|
-
],
|
|
434
|
-
DirectiveDefinition: [
|
|
435
|
-
"description",
|
|
436
|
-
"name",
|
|
437
|
-
"arguments",
|
|
438
|
-
"locations"
|
|
439
|
-
],
|
|
440
|
-
SchemaExtension: ["directives", "operationTypes"],
|
|
441
|
-
ScalarTypeExtension: ["name", "directives"],
|
|
442
|
-
ObjectTypeExtension: [
|
|
443
|
-
"name",
|
|
444
|
-
"interfaces",
|
|
445
|
-
"directives",
|
|
446
|
-
"fields"
|
|
447
|
-
],
|
|
448
|
-
InterfaceTypeExtension: [
|
|
449
|
-
"name",
|
|
450
|
-
"interfaces",
|
|
451
|
-
"directives",
|
|
452
|
-
"fields"
|
|
453
|
-
],
|
|
454
|
-
UnionTypeExtension: [
|
|
455
|
-
"name",
|
|
456
|
-
"directives",
|
|
457
|
-
"types"
|
|
458
|
-
],
|
|
459
|
-
EnumTypeExtension: [
|
|
460
|
-
"name",
|
|
461
|
-
"directives",
|
|
462
|
-
"values"
|
|
463
|
-
],
|
|
464
|
-
InputObjectTypeExtension: [
|
|
465
|
-
"name",
|
|
466
|
-
"directives",
|
|
467
|
-
"fields"
|
|
468
|
-
],
|
|
469
|
-
TypeCoordinate: ["name"],
|
|
470
|
-
MemberCoordinate: ["name", "memberName"],
|
|
471
|
-
ArgumentCoordinate: [
|
|
472
|
-
"name",
|
|
473
|
-
"fieldName",
|
|
474
|
-
"argumentName"
|
|
475
|
-
],
|
|
476
|
-
DirectiveCoordinate: ["name"],
|
|
477
|
-
DirectiveArgumentCoordinate: ["name", "argumentName"]
|
|
478
|
-
};
|
|
479
|
-
const kindValues = new Set(Object.keys(QueryDocumentKeys));
|
|
480
|
-
/**
|
|
481
|
-
* @internal
|
|
482
|
-
*/
|
|
483
|
-
function isNode(maybeNode) {
|
|
484
|
-
const maybeKind = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind;
|
|
485
|
-
return typeof maybeKind === "string" && kindValues.has(maybeKind);
|
|
486
|
-
}
|
|
487
|
-
/** Name */
|
|
488
|
-
var OperationTypeNode;
|
|
489
|
-
(function(OperationTypeNode) {
|
|
490
|
-
OperationTypeNode["QUERY"] = "query";
|
|
491
|
-
OperationTypeNode["MUTATION"] = "mutation";
|
|
492
|
-
OperationTypeNode["SUBSCRIPTION"] = "subscription";
|
|
493
|
-
})(OperationTypeNode || (OperationTypeNode = {}));
|
|
494
|
-
//#endregion
|
|
495
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/directiveLocation.mjs
|
|
496
|
-
/**
|
|
497
|
-
* The set of allowed directive location values.
|
|
498
|
-
*/
|
|
499
|
-
var DirectiveLocation;
|
|
500
|
-
(function(DirectiveLocation) {
|
|
501
|
-
DirectiveLocation["QUERY"] = "QUERY";
|
|
502
|
-
DirectiveLocation["MUTATION"] = "MUTATION";
|
|
503
|
-
DirectiveLocation["SUBSCRIPTION"] = "SUBSCRIPTION";
|
|
504
|
-
DirectiveLocation["FIELD"] = "FIELD";
|
|
505
|
-
DirectiveLocation["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
|
|
506
|
-
DirectiveLocation["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
|
|
507
|
-
DirectiveLocation["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
|
|
508
|
-
DirectiveLocation["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
|
|
509
|
-
DirectiveLocation["SCHEMA"] = "SCHEMA";
|
|
510
|
-
DirectiveLocation["SCALAR"] = "SCALAR";
|
|
511
|
-
DirectiveLocation["OBJECT"] = "OBJECT";
|
|
512
|
-
DirectiveLocation["FIELD_DEFINITION"] = "FIELD_DEFINITION";
|
|
513
|
-
DirectiveLocation["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
|
|
514
|
-
DirectiveLocation["INTERFACE"] = "INTERFACE";
|
|
515
|
-
DirectiveLocation["UNION"] = "UNION";
|
|
516
|
-
DirectiveLocation["ENUM"] = "ENUM";
|
|
517
|
-
DirectiveLocation["ENUM_VALUE"] = "ENUM_VALUE";
|
|
518
|
-
DirectiveLocation["INPUT_OBJECT"] = "INPUT_OBJECT";
|
|
519
|
-
DirectiveLocation["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
|
|
520
|
-
})(DirectiveLocation || (DirectiveLocation = {}));
|
|
521
|
-
/**
|
|
522
|
-
* The enum type representing the directive location values.
|
|
523
|
-
*
|
|
524
|
-
* @deprecated Please use `DirectiveLocation`. Will be remove in v17.
|
|
525
|
-
*/
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/kinds.mjs
|
|
528
|
-
/**
|
|
529
|
-
* The set of allowed kind values for AST nodes.
|
|
530
|
-
*/
|
|
531
|
-
var Kind;
|
|
532
|
-
(function(Kind) {
|
|
533
|
-
Kind["NAME"] = "Name";
|
|
534
|
-
Kind["DOCUMENT"] = "Document";
|
|
535
|
-
Kind["OPERATION_DEFINITION"] = "OperationDefinition";
|
|
536
|
-
Kind["VARIABLE_DEFINITION"] = "VariableDefinition";
|
|
537
|
-
Kind["SELECTION_SET"] = "SelectionSet";
|
|
538
|
-
Kind["FIELD"] = "Field";
|
|
539
|
-
Kind["ARGUMENT"] = "Argument";
|
|
540
|
-
Kind["FRAGMENT_SPREAD"] = "FragmentSpread";
|
|
541
|
-
Kind["INLINE_FRAGMENT"] = "InlineFragment";
|
|
542
|
-
Kind["FRAGMENT_DEFINITION"] = "FragmentDefinition";
|
|
543
|
-
Kind["VARIABLE"] = "Variable";
|
|
544
|
-
Kind["INT"] = "IntValue";
|
|
545
|
-
Kind["FLOAT"] = "FloatValue";
|
|
546
|
-
Kind["STRING"] = "StringValue";
|
|
547
|
-
Kind["BOOLEAN"] = "BooleanValue";
|
|
548
|
-
Kind["NULL"] = "NullValue";
|
|
549
|
-
Kind["ENUM"] = "EnumValue";
|
|
550
|
-
Kind["LIST"] = "ListValue";
|
|
551
|
-
Kind["OBJECT"] = "ObjectValue";
|
|
552
|
-
Kind["OBJECT_FIELD"] = "ObjectField";
|
|
553
|
-
Kind["DIRECTIVE"] = "Directive";
|
|
554
|
-
Kind["NAMED_TYPE"] = "NamedType";
|
|
555
|
-
Kind["LIST_TYPE"] = "ListType";
|
|
556
|
-
Kind["NON_NULL_TYPE"] = "NonNullType";
|
|
557
|
-
Kind["SCHEMA_DEFINITION"] = "SchemaDefinition";
|
|
558
|
-
Kind["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
|
|
559
|
-
Kind["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
|
|
560
|
-
Kind["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
|
|
561
|
-
Kind["FIELD_DEFINITION"] = "FieldDefinition";
|
|
562
|
-
Kind["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
|
|
563
|
-
Kind["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
|
|
564
|
-
Kind["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
|
|
565
|
-
Kind["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
|
|
566
|
-
Kind["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
|
|
567
|
-
Kind["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
|
|
568
|
-
Kind["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
|
|
569
|
-
Kind["SCHEMA_EXTENSION"] = "SchemaExtension";
|
|
570
|
-
Kind["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
|
|
571
|
-
Kind["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
|
|
572
|
-
Kind["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
|
|
573
|
-
Kind["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
|
|
574
|
-
Kind["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
|
|
575
|
-
Kind["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
|
|
576
|
-
Kind["TYPE_COORDINATE"] = "TypeCoordinate";
|
|
577
|
-
Kind["MEMBER_COORDINATE"] = "MemberCoordinate";
|
|
578
|
-
Kind["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
|
|
579
|
-
Kind["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
|
|
580
|
-
Kind["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
|
|
581
|
-
})(Kind || (Kind = {}));
|
|
582
|
-
/**
|
|
583
|
-
* The enum type representing the possible kind values of AST nodes.
|
|
584
|
-
*
|
|
585
|
-
* @deprecated Please use `Kind`. Will be remove in v17.
|
|
586
|
-
*/
|
|
587
|
-
//#endregion
|
|
588
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/characterClasses.mjs
|
|
589
|
-
/**
|
|
590
|
-
* ```
|
|
591
|
-
* WhiteSpace ::
|
|
592
|
-
* - "Horizontal Tab (U+0009)"
|
|
593
|
-
* - "Space (U+0020)"
|
|
594
|
-
* ```
|
|
595
|
-
* @internal
|
|
596
|
-
*/
|
|
597
|
-
function isWhiteSpace(code) {
|
|
598
|
-
return code === 9 || code === 32;
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* ```
|
|
602
|
-
* Digit :: one of
|
|
603
|
-
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
604
|
-
* ```
|
|
605
|
-
* @internal
|
|
606
|
-
*/
|
|
607
|
-
function isDigit(code) {
|
|
608
|
-
return code >= 48 && code <= 57;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* ```
|
|
612
|
-
* Letter :: one of
|
|
613
|
-
* - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
|
|
614
|
-
* - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
|
|
615
|
-
* - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
|
|
616
|
-
* - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
|
|
617
|
-
* ```
|
|
618
|
-
* @internal
|
|
619
|
-
*/
|
|
620
|
-
function isLetter(code) {
|
|
621
|
-
return code >= 97 && code <= 122 || code >= 65 && code <= 90;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* ```
|
|
625
|
-
* NameStart ::
|
|
626
|
-
* - Letter
|
|
627
|
-
* - `_`
|
|
628
|
-
* ```
|
|
629
|
-
* @internal
|
|
630
|
-
*/
|
|
631
|
-
function isNameStart(code) {
|
|
632
|
-
return isLetter(code) || code === 95;
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* ```
|
|
636
|
-
* NameContinue ::
|
|
637
|
-
* - Letter
|
|
638
|
-
* - Digit
|
|
639
|
-
* - `_`
|
|
640
|
-
* ```
|
|
641
|
-
* @internal
|
|
642
|
-
*/
|
|
643
|
-
function isNameContinue(code) {
|
|
644
|
-
return isLetter(code) || isDigit(code) || code === 95;
|
|
645
|
-
}
|
|
646
|
-
//#endregion
|
|
647
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/blockString.mjs
|
|
648
|
-
/**
|
|
649
|
-
* Produces the value of a block string from its parsed raw value, similar to
|
|
650
|
-
* CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc.
|
|
651
|
-
*
|
|
652
|
-
* This implements the GraphQL spec's BlockStringValue() static algorithm.
|
|
653
|
-
*
|
|
654
|
-
* @internal
|
|
655
|
-
*/
|
|
656
|
-
function dedentBlockStringLines(lines) {
|
|
657
|
-
var _firstNonEmptyLine2;
|
|
658
|
-
let commonIndent = Number.MAX_SAFE_INTEGER;
|
|
659
|
-
let firstNonEmptyLine = null;
|
|
660
|
-
let lastNonEmptyLine = -1;
|
|
661
|
-
for (let i = 0; i < lines.length; ++i) {
|
|
662
|
-
var _firstNonEmptyLine;
|
|
663
|
-
const line = lines[i];
|
|
664
|
-
const indent = leadingWhitespace(line);
|
|
665
|
-
if (indent === line.length) continue;
|
|
666
|
-
firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
|
|
667
|
-
lastNonEmptyLine = i;
|
|
668
|
-
if (i !== 0 && indent < commonIndent) commonIndent = indent;
|
|
669
|
-
}
|
|
670
|
-
return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice((_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0, lastNonEmptyLine + 1);
|
|
671
|
-
}
|
|
672
|
-
function leadingWhitespace(str) {
|
|
673
|
-
let i = 0;
|
|
674
|
-
while (i < str.length && isWhiteSpace(str.charCodeAt(i))) ++i;
|
|
675
|
-
return i;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* @internal
|
|
679
|
-
*/
|
|
680
|
-
function isPrintableAsBlockString(value) {
|
|
681
|
-
if (value === "") return true;
|
|
682
|
-
let isEmptyLine = true;
|
|
683
|
-
let hasIndent = false;
|
|
684
|
-
let hasCommonIndent = true;
|
|
685
|
-
let seenNonEmptyLine = false;
|
|
686
|
-
for (let i = 0; i < value.length; ++i) switch (value.codePointAt(i)) {
|
|
687
|
-
case 0:
|
|
688
|
-
case 1:
|
|
689
|
-
case 2:
|
|
690
|
-
case 3:
|
|
691
|
-
case 4:
|
|
692
|
-
case 5:
|
|
693
|
-
case 6:
|
|
694
|
-
case 7:
|
|
695
|
-
case 8:
|
|
696
|
-
case 11:
|
|
697
|
-
case 12:
|
|
698
|
-
case 14:
|
|
699
|
-
case 15: return false;
|
|
700
|
-
case 13: return false;
|
|
701
|
-
case 10:
|
|
702
|
-
if (isEmptyLine && !seenNonEmptyLine) return false;
|
|
703
|
-
seenNonEmptyLine = true;
|
|
704
|
-
isEmptyLine = true;
|
|
705
|
-
hasIndent = false;
|
|
706
|
-
break;
|
|
707
|
-
case 9:
|
|
708
|
-
case 32:
|
|
709
|
-
hasIndent || (hasIndent = isEmptyLine);
|
|
710
|
-
break;
|
|
711
|
-
default:
|
|
712
|
-
hasCommonIndent && (hasCommonIndent = hasIndent);
|
|
713
|
-
isEmptyLine = false;
|
|
714
|
-
}
|
|
715
|
-
if (isEmptyLine) return false;
|
|
716
|
-
if (hasCommonIndent && seenNonEmptyLine) return false;
|
|
717
|
-
return true;
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Print a block string in the indented block form by adding a leading and
|
|
721
|
-
* trailing blank line. However, if a block string starts with whitespace and is
|
|
722
|
-
* a single-line, adding a leading blank line would strip that whitespace.
|
|
723
|
-
*
|
|
724
|
-
* @internal
|
|
725
|
-
*/
|
|
726
|
-
function printBlockString(value, options) {
|
|
727
|
-
const escapedValue = value.replace(/"""/g, "\\\"\"\"");
|
|
728
|
-
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
|
729
|
-
const isSingleLine = lines.length === 1;
|
|
730
|
-
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0)));
|
|
731
|
-
const hasTrailingTripleQuotes = escapedValue.endsWith("\\\"\"\"");
|
|
732
|
-
const hasTrailingQuote = value.endsWith("\"") && !hasTrailingTripleQuotes;
|
|
733
|
-
const hasTrailingSlash = value.endsWith("\\");
|
|
734
|
-
const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;
|
|
735
|
-
const printAsMultipleLines = !(options !== null && options !== void 0 && options.minimize) && (!isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes);
|
|
736
|
-
let result = "";
|
|
737
|
-
const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0));
|
|
738
|
-
if (printAsMultipleLines && !skipLeadingNewLine || forceLeadingNewLine) result += "\n";
|
|
739
|
-
result += escapedValue;
|
|
740
|
-
if (printAsMultipleLines || forceTrailingNewline) result += "\n";
|
|
741
|
-
return "\"\"\"" + result + "\"\"\"";
|
|
742
|
-
}
|
|
743
|
-
//#endregion
|
|
744
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/tokenKind.mjs
|
|
745
|
-
/**
|
|
746
|
-
* An exported enum describing the different kinds of tokens that the
|
|
747
|
-
* lexer emits.
|
|
748
|
-
*/
|
|
749
|
-
var TokenKind;
|
|
750
|
-
(function(TokenKind) {
|
|
751
|
-
TokenKind["SOF"] = "<SOF>";
|
|
752
|
-
TokenKind["EOF"] = "<EOF>";
|
|
753
|
-
TokenKind["BANG"] = "!";
|
|
754
|
-
TokenKind["DOLLAR"] = "$";
|
|
755
|
-
TokenKind["AMP"] = "&";
|
|
756
|
-
TokenKind["PAREN_L"] = "(";
|
|
757
|
-
TokenKind["PAREN_R"] = ")";
|
|
758
|
-
TokenKind["DOT"] = ".";
|
|
759
|
-
TokenKind["SPREAD"] = "...";
|
|
760
|
-
TokenKind["COLON"] = ":";
|
|
761
|
-
TokenKind["EQUALS"] = "=";
|
|
762
|
-
TokenKind["AT"] = "@";
|
|
763
|
-
TokenKind["BRACKET_L"] = "[";
|
|
764
|
-
TokenKind["BRACKET_R"] = "]";
|
|
765
|
-
TokenKind["BRACE_L"] = "{";
|
|
766
|
-
TokenKind["PIPE"] = "|";
|
|
767
|
-
TokenKind["BRACE_R"] = "}";
|
|
768
|
-
TokenKind["NAME"] = "Name";
|
|
769
|
-
TokenKind["INT"] = "Int";
|
|
770
|
-
TokenKind["FLOAT"] = "Float";
|
|
771
|
-
TokenKind["STRING"] = "String";
|
|
772
|
-
TokenKind["BLOCK_STRING"] = "BlockString";
|
|
773
|
-
TokenKind["COMMENT"] = "Comment";
|
|
774
|
-
})(TokenKind || (TokenKind = {}));
|
|
775
|
-
/**
|
|
776
|
-
* The enum type representing the token kinds values.
|
|
777
|
-
*
|
|
778
|
-
* @deprecated Please use `TokenKind`. Will be remove in v17.
|
|
779
|
-
*/
|
|
780
|
-
//#endregion
|
|
781
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/lexer.mjs
|
|
782
|
-
/**
|
|
783
|
-
* A Lexer interface which provides common properties and methods required for
|
|
784
|
-
* lexing GraphQL source.
|
|
785
|
-
*
|
|
786
|
-
* @internal
|
|
787
|
-
*/
|
|
788
|
-
/**
|
|
789
|
-
* Given a Source object, creates a Lexer for that source.
|
|
790
|
-
* A Lexer is a stateful stream generator in that every time
|
|
791
|
-
* it is advanced, it returns the next token in the Source. Assuming the
|
|
792
|
-
* source lexes, the final Token emitted by the lexer will be of kind
|
|
793
|
-
* EOF, after which the lexer will repeatedly return the same EOF token
|
|
794
|
-
* whenever called.
|
|
795
|
-
*/
|
|
796
|
-
var Lexer = class {
|
|
797
|
-
/**
|
|
798
|
-
* The previously focused non-ignored token.
|
|
799
|
-
*/
|
|
800
|
-
/**
|
|
801
|
-
* The currently focused non-ignored token.
|
|
802
|
-
*/
|
|
803
|
-
/**
|
|
804
|
-
* The (1-indexed) line containing the current token.
|
|
805
|
-
*/
|
|
806
|
-
/**
|
|
807
|
-
* The character offset at which the current line begins.
|
|
808
|
-
*/
|
|
809
|
-
constructor(source) {
|
|
810
|
-
const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
|
|
811
|
-
this.source = source;
|
|
812
|
-
this.lastToken = startOfFileToken;
|
|
813
|
-
this.token = startOfFileToken;
|
|
814
|
-
this.line = 1;
|
|
815
|
-
this.lineStart = 0;
|
|
816
|
-
}
|
|
817
|
-
get [Symbol.toStringTag]() {
|
|
818
|
-
return "Lexer";
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Advances the token stream to the next non-ignored token.
|
|
822
|
-
*/
|
|
823
|
-
advance() {
|
|
824
|
-
this.lastToken = this.token;
|
|
825
|
-
return this.token = this.lookahead();
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Looks ahead and returns the next non-ignored token, but does not change
|
|
829
|
-
* the state of Lexer.
|
|
830
|
-
*/
|
|
831
|
-
lookahead() {
|
|
832
|
-
let token = this.token;
|
|
833
|
-
if (token.kind !== TokenKind.EOF) do
|
|
834
|
-
if (token.next) token = token.next;
|
|
835
|
-
else {
|
|
836
|
-
const nextToken = readNextToken(this, token.end);
|
|
837
|
-
token.next = nextToken;
|
|
838
|
-
nextToken.prev = token;
|
|
839
|
-
token = nextToken;
|
|
840
|
-
}
|
|
841
|
-
while (token.kind === TokenKind.COMMENT);
|
|
842
|
-
return token;
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
/**
|
|
846
|
-
* @internal
|
|
847
|
-
*/
|
|
848
|
-
function isPunctuatorTokenKind(kind) {
|
|
849
|
-
return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.DOT || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* A Unicode scalar value is any Unicode code point except surrogate code
|
|
853
|
-
* points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and
|
|
854
|
-
* 0xE000 to 0x10FFFF.
|
|
855
|
-
*
|
|
856
|
-
* SourceCharacter ::
|
|
857
|
-
* - "Any Unicode scalar value"
|
|
858
|
-
*/
|
|
859
|
-
function isUnicodeScalarValue(code) {
|
|
860
|
-
return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* The GraphQL specification defines source text as a sequence of unicode scalar
|
|
864
|
-
* values (which Unicode defines to exclude surrogate code points). However
|
|
865
|
-
* JavaScript defines strings as a sequence of UTF-16 code units which may
|
|
866
|
-
* include surrogates. A surrogate pair is a valid source character as it
|
|
867
|
-
* encodes a supplementary code point (above U+FFFF), but unpaired surrogate
|
|
868
|
-
* code points are not valid source characters.
|
|
869
|
-
*/
|
|
870
|
-
function isSupplementaryCodePoint(body, location) {
|
|
871
|
-
return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
|
|
872
|
-
}
|
|
873
|
-
function isLeadingSurrogate(code) {
|
|
874
|
-
return code >= 55296 && code <= 56319;
|
|
875
|
-
}
|
|
876
|
-
function isTrailingSurrogate(code) {
|
|
877
|
-
return code >= 56320 && code <= 57343;
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* Prints the code point (or end of file reference) at a given location in a
|
|
881
|
-
* source for use in error messages.
|
|
882
|
-
*
|
|
883
|
-
* Printable ASCII is printed quoted, while other points are printed in Unicode
|
|
884
|
-
* code point form (ie. U+1234).
|
|
885
|
-
*
|
|
886
|
-
* @internal
|
|
887
|
-
*/
|
|
888
|
-
function printCodePointAt(lexer, location) {
|
|
889
|
-
const code = lexer.source.body.codePointAt(location);
|
|
890
|
-
if (code === void 0) return TokenKind.EOF;
|
|
891
|
-
else if (code >= 32 && code <= 126) {
|
|
892
|
-
const char = String.fromCodePoint(code);
|
|
893
|
-
return char === "\"" ? "'\"'" : `"${char}"`;
|
|
894
|
-
}
|
|
895
|
-
return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Create a token with line and column location information.
|
|
899
|
-
*
|
|
900
|
-
* @internal
|
|
901
|
-
*/
|
|
902
|
-
function createToken(lexer, kind, start, end, value) {
|
|
903
|
-
const line = lexer.line;
|
|
904
|
-
return new Token(kind, start, end, line, 1 + start - lexer.lineStart, value);
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* Gets the next token from the source starting at the given position.
|
|
908
|
-
*
|
|
909
|
-
* This skips over whitespace until it finds the next lexable token, then lexes
|
|
910
|
-
* punctuators immediately or calls the appropriate helper function for more
|
|
911
|
-
* complicated tokens.
|
|
912
|
-
*/
|
|
913
|
-
function readNextToken(lexer, start) {
|
|
914
|
-
const body = lexer.source.body;
|
|
915
|
-
const bodyLength = body.length;
|
|
916
|
-
let position = start;
|
|
917
|
-
while (position < bodyLength) {
|
|
918
|
-
const code = body.charCodeAt(position);
|
|
919
|
-
switch (code) {
|
|
920
|
-
case 65279:
|
|
921
|
-
case 9:
|
|
922
|
-
case 32:
|
|
923
|
-
case 44:
|
|
924
|
-
++position;
|
|
925
|
-
continue;
|
|
926
|
-
case 10:
|
|
927
|
-
++position;
|
|
928
|
-
++lexer.line;
|
|
929
|
-
lexer.lineStart = position;
|
|
930
|
-
continue;
|
|
931
|
-
case 13:
|
|
932
|
-
if (body.charCodeAt(position + 1) === 10) position += 2;
|
|
933
|
-
else ++position;
|
|
934
|
-
++lexer.line;
|
|
935
|
-
lexer.lineStart = position;
|
|
936
|
-
continue;
|
|
937
|
-
case 35: return readComment(lexer, position);
|
|
938
|
-
case 33: return createToken(lexer, TokenKind.BANG, position, position + 1);
|
|
939
|
-
case 36: return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
|
|
940
|
-
case 38: return createToken(lexer, TokenKind.AMP, position, position + 1);
|
|
941
|
-
case 40: return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
|
|
942
|
-
case 41: return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
|
|
943
|
-
case 46:
|
|
944
|
-
if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) return createToken(lexer, TokenKind.SPREAD, position, position + 3);
|
|
945
|
-
break;
|
|
946
|
-
case 58: return createToken(lexer, TokenKind.COLON, position, position + 1);
|
|
947
|
-
case 61: return createToken(lexer, TokenKind.EQUALS, position, position + 1);
|
|
948
|
-
case 64: return createToken(lexer, TokenKind.AT, position, position + 1);
|
|
949
|
-
case 91: return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
|
|
950
|
-
case 93: return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
|
|
951
|
-
case 123: return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
|
|
952
|
-
case 124: return createToken(lexer, TokenKind.PIPE, position, position + 1);
|
|
953
|
-
case 125: return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
|
|
954
|
-
case 34:
|
|
955
|
-
if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) return readBlockString(lexer, position);
|
|
956
|
-
return readString(lexer, position);
|
|
957
|
-
}
|
|
958
|
-
if (isDigit(code) || code === 45) return readNumber(lexer, position, code);
|
|
959
|
-
if (isNameStart(code)) return readName(lexer, position);
|
|
960
|
-
throw syntaxError(lexer.source, position, code === 39 ? "Unexpected single quote character ('), did you mean to use a double quote (\")?" : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`);
|
|
961
|
-
}
|
|
962
|
-
return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Reads a comment token from the source file.
|
|
966
|
-
*
|
|
967
|
-
* ```
|
|
968
|
-
* Comment :: # CommentChar* [lookahead != CommentChar]
|
|
969
|
-
*
|
|
970
|
-
* CommentChar :: SourceCharacter but not LineTerminator
|
|
971
|
-
* ```
|
|
972
|
-
*/
|
|
973
|
-
function readComment(lexer, start) {
|
|
974
|
-
const body = lexer.source.body;
|
|
975
|
-
const bodyLength = body.length;
|
|
976
|
-
let position = start + 1;
|
|
977
|
-
while (position < bodyLength) {
|
|
978
|
-
const code = body.charCodeAt(position);
|
|
979
|
-
if (code === 10 || code === 13) break;
|
|
980
|
-
if (isUnicodeScalarValue(code)) ++position;
|
|
981
|
-
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
982
|
-
else break;
|
|
983
|
-
}
|
|
984
|
-
return createToken(lexer, TokenKind.COMMENT, start, position, body.slice(start + 1, position));
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Reads a number token from the source file, either a FloatValue or an IntValue
|
|
988
|
-
* depending on whether a FractionalPart or ExponentPart is encountered.
|
|
989
|
-
*
|
|
990
|
-
* ```
|
|
991
|
-
* IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]
|
|
992
|
-
*
|
|
993
|
-
* IntegerPart ::
|
|
994
|
-
* - NegativeSign? 0
|
|
995
|
-
* - NegativeSign? NonZeroDigit Digit*
|
|
996
|
-
*
|
|
997
|
-
* NegativeSign :: -
|
|
998
|
-
*
|
|
999
|
-
* NonZeroDigit :: Digit but not `0`
|
|
1000
|
-
*
|
|
1001
|
-
* FloatValue ::
|
|
1002
|
-
* - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
1003
|
-
* - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
|
|
1004
|
-
* - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
|
|
1005
|
-
*
|
|
1006
|
-
* FractionalPart :: . Digit+
|
|
1007
|
-
*
|
|
1008
|
-
* ExponentPart :: ExponentIndicator Sign? Digit+
|
|
1009
|
-
*
|
|
1010
|
-
* ExponentIndicator :: one of `e` `E`
|
|
1011
|
-
*
|
|
1012
|
-
* Sign :: one of + -
|
|
1013
|
-
* ```
|
|
1014
|
-
*/
|
|
1015
|
-
function readNumber(lexer, start, firstCode) {
|
|
1016
|
-
const body = lexer.source.body;
|
|
1017
|
-
let position = start;
|
|
1018
|
-
let code = firstCode;
|
|
1019
|
-
let isFloat = false;
|
|
1020
|
-
if (code === 45) code = body.charCodeAt(++position);
|
|
1021
|
-
if (code === 48) {
|
|
1022
|
-
code = body.charCodeAt(++position);
|
|
1023
|
-
if (isDigit(code)) throw syntaxError(lexer.source, position, `Invalid number, unexpected digit after 0: ${printCodePointAt(lexer, position)}.`);
|
|
1024
|
-
} else {
|
|
1025
|
-
position = readDigits(lexer, position, code);
|
|
1026
|
-
code = body.charCodeAt(position);
|
|
1027
|
-
}
|
|
1028
|
-
if (code === 46) {
|
|
1029
|
-
isFloat = true;
|
|
1030
|
-
code = body.charCodeAt(++position);
|
|
1031
|
-
position = readDigits(lexer, position, code);
|
|
1032
|
-
code = body.charCodeAt(position);
|
|
1033
|
-
}
|
|
1034
|
-
if (code === 69 || code === 101) {
|
|
1035
|
-
isFloat = true;
|
|
1036
|
-
code = body.charCodeAt(++position);
|
|
1037
|
-
if (code === 43 || code === 45) code = body.charCodeAt(++position);
|
|
1038
|
-
position = readDigits(lexer, position, code);
|
|
1039
|
-
code = body.charCodeAt(position);
|
|
1040
|
-
}
|
|
1041
|
-
if (code === 46 || isNameStart(code)) throw syntaxError(lexer.source, position, `Invalid number, expected digit but got: ${printCodePointAt(lexer, position)}.`);
|
|
1042
|
-
return createToken(lexer, isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, body.slice(start, position));
|
|
1043
|
-
}
|
|
1044
|
-
/**
|
|
1045
|
-
* Returns the new position in the source after reading one or more digits.
|
|
1046
|
-
*/
|
|
1047
|
-
function readDigits(lexer, start, firstCode) {
|
|
1048
|
-
if (!isDigit(firstCode)) throw syntaxError(lexer.source, start, `Invalid number, expected digit but got: ${printCodePointAt(lexer, start)}.`);
|
|
1049
|
-
const body = lexer.source.body;
|
|
1050
|
-
let position = start + 1;
|
|
1051
|
-
while (isDigit(body.charCodeAt(position))) ++position;
|
|
1052
|
-
return position;
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Reads a single-quote string token from the source file.
|
|
1056
|
-
*
|
|
1057
|
-
* ```
|
|
1058
|
-
* StringValue ::
|
|
1059
|
-
* - `""` [lookahead != `"`]
|
|
1060
|
-
* - `"` StringCharacter+ `"`
|
|
1061
|
-
*
|
|
1062
|
-
* StringCharacter ::
|
|
1063
|
-
* - SourceCharacter but not `"` or `\` or LineTerminator
|
|
1064
|
-
* - `\u` EscapedUnicode
|
|
1065
|
-
* - `\` EscapedCharacter
|
|
1066
|
-
*
|
|
1067
|
-
* EscapedUnicode ::
|
|
1068
|
-
* - `{` HexDigit+ `}`
|
|
1069
|
-
* - HexDigit HexDigit HexDigit HexDigit
|
|
1070
|
-
*
|
|
1071
|
-
* EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t`
|
|
1072
|
-
* ```
|
|
1073
|
-
*/
|
|
1074
|
-
function readString(lexer, start) {
|
|
1075
|
-
const body = lexer.source.body;
|
|
1076
|
-
const bodyLength = body.length;
|
|
1077
|
-
let position = start + 1;
|
|
1078
|
-
let chunkStart = position;
|
|
1079
|
-
let value = "";
|
|
1080
|
-
while (position < bodyLength) {
|
|
1081
|
-
const code = body.charCodeAt(position);
|
|
1082
|
-
if (code === 34) {
|
|
1083
|
-
value += body.slice(chunkStart, position);
|
|
1084
|
-
return createToken(lexer, TokenKind.STRING, start, position + 1, value);
|
|
1085
|
-
}
|
|
1086
|
-
if (code === 92) {
|
|
1087
|
-
value += body.slice(chunkStart, position);
|
|
1088
|
-
const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
|
|
1089
|
-
value += escape.value;
|
|
1090
|
-
position += escape.size;
|
|
1091
|
-
chunkStart = position;
|
|
1092
|
-
continue;
|
|
1093
|
-
}
|
|
1094
|
-
if (code === 10 || code === 13) break;
|
|
1095
|
-
if (isUnicodeScalarValue(code)) ++position;
|
|
1096
|
-
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
1097
|
-
else throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
|
|
1098
|
-
}
|
|
1099
|
-
throw syntaxError(lexer.source, position, "Unterminated string.");
|
|
1100
|
-
}
|
|
1101
|
-
function readEscapedUnicodeVariableWidth(lexer, position) {
|
|
1102
|
-
const body = lexer.source.body;
|
|
1103
|
-
let point = 0;
|
|
1104
|
-
let size = 3;
|
|
1105
|
-
while (size < 12) {
|
|
1106
|
-
const code = body.charCodeAt(position + size++);
|
|
1107
|
-
if (code === 125) {
|
|
1108
|
-
if (size < 5 || !isUnicodeScalarValue(point)) break;
|
|
1109
|
-
return {
|
|
1110
|
-
value: String.fromCodePoint(point),
|
|
1111
|
-
size
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
point = point << 4 | readHexDigit(code);
|
|
1115
|
-
if (point < 0) break;
|
|
1116
|
-
}
|
|
1117
|
-
throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + size)}".`);
|
|
1118
|
-
}
|
|
1119
|
-
function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
1120
|
-
const body = lexer.source.body;
|
|
1121
|
-
const code = read16BitHexCode(body, position + 2);
|
|
1122
|
-
if (isUnicodeScalarValue(code)) return {
|
|
1123
|
-
value: String.fromCodePoint(code),
|
|
1124
|
-
size: 6
|
|
1125
|
-
};
|
|
1126
|
-
if (isLeadingSurrogate(code)) {
|
|
1127
|
-
if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
|
|
1128
|
-
const trailingCode = read16BitHexCode(body, position + 8);
|
|
1129
|
-
if (isTrailingSurrogate(trailingCode)) return {
|
|
1130
|
-
value: String.fromCodePoint(code, trailingCode),
|
|
1131
|
-
size: 12
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
throw syntaxError(lexer.source, position, `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`);
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
* Reads four hexadecimal characters and returns the positive integer that 16bit
|
|
1139
|
-
* hexadecimal string represents. For example, "000f" will return 15, and "dead"
|
|
1140
|
-
* will return 57005.
|
|
1141
|
-
*
|
|
1142
|
-
* Returns a negative number if any char was not a valid hexadecimal digit.
|
|
1143
|
-
*/
|
|
1144
|
-
function read16BitHexCode(body, position) {
|
|
1145
|
-
return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Reads a hexadecimal character and returns its positive integer value (0-15).
|
|
1149
|
-
*
|
|
1150
|
-
* '0' becomes 0, '9' becomes 9
|
|
1151
|
-
* 'A' becomes 10, 'F' becomes 15
|
|
1152
|
-
* 'a' becomes 10, 'f' becomes 15
|
|
1153
|
-
*
|
|
1154
|
-
* Returns -1 if the provided character code was not a valid hexadecimal digit.
|
|
1155
|
-
*
|
|
1156
|
-
* HexDigit :: one of
|
|
1157
|
-
* - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
|
|
1158
|
-
* - `A` `B` `C` `D` `E` `F`
|
|
1159
|
-
* - `a` `b` `c` `d` `e` `f`
|
|
1160
|
-
*/
|
|
1161
|
-
function readHexDigit(code) {
|
|
1162
|
-
return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* | Escaped Character | Code Point | Character Name |
|
|
1166
|
-
* | ----------------- | ---------- | ---------------------------- |
|
|
1167
|
-
* | `"` | U+0022 | double quote |
|
|
1168
|
-
* | `\` | U+005C | reverse solidus (back slash) |
|
|
1169
|
-
* | `/` | U+002F | solidus (forward slash) |
|
|
1170
|
-
* | `b` | U+0008 | backspace |
|
|
1171
|
-
* | `f` | U+000C | form feed |
|
|
1172
|
-
* | `n` | U+000A | line feed (new line) |
|
|
1173
|
-
* | `r` | U+000D | carriage return |
|
|
1174
|
-
* | `t` | U+0009 | horizontal tab |
|
|
1175
|
-
*/
|
|
1176
|
-
function readEscapedCharacter(lexer, position) {
|
|
1177
|
-
const body = lexer.source.body;
|
|
1178
|
-
switch (body.charCodeAt(position + 1)) {
|
|
1179
|
-
case 34: return {
|
|
1180
|
-
value: "\"",
|
|
1181
|
-
size: 2
|
|
1182
|
-
};
|
|
1183
|
-
case 92: return {
|
|
1184
|
-
value: "\\",
|
|
1185
|
-
size: 2
|
|
1186
|
-
};
|
|
1187
|
-
case 47: return {
|
|
1188
|
-
value: "/",
|
|
1189
|
-
size: 2
|
|
1190
|
-
};
|
|
1191
|
-
case 98: return {
|
|
1192
|
-
value: "\b",
|
|
1193
|
-
size: 2
|
|
1194
|
-
};
|
|
1195
|
-
case 102: return {
|
|
1196
|
-
value: "\f",
|
|
1197
|
-
size: 2
|
|
1198
|
-
};
|
|
1199
|
-
case 110: return {
|
|
1200
|
-
value: "\n",
|
|
1201
|
-
size: 2
|
|
1202
|
-
};
|
|
1203
|
-
case 114: return {
|
|
1204
|
-
value: "\r",
|
|
1205
|
-
size: 2
|
|
1206
|
-
};
|
|
1207
|
-
case 116: return {
|
|
1208
|
-
value: " ",
|
|
1209
|
-
size: 2
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
throw syntaxError(lexer.source, position, `Invalid character escape sequence: "${body.slice(position, position + 2)}".`);
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Reads a block string token from the source file.
|
|
1216
|
-
*
|
|
1217
|
-
* ```
|
|
1218
|
-
* StringValue ::
|
|
1219
|
-
* - `"""` BlockStringCharacter* `"""`
|
|
1220
|
-
*
|
|
1221
|
-
* BlockStringCharacter ::
|
|
1222
|
-
* - SourceCharacter but not `"""` or `\"""`
|
|
1223
|
-
* - `\"""`
|
|
1224
|
-
* ```
|
|
1225
|
-
*/
|
|
1226
|
-
function readBlockString(lexer, start) {
|
|
1227
|
-
const body = lexer.source.body;
|
|
1228
|
-
const bodyLength = body.length;
|
|
1229
|
-
let lineStart = lexer.lineStart;
|
|
1230
|
-
let position = start + 3;
|
|
1231
|
-
let chunkStart = position;
|
|
1232
|
-
let currentLine = "";
|
|
1233
|
-
const blockLines = [];
|
|
1234
|
-
while (position < bodyLength) {
|
|
1235
|
-
const code = body.charCodeAt(position);
|
|
1236
|
-
if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
|
|
1237
|
-
currentLine += body.slice(chunkStart, position);
|
|
1238
|
-
blockLines.push(currentLine);
|
|
1239
|
-
const token = createToken(lexer, TokenKind.BLOCK_STRING, start, position + 3, dedentBlockStringLines(blockLines).join("\n"));
|
|
1240
|
-
lexer.line += blockLines.length - 1;
|
|
1241
|
-
lexer.lineStart = lineStart;
|
|
1242
|
-
return token;
|
|
1243
|
-
}
|
|
1244
|
-
if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
|
|
1245
|
-
currentLine += body.slice(chunkStart, position);
|
|
1246
|
-
chunkStart = position + 1;
|
|
1247
|
-
position += 4;
|
|
1248
|
-
continue;
|
|
1249
|
-
}
|
|
1250
|
-
if (code === 10 || code === 13) {
|
|
1251
|
-
currentLine += body.slice(chunkStart, position);
|
|
1252
|
-
blockLines.push(currentLine);
|
|
1253
|
-
if (code === 13 && body.charCodeAt(position + 1) === 10) position += 2;
|
|
1254
|
-
else ++position;
|
|
1255
|
-
currentLine = "";
|
|
1256
|
-
chunkStart = position;
|
|
1257
|
-
lineStart = position;
|
|
1258
|
-
continue;
|
|
1259
|
-
}
|
|
1260
|
-
if (isUnicodeScalarValue(code)) ++position;
|
|
1261
|
-
else if (isSupplementaryCodePoint(body, position)) position += 2;
|
|
1262
|
-
else throw syntaxError(lexer.source, position, `Invalid character within String: ${printCodePointAt(lexer, position)}.`);
|
|
1263
|
-
}
|
|
1264
|
-
throw syntaxError(lexer.source, position, "Unterminated string.");
|
|
1265
|
-
}
|
|
1266
|
-
/**
|
|
1267
|
-
* Reads an alphanumeric + underscore name from the source.
|
|
1268
|
-
*
|
|
1269
|
-
* ```
|
|
1270
|
-
* Name ::
|
|
1271
|
-
* - NameStart NameContinue* [lookahead != NameContinue]
|
|
1272
|
-
* ```
|
|
1273
|
-
*
|
|
1274
|
-
* @internal
|
|
1275
|
-
*/
|
|
1276
|
-
function readName(lexer, start) {
|
|
1277
|
-
const body = lexer.source.body;
|
|
1278
|
-
const bodyLength = body.length;
|
|
1279
|
-
let position = start + 1;
|
|
1280
|
-
while (position < bodyLength) if (isNameContinue(body.charCodeAt(position))) ++position;
|
|
1281
|
-
else break;
|
|
1282
|
-
return createToken(lexer, TokenKind.NAME, start, position, body.slice(start, position));
|
|
1283
|
-
}
|
|
1284
|
-
//#endregion
|
|
1285
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/inspect.mjs
|
|
1286
|
-
const MAX_ARRAY_LENGTH = 10;
|
|
1287
|
-
const MAX_RECURSIVE_DEPTH = 2;
|
|
1288
|
-
/**
|
|
1289
|
-
* Used to print values in error messages.
|
|
1290
|
-
*/
|
|
1291
|
-
function inspect(value) {
|
|
1292
|
-
return formatValue(value, []);
|
|
1293
|
-
}
|
|
1294
|
-
function formatValue(value, seenValues) {
|
|
1295
|
-
switch (typeof value) {
|
|
1296
|
-
case "string": return JSON.stringify(value);
|
|
1297
|
-
case "function": return value.name ? `[function ${value.name}]` : "[function]";
|
|
1298
|
-
case "object": return formatObjectValue(value, seenValues);
|
|
1299
|
-
default: return String(value);
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
function formatObjectValue(value, previouslySeenValues) {
|
|
1303
|
-
if (value === null) return "null";
|
|
1304
|
-
if (previouslySeenValues.includes(value)) return "[Circular]";
|
|
1305
|
-
const seenValues = [...previouslySeenValues, value];
|
|
1306
|
-
if (isJSONable(value)) {
|
|
1307
|
-
const jsonValue = value.toJSON();
|
|
1308
|
-
if (jsonValue !== value) return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
|
|
1309
|
-
} else if (Array.isArray(value)) return formatArray(value, seenValues);
|
|
1310
|
-
return formatObject(value, seenValues);
|
|
1311
|
-
}
|
|
1312
|
-
function isJSONable(value) {
|
|
1313
|
-
return typeof value.toJSON === "function";
|
|
1314
|
-
}
|
|
1315
|
-
function formatObject(object, seenValues) {
|
|
1316
|
-
const entries = Object.entries(object);
|
|
1317
|
-
if (entries.length === 0) return "{}";
|
|
1318
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[" + getObjectTag(object) + "]";
|
|
1319
|
-
return "{ " + entries.map(([key, value]) => key + ": " + formatValue(value, seenValues)).join(", ") + " }";
|
|
1320
|
-
}
|
|
1321
|
-
function formatArray(array, seenValues) {
|
|
1322
|
-
if (array.length === 0) return "[]";
|
|
1323
|
-
if (seenValues.length > MAX_RECURSIVE_DEPTH) return "[Array]";
|
|
1324
|
-
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
1325
|
-
const remaining = array.length - len;
|
|
1326
|
-
const items = [];
|
|
1327
|
-
for (let i = 0; i < len; ++i) items.push(formatValue(array[i], seenValues));
|
|
1328
|
-
if (remaining === 1) items.push("... 1 more item");
|
|
1329
|
-
else if (remaining > 1) items.push(`... ${remaining} more items`);
|
|
1330
|
-
return "[" + items.join(", ") + "]";
|
|
1331
|
-
}
|
|
1332
|
-
function getObjectTag(object) {
|
|
1333
|
-
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
1334
|
-
if (tag === "Object" && typeof object.constructor === "function") {
|
|
1335
|
-
const name = object.constructor.name;
|
|
1336
|
-
if (typeof name === "string" && name !== "") return name;
|
|
1337
|
-
}
|
|
1338
|
-
return tag;
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* A replacement for instanceof which includes an error warning when multi-realm
|
|
1342
|
-
* constructors are detected.
|
|
1343
|
-
* See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
|
|
1344
|
-
* See: https://webpack.js.org/guides/production/
|
|
1345
|
-
*/
|
|
1346
|
-
const instanceOf = globalThis.process && true ? function instanceOf(value, constructor) {
|
|
1347
|
-
return value instanceof constructor;
|
|
1348
|
-
} : function instanceOf(value, constructor) {
|
|
1349
|
-
if (value instanceof constructor) return true;
|
|
1350
|
-
if (typeof value === "object" && value !== null) {
|
|
1351
|
-
var _value$constructor;
|
|
1352
|
-
const className = constructor.prototype[Symbol.toStringTag];
|
|
1353
|
-
if (className === (Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name)) {
|
|
1354
|
-
const stringifiedValue = inspect(value);
|
|
1355
|
-
throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
|
|
1356
|
-
|
|
1357
|
-
Ensure that there is only one instance of "graphql" in the node_modules
|
|
1358
|
-
directory. If different versions of "graphql" are the dependencies of other
|
|
1359
|
-
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
1360
|
-
|
|
1361
|
-
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
1362
|
-
|
|
1363
|
-
Duplicate "graphql" modules cannot be used at the same time since different
|
|
1364
|
-
versions may have different capabilities and behavior. The data from one
|
|
1365
|
-
version used in the function from another could produce confusing and
|
|
1366
|
-
spurious results.`);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
return false;
|
|
1370
|
-
};
|
|
1371
|
-
//#endregion
|
|
1372
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/source.mjs
|
|
1373
|
-
/**
|
|
1374
|
-
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
1375
|
-
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
1376
|
-
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
1377
|
-
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
1378
|
-
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
1379
|
-
*/
|
|
1380
|
-
var Source = class {
|
|
1381
|
-
constructor(body, name = "GraphQL request", locationOffset = {
|
|
1382
|
-
line: 1,
|
|
1383
|
-
column: 1
|
|
1384
|
-
}) {
|
|
1385
|
-
typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
|
|
1386
|
-
this.body = body;
|
|
1387
|
-
this.name = name;
|
|
1388
|
-
this.locationOffset = locationOffset;
|
|
1389
|
-
this.locationOffset.line > 0 || devAssert(false, "line in locationOffset is 1-indexed and must be positive.");
|
|
1390
|
-
this.locationOffset.column > 0 || devAssert(false, "column in locationOffset is 1-indexed and must be positive.");
|
|
1391
|
-
}
|
|
1392
|
-
get [Symbol.toStringTag]() {
|
|
1393
|
-
return "Source";
|
|
1394
|
-
}
|
|
1395
|
-
};
|
|
1396
|
-
/**
|
|
1397
|
-
* Test if the given value is a Source object.
|
|
1398
|
-
*
|
|
1399
|
-
* @internal
|
|
1400
|
-
*/
|
|
1401
|
-
function isSource(source) {
|
|
1402
|
-
return instanceOf(source, Source);
|
|
1403
|
-
}
|
|
1404
|
-
//#endregion
|
|
1405
|
-
//#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/parser.mjs
|
|
1406
|
-
/**
|
|
1407
|
-
* Configuration options to control parser behavior
|
|
1408
|
-
*/
|
|
1409
|
-
/**
|
|
1410
|
-
* Given a GraphQL source, parses it into a Document.
|
|
1411
|
-
* Throws GraphQLError if a syntax error is encountered.
|
|
1412
|
-
*/
|
|
1413
|
-
function parse(source, options) {
|
|
1414
|
-
const parser = new Parser(source, options);
|
|
1415
|
-
const document = parser.parseDocument();
|
|
1416
|
-
Object.defineProperty(document, "tokenCount", {
|
|
1417
|
-
enumerable: false,
|
|
1418
|
-
value: parser.tokenCount
|
|
1419
|
-
});
|
|
1420
|
-
return document;
|
|
1421
|
-
}
|
|
1422
|
-
/**
|
|
1423
|
-
* This class is exported only to assist people in implementing their own parsers
|
|
1424
|
-
* without duplicating too much code and should be used only as last resort for cases
|
|
1425
|
-
* such as experimental syntax or if certain features could not be contributed upstream.
|
|
1426
|
-
*
|
|
1427
|
-
* It is still part of the internal API and is versioned, so any changes to it are never
|
|
1428
|
-
* considered breaking changes. If you still need to support multiple versions of the
|
|
1429
|
-
* library, please use the `versionInfo` variable for version detection.
|
|
1430
|
-
*
|
|
1431
|
-
* @internal
|
|
1432
|
-
*/
|
|
1433
|
-
var Parser = class {
|
|
1434
|
-
constructor(source, options = {}) {
|
|
1435
|
-
const { lexer, ..._options } = options;
|
|
1436
|
-
if (lexer) this._lexer = lexer;
|
|
1437
|
-
else this._lexer = new Lexer(isSource(source) ? source : new Source(source));
|
|
1438
|
-
this._options = _options;
|
|
1439
|
-
this._tokenCounter = 0;
|
|
1440
|
-
}
|
|
1441
|
-
get tokenCount() {
|
|
1442
|
-
return this._tokenCounter;
|
|
1443
|
-
}
|
|
1444
|
-
/**
|
|
1445
|
-
* Converts a name lex token into a name parse node.
|
|
1446
|
-
*/
|
|
1447
|
-
parseName() {
|
|
1448
|
-
const token = this.expectToken(TokenKind.NAME);
|
|
1449
|
-
return this.node(token, {
|
|
1450
|
-
kind: Kind.NAME,
|
|
1451
|
-
value: token.value
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
/**
|
|
1455
|
-
* Document : Definition+
|
|
1456
|
-
*/
|
|
1457
|
-
parseDocument() {
|
|
1458
|
-
return this.node(this._lexer.token, {
|
|
1459
|
-
kind: Kind.DOCUMENT,
|
|
1460
|
-
definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF)
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
/**
|
|
1464
|
-
* Definition :
|
|
1465
|
-
* - ExecutableDefinition
|
|
1466
|
-
* - TypeSystemDefinition
|
|
1467
|
-
* - TypeSystemExtension
|
|
1468
|
-
*
|
|
1469
|
-
* ExecutableDefinition :
|
|
1470
|
-
* - OperationDefinition
|
|
1471
|
-
* - FragmentDefinition
|
|
1472
|
-
*
|
|
1473
|
-
* TypeSystemDefinition :
|
|
1474
|
-
* - SchemaDefinition
|
|
1475
|
-
* - TypeDefinition
|
|
1476
|
-
* - DirectiveDefinition
|
|
1477
|
-
*
|
|
1478
|
-
* TypeDefinition :
|
|
1479
|
-
* - ScalarTypeDefinition
|
|
1480
|
-
* - ObjectTypeDefinition
|
|
1481
|
-
* - InterfaceTypeDefinition
|
|
1482
|
-
* - UnionTypeDefinition
|
|
1483
|
-
* - EnumTypeDefinition
|
|
1484
|
-
* - InputObjectTypeDefinition
|
|
1485
|
-
*/
|
|
1486
|
-
parseDefinition() {
|
|
1487
|
-
if (this.peek(TokenKind.BRACE_L)) return this.parseOperationDefinition();
|
|
1488
|
-
const hasDescription = this.peekDescription();
|
|
1489
|
-
const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
|
|
1490
|
-
if (hasDescription && keywordToken.kind === TokenKind.BRACE_L) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries.");
|
|
1491
|
-
if (keywordToken.kind === TokenKind.NAME) {
|
|
1492
|
-
switch (keywordToken.value) {
|
|
1493
|
-
case "schema": return this.parseSchemaDefinition();
|
|
1494
|
-
case "scalar": return this.parseScalarTypeDefinition();
|
|
1495
|
-
case "type": return this.parseObjectTypeDefinition();
|
|
1496
|
-
case "interface": return this.parseInterfaceTypeDefinition();
|
|
1497
|
-
case "union": return this.parseUnionTypeDefinition();
|
|
1498
|
-
case "enum": return this.parseEnumTypeDefinition();
|
|
1499
|
-
case "input": return this.parseInputObjectTypeDefinition();
|
|
1500
|
-
case "directive": return this.parseDirectiveDefinition();
|
|
1501
|
-
}
|
|
1502
|
-
switch (keywordToken.value) {
|
|
1503
|
-
case "query":
|
|
1504
|
-
case "mutation":
|
|
1505
|
-
case "subscription": return this.parseOperationDefinition();
|
|
1506
|
-
case "fragment": return this.parseFragmentDefinition();
|
|
1507
|
-
}
|
|
1508
|
-
if (hasDescription) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
|
|
1509
|
-
switch (keywordToken.value) {
|
|
1510
|
-
case "extend": return this.parseTypeSystemExtension();
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
throw this.unexpected(keywordToken);
|
|
1514
|
-
}
|
|
1515
|
-
/**
|
|
1516
|
-
* OperationDefinition :
|
|
1517
|
-
* - SelectionSet
|
|
1518
|
-
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
1519
|
-
*/
|
|
1520
|
-
parseOperationDefinition() {
|
|
1521
|
-
const start = this._lexer.token;
|
|
1522
|
-
if (this.peek(TokenKind.BRACE_L)) return this.node(start, {
|
|
1523
|
-
kind: Kind.OPERATION_DEFINITION,
|
|
1524
|
-
operation: OperationTypeNode.QUERY,
|
|
1525
|
-
description: void 0,
|
|
1526
|
-
name: void 0,
|
|
1527
|
-
variableDefinitions: [],
|
|
1528
|
-
directives: [],
|
|
1529
|
-
selectionSet: this.parseSelectionSet()
|
|
1530
|
-
});
|
|
1531
|
-
const description = this.parseDescription();
|
|
1532
|
-
const operation = this.parseOperationType();
|
|
1533
|
-
let name;
|
|
1534
|
-
if (this.peek(TokenKind.NAME)) name = this.parseName();
|
|
1535
|
-
return this.node(start, {
|
|
1536
|
-
kind: Kind.OPERATION_DEFINITION,
|
|
1537
|
-
operation,
|
|
1538
|
-
description,
|
|
1539
|
-
name,
|
|
1540
|
-
variableDefinitions: this.parseVariableDefinitions(),
|
|
1541
|
-
directives: this.parseDirectives(false),
|
|
1542
|
-
selectionSet: this.parseSelectionSet()
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
/**
|
|
1546
|
-
* OperationType : one of query mutation subscription
|
|
1547
|
-
*/
|
|
1548
|
-
parseOperationType() {
|
|
1549
|
-
const operationToken = this.expectToken(TokenKind.NAME);
|
|
1550
|
-
switch (operationToken.value) {
|
|
1551
|
-
case "query": return OperationTypeNode.QUERY;
|
|
1552
|
-
case "mutation": return OperationTypeNode.MUTATION;
|
|
1553
|
-
case "subscription": return OperationTypeNode.SUBSCRIPTION;
|
|
1554
|
-
}
|
|
1555
|
-
throw this.unexpected(operationToken);
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* VariableDefinitions : ( VariableDefinition+ )
|
|
1559
|
-
*/
|
|
1560
|
-
parseVariableDefinitions() {
|
|
1561
|
-
return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);
|
|
1562
|
-
}
|
|
1563
|
-
/**
|
|
1564
|
-
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
1565
|
-
*/
|
|
1566
|
-
parseVariableDefinition() {
|
|
1567
|
-
return this.node(this._lexer.token, {
|
|
1568
|
-
kind: Kind.VARIABLE_DEFINITION,
|
|
1569
|
-
description: this.parseDescription(),
|
|
1570
|
-
variable: this.parseVariable(),
|
|
1571
|
-
type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
|
|
1572
|
-
defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
|
|
1573
|
-
directives: this.parseConstDirectives()
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
/**
|
|
1577
|
-
* Variable : $ Name
|
|
1578
|
-
*/
|
|
1579
|
-
parseVariable() {
|
|
1580
|
-
const start = this._lexer.token;
|
|
1581
|
-
this.expectToken(TokenKind.DOLLAR);
|
|
1582
|
-
return this.node(start, {
|
|
1583
|
-
kind: Kind.VARIABLE,
|
|
1584
|
-
name: this.parseName()
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
|
-
* ```
|
|
1589
|
-
* SelectionSet : { Selection+ }
|
|
1590
|
-
* ```
|
|
1591
|
-
*/
|
|
1592
|
-
parseSelectionSet() {
|
|
1593
|
-
return this.node(this._lexer.token, {
|
|
1594
|
-
kind: Kind.SELECTION_SET,
|
|
1595
|
-
selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R)
|
|
1596
|
-
});
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* Selection :
|
|
1600
|
-
* - Field
|
|
1601
|
-
* - FragmentSpread
|
|
1602
|
-
* - InlineFragment
|
|
1603
|
-
*/
|
|
1604
|
-
parseSelection() {
|
|
1605
|
-
return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
1609
|
-
*
|
|
1610
|
-
* Alias : Name :
|
|
1611
|
-
*/
|
|
1612
|
-
parseField() {
|
|
1613
|
-
const start = this._lexer.token;
|
|
1614
|
-
const nameOrAlias = this.parseName();
|
|
1615
|
-
let alias;
|
|
1616
|
-
let name;
|
|
1617
|
-
if (this.expectOptionalToken(TokenKind.COLON)) {
|
|
1618
|
-
alias = nameOrAlias;
|
|
1619
|
-
name = this.parseName();
|
|
1620
|
-
} else name = nameOrAlias;
|
|
1621
|
-
return this.node(start, {
|
|
1622
|
-
kind: Kind.FIELD,
|
|
1623
|
-
alias,
|
|
1624
|
-
name,
|
|
1625
|
-
arguments: this.parseArguments(false),
|
|
1626
|
-
directives: this.parseDirectives(false),
|
|
1627
|
-
selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
/**
|
|
1631
|
-
* Arguments[Const] : ( Argument[?Const]+ )
|
|
1632
|
-
*/
|
|
1633
|
-
parseArguments(isConst) {
|
|
1634
|
-
const item = isConst ? this.parseConstArgument : this.parseArgument;
|
|
1635
|
-
return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* Argument[Const] : Name : Value[?Const]
|
|
1639
|
-
*/
|
|
1640
|
-
parseArgument(isConst = false) {
|
|
1641
|
-
const start = this._lexer.token;
|
|
1642
|
-
const name = this.parseName();
|
|
1643
|
-
this.expectToken(TokenKind.COLON);
|
|
1644
|
-
return this.node(start, {
|
|
1645
|
-
kind: Kind.ARGUMENT,
|
|
1646
|
-
name,
|
|
1647
|
-
value: this.parseValueLiteral(isConst)
|
|
1648
|
-
});
|
|
1649
|
-
}
|
|
1650
|
-
parseConstArgument() {
|
|
1651
|
-
return this.parseArgument(true);
|
|
1652
|
-
}
|
|
1653
|
-
/**
|
|
1654
|
-
* Corresponds to both FragmentSpread and InlineFragment in the spec.
|
|
1655
|
-
*
|
|
1656
|
-
* FragmentSpread : ... FragmentName Directives?
|
|
1657
|
-
*
|
|
1658
|
-
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
1659
|
-
*/
|
|
1660
|
-
parseFragment() {
|
|
1661
|
-
const start = this._lexer.token;
|
|
1662
|
-
this.expectToken(TokenKind.SPREAD);
|
|
1663
|
-
const hasTypeCondition = this.expectOptionalKeyword("on");
|
|
1664
|
-
if (!hasTypeCondition && this.peek(TokenKind.NAME)) return this.node(start, {
|
|
1665
|
-
kind: Kind.FRAGMENT_SPREAD,
|
|
1666
|
-
name: this.parseFragmentName(),
|
|
1667
|
-
directives: this.parseDirectives(false)
|
|
1668
|
-
});
|
|
1669
|
-
return this.node(start, {
|
|
1670
|
-
kind: Kind.INLINE_FRAGMENT,
|
|
1671
|
-
typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
|
|
1672
|
-
directives: this.parseDirectives(false),
|
|
1673
|
-
selectionSet: this.parseSelectionSet()
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* FragmentDefinition :
|
|
1678
|
-
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
1679
|
-
*
|
|
1680
|
-
* TypeCondition : NamedType
|
|
1681
|
-
*/
|
|
1682
|
-
parseFragmentDefinition() {
|
|
1683
|
-
const start = this._lexer.token;
|
|
1684
|
-
const description = this.parseDescription();
|
|
1685
|
-
this.expectKeyword("fragment");
|
|
1686
|
-
if (this._options.allowLegacyFragmentVariables === true) return this.node(start, {
|
|
1687
|
-
kind: Kind.FRAGMENT_DEFINITION,
|
|
1688
|
-
description,
|
|
1689
|
-
name: this.parseFragmentName(),
|
|
1690
|
-
variableDefinitions: this.parseVariableDefinitions(),
|
|
1691
|
-
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
1692
|
-
directives: this.parseDirectives(false),
|
|
1693
|
-
selectionSet: this.parseSelectionSet()
|
|
1694
|
-
});
|
|
1695
|
-
return this.node(start, {
|
|
1696
|
-
kind: Kind.FRAGMENT_DEFINITION,
|
|
1697
|
-
description,
|
|
1698
|
-
name: this.parseFragmentName(),
|
|
1699
|
-
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
1700
|
-
directives: this.parseDirectives(false),
|
|
1701
|
-
selectionSet: this.parseSelectionSet()
|
|
1702
|
-
});
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* FragmentName : Name but not `on`
|
|
1706
|
-
*/
|
|
1707
|
-
parseFragmentName() {
|
|
1708
|
-
if (this._lexer.token.value === "on") throw this.unexpected();
|
|
1709
|
-
return this.parseName();
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Value[Const] :
|
|
1713
|
-
* - [~Const] Variable
|
|
1714
|
-
* - IntValue
|
|
1715
|
-
* - FloatValue
|
|
1716
|
-
* - StringValue
|
|
1717
|
-
* - BooleanValue
|
|
1718
|
-
* - NullValue
|
|
1719
|
-
* - EnumValue
|
|
1720
|
-
* - ListValue[?Const]
|
|
1721
|
-
* - ObjectValue[?Const]
|
|
1722
|
-
*
|
|
1723
|
-
* BooleanValue : one of `true` `false`
|
|
1724
|
-
*
|
|
1725
|
-
* NullValue : `null`
|
|
1726
|
-
*
|
|
1727
|
-
* EnumValue : Name but not `true`, `false` or `null`
|
|
1728
|
-
*/
|
|
1729
|
-
parseValueLiteral(isConst) {
|
|
1730
|
-
const token = this._lexer.token;
|
|
1731
|
-
switch (token.kind) {
|
|
1732
|
-
case TokenKind.BRACKET_L: return this.parseList(isConst);
|
|
1733
|
-
case TokenKind.BRACE_L: return this.parseObject(isConst);
|
|
1734
|
-
case TokenKind.INT:
|
|
1735
|
-
this.advanceLexer();
|
|
1736
|
-
return this.node(token, {
|
|
1737
|
-
kind: Kind.INT,
|
|
1738
|
-
value: token.value
|
|
1739
|
-
});
|
|
1740
|
-
case TokenKind.FLOAT:
|
|
1741
|
-
this.advanceLexer();
|
|
1742
|
-
return this.node(token, {
|
|
1743
|
-
kind: Kind.FLOAT,
|
|
1744
|
-
value: token.value
|
|
1745
|
-
});
|
|
1746
|
-
case TokenKind.STRING:
|
|
1747
|
-
case TokenKind.BLOCK_STRING: return this.parseStringLiteral();
|
|
1748
|
-
case TokenKind.NAME:
|
|
1749
|
-
this.advanceLexer();
|
|
1750
|
-
switch (token.value) {
|
|
1751
|
-
case "true": return this.node(token, {
|
|
1752
|
-
kind: Kind.BOOLEAN,
|
|
1753
|
-
value: true
|
|
1754
|
-
});
|
|
1755
|
-
case "false": return this.node(token, {
|
|
1756
|
-
kind: Kind.BOOLEAN,
|
|
1757
|
-
value: false
|
|
1758
|
-
});
|
|
1759
|
-
case "null": return this.node(token, { kind: Kind.NULL });
|
|
1760
|
-
default: return this.node(token, {
|
|
1761
|
-
kind: Kind.ENUM,
|
|
1762
|
-
value: token.value
|
|
1763
|
-
});
|
|
1764
|
-
}
|
|
1765
|
-
case TokenKind.DOLLAR:
|
|
1766
|
-
if (isConst) {
|
|
1767
|
-
this.expectToken(TokenKind.DOLLAR);
|
|
1768
|
-
if (this._lexer.token.kind === TokenKind.NAME) {
|
|
1769
|
-
const varName = this._lexer.token.value;
|
|
1770
|
-
throw syntaxError(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`);
|
|
1771
|
-
} else throw this.unexpected(token);
|
|
1772
|
-
}
|
|
1773
|
-
return this.parseVariable();
|
|
1774
|
-
default: throw this.unexpected();
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
parseConstValueLiteral() {
|
|
1778
|
-
return this.parseValueLiteral(true);
|
|
1779
|
-
}
|
|
1780
|
-
parseStringLiteral() {
|
|
1781
|
-
const token = this._lexer.token;
|
|
1782
|
-
this.advanceLexer();
|
|
1783
|
-
return this.node(token, {
|
|
1784
|
-
kind: Kind.STRING,
|
|
1785
|
-
value: token.value,
|
|
1786
|
-
block: token.kind === TokenKind.BLOCK_STRING
|
|
1787
|
-
});
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* ListValue[Const] :
|
|
1791
|
-
* - [ ]
|
|
1792
|
-
* - [ Value[?Const]+ ]
|
|
1793
|
-
*/
|
|
1794
|
-
parseList(isConst) {
|
|
1795
|
-
const item = () => this.parseValueLiteral(isConst);
|
|
1796
|
-
return this.node(this._lexer.token, {
|
|
1797
|
-
kind: Kind.LIST,
|
|
1798
|
-
values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
|
|
1799
|
-
});
|
|
1800
|
-
}
|
|
1801
|
-
/**
|
|
1802
|
-
* ```
|
|
1803
|
-
* ObjectValue[Const] :
|
|
1804
|
-
* - { }
|
|
1805
|
-
* - { ObjectField[?Const]+ }
|
|
1806
|
-
* ```
|
|
1807
|
-
*/
|
|
1808
|
-
parseObject(isConst) {
|
|
1809
|
-
const item = () => this.parseObjectField(isConst);
|
|
1810
|
-
return this.node(this._lexer.token, {
|
|
1811
|
-
kind: Kind.OBJECT,
|
|
1812
|
-
fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
/**
|
|
1816
|
-
* ObjectField[Const] : Name : Value[?Const]
|
|
1817
|
-
*/
|
|
1818
|
-
parseObjectField(isConst) {
|
|
1819
|
-
const start = this._lexer.token;
|
|
1820
|
-
const name = this.parseName();
|
|
1821
|
-
this.expectToken(TokenKind.COLON);
|
|
1822
|
-
return this.node(start, {
|
|
1823
|
-
kind: Kind.OBJECT_FIELD,
|
|
1824
|
-
name,
|
|
1825
|
-
value: this.parseValueLiteral(isConst)
|
|
1826
|
-
});
|
|
1827
|
-
}
|
|
1828
|
-
/**
|
|
1829
|
-
* Directives[Const] : Directive[?Const]+
|
|
1830
|
-
*/
|
|
1831
|
-
parseDirectives(isConst) {
|
|
1832
|
-
const directives = [];
|
|
1833
|
-
while (this.peek(TokenKind.AT)) directives.push(this.parseDirective(isConst));
|
|
1834
|
-
return directives;
|
|
1835
|
-
}
|
|
1836
|
-
parseConstDirectives() {
|
|
1837
|
-
return this.parseDirectives(true);
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* ```
|
|
1841
|
-
* Directive[Const] : @ Name Arguments[?Const]?
|
|
1842
|
-
* ```
|
|
1843
|
-
*/
|
|
1844
|
-
parseDirective(isConst) {
|
|
1845
|
-
const start = this._lexer.token;
|
|
1846
|
-
this.expectToken(TokenKind.AT);
|
|
1847
|
-
return this.node(start, {
|
|
1848
|
-
kind: Kind.DIRECTIVE,
|
|
1849
|
-
name: this.parseName(),
|
|
1850
|
-
arguments: this.parseArguments(isConst)
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1853
|
-
/**
|
|
1854
|
-
* Type :
|
|
1855
|
-
* - NamedType
|
|
1856
|
-
* - ListType
|
|
1857
|
-
* - NonNullType
|
|
1858
|
-
*/
|
|
1859
|
-
parseTypeReference() {
|
|
1860
|
-
const start = this._lexer.token;
|
|
1861
|
-
let type;
|
|
1862
|
-
if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
|
|
1863
|
-
const innerType = this.parseTypeReference();
|
|
1864
|
-
this.expectToken(TokenKind.BRACKET_R);
|
|
1865
|
-
type = this.node(start, {
|
|
1866
|
-
kind: Kind.LIST_TYPE,
|
|
1867
|
-
type: innerType
|
|
1868
|
-
});
|
|
1869
|
-
} else type = this.parseNamedType();
|
|
1870
|
-
if (this.expectOptionalToken(TokenKind.BANG)) return this.node(start, {
|
|
1871
|
-
kind: Kind.NON_NULL_TYPE,
|
|
1872
|
-
type
|
|
1873
|
-
});
|
|
1874
|
-
return type;
|
|
1875
|
-
}
|
|
1876
|
-
/**
|
|
1877
|
-
* NamedType : Name
|
|
1878
|
-
*/
|
|
1879
|
-
parseNamedType() {
|
|
1880
|
-
return this.node(this._lexer.token, {
|
|
1881
|
-
kind: Kind.NAMED_TYPE,
|
|
1882
|
-
name: this.parseName()
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
peekDescription() {
|
|
1886
|
-
return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
|
|
1887
|
-
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Description : StringValue
|
|
1890
|
-
*/
|
|
1891
|
-
parseDescription() {
|
|
1892
|
-
if (this.peekDescription()) return this.parseStringLiteral();
|
|
1893
|
-
}
|
|
1894
|
-
/**
|
|
1895
|
-
* ```
|
|
1896
|
-
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
1897
|
-
* ```
|
|
1898
|
-
*/
|
|
1899
|
-
parseSchemaDefinition() {
|
|
1900
|
-
const start = this._lexer.token;
|
|
1901
|
-
const description = this.parseDescription();
|
|
1902
|
-
this.expectKeyword("schema");
|
|
1903
|
-
const directives = this.parseConstDirectives();
|
|
1904
|
-
const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
|
|
1905
|
-
return this.node(start, {
|
|
1906
|
-
kind: Kind.SCHEMA_DEFINITION,
|
|
1907
|
-
description,
|
|
1908
|
-
directives,
|
|
1909
|
-
operationTypes
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* OperationTypeDefinition : OperationType : NamedType
|
|
1914
|
-
*/
|
|
1915
|
-
parseOperationTypeDefinition() {
|
|
1916
|
-
const start = this._lexer.token;
|
|
1917
|
-
const operation = this.parseOperationType();
|
|
1918
|
-
this.expectToken(TokenKind.COLON);
|
|
1919
|
-
const type = this.parseNamedType();
|
|
1920
|
-
return this.node(start, {
|
|
1921
|
-
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
1922
|
-
operation,
|
|
1923
|
-
type
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
1928
|
-
*/
|
|
1929
|
-
parseScalarTypeDefinition() {
|
|
1930
|
-
const start = this._lexer.token;
|
|
1931
|
-
const description = this.parseDescription();
|
|
1932
|
-
this.expectKeyword("scalar");
|
|
1933
|
-
const name = this.parseName();
|
|
1934
|
-
const directives = this.parseConstDirectives();
|
|
1935
|
-
return this.node(start, {
|
|
1936
|
-
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
1937
|
-
description,
|
|
1938
|
-
name,
|
|
1939
|
-
directives
|
|
1940
|
-
});
|
|
1941
|
-
}
|
|
1942
|
-
/**
|
|
1943
|
-
* ObjectTypeDefinition :
|
|
1944
|
-
* Description?
|
|
1945
|
-
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
1946
|
-
*/
|
|
1947
|
-
parseObjectTypeDefinition() {
|
|
1948
|
-
const start = this._lexer.token;
|
|
1949
|
-
const description = this.parseDescription();
|
|
1950
|
-
this.expectKeyword("type");
|
|
1951
|
-
const name = this.parseName();
|
|
1952
|
-
const interfaces = this.parseImplementsInterfaces();
|
|
1953
|
-
const directives = this.parseConstDirectives();
|
|
1954
|
-
const fields = this.parseFieldsDefinition();
|
|
1955
|
-
return this.node(start, {
|
|
1956
|
-
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
1957
|
-
description,
|
|
1958
|
-
name,
|
|
1959
|
-
interfaces,
|
|
1960
|
-
directives,
|
|
1961
|
-
fields
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
/**
|
|
1965
|
-
* ImplementsInterfaces :
|
|
1966
|
-
* - implements `&`? NamedType
|
|
1967
|
-
* - ImplementsInterfaces & NamedType
|
|
1968
|
-
*/
|
|
1969
|
-
parseImplementsInterfaces() {
|
|
1970
|
-
return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
|
|
1971
|
-
}
|
|
1972
|
-
/**
|
|
1973
|
-
* ```
|
|
1974
|
-
* FieldsDefinition : { FieldDefinition+ }
|
|
1975
|
-
* ```
|
|
1976
|
-
*/
|
|
1977
|
-
parseFieldsDefinition() {
|
|
1978
|
-
return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);
|
|
1979
|
-
}
|
|
1980
|
-
/**
|
|
1981
|
-
* FieldDefinition :
|
|
1982
|
-
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
1983
|
-
*/
|
|
1984
|
-
parseFieldDefinition() {
|
|
1985
|
-
const start = this._lexer.token;
|
|
1986
|
-
const description = this.parseDescription();
|
|
1987
|
-
const name = this.parseName();
|
|
1988
|
-
const args = this.parseArgumentDefs();
|
|
1989
|
-
this.expectToken(TokenKind.COLON);
|
|
1990
|
-
const type = this.parseTypeReference();
|
|
1991
|
-
const directives = this.parseConstDirectives();
|
|
1992
|
-
return this.node(start, {
|
|
1993
|
-
kind: Kind.FIELD_DEFINITION,
|
|
1994
|
-
description,
|
|
1995
|
-
name,
|
|
1996
|
-
arguments: args,
|
|
1997
|
-
type,
|
|
1998
|
-
directives
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
/**
|
|
2002
|
-
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
2003
|
-
*/
|
|
2004
|
-
parseArgumentDefs() {
|
|
2005
|
-
return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);
|
|
2006
|
-
}
|
|
2007
|
-
/**
|
|
2008
|
-
* InputValueDefinition :
|
|
2009
|
-
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
2010
|
-
*/
|
|
2011
|
-
parseInputValueDef() {
|
|
2012
|
-
const start = this._lexer.token;
|
|
2013
|
-
const description = this.parseDescription();
|
|
2014
|
-
const name = this.parseName();
|
|
2015
|
-
this.expectToken(TokenKind.COLON);
|
|
2016
|
-
const type = this.parseTypeReference();
|
|
2017
|
-
let defaultValue;
|
|
2018
|
-
if (this.expectOptionalToken(TokenKind.EQUALS)) defaultValue = this.parseConstValueLiteral();
|
|
2019
|
-
const directives = this.parseConstDirectives();
|
|
2020
|
-
return this.node(start, {
|
|
2021
|
-
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
2022
|
-
description,
|
|
2023
|
-
name,
|
|
2024
|
-
type,
|
|
2025
|
-
defaultValue,
|
|
2026
|
-
directives
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
/**
|
|
2030
|
-
* InterfaceTypeDefinition :
|
|
2031
|
-
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
2032
|
-
*/
|
|
2033
|
-
parseInterfaceTypeDefinition() {
|
|
2034
|
-
const start = this._lexer.token;
|
|
2035
|
-
const description = this.parseDescription();
|
|
2036
|
-
this.expectKeyword("interface");
|
|
2037
|
-
const name = this.parseName();
|
|
2038
|
-
const interfaces = this.parseImplementsInterfaces();
|
|
2039
|
-
const directives = this.parseConstDirectives();
|
|
2040
|
-
const fields = this.parseFieldsDefinition();
|
|
2041
|
-
return this.node(start, {
|
|
2042
|
-
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
2043
|
-
description,
|
|
2044
|
-
name,
|
|
2045
|
-
interfaces,
|
|
2046
|
-
directives,
|
|
2047
|
-
fields
|
|
2048
|
-
});
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* UnionTypeDefinition :
|
|
2052
|
-
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
2053
|
-
*/
|
|
2054
|
-
parseUnionTypeDefinition() {
|
|
2055
|
-
const start = this._lexer.token;
|
|
2056
|
-
const description = this.parseDescription();
|
|
2057
|
-
this.expectKeyword("union");
|
|
2058
|
-
const name = this.parseName();
|
|
2059
|
-
const directives = this.parseConstDirectives();
|
|
2060
|
-
const types = this.parseUnionMemberTypes();
|
|
2061
|
-
return this.node(start, {
|
|
2062
|
-
kind: Kind.UNION_TYPE_DEFINITION,
|
|
2063
|
-
description,
|
|
2064
|
-
name,
|
|
2065
|
-
directives,
|
|
2066
|
-
types
|
|
2067
|
-
});
|
|
2068
|
-
}
|
|
2069
|
-
/**
|
|
2070
|
-
* UnionMemberTypes :
|
|
2071
|
-
* - = `|`? NamedType
|
|
2072
|
-
* - UnionMemberTypes | NamedType
|
|
2073
|
-
*/
|
|
2074
|
-
parseUnionMemberTypes() {
|
|
2075
|
-
return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
|
|
2076
|
-
}
|
|
2077
|
-
/**
|
|
2078
|
-
* EnumTypeDefinition :
|
|
2079
|
-
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
2080
|
-
*/
|
|
2081
|
-
parseEnumTypeDefinition() {
|
|
2082
|
-
const start = this._lexer.token;
|
|
2083
|
-
const description = this.parseDescription();
|
|
2084
|
-
this.expectKeyword("enum");
|
|
2085
|
-
const name = this.parseName();
|
|
2086
|
-
const directives = this.parseConstDirectives();
|
|
2087
|
-
const values = this.parseEnumValuesDefinition();
|
|
2088
|
-
return this.node(start, {
|
|
2089
|
-
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
2090
|
-
description,
|
|
2091
|
-
name,
|
|
2092
|
-
directives,
|
|
2093
|
-
values
|
|
2094
|
-
});
|
|
2095
|
-
}
|
|
2096
|
-
/**
|
|
2097
|
-
* ```
|
|
2098
|
-
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
2099
|
-
* ```
|
|
2100
|
-
*/
|
|
2101
|
-
parseEnumValuesDefinition() {
|
|
2102
|
-
return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);
|
|
2103
|
-
}
|
|
2104
|
-
/**
|
|
2105
|
-
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
2106
|
-
*/
|
|
2107
|
-
parseEnumValueDefinition() {
|
|
2108
|
-
const start = this._lexer.token;
|
|
2109
|
-
const description = this.parseDescription();
|
|
2110
|
-
const name = this.parseEnumValueName();
|
|
2111
|
-
const directives = this.parseConstDirectives();
|
|
2112
|
-
return this.node(start, {
|
|
2113
|
-
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
2114
|
-
description,
|
|
2115
|
-
name,
|
|
2116
|
-
directives
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* EnumValue : Name but not `true`, `false` or `null`
|
|
2121
|
-
*/
|
|
2122
|
-
parseEnumValueName() {
|
|
2123
|
-
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw syntaxError(this._lexer.source, this._lexer.token.start, `${getTokenDesc(this._lexer.token)} is reserved and cannot be used for an enum value.`);
|
|
2124
|
-
return this.parseName();
|
|
2125
|
-
}
|
|
2126
|
-
/**
|
|
2127
|
-
* InputObjectTypeDefinition :
|
|
2128
|
-
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
2129
|
-
*/
|
|
2130
|
-
parseInputObjectTypeDefinition() {
|
|
2131
|
-
const start = this._lexer.token;
|
|
2132
|
-
const description = this.parseDescription();
|
|
2133
|
-
this.expectKeyword("input");
|
|
2134
|
-
const name = this.parseName();
|
|
2135
|
-
const directives = this.parseConstDirectives();
|
|
2136
|
-
const fields = this.parseInputFieldsDefinition();
|
|
2137
|
-
return this.node(start, {
|
|
2138
|
-
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
2139
|
-
description,
|
|
2140
|
-
name,
|
|
2141
|
-
directives,
|
|
2142
|
-
fields
|
|
2143
|
-
});
|
|
2144
|
-
}
|
|
2145
|
-
/**
|
|
2146
|
-
* ```
|
|
2147
|
-
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
2148
|
-
* ```
|
|
2149
|
-
*/
|
|
2150
|
-
parseInputFieldsDefinition() {
|
|
2151
|
-
return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* TypeSystemExtension :
|
|
2155
|
-
* - SchemaExtension
|
|
2156
|
-
* - TypeExtension
|
|
2157
|
-
*
|
|
2158
|
-
* TypeExtension :
|
|
2159
|
-
* - ScalarTypeExtension
|
|
2160
|
-
* - ObjectTypeExtension
|
|
2161
|
-
* - InterfaceTypeExtension
|
|
2162
|
-
* - UnionTypeExtension
|
|
2163
|
-
* - EnumTypeExtension
|
|
2164
|
-
* - InputObjectTypeDefinition
|
|
2165
|
-
*/
|
|
2166
|
-
parseTypeSystemExtension() {
|
|
2167
|
-
const keywordToken = this._lexer.lookahead();
|
|
2168
|
-
if (keywordToken.kind === TokenKind.NAME) switch (keywordToken.value) {
|
|
2169
|
-
case "schema": return this.parseSchemaExtension();
|
|
2170
|
-
case "scalar": return this.parseScalarTypeExtension();
|
|
2171
|
-
case "type": return this.parseObjectTypeExtension();
|
|
2172
|
-
case "interface": return this.parseInterfaceTypeExtension();
|
|
2173
|
-
case "union": return this.parseUnionTypeExtension();
|
|
2174
|
-
case "enum": return this.parseEnumTypeExtension();
|
|
2175
|
-
case "input": return this.parseInputObjectTypeExtension();
|
|
2176
|
-
}
|
|
2177
|
-
throw this.unexpected(keywordToken);
|
|
2178
|
-
}
|
|
2179
|
-
/**
|
|
2180
|
-
* ```
|
|
2181
|
-
* SchemaExtension :
|
|
2182
|
-
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
2183
|
-
* - extend schema Directives[Const]
|
|
2184
|
-
* ```
|
|
2185
|
-
*/
|
|
2186
|
-
parseSchemaExtension() {
|
|
2187
|
-
const start = this._lexer.token;
|
|
2188
|
-
this.expectKeyword("extend");
|
|
2189
|
-
this.expectKeyword("schema");
|
|
2190
|
-
const directives = this.parseConstDirectives();
|
|
2191
|
-
const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
|
|
2192
|
-
if (directives.length === 0 && operationTypes.length === 0) throw this.unexpected();
|
|
2193
|
-
return this.node(start, {
|
|
2194
|
-
kind: Kind.SCHEMA_EXTENSION,
|
|
2195
|
-
directives,
|
|
2196
|
-
operationTypes
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
/**
|
|
2200
|
-
* ScalarTypeExtension :
|
|
2201
|
-
* - extend scalar Name Directives[Const]
|
|
2202
|
-
*/
|
|
2203
|
-
parseScalarTypeExtension() {
|
|
2204
|
-
const start = this._lexer.token;
|
|
2205
|
-
this.expectKeyword("extend");
|
|
2206
|
-
this.expectKeyword("scalar");
|
|
2207
|
-
const name = this.parseName();
|
|
2208
|
-
const directives = this.parseConstDirectives();
|
|
2209
|
-
if (directives.length === 0) throw this.unexpected();
|
|
2210
|
-
return this.node(start, {
|
|
2211
|
-
kind: Kind.SCALAR_TYPE_EXTENSION,
|
|
2212
|
-
name,
|
|
2213
|
-
directives
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* ObjectTypeExtension :
|
|
2218
|
-
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
2219
|
-
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
2220
|
-
* - extend type Name ImplementsInterfaces
|
|
2221
|
-
*/
|
|
2222
|
-
parseObjectTypeExtension() {
|
|
2223
|
-
const start = this._lexer.token;
|
|
2224
|
-
this.expectKeyword("extend");
|
|
2225
|
-
this.expectKeyword("type");
|
|
2226
|
-
const name = this.parseName();
|
|
2227
|
-
const interfaces = this.parseImplementsInterfaces();
|
|
2228
|
-
const directives = this.parseConstDirectives();
|
|
2229
|
-
const fields = this.parseFieldsDefinition();
|
|
2230
|
-
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
2231
|
-
return this.node(start, {
|
|
2232
|
-
kind: Kind.OBJECT_TYPE_EXTENSION,
|
|
2233
|
-
name,
|
|
2234
|
-
interfaces,
|
|
2235
|
-
directives,
|
|
2236
|
-
fields
|
|
2237
|
-
});
|
|
2238
|
-
}
|
|
2239
|
-
/**
|
|
2240
|
-
* InterfaceTypeExtension :
|
|
2241
|
-
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
2242
|
-
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
2243
|
-
* - extend interface Name ImplementsInterfaces
|
|
2244
|
-
*/
|
|
2245
|
-
parseInterfaceTypeExtension() {
|
|
2246
|
-
const start = this._lexer.token;
|
|
2247
|
-
this.expectKeyword("extend");
|
|
2248
|
-
this.expectKeyword("interface");
|
|
2249
|
-
const name = this.parseName();
|
|
2250
|
-
const interfaces = this.parseImplementsInterfaces();
|
|
2251
|
-
const directives = this.parseConstDirectives();
|
|
2252
|
-
const fields = this.parseFieldsDefinition();
|
|
2253
|
-
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
2254
|
-
return this.node(start, {
|
|
2255
|
-
kind: Kind.INTERFACE_TYPE_EXTENSION,
|
|
2256
|
-
name,
|
|
2257
|
-
interfaces,
|
|
2258
|
-
directives,
|
|
2259
|
-
fields
|
|
2260
|
-
});
|
|
2261
|
-
}
|
|
2262
|
-
/**
|
|
2263
|
-
* UnionTypeExtension :
|
|
2264
|
-
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
2265
|
-
* - extend union Name Directives[Const]
|
|
2266
|
-
*/
|
|
2267
|
-
parseUnionTypeExtension() {
|
|
2268
|
-
const start = this._lexer.token;
|
|
2269
|
-
this.expectKeyword("extend");
|
|
2270
|
-
this.expectKeyword("union");
|
|
2271
|
-
const name = this.parseName();
|
|
2272
|
-
const directives = this.parseConstDirectives();
|
|
2273
|
-
const types = this.parseUnionMemberTypes();
|
|
2274
|
-
if (directives.length === 0 && types.length === 0) throw this.unexpected();
|
|
2275
|
-
return this.node(start, {
|
|
2276
|
-
kind: Kind.UNION_TYPE_EXTENSION,
|
|
2277
|
-
name,
|
|
2278
|
-
directives,
|
|
2279
|
-
types
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
|
-
/**
|
|
2283
|
-
* EnumTypeExtension :
|
|
2284
|
-
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
2285
|
-
* - extend enum Name Directives[Const]
|
|
2286
|
-
*/
|
|
2287
|
-
parseEnumTypeExtension() {
|
|
2288
|
-
const start = this._lexer.token;
|
|
2289
|
-
this.expectKeyword("extend");
|
|
2290
|
-
this.expectKeyword("enum");
|
|
2291
|
-
const name = this.parseName();
|
|
2292
|
-
const directives = this.parseConstDirectives();
|
|
2293
|
-
const values = this.parseEnumValuesDefinition();
|
|
2294
|
-
if (directives.length === 0 && values.length === 0) throw this.unexpected();
|
|
2295
|
-
return this.node(start, {
|
|
2296
|
-
kind: Kind.ENUM_TYPE_EXTENSION,
|
|
2297
|
-
name,
|
|
2298
|
-
directives,
|
|
2299
|
-
values
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
/**
|
|
2303
|
-
* InputObjectTypeExtension :
|
|
2304
|
-
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
2305
|
-
* - extend input Name Directives[Const]
|
|
2306
|
-
*/
|
|
2307
|
-
parseInputObjectTypeExtension() {
|
|
2308
|
-
const start = this._lexer.token;
|
|
2309
|
-
this.expectKeyword("extend");
|
|
2310
|
-
this.expectKeyword("input");
|
|
2311
|
-
const name = this.parseName();
|
|
2312
|
-
const directives = this.parseConstDirectives();
|
|
2313
|
-
const fields = this.parseInputFieldsDefinition();
|
|
2314
|
-
if (directives.length === 0 && fields.length === 0) throw this.unexpected();
|
|
2315
|
-
return this.node(start, {
|
|
2316
|
-
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
2317
|
-
name,
|
|
2318
|
-
directives,
|
|
2319
|
-
fields
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
/**
|
|
2323
|
-
* ```
|
|
2324
|
-
* DirectiveDefinition :
|
|
2325
|
-
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
2326
|
-
* ```
|
|
2327
|
-
*/
|
|
2328
|
-
parseDirectiveDefinition() {
|
|
2329
|
-
const start = this._lexer.token;
|
|
2330
|
-
const description = this.parseDescription();
|
|
2331
|
-
this.expectKeyword("directive");
|
|
2332
|
-
this.expectToken(TokenKind.AT);
|
|
2333
|
-
const name = this.parseName();
|
|
2334
|
-
const args = this.parseArgumentDefs();
|
|
2335
|
-
const repeatable = this.expectOptionalKeyword("repeatable");
|
|
2336
|
-
this.expectKeyword("on");
|
|
2337
|
-
const locations = this.parseDirectiveLocations();
|
|
2338
|
-
return this.node(start, {
|
|
2339
|
-
kind: Kind.DIRECTIVE_DEFINITION,
|
|
2340
|
-
description,
|
|
2341
|
-
name,
|
|
2342
|
-
arguments: args,
|
|
2343
|
-
repeatable,
|
|
2344
|
-
locations
|
|
2345
|
-
});
|
|
2346
|
-
}
|
|
2347
|
-
/**
|
|
2348
|
-
* DirectiveLocations :
|
|
2349
|
-
* - `|`? DirectiveLocation
|
|
2350
|
-
* - DirectiveLocations | DirectiveLocation
|
|
2351
|
-
*/
|
|
2352
|
-
parseDirectiveLocations() {
|
|
2353
|
-
return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
|
|
2354
|
-
}
|
|
2355
|
-
parseDirectiveLocation() {
|
|
2356
|
-
const start = this._lexer.token;
|
|
2357
|
-
const name = this.parseName();
|
|
2358
|
-
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) return name;
|
|
2359
|
-
throw this.unexpected(start);
|
|
2360
|
-
}
|
|
2361
|
-
/**
|
|
2362
|
-
* SchemaCoordinate :
|
|
2363
|
-
* - Name
|
|
2364
|
-
* - Name . Name
|
|
2365
|
-
* - Name . Name ( Name : )
|
|
2366
|
-
* - \@ Name
|
|
2367
|
-
* - \@ Name ( Name : )
|
|
2368
|
-
*/
|
|
2369
|
-
parseSchemaCoordinate() {
|
|
2370
|
-
const start = this._lexer.token;
|
|
2371
|
-
const ofDirective = this.expectOptionalToken(TokenKind.AT);
|
|
2372
|
-
const name = this.parseName();
|
|
2373
|
-
let memberName;
|
|
2374
|
-
if (!ofDirective && this.expectOptionalToken(TokenKind.DOT)) memberName = this.parseName();
|
|
2375
|
-
let argumentName;
|
|
2376
|
-
if ((ofDirective || memberName) && this.expectOptionalToken(TokenKind.PAREN_L)) {
|
|
2377
|
-
argumentName = this.parseName();
|
|
2378
|
-
this.expectToken(TokenKind.COLON);
|
|
2379
|
-
this.expectToken(TokenKind.PAREN_R);
|
|
2380
|
-
}
|
|
2381
|
-
if (ofDirective) {
|
|
2382
|
-
if (argumentName) return this.node(start, {
|
|
2383
|
-
kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
|
|
2384
|
-
name,
|
|
2385
|
-
argumentName
|
|
2386
|
-
});
|
|
2387
|
-
return this.node(start, {
|
|
2388
|
-
kind: Kind.DIRECTIVE_COORDINATE,
|
|
2389
|
-
name
|
|
2390
|
-
});
|
|
2391
|
-
} else if (memberName) {
|
|
2392
|
-
if (argumentName) return this.node(start, {
|
|
2393
|
-
kind: Kind.ARGUMENT_COORDINATE,
|
|
2394
|
-
name,
|
|
2395
|
-
fieldName: memberName,
|
|
2396
|
-
argumentName
|
|
2397
|
-
});
|
|
2398
|
-
return this.node(start, {
|
|
2399
|
-
kind: Kind.MEMBER_COORDINATE,
|
|
2400
|
-
name,
|
|
2401
|
-
memberName
|
|
2402
|
-
});
|
|
2403
|
-
}
|
|
2404
|
-
return this.node(start, {
|
|
2405
|
-
kind: Kind.TYPE_COORDINATE,
|
|
2406
|
-
name
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2409
|
-
/**
|
|
2410
|
-
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
2411
|
-
* location object, used to identify the place in the source that created a
|
|
2412
|
-
* given parsed object.
|
|
2413
|
-
*/
|
|
2414
|
-
node(startToken, node) {
|
|
2415
|
-
if (this._options.noLocation !== true) node.loc = new Location(startToken, this._lexer.lastToken, this._lexer.source);
|
|
2416
|
-
return node;
|
|
2417
|
-
}
|
|
2418
|
-
/**
|
|
2419
|
-
* Determines if the next token is of a given kind
|
|
2420
|
-
*/
|
|
2421
|
-
peek(kind) {
|
|
2422
|
-
return this._lexer.token.kind === kind;
|
|
2423
|
-
}
|
|
2424
|
-
/**
|
|
2425
|
-
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
2426
|
-
* Otherwise, do not change the parser state and throw an error.
|
|
2427
|
-
*/
|
|
2428
|
-
expectToken(kind) {
|
|
2429
|
-
const token = this._lexer.token;
|
|
2430
|
-
if (token.kind === kind) {
|
|
2431
|
-
this.advanceLexer();
|
|
2432
|
-
return token;
|
|
2433
|
-
}
|
|
2434
|
-
throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);
|
|
2435
|
-
}
|
|
2436
|
-
/**
|
|
2437
|
-
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
2438
|
-
* Otherwise, do not change the parser state and return "false".
|
|
2439
|
-
*/
|
|
2440
|
-
expectOptionalToken(kind) {
|
|
2441
|
-
if (this._lexer.token.kind === kind) {
|
|
2442
|
-
this.advanceLexer();
|
|
2443
|
-
return true;
|
|
2444
|
-
}
|
|
2445
|
-
return false;
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* If the next token is a given keyword, advance the lexer.
|
|
2449
|
-
* Otherwise, do not change the parser state and throw an error.
|
|
2450
|
-
*/
|
|
2451
|
-
expectKeyword(value) {
|
|
2452
|
-
const token = this._lexer.token;
|
|
2453
|
-
if (token.kind === TokenKind.NAME && token.value === value) this.advanceLexer();
|
|
2454
|
-
else throw syntaxError(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`);
|
|
2455
|
-
}
|
|
2456
|
-
/**
|
|
2457
|
-
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
2458
|
-
* Otherwise, do not change the parser state and return "false".
|
|
2459
|
-
*/
|
|
2460
|
-
expectOptionalKeyword(value) {
|
|
2461
|
-
const token = this._lexer.token;
|
|
2462
|
-
if (token.kind === TokenKind.NAME && token.value === value) {
|
|
2463
|
-
this.advanceLexer();
|
|
2464
|
-
return true;
|
|
2465
|
-
}
|
|
2466
|
-
return false;
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
2470
|
-
*/
|
|
2471
|
-
unexpected(atToken) {
|
|
2472
|
-
const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
|
|
2473
|
-
return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);
|
|
2474
|
-
}
|
|
2475
|
-
/**
|
|
2476
|
-
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
2477
|
-
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2478
|
-
* Advances the parser to the next lex token after the closing token.
|
|
2479
|
-
*/
|
|
2480
|
-
any(openKind, parseFn, closeKind) {
|
|
2481
|
-
this.expectToken(openKind);
|
|
2482
|
-
const nodes = [];
|
|
2483
|
-
while (!this.expectOptionalToken(closeKind)) nodes.push(parseFn.call(this));
|
|
2484
|
-
return nodes;
|
|
2485
|
-
}
|
|
2486
|
-
/**
|
|
2487
|
-
* Returns a list of parse nodes, determined by the parseFn.
|
|
2488
|
-
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
2489
|
-
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2490
|
-
* Advances the parser to the next lex token after the closing token.
|
|
2491
|
-
*/
|
|
2492
|
-
optionalMany(openKind, parseFn, closeKind) {
|
|
2493
|
-
if (this.expectOptionalToken(openKind)) {
|
|
2494
|
-
const nodes = [];
|
|
2495
|
-
do
|
|
2496
|
-
nodes.push(parseFn.call(this));
|
|
2497
|
-
while (!this.expectOptionalToken(closeKind));
|
|
2498
|
-
return nodes;
|
|
2499
|
-
}
|
|
2500
|
-
return [];
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
2504
|
-
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2505
|
-
* Advances the parser to the next lex token after the closing token.
|
|
2506
|
-
*/
|
|
2507
|
-
many(openKind, parseFn, closeKind) {
|
|
2508
|
-
this.expectToken(openKind);
|
|
2509
|
-
const nodes = [];
|
|
2510
|
-
do
|
|
2511
|
-
nodes.push(parseFn.call(this));
|
|
2512
|
-
while (!this.expectOptionalToken(closeKind));
|
|
2513
|
-
return nodes;
|
|
2514
|
-
}
|
|
2515
|
-
/**
|
|
2516
|
-
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
2517
|
-
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
2518
|
-
* Advances the parser to the next lex token after last item in the list.
|
|
2519
|
-
*/
|
|
2520
|
-
delimitedMany(delimiterKind, parseFn) {
|
|
2521
|
-
this.expectOptionalToken(delimiterKind);
|
|
2522
|
-
const nodes = [];
|
|
2523
|
-
do
|
|
2524
|
-
nodes.push(parseFn.call(this));
|
|
2525
|
-
while (this.expectOptionalToken(delimiterKind));
|
|
2526
|
-
return nodes;
|
|
2527
|
-
}
|
|
2528
|
-
advanceLexer() {
|
|
2529
|
-
const { maxTokens } = this._options;
|
|
2530
|
-
const token = this._lexer.advance();
|
|
2531
|
-
if (token.kind !== TokenKind.EOF) {
|
|
2532
|
-
++this._tokenCounter;
|
|
2533
|
-
if (maxTokens !== void 0 && this._tokenCounter > maxTokens) throw syntaxError(this._lexer.source, token.start, `Document contains more that ${maxTokens} tokens. Parsing aborted.`);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
};
|
|
2537
|
-
/**
|
|
2538
|
-
* A helper function to describe a token as a string for debugging.
|
|
2539
|
-
*/
|
|
2540
|
-
function getTokenDesc(token) {
|
|
2541
|
-
const value = token.value;
|
|
2542
|
-
return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
|
|
2543
|
-
}
|
|
2544
|
-
/**
|
|
2545
|
-
* A helper function to describe a token kind as a string for debugging.
|
|
2546
|
-
*/
|
|
2547
|
-
function getTokenKindDesc(kind) {
|
|
2548
|
-
return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
|
|
2549
|
-
}
|
|
2550
|
-
//#endregion
|
|
2551
|
-
export { printBlockString as a, Kind as c, QueryDocumentKeys as d, isNode as f, devAssert as g, isObjectLike as h, isPrintableAsBlockString as i, DirectiveLocation as l, invariant as m, instanceOf as n, isNameContinue as o, GraphQLError as p, inspect as r, isNameStart as s, parse as t, OperationTypeNode as u };
|
|
2552
|
-
|
|
2553
|
-
//# sourceMappingURL=parser-CkF6Qt8V.js.map
|