@noxickon/onyx 0.0.4-dev.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/chunks/hooks-DiKvsNs-.js +48 -0
  2. package/dist/chunks/hooks-bJFfbTks.js +8624 -0
  3. package/dist/chunks/query-BhvXa-m6.js +10 -0
  4. package/dist/chunks/query-iDn3qBGF.js +14 -0
  5. package/dist/chunks/ui-ChsTPgui.js +41 -0
  6. package/dist/chunks/ui-DxsSYHCv.js +20634 -0
  7. package/dist/chunks/useAuth-BFgXzu6Q.js +12 -0
  8. package/dist/chunks/useAuth-DxoDe3YA.js +1 -0
  9. package/dist/contexts/contexts.cjs.js +5 -0
  10. package/dist/contexts/contexts.es.js +156 -0
  11. package/dist/contexts.d.ts +117 -0
  12. package/dist/hooks/hooks.cjs.js +1 -6
  13. package/dist/hooks/hooks.es.js +11 -1916
  14. package/dist/hooks.d.ts +84 -22
  15. package/dist/index.d.ts +1782 -268
  16. package/dist/layouts/layouts.cjs.js +1 -0
  17. package/dist/layouts/layouts.es.js +688 -0
  18. package/dist/layouts.d.ts +430 -0
  19. package/dist/onyx.cjs.js +1 -1
  20. package/dist/onyx.es.js +53 -1395
  21. package/dist/pages/pages.cjs.js +2 -2
  22. package/dist/pages/pages.es.js +72 -70
  23. package/dist/pages.d.ts +4 -4
  24. package/dist/routes/routes.cjs.js +1 -0
  25. package/dist/routes/routes.es.js +31 -0
  26. package/dist/routes.d.ts +28 -0
  27. package/dist/shared.css +77 -48
  28. package/dist/ui.css +1 -0
  29. package/dist/utils/utils.cjs.js +1 -1
  30. package/dist/utils/utils.es.js +20 -6
  31. package/dist/utils.d.ts +109 -5
  32. package/package.json +39 -28
  33. package/dist/chunks/AuthContext-CaZKJMxQ.js +0 -2149
  34. package/dist/chunks/AuthContext-uU1aP9gj.js +0 -31
  35. package/dist/chunks/Button-D-v4l8ZE.js +0 -20
  36. package/dist/chunks/Button-bARrxYyo.js +0 -11053
  37. package/dist/chunks/Input-CLi1H63d.js +0 -1
  38. package/dist/chunks/Input-dfvmdIHi.js +0 -138
  39. package/dist/chunks/_commonjsHelpers-C6fGbg64.js +0 -6
  40. package/dist/chunks/_commonjsHelpers-DwGv2jUC.js +0 -1
  41. package/dist/chunks/constants-B1_n9ezb.js +0 -1
  42. package/dist/chunks/constants-CDXq37n6.js +0 -4
  43. package/dist/chunks/errorHelper--G-SWQzN.js +0 -18
  44. package/dist/chunks/errorHelper-DaP_XxEx.js +0 -1
  45. package/dist/chunks/formatTimestamp-CMxOnPo1.js +0 -12
  46. package/dist/chunks/formatTimestamp-TTsNcy7u.js +0 -1
  47. package/dist/chunks/index-CPwC_oqh.js +0 -561
  48. package/dist/chunks/index-DY808_YF.js +0 -2
  49. package/dist/chunks/isObject-BDHKUJKN.js +0 -1
  50. package/dist/chunks/isObject-vmP43YLW.js +0 -6
  51. package/dist/chunks/jsx-runtime--oOP9f8K.js +0 -284
  52. package/dist/chunks/jsx-runtime-CITbqOLs.js +0 -22
  53. package/dist/chunks/tslib.es6-ci7D5hcx.js +0 -44
  54. package/dist/chunks/tslib.es6-nRfFZWHa.js +0 -1
  55. package/dist/chunks/useAuth-BsWbsZD5.js +0 -1
  56. package/dist/chunks/useAuth-CkaMowHd.js +0 -11
  57. package/dist/chunks/useForm-DfmfCtGn.js +0 -3070
  58. package/dist/chunks/useForm-OVVxm4qZ.js +0 -18
  59. package/dist/chunks/useQuery-Dh3SZN5S.js +0 -1482
  60. package/dist/chunks/useQuery-y4De9xeL.js +0 -2
  61. package/dist/context/context.cjs.js +0 -1
  62. package/dist/context/context.es.js +0 -39
  63. package/dist/context.d.ts +0 -47
  64. package/dist/index.css +0 -1
  65. package/dist/layout/layout.cjs.js +0 -1
  66. package/dist/layout/layout.es.js +0 -265
  67. package/dist/layout.d.ts +0 -90
