@powerhousedao/powerhouse-vetra-packages 6.2.3 → 6.3.0-dev.1

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.
Files changed (95) hide show
  1. package/dist/browser/document-models/index.js +1 -1
  2. package/dist/browser/documents-cxt8RRxe.js +18 -0
  3. package/dist/browser/documents-cxt8RRxe.js.map +1 -0
  4. package/dist/browser/editor-DXAJ8Mqb.js +2293 -0
  5. package/dist/browser/editor-DXAJ8Mqb.js.map +1 -0
  6. package/dist/browser/{editor-CiR6XQBO.js → editor-Dmpkd8pQ.js} +3 -3
  7. package/dist/browser/{editor-CiR6XQBO.js.map → editor-Dmpkd8pQ.js.map} +1 -1
  8. package/dist/browser/editors/document-model-editor/module.js +1 -1
  9. package/dist/browser/editors/document-model-editor/module.js.map +1 -1
  10. package/dist/browser/editors/generic-drive-explorer/index.js +4 -340
  11. package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
  12. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  13. package/dist/browser/folder-view-CwIU4XEe.js +237 -0
  14. package/dist/browser/folder-view-CwIU4XEe.js.map +1 -0
  15. package/dist/browser/graphql-editor-CGxwONKl.js +103 -0
  16. package/dist/browser/graphql-editor-CGxwONKl.js.map +1 -0
  17. package/dist/browser/hooks-D15NCia0.js +126 -0
  18. package/dist/browser/hooks-D15NCia0.js.map +1 -0
  19. package/dist/browser/index.js +5 -805
  20. package/dist/browser/index.js.map +1 -1
  21. package/dist/browser/json-editor--jgLEwP2.js +55 -0
  22. package/dist/browser/json-editor--jgLEwP2.js.map +1 -0
  23. package/dist/browser/schema-context-CC_WFs1x.js +73 -0
  24. package/dist/browser/schema-context-CC_WFs1x.js.map +1 -0
  25. package/dist/browser/state-schemas-DSY44MOd.js +307 -0
  26. package/dist/browser/state-schemas-DSY44MOd.js.map +1 -0
  27. package/dist/node/bundle-mjs-Cuu3DEfT.mjs +3140 -0
  28. package/dist/node/bundle-mjs-Cuu3DEfT.mjs.map +1 -0
  29. package/dist/node/{graphql-Dp4j7rmx.mjs → documents-DH2fyf7U.mjs} +32 -3
  30. package/dist/node/documents-DH2fyf7U.mjs.map +1 -0
  31. package/dist/node/{editor-96sMeumV.mjs → editor-BcvUeBW7.mjs} +2902 -2738
  32. package/dist/node/editor-BcvUeBW7.mjs.map +1 -0
  33. package/dist/node/editor-DJCghViS.mjs +983 -0
  34. package/dist/node/editor-DJCghViS.mjs.map +1 -0
  35. package/dist/node/editors/index.mjs +23 -2
  36. package/dist/node/editors/index.mjs.map +1 -0
  37. package/dist/node/{graphql-editor-CBJXEY_C.mjs → graphql-editor-u9NStKLL.mjs} +5078 -26
  38. package/dist/node/graphql-editor-u9NStKLL.mjs.map +1 -0
  39. package/dist/{browser/hooks-eQxBX7g4.js → node/hooks-BiLz75cj.mjs} +2 -2
  40. package/dist/node/{hooks-C2b46djt.mjs.map → hooks-BiLz75cj.mjs.map} +1 -1
  41. package/dist/node/index.mjs +12 -189
  42. package/dist/node/index.mjs.map +1 -1
  43. package/dist/{browser/json-editor-DfRD-pfk.js → node/json-editor-BfcrckeT.mjs} +3 -3
  44. package/dist/node/{json-editor-DaqHARBD.mjs.map → json-editor-BfcrckeT.mjs.map} +1 -1
  45. package/dist/node/{schema-context-CojjnSE6.mjs → schema-context-r0MTQnRC.mjs} +6 -4
  46. package/dist/node/schema-context-r0MTQnRC.mjs.map +1 -0
  47. package/dist/node/{state-schemas-BHuo0GPl.mjs → state-schemas-o3PZdBW2.mjs} +427 -54
  48. package/dist/node/state-schemas-o3PZdBW2.mjs.map +1 -0
  49. package/package.json +21 -19
  50. package/style.css +2 -0
  51. package/dist/browser/assets/entry-D62sYiFV.js +0 -318
  52. package/dist/browser/assets/projection-entry-BGcu_9-p.js +0 -446
  53. package/dist/browser/documents-CRzouuNR.js +0 -6067
  54. package/dist/browser/documents-CRzouuNR.js.map +0 -1
  55. package/dist/browser/editor-C7KBR_ar.js +0 -4676
  56. package/dist/browser/editor-C7KBR_ar.js.map +0 -1
  57. package/dist/browser/folder-view-DSgXN79D.js +0 -4409
  58. package/dist/browser/folder-view-DSgXN79D.js.map +0 -1
  59. package/dist/browser/graphql-editor-Cgi5UOrF.js +0 -11708
  60. package/dist/browser/graphql-editor-Cgi5UOrF.js.map +0 -1
  61. package/dist/browser/hooks-eQxBX7g4.js.map +0 -1
  62. package/dist/browser/json-editor-DfRD-pfk.js.map +0 -1
  63. package/dist/browser/parser-DtbeHA3H.js +0 -2554
  64. package/dist/browser/parser-DtbeHA3H.js.map +0 -1
  65. package/dist/browser/rolldown-runtime-DC62tzP2.js +0 -33
  66. package/dist/browser/src-CrUksCLW-B2dkRdgq.js +0 -5254
  67. package/dist/browser/src-CrUksCLW-B2dkRdgq.js.map +0 -1
  68. package/dist/browser/state-schemas-B5Bk_l1s.js +0 -696
  69. package/dist/browser/state-schemas-B5Bk_l1s.js.map +0 -1
  70. package/dist/browser/tslib.es6-Cno80yFJ.js +0 -32
  71. package/dist/browser/tslib.es6-Cno80yFJ.js.map +0 -1
  72. package/dist/node/documents-D70S9PZL.mjs +0 -17
  73. package/dist/node/documents-D70S9PZL.mjs.map +0 -1
  74. package/dist/node/editor-96sMeumV.mjs.map +0 -1
  75. package/dist/node/editor-wqvKwcO5.mjs +0 -24
  76. package/dist/node/editor-wqvKwcO5.mjs.map +0 -1
  77. package/dist/node/editors/document-model-editor/index.mjs +0 -1
  78. package/dist/node/editors/document-model-editor/module.mjs +0 -14
  79. package/dist/node/editors/document-model-editor/module.mjs.map +0 -1
  80. package/dist/node/editors/generic-drive-explorer/index.mjs +0 -461
  81. package/dist/node/editors/generic-drive-explorer/index.mjs.map +0 -1
  82. package/dist/node/editors/generic-drive-explorer/module.mjs +0 -14
  83. package/dist/node/editors/generic-drive-explorer/module.mjs.map +0 -1
  84. package/dist/node/folder-view-ktfv2Cvw.mjs +0 -4409
  85. package/dist/node/folder-view-ktfv2Cvw.mjs.map +0 -1
  86. package/dist/node/graphql-Dp4j7rmx.mjs.map +0 -1
  87. package/dist/node/graphql-editor-CBJXEY_C.mjs.map +0 -1
  88. package/dist/node/hooks-C2b46djt.mjs +0 -24593
  89. package/dist/node/json-editor-DaqHARBD.mjs +0 -153
  90. package/dist/node/schema-context-CojjnSE6.mjs.map +0 -1
  91. package/dist/node/src-CrUksCLW-TvF37aMo.mjs +0 -5935
  92. package/dist/node/src-CrUksCLW-TvF37aMo.mjs.map +0 -1
  93. package/dist/node/state-schemas-BHuo0GPl.mjs.map +0 -1
  94. package/dist/node/tslib.es6-VORZjfk3.mjs +0 -583
  95. package/dist/node/tslib.es6-VORZjfk3.mjs.map +0 -1
