@wirechunk/cli 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.js CHANGED
@@ -3907,6 +3907,24 @@ const cleanTinyId = () => {
3907
3907
  };
3908
3908
  const domainRegex = /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i;
3909
3909
  const validDomain = (domain) => domainRegex.test(domain);
3910
+ const removeColons = (domain) => domain.replaceAll(":", "");
3911
+ const normalizeDomain = (domain, { allowPort = false } = {}) => {
3912
+ let normalizedDomain = domain.trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/\.+/g, ".").replace(/[^a-z0-9.:-]/g, "");
3913
+ if (allowPort) {
3914
+ const lastColonIndex = normalizedDomain.lastIndexOf(":");
3915
+ if (lastColonIndex !== normalizedDomain.indexOf(":")) {
3916
+ normalizedDomain = removeColons(normalizedDomain);
3917
+ } else {
3918
+ const port = normalizedDomain.slice(lastColonIndex + 1);
3919
+ if (!/^\d{1,4}$/.test(port)) {
3920
+ normalizedDomain = removeColons(normalizedDomain);
3921
+ }
3922
+ }
3923
+ } else {
3924
+ normalizedDomain = removeColons(normalizedDomain);
3925
+ }
3926
+ return normalizedDomain || null;
3927
+ };
3910
3928
  const extractParts = (email) => {
3911
3929
  const [name, domain] = email.split("@");
3912
3930
  return { name, domain };
@@ -3937,102 +3955,17 @@ const normalizeEmailAddress = (email) => {
3937
3955
  }
3938
3956
  return { ok: true, value: emailTrimmed };
3939
3957
  };
3958
+ const siteDomainKey = "siteDomain";
3959
+ const submittedAtKey = "submittedAt";
3940
3960
  const defaultFormattedDataTemplate = `{{#each .}}{{@key}}: {{{.}}}
3941
3961
  {{/each}}`;
3942
- const siteDomainKey = "siteDomain";
3943
- const formattedDataKey = "formattedData";
3944
3962
  const defaultNotificationEmailBodyTemplate = `Form entry from your site {{${siteDomainKey}}}:
3945
3963
 
3946
- {{{${formattedDataKey}}}}
3964
+ {{#each .}}{{@key}}: {{{.}}}
3965
+ {{/each}}
3966
+
3967
+ Submitted {{${submittedAtKey}}}
3947
3968
  `;
3948
- var DeploymentEnvironment = /* @__PURE__ */ ((DeploymentEnvironment2) => {
3949
- DeploymentEnvironment2["Development"] = "development";
3950
- DeploymentEnvironment2["Production"] = "production";
3951
- DeploymentEnvironment2["Staging"] = "staging";
3952
- DeploymentEnvironment2["Test"] = "test";
3953
- return DeploymentEnvironment2;
3954
- })(DeploymentEnvironment || {});
3955
- const deploymentEnvironments = Object.values(DeploymentEnvironment);
3956
- const isDeploymentEnvironment = (value) => deploymentEnvironments.includes(value);
3957
- const nodeEnv = process.env.NODE_ENV;
3958
- const deploymentEnv = process.env.DEPLOYMENT_ENVIRONMENT;
3959
- const deploymentEnvironmentDefaultProduction = (rawDeploymentEnv) => {
3960
- if (isDeploymentEnvironment(rawDeploymentEnv)) {
3961
- return rawDeploymentEnv;
3962
- }
3963
- if (!rawDeploymentEnv) {
3964
- return DeploymentEnvironment.Production;
3965
- }
3966
- throw new Error(`Invalid deployment environment: ${rawDeploymentEnv}`);
3967
- };
3968
- const environment = nodeEnv === "test" ? DeploymentEnvironment.Test : nodeEnv === "development" ? DeploymentEnvironment.Development : deploymentEnvironmentDefaultProduction(deploymentEnv);
3969
- const forceCloudDeployment = process.env.FORCE_CLOUD_DEPLOYMENT === "true";
3970
- const cloudDeployment = environment === DeploymentEnvironment.Production || environment === DeploymentEnvironment.Staging || forceCloudDeployment;
3971
- process.env.APP_VERSION || "";
3972
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
3973
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
3974
- var root = freeGlobal || freeSelf || Function("return this")();
3975
- var Symbol$1 = root.Symbol;
3976
- var objectProto$1 = Object.prototype;
3977
- var hasOwnProperty$2 = objectProto$1.hasOwnProperty;
3978
- var nativeObjectToString$1 = objectProto$1.toString;
3979
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
3980
- function getRawTag(value) {
3981
- var isOwn = hasOwnProperty$2.call(value, symToStringTag$1), tag = value[symToStringTag$1];
3982
- try {
3983
- value[symToStringTag$1] = void 0;
3984
- var unmasked = true;
3985
- } catch (e) {
3986
- }
3987
- var result2 = nativeObjectToString$1.call(value);
3988
- if (unmasked) {
3989
- if (isOwn) {
3990
- value[symToStringTag$1] = tag;
3991
- } else {
3992
- delete value[symToStringTag$1];
3993
- }
3994
- }
3995
- return result2;
3996
- }
3997
- var objectProto = Object.prototype;
3998
- var nativeObjectToString = objectProto.toString;
3999
- function objectToString(value) {
4000
- return nativeObjectToString.call(value);
4001
- }
4002
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
4003
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
4004
- function baseGetTag(value) {
4005
- if (value == null) {
4006
- return value === void 0 ? undefinedTag : nullTag;
4007
- }
4008
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
4009
- }
4010
- function isObjectLike(value) {
4011
- return value != null && typeof value == "object";
4012
- }
4013
- var isArray = Array.isArray;
4014
- var stringTag = "[object String]";
4015
- function isString(value) {
4016
- return typeof value == "string" || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag;
4017
- }
4018
- const removeColons = (domain) => domain.replaceAll(":", "");
4019
- const normalizeDomain = (domain, { allowPort = !cloudDeployment } = {}) => {
4020
- let normalizedDomain = domain.trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/\.+/g, ".").replace(/[^a-z0-9.:-]/g, "");
4021
- if (allowPort) {
4022
- const lastColonIndex = normalizedDomain.lastIndexOf(":");
4023
- if (lastColonIndex !== normalizedDomain.indexOf(":")) {
4024
- normalizedDomain = removeColons(normalizedDomain);
4025
- } else {
4026
- const port = normalizedDomain.slice(lastColonIndex + 1);
4027
- if (!/^\d{1,4}$/.test(port)) {
4028
- normalizedDomain = removeColons(normalizedDomain);
4029
- }
4030
- }
4031
- } else {
4032
- normalizedDomain = removeColons(normalizedDomain);
4033
- }
4034
- return normalizedDomain || null;
4035
- };
4036
3969
  var dist$b = {};
4037
3970
  var dist$a = {};
4038
3971
  var createSqlTag = {};
@@ -4067,18 +4000,18 @@ function requireConstants$3() {
4067
4000
  };
4068
4001
  return constants$3;
4069
4002
  }
4070
- var hasOwnProperty$1 = {};
4003
+ var hasOwnProperty$2 = {};
4071
4004
  var hasRequiredHasOwnProperty$1;
4072
4005
  function requireHasOwnProperty$1() {
4073
- if (hasRequiredHasOwnProperty$1) return hasOwnProperty$1;
4006
+ if (hasRequiredHasOwnProperty$1) return hasOwnProperty$2;
4074
4007
  hasRequiredHasOwnProperty$1 = 1;
4075
- Object.defineProperty(hasOwnProperty$1, "__esModule", { value: true });
4076
- hasOwnProperty$1.hasOwnProperty = void 0;
4008
+ Object.defineProperty(hasOwnProperty$2, "__esModule", { value: true });
4009
+ hasOwnProperty$2.hasOwnProperty = void 0;
4077
4010
  const hasOwnProperty2 = (object, property) => {
4078
4011
  return Object.prototype.hasOwnProperty.call(object, property);
4079
4012
  };
4080
- hasOwnProperty$1.hasOwnProperty = hasOwnProperty2;
4081
- return hasOwnProperty$1;
4013
+ hasOwnProperty$2.hasOwnProperty = hasOwnProperty2;
4014
+ return hasOwnProperty$2;
4082
4015
  }
4083
4016
  var isBrowser = {};
4084
4017
  var hasRequiredIsBrowser;
@@ -4529,7 +4462,7 @@ function requireSafeStableStringify() {
4529
4462
  return circularValue;
4530
4463
  }
4531
4464
  let res = "";
4532
- let join = ",";
4465
+ let join2 = ",";
4533
4466
  const originalIndentation = indentation;