@@ -1,2149 +0,0 @@
1
- import { _ as M } from "./tslib.es6-ci7D5hcx.js";
2
- import { createContext as ee } from "react";
3
- function L(e, t) {
4
- if (!!!e)
5
- throw new Error(t);
6
- }
7
- function te(e) {
8
- return typeof e == "object" && e !== null;
9
- }
10
- function ne(e, t) {
11
- if (!!!e)
12
- throw new Error(
13
- "Unexpected invariant triggered."
14
- );
15
- }
16
- const ie = /\r\n|[\n\r]/g;
17
- function F(e, t) {
18
- let n = 0, s = 1;
19
- for (const i of e.body.matchAll(ie)) {
20
- if (typeof i.index == "number" || ne(!1), i.index >= t)
21
- break;
22
- n = i.index + i[0].length, s += 1;
23
- }
24
- return {
25
- line: s,
26
- column: t + 1 - n
27
- };
28
- }
29
- function se(e) {
30
- return G(
31
- e.source,
32
- F(e.source, e.start)
33
- );
34
- }
35
- function G(e, t) {
36
- const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, i = t.line - 1, r = e.locationOffset.line - 1, a = t.line + r, u = t.line === 1 ? n : 0, l = t.column + u, E = `${e.name}:${a}:${l}
37
- `, p = s.split(/\r\n|[\n\r]/g), N = p[i];
38
- if (N.length > 120) {
39
- const m = Math.floor(l / 80), b = l % 80, f = [];
40
- for (let I = 0; I < N.length; I += 80)
41
- f.push(N.slice(I, I + 80));
42
- return E + V([
43
- [`${a} |`, f[0]],
44
- ...f.slice(1, m + 1).map((I) => ["|", I]),
45
- ["|", "^".padStart(b)],
46
- ["|", f[m + 1]]
47
- ]);
48
- }
49
- return E + V([
50
- // Lines specified like this: ["prefix", "string"],
51
- [`${a - 1} |`, p[i - 1]],
52
- [`${a} |`, N],
53
- ["|", "^".padStart(l)],
54
- [`${a + 1} |`, p[i + 1]]
55
- ]);
56
- }
57
- function V(e) {
58
- const t = e.filter(([s, i]) => i !== void 0), n = Math.max(...t.map(([s]) => s.length));
59
- return t.map(([s, i]) => s.padStart(n) + (i ? " " + i : "")).join(`
60
- `);
61
- }
62
- function re(e) {
63
- const t = e[0];
64
- return t == null || "kind" in t || "length" in t ? {
65
- nodes: t,
66
- source: e[1],
67
- positions: e[2],
68
- path: e[3],
69
- originalError: e[4],
70
- extensions: e[5]
71
- } : t;
72
- }
73
- class U extends Error {
74
- /**
75
- * An array of `{ line, column }` locations within the source GraphQL document
76
- * which correspond to this error.
77
- *
78
- * Errors during validation often contain multiple locations, for example to
79
- * point out two things with the same name. Errors during execution include a
80
- * single location, the field which produced the error.
81
- *
82
- * Enumerable, and appears in the result of JSON.stringify().
83
- */
84
- /**
85
- * An array describing the JSON-path into the execution response which
86
- * corresponds to this error. Only included for errors during execution.
87
- *
88
- * Enumerable, and appears in the result of JSON.stringify().
89
- */
90
- /**
91
- * An array of GraphQL AST Nodes corresponding to this error.
92
- */
93
- /**
94
- * The source GraphQL document for the first location of this error.
95
- *
96
- * Note that if this Error represents more than one node, the source may not
97
- * represent nodes after the first node.
98
- */
99
- /**
100
- * An array of character offsets within the source GraphQL document
101
- * which correspond to this error.
102
- */
103
- /**
104
- * The original error thrown from a field resolver during execution.
105
- */
106
- /**
107
- * Extension fields to add to the formatted error.
108
- */
109
- /**
110
- * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
111
- */
112
- constructor(t, ...n) {
113
- var s, i, r;
114
- const { nodes: a, source: u, positions: l, path: E, originalError: p, extensions: N } = re(n);
115
- super(t), this.name = "GraphQLError", this.path = E ?? void 0, this.originalError = p ?? void 0, this.nodes = B(
116
- Array.isArray(a) ? a : a ? [a] : void 0
117
- );
118
- const m = B(
119
- (s = this.nodes) === null || s === void 0 ? void 0 : s.map((f) => f.loc).filter((f) => f != null)
120
- );
121
- this.source = u ?? (m == null || (i = m[0]) === null || i === void 0 ? void 0 : i.source), this.positions = l ?? m?.map((f) => f.start), this.locations = l && u ? l.map((f) => F(u, f)) : m?.map((f) => F(f.source, f.start));
122
- const b = te(
123
- p?.extensions
124
- ) ? p?.extensions : void 0;
125
- this.extensions = (r = N ?? b) !== null && r !== void 0 ? r : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
126
- message: {
127
- writable: !0,
128
- enumerable: !0
129
- },
130
- name: {
131
- enumerable: !1
132
- },
133
- nodes: {
134
- enumerable: !1
135
- },
136
- source: {
137
- enumerable: !1
138
- },
139
- positions: {
140
- enumerable: !1
141
- },
142
- originalError: {
143
- enumerable: !1
144
- }
145
- }), p != null && p.stack ? Object.defineProperty(this, "stack", {
146
- value: p.stack,
147
- writable: !0,
148
- configurable: !0
149
- }) : Error.captureStackTrace ? Error.captureStackTrace(this, U) : Object.defineProperty(this, "stack", {
150
- value: Error().stack,
151
- writable: !0,
152
- configurable: !0
153
- });
154
- }
155
- get [Symbol.toStringTag]() {
156
- return "GraphQLError";
157
- }
158
- toString() {
159
- let t = this.message;
160
- if (this.nodes)
161
- for (const n of this.nodes)
162
- n.loc && (t += `
163
-
164
- ` + se(n.loc));
165
- else if (this.source && this.locations)
166
- for (const n of this.locations)
167
- t += `
168
-
169
- ` + G(this.source, n);
170
- return t;
171
- }
172
- toJSON() {
173
- const t = {
174
- message: this.message
175
- };
176
- return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t;
177
- }
178
- }
179
- function B(e) {
180
- return e === void 0 || e.length === 0 ? void 0 : e;
181
- }
182
- function d(e, t, n) {
183
- return new U(`Syntax Error: ${n}`, {
184
- source: e,
185
- positions: [t]
186
- });
187
- }
188
- class oe {
189
- /**
190
- * The character offset at which this Node begins.
191
- */
192
- /**
193
- * The character offset at which this Node ends.
194
- */
195
- /**
196
- * The Token at which this Node begins.
197
- */
198
- /**
199
- * The Token at which this Node ends.
200
- */
201
- /**
202
- * The Source document the AST represents.
203
- */
204
- constructor(t, n, s) {
205
- this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = s;
206
- }
207
- get [Symbol.toStringTag]() {
208
- return "Location";
209
- }
210
- toJSON() {
211
- return {
212
- start: this.start,
213
- end: this.end
214
- };
215
- }
216
- }
217
- class Y {
218
- /**
219
- * The kind of Token.
220
- */
221
- /**
222
- * The character offset at which this Node begins.
223
- */
224
- /**
225
- * The character offset at which this Node ends.
226
- */
227
- /**
228
- * The 1-indexed line number on which this Token appears.
229
- */
230
- /**
231
- * The 1-indexed column number at which this Token begins.
232
- */
233
- /**
234
- * For non-punctuation tokens, represents the interpreted value of the token.
235
- *
236
- * Note: is undefined for punctuation tokens, but typed as string for
237
- * convenience in the parser.
238
- */
239
- /**
240
- * Tokens exist as nodes in a double-linked-list amongst all tokens
241
- * including ignored tokens. <SOF> is always the first node and <EOF>
242
- * the last.
243
- */
244
- constructor(t, n, s, i, r, a) {
245
- this.kind = t, this.start = n, this.end = s, this.line = i, this.column = r, this.value = a, this.prev = null, this.next = null;
246
- }
247
- get [Symbol.toStringTag]() {
248
- return "Token";
249
- }
250
- toJSON() {
251
- return {
252
- kind: this.kind,
253
- value: this.value,
254
- line: this.line,
255
- column: this.column
256
- };
257
- }
258
- }
259
- const ae = {
260
- Name: [],
261
- Document: ["definitions"],
262
- OperationDefinition: [
263
- "name",
264
- "variableDefinitions",
265
- "directives",
266
- "selectionSet"
267
- ],
268
- VariableDefinition: ["variable", "type", "defaultValue", "directives"],
269
- Variable: ["name"],
270
- SelectionSet: ["selections"],
271
- Field: ["alias", "name", "arguments", "directives", "selectionSet"],
272
- Argument: ["name", "value"],
273
- FragmentSpread: ["name", "directives"],
274
- InlineFragment: ["typeCondition", "directives", "selectionSet"],
275
- FragmentDefinition: [
276
- "name",
277
- // Note: fragment variable definitions are deprecated and will removed in v17.0.0
278
- "variableDefinitions",
279
- "typeCondition",
280
- "directives",
281
- "selectionSet"
282
- ],
283
- IntValue: [],
284
- FloatValue: [],
285
- StringValue: [],
286
- BooleanValue: [],
287
- NullValue: [],
288
- EnumValue: [],
289
- ListValue: ["values"],
290
- ObjectValue: ["fields"],
291
- ObjectField: ["name", "value"],
292
- Directive: ["name", "arguments"],
293
- NamedType: ["name"],
294
- ListType: ["type"],
295
- NonNullType: ["type"],
296
- SchemaDefinition: ["description", "directives", "operationTypes"],
297
- OperationTypeDefinition: ["type"],
298
- ScalarTypeDefinition: ["description", "name", "directives"],
299
- ObjectTypeDefinition: [
300
- "description",
301
- "name",
302
- "interfaces",
303
- "directives",
304
- "fields"
305
- ],
306
- FieldDefinition: ["description", "name", "arguments", "type", "directives"],
307
- InputValueDefinition: [
308
- "description",
309
- "name",
310
- "type",
311
- "defaultValue",
312
- "directives"
313
- ],
314
- InterfaceTypeDefinition: [
315
- "description",
316
- "name",
317
- "interfaces",
318
- "directives",
319
- "fields"
320
- ],
321
- UnionTypeDefinition: ["description", "name", "directives", "types"],
322
- EnumTypeDefinition: ["description", "name", "directives", "values"],
323
- EnumValueDefinition: ["description", "name", "directives"],
324
- InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
325
- DirectiveDefinition: ["description", "name", "arguments", "locations"],
326
- SchemaExtension: ["directives", "operationTypes"],
327
- ScalarTypeExtension: ["name", "directives"],
328
- ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
329
- InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
330
- UnionTypeExtension: ["name", "directives", "types"],
331
- EnumTypeExtension: ["name", "directives", "values"],
332
- InputObjectTypeExtension: ["name", "directives", "fields"]
333
- };
334
- new Set(Object.keys(ae));
335
- var x;
336
- (function(e) {
337
- e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
338
- })(x || (x = {}));
339
- var w;
340
- (function(e) {
341
- e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
342
- })(w || (w = {}));
343
- var c;
344
- (function(e) {
345
- e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
346
- })(c || (c = {}));
347
- function ce(e) {
348
- return e === 9 || e === 32;
349
- }
350
- function D(e) {
351
- return e >= 48 && e <= 57;
352
- }
353
- function $(e) {
354
- return e >= 97 && e <= 122 || // A-Z
355
- e >= 65 && e <= 90;
356
- }
357
- function J(e) {
358
- return $(e) || e === 95;
359
- }
360
- function ue(e) {
361
- return $(e) || D(e) || e === 95;
362
- }
363
- function le(e) {
364
- var t;
365
- let n = Number.MAX_SAFE_INTEGER, s = null, i = -1;
366
- for (let a = 0; a < e.length; ++a) {
367
- var r;
368
- const u = e[a], l = he(u);
369
- l !== u.length && (s = (r = s) !== null && r !== void 0 ? r : a, i = a, a !== 0 && l < n && (n = l));
370
- }
371
- return e.map((a, u) => u === 0 ? a : a.slice(n)).slice(
372
- (t = s) !== null && t !== void 0 ? t : 0,
373
- i + 1
374
- );
375
- }
376
- function he(e) {
377
- let t = 0;
378
- for (; t < e.length && ce(e.charCodeAt(t)); )
379
- ++t;
380
- return t;
381
- }
382
- var o;
383
- (function(e) {
384
- e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
385
- })(o || (o = {}));
386
- class pe {
387
- /**
388
- * The previously focused non-ignored token.
389
- */
390
- /**
391
- * The currently focused non-ignored token.
392
- */
393
- /**
394
- * The (1-indexed) line containing the current token.
395
- */
396
- /**
397
- * The character offset at which the current line begins.
398
- */
399
- constructor(t) {
400
- const n = new Y(o.SOF, 0, 0, 0, 0);
401
- this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
402
- }
403
- get [Symbol.toStringTag]() {
404
- return "Lexer";
405
- }
406
- /**
407
- * Advances the token stream to the next non-ignored token.
408
- */
409
- advance() {
410
- return this.lastToken = this.token, this.token = this.lookahead();
411
- }
412
- /**
413
- * Looks ahead and returns the next non-ignored token, but does not change
414
- * the state of Lexer.
415
- */
416
- lookahead() {
417
- let t = this.token;
418
- if (t.kind !== o.EOF)
419
- do
420
- if (t.next)
421
- t = t.next;
422
- else {
423
- const n = fe(this, t.end);
424
- t.next = n, n.prev = t, t = n;
425
- }
426
- while (t.kind === o.COMMENT);
427
- return t;
428
- }
429
- }
430
- function de(e) {
431
- return e === o.BANG || e === o.DOLLAR || e === o.AMP || e === o.PAREN_L || e === o.PAREN_R || e === o.SPREAD || e === o.COLON || e === o.EQUALS || e === o.AT || e === o.BRACKET_L || e === o.BRACKET_R || e === o.BRACE_L || e === o.PIPE || e === o.BRACE_R;
432
- }
433
- function _(e) {
434
- return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
435
- }
436
- function k(e, t) {
437
- return X(e.charCodeAt(t)) && q(e.charCodeAt(t + 1));
438
- }
439
- function X(e) {
440
- return e >= 55296 && e <= 56319;
441
- }
442
- function q(e) {
443
- return e >= 56320 && e <= 57343;
444
- }
445
- function T(e, t) {
446
- const n = e.source.body.codePointAt(t);
447
- if (n === void 0)
448
- return o.EOF;
449
- if (n >= 32 && n <= 126) {
450
- const s = String.fromCodePoint(n);
451
- return s === '"' ? `'"'` : `"${s}"`;
452
- }
453
- return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
454
- }
455
- function h(e, t, n, s, i) {
456
- const r = e.line, a = 1 + n - e.lineStart;
457
- return new Y(t, n, s, r, a, i);
458
- }
459
- function fe(e, t) {
460
- const n = e.source.body, s = n.length;
461
- let i = t;
462
- for (; i < s; ) {
463
- const r = n.charCodeAt(i);
464
- switch (r) {
465
- // Ignored ::
466
- // - UnicodeBOM
467
- // - WhiteSpace
468
- // - LineTerminator
469
- // - Comment
470
- // - Comma
471
- //
472
- // UnicodeBOM :: "Byte Order Mark (U+FEFF)"
473
- //
474
- // WhiteSpace ::
475
- // - "Horizontal Tab (U+0009)"
476
- // - "Space (U+0020)"
477
- //
478
- // Comma :: ,
479
- case 65279:
480
- // <BOM>
481
- case 9:
482
- // \t
483
- case 32:
484
- // <space>
485
- case 44:
486
- ++i;
487
- continue;
488
- // LineTerminator ::
489
- // - "New Line (U+000A)"
490
- // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
491
- // - "Carriage Return (U+000D)" "New Line (U+000A)"
492
- case 10:
493
- ++i, ++e.line, e.lineStart = i;
494
- continue;
495
- case 13:
496
- n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
497
- continue;
498
- // Comment
499
- case 35:
500
- return Ee(e, i);
501
- // Token ::
502
- // - Punctuator
503
- // - Name
504
- // - IntValue
505
- // - FloatValue
506
- // - StringValue
507
- //
508
- // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
509
- case 33:
510
- return h(e, o.BANG, i, i + 1);
511
- case 36:
512
- return h(e, o.DOLLAR, i, i + 1);
513
- case 38:
514
- return h(e, o.AMP, i, i + 1);
515
- case 40:
516
- return h(e, o.PAREN_L, i, i + 1);
517
- case 41:
518
- return h(e, o.PAREN_R, i, i + 1);
519
- case 46:
520
- if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
521
- return h(e, o.SPREAD, i, i + 3);
522
- break;
523
- case 58:
524
- return h(e, o.COLON, i, i + 1);
525
- case 61:
526
- return h(e, o.EQUALS, i, i + 1);
527
- case 64:
528
- return h(e, o.AT, i, i + 1);
529
- case 91:
530
- return h(e, o.BRACKET_L, i, i + 1);
531
- case 93:
532
- return h(e, o.BRACKET_R, i, i + 1);
533
- case 123:
534
- return h(e, o.BRACE_L, i, i + 1);
535
- case 124:
536
- return h(e, o.PIPE, i, i + 1);
537
- case 125:
538
- return h(e, o.BRACE_R, i, i + 1);
539
- // StringValue
540
- case 34:
541
- return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? Oe(e, i) : Ne(e, i);
542
- }
543
- if (D(r) || r === 45)
544
- return me(e, i, r);
545
- if (J(r))
546
- return _e(e, i);
547
- throw d(
548
- e.source,
549
- i,
550
- r === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : _(r) || k(n, i) ? `Unexpected character: ${T(e, i)}.` : `Invalid character: ${T(e, i)}.`
551
- );
552
- }
553
- return h(e, o.EOF, s, s);
554
- }
555
- function Ee(e, t) {
556
- const n = e.source.body, s = n.length;
557
- let i = t + 1;
558
- for (; i < s; ) {
559
- const r = n.charCodeAt(i);
560
- if (r === 10 || r === 13)
561
- break;
562
- if (_(r))
563
- ++i;
564
- else if (k(n, i))
565
- i += 2;
566
- else
567
- break;
568
- }
569
- return h(
570
- e,
571
- o.COMMENT,
572
- t,
573
- i,
574
- n.slice(t + 1, i)
575
- );
576
- }
577
- function me(e, t, n) {
578
- const s = e.source.body;
579
- let i = t, r = n, a = !1;
580
- if (r === 45 && (r = s.charCodeAt(++i)), r === 48) {
581
- if (r = s.charCodeAt(++i), D(r))
582
- throw d(
583
- e.source,
584
- i,
585
- `Invalid number, unexpected digit after 0: ${T(
586
- e,
587
- i
588
- )}.`
589
- );
590
- } else
591
- i = R(e, i, r), r = s.charCodeAt(i);
592
- if (r === 46 && (a = !0, r = s.charCodeAt(++i), i = R(e, i, r), r = s.charCodeAt(i)), (r === 69 || r === 101) && (a = !0, r = s.charCodeAt(++i), (r === 43 || r === 45) && (r = s.charCodeAt(++i)), i = R(e, i, r), r = s.charCodeAt(i)), r === 46 || J(r))
593
- throw d(
594
- e.source,
595
- i,
596
- `Invalid number, expected digit but got: ${T(
597
- e,
598
- i
599
- )}.`
600
- );
601
- return h(
602
- e,
603
- a ? o.FLOAT : o.INT,
604
- t,
605
- i,
606
- s.slice(t, i)
607
- );
608
- }
609
- function R(e, t, n) {
610
- if (!D(n))
611
- throw d(
612
- e.source,
613
- t,
614
- `Invalid number, expected digit but got: ${T(
615
- e,
616
- t
617
- )}.`
618
- );
619
- const s = e.source.body;
620
- let i = t + 1;
621
- for (; D(s.charCodeAt(i)); )
622
- ++i;
623
- return i;
624
- }
625
- function Ne(e, t) {
626
- const n = e.source.body, s = n.length;
627
- let i = t + 1, r = i, a = "";
628
- for (; i < s; ) {
629
- const u = n.charCodeAt(i);
630
- if (u === 34)
631
- return a += n.slice(r, i), h(e, o.STRING, t, i + 1, a);
632
- if (u === 92) {
633
- a += n.slice(r, i);
634
- const l = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? Te(e, i) : Ie(e, i) : xe(e, i);
635
- a += l.value, i += l.size, r = i;
636
- continue;
637
- }
638
- if (u === 10 || u === 13)
639
- break;
640
- if (_(u))
641
- ++i;
642
- else if (k(n, i))
643
- i += 2;
644
- else
645
- throw d(
646
- e.source,
647
- i,
648
- `Invalid character within String: ${T(
649
- e,
650
- i
651
- )}.`
652
- );
653
- }
654
- throw d(e.source, i, "Unterminated string.");
655
- }
656
- function Te(e, t) {
657
- const n = e.source.body;
658
- let s = 0, i = 3;
659
- for (; i < 12; ) {
660
- const r = n.charCodeAt(t + i++);
661
- if (r === 125) {
662
- if (i < 5 || !_(s))
663
- break;
664
- return {
665
- value: String.fromCodePoint(s),
666
- size: i
667
- };
668
- }
669
- if (s = s << 4 | y(r), s < 0)
670
- break;
671
- }
672
- throw d(
673
- e.source,
674
- t,
675
- `Invalid Unicode escape sequence: "${n.slice(
676
- t,
677
- t + i
678
- )}".`
679
- );
680
- }
681
- function Ie(e, t) {
682
- const n = e.source.body, s = j(n, t + 2);
683
- if (_(s))
684
- return {
685
- value: String.fromCodePoint(s),
686
- size: 6
687
- };
688
- if (X(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
689
- const i = j(n, t + 8);
690
- if (q(i))
691
- return {
692
- value: String.fromCodePoint(s, i),
693
- size: 12
694
- };
695
- }
696
- throw d(
697
- e.source,
698
- t,
699
- `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
700
- );
701
- }
702
- function j(e, t) {
703
- return y(e.charCodeAt(t)) << 12 | y(e.charCodeAt(t + 1)) << 8 | y(e.charCodeAt(t + 2)) << 4 | y(e.charCodeAt(t + 3));
704
- }
705
- function y(e) {
706
- return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
707
- }
708
- function xe(e, t) {
709
- const n = e.source.body;
710
- switch (n.charCodeAt(t + 1)) {
711
- case 34:
712
- return {
713
- value: '"',
714
- size: 2
715
- };
716
- case 92:
717
- return {
718
- value: "\\",
719
- size: 2
720
- };
721
- case 47:
722
- return {
723
- value: "/",
724
- size: 2
725
- };
726
- case 98:
727
- return {
728
- value: "\b",
729
- size: 2
730
- };
731
- case 102:
732
- return {
733
- value: "\f",
734
- size: 2
735
- };
736
- case 110:
737
- return {
738
- value: `
739
- `,
740
- size: 2
741
- };
742
- case 114:
743
- return {
744
- value: "\r",
745
- size: 2
746
- };
747
- case 116:
748
- return {
749
- value: " ",
750
- size: 2
751
- };
752
- }
753
- throw d(
754
- e.source,
755
- t,
756
- `Invalid character escape sequence: "${n.slice(
757
- t,
758
- t + 2
759
- )}".`
760
- );
761
- }
762
- function Oe(e, t) {
763
- const n = e.source.body, s = n.length;
764
- let i = e.lineStart, r = t + 3, a = r, u = "";
765
- const l = [];
766
- for (; r < s; ) {
767
- const E = n.charCodeAt(r);
768
- if (E === 34 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34) {
769
- u += n.slice(a, r), l.push(u);
770
- const p = h(
771
- e,
772
- o.BLOCK_STRING,
773
- t,
774
- r + 3,
775
- // Return a string of the lines joined with U+000A.
776
- le(l).join(`
777
- `)
778
- );
779
- return e.line += l.length - 1, e.lineStart = i, p;
780
- }
781
- if (E === 92 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 && n.charCodeAt(r + 3) === 34) {
782
- u += n.slice(a, r), a = r + 1, r += 4;
783
- continue;
784
- }
785
- if (E === 10 || E === 13) {
786
- u += n.slice(a, r), l.push(u), E === 13 && n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, u = "", a = r, i = r;
787
- continue;
788
- }
789
- if (_(E))
790
- ++r;
791
- else if (k(n, r))
792
- r += 2;
793
- else
794
- throw d(
795
- e.source,
796
- r,
797
- `Invalid character within String: ${T(
798
- e,
799
- r
800
- )}.`
801
- );
802
- }
803
- throw d(e.source, r, "Unterminated string.");
804
- }
805
- function _e(e, t) {
806
- const n = e.source.body, s = n.length;
807
- let i = t + 1;
808
- for (; i < s; ) {
809
- const r = n.charCodeAt(i);
810
- if (ue(r))
811
- ++i;
812
- else
813
- break;
814
- }
815
- return h(
816
- e,
817
- o.NAME,
818
- t,
819
- i,
820
- n.slice(t, i)
821
- );
822
- }
823
- const Ae = 10, Q = 2;
824
- function z(e) {
825
- return S(e, []);
826
- }
827
- function S(e, t) {
828
- switch (typeof e) {
829
- case "string":
830
- return JSON.stringify(e);
831
- case "function":
832
- return e.name ? `[function ${e.name}]` : "[function]";
833
- case "object":
834
- return ye(e, t);
835
- default:
836
- return String(e);
837
- }
838
- }
839
- function ye(e, t) {
840
- if (e === null)
841
- return "null";
842
- if (t.includes(e))
843
- return "[Circular]";
844
- const n = [...t, e];
845
- if (De(e)) {
846
- const s = e.toJSON();
847
- if (s !== e)
848
- return typeof s == "string" ? s : S(s, n);
849
- } else if (Array.isArray(e))
850
- return ve(e, n);
851
- return ge(e, n);
852
- }
853
- function De(e) {
854
- return typeof e.toJSON == "function";
855
- }
856
- function ge(e, t) {
857
- const n = Object.entries(e);
858
- return n.length === 0 ? "{}" : t.length > Q ? "[" + Ce(e) + "]" : "{ " + n.map(
859
- ([i, r]) => i + ": " + S(r, t)
860
- ).join(", ") + " }";
861
- }
862
- function ve(e, t) {
863
- if (e.length === 0)
864
- return "[]";
865
- if (t.length > Q)
866
- return "[Array]";
867
- const n = Math.min(Ae, e.length), s = e.length - n, i = [];
868
- for (let r = 0; r < n; ++r)
869
- i.push(S(e[r], t));
870
- return s === 1 ? i.push("... 1 more item") : s > 1 && i.push(`... ${s} more items`), "[" + i.join(", ") + "]";
871
- }
872
- function Ce(e) {
873
- const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
874
- if (t === "Object" && typeof e.constructor == "function") {
875
- const n = e.constructor.name;
876
- if (typeof n == "string" && n !== "")
877
- return n;
878
- }
879
- return t;
880
- }
881
- const ke = globalThis.process && // eslint-disable-next-line no-undef
882
- process.env.NODE_ENV === "production", Se = (
883
- /* c8 ignore next 6 */
884
- // FIXME: https://github.com/graphql/graphql-js/issues/2317
885
- ke ? function(t, n) {
886
- return t instanceof n;
887
- } : function(t, n) {
888
- if (t instanceof n)
889
- return !0;
890
- if (typeof t == "object" && t !== null) {
891
- var s;
892
- const i = n.prototype[Symbol.toStringTag], r = (
893
- // We still need to support constructor's name to detect conflicts with older versions of this library.
894
- Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
895
- );
896
- if (i === r) {
897
- const a = z(t);
898
- throw new Error(`Cannot use ${i} "${a}" from another module or realm.
899
-
900
- Ensure that there is only one instance of "graphql" in the node_modules
901
- directory. If different versions of "graphql" are the dependencies of other
902
- relied on modules, use "resolutions" to ensure only one version is installed.
903
-
904
- https://yarnpkg.com/en/docs/selective-version-resolutions
905
-
906
- Duplicate "graphql" modules cannot be used at the same time since different
907
- versions may have different capabilities and behavior. The data from one
908
- version used in the function from another could produce confusing and
909
- spurious results.`);
910
- }
911
- }
912
- return !1;
913
- }
914
- );
915
- class H {
916
- constructor(t, n = "GraphQL request", s = {
917
- line: 1,
918
- column: 1
919
- }) {
920
- typeof t == "string" || L(!1, `Body must be a string. Received: ${z(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || L(
921
- !1,
922
- "line in locationOffset is 1-indexed and must be positive."
923
- ), this.locationOffset.column > 0 || L(
924
- !1,
925
- "column in locationOffset is 1-indexed and must be positive."
926
- );
927
- }
928
- get [Symbol.toStringTag]() {
929
- return "Source";
930
- }
931
- }
932
- function be(e) {
933
- return Se(e, H);
934
- }
935
- function Le(e, t) {
936
- const n = new Re(e, t), s = n.parseDocument();
937
- return Object.defineProperty(s, "tokenCount", {
938
- enumerable: !1,
939
- value: n.tokenCount
940
- }), s;
941
- }
942
- class Re {
943
- constructor(t, n = {}) {
944
- const s = be(t) ? t : new H(t);
945
- this._lexer = new pe(s), this._options = n, this._tokenCounter = 0;
946
- }
947
- get tokenCount() {
948
- return this._tokenCounter;
949
- }
950
- /**
951
- * Converts a name lex token into a name parse node.
952
- */
953
- parseName() {
954
- const t = this.expectToken(o.NAME);
955
- return this.node(t, {
956
- kind: c.NAME,
957
- value: t.value
958
- });
959
- }
960
- // Implements the parsing rules in the Document section.
961
- /**
962
- * Document : Definition+
963
- */
964
- parseDocument() {
965
- return this.node(this._lexer.token, {
966
- kind: c.DOCUMENT,
967
- definitions: this.many(
968
- o.SOF,
969
- this.parseDefinition,
970
- o.EOF
971
- )
972
- });
973
- }
974
- /**
975
- * Definition :
976
- * - ExecutableDefinition
977
- * - TypeSystemDefinition
978
- * - TypeSystemExtension
979
- *
980
- * ExecutableDefinition :
981
- * - OperationDefinition
982
- * - FragmentDefinition
983
- *
984
- * TypeSystemDefinition :
985
- * - SchemaDefinition
986
- * - TypeDefinition
987
- * - DirectiveDefinition
988
- *
989
- * TypeDefinition :
990
- * - ScalarTypeDefinition
991
- * - ObjectTypeDefinition
992
- * - InterfaceTypeDefinition
993
- * - UnionTypeDefinition
994
- * - EnumTypeDefinition
995
- * - InputObjectTypeDefinition
996
- */
997
- parseDefinition() {
998
- if (this.peek(o.BRACE_L))
999
- return this.parseOperationDefinition();
1000
- const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
1001
- if (n.kind === o.NAME) {
1002
- switch (n.value) {
1003
- case "schema":
1004
- return this.parseSchemaDefinition();
1005
- case "scalar":
1006
- return this.parseScalarTypeDefinition();
1007
- case "type":
1008
- return this.parseObjectTypeDefinition();
1009
- case "interface":
1010
- return this.parseInterfaceTypeDefinition();
1011
- case "union":
1012
- return this.parseUnionTypeDefinition();
1013
- case "enum":
1014
- return this.parseEnumTypeDefinition();
1015
- case "input":
1016
- return this.parseInputObjectTypeDefinition();
1017
- case "directive":
1018
- return this.parseDirectiveDefinition();
1019
- }
1020
- if (t)
1021
- throw d(
1022
- this._lexer.source,
1023
- this._lexer.token.start,
1024
- "Unexpected description, descriptions are supported only on type definitions."
1025
- );
1026
- switch (n.value) {
1027
- case "query":
1028
- case "mutation":
1029
- case "subscription":
1030
- return this.parseOperationDefinition();
1031
- case "fragment":
1032
- return this.parseFragmentDefinition();
1033
- case "extend":
1034
- return this.parseTypeSystemExtension();
1035
- }
1036
- }
1037
- throw this.unexpected(n);
1038
- }
1039
- // Implements the parsing rules in the Operations section.
1040
- /**
1041
- * OperationDefinition :
1042
- * - SelectionSet
1043
- * - OperationType Name? VariableDefinitions? Directives? SelectionSet
1044
- */
1045
- parseOperationDefinition() {
1046
- const t = this._lexer.token;
1047
- if (this.peek(o.BRACE_L))
1048
- return this.node(t, {
1049
- kind: c.OPERATION_DEFINITION,
1050
- operation: x.QUERY,
1051
- name: void 0,
1052
- variableDefinitions: [],
1053
- directives: [],
1054
- selectionSet: this.parseSelectionSet()
1055
- });
1056
- const n = this.parseOperationType();
1057
- let s;
1058
- return this.peek(o.NAME) && (s = this.parseName()), this.node(t, {
1059
- kind: c.OPERATION_DEFINITION,
1060
- operation: n,
1061
- name: s,
1062
- variableDefinitions: this.parseVariableDefinitions(),
1063
- directives: this.parseDirectives(!1),
1064
- selectionSet: this.parseSelectionSet()
1065
- });
1066
- }
1067
- /**
1068
- * OperationType : one of query mutation subscription
1069
- */
1070
- parseOperationType() {
1071
- const t = this.expectToken(o.NAME);
1072
- switch (t.value) {
1073
- case "query":
1074
- return x.QUERY;
1075
- case "mutation":
1076
- return x.MUTATION;
1077
- case "subscription":
1078
- return x.SUBSCRIPTION;
1079
- }
1080
- throw this.unexpected(t);
1081
- }
1082
- /**
1083
- * VariableDefinitions : ( VariableDefinition+ )
1084
- */
1085
- parseVariableDefinitions() {
1086
- return this.optionalMany(
1087
- o.PAREN_L,
1088
- this.parseVariableDefinition,
1089
- o.PAREN_R
1090
- );
1091
- }
1092
- /**
1093
- * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
1094
- */
1095
- parseVariableDefinition() {
1096
- return this.node(this._lexer.token, {
1097
- kind: c.VARIABLE_DEFINITION,
1098
- variable: this.parseVariable(),
1099
- type: (this.expectToken(o.COLON), this.parseTypeReference()),
1100
- defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0,
1101
- directives: this.parseConstDirectives()
1102
- });
1103
- }
1104
- /**
1105
- * Variable : $ Name
1106
- */
1107
- parseVariable() {
1108
- const t = this._lexer.token;
1109
- return this.expectToken(o.DOLLAR), this.node(t, {
1110
- kind: c.VARIABLE,
1111
- name: this.parseName()
1112
- });
1113
- }
1114
- /**
1115
- * ```
1116
- * SelectionSet : { Selection+ }
1117
- * ```
1118
- */
1119
- parseSelectionSet() {
1120
- return this.node(this._lexer.token, {
1121
- kind: c.SELECTION_SET,
1122
- selections: this.many(
1123
- o.BRACE_L,
1124
- this.parseSelection,
1125
- o.BRACE_R
1126
- )
1127
- });
1128
- }
1129
- /**
1130
- * Selection :
1131
- * - Field
1132
- * - FragmentSpread
1133
- * - InlineFragment
1134
- */
1135
- parseSelection() {
1136
- return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField();
1137
- }
1138
- /**
1139
- * Field : Alias? Name Arguments? Directives? SelectionSet?
1140
- *
1141
- * Alias : Name :
1142
- */
1143
- parseField() {
1144
- const t = this._lexer.token, n = this.parseName();
1145
- let s, i;
1146
- return this.expectOptionalToken(o.COLON) ? (s = n, i = this.parseName()) : i = n, this.node(t, {
1147
- kind: c.FIELD,
1148
- alias: s,
1149
- name: i,
1150
- arguments: this.parseArguments(!1),
1151
- directives: this.parseDirectives(!1),
1152
- selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0
1153
- });
1154
- }
1155
- /**
1156
- * Arguments[Const] : ( Argument[?Const]+ )
1157
- */
1158
- parseArguments(t) {
1159
- const n = t ? this.parseConstArgument : this.parseArgument;
1160
- return this.optionalMany(o.PAREN_L, n, o.PAREN_R);
1161
- }
1162
- /**
1163
- * Argument[Const] : Name : Value[?Const]
1164
- */
1165
- parseArgument(t = !1) {
1166
- const n = this._lexer.token, s = this.parseName();
1167
- return this.expectToken(o.COLON), this.node(n, {
1168
- kind: c.ARGUMENT,
1169
- name: s,
1170
- value: this.parseValueLiteral(t)
1171
- });
1172
- }
1173
- parseConstArgument() {
1174
- return this.parseArgument(!0);
1175
- }
1176
- // Implements the parsing rules in the Fragments section.
1177
- /**
1178
- * Corresponds to both FragmentSpread and InlineFragment in the spec.
1179
- *
1180
- * FragmentSpread : ... FragmentName Directives?
1181
- *
1182
- * InlineFragment : ... TypeCondition? Directives? SelectionSet
1183
- */
1184
- parseFragment() {
1185
- const t = this._lexer.token;
1186
- this.expectToken(o.SPREAD);
1187
- const n = this.expectOptionalKeyword("on");
1188
- return !n && this.peek(o.NAME) ? this.node(t, {
1189
- kind: c.FRAGMENT_SPREAD,
1190
- name: this.parseFragmentName(),
1191
- directives: this.parseDirectives(!1)
1192
- }) : this.node(t, {
1193
- kind: c.INLINE_FRAGMENT,
1194
- typeCondition: n ? this.parseNamedType() : void 0,
1195
- directives: this.parseDirectives(!1),
1196
- selectionSet: this.parseSelectionSet()
1197
- });
1198
- }
1199
- /**
1200
- * FragmentDefinition :
1201
- * - fragment FragmentName on TypeCondition Directives? SelectionSet
1202
- *
1203
- * TypeCondition : NamedType
1204
- */
1205
- parseFragmentDefinition() {
1206
- const t = this._lexer.token;
1207
- return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
1208
- kind: c.FRAGMENT_DEFINITION,
1209
- name: this.parseFragmentName(),
1210
- variableDefinitions: this.parseVariableDefinitions(),
1211
- typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1212
- directives: this.parseDirectives(!1),
1213
- selectionSet: this.parseSelectionSet()
1214
- }) : this.node(t, {
1215
- kind: c.FRAGMENT_DEFINITION,
1216
- name: this.parseFragmentName(),
1217
- typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
1218
- directives: this.parseDirectives(!1),
1219
- selectionSet: this.parseSelectionSet()
1220
- });
1221
- }
1222
- /**
1223
- * FragmentName : Name but not `on`
1224
- */
1225
- parseFragmentName() {
1226
- if (this._lexer.token.value === "on")
1227
- throw this.unexpected();
1228
- return this.parseName();
1229
- }
1230
- // Implements the parsing rules in the Values section.
1231
- /**
1232
- * Value[Const] :
1233
- * - [~Const] Variable
1234
- * - IntValue
1235
- * - FloatValue
1236
- * - StringValue
1237
- * - BooleanValue
1238
- * - NullValue
1239
- * - EnumValue
1240
- * - ListValue[?Const]
1241
- * - ObjectValue[?Const]
1242
- *
1243
- * BooleanValue : one of `true` `false`
1244
- *
1245
- * NullValue : `null`
1246
- *
1247
- * EnumValue : Name but not `true`, `false` or `null`
1248
- */
1249
- parseValueLiteral(t) {
1250
- const n = this._lexer.token;
1251
- switch (n.kind) {
1252
- case o.BRACKET_L:
1253
- return this.parseList(t);
1254
- case o.BRACE_L:
1255
- return this.parseObject(t);
1256
- case o.INT:
1257
- return this.advanceLexer(), this.node(n, {
1258
- kind: c.INT,
1259
- value: n.value
1260
- });
1261
- case o.FLOAT:
1262
- return this.advanceLexer(), this.node(n, {
1263
- kind: c.FLOAT,
1264
- value: n.value
1265
- });
1266
- case o.STRING:
1267
- case o.BLOCK_STRING:
1268
- return this.parseStringLiteral();
1269
- case o.NAME:
1270
- switch (this.advanceLexer(), n.value) {
1271
- case "true":
1272
- return this.node(n, {
1273
- kind: c.BOOLEAN,
1274
- value: !0
1275
- });
1276
- case "false":
1277
- return this.node(n, {
1278
- kind: c.BOOLEAN,
1279
- value: !1
1280
- });
1281
- case "null":
1282
- return this.node(n, {
1283
- kind: c.NULL
1284
- });
1285
- default:
1286
- return this.node(n, {
1287
- kind: c.ENUM,
1288
- value: n.value
1289
- });
1290
- }
1291
- case o.DOLLAR:
1292
- if (t)
1293
- if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) {
1294
- const s = this._lexer.token.value;
1295
- throw d(
1296
- this._lexer.source,
1297
- n.start,
1298
- `Unexpected variable "$${s}" in constant value.`
1299
- );
1300
- } else
1301
- throw this.unexpected(n);
1302
- return this.parseVariable();
1303
- default:
1304
- throw this.unexpected();
1305
- }
1306
- }
1307
- parseConstValueLiteral() {
1308
- return this.parseValueLiteral(!0);
1309
- }
1310
- parseStringLiteral() {
1311
- const t = this._lexer.token;
1312
- return this.advanceLexer(), this.node(t, {
1313
- kind: c.STRING,
1314
- value: t.value,
1315
- block: t.kind === o.BLOCK_STRING
1316
- });
1317
- }
1318
- /**
1319
- * ListValue[Const] :
1320
- * - [ ]
1321
- * - [ Value[?Const]+ ]
1322
- */
1323
- parseList(t) {
1324
- const n = () => this.parseValueLiteral(t);
1325
- return this.node(this._lexer.token, {
1326
- kind: c.LIST,
1327
- values: this.any(o.BRACKET_L, n, o.BRACKET_R)
1328
- });
1329
- }
1330
- /**
1331
- * ```
1332
- * ObjectValue[Const] :
1333
- * - { }
1334
- * - { ObjectField[?Const]+ }
1335
- * ```
1336
- */
1337
- parseObject(t) {
1338
- const n = () => this.parseObjectField(t);
1339
- return this.node(this._lexer.token, {
1340
- kind: c.OBJECT,
1341
- fields: this.any(o.BRACE_L, n, o.BRACE_R)
1342
- });
1343
- }
1344
- /**
1345
- * ObjectField[Const] : Name : Value[?Const]
1346
- */
1347
- parseObjectField(t) {
1348
- const n = this._lexer.token, s = this.parseName();
1349
- return this.expectToken(o.COLON), this.node(n, {
1350
- kind: c.OBJECT_FIELD,
1351
- name: s,
1352
- value: this.parseValueLiteral(t)
1353
- });
1354
- }
1355
- // Implements the parsing rules in the Directives section.
1356
- /**
1357
- * Directives[Const] : Directive[?Const]+
1358
- */
1359
- parseDirectives(t) {
1360
- const n = [];
1361
- for (; this.peek(o.AT); )
1362
- n.push(this.parseDirective(t));
1363
- return n;
1364
- }
1365
- parseConstDirectives() {
1366
- return this.parseDirectives(!0);
1367
- }
1368
- /**
1369
- * ```
1370
- * Directive[Const] : @ Name Arguments[?Const]?
1371
- * ```
1372
- */
1373
- parseDirective(t) {
1374
- const n = this._lexer.token;
1375
- return this.expectToken(o.AT), this.node(n, {
1376
- kind: c.DIRECTIVE,
1377
- name: this.parseName(),
1378
- arguments: this.parseArguments(t)
1379
- });
1380
- }
1381
- // Implements the parsing rules in the Types section.
1382
- /**
1383
- * Type :
1384
- * - NamedType
1385
- * - ListType
1386
- * - NonNullType
1387
- */
1388
- parseTypeReference() {
1389
- const t = this._lexer.token;
1390
- let n;
1391
- if (this.expectOptionalToken(o.BRACKET_L)) {
1392
- const s = this.parseTypeReference();
1393
- this.expectToken(o.BRACKET_R), n = this.node(t, {
1394
- kind: c.LIST_TYPE,
1395
- type: s
1396
- });
1397
- } else
1398
- n = this.parseNamedType();
1399
- return this.expectOptionalToken(o.BANG) ? this.node(t, {
1400
- kind: c.NON_NULL_TYPE,
1401
- type: n
1402
- }) : n;
1403
- }
1404
- /**
1405
- * NamedType : Name
1406
- */
1407
- parseNamedType() {
1408
- return this.node(this._lexer.token, {
1409
- kind: c.NAMED_TYPE,
1410
- name: this.parseName()
1411
- });
1412
- }
1413
- // Implements the parsing rules in the Type Definition section.
1414
- peekDescription() {
1415
- return this.peek(o.STRING) || this.peek(o.BLOCK_STRING);
1416
- }
1417
- /**
1418
- * Description : StringValue
1419
- */
1420
- parseDescription() {
1421
- if (this.peekDescription())
1422
- return this.parseStringLiteral();
1423
- }
1424
- /**
1425
- * ```
1426
- * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
1427
- * ```
1428
- */
1429
- parseSchemaDefinition() {
1430
- const t = this._lexer.token, n = this.parseDescription();
1431
- this.expectKeyword("schema");
1432
- const s = this.parseConstDirectives(), i = this.many(
1433
- o.BRACE_L,
1434
- this.parseOperationTypeDefinition,
1435
- o.BRACE_R
1436
- );
1437
- return this.node(t, {
1438
- kind: c.SCHEMA_DEFINITION,
1439
- description: n,
1440
- directives: s,
1441
- operationTypes: i
1442
- });
1443
- }
1444
- /**
1445
- * OperationTypeDefinition : OperationType : NamedType
1446
- */
1447
- parseOperationTypeDefinition() {
1448
- const t = this._lexer.token, n = this.parseOperationType();
1449
- this.expectToken(o.COLON);
1450
- const s = this.parseNamedType();
1451
- return this.node(t, {
1452
- kind: c.OPERATION_TYPE_DEFINITION,
1453
- operation: n,
1454
- type: s
1455
- });
1456
- }
1457
- /**
1458
- * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
1459
- */
1460
- parseScalarTypeDefinition() {
1461
- const t = this._lexer.token, n = this.parseDescription();
1462
- this.expectKeyword("scalar");
1463
- const s = this.parseName(), i = this.parseConstDirectives();
1464
- return this.node(t, {
1465
- kind: c.SCALAR_TYPE_DEFINITION,
1466
- description: n,
1467
- name: s,
1468
- directives: i
1469
- });
1470
- }
1471
- /**
1472
- * ObjectTypeDefinition :
1473
- * Description?
1474
- * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
1475
- */
1476
- parseObjectTypeDefinition() {
1477
- const t = this._lexer.token, n = this.parseDescription();
1478
- this.expectKeyword("type");
1479
- const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
1480
- return this.node(t, {
1481
- kind: c.OBJECT_TYPE_DEFINITION,
1482
- description: n,
1483
- name: s,
1484
- interfaces: i,
1485
- directives: r,
1486
- fields: a
1487
- });
1488
- }
1489
- /**
1490
- * ImplementsInterfaces :
1491
- * - implements `&`? NamedType
1492
- * - ImplementsInterfaces & NamedType
1493
- */
1494
- parseImplementsInterfaces() {
1495
- return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : [];
1496
- }
1497
- /**
1498
- * ```
1499
- * FieldsDefinition : { FieldDefinition+ }
1500
- * ```
1501
- */
1502
- parseFieldsDefinition() {
1503
- return this.optionalMany(
1504
- o.BRACE_L,
1505
- this.parseFieldDefinition,
1506
- o.BRACE_R
1507
- );
1508
- }
1509
- /**
1510
- * FieldDefinition :
1511
- * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
1512
- */
1513
- parseFieldDefinition() {
1514
- const t = this._lexer.token, n = this.parseDescription(), s = this.parseName(), i = this.parseArgumentDefs();
1515
- this.expectToken(o.COLON);
1516
- const r = this.parseTypeReference(), a = this.parseConstDirectives();
1517
- return this.node(t, {
1518
- kind: c.FIELD_DEFINITION,
1519
- description: n,
1520
- name: s,
1521
- arguments: i,
1522
- type: r,
1523
- directives: a
1524
- });
1525
- }
1526
- /**
1527
- * ArgumentsDefinition : ( InputValueDefinition+ )
1528
- */
1529
- parseArgumentDefs() {
1530
- return this.optionalMany(
1531
- o.PAREN_L,
1532
- this.parseInputValueDef,
1533
- o.PAREN_R
1534
- );
1535
- }
1536
- /**
1537
- * InputValueDefinition :
1538
- * - Description? Name : Type DefaultValue? Directives[Const]?
1539
- */
1540
- parseInputValueDef() {
1541
- const t = this._lexer.token, n = this.parseDescription(), s = this.parseName();
1542
- this.expectToken(o.COLON);
1543
- const i = this.parseTypeReference();
1544
- let r;
1545
- this.expectOptionalToken(o.EQUALS) && (r = this.parseConstValueLiteral());
1546
- const a = this.parseConstDirectives();
1547
- return this.node(t, {
1548
- kind: c.INPUT_VALUE_DEFINITION,
1549
- description: n,
1550
- name: s,
1551
- type: i,
1552
- defaultValue: r,
1553
- directives: a
1554
- });
1555
- }
1556
- /**
1557
- * InterfaceTypeDefinition :
1558
- * - Description? interface Name Directives[Const]? FieldsDefinition?
1559
- */
1560
- parseInterfaceTypeDefinition() {
1561
- const t = this._lexer.token, n = this.parseDescription();
1562
- this.expectKeyword("interface");
1563
- const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
1564
- return this.node(t, {
1565
- kind: c.INTERFACE_TYPE_DEFINITION,
1566
- description: n,
1567
- name: s,
1568
- interfaces: i,
1569
- directives: r,
1570
- fields: a
1571
- });
1572
- }
1573
- /**
1574
- * UnionTypeDefinition :
1575
- * - Description? union Name Directives[Const]? UnionMemberTypes?
1576
- */
1577
- parseUnionTypeDefinition() {
1578
- const t = this._lexer.token, n = this.parseDescription();
1579
- this.expectKeyword("union");
1580
- const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseUnionMemberTypes();
1581
- return this.node(t, {
1582
- kind: c.UNION_TYPE_DEFINITION,
1583
- description: n,
1584
- name: s,
1585
- directives: i,
1586
- types: r
1587
- });
1588
- }
1589
- /**
1590
- * UnionMemberTypes :
1591
- * - = `|`? NamedType
1592
- * - UnionMemberTypes | NamedType
1593
- */
1594
- parseUnionMemberTypes() {
1595
- return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : [];
1596
- }
1597
- /**
1598
- * EnumTypeDefinition :
1599
- * - Description? enum Name Directives[Const]? EnumValuesDefinition?
1600
- */
1601
- parseEnumTypeDefinition() {
1602
- const t = this._lexer.token, n = this.parseDescription();
1603
- this.expectKeyword("enum");
1604
- const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseEnumValuesDefinition();
1605
- return this.node(t, {
1606
- kind: c.ENUM_TYPE_DEFINITION,
1607
- description: n,
1608
- name: s,
1609
- directives: i,
1610
- values: r
1611
- });
1612
- }
1613
- /**
1614
- * ```
1615
- * EnumValuesDefinition : { EnumValueDefinition+ }
1616
- * ```
1617
- */
1618
- parseEnumValuesDefinition() {
1619
- return this.optionalMany(
1620
- o.BRACE_L,
1621
- this.parseEnumValueDefinition,
1622
- o.BRACE_R
1623
- );
1624
- }
1625
- /**
1626
- * EnumValueDefinition : Description? EnumValue Directives[Const]?
1627
- */
1628
- parseEnumValueDefinition() {
1629
- const t = this._lexer.token, n = this.parseDescription(), s = this.parseEnumValueName(), i = this.parseConstDirectives();
1630
- return this.node(t, {
1631
- kind: c.ENUM_VALUE_DEFINITION,
1632
- description: n,
1633
- name: s,
1634
- directives: i
1635
- });
1636
- }
1637
- /**
1638
- * EnumValue : Name but not `true`, `false` or `null`
1639
- */
1640
- parseEnumValueName() {
1641
- if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
1642
- throw d(
1643
- this._lexer.source,
1644
- this._lexer.token.start,
1645
- `${g(
1646
- this._lexer.token
1647
- )} is reserved and cannot be used for an enum value.`
1648
- );
1649
- return this.parseName();
1650
- }
1651
- /**
1652
- * InputObjectTypeDefinition :
1653
- * - Description? input Name Directives[Const]? InputFieldsDefinition?
1654
- */
1655
- parseInputObjectTypeDefinition() {
1656
- const t = this._lexer.token, n = this.parseDescription();
1657
- this.expectKeyword("input");
1658
- const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseInputFieldsDefinition();
1659
- return this.node(t, {
1660
- kind: c.INPUT_OBJECT_TYPE_DEFINITION,
1661
- description: n,
1662
- name: s,
1663
- directives: i,
1664
- fields: r
1665
- });
1666
- }
1667
- /**
1668
- * ```
1669
- * InputFieldsDefinition : { InputValueDefinition+ }
1670
- * ```
1671
- */
1672
- parseInputFieldsDefinition() {
1673
- return this.optionalMany(
1674
- o.BRACE_L,
1675
- this.parseInputValueDef,
1676
- o.BRACE_R
1677
- );
1678
- }
1679
- /**
1680
- * TypeSystemExtension :
1681
- * - SchemaExtension
1682
- * - TypeExtension
1683
- *
1684
- * TypeExtension :
1685
- * - ScalarTypeExtension
1686
- * - ObjectTypeExtension
1687
- * - InterfaceTypeExtension
1688
- * - UnionTypeExtension
1689
- * - EnumTypeExtension
1690
- * - InputObjectTypeDefinition
1691
- */
1692
- parseTypeSystemExtension() {
1693
- const t = this._lexer.lookahead();
1694
- if (t.kind === o.NAME)
1695
- switch (t.value) {
1696
- case "schema":
1697
- return this.parseSchemaExtension();
1698
- case "scalar":
1699
- return this.parseScalarTypeExtension();
1700
- case "type":
1701
- return this.parseObjectTypeExtension();
1702
- case "interface":
1703
- return this.parseInterfaceTypeExtension();
1704
- case "union":
1705
- return this.parseUnionTypeExtension();
1706
- case "enum":
1707
- return this.parseEnumTypeExtension();
1708
- case "input":
1709
- return this.parseInputObjectTypeExtension();
1710
- }
1711
- throw this.unexpected(t);
1712
- }
1713
- /**
1714
- * ```
1715
- * SchemaExtension :
1716
- * - extend schema Directives[Const]? { OperationTypeDefinition+ }
1717
- * - extend schema Directives[Const]
1718
- * ```
1719
- */
1720
- parseSchemaExtension() {
1721
- const t = this._lexer.token;
1722
- this.expectKeyword("extend"), this.expectKeyword("schema");
1723
- const n = this.parseConstDirectives(), s = this.optionalMany(
1724
- o.BRACE_L,
1725
- this.parseOperationTypeDefinition,
1726
- o.BRACE_R
1727
- );
1728
- if (n.length === 0 && s.length === 0)
1729
- throw this.unexpected();
1730
- return this.node(t, {
1731
- kind: c.SCHEMA_EXTENSION,
1732
- directives: n,
1733
- operationTypes: s
1734
- });
1735
- }
1736
- /**
1737
- * ScalarTypeExtension :
1738
- * - extend scalar Name Directives[Const]
1739
- */
1740
- parseScalarTypeExtension() {
1741
- const t = this._lexer.token;
1742
- this.expectKeyword("extend"), this.expectKeyword("scalar");
1743
- const n = this.parseName(), s = this.parseConstDirectives();
1744
- if (s.length === 0)
1745
- throw this.unexpected();
1746
- return this.node(t, {
1747
- kind: c.SCALAR_TYPE_EXTENSION,
1748
- name: n,
1749
- directives: s
1750
- });
1751
- }
1752
- /**
1753
- * ObjectTypeExtension :
1754
- * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1755
- * - extend type Name ImplementsInterfaces? Directives[Const]
1756
- * - extend type Name ImplementsInterfaces
1757
- */
1758
- parseObjectTypeExtension() {
1759
- const t = this._lexer.token;
1760
- this.expectKeyword("extend"), this.expectKeyword("type");
1761
- const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
1762
- if (s.length === 0 && i.length === 0 && r.length === 0)
1763
- throw this.unexpected();
1764
- return this.node(t, {
1765
- kind: c.OBJECT_TYPE_EXTENSION,
1766
- name: n,
1767
- interfaces: s,
1768
- directives: i,
1769
- fields: r
1770
- });
1771
- }
1772
- /**
1773
- * InterfaceTypeExtension :
1774
- * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
1775
- * - extend interface Name ImplementsInterfaces? Directives[Const]
1776
- * - extend interface Name ImplementsInterfaces
1777
- */
1778
- parseInterfaceTypeExtension() {
1779
- const t = this._lexer.token;
1780
- this.expectKeyword("extend"), this.expectKeyword("interface");
1781
- const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
1782
- if (s.length === 0 && i.length === 0 && r.length === 0)
1783
- throw this.unexpected();
1784
- return this.node(t, {
1785
- kind: c.INTERFACE_TYPE_EXTENSION,
1786
- name: n,
1787
- interfaces: s,
1788
- directives: i,
1789
- fields: r
1790
- });
1791
- }
1792
- /**
1793
- * UnionTypeExtension :
1794
- * - extend union Name Directives[Const]? UnionMemberTypes
1795
- * - extend union Name Directives[Const]
1796
- */
1797
- parseUnionTypeExtension() {
1798
- const t = this._lexer.token;
1799
- this.expectKeyword("extend"), this.expectKeyword("union");
1800
- const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
1801
- if (s.length === 0 && i.length === 0)
1802
- throw this.unexpected();
1803
- return this.node(t, {
1804
- kind: c.UNION_TYPE_EXTENSION,
1805
- name: n,
1806
- directives: s,
1807
- types: i
1808
- });
1809
- }
1810
- /**
1811
- * EnumTypeExtension :
1812
- * - extend enum Name Directives[Const]? EnumValuesDefinition
1813
- * - extend enum Name Directives[Const]
1814
- */
1815
- parseEnumTypeExtension() {
1816
- const t = this._lexer.token;
1817
- this.expectKeyword("extend"), this.expectKeyword("enum");
1818
- const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
1819
- if (s.length === 0 && i.length === 0)
1820
- throw this.unexpected();
1821
- return this.node(t, {
1822
- kind: c.ENUM_TYPE_EXTENSION,
1823
- name: n,
1824
- directives: s,
1825
- values: i
1826
- });
1827
- }
1828
- /**
1829
- * InputObjectTypeExtension :
1830
- * - extend input Name Directives[Const]? InputFieldsDefinition
1831
- * - extend input Name Directives[Const]
1832
- */
1833
- parseInputObjectTypeExtension() {
1834
- const t = this._lexer.token;
1835
- this.expectKeyword("extend"), this.expectKeyword("input");
1836
- const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
1837
- if (s.length === 0 && i.length === 0)
1838
- throw this.unexpected();
1839
- return this.node(t, {
1840
- kind: c.INPUT_OBJECT_TYPE_EXTENSION,
1841
- name: n,
1842
- directives: s,
1843
- fields: i
1844
- });
1845
- }
1846
- /**
1847
- * ```
1848
- * DirectiveDefinition :
1849
- * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
1850
- * ```
1851
- */
1852
- parseDirectiveDefinition() {
1853
- const t = this._lexer.token, n = this.parseDescription();
1854
- this.expectKeyword("directive"), this.expectToken(o.AT);
1855
- const s = this.parseName(), i = this.parseArgumentDefs(), r = this.expectOptionalKeyword("repeatable");
1856
- this.expectKeyword("on");
1857
- const a = this.parseDirectiveLocations();
1858
- return this.node(t, {
1859
- kind: c.DIRECTIVE_DEFINITION,
1860
- description: n,
1861
- name: s,
1862
- arguments: i,
1863
- repeatable: r,
1864
- locations: a
1865
- });
1866
- }
1867
- /**
1868
- * DirectiveLocations :
1869
- * - `|`? DirectiveLocation
1870
- * - DirectiveLocations | DirectiveLocation
1871
- */
1872
- parseDirectiveLocations() {
1873
- return this.delimitedMany(o.PIPE, this.parseDirectiveLocation);
1874
- }
1875
- /*
1876
- * DirectiveLocation :
1877
- * - ExecutableDirectiveLocation
1878
- * - TypeSystemDirectiveLocation
1879
- *
1880
- * ExecutableDirectiveLocation : one of
1881
- * `QUERY`
1882
- * `MUTATION`
1883
- * `SUBSCRIPTION`
1884
- * `FIELD`
1885
- * `FRAGMENT_DEFINITION`
1886
- * `FRAGMENT_SPREAD`
1887
- * `INLINE_FRAGMENT`
1888
- *
1889
- * TypeSystemDirectiveLocation : one of
1890
- * `SCHEMA`
1891
- * `SCALAR`
1892
- * `OBJECT`
1893
- * `FIELD_DEFINITION`
1894
- * `ARGUMENT_DEFINITION`
1895
- * `INTERFACE`
1896
- * `UNION`
1897
- * `ENUM`
1898
- * `ENUM_VALUE`
1899
- * `INPUT_OBJECT`
1900
- * `INPUT_FIELD_DEFINITION`
1901
- */
1902
- parseDirectiveLocation() {
1903
- const t = this._lexer.token, n = this.parseName();
1904
- if (Object.prototype.hasOwnProperty.call(w, n.value))
1905
- return n;
1906
- throw this.unexpected(t);
1907
- }
1908
- // Core parsing utility functions
1909
- /**
1910
- * Returns a node that, if configured to do so, sets a "loc" field as a
1911
- * location object, used to identify the place in the source that created a
1912
- * given parsed object.
1913
- */
1914
- node(t, n) {
1915
- return this._options.noLocation !== !0 && (n.loc = new oe(
1916
- t,
1917
- this._lexer.lastToken,
1918
- this._lexer.source
1919
- )), n;
1920
- }
1921
- /**
1922
- * Determines if the next token is of a given kind
1923
- */
1924
- peek(t) {
1925
- return this._lexer.token.kind === t;
1926
- }
1927
- /**
1928
- * If the next token is of the given kind, return that token after advancing the lexer.
1929
- * Otherwise, do not change the parser state and throw an error.
1930
- */
1931
- expectToken(t) {
1932
- const n = this._lexer.token;
1933
- if (n.kind === t)
1934
- return this.advanceLexer(), n;
1935
- throw d(
1936
- this._lexer.source,
1937
- n.start,
1938
- `Expected ${W(t)}, found ${g(n)}.`
1939
- );
1940
- }
1941
- /**
1942
- * If the next token is of the given kind, return "true" after advancing the lexer.
1943
- * Otherwise, do not change the parser state and return "false".
1944
- */
1945
- expectOptionalToken(t) {
1946
- return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
1947
- }
1948
- /**
1949
- * If the next token is a given keyword, advance the lexer.
1950
- * Otherwise, do not change the parser state and throw an error.
1951
- */
1952
- expectKeyword(t) {
1953
- const n = this._lexer.token;
1954
- if (n.kind === o.NAME && n.value === t)
1955
- this.advanceLexer();
1956
- else
1957
- throw d(
1958
- this._lexer.source,
1959
- n.start,
1960
- `Expected "${t}", found ${g(n)}.`
1961
- );
1962
- }
1963
- /**
1964
- * If the next token is a given keyword, return "true" after advancing the lexer.
1965
- * Otherwise, do not change the parser state and return "false".
1966
- */
1967
- expectOptionalKeyword(t) {
1968
- const n = this._lexer.token;
1969
- return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
1970
- }
1971
- /**
1972
- * Helper function for creating an error when an unexpected lexed token is encountered.
1973
- */
1974
- unexpected(t) {
1975
- const n = t ?? this._lexer.token;
1976
- return d(
1977
- this._lexer.source,
1978
- n.start,
1979
- `Unexpected ${g(n)}.`
1980
- );
1981
- }
1982
- /**
1983
- * Returns a possibly empty list of parse nodes, determined by the parseFn.
1984
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
1985
- * Advances the parser to the next lex token after the closing token.
1986
- */
1987
- any(t, n, s) {
1988
- this.expectToken(t);
1989
- const i = [];
1990
- for (; !this.expectOptionalToken(s); )
1991
- i.push(n.call(this));
1992
- return i;
1993
- }
1994
- /**
1995
- * Returns a list of parse nodes, determined by the parseFn.
1996
- * It can be empty only if open token is missing otherwise it will always return non-empty list
1997
- * that begins with a lex token of openKind and ends with a lex token of closeKind.
1998
- * Advances the parser to the next lex token after the closing token.
1999
- */
2000
- optionalMany(t, n, s) {
2001
- if (this.expectOptionalToken(t)) {
2002
- const i = [];
2003
- do
2004
- i.push(n.call(this));
2005
- while (!this.expectOptionalToken(s));
2006
- return i;
2007
- }
2008
- return [];
2009
- }
2010
- /**
2011
- * Returns a non-empty list of parse nodes, determined by the parseFn.
2012
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
2013
- * Advances the parser to the next lex token after the closing token.
2014
- */
2015
- many(t, n, s) {
2016
- this.expectToken(t);
2017
- const i = [];
2018
- do
2019
- i.push(n.call(this));
2020
- while (!this.expectOptionalToken(s));
2021
- return i;
2022
- }
2023
- /**
2024
- * Returns a non-empty list of parse nodes, determined by the parseFn.
2025
- * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
2026
- * Advances the parser to the next lex token after last item in the list.
2027
- */
2028
- delimitedMany(t, n) {
2029
- this.expectOptionalToken(t);
2030
- const s = [];
2031
- do
2032
- s.push(n.call(this));
2033
- while (this.expectOptionalToken(t));
2034
- return s;
2035
- }
2036
- advanceLexer() {
2037
- const { maxTokens: t } = this._options, n = this._lexer.advance();
2038
- if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t))
2039
- throw d(
2040
- this._lexer.source,
2041
- n.start,
2042
- `Document contains more that ${t} tokens. Parsing aborted.`
2043
- );
2044
- }
2045
- }
2046
- function g(e) {
2047
- const t = e.value;
2048
- return W(e.kind) + (t != null ? ` "${t}"` : "");
2049
- }
2050
- function W(e) {
2051
- return de(e) ? `"${e}"` : e;
2052
- }
2053
- var v = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), Z = !0, C = !1;
2054
- function K(e) {
2055
- return e.replace(/[\s,]+/g, " ").trim();
2056
- }
2057
- function Fe(e) {
2058
- return K(e.source.body.substring(e.start, e.end));
2059
- }
2060
- function we(e) {
2061
- var t = /* @__PURE__ */ new Set(), n = [];
2062
- return e.definitions.forEach(function(s) {
2063
- if (s.kind === "FragmentDefinition") {
2064
- var i = s.name.value, r = Fe(s.loc), a = P.get(i);
2065
- a && !a.has(r) ? Z && console.warn("Warning: fragment with name " + i + ` already exists.
2066
- graphql-tag enforces all fragment names across your application to be unique; read more about
2067
- this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : a || P.set(i, a = /* @__PURE__ */ new Set()), a.add(r), t.has(r) || (t.add(r), n.push(s));
2068
- } else
2069
- n.push(s);
2070
- }), M(M({}, e), { definitions: n });
2071
- }
2072
- function Pe(e) {
2073
- var t = new Set(e.definitions);
2074
- t.forEach(function(s) {
2075
- s.loc && delete s.loc, Object.keys(s).forEach(function(i) {
2076
- var r = s[i];
2077
- r && typeof r == "object" && t.add(r);
2078
- });
2079
- });
2080
- var n = e.loc;
2081
- return n && (delete n.startToken, delete n.endToken), e;
2082
- }
2083
- function Ue(e) {
2084
- var t = K(e);
2085
- if (!v.has(t)) {
2086
- var n = Le(e, {
2087
- experimentalFragmentVariables: C,
2088
- allowLegacyFragmentVariables: C
2089
- });
2090
- if (!n || n.kind !== "Document")
2091
- throw new Error("Not a valid GraphQL document.");
2092
- v.set(t, Pe(we(n)));
2093
- }
2094
- return v.get(t);
2095
- }
2096
- function O(e) {
2097
- for (var t = [], n = 1; n < arguments.length; n++)
2098
- t[n - 1] = arguments[n];
2099
- typeof e == "string" && (e = [e]);
2100
- var s = e[0];
2101
- return t.forEach(function(i, r) {
2102
- i && i.kind === "Document" ? s += i.loc.source.body : s += i, s += e[r + 1];
2103
- }), Ue(s);
2104
- }
2105
- function Me() {
2106
- v.clear(), P.clear();
2107
- }
2108
- function Ve() {
2109
- Z = !1;
2110
- }
2111
- function Be() {
2112
- C = !0;
2113
- }
2114
- function je() {
2115
- C = !1;
2116
- }
2117
- var A = {
2118
- gql: O,
2119
- resetCaches: Me,
2120
- disableFragmentWarnings: Ve,
2121
- enableExperimentalFragmentVariables: Be,
2122
- disableExperimentalFragmentVariables: je
2123
- };
2124
- (function(e) {
2125
- e.gql = A.gql, e.resetCaches = A.resetCaches, e.disableFragmentWarnings = A.disableFragmentWarnings, e.enableExperimentalFragmentVariables = A.enableExperimentalFragmentVariables, e.disableExperimentalFragmentVariables = A.disableExperimentalFragmentVariables;
2126
- })(O || (O = {}));
2127
- O.default = O;
2128
- const $e = O`
2129
- query getCurrentUser {
2130
- me {
2131
- id
2132
- username
2133
- email
2134
- role
2135
- }
2136
- }
2137
- `, Je = ee({
2138
- user: null,
2139
- loading: !0,
2140
- error: null,
2141
- isLoggedIn: !1,
2142
- isAdmin: !1,
2143
- refreshUser: async () => Promise.resolve()
2144
- });
2145
- export {
2146
- $e as D,
2147
- Je as O,
2148
- O as g
2149
- };