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