@gql.tada/cli-utils 1.7.4 → 1.8.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.
@@ -2,42 +2,39 @@ import e from "typescript";
2
2
 
3
3
  import { getSchemaNamesFromConfig as i } from "@gql.tada/internal";
4
4
 
5
- import { findAllPersistedCallExpressions as n, getDocumentReferenceFromDocumentNode as r, getDocumentReferenceFromTypeQuery as a, unrollTadaFragments as t } from "@0no-co/graphqlsp/api";
5
+ import { findAllPersistedCallExpressions as r, getDocumentReferenceFromDocumentNode as n, getDocumentReferenceFromTypeQuery as t, unrollTadaFragments as a } from "@0no-co/graphqlsp/api";
6
6
 
7
7
  import { e as o } from "./index-chunk2.mjs";
8
8
 
9
- import { p as l } from "./index-chunk.mjs";
9
+ import { p as s } from "./index-chunk.mjs";
10
10
 
11
- var s = "FragmentDefinition";
11
+ var l = "FragmentDefinition";
12
12
 
13
13
  class GraphQLError extends Error {
14
- constructor(e, i, n, r, a, t, o) {
15
- super(e);
16
- this.name = "GraphQLError";
17
- this.message = e;
18
- if (a) {
19
- this.path = a;
14
+ constructor(e, i, r, n, t, a, o) {
15
+ if (super(e), this.name = "GraphQLError", this.message = e, t) {
16
+ this.path = t;
20
17
  }
21
18
  if (i) {
22
19
  this.nodes = Array.isArray(i) ? i : [ i ];
23
20
  }
24
- if (n) {
25
- this.source = n;
26
- }
27
21
  if (r) {
28
- this.positions = r;
22
+ this.source = r;
29
23
  }
30
- if (t) {
31
- this.originalError = t;
24
+ if (n) {
25
+ this.positions = n;
26
+ }
27
+ if (a) {
28
+ this.originalError = a;
32
29
  }
33
- var l = o;
34
- if (!l && t) {
35
- var s = t.extensions;
36
- if (s && "object" == typeof s) {
37
- l = s;
30
+ var s = o;
31
+ if (!s && a) {
32
+ var l = a.extensions;
33
+ if (l && "object" == typeof l) {
34
+ s = l;
38
35
  }
39
36
  }
40
- this.extensions = l || {};
37
+ this.extensions = s || {};
41
38
  }
42
39
  toJSON() {
43
40
  return {
@@ -53,566 +50,563 @@ class GraphQLError extends Error {
53
50
  }
54
51
  }
55
52
 
56
- var u;
57
-
58
53
  var d;
59
54
 
55
+ var c;
56
+
60
57
  function error(e) {
61
- return new GraphQLError(`Syntax Error: Unexpected token at ${d} in ${e}`);
58
+ return new GraphQLError(`Syntax Error: Unexpected token at ${c} in ${e}`);
62
59
  }
63
60
 
64
61
  function advance(e) {
65
- e.lastIndex = d;
66
- if (e.test(u)) {
67
- return u.slice(d, d = e.lastIndex);
62
+ if (e.lastIndex = c, e.test(d)) {
63
+ return d.slice(c, c = e.lastIndex);
68
64
  }
69
65
  }
70
66
 
71
- var c = / +(?=[^\s])/y;
67
+ var u = / +(?=[^\s])/y;
72
68
 
73
69
  function blockString(e) {
74
70
  var i = e.split("\n");
75
- var n = "";
76
- var r = 0;
77
- var a = 0;
78
- var t = i.length - 1;
71
+ var r = "";
72
+ var n = 0;
73
+ var t = 0;
74
+ var a = i.length - 1;
79
75
  for (var o = 0; o < i.length; o++) {
80
- c.lastIndex = 0;
81
- if (c.test(i[o])) {
82
- if (o && (!r || c.lastIndex < r)) {
83
- r = c.lastIndex;
76
+ if (u.lastIndex = 0, u.test(i[o])) {
77
+ if (o && (!n || u.lastIndex < n)) {
78
+ n = u.lastIndex;
84
79
  }
85
- a = a || o;
86
- t = o;
80
+ t = t || o, a = o;
87
81
  }
88
82
  }
89
- for (var l = a; l <= t; l++) {
90
- if (l !== a) {
91
- n += "\n";
83
+ for (var s = t; s <= a; s++) {
84
+ if (s !== t) {
85
+ r += "\n";
92
86
  }
93
- n += i[l].slice(r).replace(/\\"""/g, '"""');
87
+ r += i[s].slice(n).replace(/\\"""/g, '"""');
94
88
  }
95
- return n;
89
+ return r;
96
90
  }
97
91
 
98
92
  function ignored() {
99
- for (var e = 0 | u.charCodeAt(d++); 9 === e || 10 === e || 13 === e || 32 === e || 35 === e || 44 === e || 65279 === e; e = 0 | u.charCodeAt(d++)) {
93
+ for (var e = 0 | d.charCodeAt(c++); 9 === e || 10 === e || 13 === e || 32 === e || 35 === e || 44 === e || 65279 === e; e = 0 | d.charCodeAt(c++)) {
100
94
  if (35 === e) {
101
- while (10 !== (e = u.charCodeAt(d++)) && 13 !== e) {}
95
+ for (;(e = 0 | d.charCodeAt(c++)) && 10 !== e && 13 !== e; ) {}
102
96
  }
103
97
  }
104
- d--;
98
+ c--;
105
99
  }
106
100
 
107
- var v = /[_A-Za-z]\w*/y;
101
+ function name() {
102
+ var e = c;
103
+ for (var i = 0 | d.charCodeAt(c++); i >= 48 && i <= 57 || i >= 65 && i <= 90 || 95 === i || i >= 97 && i <= 122; i = 0 | d.charCodeAt(c++)) {}
104
+ if (e === c - 1) {
105
+ throw error("Name");
106
+ }
107
+ var r = d.slice(e, --c);
108
+ return ignored(), r;
109
+ }
108
110
 
109
- var f = new RegExp("(?:(null|true|false)|\\$(" + v.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + v.source + "))", "y");
111
+ function nameNode() {
112
+ return {
113
+ kind: "Name",
114
+ value: name()
115
+ };
116
+ }
110
117
 
111
- var m = function(e) {
112
- e[e.Const = 1] = "Const";
113
- e[e.Var = 2] = "Var";
114
- e[e.Int = 3] = "Int";
115
- e[e.Float = 4] = "Float";
116
- e[e.BlockString = 5] = "BlockString";
117
- e[e.String = 6] = "String";
118
- e[e.Enum = 7] = "Enum";
119
- return e;
120
- }(m || {});
118
+ var f = /(?:"""|(?:[\s\S]*?[^\\])""")/y;
121
119
 
122
- var g = /\\/g;
120
+ var v = /(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;
123
121
 
124
122
  function value(e) {
125
123
  var i;
126
- var n;
127
- f.lastIndex = d;
128
- if (91 === u.charCodeAt(d)) {
129
- d++;
130
- ignored();
124
+ switch (d.charCodeAt(c)) {
125
+ case 91:
126
+ c++, ignored();
131
127
  var r = [];
132
- while (93 !== u.charCodeAt(d)) {
128
+ for (;93 !== d.charCodeAt(c); ) {
133
129
  r.push(value(e));
134
130
  }
135
- d++;
136
- ignored();
137
- return {
131
+ return c++, ignored(), {
138
132
  kind: "ListValue",
139
133
  values: r
140
134
  };
141
- } else if (123 === u.charCodeAt(d)) {
142
- d++;
143
- ignored();
144
- var a = [];
145
- while (125 !== u.charCodeAt(d)) {
146
- if (null == (i = advance(v))) {
147
- throw error("ObjectField");
148
- }
149
- ignored();
150
- if (58 !== u.charCodeAt(d++)) {
135
+
136
+ case 123:
137
+ c++, ignored();
138
+ var n = [];
139
+ for (;125 !== d.charCodeAt(c); ) {
140
+ var t = nameNode();
141
+ if (58 !== d.charCodeAt(c++)) {
151
142
  throw error("ObjectField");
152
143
  }
153
- ignored();
154
- a.push({
144
+ ignored(), n.push({
155
145
  kind: "ObjectField",
156
- name: {
157
- kind: "Name",
158
- value: i
159
- },
146
+ name: t,
160
147
  value: value(e)
161
148
  });
162
149
  }
163
- d++;
164
- ignored();
165
- return {
150
+ return c++, ignored(), {
166
151
  kind: "ObjectValue",
167
- fields: a
152
+ fields: n
168
153
  };
169
- } else if (null != (n = f.exec(u))) {
170
- d = f.lastIndex;
171
- ignored();
172
- if (null != (i = n[m.Const])) {
173
- return "null" === i ? {
174
- kind: "NullValue"
175
- } : {
176
- kind: "BooleanValue",
177
- value: "true" === i
178
- };
179
- } else if (null != (i = n[m.Var])) {
180
- if (e) {
181
- throw error("Variable");
182
- } else {
183
- return {
184
- kind: "Variable",
185
- name: {
186
- kind: "Name",
187
- value: i
188
- }
189
- };
190
- }
191
- } else if (null != (i = n[m.Int])) {
192
- var t;
193
- if (null != (t = n[m.Float])) {
194
- return {
195
- kind: "FloatValue",
196
- value: i + t
197
- };
198
- } else {
199
- return {
200
- kind: "IntValue",
201
- value: i
202
- };
154
+
155
+ case 36:
156
+ if (e) {
157
+ throw error("Variable");
158
+ }
159
+ return c++, {
160
+ kind: "Variable",
161
+ name: nameNode()
162
+ };
163
+
164
+ case 34:
165
+ if (34 === d.charCodeAt(c + 1) && 34 === d.charCodeAt(c + 2)) {
166
+ if (c += 3, null == (i = advance(f))) {
167
+ throw error("StringValue");
203
168
  }
204
- } else if (null != (i = n[m.BlockString])) {
205
- return {
169
+ return ignored(), {
206
170
  kind: "StringValue",
207
- value: blockString(i.slice(3, -3)),
171
+ value: blockString(i.slice(0, -3)),
208
172
  block: !0
209
173
  };
210
- } else if (null != (i = n[m.String])) {
211
- return {
174
+ } else {
175
+ var a = c;
176
+ var o;
177
+ c++;
178
+ var s = !1;
179
+ for (o = 0 | d.charCodeAt(c++); 92 === o && (c++, s = !0) || 10 !== o && 13 !== o && 34 !== o && o; o = 0 | d.charCodeAt(c++)) {}
180
+ if (34 !== o) {
181
+ throw error("StringValue");
182
+ }
183
+ return i = d.slice(a, c), ignored(), {
212
184
  kind: "StringValue",
213
- value: g.test(i) ? JSON.parse(i) : i.slice(1, -1),
185
+ value: s ? JSON.parse(i) : i.slice(1, -1),
214
186
  block: !1
215
187
  };
216
- } else if (null != (i = n[m.Enum])) {
217
- return {
218
- kind: "EnumValue",
219
- value: i
188
+ }
189
+
190
+ case 45:
191
+ case 48:
192
+ case 49:
193
+ case 50:
194
+ case 51:
195
+ case 52:
196
+ case 53:
197
+ case 54:
198
+ case 55:
199
+ case 56:
200
+ case 57:
201
+ var l = c++;
202
+ var u;
203
+ for (;(u = 0 | d.charCodeAt(c++)) >= 48 && u <= 57; ) {}
204
+ var m = d.slice(l, --c);
205
+ if (46 === (u = d.charCodeAt(c)) || 69 === u || 101 === u) {
206
+ if (null == (i = advance(v))) {
207
+ throw error("FloatValue");
208
+ }
209
+ return ignored(), {
210
+ kind: "FloatValue",
211
+ value: m + i
212
+ };
213
+ } else {
214
+ return ignored(), {
215
+ kind: "IntValue",
216
+ value: m
220
217
  };
221
218
  }
219
+
220
+ case 110:
221
+ if (117 === d.charCodeAt(c + 1) && 108 === d.charCodeAt(c + 2) && 108 === d.charCodeAt(c + 3)) {
222
+ return c += 4, ignored(), {
223
+ kind: "NullValue"
224
+ };
225
+ } else {
226
+ break;
227
+ }
228
+
229
+ case 116:
230
+ if (114 === d.charCodeAt(c + 1) && 117 === d.charCodeAt(c + 2) && 101 === d.charCodeAt(c + 3)) {
231
+ return c += 4, ignored(), {
232
+ kind: "BooleanValue",
233
+ value: !0
234
+ };
235
+ } else {
236
+ break;
237
+ }
238
+
239
+ case 102:
240
+ if (97 === d.charCodeAt(c + 1) && 108 === d.charCodeAt(c + 2) && 115 === d.charCodeAt(c + 3) && 101 === d.charCodeAt(c + 4)) {
241
+ return c += 5, ignored(), {
242
+ kind: "BooleanValue",
243
+ value: !1
244
+ };
245
+ } else {
246
+ break;
247
+ }
222
248
  }
223
- throw error("Value");
249
+ return {
250
+ kind: "EnumValue",
251
+ value: name()
252
+ };
224
253
  }
225
254
 
226
255
  function arguments_(e) {
227
- if (40 === u.charCodeAt(d)) {
256
+ if (40 === d.charCodeAt(c)) {
228
257
  var i = [];
229
- d++;
230
- ignored();
231
- var n;
258
+ c++, ignored();
232
259
  do {
233
- if (null == (n = advance(v))) {
234
- throw error("Argument");
235
- }
236
- ignored();
237
- if (58 !== u.charCodeAt(d++)) {
260
+ var r = nameNode();
261
+ if (58 !== d.charCodeAt(c++)) {
238
262
  throw error("Argument");
239
263
  }
240
- ignored();
241
- i.push({
264
+ ignored(), i.push({
242
265
  kind: "Argument",
243
- name: {
244
- kind: "Name",
245
- value: n
246
- },
266
+ name: r,
247
267
  value: value(e)
248
268
  });
249
- } while (41 !== u.charCodeAt(d));
250
- d++;
251
- ignored();
252
- return i;
269
+ } while (41 !== d.charCodeAt(c));
270
+ return c++, ignored(), i;
253
271
  }
254
272
  }
255
273
 
256
274
  function directives(e) {
257
- if (64 === u.charCodeAt(d)) {
275
+ if (64 === d.charCodeAt(c)) {
258
276
  var i = [];
259
- var n;
260
277
  do {
261
- d++;
262
- if (null == (n = advance(v))) {
263
- throw error("Directive");
264
- }
265
- ignored();
266
- i.push({
278
+ c++, i.push({
267
279
  kind: "Directive",
268
- name: {
269
- kind: "Name",
270
- value: n
271
- },
280
+ name: nameNode(),
272
281
  arguments: arguments_(e)
273
282
  });
274
- } while (64 === u.charCodeAt(d));
283
+ } while (64 === d.charCodeAt(c));
275
284
  return i;
276
285
  }
277
286
  }
278
287
 
279
288
  function type() {
280
- var e;
281
- var i = 0;
282
- while (91 === u.charCodeAt(d)) {
283
- i++;
284
- d++;
285
- ignored();
286
- }
287
- if (null == (e = advance(v))) {
288
- throw error("NamedType");
289
+ var e = 0;
290
+ for (;91 === d.charCodeAt(c); ) {
291
+ e++, c++, ignored();
289
292
  }
290
- ignored();
291
- var n = {
293
+ var i = {
292
294
  kind: "NamedType",
293
- name: {
294
- kind: "Name",
295
- value: e
296
- }
295
+ name: nameNode()
297
296
  };
298
297
  do {
299
- if (33 === u.charCodeAt(d)) {
300
- d++;
301
- ignored();
302
- n = {
298
+ if (33 === d.charCodeAt(c)) {
299
+ c++, ignored(), i = {
303
300
  kind: "NonNullType",
304
- type: n
301
+ type: i
305
302
  };
306
303
  }
307
- if (i) {
308
- if (93 !== u.charCodeAt(d++)) {
304
+ if (e) {
305
+ if (93 !== d.charCodeAt(c++)) {
309
306
  throw error("NamedType");
310
307
  }
311
- ignored();
312
- n = {
308
+ ignored(), i = {
313
309
  kind: "ListType",
314
- type: n
310
+ type: i
315
311
  };
316
312
  }
317
- } while (i--);
318
- return n;
313
+ } while (e--);
314
+ return i;
319
315
  }
320
316
 
321
- var h = new RegExp("(?:(\\.{3})|(" + v.source + "))", "y");
322
-
323
- var p = function(e) {
324
- e[e.Spread = 1] = "Spread";
325
- e[e.Name = 2] = "Name";
326
- return e;
327
- }(p || {});
317
+ function selectionSetStart() {
318
+ if (123 !== d.charCodeAt(c++)) {
319
+ throw error("SelectionSet");
320
+ }
321
+ return ignored(), selectionSet();
322
+ }
328
323
 
329
324
  function selectionSet() {
330
325
  var e = [];
331
- var i;
332
- var n;
333
326
  do {
334
- h.lastIndex = d;
335
- if (null != (n = h.exec(u))) {
336
- d = h.lastIndex;
337
- if (null != n[p.Spread]) {
338
- ignored();
339
- var r = advance(v);
340
- if (null != r && "on" !== r) {
341
- ignored();
342
- e.push({
343
- kind: "FragmentSpread",
344
- name: {
345
- kind: "Name",
346
- value: r
327
+ if (46 === d.charCodeAt(c)) {
328
+ if (46 !== d.charCodeAt(++c) || 46 !== d.charCodeAt(++c)) {
329
+ throw error("SelectionSet");
330
+ }
331
+ switch (c++, ignored(), d.charCodeAt(c)) {
332
+ case 64:
333
+ e.push({
334
+ kind: "InlineFragment",
335
+ typeCondition: void 0,
336
+ directives: directives(!1),
337
+ selectionSet: selectionSetStart()
338
+ });
339
+ break;
340
+
341
+ case 111:
342
+ if (110 === d.charCodeAt(c + 1)) {
343
+ c += 2, ignored(), e.push({
344
+ kind: "InlineFragment",
345
+ typeCondition: {
346
+ kind: "NamedType",
347
+ name: nameNode()
347
348
  },
348
- directives: directives(!1)
349
+ directives: directives(!1),
350
+ selectionSet: selectionSetStart()
349
351
  });
350
352
  } else {
351
- ignored();
352
- if ("on" === r) {
353
- if (null == (r = advance(v))) {
354
- throw error("NamedType");
355
- }
356
- ignored();
357
- }
358
- var a = directives(!1);
359
- if (123 !== u.charCodeAt(d++)) {
360
- throw error("InlineFragment");
361
- }
362
- ignored();
363
353
  e.push({
364
- kind: "InlineFragment",
365
- typeCondition: r ? {
366
- kind: "NamedType",
367
- name: {
368
- kind: "Name",
369
- value: r
370
- }
371
- } : void 0,
372
- directives: a,
373
- selectionSet: selectionSet()
354
+ kind: "FragmentSpread",
355
+ name: nameNode(),
356
+ directives: directives(!1)
374
357
  });
375
358
  }
376
- } else if (null != (i = n[p.Name])) {
377
- var t = void 0;
378
- ignored();
379
- if (58 === u.charCodeAt(d)) {
380
- d++;
381
- ignored();
382
- t = i;
383
- if (null == (i = advance(v))) {
384
- throw error("Field");
385
- }
386
- ignored();
387
- }
388
- var o = arguments_(!1);
389
- ignored();
390
- var l = directives(!1);
391
- var s = void 0;
392
- if (123 === u.charCodeAt(d)) {
393
- d++;
394
- ignored();
395
- s = selectionSet();
396
- }
359
+ break;
360
+
361
+ case 123:
362
+ c++, ignored(), e.push({
363
+ kind: "InlineFragment",
364
+ typeCondition: void 0,
365
+ directives: void 0,
366
+ selectionSet: selectionSet()
367
+ });
368
+ break;
369
+
370
+ default:
397
371
  e.push({
398
- kind: "Field",
399
- alias: t ? {
400
- kind: "Name",
401
- value: t
402
- } : void 0,
403
- name: {
404
- kind: "Name",
405
- value: i
406
- },
407
- arguments: o,
408
- directives: l,
409
- selectionSet: s
372
+ kind: "FragmentSpread",
373
+ name: nameNode(),
374
+ directives: directives(!1)
410
375
  });
411
376
  }
412
377
  } else {
413
- throw error("SelectionSet");
378
+ var i = nameNode();
379
+ var r = void 0;
380
+ if (58 === d.charCodeAt(c)) {
381
+ c++, ignored(), r = i, i = nameNode();
382
+ }
383
+ var n = arguments_(!1);
384
+ var t = directives(!1);
385
+ var a = void 0;
386
+ if (123 === d.charCodeAt(c)) {
387
+ c++, ignored(), a = selectionSet();
388
+ }
389
+ e.push({
390
+ kind: "Field",
391
+ alias: r,
392
+ name: i,
393
+ arguments: n,
394
+ directives: t,
395
+ selectionSet: a
396
+ });
414
397
  }
415
- } while (125 !== u.charCodeAt(d));
416
- d++;
417
- ignored();
418
- return {
398
+ } while (125 !== d.charCodeAt(c));
399
+ return c++, ignored(), {
419
400
  kind: "SelectionSet",
420
401
  selections: e
421
402
  };
422
403
  }
423
404
 
424
- function fragmentDefinition() {
425
- var e;
426
- var i;
427
- if (null == (e = advance(v))) {
428
- throw error("FragmentDefinition");
429
- }
430
- ignored();
431
- if ("on" !== advance(v)) {
432
- throw error("FragmentDefinition");
433
- }
434
- ignored();
435
- if (null == (i = advance(v))) {
436
- throw error("FragmentDefinition");
405
+ function variableDefinitions() {
406
+ if (ignored(), 40 === d.charCodeAt(c)) {
407
+ var e = [];
408
+ c++, ignored();
409
+ do {
410
+ var i = void 0;
411
+ if (34 === d.charCodeAt(c)) {
412
+ i = value(!0);
413
+ }
414
+ if (36 !== d.charCodeAt(c++)) {
415
+ throw error("Variable");
416
+ }
417
+ var r = nameNode();
418
+ if (58 !== d.charCodeAt(c++)) {
419
+ throw error("VariableDefinition");
420
+ }
421
+ ignored();
422
+ var n = type();
423
+ var t = void 0;
424
+ if (61 === d.charCodeAt(c)) {
425
+ c++, ignored(), t = value(!0);
426
+ }
427
+ ignored();
428
+ var a = {
429
+ kind: "VariableDefinition",
430
+ variable: {
431
+ kind: "Variable",
432
+ name: r
433
+ },
434
+ type: n,
435
+ defaultValue: t,
436
+ directives: directives(!0)
437
+ };
438
+ if (i) {
439
+ a.description = i;
440
+ }
441
+ e.push(a);
442
+ } while (41 !== d.charCodeAt(c));
443
+ return c++, ignored(), e;
437
444
  }
438
- ignored();
439
- var n = directives(!1);
440
- if (123 !== u.charCodeAt(d++)) {
445
+ }
446
+
447
+ function fragmentDefinition(e) {
448
+ var i = nameNode();
449
+ if (111 !== d.charCodeAt(c++) || 110 !== d.charCodeAt(c++)) {
441
450
  throw error("FragmentDefinition");
442
451
  }
443
452
  ignored();
444
- return {
453
+ var r = {
445
454
  kind: "FragmentDefinition",
446
- name: {
447
- kind: "Name",
448
- value: e
449
- },
455
+ name: i,
450
456
  typeCondition: {
451
457
  kind: "NamedType",
452
- name: {
453
- kind: "Name",
454
- value: i
455
- }
458
+ name: nameNode()
456
459
  },
457
- directives: n,
458
- selectionSet: selectionSet()
460
+ directives: directives(!1),
461
+ selectionSet: selectionSetStart()
459
462
  };
463
+ if (e) {
464
+ r.description = e;
465
+ }
466
+ return r;
460
467
  }
461
468
 
462
- var S = /(?:query|mutation|subscription|fragment)/y;
469
+ function definitions() {
470
+ var e = [];
471
+ do {
472
+ var i = void 0;
473
+ if (34 === d.charCodeAt(c)) {
474
+ i = value(!0);
475
+ }
476
+ if (123 === d.charCodeAt(c)) {
477
+ if (i) {
478
+ throw error("Document");
479
+ }
480
+ c++, ignored(), e.push({
481
+ kind: "OperationDefinition",
482
+ operation: "query",
483
+ name: void 0,
484
+ variableDefinitions: void 0,
485
+ directives: void 0,
486
+ selectionSet: selectionSet()
487
+ });
488
+ } else {
489
+ var r = name();
490
+ switch (r) {
491
+ case "fragment":
492
+ e.push(fragmentDefinition(i));
493
+ break;
494
+
495
+ case "query":
496
+ case "mutation":
497
+ case "subscription":
498
+ var n;
499
+ var t = void 0;
500
+ if (40 !== (n = d.charCodeAt(c)) && 64 !== n && 123 !== n) {
501
+ t = nameNode();
502
+ }
503
+ var a = {
504
+ kind: "OperationDefinition",
505
+ operation: r,
506
+ name: t,
507
+ variableDefinitions: variableDefinitions(),
508
+ directives: directives(!1),
509
+ selectionSet: selectionSetStart()
510
+ };
511
+ if (i) {
512
+ a.description = i;
513
+ }
514
+ e.push(a);
515
+ break;
463
516
 
464
- function operationDefinition(e) {
465
- var i;
466
- var n;
467
- var r;
468
- if (e) {
469
- ignored();
470
- i = advance(v);
471
- n = function variableDefinitions() {
472
- ignored();
473
- if (40 === u.charCodeAt(d)) {
474
- var e = [];
475
- d++;
476
- ignored();
477
- var i;
478
- do {
479
- if (36 !== u.charCodeAt(d++)) {
480
- throw error("Variable");
481
- }
482
- if (null == (i = advance(v))) {
483
- throw error("Variable");
484
- }
485
- ignored();
486
- if (58 !== u.charCodeAt(d++)) {
487
- throw error("VariableDefinition");
488
- }
489
- ignored();
490
- var n = type();
491
- var r = void 0;
492
- if (61 === u.charCodeAt(d)) {
493
- d++;
494
- ignored();
495
- r = value(!0);
496
- }
497
- ignored();
498
- e.push({
499
- kind: "VariableDefinition",
500
- variable: {
501
- kind: "Variable",
502
- name: {
503
- kind: "Name",
504
- value: i
505
- }
506
- },
507
- type: n,
508
- defaultValue: r,
509
- directives: directives(!0)
510
- });
511
- } while (41 !== u.charCodeAt(d));
512
- d++;
513
- ignored();
514
- return e;
517
+ default:
518
+ throw error("Document");
515
519
  }
516
- }();
517
- r = directives(!1);
518
- }
519
- if (123 === u.charCodeAt(d)) {
520
- d++;
521
- ignored();
522
- return {
523
- kind: "OperationDefinition",
524
- operation: e || "query",
525
- name: i ? {
526
- kind: "Name",
527
- value: i
528
- } : void 0,
529
- variableDefinitions: n,
530
- directives: r,
531
- selectionSet: selectionSet()
532
- };
533
- }
520
+ }
521
+ } while (c < d.length);
522
+ return e;
534
523
  }
535
524
 
536
525
  function parse(e, i) {
537
- u = "string" == typeof e.body ? e.body : e;
538
- d = 0;
539
- return function document() {
540
- var e;
541
- var i;
542
- ignored();
543
- var n = [];
544
- do {
545
- if ("fragment" === (e = advance(S))) {
546
- ignored();
547
- n.push(fragmentDefinition());
548
- } else if (null != (i = operationDefinition(e))) {
549
- n.push(i);
550
- } else {
551
- throw error("Document");
552
- }
553
- } while (d < u.length);
526
+ if (d = e.body ? e.body : e, c = 0, ignored(), i) {} else {
554
527
  return {
555
528
  kind: "Document",
556
- definitions: n
529
+ definitions: definitions(),
530
+ loc: {
531
+ start: 0,
532
+ end: d.length,
533
+ startToken: void 0,
534
+ endToken: void 0,
535
+ source: {
536
+ body: d,
537
+ name: "graphql.web",
538
+ locationOffset: {
539
+ line: 1,
540
+ column: 1
541
+ }
542
+ }
543
+ }
557
544
  };
558
- }();
545
+ }
559
546
  }
560
547
 
561
- function mapJoin(e, i, n) {
562
- var r = "";
563
- for (var a = 0; a < e.length; a++) {
564
- if (a) {
565
- r += i;
548
+ function mapJoin(e, i, r) {
549
+ var n = "";
550
+ for (var t = 0; t < e.length; t++) {
551
+ if (t) {
552
+ n += i;
566
553
  }
567
- r += n(e[a]);
554
+ n += r(e[t]);
568
555
  }
569
- return r;
556
+ return n;
570
557
  }
571
558
 
572
- var k = "\n";
559
+ var m = "\n";
573
560
 
574
- var y = {
561
+ var h = {
575
562
  OperationDefinition(e) {
576
- var i = e.operation;
577
- if (e.name) {
563
+ var i = "";
564
+ if (e.description) {
565
+ i += h.StringValue(e.description) + "\n";
566
+ }
567
+ if (i += e.operation, e.name) {
578
568
  i += " " + e.name.value;
579
569
  }
580
570
  if (e.variableDefinitions && e.variableDefinitions.length) {
581
571
  if (!e.name) {
582
572
  i += " ";
583
573
  }
584
- i += "(" + mapJoin(e.variableDefinitions, ", ", y.VariableDefinition) + ")";
574
+ i += "(" + mapJoin(e.variableDefinitions, ", ", h.VariableDefinition) + ")";
585
575
  }
586
576
  if (e.directives && e.directives.length) {
587
- i += " " + mapJoin(e.directives, " ", y.Directive);
577
+ i += " " + mapJoin(e.directives, " ", h.Directive);
588
578
  }
589
- return "query" !== i ? i + " " + y.SelectionSet(e.selectionSet) : y.SelectionSet(e.selectionSet);
579
+ var r = h.SelectionSet(e.selectionSet);
580
+ return "query" !== i ? i + " " + r : r;
590
581
  },
591
582
  VariableDefinition(e) {
592
- var i = y.Variable(e.variable) + ": " + _print(e.type);
593
- if (e.defaultValue) {
583
+ var i = "";
584
+ if (e.description) {
585
+ i += h.StringValue(e.description) + " ";
586
+ }
587
+ if (i += h.Variable(e.variable) + ": " + _print(e.type), e.defaultValue) {
594
588
  i += " = " + _print(e.defaultValue);
595
589
  }
596
590
  if (e.directives && e.directives.length) {
597
- i += " " + mapJoin(e.directives, " ", y.Directive);
591
+ i += " " + mapJoin(e.directives, " ", h.Directive);
598
592
  }
599
593
  return i;
600
594
  },
601
595
  Field(e) {
602
596
  var i = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
603
597
  if (e.arguments && e.arguments.length) {
604
- var n = mapJoin(e.arguments, ", ", y.Argument);
605
- if (i.length + n.length + 2 > 80) {
606
- i += "(" + (k += " ") + mapJoin(e.arguments, k, y.Argument) + (k = k.slice(0, -2)) + ")";
598
+ var r = mapJoin(e.arguments, ", ", h.Argument);
599
+ if (i.length + r.length + 2 > 80) {
600
+ i += "(" + (m += " ") + mapJoin(e.arguments, m, h.Argument) + (m = m.slice(0, -2)) + ")";
607
601
  } else {
608
- i += "(" + n + ")";
602
+ i += "(" + r + ")";
609
603
  }
610
604
  }
611
605
  if (e.directives && e.directives.length) {
612
- i += " " + mapJoin(e.directives, " ", y.Directive);
606
+ i += " " + mapJoin(e.directives, " ", h.Directive);
613
607
  }
614
- if (e.selectionSet) {
615
- i += " " + y.SelectionSet(e.selectionSet);
608
+ if (e.selectionSet && e.selectionSet.selections.length) {
609
+ i += " " + h.SelectionSet(e.selectionSet);
616
610
  }
617
611
  return i;
618
612
  },
@@ -620,7 +614,7 @@ var y = {
620
614
  if (e.block) {
621
615
  return function printBlockString(e) {
622
616
  return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
623
- }(e.value).replace(/\n/g, k);
617
+ }(e.value).replace(/\n/g, m);
624
618
  } else {
625
619
  return function printString(e) {
626
620
  return JSON.stringify(e);
@@ -635,20 +629,21 @@ var y = {
635
629
  Name: e => e.value,
636
630
  Variable: e => "$" + e.name.value,
637
631
  ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
638
- ObjectValue: e => "{" + mapJoin(e.fields, ", ", y.ObjectField) + "}",
632
+ ObjectValue: e => "{" + mapJoin(e.fields, ", ", h.ObjectField) + "}",
639
633
  ObjectField: e => e.name.value + ": " + _print(e.value),
640
634
  Document(e) {
641
635
  if (!e.definitions || !e.definitions.length) {
642
636
  return "";
637
+ } else {
638
+ return mapJoin(e.definitions, "\n\n", _print);
643
639
  }
644
- return mapJoin(e.definitions, "\n\n", _print);
645
640
  },
646
- SelectionSet: e => "{" + (k += " ") + mapJoin(e.selections, k, _print) + (k = k.slice(0, -2)) + "}",
641
+ SelectionSet: e => "{" + (m += " ") + mapJoin(e.selections, m, _print) + (m = m.slice(0, -2)) + "}",
647
642
  Argument: e => e.name.value + ": " + _print(e.value),
648
643
  FragmentSpread(e) {
649
644
  var i = "..." + e.name.value;
650
645
  if (e.directives && e.directives.length) {
651
- i += " " + mapJoin(e.directives, " ", y.Directive);
646
+ i += " " + mapJoin(e.directives, " ", h.Directive);
652
647
  }
653
648
  return i;
654
649
  },
@@ -658,22 +653,24 @@ var y = {
658
653
  i += " on " + e.typeCondition.name.value;
659
654
  }
660
655
  if (e.directives && e.directives.length) {
661
- i += " " + mapJoin(e.directives, " ", y.Directive);
656
+ i += " " + mapJoin(e.directives, " ", h.Directive);
662
657
  }
663
- return i + " " + y.SelectionSet(e.selectionSet);
658
+ return i + " " + h.SelectionSet(e.selectionSet);
664
659
  },
665
660
  FragmentDefinition(e) {
666
- var i = "fragment " + e.name.value;
667
- i += " on " + e.typeCondition.name.value;
668
- if (e.directives && e.directives.length) {
669
- i += " " + mapJoin(e.directives, " ", y.Directive);
661
+ var i = "";
662
+ if (e.description) {
663
+ i += h.StringValue(e.description) + "\n";
664
+ }
665
+ if (i += "fragment " + e.name.value, i += " on " + e.typeCondition.name.value, e.directives && e.directives.length) {
666
+ i += " " + mapJoin(e.directives, " ", h.Directive);
670
667
  }
671
- return i + " " + y.SelectionSet(e.selectionSet);
668
+ return i + " " + h.SelectionSet(e.selectionSet);
672
669
  },
673
670
  Directive(e) {
674
671
  var i = "@" + e.name.value;
675
672
  if (e.arguments && e.arguments.length) {
676
- i += "(" + mapJoin(e.arguments, ", ", y.Argument) + ")";
673
+ i += "(" + mapJoin(e.arguments, ", ", h.Argument) + ")";
677
674
  }
678
675
  return i;
679
676
  },
@@ -682,119 +679,118 @@ var y = {
682
679
  NonNullType: e => _print(e.type) + "!"
683
680
  };
684
681
 
685
- var _print = e => y[e.kind](e);
682
+ var _print = e => h[e.kind](e);
686
683
 
687
684
  function print(e) {
688
- k = "\n";
689
- return y[e.kind] ? y[e.kind](e) : "";
685
+ return m = "\n", h[e.kind] ? h[e.kind](e) : "";
690
686
  }
691
687
 
692
- var N = o((async function* _runPersisted(o) {
693
- var u = i(o.pluginConfig);
694
- var d = l(o);
695
- var c = d.createExternalFiles();
696
- if (c.length) {
688
+ var g = o((async function* _runPersisted(o) {
689
+ var d = i(o.pluginConfig);
690
+ var c = s(o);
691
+ var u = c.createExternalFiles();
692
+ if (u.length) {
697
693
  yield {
698
694
  kind: "EXTERNAL_WARNING"
699
695
  };
700
- await d.addVirtualFiles(c);
696
+ await c.addVirtualFiles(u);
701
697
  }
702
- var v = d.build();
703
- var f = v.buildPluginInfo(o.pluginConfig);
704
- var m = v.getSourceFiles();
698
+ var f = c.build();
699
+ var v = f.buildPluginInfo(o.pluginConfig);
700
+ var m = f.getSourceFiles();
705
701
  yield {
706
702
  kind: "FILE_COUNT",
707
703
  fileCount: m.length
708
704
  };
709
- for (var g of m) {
710
- var h = g.fileName;
705
+ for (var h of m) {
706
+ var g = h.fileName;
711
707
  var p = [];
712
708
  var S = [];
713
- var k = n(g, f);
714
- for (var y of k) {
715
- var N = v.getSourcePosition(g, y.node.getStart());
716
- h = N.fileName;
717
- if (!u.has(y.schema)) {
709
+ var C = r(h, v);
710
+ for (var A of C) {
711
+ var k = f.getSourcePosition(h, A.node.getStart());
712
+ g = k.fileName;
713
+ if (!d.has(A.schema)) {
718
714
  S.push({
719
- message: y.schema ? `The '${y.schema}' schema is not in the configuration but was referenced by "graphql.persisted".` : u.size > 1 ? "The document is not for a known schema. Have you re-generated the output file?" : "Multiple schemas are configured, but the document is not for a specific schema.",
720
- file: N.fileName,
721
- line: N.line,
722
- col: N.col
715
+ message: A.schema ? `The '${A.schema}' schema is not in the configuration but was referenced by "graphql.persisted".` : d.size > 1 ? "The document is not for a known schema. Have you re-generated the output file?" : "Multiple schemas are configured, but the document is not for a specific schema.",
716
+ file: k.fileName,
717
+ line: k.line,
718
+ col: k.col
723
719
  });
724
720
  continue;
725
721
  }
726
- var b = y.node.arguments[0];
727
- var C = y.node.arguments[1];
728
- var w = y.node.typeArguments && y.node.typeArguments[0];
722
+ var b = A.node.arguments[0];
723
+ var y = A.node.arguments[1];
724
+ var N = A.node.typeArguments && A.node.typeArguments[0];
729
725
  if (!b || !e.isStringLiteral(b)) {
730
726
  S.push({
731
727
  message: '"graphql.persisted" must be called with a string literal as the first argument.',
732
- file: N.fileName,
733
- line: N.line,
734
- col: N.col
728
+ file: k.fileName,
729
+ line: k.line,
730
+ col: k.col
735
731
  });
736
732
  continue;
737
- } else if (!C && !w) {
733
+ } else if (!y && !N) {
738
734
  S.push({
739
735
  message: '"graphql.persisted" is missing a document.\nThis may be passed as a generic such as `graphql.persisted<typeof document>` or as the second argument.',
740
- file: N.fileName,
741
- line: N.line,
742
- col: N.col
736
+ file: k.fileName,
737
+ line: k.line,
738
+ col: k.col
743
739
  });
744
740
  continue;
745
741
  }
746
- var A = null;
747
- var V = y.node;
748
- if (C && (e.isCallExpression(C) || e.isIdentifier(C))) {
749
- A = r(C, g.fileName, f).node;
750
- V = C;
751
- } else if (w && e.isTypeQueryNode(w)) {
752
- A = a(w, g.fileName, f).node;
753
- V = w;
742
+ var V = null;
743
+ var w = A.node;
744
+ if (y && (e.isCallExpression(y) || e.isIdentifier(y))) {
745
+ V = n(y, h.fileName, v).node;
746
+ w = y;
747
+ } else if (N && e.isTypeQueryNode(N)) {
748
+ V = t(N, h.fileName, v).node;
749
+ w = N;
754
750
  }
755
- if (!A) {
751
+ if (!V) {
756
752
  S.push({
757
- message: `Could not find reference for "${V.getText()}".\nIf this is unexpected, please file an issue describing your case.`,
758
- file: N.fileName,
759
- line: N.line,
760
- col: N.col
753
+ message: `Could not find reference for "${w.getText()}".\nIf this is unexpected, please file an issue describing your case.`,
754
+ file: k.fileName,
755
+ line: k.line,
756
+ col: k.col
761
757
  });
762
758
  continue;
763
759
  }
764
- if (!A || !e.isCallExpression(A) || !e.isNoSubstitutionTemplateLiteral(A.arguments[0]) && !e.isStringLiteral(A.arguments[0])) {
760
+ if (!V || !e.isCallExpression(V) || !e.isNoSubstitutionTemplateLiteral(V.arguments[0]) && !e.isStringLiteral(V.arguments[0])) {
765
761
  S.push({
766
- message: `The referenced document of "${V.getText()}" contains no document string literal.\nIf this is unexpected, please file an issue describing your case.`,
767
- file: N.fileName,
768
- line: N.line,
769
- col: N.col
762
+ message: `The referenced document of "${w.getText()}" contains no document string literal.\nIf this is unexpected, please file an issue describing your case.`,
763
+ file: k.fileName,
764
+ line: k.line,
765
+ col: k.col
770
766
  });
771
767
  continue;
772
768
  }
773
769
  var D = [];
774
- var x = A.arguments[0].getText().slice(1, -1);
775
- if (A.arguments[1] && e.isArrayLiteralExpression(A.arguments[1])) {
776
- t(A.arguments[1], D, v.buildPluginInfo(o.pluginConfig));
770
+ var T = V.arguments[0].getText().slice(1, -1);
771
+ if (V.arguments[1] && e.isArrayLiteralExpression(V.arguments[1])) {
772
+ a(V.arguments[1], D, f.buildPluginInfo(o.pluginConfig));
777
773
  }
778
774
  var F = new Set;
779
- var T = void 0;
775
+ var x = void 0;
780
776
  if (o.disableNormalization) {
781
- T = x;
777
+ x = T;
782
778
  } else {
783
779
  try {
784
- var I = parse(x);
785
- var E = new Set;
786
- for (var J of I.definitions) {
787
- if (J.kind === s && !E.has(J)) {
780
+ var E = parse(T);
781
+ var I = new Set;
782
+ for (var J of E.definitions) {
783
+ if (J.kind === l && !I.has(J)) {
788
784
  stripUnmaskDirectivesFromDefinition(J);
789
785
  }
790
786
  }
791
- T = print(I);
787
+ x = print(E);
792
788
  } catch (e) {
793
789
  S.push({
794
- message: `The referenced document of "${V.getText()}" could not be parsed.\nRun \`check\` to see specific validation errors.`,
795
- file: N.fileName,
796
- line: N.line,
797
- col: N.col
790
+ message: `The referenced document of "${w.getText()}" could not be parsed.\nRun \`check\` to see specific validation errors.`,
791
+ file: k.fileName,
792
+ line: k.line,
793
+ col: k.col
798
794
  });
799
795
  continue;
800
796
  }
@@ -803,19 +799,19 @@ var N = o((async function* _runPersisted(o) {
803
799
  stripUnmaskDirectivesFromDefinition(L);
804
800
  var O = print(L);
805
801
  if (!F.has(O)) {
806
- T += "\n\n" + print(L);
802
+ x += "\n\n" + print(L);
807
803
  F.add(O);
808
804
  }
809
805
  }
810
806
  p.push({
811
- schemaName: y.schema,
807
+ schemaName: A.schema,
812
808
  hashKey: b.getText().slice(1, -1),
813
- document: T
809
+ document: x
814
810
  });
815
811
  }
816
812
  yield {
817
813
  kind: "FILE_PERSISTED",
818
- filePath: h,
814
+ filePath: g,
819
815
  documents: p,
820
816
  warnings: S
821
817
  };
@@ -826,5 +822,5 @@ var stripUnmaskDirectivesFromDefinition = e => {
826
822
  e.directives = e.directives?.filter((e => "_unmask" !== e.name.value));
827
823
  };
828
824
 
829
- export { N as runPersisted };
825
+ export { g as runPersisted };
830
826
  //# sourceMappingURL=thread-chunk.mjs.map