4534
4467
  if (Array.isArray(value)) {
4535
4468
  if (value.length === 0) {
@@ -4543,7 +4476,7 @@ function requireSafeStableStringify() {
4543
4476
  indentation += spacer;
4544
4477
  res += `
4545
4478
  ${indentation}`;
4546
- join = `,
4479
+ join2 = `,
4547
4480
  ${indentation}`;
4548
4481
  }
4549
4482
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -4551,13 +4484,13 @@ ${indentation}`;
4551
4484
  for (; i < maximumValuesToStringify - 1; i++) {
4552
4485
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
4553
4486
  res += tmp2 !== void 0 ? tmp2 : "null";
4554
- res += join;
4487
+ res += join2;
4555
4488
  }
4556
4489
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
4557
4490
  res += tmp !== void 0 ? tmp : "null";
4558
4491
  if (value.length - 1 > maximumBreadth) {
4559
4492
  const removedKeys = value.length - maximumBreadth - 1;
4560
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
4493
+ res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
4561
4494
  }
4562
4495
  if (spacer !== "") {
4563
4496
  res += `
@@ -4578,7 +4511,7 @@ ${originalIndentation}`;
4578
4511
  let separator = "";
4579
4512
  if (spacer !== "") {
4580
4513
  indentation += spacer;
4581
- join = `,
4514
+ join2 = `,
4582
4515
  ${indentation}`;
4583
4516
  whitespace = " ";
4584
4517
  }
@@ -4592,13 +4525,13 @@ ${indentation}`;
4592
4525
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
4593
4526
  if (tmp !== void 0) {
4594
4527
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
4595
- separator = join;
4528
+ separator = join2;
4596
4529
  }
4597
4530
  }
4598
4531
  if (keyLength > maximumBreadth) {
4599
4532
  const removedKeys = keyLength - maximumBreadth;
4600
4533
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
4601
- separator = join;
4534
+ separator = join2;
4602
4535
  }
4603
4536
  if (spacer !== "" && separator.length > 1) {
4604
4537
  res = `
@@ -4639,7 +4572,7 @@ ${originalIndentation}`;
4639
4572
  }
4640
4573
  const originalIndentation = indentation;
4641
4574
  let res = "";
4642
- let join = ",";
4575
+ let join2 = ",";
4643
4576
  if (Array.isArray(value)) {
4644
4577
  if (value.length === 0) {
4645
4578
  return "[]";
@@ -4652,7 +4585,7 @@ ${originalIndentation}`;
4652
4585
  indentation += spacer;
4653
4586
  res += `
4654
4587
  ${indentation}`;
4655
- join = `,
4588
+ join2 = `,
4656
4589
  ${indentation}`;
4657
4590
  }
4658
4591
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -4660,13 +4593,13 @@ ${indentation}`;
4660
4593
  for (; i < maximumValuesToStringify - 1; i++) {
4661
4594
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
4662
4595
  res += tmp2 !== void 0 ? tmp2 : "null";
4663
- res += join;
4596
+ res += join2;
4664
4597
  }
4665
4598
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
4666
4599
  res += tmp !== void 0 ? tmp : "null";
4667
4600
  if (value.length - 1 > maximumBreadth) {
4668
4601
  const removedKeys = value.length - maximumBreadth - 1;
4669
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
4602
+ res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
4670
4603
  }
4671
4604
  if (spacer !== "") {
4672
4605
  res += `
@@ -4679,7 +4612,7 @@ ${originalIndentation}`;
4679
4612
  let whitespace = "";
4680
4613
  if (spacer !== "") {
4681
4614
  indentation += spacer;
4682
- join = `,
4615
+ join2 = `,
4683
4616
  ${indentation}`;
4684
4617
  whitespace = " ";
4685
4618
  }
@@ -4688,7 +4621,7 @@ ${indentation}`;
4688
4621
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
4689
4622
  if (tmp !== void 0) {
4690
4623
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
4691
- separator = join;
4624
+ separator = join2;
4692
4625
  }
4693
4626
  }
4694
4627
  if (spacer !== "" && separator.length > 1) {
@@ -4746,20 +4679,20 @@ ${originalIndentation}`;
4746
4679
  indentation += spacer;
4747
4680
  let res2 = `
4748
4681
  ${indentation}`;
4749
- const join2 = `,
4682
+ const join3 = `,
4750
4683
  ${indentation}`;
4751
4684
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
4752
4685
  let i = 0;
4753
4686
  for (; i < maximumValuesToStringify - 1; i++) {
4754
4687
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4755
4688
  res2 += tmp2 !== void 0 ? tmp2 : "null";
4756
- res2 += join2;
4689
+ res2 += join3;
4757
4690
  }
4758
4691
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
4759
4692
  res2 += tmp !== void 0 ? tmp : "null";
4760
4693
  if (value.length - 1 > maximumBreadth) {
4761
4694
  const removedKeys = value.length - maximumBreadth - 1;
4762
- res2 += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
4695
+ res2 += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
4763
4696
  }
4764
4697
  res2 += `
4765
4698
  ${originalIndentation}`;
@@ -4775,16 +4708,16 @@ ${originalIndentation}`;
4775
4708
  return '"[Object]"';
4776
4709
  }
4777
4710
  indentation += spacer;
4778
- const join = `,
4711
+ const join2 = `,
4779
4712
  ${indentation}`;
4780
4713
  let res = "";
4781
4714
  let separator = "";
4782
4715
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
4783
4716
  if (isTypedArrayWithEntries(value)) {
4784
- res += stringifyTypedArray(value, join, maximumBreadth);
4717
+ res += stringifyTypedArray(value, join2, maximumBreadth);
4785
4718
  keys = keys.slice(value.length);
4786
4719
  maximumPropertiesToStringify -= value.length;
4787
- separator = join;
4720
+ separator = join2;
4788
4721
  }
4789
4722
  if (deterministic) {
4790
4723
  keys = sort(keys, comparator);
@@ -4795,13 +4728,13 @@ ${indentation}`;
4795
4728
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
4796
4729
  if (tmp !== void 0) {
4797
4730
  res += `${separator}${strEscape(key2)}: ${tmp}`;
4798
- separator = join;
4731
+ separator = join2;
4799
4732
  }
4800
4733
  }
4801
4734
  if (keyLength > maximumBreadth) {
4802
4735
  const removedKeys = keyLength - maximumBreadth;
4803
4736
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
4804
- separator = join;
4737
+ separator = join2;
4805
4738
  }
4806
4739
  if (separator !== "") {
4807
4740
  res = `
@@ -5482,18 +5415,18 @@ function requireIsPrimitiveValueExpression() {
5482
5415
  return isPrimitiveValueExpression;
5483
5416
  }
5484
5417
  var isSqlToken = {};
5485
- var hasOwnProperty = {};
5418
+ var hasOwnProperty$1 = {};
5486
5419
  var hasRequiredHasOwnProperty;
5487
5420
  function requireHasOwnProperty() {
5488
- if (hasRequiredHasOwnProperty) return hasOwnProperty;
5421
+ if (hasRequiredHasOwnProperty) return hasOwnProperty$1;
5489
5422
  hasRequiredHasOwnProperty = 1;
5490
- Object.defineProperty(hasOwnProperty, "__esModule", { value: true });
5491
- hasOwnProperty.hasOwnProperty = void 0;
5492
- const hasOwnProperty$12 = (object, property) => {
5423
+ Object.defineProperty(hasOwnProperty$1, "__esModule", { value: true });
5424
+ hasOwnProperty$1.hasOwnProperty = void 0;
5425
+ const hasOwnProperty2 = (object, property) => {
5493
5426
  return Object.prototype.hasOwnProperty.call(object, property);
5494
5427
  };
5495
- hasOwnProperty.hasOwnProperty = hasOwnProperty$12;
5496
- return hasOwnProperty;
5428
+ hasOwnProperty$1.hasOwnProperty = hasOwnProperty2;
5429
+ return hasOwnProperty$1;
5497
5430
  }
5498
5431
  var dist$9 = {};
5499
5432
  var errors$3 = {};
@@ -10238,22 +10171,22 @@ function requireCreateIntervalSqlFragment() {
10238
10171
  return createIntervalSqlFragment;
10239
10172
  }
10240
10173
  var createJsonSqlFragment = {};
10241
- var isPlainObject = {};
10174
+ var isPlainObject$1 = {};
10242
10175
  var hasRequiredIsPlainObject$1;
10243
10176
  function requireIsPlainObject$1() {
10244
- if (hasRequiredIsPlainObject$1) return isPlainObject;
10177
+ if (hasRequiredIsPlainObject$1) return isPlainObject$1;
10245
10178
  hasRequiredIsPlainObject$1 = 1;
10246
- Object.defineProperty(isPlainObject, "__esModule", { value: true });
10247
- isPlainObject.isPlainObject = void 0;
10248
- const isPlainObject$1 = (subject) => {
10179
+ Object.defineProperty(isPlainObject$1, "__esModule", { value: true });
10180
+ isPlainObject$1.isPlainObject = void 0;
10181
+ const isPlainObject2 = (subject) => {
10249
10182
  if (typeof subject !== "object" || subject === null) {
10250
10183
  return false;
10251
10184
  }
10252
10185
  const prototype = Object.getPrototypeOf(subject);
10253
10186
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in subject) && !(Symbol.iterator in subject);
10254
10187
  };
10255
- isPlainObject.isPlainObject = isPlainObject$1;
10256
- return isPlainObject;
10188
+ isPlainObject$1.isPlainObject = isPlainObject2;
10189
+ return isPlainObject$1;
10257
10190
  }
10258
10191
  var serializeError_1;
10259
10192
  var hasRequiredSerializeError;
@@ -11264,7 +11197,7 @@ function requireDist$9() {
11264
11197
  var dist$7 = {};
11265
11198
  var getStackTrace = {};
11266
11199
  var UNKNOWN_FUNCTION = "<unknown>";
11267
- function parse$1(stackString) {
11200
+ function parse$2(stackString) {
11268
11201
  var lines = stackString.split("\n");
11269
11202
  return lines.reduce(function(stack, line) {
11270
11203
  var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
@@ -11363,7 +11296,7 @@ function parseNode(line) {
11363
11296
  }
11364
11297
  const stackTraceParser_esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11365
11298
  __proto__: null,
11366
- parse: parse$1
11299
+ parse: parse$2
11367
11300
  }, Symbol.toStringTag, { value: "Module" }));
11368
11301
  const require$$0$4 = /* @__PURE__ */ getAugmentedNamespace(stackTraceParser_esm);
11369
11302
  var hasRequiredGetStackTrace;
@@ -12646,7 +12579,7 @@ const defaultDuration = Object.freeze({
12646
12579
  seconds: 0
12647
12580
  });
12648
12581
  const pattern$2 = new RegExp(iso8601);
12649
- const parse = (durationString) => {
12582
+ const parse$1 = (durationString) => {
12650
12583
  return durationString.match(pattern$2).slice(1).reduce((prev, next2, idx) => {
12651
12584
  prev[objMap[idx]] = parseFloat(next2) || 0;
12652
12585
  return prev;
@@ -12677,13 +12610,13 @@ const index$1 = {
12677
12610
  end,
12678
12611
  toSeconds,
12679
12612
  pattern: pattern$2,
12680
- parse
12613
+ parse: parse$1
12681
12614
  };
12682
12615
  const src = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12683
12616
  __proto__: null,
12684
12617
  default: index$1,
12685
12618
  end,
12686
- parse,
12619
+ parse: parse$1,
12687
12620
  pattern: pattern$2,
12688
12621
  toSeconds
12689
12622
  }, Symbol.toStringTag, { value: "Module" }));
@@ -15994,7 +15927,7 @@ function requireParser() {
15994
15927
  const LEN_LENGTH = 4;
15995
15928
  const HEADER_LENGTH = CODE_LENGTH + LEN_LENGTH;
15996
15929
  const emptyBuffer = Buffer.allocUnsafe(0);
15997
- class Parser {
15930
+ class Parser2 {
15998
15931
  constructor(opts) {
15999
15932
  this.buffer = emptyBuffer;
16000
15933
  this.bufferLength = 0;
@@ -16269,7 +16202,7 @@ function requireParser() {
16269
16202
  return message;
16270
16203
  }
16271
16204
  }
16272
- parser.Parser = Parser;
16205
+ parser.Parser = Parser2;
16273
16206
  return parser;
16274
16207
  }
16275
16208
  var hasRequiredDist$6;
@@ -25038,7 +24971,7 @@ const bootstrap = async (opts, env2) => {
25038
24971
  });
25039
24972
  console.log(`Created platform ${name} with handle ${handle} (ID ${platformId})`);
25040
24973
  };
25041
- const validateExtensionConfig$1 = validate25;
24974
+ const validateExtensionConfig = validate25;
25042
24975
  function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
25043
24976
  let vErrors = null;
25044
24977
  let errors2 = 0;
@@ -30563,7 +30496,7 @@ function requireContains() {
30563
30496
  const count = gen.let("count", 0);
30564
30497
  validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
30565
30498
  }
30566
- function validateItems(_valid, block) {
30499
+ function validateItems(_valid, block2) {
30567
30500
  gen.forRange("i", 0, len, (i) => {
30568
30501
  cxt.subschema({
30569
30502
  keyword: "contains",
@@ -30571,7 +30504,7 @@ function requireContains() {
30571
30504
  dataPropType: util_1.Type.Num,
30572
30505
  compositeRule: true
30573
30506
  }, _valid);
30574
- block();
30507
+ block2();
30575
30508
  });
30576
30509
  }
30577
30510
  function checkLimits(count) {
@@ -32101,7 +32034,7 @@ const preCompiledSafeValidator = (validate2) => (value) => {
32101
32034
  error: errorsText(validate2)
32102
32035
  };
32103
32036
  };
32104
- const validateExtensionConfig = preCompiledSafeValidator(validateExtensionConfig$1);
32037
+ const validateExtensionManifest = preCompiledSafeValidator(validateExtensionConfig);
32105
32038
  const requireValidExtensionDir = async (dir2) => {
32106
32039
  const extConfigPath = resolve$1(dir2, "extension.json");
32107
32040
  if (!existsSync(extConfigPath)) {
@@ -32109,7 +32042,7 @@ const requireValidExtensionDir = async (dir2) => {
32109
32042
  process.exit(1);
32110
32043
  }
32111
32044
  const extConfig = JSON.parse(await readFile(extConfigPath, "utf8"));
32112
- const validateResult = validateExtensionConfig(extConfig);
32045
+ const validateResult = validateExtensionManifest(extConfig);
32113
32046
  if (validateResult.ok) {
32114
32047
  const config2 = validateResult.value;
32115
32048
  if (config2.components) {
@@ -32125,11 +32058,57 @@ const requireValidExtensionDir = async (dir2) => {
32125
32058
  }
32126
32059
  }
32127
32060
  }
32128
- return { ...config2, dir: dir2 };
32061
+ return { manifest: config2, dir: dir2 };
32129
32062
  }
32130
32063
  console.error(`Invalid extension config file:`, validateResult.error);
32131
32064
  process.exit(1);
32132
32065
  };
32066
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
32067
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
32068
+ var root = freeGlobal || freeSelf || Function("return this")();
32069
+ var Symbol$1 = root.Symbol;
32070
+ var objectProto$1 = Object.prototype;
32071
+ var hasOwnProperty = objectProto$1.hasOwnProperty;
32072
+ var nativeObjectToString$1 = objectProto$1.toString;
32073
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
32074
+ function getRawTag(value) {
32075
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
32076
+ try {
32077
+ value[symToStringTag$1] = void 0;
32078
+ var unmasked = true;
32079
+ } catch (e) {
32080
+ }
32081
+ var result2 = nativeObjectToString$1.call(value);
32082
+ if (unmasked) {
32083
+ if (isOwn) {
32084
+ value[symToStringTag$1] = tag;
32085
+ } else {
32086
+ delete value[symToStringTag$1];
32087
+ }
32088
+ }
32089
+ return result2;
32090
+ }
32091
+ var objectProto = Object.prototype;
32092
+ var nativeObjectToString = objectProto.toString;
32093
+ function objectToString(value) {
32094
+ return nativeObjectToString.call(value);
32095
+ }
32096
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
32097
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
32098
+ function baseGetTag(value) {
32099
+ if (value == null) {
32100
+ return value === void 0 ? undefinedTag : nullTag;
32101
+ }
32102
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
32103
+ }
32104
+ function isObjectLike$1(value) {
32105
+ return value != null && typeof value == "object";
32106
+ }
32107
+ var isArray = Array.isArray;
32108
+ var stringTag = "[object String]";
32109
+ function isString(value) {
32110
+ return typeof value == "string" || !isArray(value) && isObjectLike$1(value) && baseGetTag(value) == stringTag;
32111
+ }
32133
32112
  const isNonEmptyString = (value) => isString(value) && value.length > 0;
32134
32113
  const genericErrorMessage = "An unknown error occurred";
32135
32114
  const parseErrorMessage = (err) => {
@@ -33168,7 +33147,7 @@ var hasNextTick = typeof process === "object" && typeof process.nextTick === "fu
33168
33147
  function fallback(fn) {
33169
33148
  setTimeout(fn, 0);
33170
33149
  }
33171
- function wrap(defer2) {
33150
+ function wrap$1(defer2) {
33172
33151
  return (fn, ...args) => defer2(() => fn(...args));
33173
33152
  }
33174
33153
  var _defer$1;
@@ -33181,7 +33160,7 @@ if (hasQueueMicrotask) {
33181
33160
  } else {
33182
33161
  _defer$1 = fallback;
33183
33162
  }
33184
- var setImmediate$1 = wrap(_defer$1);
33163
+ var setImmediate$1 = wrap$1(_defer$1);
33185
33164
  function asyncify(func) {
33186
33165
  if (isAsync(func)) {
33187
33166
  return function(...args) {
@@ -34359,7 +34338,7 @@ if (hasNextTick) {
34359
34338
  } else {
34360
34339
  _defer = fallback;
34361
34340
  }
34362
- var nextTick = wrap(_defer);
34341
+ var nextTick = wrap$1(_defer);
34363
34342
  var _parallel = awaitify((eachfn, tasks, callback) => {
34364
34343
  var results = isArrayLike(tasks) ? [] : {};
34365
34344
  eachfn(tasks, (task, key, taskCb) => {
@@ -36088,7 +36067,7 @@ function requireBufferList() {
36088
36067
  this.head = this.tail = null;
36089
36068
  this.length = 0;
36090
36069
  };
36091
- BufferList2.prototype.join = function join(s) {
36070
+ BufferList2.prototype.join = function join2(s) {
36092
36071
  if (this.length === 0) return "";
36093
36072
  var p = this.head;
36094
36073
  var ret = "" + p.data;
@@ -39539,7 +39518,7 @@ var hasRequiredErrors;
39539
39518
  function requireErrors() {
39540
39519
  if (hasRequiredErrors) return errors;
39541
39520
  hasRequiredErrors = 1;
39542
- const { format: format2, inspect, AggregateError: CustomAggregateError } = requireUtil$2();
39521
+ const { format: format2, inspect: inspect2, AggregateError: CustomAggregateError } = requireUtil$2();
39543
39522
  const AggregateError = globalThis.AggregateError || CustomAggregateError;
39544
39523
  const kIsNodeError = Symbol("kIsNodeError");
39545
39524
  const kTypes = [
@@ -39747,13 +39726,13 @@ function requireErrors() {
39747
39726
  if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
39748
39727
  msg += `. Received an instance of ${actual.constructor.name}`;
39749
39728
  } else {
39750
- const inspected = inspect(actual, {
39729
+ const inspected = inspect2(actual, {
39751
39730
  depth: -1
39752
39731
  });
39753
39732
  msg += `. Received ${inspected}`;
39754
39733
  }
39755
39734
  } else {
39756
- let inspected = inspect(actual, {
39735
+ let inspected = inspect2(actual, {
39757
39736
  colors: false
39758
39737
  });
39759
39738
  if (inspected.length > 25) {
@@ -39768,7 +39747,7 @@ function requireErrors() {
39768
39747
  E(
39769
39748
  "ERR_INVALID_ARG_VALUE",
39770
39749
  (name, value, reason = "is invalid") => {
39771
- let inspected = inspect(value);
39750
+ let inspected = inspect2(value);
39772
39751
  if (inspected.length > 128) {
39773
39752
  inspected = inspected.slice(0, 128) + "...";
39774
39753
  }
@@ -39825,7 +39804,7 @@ function requireErrors() {
39825
39804
  }
39826
39805
  received += "n";
39827
39806
  } else {
39828
- received = inspect(input);
39807
+ received = inspect2(input);
39829
39808
  }
39830
39809
  return `The value of "${str}" is out of range. It must be ${range2}. Received ${received}`;
39831
39810
  },
@@ -40986,7 +40965,7 @@ function requireBuffer_list() {
40986
40965
  hasRequiredBuffer_list = 1;
40987
40966
  const { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array: Uint8Array2 } = requirePrimordials();
40988
40967
  const { Buffer: Buffer2 } = require$$0$h;
40989
- const { inspect } = requireUtil$2();
40968
+ const { inspect: inspect2 } = requireUtil$2();
40990
40969
  buffer_list = class BufferList {
40991
40970
  constructor() {
40992
40971
  this.head = null;
@@ -41123,7 +41102,7 @@ function requireBuffer_list() {
41123
41102
  }
41124
41103
  // Make sure the linked list only shows the minimal necessary information.
41125
41104
  [Symbol.for("nodejs.util.inspect.custom")](_2, options) {
41126
- return inspect(this, {
41105
+ return inspect2(this, {
41127
41106
  ...options,
41128
41107
  // Only inspect one level.
41129
41108
  depth: 0,
@@ -54294,10 +54273,10 @@ function requireZipStream() {
54294
54273
  * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
54295
54274
  * @copyright (c) 2012-2014 Chris Talkington, contributors.
54296
54275
  */
54297
- var zip;
54276
+ var zip$1;
54298
54277
  var hasRequiredZip;
54299
54278
  function requireZip() {
54300
- if (hasRequiredZip) return zip;
54279
+ if (hasRequiredZip) return zip$1;
54301
54280
  hasRequiredZip = 1;
54302
54281
  var engine = requireZipStream();
54303
54282
  var util2 = requireArchiverUtils();
@@ -54332,8 +54311,8 @@ function requireZip() {
54332
54311
  Zip.prototype.unpipe = function() {
54333
54312
  return this.engine.unpipe.apply(this.engine, arguments);
54334
54313
  };
54335
- zip = Zip;
54336
- return zip;
54314
+ zip$1 = Zip;
54315
+ return zip$1;
54337
54316
  }
54338
54317
  var tarStream = {};
54339
54318
  var queueMicrotask_1;
@@ -55917,16 +55896,16 @@ function requireHeaders() {
55917
55896
  }
55918
55897
  return 0;
55919
55898
  }
55920
- function indexOf(block, num, offset, end2) {
55899
+ function indexOf(block2, num, offset, end2) {
55921
55900
  for (; offset < end2; offset++) {
55922
- if (block[offset] === num) return offset;
55901
+ if (block2[offset] === num) return offset;
55923
55902
  }
55924
55903
  return end2;
55925
55904
  }
55926
- function cksum(block) {
55905
+ function cksum(block2) {
55927
55906
  let sum = 8 * 32;
55928
- for (let i = 0; i < 148; i++) sum += block[i];
55929
- for (let j = 156; j < 512; j++) sum += block[j];
55907
+ for (let i = 0; i < 148; i++) sum += block2[i];
55908
+ for (let j = 156; j < 512; j++) sum += block2[j];
55930
55909
  return sum;
55931
55910
  }
55932
55911
  function encodeOct(val, n) {
@@ -56043,7 +56022,7 @@ function requireExtract() {
56043
56022
  return buf.subarray(this._offset, this._offset += size);
56044
56023
  }
56045
56024
  }
56046
- class Source extends Readable {
56025
+ class Source2 extends Readable {
56047
56026
  constructor(self2, header, offset) {
56048
56027
  super();
56049
56028
  this.header = header;
@@ -56192,7 +56171,7 @@ function requireExtract() {
56192
56171
  return drained;
56193
56172
  }
56194
56173
  _createStream() {
56195
- return new Source(this, this._header, this._offset);
56174
+ return new Source2(this, this._header, this._offset);
56196
56175
  }
56197
56176
  _update() {
56198
56177
  while (this._buffer.buffered > 0 && !this.destroying) {
@@ -57099,6 +57078,3616 @@ function requireArchiver() {
57099
57078
  }
57100
57079
  var archiverExports = requireArchiver();
57101
57080
  const archiver = /* @__PURE__ */ getDefaultExportFromCjs(archiverExports);
57081
+ class ClientError extends Error {
57082
+ response;
57083
+ request;
57084
+ constructor(response, request) {
57085
+ const message = `${ClientError.extractMessage(response)}: ${JSON.stringify({
57086
+ response,
57087
+ request
57088
+ })}`;
57089
+ super(message);
57090
+ Object.setPrototypeOf(this, ClientError.prototype);
57091
+ this.response = response;
57092
+ this.request = request;
57093
+ if (typeof Error.captureStackTrace === `function`) {
57094
+ Error.captureStackTrace(this, ClientError);
57095
+ }
57096
+ }
57097
+ static extractMessage(response) {
57098
+ return response.errors?.[0]?.message ?? `GraphQL Error (Code: ${String(response.status)})`;
57099
+ }
57100
+ }
57101
+ const uppercase = (str) => str.toUpperCase();
57102
+ const callOrIdentity = (value) => {
57103
+ return typeof value === `function` ? value() : value;
57104
+ };
57105
+ const zip = (a, b) => a.map((k, i) => [k, b[i]]);
57106
+ const HeadersInitToPlainObject = (headers2) => {
57107
+ let oHeaders = {};
57108
+ if (headers2 instanceof Headers) {
57109
+ oHeaders = HeadersInstanceToPlainObject(headers2);
57110
+ } else if (Array.isArray(headers2)) {
57111
+ headers2.forEach(([name, value]) => {
57112
+ if (name && value !== void 0) {
57113
+ oHeaders[name] = value;
57114
+ }
57115
+ });
57116
+ } else if (headers2) {
57117
+ oHeaders = headers2;
57118
+ }
57119
+ return oHeaders;
57120
+ };
57121
+ const HeadersInstanceToPlainObject = (headers2) => {
57122
+ const o = {};
57123
+ headers2.forEach((v, k) => {
57124
+ o[k] = v;
57125
+ });
57126
+ return o;
57127
+ };
57128
+ const tryCatch = (fn) => {
57129
+ try {
57130
+ const result2 = fn();
57131
+ if (isPromiseLikeValue(result2)) {
57132
+ return result2.catch((error2) => {
57133
+ return errorFromMaybeError(error2);
57134
+ });
57135
+ }
57136
+ return result2;
57137
+ } catch (error2) {
57138
+ return errorFromMaybeError(error2);
57139
+ }
57140
+ };
57141
+ const errorFromMaybeError = (maybeError) => {
57142
+ if (maybeError instanceof Error)
57143
+ return maybeError;
57144
+ return new Error(String(maybeError));
57145
+ };
57146
+ const isPromiseLikeValue = (value) => {
57147
+ return typeof value === `object` && value !== null && `then` in value && typeof value.then === `function` && `catch` in value && typeof value.catch === `function` && `finally` in value && typeof value.finally === `function`;
57148
+ };
57149
+ const casesExhausted = (value) => {
57150
+ throw new Error(`Unhandled case: ${String(value)}`);
57151
+ };
57152
+ const isPlainObject = (value) => {
57153
+ return typeof value === `object` && value !== null && !Array.isArray(value);
57154
+ };
57155
+ const parseBatchRequestArgs = (documentsOrOptions, requestHeaders) => {
57156
+ return documentsOrOptions.documents ? documentsOrOptions : {
57157
+ documents: documentsOrOptions,
57158
+ requestHeaders,
57159
+ signal: void 0
57160
+ };
57161
+ };
57162
+ const parseRawRequestArgs = (queryOrOptions, variables, requestHeaders) => {
57163
+ return queryOrOptions.query ? queryOrOptions : {
57164
+ query: queryOrOptions,
57165
+ variables,
57166
+ requestHeaders,
57167
+ signal: void 0
57168
+ };
57169
+ };
57170
+ function devAssert(condition, message) {
57171
+ const booleanCondition = Boolean(condition);
57172
+ if (!booleanCondition) {
57173
+ throw new Error(message);
57174
+ }
57175
+ }
57176
+ function isObjectLike(value) {
57177
+ return typeof value == "object" && value !== null;
57178
+ }
57179
+ function invariant(condition, message) {
57180
+ const booleanCondition = Boolean(condition);
57181
+ if (!booleanCondition) {
57182
+ throw new Error(
57183
+ "Unexpected invariant triggered."
57184
+ );
57185
+ }
57186
+ }
57187
+ const LineRegExp = /\r\n|[\n\r]/g;
57188
+ function getLocation(source, position) {
57189
+ let lastLineStart = 0;
57190
+ let line = 1;
57191
+ for (const match of source.body.matchAll(LineRegExp)) {
57192
+ typeof match.index === "number" || invariant(false);
57193
+ if (match.index >= position) {
57194
+ break;
57195
+ }
57196
+ lastLineStart = match.index + match[0].length;
57197
+ line += 1;
57198
+ }
57199
+ return {
57200
+ line,
57201
+ column: position + 1 - lastLineStart
57202
+ };
57203
+ }
57204
+ function printLocation(location) {
57205
+ return printSourceLocation(
57206
+ location.source,
57207
+ getLocation(location.source, location.start)
57208
+ );
57209
+ }
57210
+ function printSourceLocation(source, sourceLocation) {
57211
+ const firstLineColumnOffset = source.locationOffset.column - 1;
57212
+ const body = "".padStart(firstLineColumnOffset) + source.body;
57213
+ const lineIndex = sourceLocation.line - 1;
57214
+ const lineOffset = source.locationOffset.line - 1;
57215
+ const lineNum = sourceLocation.line + lineOffset;
57216
+ const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
57217
+ const columnNum = sourceLocation.column + columnOffset;
57218
+ const locationStr = `${source.name}:${lineNum}:${columnNum}
57219
+ `;
57220
+ const lines = body.split(/\r\n|[\n\r]/g);
57221
+ const locationLine = lines[lineIndex];
57222
+ if (locationLine.length > 120) {
57223
+ const subLineIndex = Math.floor(columnNum / 80);
57224
+ const subLineColumnNum = columnNum % 80;
57225
+ const subLines = [];
57226
+ for (let i = 0; i < locationLine.length; i += 80) {
57227
+ subLines.push(locationLine.slice(i, i + 80));
57228
+ }
57229
+ return locationStr + printPrefixedLines([
57230
+ [`${lineNum} |`, subLines[0]],
57231
+ ...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
57232
+ ["|", "^".padStart(subLineColumnNum)],
57233
+ ["|", subLines[subLineIndex + 1]]
57234
+ ]);
57235
+ }
57236
+ return locationStr + printPrefixedLines([
57237
+ // Lines specified like this: ["prefix", "string"],
57238
+ [`${lineNum - 1} |`, lines[lineIndex - 1]],
57239
+ [`${lineNum} |`, locationLine],
57240
+ ["|", "^".padStart(columnNum)],
57241
+ [`${lineNum + 1} |`, lines[lineIndex + 1]]
57242
+ ]);
57243
+ }
57244
+ function printPrefixedLines(lines) {
57245
+ const existingLines = lines.filter(([_2, line]) => line !== void 0);
57246
+ const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
57247
+ return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
57248
+ }
57249
+ function toNormalizedOptions(args) {
57250
+ const firstArg = args[0];
57251
+ if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
57252
+ return {
57253
+ nodes: firstArg,
57254
+ source: args[1],
57255
+ positions: args[2],
57256
+ path: args[3],
57257
+ originalError: args[4],
57258
+ extensions: args[5]
57259
+ };
57260
+ }
57261
+ return firstArg;
57262
+ }
57263
+ class GraphQLError extends Error {
57264
+ /**
57265
+ * An array of `{ line, column }` locations within the source GraphQL document
57266
+ * which correspond to this error.
57267
+ *
57268
+ * Errors during validation often contain multiple locations, for example to
57269
+ * point out two things with the same name. Errors during execution include a
57270
+ * single location, the field which produced the error.
57271
+ *
57272
+ * Enumerable, and appears in the result of JSON.stringify().
57273
+ */
57274
+ /**
57275
+ * An array describing the JSON-path into the execution response which
57276
+ * corresponds to this error. Only included for errors during execution.
57277
+ *
57278
+ * Enumerable, and appears in the result of JSON.stringify().
57279
+ */
57280
+ /**
57281
+ * An array of GraphQL AST Nodes corresponding to this error.
57282
+ */
57283
+ /**
57284
+ * The source GraphQL document for the first location of this error.
57285
+ *
57286
+ * Note that if this Error represents more than one node, the source may not
57287
+ * represent nodes after the first node.
57288
+ */
57289
+ /**
57290
+ * An array of character offsets within the source GraphQL document
57291
+ * which correspond to this error.
57292
+ */
57293
+ /**
57294
+ * The original error thrown from a field resolver during execution.
57295
+ */
57296
+ /**
57297
+ * Extension fields to add to the formatted error.
57298
+ */
57299
+ /**
57300
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
57301
+ */
57302
+ constructor(message, ...rawArgs) {
57303
+ var _this$nodes, _nodeLocations$, _ref;
57304
+ const { nodes, source, positions, path: path2, originalError, extensions } = toNormalizedOptions(rawArgs);
57305
+ super(message);
57306
+ this.name = "GraphQLError";
57307
+ this.path = path2 !== null && path2 !== void 0 ? path2 : void 0;
57308
+ this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
57309
+ this.nodes = undefinedIfEmpty(
57310
+ Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
57311
+ );
57312
+ const nodeLocations = undefinedIfEmpty(
57313
+ (_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node2) => node2.loc).filter((loc) => loc != null)
57314
+ );
57315
+ this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
57316
+ this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
57317
+ this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
57318
+ const originalExtensions = isObjectLike(
57319
+ originalError === null || originalError === void 0 ? void 0 : originalError.extensions
57320
+ ) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
57321
+ this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ Object.create(null);
57322
+ Object.defineProperties(this, {
57323
+ message: {
57324
+ writable: true,
57325
+ enumerable: true
57326
+ },
57327
+ name: {
57328
+ enumerable: false
57329
+ },
57330
+ nodes: {
57331
+ enumerable: false
57332
+ },
57333
+ source: {
57334
+ enumerable: false
57335
+ },
57336
+ positions: {
57337
+ enumerable: false
57338
+ },
57339
+ originalError: {
57340
+ enumerable: false
57341
+ }
57342
+ });
57343
+ if (originalError !== null && originalError !== void 0 && originalError.stack) {
57344
+ Object.defineProperty(this, "stack", {
57345
+ value: originalError.stack,
57346
+ writable: true,
57347
+ configurable: true
57348
+ });
57349
+ } else if (Error.captureStackTrace) {
57350
+ Error.captureStackTrace(this, GraphQLError);
57351
+ } else {
57352
+ Object.defineProperty(this, "stack", {
57353
+ value: Error().stack,
57354
+ writable: true,
57355
+ configurable: true
57356
+ });
57357
+ }
57358
+ }
57359
+ get [Symbol.toStringTag]() {
57360
+ return "GraphQLError";
57361
+ }
57362
+ toString() {
57363
+ let output = this.message;
57364
+ if (this.nodes) {
57365
+ for (const node2 of this.nodes) {
57366
+ if (node2.loc) {
57367
+ output += "\n\n" + printLocation(node2.loc);
57368
+ }
57369
+ }
57370
+ } else if (this.source && this.locations) {
57371
+ for (const location of this.locations) {
57372
+ output += "\n\n" + printSourceLocation(this.source, location);
57373
+ }
57374
+ }
57375
+ return output;
57376
+ }
57377
+ toJSON() {
57378
+ const formattedError = {
57379
+ message: this.message
57380
+ };
57381
+ if (this.locations != null) {
57382
+ formattedError.locations = this.locations;
57383
+ }
57384
+ if (this.path != null) {
57385
+ formattedError.path = this.path;
57386
+ }
57387
+ if (this.extensions != null && Object.keys(this.extensions).length > 0) {
57388
+ formattedError.extensions = this.extensions;
57389
+ }
57390
+ return formattedError;
57391
+ }
57392
+ }
57393
+ function undefinedIfEmpty(array) {
57394
+ return array === void 0 || array.length === 0 ? void 0 : array;
57395
+ }
57396
+ function syntaxError(source, position, description2) {
57397
+ return new GraphQLError(`Syntax Error: ${description2}`, {
57398
+ source,
57399
+ positions: [position]
57400
+ });
57401
+ }
57402
+ class Location {
57403
+ /**
57404
+ * The character offset at which this Node begins.
57405
+ */
57406
+ /**
57407
+ * The character offset at which this Node ends.
57408
+ */
57409
+ /**
57410
+ * The Token at which this Node begins.
57411
+ */
57412
+ /**
57413
+ * The Token at which this Node ends.
57414
+ */
57415
+ /**
57416
+ * The Source document the AST represents.
57417
+ */
57418
+ constructor(startToken, endToken, source) {
57419
+ this.start = startToken.start;
57420
+ this.end = endToken.end;
57421
+ this.startToken = startToken;
57422
+ this.endToken = endToken;
57423
+ this.source = source;
57424
+ }
57425
+ get [Symbol.toStringTag]() {
57426
+ return "Location";
57427
+ }
57428
+ toJSON() {
57429
+ return {
57430
+ start: this.start,
57431
+ end: this.end
57432
+ };
57433
+ }
57434
+ }
57435
+ class Token {
57436
+ /**
57437
+ * The kind of Token.
57438
+ */
57439
+ /**
57440
+ * The character offset at which this Node begins.
57441
+ */
57442
+ /**
57443
+ * The character offset at which this Node ends.
57444
+ */
57445
+ /**
57446
+ * The 1-indexed line number on which this Token appears.
57447
+ */
57448
+ /**
57449
+ * The 1-indexed column number at which this Token begins.
57450
+ */
57451
+ /**
57452
+ * For non-punctuation tokens, represents the interpreted value of the token.
57453
+ *
57454
+ * Note: is undefined for punctuation tokens, but typed as string for
57455
+ * convenience in the parser.
57456
+ */
57457
+ /**
57458
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
57459
+ * including ignored tokens. <SOF> is always the first node and <EOF>
57460
+ * the last.
57461
+ */
57462
+ constructor(kind, start, end2, line, column, value) {
57463
+ this.kind = kind;
57464
+ this.start = start;
57465
+ this.end = end2;
57466
+ this.line = line;
57467
+ this.column = column;
57468
+ this.value = value;
57469
+ this.prev = null;
57470
+ this.next = null;
57471
+ }
57472
+ get [Symbol.toStringTag]() {
57473
+ return "Token";
57474
+ }
57475
+ toJSON() {
57476
+ return {
57477
+ kind: this.kind,
57478
+ value: this.value,
57479
+ line: this.line,
57480
+ column: this.column
57481
+ };
57482
+ }
57483
+ }
57484
+ const QueryDocumentKeys = {
57485
+ Name: [],
57486
+ Document: ["definitions"],
57487
+ OperationDefinition: [
57488
+ "name",
57489
+ "variableDefinitions",
57490
+ "directives",
57491
+ "selectionSet"
57492
+ ],
57493
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
57494
+ Variable: ["name"],
57495
+ SelectionSet: ["selections"],
57496
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
57497
+ Argument: ["name", "value"],
57498
+ FragmentSpread: ["name", "directives"],
57499
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
57500
+ FragmentDefinition: [
57501
+ "name",
57502
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
57503
+ "variableDefinitions",
57504
+ "typeCondition",
57505
+ "directives",
57506
+ "selectionSet"
57507
+ ],
57508
+ IntValue: [],
57509
+ FloatValue: [],
57510
+ StringValue: [],
57511
+ BooleanValue: [],
57512
+ NullValue: [],
57513
+ EnumValue: [],
57514
+ ListValue: ["values"],
57515
+ ObjectValue: ["fields"],
57516
+ ObjectField: ["name", "value"],
57517
+ Directive: ["name", "arguments"],
57518
+ NamedType: ["name"],
57519
+ ListType: ["type"],
57520
+ NonNullType: ["type"],
57521
+ SchemaDefinition: ["description", "directives", "operationTypes"],
57522
+ OperationTypeDefinition: ["type"],
57523
+ ScalarTypeDefinition: ["description", "name", "directives"],
57524
+ ObjectTypeDefinition: [
57525
+ "description",
57526
+ "name",
57527
+ "interfaces",
57528
+ "directives",
57529
+ "fields"
57530
+ ],
57531
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
57532
+ InputValueDefinition: [
57533
+ "description",
57534
+ "name",
57535
+ "type",
57536
+ "defaultValue",
57537
+ "directives"
57538
+ ],
57539
+ InterfaceTypeDefinition: [
57540
+ "description",
57541
+ "name",
57542
+ "interfaces",
57543
+ "directives",
57544
+ "fields"
57545
+ ],
57546
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
57547
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
57548
+ EnumValueDefinition: ["description", "name", "directives"],
57549
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
57550
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
57551
+ SchemaExtension: ["directives", "operationTypes"],
57552
+ ScalarTypeExtension: ["name", "directives"],
57553
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
57554
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
57555
+ UnionTypeExtension: ["name", "directives", "types"],
57556
+ EnumTypeExtension: ["name", "directives", "values"],
57557
+ InputObjectTypeExtension: ["name", "directives", "fields"]
57558
+ };
57559
+ const kindValues = new Set(Object.keys(QueryDocumentKeys));
57560
+ function isNode(maybeNode) {
57561
+ const maybeKind = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind;
57562
+ return typeof maybeKind === "string" && kindValues.has(maybeKind);
57563
+ }
57564
+ var OperationTypeNode;
57565
+ (function(OperationTypeNode2) {
57566
+ OperationTypeNode2["QUERY"] = "query";
57567
+ OperationTypeNode2["MUTATION"] = "mutation";
57568
+ OperationTypeNode2["SUBSCRIPTION"] = "subscription";
57569
+ })(OperationTypeNode || (OperationTypeNode = {}));
57570
+ var DirectiveLocation;
57571
+ (function(DirectiveLocation2) {
57572
+ DirectiveLocation2["QUERY"] = "QUERY";
57573
+ DirectiveLocation2["MUTATION"] = "MUTATION";
57574
+ DirectiveLocation2["SUBSCRIPTION"] = "SUBSCRIPTION";
57575
+ DirectiveLocation2["FIELD"] = "FIELD";
57576
+ DirectiveLocation2["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
57577
+ DirectiveLocation2["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
57578
+ DirectiveLocation2["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
57579
+ DirectiveLocation2["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
57580
+ DirectiveLocation2["SCHEMA"] = "SCHEMA";
57581
+ DirectiveLocation2["SCALAR"] = "SCALAR";
57582
+ DirectiveLocation2["OBJECT"] = "OBJECT";
57583
+ DirectiveLocation2["FIELD_DEFINITION"] = "FIELD_DEFINITION";
57584
+ DirectiveLocation2["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
57585
+ DirectiveLocation2["INTERFACE"] = "INTERFACE";
57586
+ DirectiveLocation2["UNION"] = "UNION";
57587
+ DirectiveLocation2["ENUM"] = "ENUM";
57588
+ DirectiveLocation2["ENUM_VALUE"] = "ENUM_VALUE";
57589
+ DirectiveLocation2["INPUT_OBJECT"] = "INPUT_OBJECT";
57590
+ DirectiveLocation2["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
57591
+ })(DirectiveLocation || (DirectiveLocation = {}));
57592
+ var Kind;
57593
+ (function(Kind2) {
57594
+ Kind2["NAME"] = "Name";
57595
+ Kind2["DOCUMENT"] = "Document";
57596
+ Kind2["OPERATION_DEFINITION"] = "OperationDefinition";
57597
+ Kind2["VARIABLE_DEFINITION"] = "VariableDefinition";
57598
+ Kind2["SELECTION_SET"] = "SelectionSet";
57599
+ Kind2["FIELD"] = "Field";
57600
+ Kind2["ARGUMENT"] = "Argument";
57601
+ Kind2["FRAGMENT_SPREAD"] = "FragmentSpread";
57602
+ Kind2["INLINE_FRAGMENT"] = "InlineFragment";
57603
+ Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition";
57604
+ Kind2["VARIABLE"] = "Variable";
57605
+ Kind2["INT"] = "IntValue";
57606
+ Kind2["FLOAT"] = "FloatValue";
57607
+ Kind2["STRING"] = "StringValue";
57608
+ Kind2["BOOLEAN"] = "BooleanValue";
57609
+ Kind2["NULL"] = "NullValue";
57610
+ Kind2["ENUM"] = "EnumValue";
57611
+ Kind2["LIST"] = "ListValue";
57612
+ Kind2["OBJECT"] = "ObjectValue";
57613
+ Kind2["OBJECT_FIELD"] = "ObjectField";
57614
+ Kind2["DIRECTIVE"] = "Directive";
57615
+ Kind2["NAMED_TYPE"] = "NamedType";
57616
+ Kind2["LIST_TYPE"] = "ListType";
57617
+ Kind2["NON_NULL_TYPE"] = "NonNullType";
57618
+ Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition";
57619
+ Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
57620
+ Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
57621
+ Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
57622
+ Kind2["FIELD_DEFINITION"] = "FieldDefinition";
57623
+ Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
57624
+ Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
57625
+ Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
57626
+ Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
57627
+ Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
57628
+ Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
57629
+ Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
57630
+ Kind2["SCHEMA_EXTENSION"] = "SchemaExtension";
57631
+ Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
57632
+ Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
57633
+ Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
57634
+ Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
57635
+ Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
57636
+ Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
57637
+ })(Kind || (Kind = {}));
57638
+ function isWhiteSpace(code2) {
57639
+ return code2 === 9 || code2 === 32;
57640
+ }
57641
+ function isDigit(code2) {
57642
+ return code2 >= 48 && code2 <= 57;
57643
+ }
57644
+ function isLetter(code2) {
57645
+ return code2 >= 97 && code2 <= 122 || // A-Z
57646
+ code2 >= 65 && code2 <= 90;
57647
+ }
57648
+ function isNameStart(code2) {
57649
+ return isLetter(code2) || code2 === 95;
57650
+ }
57651
+ function isNameContinue(code2) {
57652
+ return isLetter(code2) || isDigit(code2) || code2 === 95;
57653
+ }
57654
+ function dedentBlockStringLines(lines) {
57655
+ var _firstNonEmptyLine2;
57656
+ let commonIndent = Number.MAX_SAFE_INTEGER;
57657
+ let firstNonEmptyLine = null;
57658
+ let lastNonEmptyLine = -1;
57659
+ for (let i = 0; i < lines.length; ++i) {
57660
+ var _firstNonEmptyLine;
57661
+ const line = lines[i];
57662
+ const indent2 = leadingWhitespace(line);
57663
+ if (indent2 === line.length) {
57664
+ continue;
57665
+ }
57666
+ firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
57667
+ lastNonEmptyLine = i;
57668
+ if (i !== 0 && indent2 < commonIndent) {
57669
+ commonIndent = indent2;
57670
+ }
57671
+ }
57672
+ return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice(
57673
+ (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0,
57674
+ lastNonEmptyLine + 1
57675
+ );
57676
+ }
57677
+ function leadingWhitespace(str) {
57678
+ let i = 0;
57679
+ while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
57680
+ ++i;
57681
+ }
57682
+ return i;
57683
+ }
57684
+ function printBlockString(value, options) {
57685
+ const escapedValue = value.replace(/"""/g, '\\"""');
57686
+ const lines = escapedValue.split(/\r\n|[\n\r]/g);
57687
+ const isSingleLine = lines.length === 1;
57688
+ const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0)));
57689
+ const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""');
57690
+ const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes;
57691
+ const hasTrailingSlash = value.endsWith("\\");
57692
+ const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;
57693
+ const printAsMultipleLines = (
57694
+ // add leading and trailing new lines only if it improves readability
57695
+ !isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes
57696
+ );
57697
+ let result2 = "";
57698
+ const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0));
57699
+ if (printAsMultipleLines && !skipLeadingNewLine || forceLeadingNewLine) {
57700
+ result2 += "\n";
57701
+ }
57702
+ result2 += escapedValue;
57703
+ if (printAsMultipleLines || forceTrailingNewline) {
57704
+ result2 += "\n";
57705
+ }
57706
+ return '"""' + result2 + '"""';
57707
+ }
57708
+ var TokenKind;
57709
+ (function(TokenKind2) {
57710
+ TokenKind2["SOF"] = "<SOF>";
57711
+ TokenKind2["EOF"] = "<EOF>";
57712
+ TokenKind2["BANG"] = "!";
57713
+ TokenKind2["DOLLAR"] = "$";
57714
+ TokenKind2["AMP"] = "&";
57715
+ TokenKind2["PAREN_L"] = "(";
57716
+ TokenKind2["PAREN_R"] = ")";
57717
+ TokenKind2["SPREAD"] = "...";
57718
+ TokenKind2["COLON"] = ":";
57719
+ TokenKind2["EQUALS"] = "=";
57720
+ TokenKind2["AT"] = "@";
57721
+ TokenKind2["BRACKET_L"] = "[";
57722
+ TokenKind2["BRACKET_R"] = "]";
57723
+ TokenKind2["BRACE_L"] = "{";
57724
+ TokenKind2["PIPE"] = "|";
57725
+ TokenKind2["BRACE_R"] = "}";
57726
+ TokenKind2["NAME"] = "Name";
57727
+ TokenKind2["INT"] = "Int";
57728
+ TokenKind2["FLOAT"] = "Float";
57729
+ TokenKind2["STRING"] = "String";
57730
+ TokenKind2["BLOCK_STRING"] = "BlockString";
57731
+ TokenKind2["COMMENT"] = "Comment";
57732
+ })(TokenKind || (TokenKind = {}));
57733
+ class Lexer {
57734
+ /**
57735
+ * The previously focused non-ignored token.
57736
+ */
57737
+ /**
57738
+ * The currently focused non-ignored token.
57739
+ */
57740
+ /**
57741
+ * The (1-indexed) line containing the current token.
57742
+ */
57743
+ /**
57744
+ * The character offset at which the current line begins.
57745
+ */
57746
+ constructor(source) {
57747
+ const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
57748
+ this.source = source;
57749
+ this.lastToken = startOfFileToken;
57750
+ this.token = startOfFileToken;
57751
+ this.line = 1;
57752
+ this.lineStart = 0;
57753
+ }
57754
+ get [Symbol.toStringTag]() {
57755
+ return "Lexer";
57756
+ }
57757
+ /**
57758
+ * Advances the token stream to the next non-ignored token.
57759
+ */
57760
+ advance() {
57761
+ this.lastToken = this.token;
57762
+ const token = this.token = this.lookahead();
57763
+ return token;
57764
+ }
57765
+ /**
57766
+ * Looks ahead and returns the next non-ignored token, but does not change
57767
+ * the state of Lexer.
57768
+ */
57769
+ lookahead() {
57770
+ let token = this.token;
57771
+ if (token.kind !== TokenKind.EOF) {
57772
+ do {
57773
+ if (token.next) {
57774
+ token = token.next;
57775
+ } else {
57776
+ const nextToken = readNextToken(this, token.end);
57777
+ token.next = nextToken;
57778
+ nextToken.prev = token;
57779
+ token = nextToken;
57780
+ }
57781
+ } while (token.kind === TokenKind.COMMENT);
57782
+ }
57783
+ return token;
57784
+ }
57785
+ }
57786
+ function isPunctuatorTokenKind(kind) {
57787
+ return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
57788
+ }
57789
+ function isUnicodeScalarValue(code2) {
57790
+ return code2 >= 0 && code2 <= 55295 || code2 >= 57344 && code2 <= 1114111;
57791
+ }
57792
+ function isSupplementaryCodePoint(body, location) {
57793
+ return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
57794
+ }
57795
+ function isLeadingSurrogate(code2) {
57796
+ return code2 >= 55296 && code2 <= 56319;
57797
+ }
57798
+ function isTrailingSurrogate(code2) {
57799
+ return code2 >= 56320 && code2 <= 57343;
57800
+ }
57801
+ function printCodePointAt(lexer, location) {
57802
+ const code2 = lexer.source.body.codePointAt(location);
57803
+ if (code2 === void 0) {
57804
+ return TokenKind.EOF;
57805
+ } else if (code2 >= 32 && code2 <= 126) {
57806
+ const char = String.fromCodePoint(code2);
57807
+ return char === '"' ? `'"'` : `"${char}"`;
57808
+ }
57809
+ return "U+" + code2.toString(16).toUpperCase().padStart(4, "0");
57810
+ }
57811
+ function createToken(lexer, kind, start, end2, value) {
57812
+ const line = lexer.line;
57813
+ const col = 1 + start - lexer.lineStart;
57814
+ return new Token(kind, start, end2, line, col, value);
57815
+ }
57816
+ function readNextToken(lexer, start) {
57817
+ const body = lexer.source.body;
57818
+ const bodyLength = body.length;
57819
+ let position = start;
57820
+ while (position < bodyLength) {
57821
+ const code2 = body.charCodeAt(position);
57822
+ switch (code2) {
57823
+ // Ignored ::
57824
+ // - UnicodeBOM
57825
+ // - WhiteSpace
57826
+ // - LineTerminator
57827
+ // - Comment
57828
+ // - Comma
57829
+ //
57830
+ // UnicodeBOM :: "Byte Order Mark (U+FEFF)"
57831
+ //
57832
+ // WhiteSpace ::
57833
+ // - "Horizontal Tab (U+0009)"
57834
+ // - "Space (U+0020)"
57835
+ //
57836
+ // Comma :: ,
57837
+ case 65279:
57838
+ // <BOM>
57839
+ case 9:
57840
+ // \t
57841
+ case 32:
57842
+ // <space>
57843
+ case 44:
57844
+ ++position;
57845
+ continue;
57846
+ // LineTerminator ::
57847
+ // - "New Line (U+000A)"
57848
+ // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
57849
+ // - "Carriage Return (U+000D)" "New Line (U+000A)"
57850
+ case 10:
57851
+ ++position;
57852
+ ++lexer.line;
57853
+ lexer.lineStart = position;
57854
+ continue;
57855
+ case 13:
57856
+ if (body.charCodeAt(position + 1) === 10) {
57857
+ position += 2;
57858
+ } else {
57859
+ ++position;
57860
+ }
57861
+ ++lexer.line;
57862
+ lexer.lineStart = position;
57863
+ continue;
57864
+ // Comment
57865
+ case 35:
57866
+ return readComment(lexer, position);
57867
+ // Token ::
57868
+ // - Punctuator
57869
+ // - Name
57870
+ // - IntValue
57871
+ // - FloatValue
57872
+ // - StringValue
57873
+ //
57874
+ // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
57875
+ case 33:
57876
+ return createToken(lexer, TokenKind.BANG, position, position + 1);
57877
+ case 36:
57878
+ return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
57879
+ case 38:
57880
+ return createToken(lexer, TokenKind.AMP, position, position + 1);
57881
+ case 40:
57882
+ return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
57883
+ case 41:
57884
+ return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
57885
+ case 46:
57886
+ if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) {
57887
+ return createToken(lexer, TokenKind.SPREAD, position, position + 3);
57888
+ }
57889
+ break;
57890
+ case 58:
57891
+ return createToken(lexer, TokenKind.COLON, position, position + 1);
57892
+ case 61:
57893
+ return createToken(lexer, TokenKind.EQUALS, position, position + 1);
57894
+ case 64:
57895
+ return createToken(lexer, TokenKind.AT, position, position + 1);
57896
+ case 91:
57897
+ return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
57898
+ case 93:
57899
+ return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
57900
+ case 123:
57901
+ return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
57902
+ case 124:
57903
+ return createToken(lexer, TokenKind.PIPE, position, position + 1);
57904
+ case 125:
57905
+ return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
57906
+ // StringValue
57907
+ case 34:
57908
+ if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
57909
+ return readBlockString(lexer, position);
57910
+ }
57911
+ return readString(lexer, position);
57912
+ }
57913
+ if (isDigit(code2) || code2 === 45) {
57914
+ return readNumber(lexer, position, code2);
57915
+ }
57916
+ if (isNameStart(code2)) {
57917
+ return readName(lexer, position);
57918
+ }
57919
+ throw syntaxError(
57920
+ lexer.source,
57921
+ position,
57922
+ code2 === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : isUnicodeScalarValue(code2) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`
57923
+ );
57924
+ }
57925
+ return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
57926
+ }
57927
+ function readComment(lexer, start) {
57928
+ const body = lexer.source.body;
57929
+ const bodyLength = body.length;
57930
+ let position = start + 1;
57931
+ while (position < bodyLength) {
57932
+ const code2 = body.charCodeAt(position);
57933
+ if (code2 === 10 || code2 === 13) {
57934
+ break;
57935
+ }
57936
+ if (isUnicodeScalarValue(code2)) {
57937
+ ++position;
57938
+ } else if (isSupplementaryCodePoint(body, position)) {
57939
+ position += 2;
57940
+ } else {
57941
+ break;
57942
+ }
57943
+ }
57944
+ return createToken(
57945
+ lexer,
57946
+ TokenKind.COMMENT,
57947
+ start,
57948
+ position,
57949
+ body.slice(start + 1, position)
57950
+ );
57951
+ }
57952
+ function readNumber(lexer, start, firstCode) {
57953
+ const body = lexer.source.body;
57954
+ let position = start;
57955
+ let code2 = firstCode;
57956
+ let isFloat = false;
57957
+ if (code2 === 45) {
57958
+ code2 = body.charCodeAt(++position);
57959
+ }
57960
+ if (code2 === 48) {
57961
+ code2 = body.charCodeAt(++position);
57962
+ if (isDigit(code2)) {
57963
+ throw syntaxError(
57964
+ lexer.source,
57965
+ position,
57966
+ `Invalid number, unexpected digit after 0: ${printCodePointAt(
57967
+ lexer,
57968
+ position
57969
+ )}.`
57970
+ );
57971
+ }
57972
+ } else {
57973
+ position = readDigits(lexer, position, code2);
57974
+ code2 = body.charCodeAt(position);
57975
+ }
57976
+ if (code2 === 46) {
57977
+ isFloat = true;
57978
+ code2 = body.charCodeAt(++position);
57979
+ position = readDigits(lexer, position, code2);
57980
+ code2 = body.charCodeAt(position);
57981
+ }
57982
+ if (code2 === 69 || code2 === 101) {
57983
+ isFloat = true;
57984
+ code2 = body.charCodeAt(++position);
57985
+ if (code2 === 43 || code2 === 45) {
57986
+ code2 = body.charCodeAt(++position);
57987
+ }
57988
+ position = readDigits(lexer, position, code2);
57989
+ code2 = body.charCodeAt(position);
57990
+ }
57991
+ if (code2 === 46 || isNameStart(code2)) {
57992
+ throw syntaxError(
57993
+ lexer.source,
57994
+ position,
57995
+ `Invalid number, expected digit but got: ${printCodePointAt(
57996
+ lexer,
57997
+ position
57998
+ )}.`
57999
+ );
58000
+ }
58001
+ return createToken(
58002
+ lexer,
58003
+ isFloat ? TokenKind.FLOAT : TokenKind.INT,
58004
+ start,
58005
+ position,
58006
+ body.slice(start, position)
58007
+ );
58008
+ }
58009
+ function readDigits(lexer, start, firstCode) {
58010
+ if (!isDigit(firstCode)) {
58011
+ throw syntaxError(
58012
+ lexer.source,
58013
+ start,
58014
+ `Invalid number, expected digit but got: ${printCodePointAt(
58015
+ lexer,
58016
+ start
58017
+ )}.`
58018
+ );
58019
+ }
58020
+ const body = lexer.source.body;
58021
+ let position = start + 1;
58022
+ while (isDigit(body.charCodeAt(position))) {
58023
+ ++position;
58024
+ }
58025
+ return position;
58026
+ }
58027
+ function readString(lexer, start) {
58028
+ const body = lexer.source.body;
58029
+ const bodyLength = body.length;
58030
+ let position = start + 1;
58031
+ let chunkStart = position;
58032
+ let value = "";
58033
+ while (position < bodyLength) {
58034
+ const code2 = body.charCodeAt(position);
58035
+ if (code2 === 34) {
58036
+ value += body.slice(chunkStart, position);
58037
+ return createToken(lexer, TokenKind.STRING, start, position + 1, value);
58038
+ }
58039
+ if (code2 === 92) {
58040
+ value += body.slice(chunkStart, position);
58041
+ const escape2 = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
58042
+ value += escape2.value;
58043
+ position += escape2.size;
58044
+ chunkStart = position;
58045
+ continue;
58046
+ }
58047
+ if (code2 === 10 || code2 === 13) {
58048
+ break;
58049
+ }
58050
+ if (isUnicodeScalarValue(code2)) {
58051
+ ++position;
58052
+ } else if (isSupplementaryCodePoint(body, position)) {
58053
+ position += 2;
58054
+ } else {
58055
+ throw syntaxError(
58056
+ lexer.source,
58057
+ position,
58058
+ `Invalid character within String: ${printCodePointAt(
58059
+ lexer,
58060
+ position
58061
+ )}.`
58062
+ );
58063
+ }
58064
+ }
58065
+ throw syntaxError(lexer.source, position, "Unterminated string.");
58066
+ }
58067
+ function readEscapedUnicodeVariableWidth(lexer, position) {
58068
+ const body = lexer.source.body;
58069
+ let point = 0;
58070
+ let size = 3;
58071
+ while (size < 12) {
58072
+ const code2 = body.charCodeAt(position + size++);
58073
+ if (code2 === 125) {
58074
+ if (size < 5 || !isUnicodeScalarValue(point)) {
58075
+ break;
58076
+ }
58077
+ return {
58078
+ value: String.fromCodePoint(point),
58079
+ size
58080
+ };
58081
+ }
58082
+ point = point << 4 | readHexDigit(code2);
58083
+ if (point < 0) {
58084
+ break;
58085
+ }
58086
+ }
58087
+ throw syntaxError(
58088
+ lexer.source,
58089
+ position,
58090
+ `Invalid Unicode escape sequence: "${body.slice(
58091
+ position,
58092
+ position + size
58093
+ )}".`
58094
+ );
58095
+ }
58096
+ function readEscapedUnicodeFixedWidth(lexer, position) {
58097
+ const body = lexer.source.body;
58098
+ const code2 = read16BitHexCode(body, position + 2);
58099
+ if (isUnicodeScalarValue(code2)) {
58100
+ return {
58101
+ value: String.fromCodePoint(code2),
58102
+ size: 6
58103
+ };
58104
+ }
58105
+ if (isLeadingSurrogate(code2)) {
58106
+ if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
58107
+ const trailingCode = read16BitHexCode(body, position + 8);
58108
+ if (isTrailingSurrogate(trailingCode)) {
58109
+ return {
58110
+ value: String.fromCodePoint(code2, trailingCode),
58111
+ size: 12
58112
+ };
58113
+ }
58114
+ }
58115
+ }
58116
+ throw syntaxError(
58117
+ lexer.source,
58118
+ position,
58119
+ `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`
58120
+ );
58121
+ }
58122
+ function read16BitHexCode(body, position) {
58123
+ return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
58124
+ }
58125
+ function readHexDigit(code2) {
58126
+ return code2 >= 48 && code2 <= 57 ? code2 - 48 : code2 >= 65 && code2 <= 70 ? code2 - 55 : code2 >= 97 && code2 <= 102 ? code2 - 87 : -1;
58127
+ }
58128
+ function readEscapedCharacter(lexer, position) {
58129
+ const body = lexer.source.body;
58130
+ const code2 = body.charCodeAt(position + 1);
58131
+ switch (code2) {
58132
+ case 34:
58133
+ return {
58134
+ value: '"',
58135
+ size: 2
58136
+ };
58137
+ case 92:
58138
+ return {
58139
+ value: "\\",
58140
+ size: 2
58141
+ };
58142
+ case 47:
58143
+ return {
58144
+ value: "/",
58145
+ size: 2
58146
+ };
58147
+ case 98:
58148
+ return {
58149
+ value: "\b",
58150
+ size: 2
58151
+ };
58152
+ case 102:
58153
+ return {
58154
+ value: "\f",
58155
+ size: 2
58156
+ };
58157
+ case 110:
58158
+ return {
58159
+ value: "\n",
58160
+ size: 2
58161
+ };
58162
+ case 114:
58163
+ return {
58164
+ value: "\r",
58165
+ size: 2
58166
+ };
58167
+ case 116:
58168
+ return {
58169
+ value: " ",
58170
+ size: 2
58171
+ };
58172
+ }
58173
+ throw syntaxError(
58174
+ lexer.source,
58175
+ position,
58176
+ `Invalid character escape sequence: "${body.slice(
58177
+ position,
58178
+ position + 2
58179
+ )}".`
58180
+ );
58181
+ }
58182
+ function readBlockString(lexer, start) {
58183
+ const body = lexer.source.body;
58184
+ const bodyLength = body.length;
58185
+ let lineStart = lexer.lineStart;
58186
+ let position = start + 3;
58187
+ let chunkStart = position;
58188
+ let currentLine = "";
58189
+ const blockLines = [];
58190
+ while (position < bodyLength) {
58191
+ const code2 = body.charCodeAt(position);
58192
+ if (code2 === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
58193
+ currentLine += body.slice(chunkStart, position);
58194
+ blockLines.push(currentLine);
58195
+ const token = createToken(
58196
+ lexer,
58197
+ TokenKind.BLOCK_STRING,
58198
+ start,
58199
+ position + 3,
58200
+ // Return a string of the lines joined with U+000A.
58201
+ dedentBlockStringLines(blockLines).join("\n")
58202
+ );
58203
+ lexer.line += blockLines.length - 1;
58204
+ lexer.lineStart = lineStart;
58205
+ return token;
58206
+ }
58207
+ if (code2 === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
58208
+ currentLine += body.slice(chunkStart, position);
58209
+ chunkStart = position + 1;
58210
+ position += 4;
58211
+ continue;
58212
+ }
58213
+ if (code2 === 10 || code2 === 13) {
58214
+ currentLine += body.slice(chunkStart, position);
58215
+ blockLines.push(currentLine);
58216
+ if (code2 === 13 && body.charCodeAt(position + 1) === 10) {
58217
+ position += 2;
58218
+ } else {
58219
+ ++position;
58220
+ }
58221
+ currentLine = "";
58222
+ chunkStart = position;
58223
+ lineStart = position;
58224
+ continue;
58225
+ }
58226
+ if (isUnicodeScalarValue(code2)) {
58227
+ ++position;
58228
+ } else if (isSupplementaryCodePoint(body, position)) {
58229
+ position += 2;
58230
+ } else {
58231
+ throw syntaxError(
58232
+ lexer.source,
58233
+ position,
58234
+ `Invalid character within String: ${printCodePointAt(
58235
+ lexer,
58236
+ position
58237
+ )}.`
58238
+ );
58239
+ }
58240
+ }
58241
+ throw syntaxError(lexer.source, position, "Unterminated string.");
58242
+ }
58243
+ function readName(lexer, start) {
58244
+ const body = lexer.source.body;
58245
+ const bodyLength = body.length;
58246
+ let position = start + 1;
58247
+ while (position < bodyLength) {
58248
+ const code2 = body.charCodeAt(position);
58249
+ if (isNameContinue(code2)) {
58250
+ ++position;
58251
+ } else {
58252
+ break;
58253
+ }
58254
+ }
58255
+ return createToken(
58256
+ lexer,
58257
+ TokenKind.NAME,
58258
+ start,
58259
+ position,
58260
+ body.slice(start, position)
58261
+ );
58262
+ }
58263
+ const MAX_ARRAY_LENGTH = 10;
58264
+ const MAX_RECURSIVE_DEPTH = 2;
58265
+ function inspect(value) {
58266
+ return formatValue(value, []);
58267
+ }
58268
+ function formatValue(value, seenValues) {
58269
+ switch (typeof value) {
58270
+ case "string":
58271
+ return JSON.stringify(value);
58272
+ case "function":
58273
+ return value.name ? `[function ${value.name}]` : "[function]";
58274
+ case "object":
58275
+ return formatObjectValue(value, seenValues);
58276
+ default:
58277
+ return String(value);
58278
+ }
58279
+ }
58280
+ function formatObjectValue(value, previouslySeenValues) {
58281
+ if (value === null) {
58282
+ return "null";
58283
+ }
58284
+ if (previouslySeenValues.includes(value)) {
58285
+ return "[Circular]";
58286
+ }
58287
+ const seenValues = [...previouslySeenValues, value];
58288
+ if (isJSONable(value)) {
58289
+ const jsonValue = value.toJSON();
58290
+ if (jsonValue !== value) {
58291
+ return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
58292
+ }
58293
+ } else if (Array.isArray(value)) {
58294
+ return formatArray(value, seenValues);
58295
+ }
58296
+ return formatObject(value, seenValues);
58297
+ }
58298
+ function isJSONable(value) {
58299
+ return typeof value.toJSON === "function";
58300
+ }
58301
+ function formatObject(object, seenValues) {
58302
+ const entries = Object.entries(object);
58303
+ if (entries.length === 0) {
58304
+ return "{}";
58305
+ }
58306
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
58307
+ return "[" + getObjectTag(object) + "]";
58308
+ }
58309
+ const properties2 = entries.map(
58310
+ ([key, value]) => key + ": " + formatValue(value, seenValues)
58311
+ );
58312
+ return "{ " + properties2.join(", ") + " }";
58313
+ }
58314
+ function formatArray(array, seenValues) {
58315
+ if (array.length === 0) {
58316
+ return "[]";
58317
+ }
58318
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
58319
+ return "[Array]";
58320
+ }
58321
+ const len = Math.min(MAX_ARRAY_LENGTH, array.length);
58322
+ const remaining = array.length - len;
58323
+ const items2 = [];
58324
+ for (let i = 0; i < len; ++i) {
58325
+ items2.push(formatValue(array[i], seenValues));
58326
+ }
58327
+ if (remaining === 1) {
58328
+ items2.push("... 1 more item");
58329
+ } else if (remaining > 1) {
58330
+ items2.push(`... ${remaining} more items`);
58331
+ }
58332
+ return "[" + items2.join(", ") + "]";
58333
+ }
58334
+ function getObjectTag(object) {
58335
+ const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
58336
+ if (tag === "Object" && typeof object.constructor === "function") {
58337
+ const name = object.constructor.name;
58338
+ if (typeof name === "string" && name !== "") {
58339
+ return name;
58340
+ }
58341
+ }
58342
+ return tag;
58343
+ }
58344
+ const isProduction = globalThis.process && // eslint-disable-next-line no-undef
58345
+ process.env.NODE_ENV === "production";
58346
+ const instanceOf = (
58347
+ /* c8 ignore next 6 */
58348
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
58349
+ isProduction ? function instanceOf2(value, constructor) {
58350
+ return value instanceof constructor;
58351
+ } : function instanceOf3(value, constructor) {
58352
+ if (value instanceof constructor) {
58353
+ return true;
58354
+ }
58355
+ if (typeof value === "object" && value !== null) {
58356
+ var _value$constructor;
58357
+ const className = constructor.prototype[Symbol.toStringTag];
58358
+ const valueClassName = (
58359
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
58360
+ Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name
58361
+ );
58362
+ if (className === valueClassName) {
58363
+ const stringifiedValue = inspect(value);
58364
+ throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
58365
+
58366
+ Ensure that there is only one instance of "graphql" in the node_modules
58367
+ directory. If different versions of "graphql" are the dependencies of other
58368
+ relied on modules, use "resolutions" to ensure only one version is installed.
58369
+
58370
+ https://yarnpkg.com/en/docs/selective-version-resolutions
58371
+
58372
+ Duplicate "graphql" modules cannot be used at the same time since different
58373
+ versions may have different capabilities and behavior. The data from one
58374
+ version used in the function from another could produce confusing and
58375
+ spurious results.`);
58376
+ }
58377
+ }
58378
+ return false;
58379
+ }
58380
+ );
58381
+ class Source {
58382
+ constructor(body, name = "GraphQL request", locationOffset = {
58383
+ line: 1,
58384
+ column: 1
58385
+ }) {
58386
+ typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
58387
+ this.body = body;
58388
+ this.name = name;
58389
+ this.locationOffset = locationOffset;
58390
+ this.locationOffset.line > 0 || devAssert(
58391
+ false,
58392
+ "line in locationOffset is 1-indexed and must be positive."
58393
+ );
58394
+ this.locationOffset.column > 0 || devAssert(
58395
+ false,
58396
+ "column in locationOffset is 1-indexed and must be positive."
58397
+ );
58398
+ }
58399
+ get [Symbol.toStringTag]() {
58400
+ return "Source";
58401
+ }
58402
+ }
58403
+ function isSource(source) {
58404
+ return instanceOf(source, Source);
58405
+ }
58406
+ function parse(source, options) {
58407
+ const parser2 = new Parser(source, options);
58408
+ const document = parser2.parseDocument();
58409
+ Object.defineProperty(document, "tokenCount", {
58410
+ enumerable: false,
58411
+ value: parser2.tokenCount
58412
+ });
58413
+ return document;
58414
+ }
58415
+ class Parser {
58416
+ constructor(source, options = {}) {
58417
+ const sourceObj = isSource(source) ? source : new Source(source);
58418
+ this._lexer = new Lexer(sourceObj);
58419
+ this._options = options;
58420
+ this._tokenCounter = 0;
58421
+ }
58422
+ get tokenCount() {
58423
+ return this._tokenCounter;
58424
+ }
58425
+ /**
58426
+ * Converts a name lex token into a name parse node.
58427
+ */
58428
+ parseName() {
58429
+ const token = this.expectToken(TokenKind.NAME);
58430
+ return this.node(token, {
58431
+ kind: Kind.NAME,
58432
+ value: token.value
58433
+ });
58434
+ }
58435
+ // Implements the parsing rules in the Document section.
58436
+ /**
58437
+ * Document : Definition+
58438
+ */
58439
+ parseDocument() {
58440
+ return this.node(this._lexer.token, {
58441
+ kind: Kind.DOCUMENT,
58442
+ definitions: this.many(
58443
+ TokenKind.SOF,
58444
+ this.parseDefinition,
58445
+ TokenKind.EOF
58446
+ )
58447
+ });
58448
+ }
58449
+ /**
58450
+ * Definition :
58451
+ * - ExecutableDefinition
58452
+ * - TypeSystemDefinition
58453
+ * - TypeSystemExtension
58454
+ *
58455
+ * ExecutableDefinition :
58456
+ * - OperationDefinition
58457
+ * - FragmentDefinition
58458
+ *
58459
+ * TypeSystemDefinition :
58460
+ * - SchemaDefinition
58461
+ * - TypeDefinition
58462
+ * - DirectiveDefinition
58463
+ *
58464
+ * TypeDefinition :
58465
+ * - ScalarTypeDefinition
58466
+ * - ObjectTypeDefinition
58467
+ * - InterfaceTypeDefinition
58468
+ * - UnionTypeDefinition
58469
+ * - EnumTypeDefinition
58470
+ * - InputObjectTypeDefinition
58471
+ */
58472
+ parseDefinition() {
58473
+ if (this.peek(TokenKind.BRACE_L)) {
58474
+ return this.parseOperationDefinition();
58475
+ }
58476
+ const hasDescription = this.peekDescription();
58477
+ const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
58478
+ if (keywordToken.kind === TokenKind.NAME) {
58479
+ switch (keywordToken.value) {
58480
+ case "schema":
58481
+ return this.parseSchemaDefinition();
58482
+ case "scalar":
58483
+ return this.parseScalarTypeDefinition();
58484
+ case "type":
58485
+ return this.parseObjectTypeDefinition();
58486
+ case "interface":
58487
+ return this.parseInterfaceTypeDefinition();
58488
+ case "union":
58489
+ return this.parseUnionTypeDefinition();
58490
+ case "enum":
58491
+ return this.parseEnumTypeDefinition();
58492
+ case "input":
58493
+ return this.parseInputObjectTypeDefinition();
58494
+ case "directive":
58495
+ return this.parseDirectiveDefinition();
58496
+ }
58497
+ if (hasDescription) {
58498
+ throw syntaxError(
58499
+ this._lexer.source,
58500
+ this._lexer.token.start,
58501
+ "Unexpected description, descriptions are supported only on type definitions."
58502
+ );
58503
+ }
58504
+ switch (keywordToken.value) {
58505
+ case "query":
58506
+ case "mutation":
58507
+ case "subscription":
58508
+ return this.parseOperationDefinition();
58509
+ case "fragment":
58510
+ return this.parseFragmentDefinition();
58511
+ case "extend":
58512
+ return this.parseTypeSystemExtension();
58513
+ }
58514
+ }
58515
+ throw this.unexpected(keywordToken);
58516
+ }
58517
+ // Implements the parsing rules in the Operations section.
58518
+ /**
58519
+ * OperationDefinition :
58520
+ * - SelectionSet
58521
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
58522
+ */
58523
+ parseOperationDefinition() {
58524
+ const start = this._lexer.token;
58525
+ if (this.peek(TokenKind.BRACE_L)) {
58526
+ return this.node(start, {
58527
+ kind: Kind.OPERATION_DEFINITION,
58528
+ operation: OperationTypeNode.QUERY,
58529
+ name: void 0,
58530
+ variableDefinitions: [],
58531
+ directives: [],
58532
+ selectionSet: this.parseSelectionSet()
58533
+ });
58534
+ }
58535
+ const operation = this.parseOperationType();
58536
+ let name;
58537
+ if (this.peek(TokenKind.NAME)) {
58538
+ name = this.parseName();
58539
+ }
58540
+ return this.node(start, {
58541
+ kind: Kind.OPERATION_DEFINITION,
58542
+ operation,
58543
+ name,
58544
+ variableDefinitions: this.parseVariableDefinitions(),
58545
+ directives: this.parseDirectives(false),
58546
+ selectionSet: this.parseSelectionSet()
58547
+ });
58548
+ }
58549
+ /**
58550
+ * OperationType : one of query mutation subscription
58551
+ */
58552
+ parseOperationType() {
58553
+ const operationToken = this.expectToken(TokenKind.NAME);
58554
+ switch (operationToken.value) {
58555
+ case "query":
58556
+ return OperationTypeNode.QUERY;
58557
+ case "mutation":
58558
+ return OperationTypeNode.MUTATION;
58559
+ case "subscription":
58560
+ return OperationTypeNode.SUBSCRIPTION;
58561
+ }
58562
+ throw this.unexpected(operationToken);
58563
+ }
58564
+ /**
58565
+ * VariableDefinitions : ( VariableDefinition+ )
58566
+ */
58567
+ parseVariableDefinitions() {
58568
+ return this.optionalMany(
58569
+ TokenKind.PAREN_L,
58570
+ this.parseVariableDefinition,
58571
+ TokenKind.PAREN_R
58572
+ );
58573
+ }
58574
+ /**
58575
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
58576
+ */
58577
+ parseVariableDefinition() {
58578
+ return this.node(this._lexer.token, {
58579
+ kind: Kind.VARIABLE_DEFINITION,
58580
+ variable: this.parseVariable(),
58581
+ type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
58582
+ defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
58583
+ directives: this.parseConstDirectives()
58584
+ });
58585
+ }
58586
+ /**
58587
+ * Variable : $ Name
58588
+ */
58589
+ parseVariable() {
58590
+ const start = this._lexer.token;
58591
+ this.expectToken(TokenKind.DOLLAR);
58592
+ return this.node(start, {
58593
+ kind: Kind.VARIABLE,
58594
+ name: this.parseName()
58595
+ });
58596
+ }
58597
+ /**
58598
+ * ```
58599
+ * SelectionSet : { Selection+ }
58600
+ * ```
58601
+ */
58602
+ parseSelectionSet() {
58603
+ return this.node(this._lexer.token, {
58604
+ kind: Kind.SELECTION_SET,
58605
+ selections: this.many(
58606
+ TokenKind.BRACE_L,
58607
+ this.parseSelection,
58608
+ TokenKind.BRACE_R
58609
+ )
58610
+ });
58611
+ }
58612
+ /**
58613
+ * Selection :
58614
+ * - Field
58615
+ * - FragmentSpread
58616
+ * - InlineFragment
58617
+ */
58618
+ parseSelection() {
58619
+ return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
58620
+ }
58621
+ /**
58622
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
58623
+ *
58624
+ * Alias : Name :
58625
+ */
58626
+ parseField() {
58627
+ const start = this._lexer.token;
58628
+ const nameOrAlias = this.parseName();
58629
+ let alias;
58630
+ let name;
58631
+ if (this.expectOptionalToken(TokenKind.COLON)) {
58632
+ alias = nameOrAlias;
58633
+ name = this.parseName();
58634
+ } else {
58635
+ name = nameOrAlias;
58636
+ }
58637
+ return this.node(start, {
58638
+ kind: Kind.FIELD,
58639
+ alias,
58640
+ name,
58641
+ arguments: this.parseArguments(false),
58642
+ directives: this.parseDirectives(false),
58643
+ selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
58644
+ });
58645
+ }
58646
+ /**
58647
+ * Arguments[Const] : ( Argument[?Const]+ )
58648
+ */
58649
+ parseArguments(isConst) {
58650
+ const item = isConst ? this.parseConstArgument : this.parseArgument;
58651
+ return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
58652
+ }
58653
+ /**
58654
+ * Argument[Const] : Name : Value[?Const]
58655
+ */
58656
+ parseArgument(isConst = false) {
58657
+ const start = this._lexer.token;
58658
+ const name = this.parseName();
58659
+ this.expectToken(TokenKind.COLON);
58660
+ return this.node(start, {
58661
+ kind: Kind.ARGUMENT,
58662
+ name,
58663
+ value: this.parseValueLiteral(isConst)
58664
+ });
58665
+ }
58666
+ parseConstArgument() {
58667
+ return this.parseArgument(true);
58668
+ }
58669
+ // Implements the parsing rules in the Fragments section.
58670
+ /**
58671
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
58672
+ *
58673
+ * FragmentSpread : ... FragmentName Directives?
58674
+ *
58675
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
58676
+ */
58677
+ parseFragment() {
58678
+ const start = this._lexer.token;
58679
+ this.expectToken(TokenKind.SPREAD);
58680
+ const hasTypeCondition = this.expectOptionalKeyword("on");
58681
+ if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
58682
+ return this.node(start, {
58683
+ kind: Kind.FRAGMENT_SPREAD,
58684
+ name: this.parseFragmentName(),
58685
+ directives: this.parseDirectives(false)
58686
+ });
58687
+ }
58688
+ return this.node(start, {
58689
+ kind: Kind.INLINE_FRAGMENT,
58690
+ typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
58691
+ directives: this.parseDirectives(false),
58692
+ selectionSet: this.parseSelectionSet()
58693
+ });
58694
+ }
58695
+ /**
58696
+ * FragmentDefinition :
58697
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
58698
+ *
58699
+ * TypeCondition : NamedType
58700
+ */
58701
+ parseFragmentDefinition() {
58702
+ const start = this._lexer.token;
58703
+ this.expectKeyword("fragment");
58704
+ if (this._options.allowLegacyFragmentVariables === true) {
58705
+ return this.node(start, {
58706
+ kind: Kind.FRAGMENT_DEFINITION,
58707
+ name: this.parseFragmentName(),
58708
+ variableDefinitions: this.parseVariableDefinitions(),
58709
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
58710
+ directives: this.parseDirectives(false),
58711
+ selectionSet: this.parseSelectionSet()
58712
+ });
58713
+ }
58714
+ return this.node(start, {
58715
+ kind: Kind.FRAGMENT_DEFINITION,
58716
+ name: this.parseFragmentName(),
58717
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
58718
+ directives: this.parseDirectives(false),
58719
+ selectionSet: this.parseSelectionSet()
58720
+ });
58721
+ }
58722
+ /**
58723
+ * FragmentName : Name but not `on`
58724
+ */
58725
+ parseFragmentName() {
58726
+ if (this._lexer.token.value === "on") {
58727
+ throw this.unexpected();
58728
+ }
58729
+ return this.parseName();
58730
+ }
58731
+ // Implements the parsing rules in the Values section.
58732
+ /**
58733
+ * Value[Const] :
58734
+ * - [~Const] Variable
58735
+ * - IntValue
58736
+ * - FloatValue
58737
+ * - StringValue
58738
+ * - BooleanValue
58739
+ * - NullValue
58740
+ * - EnumValue
58741
+ * - ListValue[?Const]
58742
+ * - ObjectValue[?Const]
58743
+ *
58744
+ * BooleanValue : one of `true` `false`
58745
+ *
58746
+ * NullValue : `null`
58747
+ *
58748
+ * EnumValue : Name but not `true`, `false` or `null`
58749
+ */
58750
+ parseValueLiteral(isConst) {
58751
+ const token = this._lexer.token;
58752
+ switch (token.kind) {
58753
+ case TokenKind.BRACKET_L:
58754
+ return this.parseList(isConst);
58755
+ case TokenKind.BRACE_L:
58756
+ return this.parseObject(isConst);
58757
+ case TokenKind.INT:
58758
+ this.advanceLexer();
58759
+ return this.node(token, {
58760
+ kind: Kind.INT,
58761
+ value: token.value
58762
+ });
58763
+ case TokenKind.FLOAT:
58764
+ this.advanceLexer();
58765
+ return this.node(token, {
58766
+ kind: Kind.FLOAT,
58767
+ value: token.value
58768
+ });
58769
+ case TokenKind.STRING:
58770
+ case TokenKind.BLOCK_STRING:
58771
+ return this.parseStringLiteral();
58772
+ case TokenKind.NAME:
58773
+ this.advanceLexer();
58774
+ switch (token.value) {
58775
+ case "true":
58776
+ return this.node(token, {
58777
+ kind: Kind.BOOLEAN,
58778
+ value: true
58779
+ });
58780
+ case "false":
58781
+ return this.node(token, {
58782
+ kind: Kind.BOOLEAN,
58783
+ value: false
58784
+ });
58785
+ case "null":
58786
+ return this.node(token, {
58787
+ kind: Kind.NULL
58788
+ });
58789
+ default:
58790
+ return this.node(token, {
58791
+ kind: Kind.ENUM,
58792
+ value: token.value
58793
+ });
58794
+ }
58795
+ case TokenKind.DOLLAR:
58796
+ if (isConst) {
58797
+ this.expectToken(TokenKind.DOLLAR);
58798
+ if (this._lexer.token.kind === TokenKind.NAME) {
58799
+ const varName = this._lexer.token.value;
58800
+ throw syntaxError(
58801
+ this._lexer.source,
58802
+ token.start,
58803
+ `Unexpected variable "$${varName}" in constant value.`
58804
+ );
58805
+ } else {
58806
+ throw this.unexpected(token);
58807
+ }
58808
+ }
58809
+ return this.parseVariable();
58810
+ default:
58811
+ throw this.unexpected();
58812
+ }
58813
+ }
58814
+ parseConstValueLiteral() {
58815
+ return this.parseValueLiteral(true);
58816
+ }
58817
+ parseStringLiteral() {
58818
+ const token = this._lexer.token;
58819
+ this.advanceLexer();
58820
+ return this.node(token, {
58821
+ kind: Kind.STRING,
58822
+ value: token.value,
58823
+ block: token.kind === TokenKind.BLOCK_STRING
58824
+ });
58825
+ }
58826
+ /**
58827
+ * ListValue[Const] :
58828
+ * - [ ]
58829
+ * - [ Value[?Const]+ ]
58830
+ */
58831
+ parseList(isConst) {
58832
+ const item = () => this.parseValueLiteral(isConst);
58833
+ return this.node(this._lexer.token, {
58834
+ kind: Kind.LIST,
58835
+ values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
58836
+ });
58837
+ }
58838
+ /**
58839
+ * ```
58840
+ * ObjectValue[Const] :
58841
+ * - { }
58842
+ * - { ObjectField[?Const]+ }
58843
+ * ```
58844
+ */
58845
+ parseObject(isConst) {
58846
+ const item = () => this.parseObjectField(isConst);
58847
+ return this.node(this._lexer.token, {
58848
+ kind: Kind.OBJECT,
58849
+ fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
58850
+ });
58851
+ }
58852
+ /**
58853
+ * ObjectField[Const] : Name : Value[?Const]
58854
+ */
58855
+ parseObjectField(isConst) {
58856
+ const start = this._lexer.token;
58857
+ const name = this.parseName();
58858
+ this.expectToken(TokenKind.COLON);
58859
+ return this.node(start, {
58860
+ kind: Kind.OBJECT_FIELD,
58861
+ name,
58862
+ value: this.parseValueLiteral(isConst)
58863
+ });
58864
+ }
58865
+ // Implements the parsing rules in the Directives section.
58866
+ /**
58867
+ * Directives[Const] : Directive[?Const]+
58868
+ */
58869
+ parseDirectives(isConst) {
58870
+ const directives = [];
58871
+ while (this.peek(TokenKind.AT)) {
58872
+ directives.push(this.parseDirective(isConst));
58873
+ }
58874
+ return directives;
58875
+ }
58876
+ parseConstDirectives() {
58877
+ return this.parseDirectives(true);
58878
+ }
58879
+ /**
58880
+ * ```
58881
+ * Directive[Const] : @ Name Arguments[?Const]?
58882
+ * ```
58883
+ */
58884
+ parseDirective(isConst) {
58885
+ const start = this._lexer.token;
58886
+ this.expectToken(TokenKind.AT);
58887
+ return this.node(start, {
58888
+ kind: Kind.DIRECTIVE,
58889
+ name: this.parseName(),
58890
+ arguments: this.parseArguments(isConst)
58891
+ });
58892
+ }
58893
+ // Implements the parsing rules in the Types section.
58894
+ /**
58895
+ * Type :
58896
+ * - NamedType
58897
+ * - ListType
58898
+ * - NonNullType
58899
+ */
58900
+ parseTypeReference() {
58901
+ const start = this._lexer.token;
58902
+ let type2;
58903
+ if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
58904
+ const innerType = this.parseTypeReference();
58905
+ this.expectToken(TokenKind.BRACKET_R);
58906
+ type2 = this.node(start, {
58907
+ kind: Kind.LIST_TYPE,
58908
+ type: innerType
58909
+ });
58910
+ } else {
58911
+ type2 = this.parseNamedType();
58912
+ }
58913
+ if (this.expectOptionalToken(TokenKind.BANG)) {
58914
+ return this.node(start, {
58915
+ kind: Kind.NON_NULL_TYPE,
58916
+ type: type2
58917
+ });
58918
+ }
58919
+ return type2;
58920
+ }
58921
+ /**
58922
+ * NamedType : Name
58923
+ */
58924
+ parseNamedType() {
58925
+ return this.node(this._lexer.token, {
58926
+ kind: Kind.NAMED_TYPE,
58927
+ name: this.parseName()
58928
+ });
58929
+ }
58930
+ // Implements the parsing rules in the Type Definition section.
58931
+ peekDescription() {
58932
+ return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
58933
+ }
58934
+ /**
58935
+ * Description : StringValue
58936
+ */
58937
+ parseDescription() {
58938
+ if (this.peekDescription()) {
58939
+ return this.parseStringLiteral();
58940
+ }
58941
+ }
58942
+ /**
58943
+ * ```
58944
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
58945
+ * ```
58946
+ */
58947
+ parseSchemaDefinition() {
58948
+ const start = this._lexer.token;
58949
+ const description2 = this.parseDescription();
58950
+ this.expectKeyword("schema");
58951
+ const directives = this.parseConstDirectives();
58952
+ const operationTypes = this.many(
58953
+ TokenKind.BRACE_L,
58954
+ this.parseOperationTypeDefinition,
58955
+ TokenKind.BRACE_R
58956
+ );
58957
+ return this.node(start, {
58958
+ kind: Kind.SCHEMA_DEFINITION,
58959
+ description: description2,
58960
+ directives,
58961
+ operationTypes
58962
+ });
58963
+ }
58964
+ /**
58965
+ * OperationTypeDefinition : OperationType : NamedType
58966
+ */
58967
+ parseOperationTypeDefinition() {
58968
+ const start = this._lexer.token;
58969
+ const operation = this.parseOperationType();
58970
+ this.expectToken(TokenKind.COLON);
58971
+ const type2 = this.parseNamedType();
58972
+ return this.node(start, {
58973
+ kind: Kind.OPERATION_TYPE_DEFINITION,
58974
+ operation,
58975
+ type: type2
58976
+ });
58977
+ }
58978
+ /**
58979
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
58980
+ */
58981
+ parseScalarTypeDefinition() {
58982
+ const start = this._lexer.token;
58983
+ const description2 = this.parseDescription();
58984
+ this.expectKeyword("scalar");
58985
+ const name = this.parseName();
58986
+ const directives = this.parseConstDirectives();
58987
+ return this.node(start, {
58988
+ kind: Kind.SCALAR_TYPE_DEFINITION,
58989
+ description: description2,
58990
+ name,
58991
+ directives
58992
+ });
58993
+ }
58994
+ /**
58995
+ * ObjectTypeDefinition :
58996
+ * Description?
58997
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
58998
+ */
58999
+ parseObjectTypeDefinition() {
59000
+ const start = this._lexer.token;
59001
+ const description2 = this.parseDescription();
59002
+ this.expectKeyword("type");
59003
+ const name = this.parseName();
59004
+ const interfaces = this.parseImplementsInterfaces();
59005
+ const directives = this.parseConstDirectives();
59006
+ const fields = this.parseFieldsDefinition();
59007
+ return this.node(start, {
59008
+ kind: Kind.OBJECT_TYPE_DEFINITION,
59009
+ description: description2,
59010
+ name,
59011
+ interfaces,
59012
+ directives,
59013
+ fields
59014
+ });
59015
+ }
59016
+ /**
59017
+ * ImplementsInterfaces :
59018
+ * - implements `&`? NamedType
59019
+ * - ImplementsInterfaces & NamedType
59020
+ */
59021
+ parseImplementsInterfaces() {
59022
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
59023
+ }
59024
+ /**
59025
+ * ```
59026
+ * FieldsDefinition : { FieldDefinition+ }
59027
+ * ```
59028
+ */
59029
+ parseFieldsDefinition() {
59030
+ return this.optionalMany(
59031
+ TokenKind.BRACE_L,
59032
+ this.parseFieldDefinition,
59033
+ TokenKind.BRACE_R
59034
+ );
59035
+ }
59036
+ /**
59037
+ * FieldDefinition :
59038
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
59039
+ */
59040
+ parseFieldDefinition() {
59041
+ const start = this._lexer.token;
59042
+ const description2 = this.parseDescription();
59043
+ const name = this.parseName();
59044
+ const args = this.parseArgumentDefs();
59045
+ this.expectToken(TokenKind.COLON);
59046
+ const type2 = this.parseTypeReference();
59047
+ const directives = this.parseConstDirectives();
59048
+ return this.node(start, {
59049
+ kind: Kind.FIELD_DEFINITION,
59050
+ description: description2,
59051
+ name,
59052
+ arguments: args,
59053
+ type: type2,
59054
+ directives
59055
+ });
59056
+ }
59057
+ /**
59058
+ * ArgumentsDefinition : ( InputValueDefinition+ )
59059
+ */
59060
+ parseArgumentDefs() {
59061
+ return this.optionalMany(
59062
+ TokenKind.PAREN_L,
59063
+ this.parseInputValueDef,
59064
+ TokenKind.PAREN_R
59065
+ );
59066
+ }
59067
+ /**
59068
+ * InputValueDefinition :
59069
+ * - Description? Name : Type DefaultValue? Directives[Const]?
59070
+ */
59071
+ parseInputValueDef() {
59072
+ const start = this._lexer.token;
59073
+ const description2 = this.parseDescription();
59074
+ const name = this.parseName();
59075
+ this.expectToken(TokenKind.COLON);
59076
+ const type2 = this.parseTypeReference();
59077
+ let defaultValue;
59078
+ if (this.expectOptionalToken(TokenKind.EQUALS)) {
59079
+ defaultValue = this.parseConstValueLiteral();
59080
+ }
59081
+ const directives = this.parseConstDirectives();
59082
+ return this.node(start, {
59083
+ kind: Kind.INPUT_VALUE_DEFINITION,
59084
+ description: description2,
59085
+ name,
59086
+ type: type2,
59087
+ defaultValue,
59088
+ directives
59089
+ });
59090
+ }
59091
+ /**
59092
+ * InterfaceTypeDefinition :
59093
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
59094
+ */
59095
+ parseInterfaceTypeDefinition() {
59096
+ const start = this._lexer.token;
59097
+ const description2 = this.parseDescription();
59098
+ this.expectKeyword("interface");
59099
+ const name = this.parseName();
59100
+ const interfaces = this.parseImplementsInterfaces();
59101
+ const directives = this.parseConstDirectives();
59102
+ const fields = this.parseFieldsDefinition();
59103
+ return this.node(start, {
59104
+ kind: Kind.INTERFACE_TYPE_DEFINITION,
59105
+ description: description2,
59106
+ name,
59107
+ interfaces,
59108
+ directives,
59109
+ fields
59110
+ });
59111
+ }
59112
+ /**
59113
+ * UnionTypeDefinition :
59114
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
59115
+ */
59116
+ parseUnionTypeDefinition() {
59117
+ const start = this._lexer.token;
59118
+ const description2 = this.parseDescription();
59119
+ this.expectKeyword("union");
59120
+ const name = this.parseName();
59121
+ const directives = this.parseConstDirectives();
59122
+ const types2 = this.parseUnionMemberTypes();
59123
+ return this.node(start, {
59124
+ kind: Kind.UNION_TYPE_DEFINITION,
59125
+ description: description2,
59126
+ name,
59127
+ directives,
59128
+ types: types2
59129
+ });
59130
+ }
59131
+ /**
59132
+ * UnionMemberTypes :
59133
+ * - = `|`? NamedType
59134
+ * - UnionMemberTypes | NamedType
59135
+ */
59136
+ parseUnionMemberTypes() {
59137
+ return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
59138
+ }
59139
+ /**
59140
+ * EnumTypeDefinition :
59141
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
59142
+ */
59143
+ parseEnumTypeDefinition() {
59144
+ const start = this._lexer.token;
59145
+ const description2 = this.parseDescription();
59146
+ this.expectKeyword("enum");
59147
+ const name = this.parseName();
59148
+ const directives = this.parseConstDirectives();
59149
+ const values = this.parseEnumValuesDefinition();
59150
+ return this.node(start, {
59151
+ kind: Kind.ENUM_TYPE_DEFINITION,
59152
+ description: description2,
59153
+ name,
59154
+ directives,
59155
+ values
59156
+ });
59157
+ }
59158
+ /**
59159
+ * ```
59160
+ * EnumValuesDefinition : { EnumValueDefinition+ }
59161
+ * ```
59162
+ */
59163
+ parseEnumValuesDefinition() {
59164
+ return this.optionalMany(
59165
+ TokenKind.BRACE_L,
59166
+ this.parseEnumValueDefinition,
59167
+ TokenKind.BRACE_R
59168
+ );
59169
+ }
59170
+ /**
59171
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
59172
+ */
59173
+ parseEnumValueDefinition() {
59174
+ const start = this._lexer.token;
59175
+ const description2 = this.parseDescription();
59176
+ const name = this.parseEnumValueName();
59177
+ const directives = this.parseConstDirectives();
59178
+ return this.node(start, {
59179
+ kind: Kind.ENUM_VALUE_DEFINITION,
59180
+ description: description2,
59181
+ name,
59182
+ directives
59183
+ });
59184
+ }
59185
+ /**
59186
+ * EnumValue : Name but not `true`, `false` or `null`
59187
+ */
59188
+ parseEnumValueName() {
59189
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") {
59190
+ throw syntaxError(
59191
+ this._lexer.source,
59192
+ this._lexer.token.start,
59193
+ `${getTokenDesc(
59194
+ this._lexer.token
59195
+ )} is reserved and cannot be used for an enum value.`
59196
+ );
59197
+ }
59198
+ return this.parseName();
59199
+ }
59200
+ /**
59201
+ * InputObjectTypeDefinition :
59202
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
59203
+ */
59204
+ parseInputObjectTypeDefinition() {
59205
+ const start = this._lexer.token;
59206
+ const description2 = this.parseDescription();
59207
+ this.expectKeyword("input");
59208
+ const name = this.parseName();
59209
+ const directives = this.parseConstDirectives();
59210
+ const fields = this.parseInputFieldsDefinition();
59211
+ return this.node(start, {
59212
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
59213
+ description: description2,
59214
+ name,
59215
+ directives,
59216
+ fields
59217
+ });
59218
+ }
59219
+ /**
59220
+ * ```
59221
+ * InputFieldsDefinition : { InputValueDefinition+ }
59222
+ * ```
59223
+ */
59224
+ parseInputFieldsDefinition() {
59225
+ return this.optionalMany(
59226
+ TokenKind.BRACE_L,
59227
+ this.parseInputValueDef,
59228
+ TokenKind.BRACE_R
59229
+ );
59230
+ }
59231
+ /**
59232
+ * TypeSystemExtension :
59233
+ * - SchemaExtension
59234
+ * - TypeExtension
59235
+ *
59236
+ * TypeExtension :
59237
+ * - ScalarTypeExtension
59238
+ * - ObjectTypeExtension
59239
+ * - InterfaceTypeExtension
59240
+ * - UnionTypeExtension
59241
+ * - EnumTypeExtension
59242
+ * - InputObjectTypeDefinition
59243
+ */
59244
+ parseTypeSystemExtension() {
59245
+ const keywordToken = this._lexer.lookahead();
59246
+ if (keywordToken.kind === TokenKind.NAME) {
59247
+ switch (keywordToken.value) {
59248
+ case "schema":
59249
+ return this.parseSchemaExtension();
59250
+ case "scalar":
59251
+ return this.parseScalarTypeExtension();
59252
+ case "type":
59253
+ return this.parseObjectTypeExtension();
59254
+ case "interface":
59255
+ return this.parseInterfaceTypeExtension();
59256
+ case "union":
59257
+ return this.parseUnionTypeExtension();
59258
+ case "enum":
59259
+ return this.parseEnumTypeExtension();
59260
+ case "input":
59261
+ return this.parseInputObjectTypeExtension();
59262
+ }
59263
+ }
59264
+ throw this.unexpected(keywordToken);
59265
+ }
59266
+ /**
59267
+ * ```
59268
+ * SchemaExtension :
59269
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
59270
+ * - extend schema Directives[Const]
59271
+ * ```
59272
+ */
59273
+ parseSchemaExtension() {
59274
+ const start = this._lexer.token;
59275
+ this.expectKeyword("extend");
59276
+ this.expectKeyword("schema");
59277
+ const directives = this.parseConstDirectives();
59278
+ const operationTypes = this.optionalMany(
59279
+ TokenKind.BRACE_L,
59280
+ this.parseOperationTypeDefinition,
59281
+ TokenKind.BRACE_R
59282
+ );
59283
+ if (directives.length === 0 && operationTypes.length === 0) {
59284
+ throw this.unexpected();
59285
+ }
59286
+ return this.node(start, {
59287
+ kind: Kind.SCHEMA_EXTENSION,
59288
+ directives,
59289
+ operationTypes
59290
+ });
59291
+ }
59292
+ /**
59293
+ * ScalarTypeExtension :
59294
+ * - extend scalar Name Directives[Const]
59295
+ */
59296
+ parseScalarTypeExtension() {
59297
+ const start = this._lexer.token;
59298
+ this.expectKeyword("extend");
59299
+ this.expectKeyword("scalar");
59300
+ const name = this.parseName();
59301
+ const directives = this.parseConstDirectives();
59302
+ if (directives.length === 0) {
59303
+ throw this.unexpected();
59304
+ }
59305
+ return this.node(start, {
59306
+ kind: Kind.SCALAR_TYPE_EXTENSION,
59307
+ name,
59308
+ directives
59309
+ });
59310
+ }
59311
+ /**
59312
+ * ObjectTypeExtension :
59313
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
59314
+ * - extend type Name ImplementsInterfaces? Directives[Const]
59315
+ * - extend type Name ImplementsInterfaces
59316
+ */
59317
+ parseObjectTypeExtension() {
59318
+ const start = this._lexer.token;
59319
+ this.expectKeyword("extend");
59320
+ this.expectKeyword("type");
59321
+ const name = this.parseName();
59322
+ const interfaces = this.parseImplementsInterfaces();
59323
+ const directives = this.parseConstDirectives();
59324
+ const fields = this.parseFieldsDefinition();
59325
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
59326
+ throw this.unexpected();
59327
+ }
59328
+ return this.node(start, {
59329
+ kind: Kind.OBJECT_TYPE_EXTENSION,
59330
+ name,
59331
+ interfaces,
59332
+ directives,
59333
+ fields
59334
+ });
59335
+ }
59336
+ /**
59337
+ * InterfaceTypeExtension :
59338
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
59339
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
59340
+ * - extend interface Name ImplementsInterfaces
59341
+ */
59342
+ parseInterfaceTypeExtension() {
59343
+ const start = this._lexer.token;
59344
+ this.expectKeyword("extend");
59345
+ this.expectKeyword("interface");
59346
+ const name = this.parseName();
59347
+ const interfaces = this.parseImplementsInterfaces();
59348
+ const directives = this.parseConstDirectives();
59349
+ const fields = this.parseFieldsDefinition();
59350
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
59351
+ throw this.unexpected();
59352
+ }
59353
+ return this.node(start, {
59354
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
59355
+ name,
59356
+ interfaces,
59357
+ directives,
59358
+ fields
59359
+ });
59360
+ }
59361
+ /**
59362
+ * UnionTypeExtension :
59363
+ * - extend union Name Directives[Const]? UnionMemberTypes
59364
+ * - extend union Name Directives[Const]
59365
+ */
59366
+ parseUnionTypeExtension() {
59367
+ const start = this._lexer.token;
59368
+ this.expectKeyword("extend");
59369
+ this.expectKeyword("union");
59370
+ const name = this.parseName();
59371
+ const directives = this.parseConstDirectives();
59372
+ const types2 = this.parseUnionMemberTypes();
59373
+ if (directives.length === 0 && types2.length === 0) {
59374
+ throw this.unexpected();
59375
+ }
59376
+ return this.node(start, {
59377
+ kind: Kind.UNION_TYPE_EXTENSION,
59378
+ name,
59379
+ directives,
59380
+ types: types2
59381
+ });
59382
+ }
59383
+ /**
59384
+ * EnumTypeExtension :
59385
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
59386
+ * - extend enum Name Directives[Const]
59387
+ */
59388
+ parseEnumTypeExtension() {
59389
+ const start = this._lexer.token;
59390
+ this.expectKeyword("extend");
59391
+ this.expectKeyword("enum");
59392
+ const name = this.parseName();
59393
+ const directives = this.parseConstDirectives();
59394
+ const values = this.parseEnumValuesDefinition();
59395
+ if (directives.length === 0 && values.length === 0) {
59396
+ throw this.unexpected();
59397
+ }
59398
+ return this.node(start, {
59399
+ kind: Kind.ENUM_TYPE_EXTENSION,
59400
+ name,
59401
+ directives,
59402
+ values
59403
+ });
59404
+ }
59405
+ /**
59406
+ * InputObjectTypeExtension :
59407
+ * - extend input Name Directives[Const]? InputFieldsDefinition
59408
+ * - extend input Name Directives[Const]
59409
+ */
59410
+ parseInputObjectTypeExtension() {
59411
+ const start = this._lexer.token;
59412
+ this.expectKeyword("extend");
59413
+ this.expectKeyword("input");
59414
+ const name = this.parseName();
59415
+ const directives = this.parseConstDirectives();
59416
+ const fields = this.parseInputFieldsDefinition();
59417
+ if (directives.length === 0 && fields.length === 0) {
59418
+ throw this.unexpected();
59419
+ }
59420
+ return this.node(start, {
59421
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
59422
+ name,
59423
+ directives,
59424
+ fields
59425
+ });
59426
+ }
59427
+ /**
59428
+ * ```
59429
+ * DirectiveDefinition :
59430
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
59431
+ * ```
59432
+ */
59433
+ parseDirectiveDefinition() {
59434
+ const start = this._lexer.token;
59435
+ const description2 = this.parseDescription();
59436
+ this.expectKeyword("directive");
59437
+ this.expectToken(TokenKind.AT);
59438
+ const name = this.parseName();
59439
+ const args = this.parseArgumentDefs();
59440
+ const repeatable = this.expectOptionalKeyword("repeatable");
59441
+ this.expectKeyword("on");
59442
+ const locations = this.parseDirectiveLocations();
59443
+ return this.node(start, {
59444
+ kind: Kind.DIRECTIVE_DEFINITION,
59445
+ description: description2,
59446
+ name,
59447
+ arguments: args,
59448
+ repeatable,
59449
+ locations
59450
+ });
59451
+ }
59452
+ /**
59453
+ * DirectiveLocations :
59454
+ * - `|`? DirectiveLocation
59455
+ * - DirectiveLocations | DirectiveLocation
59456
+ */
59457
+ parseDirectiveLocations() {
59458
+ return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
59459
+ }
59460
+ /*
59461
+ * DirectiveLocation :
59462
+ * - ExecutableDirectiveLocation
59463
+ * - TypeSystemDirectiveLocation
59464
+ *
59465
+ * ExecutableDirectiveLocation : one of
59466
+ * `QUERY`
59467
+ * `MUTATION`
59468
+ * `SUBSCRIPTION`
59469
+ * `FIELD`
59470
+ * `FRAGMENT_DEFINITION`
59471
+ * `FRAGMENT_SPREAD`
59472
+ * `INLINE_FRAGMENT`
59473
+ *
59474
+ * TypeSystemDirectiveLocation : one of
59475
+ * `SCHEMA`
59476
+ * `SCALAR`
59477
+ * `OBJECT`
59478
+ * `FIELD_DEFINITION`
59479
+ * `ARGUMENT_DEFINITION`
59480
+ * `INTERFACE`
59481
+ * `UNION`
59482
+ * `ENUM`
59483
+ * `ENUM_VALUE`
59484
+ * `INPUT_OBJECT`
59485
+ * `INPUT_FIELD_DEFINITION`
59486
+ */
59487
+ parseDirectiveLocation() {
59488
+ const start = this._lexer.token;
59489
+ const name = this.parseName();
59490
+ if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
59491
+ return name;
59492
+ }
59493
+ throw this.unexpected(start);
59494
+ }
59495
+ // Core parsing utility functions
59496
+ /**
59497
+ * Returns a node that, if configured to do so, sets a "loc" field as a
59498
+ * location object, used to identify the place in the source that created a
59499
+ * given parsed object.
59500
+ */
59501
+ node(startToken, node2) {
59502
+ if (this._options.noLocation !== true) {
59503
+ node2.loc = new Location(
59504
+ startToken,
59505
+ this._lexer.lastToken,
59506
+ this._lexer.source
59507
+ );
59508
+ }
59509
+ return node2;
59510
+ }
59511
+ /**
59512
+ * Determines if the next token is of a given kind
59513
+ */
59514
+ peek(kind) {
59515
+ return this._lexer.token.kind === kind;
59516
+ }
59517
+ /**
59518
+ * If the next token is of the given kind, return that token after advancing the lexer.
59519
+ * Otherwise, do not change the parser state and throw an error.
59520
+ */
59521
+ expectToken(kind) {
59522
+ const token = this._lexer.token;
59523
+ if (token.kind === kind) {
59524
+ this.advanceLexer();
59525
+ return token;
59526
+ }
59527
+ throw syntaxError(
59528
+ this._lexer.source,
59529
+ token.start,
59530
+ `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
59531
+ );
59532
+ }
59533
+ /**
59534
+ * If the next token is of the given kind, return "true" after advancing the lexer.
59535
+ * Otherwise, do not change the parser state and return "false".
59536
+ */
59537
+ expectOptionalToken(kind) {
59538
+ const token = this._lexer.token;
59539
+ if (token.kind === kind) {
59540
+ this.advanceLexer();
59541
+ return true;
59542
+ }
59543
+ return false;
59544
+ }
59545
+ /**
59546
+ * If the next token is a given keyword, advance the lexer.
59547
+ * Otherwise, do not change the parser state and throw an error.
59548
+ */
59549
+ expectKeyword(value) {
59550
+ const token = this._lexer.token;
59551
+ if (token.kind === TokenKind.NAME && token.value === value) {
59552
+ this.advanceLexer();
59553
+ } else {
59554
+ throw syntaxError(
59555
+ this._lexer.source,
59556
+ token.start,
59557
+ `Expected "${value}", found ${getTokenDesc(token)}.`
59558
+ );
59559
+ }
59560
+ }
59561
+ /**
59562
+ * If the next token is a given keyword, return "true" after advancing the lexer.
59563
+ * Otherwise, do not change the parser state and return "false".
59564
+ */
59565
+ expectOptionalKeyword(value) {
59566
+ const token = this._lexer.token;
59567
+ if (token.kind === TokenKind.NAME && token.value === value) {
59568
+ this.advanceLexer();
59569
+ return true;
59570
+ }
59571
+ return false;
59572
+ }
59573
+ /**
59574
+ * Helper function for creating an error when an unexpected lexed token is encountered.
59575
+ */
59576
+ unexpected(atToken) {
59577
+ const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
59578
+ return syntaxError(
59579
+ this._lexer.source,
59580
+ token.start,
59581
+ `Unexpected ${getTokenDesc(token)}.`
59582
+ );
59583
+ }
59584
+ /**
59585
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
59586
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
59587
+ * Advances the parser to the next lex token after the closing token.
59588
+ */
59589
+ any(openKind, parseFn, closeKind) {
59590
+ this.expectToken(openKind);
59591
+ const nodes = [];
59592
+ while (!this.expectOptionalToken(closeKind)) {
59593
+ nodes.push(parseFn.call(this));
59594
+ }
59595
+ return nodes;
59596
+ }
59597
+ /**
59598
+ * Returns a list of parse nodes, determined by the parseFn.
59599
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
59600
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
59601
+ * Advances the parser to the next lex token after the closing token.
59602
+ */
59603
+ optionalMany(openKind, parseFn, closeKind) {
59604
+ if (this.expectOptionalToken(openKind)) {
59605
+ const nodes = [];
59606
+ do {
59607
+ nodes.push(parseFn.call(this));
59608
+ } while (!this.expectOptionalToken(closeKind));
59609
+ return nodes;
59610
+ }
59611
+ return [];
59612
+ }
59613
+ /**
59614
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
59615
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
59616
+ * Advances the parser to the next lex token after the closing token.
59617
+ */
59618
+ many(openKind, parseFn, closeKind) {
59619
+ this.expectToken(openKind);
59620
+ const nodes = [];
59621
+ do {
59622
+ nodes.push(parseFn.call(this));
59623
+ } while (!this.expectOptionalToken(closeKind));
59624
+ return nodes;
59625
+ }
59626
+ /**
59627
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
59628
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
59629
+ * Advances the parser to the next lex token after last item in the list.
59630
+ */
59631
+ delimitedMany(delimiterKind, parseFn) {
59632
+ this.expectOptionalToken(delimiterKind);
59633
+ const nodes = [];
59634
+ do {
59635
+ nodes.push(parseFn.call(this));
59636
+ } while (this.expectOptionalToken(delimiterKind));
59637
+ return nodes;
59638
+ }
59639
+ advanceLexer() {
59640
+ const { maxTokens } = this._options;
59641
+ const token = this._lexer.advance();
59642
+ if (token.kind !== TokenKind.EOF) {
59643
+ ++this._tokenCounter;
59644
+ if (maxTokens !== void 0 && this._tokenCounter > maxTokens) {
59645
+ throw syntaxError(
59646
+ this._lexer.source,
59647
+ token.start,
59648
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`
59649
+ );
59650
+ }
59651
+ }
59652
+ }
59653
+ }
59654
+ function getTokenDesc(token) {
59655
+ const value = token.value;
59656
+ return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
59657
+ }
59658
+ function getTokenKindDesc(kind) {
59659
+ return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
59660
+ }
59661
+ function printString(str) {
59662
+ return `"${str.replace(escapedRegExp, escapedReplacer)}"`;
59663
+ }
59664
+ const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g;
59665
+ function escapedReplacer(str) {
59666
+ return escapeSequences[str.charCodeAt(0)];
59667
+ }
59668
+ const escapeSequences = [
59669
+ "\\u0000",
59670
+ "\\u0001",
59671
+ "\\u0002",
59672
+ "\\u0003",
59673
+ "\\u0004",
59674
+ "\\u0005",
59675
+ "\\u0006",
59676
+ "\\u0007",
59677
+ "\\b",
59678
+ "\\t",
59679
+ "\\n",
59680
+ "\\u000B",
59681
+ "\\f",
59682
+ "\\r",
59683
+ "\\u000E",
59684
+ "\\u000F",
59685
+ "\\u0010",
59686
+ "\\u0011",
59687
+ "\\u0012",
59688
+ "\\u0013",
59689
+ "\\u0014",
59690
+ "\\u0015",
59691
+ "\\u0016",
59692
+ "\\u0017",
59693
+ "\\u0018",
59694
+ "\\u0019",
59695
+ "\\u001A",
59696
+ "\\u001B",
59697
+ "\\u001C",
59698
+ "\\u001D",
59699
+ "\\u001E",
59700
+ "\\u001F",
59701
+ "",
59702
+ "",
59703
+ '\\"',
59704
+ "",
59705
+ "",
59706
+ "",
59707
+ "",
59708
+ "",
59709
+ "",
59710
+ "",
59711
+ "",
59712
+ "",
59713
+ "",
59714
+ "",
59715
+ "",
59716
+ "",
59717
+ // 2F
59718
+ "",
59719
+ "",
59720
+ "",
59721
+ "",
59722
+ "",
59723
+ "",
59724
+ "",
59725
+ "",
59726
+ "",
59727
+ "",
59728
+ "",
59729
+ "",
59730
+ "",
59731
+ "",
59732
+ "",
59733
+ "",
59734
+ // 3F
59735
+ "",
59736
+ "",
59737
+ "",
59738
+ "",
59739
+ "",
59740
+ "",
59741
+ "",
59742
+ "",
59743
+ "",
59744
+ "",
59745
+ "",
59746
+ "",
59747
+ "",
59748
+ "",
59749
+ "",
59750
+ "",
59751
+ // 4F
59752
+ "",
59753
+ "",
59754
+ "",
59755
+ "",
59756
+ "",
59757
+ "",
59758
+ "",
59759
+ "",
59760
+ "",
59761
+ "",
59762
+ "",
59763
+ "",
59764
+ "\\\\",
59765
+ "",
59766
+ "",
59767
+ "",
59768
+ // 5F
59769
+ "",
59770
+ "",
59771
+ "",
59772
+ "",
59773
+ "",
59774
+ "",
59775
+ "",
59776
+ "",
59777
+ "",
59778
+ "",
59779
+ "",
59780
+ "",
59781
+ "",
59782
+ "",
59783
+ "",
59784
+ "",
59785
+ // 6F
59786
+ "",
59787
+ "",
59788
+ "",
59789
+ "",
59790
+ "",
59791
+ "",
59792
+ "",
59793
+ "",
59794
+ "",
59795
+ "",
59796
+ "",
59797
+ "",
59798
+ "",
59799
+ "",
59800
+ "",
59801
+ "\\u007F",
59802
+ "\\u0080",
59803
+ "\\u0081",
59804
+ "\\u0082",
59805
+ "\\u0083",
59806
+ "\\u0084",
59807
+ "\\u0085",
59808
+ "\\u0086",
59809
+ "\\u0087",
59810
+ "\\u0088",
59811
+ "\\u0089",
59812
+ "\\u008A",
59813
+ "\\u008B",
59814
+ "\\u008C",
59815
+ "\\u008D",
59816
+ "\\u008E",
59817
+ "\\u008F",
59818
+ "\\u0090",
59819
+ "\\u0091",
59820
+ "\\u0092",
59821
+ "\\u0093",
59822
+ "\\u0094",
59823
+ "\\u0095",
59824
+ "\\u0096",
59825
+ "\\u0097",
59826
+ "\\u0098",
59827
+ "\\u0099",
59828
+ "\\u009A",
59829
+ "\\u009B",
59830
+ "\\u009C",
59831
+ "\\u009D",
59832
+ "\\u009E",
59833
+ "\\u009F"
59834
+ ];
59835
+ const BREAK = Object.freeze({});
59836
+ function visit(root2, visitor, visitorKeys = QueryDocumentKeys) {
59837
+ const enterLeaveMap = /* @__PURE__ */ new Map();
59838
+ for (const kind of Object.values(Kind)) {
59839
+ enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
59840
+ }
59841
+ let stack = void 0;
59842
+ let inArray = Array.isArray(root2);
59843
+ let keys = [root2];
59844
+ let index2 = -1;
59845
+ let edits = [];
59846
+ let node2 = root2;
59847
+ let key = void 0;
59848
+ let parent2 = void 0;
59849
+ const path2 = [];
59850
+ const ancestors = [];
59851
+ do {
59852
+ index2++;
59853
+ const isLeaving = index2 === keys.length;
59854
+ const isEdited = isLeaving && edits.length !== 0;
59855
+ if (isLeaving) {
59856
+ key = ancestors.length === 0 ? void 0 : path2[path2.length - 1];
59857
+ node2 = parent2;
59858
+ parent2 = ancestors.pop();
59859
+ if (isEdited) {
59860
+ if (inArray) {
59861
+ node2 = node2.slice();
59862
+ let editOffset = 0;
59863
+ for (const [editKey, editValue] of edits) {
59864
+ const arrayKey = editKey - editOffset;
59865
+ if (editValue === null) {
59866
+ node2.splice(arrayKey, 1);
59867
+ editOffset++;
59868
+ } else {
59869
+ node2[arrayKey] = editValue;
59870
+ }
59871
+ }
59872
+ } else {
59873
+ node2 = Object.defineProperties(
59874
+ {},
59875
+ Object.getOwnPropertyDescriptors(node2)
59876
+ );
59877
+ for (const [editKey, editValue] of edits) {
59878
+ node2[editKey] = editValue;
59879
+ }
59880
+ }
59881
+ }
59882
+ index2 = stack.index;
59883
+ keys = stack.keys;
59884
+ edits = stack.edits;
59885
+ inArray = stack.inArray;
59886
+ stack = stack.prev;
59887
+ } else if (parent2) {
59888
+ key = inArray ? index2 : keys[index2];
59889
+ node2 = parent2[key];
59890
+ if (node2 === null || node2 === void 0) {
59891
+ continue;
59892
+ }
59893
+ path2.push(key);
59894
+ }
59895
+ let result2;
59896
+ if (!Array.isArray(node2)) {
59897
+ var _enterLeaveMap$get, _enterLeaveMap$get2;
59898
+ isNode(node2) || devAssert(false, `Invalid AST Node: ${inspect(node2)}.`);
59899
+ const visitFn = isLeaving ? (_enterLeaveMap$get = enterLeaveMap.get(node2.kind)) === null || _enterLeaveMap$get === void 0 ? void 0 : _enterLeaveMap$get.leave : (_enterLeaveMap$get2 = enterLeaveMap.get(node2.kind)) === null || _enterLeaveMap$get2 === void 0 ? void 0 : _enterLeaveMap$get2.enter;
59900
+ result2 = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node2, key, parent2, path2, ancestors);
59901
+ if (result2 === BREAK) {
59902
+ break;
59903
+ }
59904
+ if (result2 === false) {
59905
+ if (!isLeaving) {
59906
+ path2.pop();
59907
+ continue;
59908
+ }
59909
+ } else if (result2 !== void 0) {
59910
+ edits.push([key, result2]);
59911
+ if (!isLeaving) {
59912
+ if (isNode(result2)) {
59913
+ node2 = result2;
59914
+ } else {
59915
+ path2.pop();
59916
+ continue;
59917
+ }
59918
+ }
59919
+ }
59920
+ }
59921
+ if (result2 === void 0 && isEdited) {
59922
+ edits.push([key, node2]);
59923
+ }
59924
+ if (isLeaving) {
59925
+ path2.pop();
59926
+ } else {
59927
+ var _node$kind;
59928
+ stack = {
59929
+ inArray,
59930
+ index: index2,
59931
+ keys,
59932
+ edits,
59933
+ prev: stack
59934
+ };
59935
+ inArray = Array.isArray(node2);
59936
+ keys = inArray ? node2 : (_node$kind = visitorKeys[node2.kind]) !== null && _node$kind !== void 0 ? _node$kind : [];
59937
+ index2 = -1;
59938
+ edits = [];
59939
+ if (parent2) {
59940
+ ancestors.push(parent2);
59941
+ }
59942
+ parent2 = node2;
59943
+ }
59944
+ } while (stack !== void 0);
59945
+ if (edits.length !== 0) {
59946
+ return edits[edits.length - 1][1];
59947
+ }
59948
+ return root2;
59949
+ }
59950
+ function getEnterLeaveForKind(visitor, kind) {
59951
+ const kindVisitor = visitor[kind];
59952
+ if (typeof kindVisitor === "object") {
59953
+ return kindVisitor;
59954
+ } else if (typeof kindVisitor === "function") {
59955
+ return {
59956
+ enter: kindVisitor,
59957
+ leave: void 0
59958
+ };
59959
+ }
59960
+ return {
59961
+ enter: visitor.enter,
59962
+ leave: visitor.leave
59963
+ };
59964
+ }
59965
+ function print(ast2) {
59966
+ return visit(ast2, printDocASTReducer);
59967
+ }
59968
+ const MAX_LINE_LENGTH = 80;
59969
+ const printDocASTReducer = {
59970
+ Name: {
59971
+ leave: (node2) => node2.value
59972
+ },
59973
+ Variable: {
59974
+ leave: (node2) => "$" + node2.name
59975
+ },
59976
+ // Document
59977
+ Document: {
59978
+ leave: (node2) => join(node2.definitions, "\n\n")
59979
+ },
59980
+ OperationDefinition: {
59981
+ leave(node2) {
59982
+ const varDefs = wrap("(", join(node2.variableDefinitions, ", "), ")");
59983
+ const prefix = join(
59984
+ [
59985
+ node2.operation,
59986
+ join([node2.name, varDefs]),
59987
+ join(node2.directives, " ")
59988
+ ],
59989
+ " "
59990
+ );
59991
+ return (prefix === "query" ? "" : prefix + " ") + node2.selectionSet;
59992
+ }
59993
+ },
59994
+ VariableDefinition: {
59995
+ leave: ({ variable, type: type2, defaultValue, directives }) => variable + ": " + type2 + wrap(" = ", defaultValue) + wrap(" ", join(directives, " "))
59996
+ },
59997
+ SelectionSet: {
59998
+ leave: ({ selections }) => block(selections)
59999
+ },
60000
+ Field: {
60001
+ leave({ alias, name, arguments: args, directives, selectionSet }) {
60002
+ const prefix = wrap("", alias, ": ") + name;
60003
+ let argsLine = prefix + wrap("(", join(args, ", "), ")");
60004
+ if (argsLine.length > MAX_LINE_LENGTH) {
60005
+ argsLine = prefix + wrap("(\n", indent(join(args, "\n")), "\n)");
60006
+ }
60007
+ return join([argsLine, join(directives, " "), selectionSet], " ");
60008
+ }
60009
+ },
60010
+ Argument: {
60011
+ leave: ({ name, value }) => name + ": " + value
60012
+ },
60013
+ // Fragments
60014
+ FragmentSpread: {
60015
+ leave: ({ name, directives }) => "..." + name + wrap(" ", join(directives, " "))
60016
+ },
60017
+ InlineFragment: {
60018
+ leave: ({ typeCondition, directives, selectionSet }) => join(
60019
+ [
60020
+ "...",
60021
+ wrap("on ", typeCondition),
60022
+ join(directives, " "),
60023
+ selectionSet
60024
+ ],
60025
+ " "
60026
+ )
60027
+ },
60028
+ FragmentDefinition: {
60029
+ leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet }) => (
60030
+ // or removed in the future.
60031
+ `fragment ${name}${wrap("(", join(variableDefinitions, ", "), ")")} on ${typeCondition} ${wrap("", join(directives, " "), " ")}` + selectionSet
60032
+ )
60033
+ },
60034
+ // Value
60035
+ IntValue: {
60036
+ leave: ({ value }) => value
60037
+ },
60038
+ FloatValue: {
60039
+ leave: ({ value }) => value
60040
+ },
60041
+ StringValue: {
60042
+ leave: ({ value, block: isBlockString }) => isBlockString ? printBlockString(value) : printString(value)
60043
+ },
60044
+ BooleanValue: {
60045
+ leave: ({ value }) => value ? "true" : "false"
60046
+ },
60047
+ NullValue: {
60048
+ leave: () => "null"
60049
+ },
60050
+ EnumValue: {
60051
+ leave: ({ value }) => value
60052
+ },
60053
+ ListValue: {
60054
+ leave: ({ values }) => "[" + join(values, ", ") + "]"
60055
+ },
60056
+ ObjectValue: {
60057
+ leave: ({ fields }) => "{" + join(fields, ", ") + "}"
60058
+ },
60059
+ ObjectField: {
60060
+ leave: ({ name, value }) => name + ": " + value
60061
+ },
60062
+ // Directive
60063
+ Directive: {
60064
+ leave: ({ name, arguments: args }) => "@" + name + wrap("(", join(args, ", "), ")")
60065
+ },
60066
+ // Type
60067
+ NamedType: {
60068
+ leave: ({ name }) => name
60069
+ },
60070
+ ListType: {
60071
+ leave: ({ type: type2 }) => "[" + type2 + "]"
60072
+ },
60073
+ NonNullType: {
60074
+ leave: ({ type: type2 }) => type2 + "!"
60075
+ },
60076
+ // Type System Definitions
60077
+ SchemaDefinition: {
60078
+ leave: ({ description: description2, directives, operationTypes }) => wrap("", description2, "\n") + join(["schema", join(directives, " "), block(operationTypes)], " ")
60079
+ },
60080
+ OperationTypeDefinition: {
60081
+ leave: ({ operation, type: type2 }) => operation + ": " + type2
60082
+ },
60083
+ ScalarTypeDefinition: {
60084
+ leave: ({ description: description2, name, directives }) => wrap("", description2, "\n") + join(["scalar", name, join(directives, " ")], " ")
60085
+ },
60086
+ ObjectTypeDefinition: {
60087
+ leave: ({ description: description2, name, interfaces, directives, fields }) => wrap("", description2, "\n") + join(
60088
+ [
60089
+ "type",
60090
+ name,
60091
+ wrap("implements ", join(interfaces, " & ")),
60092
+ join(directives, " "),
60093
+ block(fields)
60094
+ ],
60095
+ " "
60096
+ )
60097
+ },
60098
+ FieldDefinition: {
60099
+ leave: ({ description: description2, name, arguments: args, type: type2, directives }) => wrap("", description2, "\n") + name + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + ": " + type2 + wrap(" ", join(directives, " "))
60100
+ },
60101
+ InputValueDefinition: {
60102
+ leave: ({ description: description2, name, type: type2, defaultValue, directives }) => wrap("", description2, "\n") + join(
60103
+ [name + ": " + type2, wrap("= ", defaultValue), join(directives, " ")],
60104
+ " "
60105
+ )
60106
+ },
60107
+ InterfaceTypeDefinition: {
60108
+ leave: ({ description: description2, name, interfaces, directives, fields }) => wrap("", description2, "\n") + join(
60109
+ [
60110
+ "interface",
60111
+ name,
60112
+ wrap("implements ", join(interfaces, " & ")),
60113
+ join(directives, " "),
60114
+ block(fields)
60115
+ ],
60116
+ " "
60117
+ )
60118
+ },
60119
+ UnionTypeDefinition: {
60120
+ leave: ({ description: description2, name, directives, types: types2 }) => wrap("", description2, "\n") + join(
60121
+ ["union", name, join(directives, " "), wrap("= ", join(types2, " | "))],
60122
+ " "
60123
+ )
60124
+ },
60125
+ EnumTypeDefinition: {
60126
+ leave: ({ description: description2, name, directives, values }) => wrap("", description2, "\n") + join(["enum", name, join(directives, " "), block(values)], " ")
60127
+ },
60128
+ EnumValueDefinition: {
60129
+ leave: ({ description: description2, name, directives }) => wrap("", description2, "\n") + join([name, join(directives, " ")], " ")
60130
+ },
60131
+ InputObjectTypeDefinition: {
60132
+ leave: ({ description: description2, name, directives, fields }) => wrap("", description2, "\n") + join(["input", name, join(directives, " "), block(fields)], " ")
60133
+ },
60134
+ DirectiveDefinition: {
60135
+ leave: ({ description: description2, name, arguments: args, repeatable, locations }) => wrap("", description2, "\n") + "directive @" + name + (hasMultilineItems(args) ? wrap("(\n", indent(join(args, "\n")), "\n)") : wrap("(", join(args, ", "), ")")) + (repeatable ? " repeatable" : "") + " on " + join(locations, " | ")
60136
+ },
60137
+ SchemaExtension: {
60138
+ leave: ({ directives, operationTypes }) => join(
60139
+ ["extend schema", join(directives, " "), block(operationTypes)],
60140
+ " "
60141
+ )
60142
+ },
60143
+ ScalarTypeExtension: {
60144
+ leave: ({ name, directives }) => join(["extend scalar", name, join(directives, " ")], " ")
60145
+ },
60146
+ ObjectTypeExtension: {
60147
+ leave: ({ name, interfaces, directives, fields }) => join(
60148
+ [
60149
+ "extend type",
60150
+ name,
60151
+ wrap("implements ", join(interfaces, " & ")),
60152
+ join(directives, " "),
60153
+ block(fields)
60154
+ ],
60155
+ " "
60156
+ )
60157
+ },
60158
+ InterfaceTypeExtension: {
60159
+ leave: ({ name, interfaces, directives, fields }) => join(
60160
+ [
60161
+ "extend interface",
60162
+ name,
60163
+ wrap("implements ", join(interfaces, " & ")),
60164
+ join(directives, " "),
60165
+ block(fields)
60166
+ ],
60167
+ " "
60168
+ )
60169
+ },
60170
+ UnionTypeExtension: {
60171
+ leave: ({ name, directives, types: types2 }) => join(
60172
+ [
60173
+ "extend union",
60174
+ name,
60175
+ join(directives, " "),
60176
+ wrap("= ", join(types2, " | "))
60177
+ ],
60178
+ " "
60179
+ )
60180
+ },
60181
+ EnumTypeExtension: {
60182
+ leave: ({ name, directives, values }) => join(["extend enum", name, join(directives, " "), block(values)], " ")
60183
+ },
60184
+ InputObjectTypeExtension: {
60185
+ leave: ({ name, directives, fields }) => join(["extend input", name, join(directives, " "), block(fields)], " ")
60186
+ }
60187
+ };
60188
+ function join(maybeArray, separator = "") {
60189
+ var _maybeArray$filter$jo;
60190
+ return (_maybeArray$filter$jo = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.filter((x) => x).join(separator)) !== null && _maybeArray$filter$jo !== void 0 ? _maybeArray$filter$jo : "";
60191
+ }
60192
+ function block(array) {
60193
+ return wrap("{\n", indent(join(array, "\n")), "\n}");
60194
+ }
60195
+ function wrap(start, maybeString, end2 = "") {
60196
+ return maybeString != null && maybeString !== "" ? start + maybeString + end2 : "";
60197
+ }
60198
+ function indent(str) {
60199
+ return wrap(" ", str.replace(/\n/g, "\n "));
60200
+ }
60201
+ function hasMultilineItems(maybeArray) {
60202
+ var _maybeArray$some;
60203
+ return (_maybeArray$some = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.some((str) => str.includes("\n"))) !== null && _maybeArray$some !== void 0 ? _maybeArray$some : false;
60204
+ }
60205
+ const ACCEPT_HEADER = `Accept`;
60206
+ const CONTENT_TYPE_HEADER = `Content-Type`;
60207
+ const CONTENT_TYPE_JSON = `application/json`;
60208
+ const CONTENT_TYPE_GQL = `application/graphql-response+json`;
60209
+ const cleanQuery = (str) => str.replace(/([\s,]|#[^\n\r]+)+/g, ` `).trim();
60210
+ const isGraphQLContentType = (contentType) => {
60211
+ const contentTypeLower = contentType.toLowerCase();
60212
+ return contentTypeLower.includes(CONTENT_TYPE_GQL) || contentTypeLower.includes(CONTENT_TYPE_JSON);
60213
+ };
60214
+ const parseGraphQLExecutionResult = (result2) => {
60215
+ try {
60216
+ if (Array.isArray(result2)) {
60217
+ return {
60218
+ _tag: `Batch`,
60219
+ executionResults: result2.map(parseExecutionResult)
60220
+ };
60221
+ } else if (isPlainObject(result2)) {
60222
+ return {
60223
+ _tag: `Single`,
60224
+ executionResult: parseExecutionResult(result2)
60225
+ };
60226
+ } else {
60227
+ throw new Error(`Invalid execution result: result is not object or array.
60228
+ Got:
60229
+ ${String(result2)}`);
60230
+ }
60231
+ } catch (e) {
60232
+ return e;
60233
+ }
60234
+ };
60235
+ const parseExecutionResult = (result2) => {
60236
+ if (typeof result2 !== `object` || result2 === null) {
60237
+ throw new Error(`Invalid execution result: result is not object`);
60238
+ }
60239
+ let errors2 = void 0;
60240
+ let data = void 0;
60241
+ let extensions = void 0;
60242
+ if (`errors` in result2) {
60243
+ if (!isPlainObject(result2.errors) && !Array.isArray(result2.errors)) {
60244
+ throw new Error(`Invalid execution result: errors is not plain object OR array`);
60245
+ }
60246
+ errors2 = result2.errors;
60247
+ }
60248
+ if (`data` in result2) {
60249
+ if (!isPlainObject(result2.data) && result2.data !== null) {
60250
+ throw new Error(`Invalid execution result: data is not plain object`);
60251
+ }
60252
+ data = result2.data;
60253
+ }
60254
+ if (`extensions` in result2) {
60255
+ if (!isPlainObject(result2.extensions))
60256
+ throw new Error(`Invalid execution result: extensions is not plain object`);
60257
+ extensions = result2.extensions;
60258
+ }
60259
+ return {
60260
+ data,
60261
+ errors: errors2,
60262
+ extensions
60263
+ };
60264
+ };
60265
+ const isRequestResultHaveErrors = (result2) => result2._tag === `Batch` ? result2.executionResults.some(isExecutionResultHaveErrors) : isExecutionResultHaveErrors(result2.executionResult);
60266
+ const isExecutionResultHaveErrors = (result2) => Array.isArray(result2.errors) ? result2.errors.length > 0 : Boolean(result2.errors);
60267
+ const isOperationDefinitionNode = (definition) => {
60268
+ return typeof definition === `object` && definition !== null && `kind` in definition && definition.kind === Kind.OPERATION_DEFINITION;
60269
+ };
60270
+ const extractOperationName = (document) => {
60271
+ let operationName = void 0;
60272
+ const defs = document.definitions.filter(isOperationDefinitionNode);
60273
+ if (defs.length === 1) {
60274
+ operationName = defs[0].name?.value;
60275
+ }
60276
+ return operationName;
60277
+ };
60278
+ const extractIsMutation = (document) => {
60279
+ let isMutation = false;
60280
+ const defs = document.definitions.filter(isOperationDefinitionNode);
60281
+ if (defs.length === 1) {
60282
+ isMutation = defs[0].operation === OperationTypeNode.MUTATION;
60283
+ }
60284
+ return isMutation;
60285
+ };
60286
+ const analyzeDocument = (document, excludeOperationName) => {
60287
+ const expression = typeof document === `string` ? document : print(document);
60288
+ let isMutation = false;
60289
+ let operationName = void 0;
60290
+ if (excludeOperationName) {
60291
+ return { expression, isMutation, operationName };
60292
+ }
60293
+ const docNode = tryCatch(() => typeof document === `string` ? parse(document) : document);
60294
+ if (docNode instanceof Error) {
60295
+ return { expression, isMutation, operationName };
60296
+ }
60297
+ operationName = extractOperationName(docNode);
60298
+ isMutation = extractIsMutation(docNode);
60299
+ return { expression, operationName, isMutation };
60300
+ };
60301
+ const defaultJsonSerializer = JSON;
60302
+ const runRequest = async (input) => {
60303
+ const config2 = {
60304
+ ...input,
60305
+ method: input.request._tag === `Single` ? input.request.document.isMutation ? `POST` : uppercase(input.method ?? `post`) : input.request.hasMutations ? `POST` : uppercase(input.method ?? `post`),
60306
+ fetchOptions: {
60307
+ ...input.fetchOptions,
60308
+ errorPolicy: input.fetchOptions.errorPolicy ?? `none`
60309
+ }
60310
+ };
60311
+ const fetcher = createFetcher(config2.method);
60312
+ const fetchResponse = await fetcher(config2);
60313
+ if (!fetchResponse.ok) {
60314
+ return new ClientError({ status: fetchResponse.status, headers: fetchResponse.headers }, {
60315
+ query: input.request._tag === `Single` ? input.request.document.expression : input.request.query,
60316
+ variables: input.request.variables
60317
+ });
60318
+ }
60319
+ const result2 = await parseResultFromResponse(fetchResponse, input.fetchOptions.jsonSerializer ?? defaultJsonSerializer);
60320
+ if (result2 instanceof Error)
60321
+ throw result2;
60322
+ const clientResponseBase = {
60323
+ status: fetchResponse.status,
60324
+ headers: fetchResponse.headers
60325
+ };
60326
+ if (isRequestResultHaveErrors(result2) && config2.fetchOptions.errorPolicy === `none`) {
60327
+ const clientResponse = result2._tag === `Batch` ? { ...result2.executionResults, ...clientResponseBase } : {
60328
+ ...result2.executionResult,
60329
+ ...clientResponseBase
60330
+ };
60331
+ return new ClientError(clientResponse, {
60332
+ query: input.request._tag === `Single` ? input.request.document.expression : input.request.query,
60333
+ variables: input.request.variables
60334
+ });
60335
+ }
60336
+ switch (result2._tag) {
60337
+ case `Single`:
60338
+ return {
60339
+ ...clientResponseBase,
60340
+ ...executionResultClientResponseFields(config2)(result2.executionResult)
60341
+ };
60342
+ case `Batch`:
60343
+ return {
60344
+ ...clientResponseBase,
60345
+ data: result2.executionResults.map(executionResultClientResponseFields(config2))
60346
+ };
60347
+ default:
60348
+ casesExhausted(result2);
60349
+ }
60350
+ };
60351
+ const executionResultClientResponseFields = ($params) => (executionResult) => {
60352
+ return {
60353
+ extensions: executionResult.extensions,
60354
+ data: executionResult.data,
60355
+ errors: $params.fetchOptions.errorPolicy === `all` ? executionResult.errors : void 0
60356
+ };
60357
+ };
60358
+ const parseResultFromResponse = async (response, jsonSerializer) => {
60359
+ const contentType = response.headers.get(CONTENT_TYPE_HEADER);
60360
+ const text = await response.text();
60361
+ if (contentType && isGraphQLContentType(contentType)) {
60362
+ return parseGraphQLExecutionResult(jsonSerializer.parse(text));
60363
+ } else {
60364
+ return parseGraphQLExecutionResult(text);
60365
+ }
60366
+ };
60367
+ const createFetcher = (method) => async (params) => {
60368
+ const headers2 = new Headers(params.headers);
60369
+ let searchParams = null;
60370
+ let body = void 0;
60371
+ if (!headers2.has(ACCEPT_HEADER)) {
60372
+ headers2.set(ACCEPT_HEADER, [CONTENT_TYPE_GQL, CONTENT_TYPE_JSON].join(`, `));
60373
+ }
60374
+ if (method === `POST`) {
60375
+ const $jsonSerializer = params.fetchOptions.jsonSerializer ?? defaultJsonSerializer;
60376
+ body = $jsonSerializer.stringify(buildBody(params));
60377
+ if (typeof body === `string` && !headers2.has(CONTENT_TYPE_HEADER)) {
60378
+ headers2.set(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON);
60379
+ }
60380
+ } else {
60381
+ searchParams = buildQueryParams(params);
60382
+ }
60383
+ const init = { method, headers: headers2, body, ...params.fetchOptions };
60384
+ let url = new URL(params.url);
60385
+ let initResolved = init;
60386
+ if (params.middleware) {
60387
+ const result2 = await Promise.resolve(params.middleware({
60388
+ ...init,
60389
+ url: params.url,
60390
+ operationName: params.request._tag === `Single` ? params.request.document.operationName : void 0,
60391
+ variables: params.request.variables
60392
+ }));
60393
+ const { url: urlNew, ...initNew } = result2;
60394
+ url = new URL(urlNew);
60395
+ initResolved = initNew;
60396
+ }
60397
+ if (searchParams) {
60398
+ searchParams.forEach((value, name) => {
60399
+ url.searchParams.append(name, value);
60400
+ });
60401
+ }
60402
+ const $fetch = params.fetch ?? fetch;
60403
+ return await $fetch(url, initResolved);
60404
+ };
60405
+ const buildBody = (params) => {
60406
+ switch (params.request._tag) {
60407
+ case `Single`:
60408
+ return {
60409
+ query: params.request.document.expression,
60410
+ variables: params.request.variables,
60411
+ operationName: params.request.document.operationName
60412
+ };
60413
+ case `Batch`:
60414
+ return zip(params.request.query, params.request.variables ?? []).map(([query2, variables]) => ({
60415
+ query: query2,
60416
+ variables
60417
+ }));
60418
+ default:
60419
+ throw casesExhausted(params.request);
60420
+ }
60421
+ };
60422
+ const buildQueryParams = (params) => {
60423
+ const $jsonSerializer = params.fetchOptions.jsonSerializer ?? defaultJsonSerializer;
60424
+ const searchParams = new URLSearchParams();
60425
+ switch (params.request._tag) {
60426
+ case `Single`: {
60427
+ searchParams.append(`query`, cleanQuery(params.request.document.expression));
60428
+ if (params.request.variables) {
60429
+ searchParams.append(`variables`, $jsonSerializer.stringify(params.request.variables));
60430
+ }
60431
+ if (params.request.document.operationName) {
60432
+ searchParams.append(`operationName`, params.request.document.operationName);
60433
+ }
60434
+ return searchParams;
60435
+ }
60436
+ case `Batch`: {
60437
+ const variablesSerialized = params.request.variables?.map((v) => $jsonSerializer.stringify(v)) ?? [];
60438
+ const queriesCleaned = params.request.query.map(cleanQuery);
60439
+ const payload = zip(queriesCleaned, variablesSerialized).map(([query2, variables]) => ({
60440
+ query: query2,
60441
+ variables
60442
+ }));
60443
+ searchParams.append(`query`, $jsonSerializer.stringify(payload));
60444
+ return searchParams;
60445
+ }
60446
+ default:
60447
+ throw casesExhausted(params.request);
60448
+ }
60449
+ };
60450
+ class GraphQLClient {
60451
+ url;
60452
+ requestConfig;
60453
+ constructor(url, requestConfig = {}) {
60454
+ this.url = url;
60455
+ this.requestConfig = requestConfig;
60456
+ }
60457
+ /**
60458
+ * Send a GraphQL query to the server.
60459
+ */
60460
+ rawRequest = async (...args) => {
60461
+ const [queryOrOptions, variables, requestHeaders] = args;
60462
+ const rawRequestOptions = parseRawRequestArgs(queryOrOptions, variables, requestHeaders);
60463
+ const { headers: headers2, fetch: fetch2 = globalThis.fetch, method = `POST`, requestMiddleware, responseMiddleware, excludeOperationName, ...fetchOptions } = this.requestConfig;
60464
+ const { url } = this;
60465
+ if (rawRequestOptions.signal !== void 0) {
60466
+ fetchOptions.signal = rawRequestOptions.signal;
60467
+ }
60468
+ const document = analyzeDocument(rawRequestOptions.query, excludeOperationName);
60469
+ const response = await runRequest({
60470
+ url,
60471
+ request: {
60472
+ _tag: `Single`,
60473
+ document,
60474
+ variables: rawRequestOptions.variables
60475
+ },
60476
+ headers: {
60477
+ ...HeadersInitToPlainObject(callOrIdentity(headers2)),
60478
+ ...HeadersInitToPlainObject(rawRequestOptions.requestHeaders)
60479
+ },
60480
+ fetch: fetch2,
60481
+ method,
60482
+ fetchOptions,
60483
+ middleware: requestMiddleware
60484
+ });
60485
+ if (responseMiddleware) {
60486
+ await responseMiddleware(response, {
60487
+ operationName: document.operationName,
60488
+ variables,
60489
+ url: this.url
60490
+ });
60491
+ }
60492
+ if (response instanceof Error) {
60493
+ throw response;
60494
+ }
60495
+ return response;
60496
+ };
60497
+ async request(documentOrOptions, ...variablesAndRequestHeaders) {
60498
+ const [variables, requestHeaders] = variablesAndRequestHeaders;
60499
+ const requestOptions = parseRequestArgs(documentOrOptions, variables, requestHeaders);
60500
+ const { headers: headers2, fetch: fetch2 = globalThis.fetch, method = `POST`, requestMiddleware, responseMiddleware, excludeOperationName, ...fetchOptions } = this.requestConfig;
60501
+ const { url } = this;
60502
+ if (requestOptions.signal !== void 0) {
60503
+ fetchOptions.signal = requestOptions.signal;
60504
+ }
60505
+ const analyzedDocument = analyzeDocument(requestOptions.document, excludeOperationName);
60506
+ const response = await runRequest({
60507
+ url,
60508
+ request: {
60509
+ _tag: `Single`,
60510
+ document: analyzedDocument,
60511
+ variables: requestOptions.variables
60512
+ },
60513
+ headers: {
60514
+ ...HeadersInitToPlainObject(callOrIdentity(headers2)),
60515
+ ...HeadersInitToPlainObject(requestOptions.requestHeaders)
60516
+ },
60517
+ fetch: fetch2,
60518
+ method,
60519
+ fetchOptions,
60520
+ middleware: requestMiddleware
60521
+ });
60522
+ if (responseMiddleware) {
60523
+ await responseMiddleware(response, {
60524
+ operationName: analyzedDocument.operationName,
60525
+ variables: requestOptions.variables,
60526
+ url: this.url
60527
+ });
60528
+ }
60529
+ if (response instanceof Error) {
60530
+ throw response;
60531
+ }
60532
+ return response.data;
60533
+ }
60534
+ async batchRequests(documentsOrOptions, requestHeaders) {
60535
+ const batchRequestOptions = parseBatchRequestArgs(documentsOrOptions, requestHeaders);
60536
+ const { headers: headers2, excludeOperationName, ...fetchOptions } = this.requestConfig;
60537
+ if (batchRequestOptions.signal !== void 0) {
60538
+ fetchOptions.signal = batchRequestOptions.signal;
60539
+ }
60540
+ const analyzedDocuments = batchRequestOptions.documents.map(({ document }) => analyzeDocument(document, excludeOperationName));
60541
+ const expressions = analyzedDocuments.map(({ expression }) => expression);
60542
+ const hasMutations = analyzedDocuments.some(({ isMutation }) => isMutation);
60543
+ const variables = batchRequestOptions.documents.map(({ variables: variables2 }) => variables2);
60544
+ const response = await runRequest({
60545
+ url: this.url,
60546
+ request: {
60547
+ _tag: `Batch`,
60548
+ operationName: void 0,
60549
+ query: expressions,
60550
+ hasMutations,
60551
+ variables
60552
+ },
60553
+ headers: {
60554
+ ...HeadersInitToPlainObject(callOrIdentity(headers2)),
60555
+ ...HeadersInitToPlainObject(batchRequestOptions.requestHeaders)
60556
+ },
60557
+ fetch: this.requestConfig.fetch ?? globalThis.fetch,
60558
+ method: this.requestConfig.method || `POST`,
60559
+ fetchOptions,
60560
+ middleware: this.requestConfig.requestMiddleware
60561
+ });
60562
+ if (this.requestConfig.responseMiddleware) {
60563
+ await this.requestConfig.responseMiddleware(response, {
60564
+ operationName: void 0,
60565
+ variables,
60566
+ url: this.url
60567
+ });
60568
+ }
60569
+ if (response instanceof Error) {
60570
+ throw response;
60571
+ }
60572
+ return response.data;
60573
+ }
60574
+ setHeaders(headers2) {
60575
+ this.requestConfig.headers = headers2;
60576
+ return this;
60577
+ }
60578
+ /**
60579
+ * Attach a header to the client. All subsequent requests will have this header.
60580
+ */
60581
+ setHeader(key, value) {
60582
+ const { headers: headers2 } = this.requestConfig;
60583
+ if (headers2) {
60584
+ headers2[key] = value;
60585
+ } else {
60586
+ this.requestConfig.headers = { [key]: value };
60587
+ }
60588
+ return this;
60589
+ }
60590
+ /**
60591
+ * Change the client endpoint. All subsequent requests will send to this endpoint.
60592
+ */
60593
+ setEndpoint(value) {
60594
+ this.url = value;
60595
+ return this;
60596
+ }
60597
+ }
60598
+ const parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
60599
+ return documentOrOptions.document ? documentOrOptions : {
60600
+ document: documentOrOptions,
60601
+ variables,
60602
+ requestHeaders,
60603
+ signal: void 0
60604
+ };
60605
+ };
60606
+ const CreateExtensionVersionDocument = {
60607
+ kind: "Document",
60608
+ definitions: [
60609
+ {
60610
+ kind: "OperationDefinition",
60611
+ operation: "mutation",
60612
+ name: { kind: "Name", value: "CreateExtensionVersion" },
60613
+ variableDefinitions: [
60614
+ {
60615
+ kind: "VariableDefinition",
60616
+ variable: { kind: "Variable", name: { kind: "Name", value: "input" } },
60617
+ type: {
60618
+ kind: "NonNullType",
60619
+ type: {
60620
+ kind: "NamedType",
60621
+ name: { kind: "Name", value: "CreateExtensionVersionInput" }
60622
+ }
60623
+ }
60624
+ }
60625
+ ],
60626
+ selectionSet: {
60627
+ kind: "SelectionSet",
60628
+ selections: [
60629
+ {
60630
+ kind: "Field",
60631
+ name: { kind: "Name", value: "createExtensionVersion" },
60632
+ arguments: [
60633
+ {
60634
+ kind: "Argument",
60635
+ name: { kind: "Name", value: "input" },
60636
+ value: { kind: "Variable", name: { kind: "Name", value: "input" } }
60637
+ }
60638
+ ],
60639
+ selectionSet: {
60640
+ kind: "SelectionSet",
60641
+ selections: [
60642
+ { kind: "Field", name: { kind: "Name", value: "__typename" } },
60643
+ {
60644
+ kind: "InlineFragment",
60645
+ typeCondition: {
60646
+ kind: "NamedType",
60647
+ name: { kind: "Name", value: "CreateExtensionVersionSuccessResult" }
60648
+ },
60649
+ selectionSet: {
60650
+ kind: "SelectionSet",
60651
+ selections: [
60652
+ {
60653
+ kind: "Field",
60654
+ name: { kind: "Name", value: "extensionVersion" },
60655
+ selectionSet: {
60656
+ kind: "SelectionSet",
60657
+ selections: [{ kind: "Field", name: { kind: "Name", value: "id" } }]
60658
+ }
60659
+ },
60660
+ { kind: "Field", name: { kind: "Name", value: "signedUrl" } }
60661
+ ]
60662
+ }
60663
+ },
60664
+ {
60665
+ kind: "InlineFragment",
60666
+ typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Error" } },
60667
+ selectionSet: {
60668
+ kind: "SelectionSet",
60669
+ selections: [{ kind: "Field", name: { kind: "Name", value: "message" } }]
60670
+ }
60671
+ }
60672
+ ]
60673
+ }
60674
+ }
60675
+ ]
60676
+ }
60677
+ }
60678
+ ]
60679
+ };
60680
+ const createExtensionVersion$1 = ({
60681
+ client: client2,
60682
+ variables,
60683
+ sessionAuthToken
60684
+ }) => client2.request({
60685
+ document: CreateExtensionVersionDocument,
60686
+ variables,
60687
+ requestHeaders: {
60688
+ Authorization: `Bearer ${sessionAuthToken}`
60689
+ }
60690
+ });
57102
60691
  const bytesFormat = Intl.NumberFormat("en", {
57103
60692
  notation: "compact",
57104
60693
  style: "unit",
@@ -57107,64 +60696,58 @@ const bytesFormat = Intl.NumberFormat("en", {
57107
60696
  minimumFractionDigits: 1,
57108
60697
  maximumFractionDigits: 1
57109
60698
  });
57110
- const createExtensionVersionResultDataSchema = z.discriminatedUnion("__typename", [
57111
- z.object({
57112
- __typename: z.literal("CreateExtensionVersionSuccessResult"),
57113
- extensionVersion: z.object({
57114
- id: z.string()
57115
- }),
57116
- signedUrl: z.string()
57117
- }),
57118
- z.object({
57119
- __typename: z.literal("AuthorizationError"),
57120
- message: z.string()
57121
- }),
57122
- z.object({
57123
- __typename: z.literal("GenericInternalError"),
57124
- message: z.string()
57125
- }),
57126
- z.object({
57127
- __typename: z.literal("GenericUserError"),
57128
- message: z.string()
57129
- })
57130
- ]);
57131
- const graphQlErrorSchema = z.object({
57132
- message: z.string()
57133
- });
57134
- const createExtensionVersionResultSchema = z.object({
57135
- errors: z.array(graphQlErrorSchema).optional().nullable(),
57136
- data: z.object({
57137
- createExtensionVersion: createExtensionVersionResultDataSchema
57138
- }).nullable()
57139
- });
60699
+ const ignoreGlobs = [
60700
+ "**/.git/**/*",
60701
+ ".git/**/*",
60702
+ "eslint.config.js",
60703
+ "**/eslint.config.js",
60704
+ "node_modules/**/*",
60705
+ "**/node_modules/**/*",
60706
+ "yalc.lock",
60707
+ "**/yalc.lock"
60708
+ ];
57140
60709
  const createExtensionVersion = async (opts, env2) => {
57141
60710
  const extensionId = requireExtensionIdOptionOrEnvVar(opts, env2);
57142
60711
  const apiToken = requireApiToken(env2);
57143
60712
  const cwd = process.cwd();
57144
- const extConfig = await requireValidExtensionDir(cwd);
60713
+ const { manifest } = await requireValidExtensionDir(cwd);
57145
60714
  let enableServer;
57146
60715
  let enableDb;
57147
- if (extConfig.server) {
57148
- enableServer = !!extConfig.server.enable;
57149
- if (extConfig.server.database?.enable && extConfig.server.enable === false) {
60716
+ if (manifest.server) {
60717
+ enableServer = !!manifest.server.enable;
60718
+ if (manifest.server.database?.enable && manifest.server.enable === false) {
57150
60719
  console.warn("WARNING: Automatically disabling database because server is disabled");
57151
60720
  enableDb = false;
57152
- } else if (extConfig.server.database?.enable && !extConfig.server.enable) {
60721
+ } else if (manifest.server.database?.enable && !manifest.server.enable) {
57153
60722
  console.warn("WARNING: Automatically enabling server because database is enabled");
57154
60723
  enableServer = true;
57155
60724
  enableDb = true;
57156
60725
  } else {
57157
- enableDb = !!extConfig.server.database?.enable;
60726
+ enableDb = !!manifest.server.database?.enable;
57158
60727
  }
57159
60728
  } else {
57160
60729
  enableServer = false;
57161
60730
  enableDb = false;
57162
60731
  }
60732
+ let config2 = null;
60733
+ if (opts.configFile) {
60734
+ const configFilePath = resolve$1(cwd, opts.configFile);
60735
+ if (opts.verbose) {
60736
+ console.log(`Loading config file ${configFilePath}`);
60737
+ }
60738
+ const configFile = await readFile(configFilePath, "utf8");
60739
+ try {
60740
+ config2 = parseEnv$1(configFile);
60741
+ } catch (e) {
60742
+ console.error(`Failed to parse config file at ${configFilePath}:`, parseErrorMessage(e));
60743
+ process.exit(1);
60744
+ }
60745
+ }
57163
60746
  const { versionName } = opts;
57164
60747
  console.log(`Creating extension version ${versionName} (Extension ID ${extensionId})
57165
60748
  Server: ${enableServer ? "enabled" : "disabled"}
57166
60749
  Database: ${enableDb ? "enabled" : "disabled"}
57167
- Components: ${Object.keys(extConfig.components ?? {}).length}`);
60750
+ Components: ${Object.keys(manifest.components ?? {}).length}`);
57168
60751
  let extensionVersionId;
57169
60752
  let signedUrl;
57170
60753
  try {
@@ -57172,69 +60755,28 @@ const createExtensionVersion = async (opts, env2) => {
57172
60755
  if (opts.verbose) {
57173
60756
  console.log(`POST ${url}`);
57174
60757
  }
57175
- const createResult = await fetch(url, {
57176
- method: "POST",
57177
- headers: {
57178
- "Content-Type": "application/json",
57179
- Authorization: `Bearer ${apiToken}`
57180
- },
57181
- body: JSON.stringify({
57182
- query: `
57183
- mutation ($input: CreateExtensionVersionInput!) {
57184
- createExtensionVersion(input: $input) {
57185
- __typename
57186
- ... on CreateExtensionVersionSuccessResult {
57187
- extensionVersion {
57188
- id
57189
- }
57190
- signedUrl
57191
- }
57192
- ... on Error {
57193
- message
57194
- }
57195
- }
57196
- }
57197
- `,
57198
- variables: {
57199
- input: {
57200
- extensionId,
57201
- extensionName: extConfig.name,
57202
- versionName,
57203
- enableServer,
57204
- enableDb
57205
- }
60758
+ const result2 = await createExtensionVersion$1({
60759
+ client: new GraphQLClient(url),
60760
+ variables: {
60761
+ input: {
60762
+ extensionId,
60763
+ extensionName: manifest.name,
60764
+ versionName,
60765
+ manifest: JSON.stringify(manifest),
60766
+ enableServer,
60767
+ enableDb,
60768
+ config: config2 ? JSON.stringify(config2) : void 0
57206
60769
  }
57207
- })
60770
+ },
60771
+ sessionAuthToken: apiToken
57208
60772
  });
57209
- if (!createResult.ok) {
57210
- const message = `Failed to create an extension version (status ${createResult.status})`;
57211
- try {
57212
- const data2 = await createResult.json();
57213
- console.error(`${message}:`, parseErrorMessage(data2));
57214
- process.exit(1);
57215
- } catch {
57216
- console.error(message);
57217
- process.exit(1);
57218
- }
57219
- }
57220
- const data = await createResult.json();
57221
- const parseResult = createExtensionVersionResultSchema.safeParse(data);
57222
- if (!parseResult.success) {
57223
- console.error("Failed to create an extension version:", parseResult.error.message);
57224
- process.exit(1);
57225
- }
57226
- const result2 = parseResult.data;
57227
- if (result2.errors) {
57228
- console.error("Failed to create an extension version:", parseErrorMessage(result2));
57229
- process.exit(1);
57230
- }
57231
- if (result2.data?.createExtensionVersion.__typename === "CreateExtensionVersionSuccessResult") {
57232
- extensionVersionId = result2.data.createExtensionVersion.extensionVersion.id;
57233
- signedUrl = result2.data.createExtensionVersion.signedUrl;
60773
+ if (result2.createExtensionVersion.__typename === "CreateExtensionVersionSuccessResult") {
60774
+ extensionVersionId = result2.createExtensionVersion.extensionVersion.id;
60775
+ signedUrl = result2.createExtensionVersion.signedUrl;
57234
60776
  } else {
57235
60777
  console.error(
57236
- `Failed to create an extension version (${result2.data?.createExtensionVersion.__typename ?? "unknown error"}):`,
57237
- parseErrorMessage(result2.data?.createExtensionVersion)
60778
+ `Failed to create an extension version (${result2.createExtensionVersion.__typename}):`,
60779
+ result2.createExtensionVersion.message
57238
60780
  );
57239
60781
  process.exit(1);
57240
60782
  }
@@ -57265,14 +60807,7 @@ const createExtensionVersion = async (opts, env2) => {
57265
60807
  }
57266
60808
  archive.glob("**/*", {
57267
60809
  cwd,
57268
- ignore: [
57269
- "**/.git/**/*",
57270
- ".git/**/*",
57271
- "eslint.config.js",
57272
- "**/eslint.config.js",
57273
- "node_modules/**/*",
57274
- "**/node_modules/**/*"
57275
- ]
60810
+ ignore: ignoreGlobs
57276
60811
  });
57277
60812
  if (opts.verbose) {
57278
60813
  console.log(`Uploading files at ${cwd}`);
@@ -57456,9 +60991,11 @@ const createUser = async (opts, env2) => {
57456
60991
  process.exit(1);
57457
60992
  }
57458
60993
  };
57459
- const Permission = {
60994
+ const PermissionName = {
57460
60995
  /** Create (i.e., add) extensions. */
57461
60996
  CreateExtension: "CreateExtension",
60997
+ /** Create extension versions for existing extensions. This includes deploying new code. */
60998
+ CreateExtensionVersion: "CreateExtensionVersion",
57462
60999
  /** Create sites. */
57463
61000
  CreateSite: "CreateSite",
57464
61001
  /** Create page and form templates. */
@@ -57477,7 +61014,7 @@ const Permission = {
57477
61014
  EditCustomField: "EditCustomField",
57478
61015
  /** Edit any customer site, including its pages and forms, but not necessarily domain. */
57479
61016
  EditCustomerSite: "EditCustomerSite",
57480
- /** Edit any extension. */
61017
+ /** Edit any extension. This does not include creating extension versions (i.e., deploying new code). */
57481
61018
  EditExtension: "EditExtension",
57482
61019
  /** Edit any help ticket's status. */
57483
61020
  EditHelpTicketStatus: "EditHelpTicketStatus",
@@ -57522,7 +61059,7 @@ const Permission = {
57522
61059
  /** View any page or form template. */
57523
61060
  ViewTemplate: "ViewTemplate"
57524
61061
  };
57525
- const allPermissions = Object.values(Permission);
61062
+ const allPermissions = Object.values(PermissionName);
57526
61063
  const revokeAllUserPlatformPermissions = async ({
57527
61064
  platformAdminId
57528
61065
  }, db) => {
@@ -57648,7 +61185,7 @@ const editAdmin = async (opts, env2) => {
57648
61185
  process.exit(1);
57649
61186
  }
57650
61187
  };
57651
- const dbConnectInfo = async (opts, env2) => {
61188
+ const getDbUrl = async (opts, env2) => {
57652
61189
  const connInfo = getExtensionDbConnectInfo(opts, env2);
57653
61190
  const url = connInfo.url.toString();
57654
61191
  const cwd = process.cwd();
@@ -57778,7 +61315,7 @@ const applyExtensionPolicy = async ({
57778
61315
  const initDb = async (opts, env2) => {
57779
61316
  const coreDbUrl = requireCoreDbUrl(env2);
57780
61317
  const extensionId = requireExtensionIdOptionOrEnvVar(opts, env2);
57781
- await dbConnectInfo(opts, env2);
61318
+ await getDbUrl(opts, env2);
57782
61319
  const db = await distExports$1.createPool(coreDbUrl, dbPoolOptions(opts));
57783
61320
  const extension = await db.maybeOne(distExports$1.sql.type(extensionSelectSchema)`
57784
61321
  select "id", "platformId"
@@ -57847,7 +61384,7 @@ const initDb = async (opts, env2) => {
57847
61384
  };
57848
61385
  const program = new Command().name("wirechunk").option("--verbose", "output debug logging").option(
57849
61386
  "--env-mode <mode>",
57850
- 'the mode to use for finding .env files to load environment variables, such as "test" to load .env, .env.test, .env.local, and .env.test.local'
61387
+ 'the mode to use for finding .env files to load environment variables, such as "test" to load .env, .env.test, .env.local, and .env.test.local; also for finding config files to include when creating an extension or extension version, such as config.production.json'
57851
61388
  ).description(`The official Wirechunk CLI
57852
61389
 
57853
61390
  By default, environment variables are loaded from the .env file in the current working directory,
@@ -57875,7 +61412,10 @@ program.command("bootstrap").description("create a platform").requiredOption("--
57875
61412
  program.command("create-extension-version").description("create an extension version").option(
57876
61413
  "--extension-id <string>",
57877
61414
  "the ID of the extension, can be set with an EXTENSION_ID environment variable instead"
57878
- ).requiredOption("--version-name <string>", "the name of the version").action(withOptionsAndEnv(createExtensionVersion));
61415
+ ).requiredOption("--version-name <string>", "the name of the version").option(
61416
+ "--config-file <string>",
61417
+ "the path to a file to use when creating the extension version, containing environment-style key-value pairs"
61418
+ ).action(withOptionsAndEnv(createExtensionVersion));
57879
61419
  program.command("create-user").description("create a user").requiredOption("--email <string>", "the email address of the user").requiredOption("--password <string>", "the password of the user").requiredOption("--first-name <string>", "the first name of the user").requiredOption("--last-name <string>", "the last name of the user").option(
57880
61420
  "--org-id <string>",
57881
61421
  "the ID of the org to which the user belongs, defaults to creating a new org if not specified"
@@ -57886,12 +61426,12 @@ program.command("create-user").description("create a user").requiredOption("--em
57886
61426
  new Option("--role <string>", "the role the user will have").default("OrganizationOwner")
57887
61427
  ).option("--email-verified", "mark the email address as already verified by the user", false).option("--pending", "create the user in a pending state", false).action(withOptionsAndEnv(createUser));
57888
61428
  const extDev = program.command("ext-dev").description("extension development commands");
57889
- extDev.command("db-connect-info").description(
57890
- "write the connection info for the extension database to a .local.env or .local.<env-mode>.env file"
61429
+ extDev.command("get-db-url").description(
61430
+ "write the connection info for the extension database to a .env.local or .env.<env-mode>.local file"
57891
61431
  ).option(
57892
61432
  "--extension-id <string>",
57893
61433
  "the ID of the extension, can be set with an EXTENSION_ID environment variable instead"
57894
- ).action(withOptionsAndEnv(dbConnectInfo));
61434
+ ).action(withOptionsAndEnv(getDbUrl));
57895
61435
  extDev.command("init-db").description(
57896
61436
  "initialize a development database for an extension, useful for testing, assumes the extension role exists"
57897
61437
  ).option(