@@ -1,2554 +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, function instanceOf(value, constructor) {
1347
- if (value instanceof constructor) return true;
1348
- if (typeof value === "object" && value !== null) {
1349
- var _value$constructor;
1350
- const className = constructor.prototype[Symbol.toStringTag];
1351
- if (className === (Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name)) {
1352
- const stringifiedValue = inspect(value);
1353
- throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
1354
-
1355
- Ensure that there is only one instance of "graphql" in the node_modules
1356
- directory. If different versions of "graphql" are the dependencies of other
1357
- relied on modules, use "resolutions" to ensure only one version is installed.
1358
-
1359
- https://yarnpkg.com/en/docs/selective-version-resolutions
1360
-
1361
- Duplicate "graphql" modules cannot be used at the same time since different
1362
- versions may have different capabilities and behavior. The data from one
1363
- version used in the function from another could produce confusing and
1364
- spurious results.`);
1365
- }
1366
- }
1367
- return false;
1368
- });
1369
- //#endregion
1370
- //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/source.mjs
1371
- /**
1372
- * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
1373
- * optional, but they are useful for clients who store GraphQL documents in source files.
1374
- * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
1375
- * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
1376
- * The `line` and `column` properties in `locationOffset` are 1-indexed.
1377
- */
1378
- var Source = class {
1379
- constructor(body, name = "GraphQL request", locationOffset = {
1380
- line: 1,
1381
- column: 1
1382
- }) {
1383
- typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
1384
- this.body = body;
1385
- this.name = name;
1386
- this.locationOffset = locationOffset;
1387
- this.locationOffset.line > 0 || devAssert(false, "line in locationOffset is 1-indexed and must be positive.");
1388
- this.locationOffset.column > 0 || devAssert(false, "column in locationOffset is 1-indexed and must be positive.");
1389
- }
1390
- get [Symbol.toStringTag]() {
1391
- return "Source";
1392
- }
1393
- };
1394
- /**
1395
- * Test if the given value is a Source object.
1396
- *
1397
- * @internal
1398
- */
1399
- function isSource(source) {
1400
- return instanceOf(source, Source);
1401
- }
1402
- //#endregion
1403
- //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/parser.mjs
1404
- /**
1405
- * Configuration options to control parser behavior
1406
- */
1407
- /**
1408
- * Given a GraphQL source, parses it into a Document.
1409
- * Throws GraphQLError if a syntax error is encountered.
1410
- */
1411
- function parse(source, options) {
1412
- const parser = new Parser(source, options);
1413
- const document = parser.parseDocument();
1414
- Object.defineProperty(document, "tokenCount", {
1415
- enumerable: false,
1416
- value: parser.tokenCount
1417
- });
1418
- return document;
1419
- }
1420
- /**
1421
- * This class is exported only to assist people in implementing their own parsers
1422
- * without duplicating too much code and should be used only as last resort for cases
1423
- * such as experimental syntax or if certain features could not be contributed upstream.
1424
- *
1425
- * It is still part of the internal API and is versioned, so any changes to it are never
1426
- * considered breaking changes. If you still need to support multiple versions of the
1427
- * library, please use the `versionInfo` variable for version detection.
1428
- *
1429
- * @internal
1430
- */
1431
- var Parser = class {
1432
- constructor(source, options = {}) {
1433
- const { lexer, ..._options } = options;
1434
- if (lexer) this._lexer = lexer;
1435
- else {
1436
- const sourceObj = isSource(source) ? source : new Source(source);
1437
- this._lexer = new Lexer(sourceObj);
1438
- }
1439
- this._options = _options;
1440
- this._tokenCounter = 0;
1441
- }
1442
- get tokenCount() {
1443
- return this._tokenCounter;
1444
- }
1445
- /**
1446
- * Converts a name lex token into a name parse node.
1447
- */
1448
- parseName() {
1449
- const token = this.expectToken(TokenKind.NAME);
1450
- return this.node(token, {
1451
- kind: Kind.NAME,
1452
- value: token.value
1453
- });
1454
- }
1455
- /**
1456
- * Document : Definition+
1457
- */
1458
- parseDocument() {
1459
- return this.node(this._lexer.token, {
1460
- kind: Kind.DOCUMENT,
1461
- definitions: this.many(TokenKind.SOF, this.parseDefinition, TokenKind.EOF)
1462
- });
1463
- }
1464
- /**
1465
- * Definition :
1466
- * - ExecutableDefinition
1467
- * - TypeSystemDefinition
1468
- * - TypeSystemExtension
1469
- *
1470
- * ExecutableDefinition :
1471
- * - OperationDefinition
1472
- * - FragmentDefinition
1473
- *
1474
- * TypeSystemDefinition :
1475
- * - SchemaDefinition
1476
- * - TypeDefinition
1477
- * - DirectiveDefinition
1478
- *
1479
- * TypeDefinition :
1480
- * - ScalarTypeDefinition
1481
- * - ObjectTypeDefinition
1482
- * - InterfaceTypeDefinition
1483
- * - UnionTypeDefinition
1484
- * - EnumTypeDefinition
1485
- * - InputObjectTypeDefinition
1486
- */
1487
- parseDefinition() {
1488
- if (this.peek(TokenKind.BRACE_L)) return this.parseOperationDefinition();
1489
- const hasDescription = this.peekDescription();
1490
- const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
1491
- 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.");
1492
- if (keywordToken.kind === TokenKind.NAME) {
1493
- switch (keywordToken.value) {
1494
- case "schema": return this.parseSchemaDefinition();
1495
- case "scalar": return this.parseScalarTypeDefinition();
1496
- case "type": return this.parseObjectTypeDefinition();
1497
- case "interface": return this.parseInterfaceTypeDefinition();
1498
- case "union": return this.parseUnionTypeDefinition();
1499
- case "enum": return this.parseEnumTypeDefinition();
1500
- case "input": return this.parseInputObjectTypeDefinition();
1501
- case "directive": return this.parseDirectiveDefinition();
1502
- }
1503
- switch (keywordToken.value) {
1504
- case "query":
1505
- case "mutation":
1506
- case "subscription": return this.parseOperationDefinition();
1507
- case "fragment": return this.parseFragmentDefinition();
1508
- }
1509
- if (hasDescription) throw syntaxError(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
1510
- switch (keywordToken.value) {
1511
- case "extend": return this.parseTypeSystemExtension();
1512
- }
1513
- }
1514
- throw this.unexpected(keywordToken);
1515
- }
1516
- /**
1517
- * OperationDefinition :
1518
- * - SelectionSet
1519
- * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1520
- */
1521
- parseOperationDefinition() {
1522
- const start = this._lexer.token;
1523
- if (this.peek(TokenKind.BRACE_L)) return this.node(start, {
1524
- kind: Kind.OPERATION_DEFINITION,
1525
- operation: OperationTypeNode.QUERY,
1526
- description: void 0,
1527
- name: void 0,
1528
- variableDefinitions: [],
1529
- directives: [],
1530
- selectionSet: this.parseSelectionSet()
1531
- });
1532
- const description = this.parseDescription();
1533
- const operation = this.parseOperationType();
1534
- let name;
1535
- if (this.peek(TokenKind.NAME)) name = this.parseName();
1536
- return this.node(start, {
1537
- kind: Kind.OPERATION_DEFINITION,
1538
- operation,
1539
- description,
1540
- name,
1541
- variableDefinitions: this.parseVariableDefinitions(),
1542
- directives: this.parseDirectives(false),
1543
- selectionSet: this.parseSelectionSet()
1544
- });
1545
- }
1546
- /**
1547
- * OperationType : one of query mutation subscription
1548
- */
1549
- parseOperationType() {
1550
- const operationToken = this.expectToken(TokenKind.NAME);
1551
- switch (operationToken.value) {
1552
- case "query": return OperationTypeNode.QUERY;
1553
- case "mutation": return OperationTypeNode.MUTATION;
1554
- case "subscription": return OperationTypeNode.SUBSCRIPTION;
1555
- }
1556
- throw this.unexpected(operationToken);
1557
- }
1558
- /**
1559
- * VariableDefinitions : ( VariableDefinition+ )
1560
- */
1561
- parseVariableDefinitions() {
1562
- return this.optionalMany(TokenKind.PAREN_L, this.parseVariableDefinition, TokenKind.PAREN_R);
1563
- }
1564
- /**
1565
- * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1566
- */
1567
- parseVariableDefinition() {
1568
- return this.node(this._lexer.token, {
1569
- kind: Kind.VARIABLE_DEFINITION,
1570
- description: this.parseDescription(),
1571
- variable: this.parseVariable(),
1572
- type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
1573
- defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
1574
- directives: this.parseConstDirectives()
1575
- });
1576
- }
1577
- /**
1578
- * Variable : $ Name
1579
- */
1580
- parseVariable() {
1581
- const start = this._lexer.token;
1582
- this.expectToken(TokenKind.DOLLAR);
1583
- return this.node(start, {
1584
- kind: Kind.VARIABLE,
1585
- name: this.parseName()
1586
- });
1587
- }
1588
- /**
1589
- * ```
1590
- * SelectionSet : { Selection+ }
1591
- * ```
1592
- */
1593
- parseSelectionSet() {
1594
- return this.node(this._lexer.token, {
1595
- kind: Kind.SELECTION_SET,
1596
- selections: this.many(TokenKind.BRACE_L, this.parseSelection, TokenKind.BRACE_R)
1597
- });
1598
- }
1599
- /**
1600
- * Selection :
1601
- * - Field
1602
- * - FragmentSpread
1603
- * - InlineFragment
1604
- */
1605
- parseSelection() {
1606
- return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
1607
- }
1608
- /**
1609
- * Field : Alias? Name Arguments? Directives? SelectionSet?
1610
- *
1611
- * Alias : Name :
1612
- */
1613
- parseField() {
1614
- const start = this._lexer.token;
1615
- const nameOrAlias = this.parseName();
1616
- let alias;
1617
- let name;
1618
- if (this.expectOptionalToken(TokenKind.COLON)) {
1619
- alias = nameOrAlias;
1620
- name = this.parseName();
1621
- } else name = nameOrAlias;
1622
- return this.node(start, {
1623
- kind: Kind.FIELD,
1624
- alias,
1625
- name,
1626
- arguments: this.parseArguments(false),
1627
- directives: this.parseDirectives(false),
1628
- selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
1629
- });
1630
- }
1631
- /**
1632
- * Arguments[Const] : ( Argument[?Const]+ )
1633
- */
1634
- parseArguments(isConst) {
1635
- const item = isConst ? this.parseConstArgument : this.parseArgument;
1636
- return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
1637
- }
1638
- /**
1639
- * Argument[Const] : Name : Value[?Const]
1640
- */
1641
- parseArgument(isConst = false) {
1642
- const start = this._lexer.token;
1643
- const name = this.parseName();
1644
- this.expectToken(TokenKind.COLON);
1645
- return this.node(start, {
1646
- kind: Kind.ARGUMENT,
1647
- name,
1648
- value: this.parseValueLiteral(isConst)
1649
- });
1650
- }
1651
- parseConstArgument() {
1652
- return this.parseArgument(true);
1653
- }
1654
- /**
1655
- * Corresponds to both FragmentSpread and InlineFragment in the spec.
1656
- *
1657
- * FragmentSpread : ... FragmentName Directives?
1658
- *
1659
- * InlineFragment : ... TypeCondition? Directives? SelectionSet
1660
- */
1661
- parseFragment() {
1662
- const start = this._lexer.token;
1663
- this.expectToken(TokenKind.SPREAD);
1664
- const hasTypeCondition = this.expectOptionalKeyword("on");
1665
- if (!hasTypeCondition && this.peek(TokenKind.NAME)) return this.node(start, {
1666
- kind: Kind.FRAGMENT_SPREAD,
1667
- name: this.parseFragmentName(),
1668
- directives: this.parseDirectives(false)
1669
- });
1670
- return this.node(start, {
1671
- kind: Kind.INLINE_FRAGMENT,
1672
- typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
1673
- directives: this.parseDirectives(false),
1674
- selectionSet: this.parseSelectionSet()
1675
- });
1676
- }
1677
- /**
1678
- * FragmentDefinition :
1679
- * - fragment FragmentName on TypeCondition Directives? SelectionSet
1680
- *
1681
- * TypeCondition : NamedType
1682
- */
1683
- parseFragmentDefinition() {
1684
- const start = this._lexer.token;
1685
- const description = this.parseDescription();
1686
- this.expectKeyword("fragment");
1687
- if (this._options.allowLegacyFragmentVariables === true) return this.node(start, {
1688
- kind: Kind.FRAGMENT_DEFINITION,
1689
- description,
1690
- name: this.parseFragmentName(),
1691
- variableDefinitions: this.parseVariableDefinitions(),
1692
- typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1693
- directives: this.parseDirectives(false),
1694
- selectionSet: this.parseSelectionSet()
1695
- });
1696
- return this.node(start, {
1697
- kind: Kind.FRAGMENT_DEFINITION,
1698
- description,
1699
- name: this.parseFragmentName(),
1700
- typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1701
- directives: this.parseDirectives(false),
1702
- selectionSet: this.parseSelectionSet()
1703
- });
1704
- }
1705
- /**
1706
- * FragmentName : Name but not `on`
1707
- */
1708
- parseFragmentName() {
1709
- if (this._lexer.token.value === "on") throw this.unexpected();
1710
- return this.parseName();
1711
- }
1712
- /**
1713
- * Value[Const] :
1714
- * - [~Const] Variable
1715
- * - IntValue
1716
- * - FloatValue
1717
- * - StringValue
1718
- * - BooleanValue
1719
- * - NullValue
1720
- * - EnumValue
1721
- * - ListValue[?Const]
1722
- * - ObjectValue[?Const]
1723
- *
1724
- * BooleanValue : one of `true` `false`
1725
- *
1726
- * NullValue : `null`
1727
- *
1728
- * EnumValue : Name but not `true`, `false` or `null`
1729
- */
1730
- parseValueLiteral(isConst) {
1731
- const token = this._lexer.token;
1732
- switch (token.kind) {
1733
- case TokenKind.BRACKET_L: return this.parseList(isConst);
1734
- case TokenKind.BRACE_L: return this.parseObject(isConst);
1735
- case TokenKind.INT:
1736
- this.advanceLexer();
1737
- return this.node(token, {
1738
- kind: Kind.INT,
1739
- value: token.value
1740
- });
1741
- case TokenKind.FLOAT:
1742
- this.advanceLexer();
1743
- return this.node(token, {
1744
- kind: Kind.FLOAT,
1745
- value: token.value
1746
- });
1747
- case TokenKind.STRING:
1748
- case TokenKind.BLOCK_STRING: return this.parseStringLiteral();
1749
- case TokenKind.NAME:
1750
- this.advanceLexer();
1751
- switch (token.value) {
1752
- case "true": return this.node(token, {
1753
- kind: Kind.BOOLEAN,
1754
- value: true
1755
- });
1756
- case "false": return this.node(token, {
1757
- kind: Kind.BOOLEAN,
1758
- value: false
1759
- });
1760
- case "null": return this.node(token, { kind: Kind.NULL });
1761
- default: return this.node(token, {
1762
- kind: Kind.ENUM,
1763
- value: token.value
1764
- });
1765
- }
1766
- case TokenKind.DOLLAR:
1767
- if (isConst) {
1768
- this.expectToken(TokenKind.DOLLAR);
1769
- if (this._lexer.token.kind === TokenKind.NAME) {
1770
- const varName = this._lexer.token.value;
1771
- throw syntaxError(this._lexer.source, token.start, `Unexpected variable "$${varName}" in constant value.`);
1772
- } else throw this.unexpected(token);
1773
- }
1774
- return this.parseVariable();
1775
- default: throw this.unexpected();
1776
- }
1777
- }
1778
- parseConstValueLiteral() {
1779
- return this.parseValueLiteral(true);
1780
- }
1781
- parseStringLiteral() {
1782
- const token = this._lexer.token;
1783
- this.advanceLexer();
1784
- return this.node(token, {
1785
- kind: Kind.STRING,
1786
- value: token.value,
1787
- block: token.kind === TokenKind.BLOCK_STRING
1788
- });
1789
- }
1790
- /**
1791
- * ListValue[Const] :
1792
- * - [ ]
1793
- * - [ Value[?Const]+ ]
1794
- */
1795
- parseList(isConst) {
1796
- const item = () => this.parseValueLiteral(isConst);
1797
- return this.node(this._lexer.token, {
1798
- kind: Kind.LIST,
1799
- values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
1800
- });
1801
- }
1802
- /**
1803
- * ```
1804
- * ObjectValue[Const] :
1805
- * - { }
1806
- * - { ObjectField[?Const]+ }
1807
- * ```
1808
- */
1809
- parseObject(isConst) {
1810
- const item = () => this.parseObjectField(isConst);
1811
- return this.node(this._lexer.token, {
1812
- kind: Kind.OBJECT,
1813
- fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
1814
- });
1815
- }
1816
- /**
1817
- * ObjectField[Const] : Name : Value[?Const]
1818
- */
1819
- parseObjectField(isConst) {
1820
- const start = this._lexer.token;
1821
- const name = this.parseName();
1822
- this.expectToken(TokenKind.COLON);
1823
- return this.node(start, {
1824
- kind: Kind.OBJECT_FIELD,
1825
- name,
1826
- value: this.parseValueLiteral(isConst)
1827
- });
1828
- }
1829
- /**
1830
- * Directives[Const] : Directive[?Const]+
1831
- */
1832
- parseDirectives(isConst) {
1833
- const directives = [];
1834
- while (this.peek(TokenKind.AT)) directives.push(this.parseDirective(isConst));
1835
- return directives;
1836
- }
1837
- parseConstDirectives() {
1838
- return this.parseDirectives(true);
1839
- }
1840
- /**
1841
- * ```
1842
- * Directive[Const] : @ Name Arguments[?Const]?
1843
- * ```
1844
- */
1845
- parseDirective(isConst) {
1846
- const start = this._lexer.token;
1847
- this.expectToken(TokenKind.AT);
1848
- return this.node(start, {
1849
- kind: Kind.DIRECTIVE,
1850
- name: this.parseName(),
1851
- arguments: this.parseArguments(isConst)
1852
- });
1853
- }
1854
- /**
1855
- * Type :
1856
- * - NamedType
1857
- * - ListType
1858
- * - NonNullType
1859
- */
1860
- parseTypeReference() {
1861
- const start = this._lexer.token;
1862
- let type;
1863
- if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
1864
- const innerType = this.parseTypeReference();
1865
- this.expectToken(TokenKind.BRACKET_R);
1866
- type = this.node(start, {
1867
- kind: Kind.LIST_TYPE,
1868
- type: innerType
1869
- });
1870
- } else type = this.parseNamedType();
1871
- if (this.expectOptionalToken(TokenKind.BANG)) return this.node(start, {
1872
- kind: Kind.NON_NULL_TYPE,
1873
- type
1874
- });
1875
- return type;
1876
- }
1877
- /**
1878
- * NamedType : Name
1879
- */
1880
- parseNamedType() {
1881
- return this.node(this._lexer.token, {
1882
- kind: Kind.NAMED_TYPE,
1883
- name: this.parseName()
1884
- });
1885
- }
1886
- peekDescription() {
1887
- return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
1888
- }
1889
- /**
1890
- * Description : StringValue
1891
- */
1892
- parseDescription() {
1893
- if (this.peekDescription()) return this.parseStringLiteral();
1894
- }
1895
- /**
1896
- * ```
1897
- * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1898
- * ```
1899
- */
1900
- parseSchemaDefinition() {
1901
- const start = this._lexer.token;
1902
- const description = this.parseDescription();
1903
- this.expectKeyword("schema");
1904
- const directives = this.parseConstDirectives();
1905
- const operationTypes = this.many(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
1906
- return this.node(start, {
1907
- kind: Kind.SCHEMA_DEFINITION,
1908
- description,
1909
- directives,
1910
- operationTypes
1911
- });
1912
- }
1913
- /**
1914
- * OperationTypeDefinition : OperationType : NamedType
1915
- */
1916
- parseOperationTypeDefinition() {
1917
- const start = this._lexer.token;
1918
- const operation = this.parseOperationType();
1919
- this.expectToken(TokenKind.COLON);
1920
- const type = this.parseNamedType();
1921
- return this.node(start, {
1922
- kind: Kind.OPERATION_TYPE_DEFINITION,
1923
- operation,
1924
- type
1925
- });
1926
- }
1927
- /**
1928
- * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1929
- */
1930
- parseScalarTypeDefinition() {
1931
- const start = this._lexer.token;
1932
- const description = this.parseDescription();
1933
- this.expectKeyword("scalar");
1934
- const name = this.parseName();
1935
- const directives = this.parseConstDirectives();
1936
- return this.node(start, {
1937
- kind: Kind.SCALAR_TYPE_DEFINITION,
1938
- description,
1939
- name,
1940
- directives
1941
- });
1942
- }
1943
- /**
1944
- * ObjectTypeDefinition :
1945
- * Description?
1946
- * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1947
- */
1948
- parseObjectTypeDefinition() {
1949
- const start = this._lexer.token;
1950
- const description = this.parseDescription();
1951
- this.expectKeyword("type");
1952
- const name = this.parseName();
1953
- const interfaces = this.parseImplementsInterfaces();
1954
- const directives = this.parseConstDirectives();
1955
- const fields = this.parseFieldsDefinition();
1956
- return this.node(start, {
1957
- kind: Kind.OBJECT_TYPE_DEFINITION,
1958
- description,
1959
- name,
1960
- interfaces,
1961
- directives,
1962
- fields
1963
- });
1964
- }
1965
- /**
1966
- * ImplementsInterfaces :
1967
- * - implements `&`? NamedType
1968
- * - ImplementsInterfaces & NamedType
1969
- */
1970
- parseImplementsInterfaces() {
1971
- return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
1972
- }
1973
- /**
1974
- * ```
1975
- * FieldsDefinition : { FieldDefinition+ }
1976
- * ```
1977
- */
1978
- parseFieldsDefinition() {
1979
- return this.optionalMany(TokenKind.BRACE_L, this.parseFieldDefinition, TokenKind.BRACE_R);
1980
- }
1981
- /**
1982
- * FieldDefinition :
1983
- * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1984
- */
1985
- parseFieldDefinition() {
1986
- const start = this._lexer.token;
1987
- const description = this.parseDescription();
1988
- const name = this.parseName();
1989
- const args = this.parseArgumentDefs();
1990
- this.expectToken(TokenKind.COLON);
1991
- const type = this.parseTypeReference();
1992
- const directives = this.parseConstDirectives();
1993
- return this.node(start, {
1994
- kind: Kind.FIELD_DEFINITION,
1995
- description,
1996
- name,
1997
- arguments: args,
1998
- type,
1999
- directives
2000
- });
2001
- }
2002
- /**
2003
- * ArgumentsDefinition : ( InputValueDefinition+ )
2004
- */
2005
- parseArgumentDefs() {
2006
- return this.optionalMany(TokenKind.PAREN_L, this.parseInputValueDef, TokenKind.PAREN_R);
2007
- }
2008
- /**
2009
- * InputValueDefinition :
2010
- * - Description? Name : Type DefaultValue? Directives[Const]?
2011
- */
2012
- parseInputValueDef() {
2013
- const start = this._lexer.token;
2014
- const description = this.parseDescription();
2015
- const name = this.parseName();
2016
- this.expectToken(TokenKind.COLON);
2017
- const type = this.parseTypeReference();
2018
- let defaultValue;
2019
- if (this.expectOptionalToken(TokenKind.EQUALS)) defaultValue = this.parseConstValueLiteral();
2020
- const directives = this.parseConstDirectives();
2021
- return this.node(start, {
2022
- kind: Kind.INPUT_VALUE_DEFINITION,
2023
- description,
2024
- name,
2025
- type,
2026
- defaultValue,
2027
- directives
2028
- });
2029
- }
2030
- /**
2031
- * InterfaceTypeDefinition :
2032
- * - Description? interface Name Directives[Const]? FieldsDefinition?
2033
- */
2034
- parseInterfaceTypeDefinition() {
2035
- const start = this._lexer.token;
2036
- const description = this.parseDescription();
2037
- this.expectKeyword("interface");
2038
- const name = this.parseName();
2039
- const interfaces = this.parseImplementsInterfaces();
2040
- const directives = this.parseConstDirectives();
2041
- const fields = this.parseFieldsDefinition();
2042
- return this.node(start, {
2043
- kind: Kind.INTERFACE_TYPE_DEFINITION,
2044
- description,
2045
- name,
2046
- interfaces,
2047
- directives,
2048
- fields
2049
- });
2050
- }
2051
- /**
2052
- * UnionTypeDefinition :
2053
- * - Description? union Name Directives[Const]? UnionMemberTypes?
2054
- */
2055
- parseUnionTypeDefinition() {
2056
- const start = this._lexer.token;
2057
- const description = this.parseDescription();
2058
- this.expectKeyword("union");
2059
- const name = this.parseName();
2060
- const directives = this.parseConstDirectives();
2061
- const types = this.parseUnionMemberTypes();
2062
- return this.node(start, {
2063
- kind: Kind.UNION_TYPE_DEFINITION,
2064
- description,
2065
- name,
2066
- directives,
2067
- types
2068
- });
2069
- }
2070
- /**
2071
- * UnionMemberTypes :
2072
- * - = `|`? NamedType
2073
- * - UnionMemberTypes | NamedType
2074
- */
2075
- parseUnionMemberTypes() {
2076
- return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
2077
- }
2078
- /**
2079
- * EnumTypeDefinition :
2080
- * - Description? enum Name Directives[Const]? EnumValuesDefinition?
2081
- */
2082
- parseEnumTypeDefinition() {
2083
- const start = this._lexer.token;
2084
- const description = this.parseDescription();
2085
- this.expectKeyword("enum");
2086
- const name = this.parseName();
2087
- const directives = this.parseConstDirectives();
2088
- const values = this.parseEnumValuesDefinition();
2089
- return this.node(start, {
2090
- kind: Kind.ENUM_TYPE_DEFINITION,
2091
- description,
2092
- name,
2093
- directives,
2094
- values
2095
- });
2096
- }
2097
- /**
2098
- * ```
2099
- * EnumValuesDefinition : { EnumValueDefinition+ }
2100
- * ```
2101
- */
2102
- parseEnumValuesDefinition() {
2103
- return this.optionalMany(TokenKind.BRACE_L, this.parseEnumValueDefinition, TokenKind.BRACE_R);
2104
- }
2105
- /**
2106
- * EnumValueDefinition : Description? EnumValue Directives[Const]?
2107
- */
2108
- parseEnumValueDefinition() {
2109
- const start = this._lexer.token;
2110
- const description = this.parseDescription();
2111
- const name = this.parseEnumValueName();
2112
- const directives = this.parseConstDirectives();
2113
- return this.node(start, {
2114
- kind: Kind.ENUM_VALUE_DEFINITION,
2115
- description,
2116
- name,
2117
- directives
2118
- });
2119
- }
2120
- /**
2121
- * EnumValue : Name but not `true`, `false` or `null`
2122
- */
2123
- parseEnumValueName() {
2124
- 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.`);
2125
- return this.parseName();
2126
- }
2127
- /**
2128
- * InputObjectTypeDefinition :
2129
- * - Description? input Name Directives[Const]? InputFieldsDefinition?
2130
- */
2131
- parseInputObjectTypeDefinition() {
2132
- const start = this._lexer.token;
2133
- const description = this.parseDescription();
2134
- this.expectKeyword("input");
2135
- const name = this.parseName();
2136
- const directives = this.parseConstDirectives();
2137
- const fields = this.parseInputFieldsDefinition();
2138
- return this.node(start, {
2139
- kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
2140
- description,
2141
- name,
2142
- directives,
2143
- fields
2144
- });
2145
- }
2146
- /**
2147
- * ```
2148
- * InputFieldsDefinition : { InputValueDefinition+ }
2149
- * ```
2150
- */
2151
- parseInputFieldsDefinition() {
2152
- return this.optionalMany(TokenKind.BRACE_L, this.parseInputValueDef, TokenKind.BRACE_R);
2153
- }
2154
- /**
2155
- * TypeSystemExtension :
2156
- * - SchemaExtension
2157
- * - TypeExtension
2158
- *
2159
- * TypeExtension :
2160
- * - ScalarTypeExtension
2161
- * - ObjectTypeExtension
2162
- * - InterfaceTypeExtension
2163
- * - UnionTypeExtension
2164
- * - EnumTypeExtension
2165
- * - InputObjectTypeDefinition
2166
- */
2167
- parseTypeSystemExtension() {
2168
- const keywordToken = this._lexer.lookahead();
2169
- if (keywordToken.kind === TokenKind.NAME) switch (keywordToken.value) {
2170
- case "schema": return this.parseSchemaExtension();
2171
- case "scalar": return this.parseScalarTypeExtension();
2172
- case "type": return this.parseObjectTypeExtension();
2173
- case "interface": return this.parseInterfaceTypeExtension();
2174
- case "union": return this.parseUnionTypeExtension();
2175
- case "enum": return this.parseEnumTypeExtension();
2176
- case "input": return this.parseInputObjectTypeExtension();
2177
- }
2178
- throw this.unexpected(keywordToken);
2179
- }
2180
- /**
2181
- * ```
2182
- * SchemaExtension :
2183
- * - extend schema Directives[Const]? { OperationTypeDefinition+ }
2184
- * - extend schema Directives[Const]
2185
- * ```
2186
- */
2187
- parseSchemaExtension() {
2188
- const start = this._lexer.token;
2189
- this.expectKeyword("extend");
2190
- this.expectKeyword("schema");
2191
- const directives = this.parseConstDirectives();
2192
- const operationTypes = this.optionalMany(TokenKind.BRACE_L, this.parseOperationTypeDefinition, TokenKind.BRACE_R);
2193
- if (directives.length === 0 && operationTypes.length === 0) throw this.unexpected();
2194
- return this.node(start, {
2195
- kind: Kind.SCHEMA_EXTENSION,
2196
- directives,
2197
- operationTypes
2198
- });
2199
- }
2200
- /**
2201
- * ScalarTypeExtension :
2202
- * - extend scalar Name Directives[Const]
2203
- */
2204
- parseScalarTypeExtension() {
2205
- const start = this._lexer.token;
2206
- this.expectKeyword("extend");
2207
- this.expectKeyword("scalar");
2208
- const name = this.parseName();
2209
- const directives = this.parseConstDirectives();
2210
- if (directives.length === 0) throw this.unexpected();
2211
- return this.node(start, {
2212
- kind: Kind.SCALAR_TYPE_EXTENSION,
2213
- name,
2214
- directives
2215
- });
2216
- }
2217
- /**
2218
- * ObjectTypeExtension :
2219
- * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2220
- * - extend type Name ImplementsInterfaces? Directives[Const]
2221
- * - extend type Name ImplementsInterfaces
2222
- */
2223
- parseObjectTypeExtension() {
2224
- const start = this._lexer.token;
2225
- this.expectKeyword("extend");
2226
- this.expectKeyword("type");
2227
- const name = this.parseName();
2228
- const interfaces = this.parseImplementsInterfaces();
2229
- const directives = this.parseConstDirectives();
2230
- const fields = this.parseFieldsDefinition();
2231
- if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
2232
- return this.node(start, {
2233
- kind: Kind.OBJECT_TYPE_EXTENSION,
2234
- name,
2235
- interfaces,
2236
- directives,
2237
- fields
2238
- });
2239
- }
2240
- /**
2241
- * InterfaceTypeExtension :
2242
- * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2243
- * - extend interface Name ImplementsInterfaces? Directives[Const]
2244
- * - extend interface Name ImplementsInterfaces
2245
- */
2246
- parseInterfaceTypeExtension() {
2247
- const start = this._lexer.token;
2248
- this.expectKeyword("extend");
2249
- this.expectKeyword("interface");
2250
- const name = this.parseName();
2251
- const interfaces = this.parseImplementsInterfaces();
2252
- const directives = this.parseConstDirectives();
2253
- const fields = this.parseFieldsDefinition();
2254
- if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) throw this.unexpected();
2255
- return this.node(start, {
2256
- kind: Kind.INTERFACE_TYPE_EXTENSION,
2257
- name,
2258
- interfaces,
2259
- directives,
2260
- fields
2261
- });
2262
- }
2263
- /**
2264
- * UnionTypeExtension :
2265
- * - extend union Name Directives[Const]? UnionMemberTypes
2266
- * - extend union Name Directives[Const]
2267
- */
2268
- parseUnionTypeExtension() {
2269
- const start = this._lexer.token;
2270
- this.expectKeyword("extend");
2271
- this.expectKeyword("union");
2272
- const name = this.parseName();
2273
- const directives = this.parseConstDirectives();
2274
- const types = this.parseUnionMemberTypes();
2275
- if (directives.length === 0 && types.length === 0) throw this.unexpected();
2276
- return this.node(start, {
2277
- kind: Kind.UNION_TYPE_EXTENSION,
2278
- name,
2279
- directives,
2280
- types
2281
- });
2282
- }
2283
- /**
2284
- * EnumTypeExtension :
2285
- * - extend enum Name Directives[Const]? EnumValuesDefinition
2286
- * - extend enum Name Directives[Const]
2287
- */
2288
- parseEnumTypeExtension() {
2289
- const start = this._lexer.token;
2290
- this.expectKeyword("extend");
2291
- this.expectKeyword("enum");
2292
- const name = this.parseName();
2293
- const directives = this.parseConstDirectives();
2294
- const values = this.parseEnumValuesDefinition();
2295
- if (directives.length === 0 && values.length === 0) throw this.unexpected();
2296
- return this.node(start, {
2297
- kind: Kind.ENUM_TYPE_EXTENSION,
2298
- name,
2299
- directives,
2300
- values
2301
- });
2302
- }
2303
- /**
2304
- * InputObjectTypeExtension :
2305
- * - extend input Name Directives[Const]? InputFieldsDefinition
2306
- * - extend input Name Directives[Const]
2307
- */
2308
- parseInputObjectTypeExtension() {
2309
- const start = this._lexer.token;
2310
- this.expectKeyword("extend");
2311
- this.expectKeyword("input");
2312
- const name = this.parseName();
2313
- const directives = this.parseConstDirectives();
2314
- const fields = this.parseInputFieldsDefinition();
2315
- if (directives.length === 0 && fields.length === 0) throw this.unexpected();
2316
- return this.node(start, {
2317
- kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
2318
- name,
2319
- directives,
2320
- fields
2321
- });
2322
- }
2323
- /**
2324
- * ```
2325
- * DirectiveDefinition :
2326
- * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
2327
- * ```
2328
- */
2329
- parseDirectiveDefinition() {
2330
- const start = this._lexer.token;
2331
- const description = this.parseDescription();
2332
- this.expectKeyword("directive");
2333
- this.expectToken(TokenKind.AT);
2334
- const name = this.parseName();
2335
- const args = this.parseArgumentDefs();
2336
- const repeatable = this.expectOptionalKeyword("repeatable");
2337
- this.expectKeyword("on");
2338
- const locations = this.parseDirectiveLocations();
2339
- return this.node(start, {
2340
- kind: Kind.DIRECTIVE_DEFINITION,
2341
- description,
2342
- name,
2343
- arguments: args,
2344
- repeatable,
2345
- locations
2346
- });
2347
- }
2348
- /**
2349
- * DirectiveLocations :
2350
- * - `|`? DirectiveLocation
2351
- * - DirectiveLocations | DirectiveLocation
2352
- */
2353
- parseDirectiveLocations() {
2354
- return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
2355
- }
2356
- parseDirectiveLocation() {
2357
- const start = this._lexer.token;
2358
- const name = this.parseName();
2359
- if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) return name;
2360
- throw this.unexpected(start);
2361
- }
2362
- /**
2363
- * SchemaCoordinate :
2364
- * - Name
2365
- * - Name . Name
2366
- * - Name . Name ( Name : )
2367
- * - \@ Name
2368
- * - \@ Name ( Name : )
2369
- */
2370
- parseSchemaCoordinate() {
2371
- const start = this._lexer.token;
2372
- const ofDirective = this.expectOptionalToken(TokenKind.AT);
2373
- const name = this.parseName();
2374
- let memberName;
2375
- if (!ofDirective && this.expectOptionalToken(TokenKind.DOT)) memberName = this.parseName();
2376
- let argumentName;
2377
- if ((ofDirective || memberName) && this.expectOptionalToken(TokenKind.PAREN_L)) {
2378
- argumentName = this.parseName();
2379
- this.expectToken(TokenKind.COLON);
2380
- this.expectToken(TokenKind.PAREN_R);
2381
- }
2382
- if (ofDirective) {
2383
- if (argumentName) return this.node(start, {
2384
- kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
2385
- name,
2386
- argumentName
2387
- });
2388
- return this.node(start, {
2389
- kind: Kind.DIRECTIVE_COORDINATE,
2390
- name
2391
- });
2392
- } else if (memberName) {
2393
- if (argumentName) return this.node(start, {
2394
- kind: Kind.ARGUMENT_COORDINATE,
2395
- name,
2396
- fieldName: memberName,
2397
- argumentName
2398
- });
2399
- return this.node(start, {
2400
- kind: Kind.MEMBER_COORDINATE,
2401
- name,
2402
- memberName
2403
- });
2404
- }
2405
- return this.node(start, {
2406
- kind: Kind.TYPE_COORDINATE,
2407
- name
2408
- });
2409
- }
2410
- /**
2411
- * Returns a node that, if configured to do so, sets a "loc" field as a
2412
- * location object, used to identify the place in the source that created a
2413
- * given parsed object.
2414
- */
2415
- node(startToken, node) {
2416
- if (this._options.noLocation !== true) node.loc = new Location(startToken, this._lexer.lastToken, this._lexer.source);
2417
- return node;
2418
- }
2419
- /**
2420
- * Determines if the next token is of a given kind
2421
- */
2422
- peek(kind) {
2423
- return this._lexer.token.kind === kind;
2424
- }
2425
- /**
2426
- * If the next token is of the given kind, return that token after advancing the lexer.
2427
- * Otherwise, do not change the parser state and throw an error.
2428
- */
2429
- expectToken(kind) {
2430
- const token = this._lexer.token;
2431
- if (token.kind === kind) {
2432
- this.advanceLexer();
2433
- return token;
2434
- }
2435
- throw syntaxError(this._lexer.source, token.start, `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`);
2436
- }
2437
- /**
2438
- * If the next token is of the given kind, return "true" after advancing the lexer.
2439
- * Otherwise, do not change the parser state and return "false".
2440
- */
2441
- expectOptionalToken(kind) {
2442
- if (this._lexer.token.kind === kind) {
2443
- this.advanceLexer();
2444
- return true;
2445
- }
2446
- return false;
2447
- }
2448
- /**
2449
- * If the next token is a given keyword, advance the lexer.
2450
- * Otherwise, do not change the parser state and throw an error.
2451
- */
2452
- expectKeyword(value) {
2453
- const token = this._lexer.token;
2454
- if (token.kind === TokenKind.NAME && token.value === value) this.advanceLexer();
2455
- else throw syntaxError(this._lexer.source, token.start, `Expected "${value}", found ${getTokenDesc(token)}.`);
2456
- }
2457
- /**
2458
- * If the next token is a given keyword, return "true" after advancing the lexer.
2459
- * Otherwise, do not change the parser state and return "false".
2460
- */
2461
- expectOptionalKeyword(value) {
2462
- const token = this._lexer.token;
2463
- if (token.kind === TokenKind.NAME && token.value === value) {
2464
- this.advanceLexer();
2465
- return true;
2466
- }
2467
- return false;
2468
- }
2469
- /**
2470
- * Helper function for creating an error when an unexpected lexed token is encountered.
2471
- */
2472
- unexpected(atToken) {
2473
- const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
2474
- return syntaxError(this._lexer.source, token.start, `Unexpected ${getTokenDesc(token)}.`);
2475
- }
2476
- /**
2477
- * Returns a possibly empty list of parse nodes, determined by the parseFn.
2478
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2479
- * Advances the parser to the next lex token after the closing token.
2480
- */
2481
- any(openKind, parseFn, closeKind) {
2482
- this.expectToken(openKind);
2483
- const nodes = [];
2484
- while (!this.expectOptionalToken(closeKind)) nodes.push(parseFn.call(this));
2485
- return nodes;
2486
- }
2487
- /**
2488
- * Returns a list of parse nodes, determined by the parseFn.
2489
- * It can be empty only if open token is missing otherwise it will always return non-empty list
2490
- * that begins with a lex token of openKind and ends with a lex token of closeKind.
2491
- * Advances the parser to the next lex token after the closing token.
2492
- */
2493
- optionalMany(openKind, parseFn, closeKind) {
2494
- if (this.expectOptionalToken(openKind)) {
2495
- const nodes = [];
2496
- do
2497
- nodes.push(parseFn.call(this));
2498
- while (!this.expectOptionalToken(closeKind));
2499
- return nodes;
2500
- }
2501
- return [];
2502
- }
2503
- /**
2504
- * Returns a non-empty list of parse nodes, determined by the parseFn.
2505
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2506
- * Advances the parser to the next lex token after the closing token.
2507
- */
2508
- many(openKind, parseFn, closeKind) {
2509
- this.expectToken(openKind);
2510
- const nodes = [];
2511
- do
2512
- nodes.push(parseFn.call(this));
2513
- while (!this.expectOptionalToken(closeKind));
2514
- return nodes;
2515
- }
2516
- /**
2517
- * Returns a non-empty list of parse nodes, determined by the parseFn.
2518
- * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2519
- * Advances the parser to the next lex token after last item in the list.
2520
- */
2521
- delimitedMany(delimiterKind, parseFn) {
2522
- this.expectOptionalToken(delimiterKind);
2523
- const nodes = [];
2524
- do
2525
- nodes.push(parseFn.call(this));
2526
- while (this.expectOptionalToken(delimiterKind));
2527
- return nodes;
2528
- }
2529
- advanceLexer() {
2530
- const { maxTokens } = this._options;
2531
- const token = this._lexer.advance();
2532
- if (token.kind !== TokenKind.EOF) {
2533
- ++this._tokenCounter;
2534
- if (maxTokens !== void 0 && this._tokenCounter > maxTokens) throw syntaxError(this._lexer.source, token.start, `Document contains more that ${maxTokens} tokens. Parsing aborted.`);
2535
- }
2536
- }
2537
- };
2538
- /**
2539
- * A helper function to describe a token as a string for debugging.
2540
- */
2541
- function getTokenDesc(token) {
2542
- const value = token.value;
2543
- return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
2544
- }
2545
- /**
2546
- * A helper function to describe a token kind as a string for debugging.
2547
- */
2548
- function getTokenKindDesc(kind) {
2549
- return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
2550
- }
2551
- //#endregion
2552
- 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 };
2553
-
2554
- //# sourceMappingURL=parser-DtbeHA3H.js.map