@bananapus/nana-sdk-react 2.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ import {
56
56
  JBCoreContracts as JBCoreContracts3,
57
57
  getJBContractAddress as getJBContractAddress2
58
58
  } from "@bananapus/nana-sdk-core";
59
- import { createContext as createContext8, useCallback, useContext as useContext8, useMemo as useMemo3 } from "react";
59
+ import { createContext as createContext8, useCallback, useContext as useContext8, useMemo as useMemo5 } from "react";
60
60
  import { isAddressEqual as isAddressEqual4, zeroAddress as zeroAddress4 } from "viem";
61
61
 
62
62
  // src/hooks/usePreparePayMetadata.ts
@@ -717,6 +717,2643 @@ function useSuckers(args) {
717
717
  return { data: pairs, ...rest };
718
718
  }
719
719
 
720
+ // src/hooks/shop/useShopPurchases.ts
721
+ import { useMemo as useMemo3 } from "react";
722
+
723
+ // ../../node_modules/graphql/jsutils/devAssert.mjs
724
+ function devAssert(condition, message) {
725
+ const booleanCondition = Boolean(condition);
726
+ if (!booleanCondition) {
727
+ throw new Error(message);
728
+ }
729
+ }
730
+
731
+ // ../../node_modules/graphql/jsutils/isObjectLike.mjs
732
+ function isObjectLike(value) {
733
+ return typeof value == "object" && value !== null;
734
+ }
735
+
736
+ // ../../node_modules/graphql/jsutils/invariant.mjs
737
+ function invariant(condition, message) {
738
+ const booleanCondition = Boolean(condition);
739
+ if (!booleanCondition) {
740
+ throw new Error(
741
+ message != null ? message : "Unexpected invariant triggered."
742
+ );
743
+ }
744
+ }
745
+
746
+ // ../../node_modules/graphql/language/location.mjs
747
+ var LineRegExp = /\r\n|[\n\r]/g;
748
+ function getLocation(source, position) {
749
+ let lastLineStart = 0;
750
+ let line = 1;
751
+ for (const match of source.body.matchAll(LineRegExp)) {
752
+ typeof match.index === "number" || invariant(false);
753
+ if (match.index >= position) {
754
+ break;
755
+ }
756
+ lastLineStart = match.index + match[0].length;
757
+ line += 1;
758
+ }
759
+ return {
760
+ line,
761
+ column: position + 1 - lastLineStart
762
+ };
763
+ }
764
+
765
+ // ../../node_modules/graphql/language/printLocation.mjs
766
+ function printLocation(location) {
767
+ return printSourceLocation(
768
+ location.source,
769
+ getLocation(location.source, location.start)
770
+ );
771
+ }
772
+ function printSourceLocation(source, sourceLocation) {
773
+ const firstLineColumnOffset = source.locationOffset.column - 1;
774
+ const body = "".padStart(firstLineColumnOffset) + source.body;
775
+ const lineIndex = sourceLocation.line - 1;
776
+ const lineOffset = source.locationOffset.line - 1;
777
+ const lineNum = sourceLocation.line + lineOffset;
778
+ const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
779
+ const columnNum = sourceLocation.column + columnOffset;
780
+ const locationStr = `${source.name}:${lineNum}:${columnNum}
781
+ `;
782
+ const lines = body.split(/\r\n|[\n\r]/g);
783
+ const locationLine = lines[lineIndex];
784
+ if (locationLine.length > 120) {
785
+ const subLineIndex = Math.floor(columnNum / 80);
786
+ const subLineColumnNum = columnNum % 80;
787
+ const subLines = [];
788
+ for (let i = 0; i < locationLine.length; i += 80) {
789
+ subLines.push(locationLine.slice(i, i + 80));
790
+ }
791
+ return locationStr + printPrefixedLines([
792
+ [`${lineNum} |`, subLines[0]],
793
+ ...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
794
+ ["|", "^".padStart(subLineColumnNum)],
795
+ ["|", subLines[subLineIndex + 1]]
796
+ ]);
797
+ }
798
+ return locationStr + printPrefixedLines([
799
+ // Lines specified like this: ["prefix", "string"],
800
+ [`${lineNum - 1} |`, lines[lineIndex - 1]],
801
+ [`${lineNum} |`, locationLine],
802
+ ["|", "^".padStart(columnNum)],
803
+ [`${lineNum + 1} |`, lines[lineIndex + 1]]
804
+ ]);
805
+ }
806
+ function printPrefixedLines(lines) {
807
+ const existingLines = lines.filter(([_, line]) => line !== void 0);
808
+ const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
809
+ return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
810
+ }
811
+
812
+ // ../../node_modules/graphql/error/GraphQLError.mjs
813
+ function toNormalizedOptions(args) {
814
+ const firstArg = args[0];
815
+ if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
816
+ return {
817
+ nodes: firstArg,
818
+ source: args[1],
819
+ positions: args[2],
820
+ path: args[3],
821
+ originalError: args[4],
822
+ extensions: args[5]
823
+ };
824
+ }
825
+ return firstArg;
826
+ }
827
+ var GraphQLError = class _GraphQLError extends Error {
828
+ /**
829
+ * An array of `{ line, column }` locations within the source GraphQL document
830
+ * which correspond to this error.
831
+ *
832
+ * Errors during validation often contain multiple locations, for example to
833
+ * point out two things with the same name. Errors during execution include a
834
+ * single location, the field which produced the error.
835
+ *
836
+ * Enumerable, and appears in the result of JSON.stringify().
837
+ */
838
+ /**
839
+ * An array describing the JSON-path into the execution response which
840
+ * corresponds to this error. Only included for errors during execution.
841
+ *
842
+ * Enumerable, and appears in the result of JSON.stringify().
843
+ */
844
+ /**
845
+ * An array of GraphQL AST Nodes corresponding to this error.
846
+ */
847
+ /**
848
+ * The source GraphQL document for the first location of this error.
849
+ *
850
+ * Note that if this Error represents more than one node, the source may not
851
+ * represent nodes after the first node.
852
+ */
853
+ /**
854
+ * An array of character offsets within the source GraphQL document
855
+ * which correspond to this error.
856
+ */
857
+ /**
858
+ * The original error thrown from a field resolver during execution.
859
+ */
860
+ /**
861
+ * Extension fields to add to the formatted error.
862
+ */
863
+ /**
864
+ * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
865
+ */
866
+ constructor(message, ...rawArgs) {
867
+ var _this$nodes, _nodeLocations$, _ref;
868
+ const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
869
+ super(message);
870
+ this.name = "GraphQLError";
871
+ this.path = path !== null && path !== void 0 ? path : void 0;
872
+ this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
873
+ this.nodes = undefinedIfEmpty(
874
+ Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
875
+ );
876
+ const nodeLocations = undefinedIfEmpty(
877
+ (_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null)
878
+ );
879
+ 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;
880
+ this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
881
+ 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));
882
+ const originalExtensions = isObjectLike(
883
+ originalError === null || originalError === void 0 ? void 0 : originalError.extensions
884
+ ) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
885
+ this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ Object.create(null);
886
+ Object.defineProperties(this, {
887
+ message: {
888
+ writable: true,
889
+ enumerable: true
890
+ },
891
+ name: {
892
+ enumerable: false
893
+ },
894
+ nodes: {
895
+ enumerable: false
896
+ },
897
+ source: {
898
+ enumerable: false
899
+ },
900
+ positions: {
901
+ enumerable: false
902
+ },
903
+ originalError: {
904
+ enumerable: false
905
+ }
906
+ });
907
+ if (originalError !== null && originalError !== void 0 && originalError.stack) {
908
+ Object.defineProperty(this, "stack", {
909
+ value: originalError.stack,
910
+ writable: true,
911
+ configurable: true
912
+ });
913
+ } else if (Error.captureStackTrace) {
914
+ Error.captureStackTrace(this, _GraphQLError);
915
+ } else {
916
+ Object.defineProperty(this, "stack", {
917
+ value: Error().stack,
918
+ writable: true,
919
+ configurable: true
920
+ });
921
+ }
922
+ }
923
+ get [Symbol.toStringTag]() {
924
+ return "GraphQLError";
925
+ }
926
+ toString() {
927
+ let output = this.message;
928
+ if (this.nodes) {
929
+ for (const node of this.nodes) {
930
+ if (node.loc) {
931
+ output += "\n\n" + printLocation(node.loc);
932
+ }
933
+ }
934
+ } else if (this.source && this.locations) {
935
+ for (const location of this.locations) {
936
+ output += "\n\n" + printSourceLocation(this.source, location);
937
+ }
938
+ }
939
+ return output;
940
+ }
941
+ toJSON() {
942
+ const formattedError = {
943
+ message: this.message
944
+ };
945
+ if (this.locations != null) {
946
+ formattedError.locations = this.locations;
947
+ }
948
+ if (this.path != null) {
949
+ formattedError.path = this.path;
950
+ }
951
+ if (this.extensions != null && Object.keys(this.extensions).length > 0) {
952
+ formattedError.extensions = this.extensions;
953
+ }
954
+ return formattedError;
955
+ }
956
+ };
957
+ function undefinedIfEmpty(array) {
958
+ return array === void 0 || array.length === 0 ? void 0 : array;
959
+ }
960
+
961
+ // ../../node_modules/graphql/error/syntaxError.mjs
962
+ function syntaxError(source, position, description) {
963
+ return new GraphQLError(`Syntax Error: ${description}`, {
964
+ source,
965
+ positions: [position]
966
+ });
967
+ }
968
+
969
+ // ../../node_modules/graphql/language/ast.mjs
970
+ var Location = class {
971
+ /**
972
+ * The character offset at which this Node begins.
973
+ */
974
+ /**
975
+ * The character offset at which this Node ends.
976
+ */
977
+ /**
978
+ * The Token at which this Node begins.
979
+ */
980
+ /**
981
+ * The Token at which this Node ends.
982
+ */
983
+ /**
984
+ * The Source document the AST represents.
985
+ */
986
+ constructor(startToken, endToken, source) {
987
+ this.start = startToken.start;
988
+ this.end = endToken.end;
989
+ this.startToken = startToken;
990
+ this.endToken = endToken;
991
+ this.source = source;
992
+ }
993
+ get [Symbol.toStringTag]() {
994
+ return "Location";
995
+ }
996
+ toJSON() {
997
+ return {
998
+ start: this.start,
999
+ end: this.end
1000
+ };
1001
+ }
1002
+ };
1003
+ var Token = class {
1004
+ /**
1005
+ * The kind of Token.
1006
+ */
1007
+ /**
1008
+ * The character offset at which this Node begins.
1009
+ */
1010
+ /**
1011
+ * The character offset at which this Node ends.
1012
+ */
1013
+ /**
1014
+ * The 1-indexed line number on which this Token appears.
1015
+ */
1016
+ /**
1017
+ * The 1-indexed column number at which this Token begins.
1018
+ */
1019
+ /**
1020
+ * For non-punctuation tokens, represents the interpreted value of the token.
1021
+ *
1022
+ * Note: is undefined for punctuation tokens, but typed as string for
1023
+ * convenience in the parser.
1024
+ */
1025
+ /**
1026
+ * Tokens exist as nodes in a double-linked-list amongst all tokens
1027
+ * including ignored tokens. <SOF> is always the first node and <EOF>
1028
+ * the last.
1029
+ */
1030
+ constructor(kind, start, end, line, column, value) {
1031
+ this.kind = kind;
1032
+ this.start = start;
1033
+ this.end = end;
1034
+ this.line = line;
1035
+ this.column = column;
1036
+ this.value = value;
1037
+ this.prev = null;
1038
+ this.next = null;
1039
+ }
1040
+ get [Symbol.toStringTag]() {
1041
+ return "Token";
1042
+ }
1043
+ toJSON() {
1044
+ return {
1045
+ kind: this.kind,
1046
+ value: this.value,
1047
+ line: this.line,
1048
+ column: this.column
1049
+ };
1050
+ }
1051
+ };
1052
+ var QueryDocumentKeys = {
1053
+ Name: [],
1054
+ Document: ["definitions"],
1055
+ OperationDefinition: [
1056
+ "name",
1057
+ "variableDefinitions",
1058
+ "directives",
1059
+ "selectionSet"
1060
+ ],
1061
+ VariableDefinition: ["variable", "type", "defaultValue", "directives"],
1062
+ Variable: ["name"],
1063
+ SelectionSet: ["selections"],
1064
+ Field: ["alias", "name", "arguments", "directives", "selectionSet"],
1065
+ Argument: ["name", "value"],
1066
+ FragmentSpread: ["name", "directives"],
1067
+ InlineFragment: ["typeCondition", "directives", "selectionSet"],
1068
+ FragmentDefinition: [
1069
+ "name",
1070
+ // Note: fragment variable definitions are deprecated and will removed in v17.0.0
1071
+ "variableDefinitions",
1072
+ "typeCondition",
1073
+ "directives",
1074
+ "selectionSet"
1075
+ ],
1076
+ IntValue: [],
1077
+ FloatValue: [],
1078
+ StringValue: [],
1079
+ BooleanValue: [],
1080
+ NullValue: [],
1081
+ EnumValue: [],
1082
+ ListValue: ["values"],
1083
+ ObjectValue: ["fields"],
1084
+ ObjectField: ["name", "value"],
1085
+ Directive: ["name", "arguments"],
1086
+ NamedType: ["name"],
1087
+ ListType: ["type"],
1088
+ NonNullType: ["type"],
1089
+ SchemaDefinition: ["description", "directives", "operationTypes"],
1090
+ OperationTypeDefinition: ["type"],
1091
+ ScalarTypeDefinition: ["description", "name", "directives"],
1092
+ ObjectTypeDefinition: [
1093
+ "description",
1094
+ "name",
1095
+ "interfaces",
1096
+ "directives",
1097
+ "fields"
1098
+ ],
1099
+ FieldDefinition: ["description", "name", "arguments", "type", "directives"],
1100
+ InputValueDefinition: [
1101
+ "description",
1102
+ "name",
1103
+ "type",
1104
+ "defaultValue",
1105
+ "directives"
1106
+ ],
1107
+ InterfaceTypeDefinition: [
1108
+ "description",
1109
+ "name",
1110
+ "interfaces",
1111
+ "directives",
1112
+ "fields"
1113
+ ],
1114
+ UnionTypeDefinition: ["description", "name", "directives", "types"],
1115
+ EnumTypeDefinition: ["description", "name", "directives", "values"],
1116
+ EnumValueDefinition: ["description", "name", "directives"],
1117
+ InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
1118
+ DirectiveDefinition: ["description", "name", "arguments", "locations"],
1119
+ SchemaExtension: ["directives", "operationTypes"],
1120
+ ScalarTypeExtension: ["name", "directives"],
1121
+ ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
1122
+ InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
1123
+ UnionTypeExtension: ["name", "directives", "types"],
1124
+ EnumTypeExtension: ["name", "directives", "values"],
1125
+ InputObjectTypeExtension: ["name", "directives", "fields"]
1126
+ };
1127
+ var kindValues = new Set(Object.keys(QueryDocumentKeys));
1128
+ var OperationTypeNode;
1129
+ (function(OperationTypeNode2) {
1130
+ OperationTypeNode2["QUERY"] = "query";
1131
+ OperationTypeNode2["MUTATION"] = "mutation";
1132
+ OperationTypeNode2["SUBSCRIPTION"] = "subscription";
1133
+ })(OperationTypeNode || (OperationTypeNode = {}));
1134
+
1135
+ // ../../node_modules/graphql/language/directiveLocation.mjs
1136
+ var DirectiveLocation;
1137
+ (function(DirectiveLocation2) {
1138
+ DirectiveLocation2["QUERY"] = "QUERY";
1139
+ DirectiveLocation2["MUTATION"] = "MUTATION";
1140
+ DirectiveLocation2["SUBSCRIPTION"] = "SUBSCRIPTION";
1141
+ DirectiveLocation2["FIELD"] = "FIELD";
1142
+ DirectiveLocation2["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
1143
+ DirectiveLocation2["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
1144
+ DirectiveLocation2["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
1145
+ DirectiveLocation2["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
1146
+ DirectiveLocation2["SCHEMA"] = "SCHEMA";
1147
+ DirectiveLocation2["SCALAR"] = "SCALAR";
1148
+ DirectiveLocation2["OBJECT"] = "OBJECT";
1149
+ DirectiveLocation2["FIELD_DEFINITION"] = "FIELD_DEFINITION";
1150
+ DirectiveLocation2["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
1151
+ DirectiveLocation2["INTERFACE"] = "INTERFACE";
1152
+ DirectiveLocation2["UNION"] = "UNION";
1153
+ DirectiveLocation2["ENUM"] = "ENUM";
1154
+ DirectiveLocation2["ENUM_VALUE"] = "ENUM_VALUE";
1155
+ DirectiveLocation2["INPUT_OBJECT"] = "INPUT_OBJECT";
1156
+ DirectiveLocation2["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
1157
+ })(DirectiveLocation || (DirectiveLocation = {}));
1158
+
1159
+ // ../../node_modules/graphql/language/kinds.mjs
1160
+ var Kind;
1161
+ (function(Kind2) {
1162
+ Kind2["NAME"] = "Name";
1163
+ Kind2["DOCUMENT"] = "Document";
1164
+ Kind2["OPERATION_DEFINITION"] = "OperationDefinition";
1165
+ Kind2["VARIABLE_DEFINITION"] = "VariableDefinition";
1166
+ Kind2["SELECTION_SET"] = "SelectionSet";
1167
+ Kind2["FIELD"] = "Field";
1168
+ Kind2["ARGUMENT"] = "Argument";
1169
+ Kind2["FRAGMENT_SPREAD"] = "FragmentSpread";
1170
+ Kind2["INLINE_FRAGMENT"] = "InlineFragment";
1171
+ Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition";
1172
+ Kind2["VARIABLE"] = "Variable";
1173
+ Kind2["INT"] = "IntValue";
1174
+ Kind2["FLOAT"] = "FloatValue";
1175
+ Kind2["STRING"] = "StringValue";
1176
+ Kind2["BOOLEAN"] = "BooleanValue";
1177
+ Kind2["NULL"] = "NullValue";
1178
+ Kind2["ENUM"] = "EnumValue";
1179
+ Kind2["LIST"] = "ListValue";
1180
+ Kind2["OBJECT"] = "ObjectValue";
1181
+ Kind2["OBJECT_FIELD"] = "ObjectField";
1182
+ Kind2["DIRECTIVE"] = "Directive";
1183
+ Kind2["NAMED_TYPE"] = "NamedType";
1184
+ Kind2["LIST_TYPE"] = "ListType";
1185
+ Kind2["NON_NULL_TYPE"] = "NonNullType";
1186
+ Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition";
1187
+ Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
1188
+ Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
1189
+ Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
1190
+ Kind2["FIELD_DEFINITION"] = "FieldDefinition";
1191
+ Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
1192
+ Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
1193
+ Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
1194
+ Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
1195
+ Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
1196
+ Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
1197
+ Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
1198
+ Kind2["SCHEMA_EXTENSION"] = "SchemaExtension";
1199
+ Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
1200
+ Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
1201
+ Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
1202
+ Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
1203
+ Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
1204
+ Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
1205
+ })(Kind || (Kind = {}));
1206
+
1207
+ // ../../node_modules/graphql/language/characterClasses.mjs
1208
+ function isWhiteSpace(code) {
1209
+ return code === 9 || code === 32;
1210
+ }
1211
+ function isDigit(code) {
1212
+ return code >= 48 && code <= 57;
1213
+ }
1214
+ function isLetter(code) {
1215
+ return code >= 97 && code <= 122 || // A-Z
1216
+ code >= 65 && code <= 90;
1217
+ }
1218
+ function isNameStart(code) {
1219
+ return isLetter(code) || code === 95;
1220
+ }
1221
+ function isNameContinue(code) {
1222
+ return isLetter(code) || isDigit(code) || code === 95;
1223
+ }
1224
+
1225
+ // ../../node_modules/graphql/language/blockString.mjs
1226
+ function dedentBlockStringLines(lines) {
1227
+ var _firstNonEmptyLine2;
1228
+ let commonIndent = Number.MAX_SAFE_INTEGER;
1229
+ let firstNonEmptyLine = null;
1230
+ let lastNonEmptyLine = -1;
1231
+ for (let i = 0; i < lines.length; ++i) {
1232
+ var _firstNonEmptyLine;
1233
+ const line = lines[i];
1234
+ const indent = leadingWhitespace(line);
1235
+ if (indent === line.length) {
1236
+ continue;
1237
+ }
1238
+ firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
1239
+ lastNonEmptyLine = i;
1240
+ if (i !== 0 && indent < commonIndent) {
1241
+ commonIndent = indent;
1242
+ }
1243
+ }
1244
+ return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice(
1245
+ (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0,
1246
+ lastNonEmptyLine + 1
1247
+ );
1248
+ }
1249
+ function leadingWhitespace(str) {
1250
+ let i = 0;
1251
+ while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
1252
+ ++i;
1253
+ }
1254
+ return i;
1255
+ }
1256
+
1257
+ // ../../node_modules/graphql/language/tokenKind.mjs
1258
+ var TokenKind;
1259
+ (function(TokenKind2) {
1260
+ TokenKind2["SOF"] = "<SOF>";
1261
+ TokenKind2["EOF"] = "<EOF>";
1262
+ TokenKind2["BANG"] = "!";
1263
+ TokenKind2["DOLLAR"] = "$";
1264
+ TokenKind2["AMP"] = "&";
1265
+ TokenKind2["PAREN_L"] = "(";
1266
+ TokenKind2["PAREN_R"] = ")";
1267
+ TokenKind2["SPREAD"] = "...";
1268
+ TokenKind2["COLON"] = ":";
1269
+ TokenKind2["EQUALS"] = "=";
1270
+ TokenKind2["AT"] = "@";
1271
+ TokenKind2["BRACKET_L"] = "[";
1272
+ TokenKind2["BRACKET_R"] = "]";
1273
+ TokenKind2["BRACE_L"] = "{";
1274
+ TokenKind2["PIPE"] = "|";
1275
+ TokenKind2["BRACE_R"] = "}";
1276
+ TokenKind2["NAME"] = "Name";
1277
+ TokenKind2["INT"] = "Int";
1278
+ TokenKind2["FLOAT"] = "Float";
1279
+ TokenKind2["STRING"] = "String";
1280
+ TokenKind2["BLOCK_STRING"] = "BlockString";
1281
+ TokenKind2["COMMENT"] = "Comment";
1282
+ })(TokenKind || (TokenKind = {}));
1283
+
1284
+ // ../../node_modules/graphql/language/lexer.mjs
1285
+ var Lexer = class {
1286
+ /**
1287
+ * The previously focused non-ignored token.
1288
+ */
1289
+ /**
1290
+ * The currently focused non-ignored token.
1291
+ */
1292
+ /**
1293
+ * The (1-indexed) line containing the current token.
1294
+ */
1295
+ /**
1296
+ * The character offset at which the current line begins.
1297
+ */
1298
+ constructor(source) {
1299
+ const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
1300
+ this.source = source;
1301
+ this.lastToken = startOfFileToken;
1302
+ this.token = startOfFileToken;
1303
+ this.line = 1;
1304
+ this.lineStart = 0;
1305
+ }
1306
+ get [Symbol.toStringTag]() {
1307
+ return "Lexer";
1308
+ }
1309
+ /**
1310
+ * Advances the token stream to the next non-ignored token.
1311
+ */
1312
+ advance() {
1313
+ this.lastToken = this.token;
1314
+ const token = this.token = this.lookahead();
1315
+ return token;
1316
+ }
1317
+ /**
1318
+ * Looks ahead and returns the next non-ignored token, but does not change
1319
+ * the state of Lexer.
1320
+ */
1321
+ lookahead() {
1322
+ let token = this.token;
1323
+ if (token.kind !== TokenKind.EOF) {
1324
+ do {
1325
+ if (token.next) {
1326
+ token = token.next;
1327
+ } else {
1328
+ const nextToken = readNextToken(this, token.end);
1329
+ token.next = nextToken;
1330
+ nextToken.prev = token;
1331
+ token = nextToken;
1332
+ }
1333
+ } while (token.kind === TokenKind.COMMENT);
1334
+ }
1335
+ return token;
1336
+ }
1337
+ };
1338
+ function isPunctuatorTokenKind(kind) {
1339
+ 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;
1340
+ }
1341
+ function isUnicodeScalarValue(code) {
1342
+ return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
1343
+ }
1344
+ function isSupplementaryCodePoint(body, location) {
1345
+ return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
1346
+ }
1347
+ function isLeadingSurrogate(code) {
1348
+ return code >= 55296 && code <= 56319;
1349
+ }
1350
+ function isTrailingSurrogate(code) {
1351
+ return code >= 56320 && code <= 57343;
1352
+ }
1353
+ function printCodePointAt(lexer, location) {
1354
+ const code = lexer.source.body.codePointAt(location);
1355
+ if (code === void 0) {
1356
+ return TokenKind.EOF;
1357
+ } else if (code >= 32 && code <= 126) {
1358
+ const char = String.fromCodePoint(code);
1359
+ return char === '"' ? `'"'` : `"${char}"`;
1360
+ }
1361
+ return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
1362
+ }
1363
+ function createToken(lexer, kind, start, end, value) {
1364
+ const line = lexer.line;
1365
+ const col = 1 + start - lexer.lineStart;
1366
+ return new Token(kind, start, end, line, col, value);
1367
+ }
1368
+ function readNextToken(lexer, start) {
1369
+ const body = lexer.source.body;
1370
+ const bodyLength = body.length;
1371
+ let position = start;
1372
+ while (position < bodyLength) {
1373
+ const code = body.charCodeAt(position);
1374
+ switch (code) {
1375
+ // Ignored ::
1376
+ // - UnicodeBOM
1377
+ // - WhiteSpace
1378
+ // - LineTerminator
1379
+ // - Comment
1380
+ // - Comma
1381
+ //
1382
+ // UnicodeBOM :: "Byte Order Mark (U+FEFF)"
1383
+ //
1384
+ // WhiteSpace ::
1385
+ // - "Horizontal Tab (U+0009)"
1386
+ // - "Space (U+0020)"
1387
+ //
1388
+ // Comma :: ,
1389
+ case 65279:
1390
+ // <BOM>
1391
+ case 9:
1392
+ // \t
1393
+ case 32:
1394
+ // <space>
1395
+ case 44:
1396
+ ++position;
1397
+ continue;
1398
+ // LineTerminator ::
1399
+ // - "New Line (U+000A)"
1400
+ // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
1401
+ // - "Carriage Return (U+000D)" "New Line (U+000A)"
1402
+ case 10:
1403
+ ++position;
1404
+ ++lexer.line;
1405
+ lexer.lineStart = position;
1406
+ continue;
1407
+ case 13:
1408
+ if (body.charCodeAt(position + 1) === 10) {
1409
+ position += 2;
1410
+ } else {
1411
+ ++position;
1412
+ }
1413
+ ++lexer.line;
1414
+ lexer.lineStart = position;
1415
+ continue;
1416
+ // Comment
1417
+ case 35:
1418
+ return readComment(lexer, position);
1419
+ // Token ::
1420
+ // - Punctuator
1421
+ // - Name
1422
+ // - IntValue
1423
+ // - FloatValue
1424
+ // - StringValue
1425
+ //
1426
+ // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
1427
+ case 33:
1428
+ return createToken(lexer, TokenKind.BANG, position, position + 1);
1429
+ case 36:
1430
+ return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
1431
+ case 38:
1432
+ return createToken(lexer, TokenKind.AMP, position, position + 1);
1433
+ case 40:
1434
+ return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
1435
+ case 41:
1436
+ return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
1437
+ case 46:
1438
+ if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) {
1439
+ return createToken(lexer, TokenKind.SPREAD, position, position + 3);
1440
+ }
1441
+ break;
1442
+ case 58:
1443
+ return createToken(lexer, TokenKind.COLON, position, position + 1);
1444
+ case 61:
1445
+ return createToken(lexer, TokenKind.EQUALS, position, position + 1);
1446
+ case 64:
1447
+ return createToken(lexer, TokenKind.AT, position, position + 1);
1448
+ case 91:
1449
+ return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
1450
+ case 93:
1451
+ return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
1452
+ case 123:
1453
+ return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
1454
+ case 124:
1455
+ return createToken(lexer, TokenKind.PIPE, position, position + 1);
1456
+ case 125:
1457
+ return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
1458
+ // StringValue
1459
+ case 34:
1460
+ if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
1461
+ return readBlockString(lexer, position);
1462
+ }
1463
+ return readString(lexer, position);
1464
+ }
1465
+ if (isDigit(code) || code === 45) {
1466
+ return readNumber(lexer, position, code);
1467
+ }
1468
+ if (isNameStart(code)) {
1469
+ return readName(lexer, position);
1470
+ }
1471
+ throw syntaxError(
1472
+ lexer.source,
1473
+ position,
1474
+ code === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`
1475
+ );
1476
+ }
1477
+ return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
1478
+ }
1479
+ function readComment(lexer, start) {
1480
+ const body = lexer.source.body;
1481
+ const bodyLength = body.length;
1482
+ let position = start + 1;
1483
+ while (position < bodyLength) {
1484
+ const code = body.charCodeAt(position);
1485
+ if (code === 10 || code === 13) {
1486
+ break;
1487
+ }
1488
+ if (isUnicodeScalarValue(code)) {
1489
+ ++position;
1490
+ } else if (isSupplementaryCodePoint(body, position)) {
1491
+ position += 2;
1492
+ } else {
1493
+ break;
1494
+ }
1495
+ }
1496
+ return createToken(
1497
+ lexer,
1498
+ TokenKind.COMMENT,
1499
+ start,
1500
+ position,
1501
+ body.slice(start + 1, position)
1502
+ );
1503
+ }
1504
+ function readNumber(lexer, start, firstCode) {
1505
+ const body = lexer.source.body;
1506
+ let position = start;
1507
+ let code = firstCode;
1508
+ let isFloat = false;
1509
+ if (code === 45) {
1510
+ code = body.charCodeAt(++position);
1511
+ }
1512
+ if (code === 48) {
1513
+ code = body.charCodeAt(++position);
1514
+ if (isDigit(code)) {
1515
+ throw syntaxError(
1516
+ lexer.source,
1517
+ position,
1518
+ `Invalid number, unexpected digit after 0: ${printCodePointAt(
1519
+ lexer,
1520
+ position
1521
+ )}.`
1522
+ );
1523
+ }
1524
+ } else {
1525
+ position = readDigits(lexer, position, code);
1526
+ code = body.charCodeAt(position);
1527
+ }
1528
+ if (code === 46) {
1529
+ isFloat = true;
1530
+ code = body.charCodeAt(++position);
1531
+ position = readDigits(lexer, position, code);
1532
+ code = body.charCodeAt(position);
1533
+ }
1534
+ if (code === 69 || code === 101) {
1535
+ isFloat = true;
1536
+ code = body.charCodeAt(++position);
1537
+ if (code === 43 || code === 45) {
1538
+ code = body.charCodeAt(++position);
1539
+ }
1540
+ position = readDigits(lexer, position, code);
1541
+ code = body.charCodeAt(position);
1542
+ }
1543
+ if (code === 46 || isNameStart(code)) {
1544
+ throw syntaxError(
1545
+ lexer.source,
1546
+ position,
1547
+ `Invalid number, expected digit but got: ${printCodePointAt(
1548
+ lexer,
1549
+ position
1550
+ )}.`
1551
+ );
1552
+ }
1553
+ return createToken(
1554
+ lexer,
1555
+ isFloat ? TokenKind.FLOAT : TokenKind.INT,
1556
+ start,
1557
+ position,
1558
+ body.slice(start, position)
1559
+ );
1560
+ }
1561
+ function readDigits(lexer, start, firstCode) {
1562
+ if (!isDigit(firstCode)) {
1563
+ throw syntaxError(
1564
+ lexer.source,
1565
+ start,
1566
+ `Invalid number, expected digit but got: ${printCodePointAt(
1567
+ lexer,
1568
+ start
1569
+ )}.`
1570
+ );
1571
+ }
1572
+ const body = lexer.source.body;
1573
+ let position = start + 1;
1574
+ while (isDigit(body.charCodeAt(position))) {
1575
+ ++position;
1576
+ }
1577
+ return position;
1578
+ }
1579
+ function readString(lexer, start) {
1580
+ const body = lexer.source.body;
1581
+ const bodyLength = body.length;
1582
+ let position = start + 1;
1583
+ let chunkStart = position;
1584
+ let value = "";
1585
+ while (position < bodyLength) {
1586
+ const code = body.charCodeAt(position);
1587
+ if (code === 34) {
1588
+ value += body.slice(chunkStart, position);
1589
+ return createToken(lexer, TokenKind.STRING, start, position + 1, value);
1590
+ }
1591
+ if (code === 92) {
1592
+ value += body.slice(chunkStart, position);
1593
+ const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
1594
+ value += escape.value;
1595
+ position += escape.size;
1596
+ chunkStart = position;
1597
+ continue;
1598
+ }
1599
+ if (code === 10 || code === 13) {
1600
+ break;
1601
+ }
1602
+ if (isUnicodeScalarValue(code)) {
1603
+ ++position;
1604
+ } else if (isSupplementaryCodePoint(body, position)) {
1605
+ position += 2;
1606
+ } else {
1607
+ throw syntaxError(
1608
+ lexer.source,
1609
+ position,
1610
+ `Invalid character within String: ${printCodePointAt(
1611
+ lexer,
1612
+ position
1613
+ )}.`
1614
+ );
1615
+ }
1616
+ }
1617
+ throw syntaxError(lexer.source, position, "Unterminated string.");
1618
+ }
1619
+ function readEscapedUnicodeVariableWidth(lexer, position) {
1620
+ const body = lexer.source.body;
1621
+ let point = 0;
1622
+ let size = 3;
1623
+ while (size < 12) {
1624
+ const code = body.charCodeAt(position + size++);
1625
+ if (code === 125) {
1626
+ if (size < 5 || !isUnicodeScalarValue(point)) {
1627
+ break;
1628
+ }
1629
+ return {
1630
+ value: String.fromCodePoint(point),
1631
+ size
1632
+ };
1633
+ }
1634
+ point = point << 4 | readHexDigit(code);
1635
+ if (point < 0) {
1636
+ break;
1637
+ }
1638
+ }
1639
+ throw syntaxError(
1640
+ lexer.source,
1641
+ position,
1642
+ `Invalid Unicode escape sequence: "${body.slice(
1643
+ position,
1644
+ position + size
1645
+ )}".`
1646
+ );
1647
+ }
1648
+ function readEscapedUnicodeFixedWidth(lexer, position) {
1649
+ const body = lexer.source.body;
1650
+ const code = read16BitHexCode(body, position + 2);
1651
+ if (isUnicodeScalarValue(code)) {
1652
+ return {
1653
+ value: String.fromCodePoint(code),
1654
+ size: 6
1655
+ };
1656
+ }
1657
+ if (isLeadingSurrogate(code)) {
1658
+ if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
1659
+ const trailingCode = read16BitHexCode(body, position + 8);
1660
+ if (isTrailingSurrogate(trailingCode)) {
1661
+ return {
1662
+ value: String.fromCodePoint(code, trailingCode),
1663
+ size: 12
1664
+ };
1665
+ }
1666
+ }
1667
+ }
1668
+ throw syntaxError(
1669
+ lexer.source,
1670
+ position,
1671
+ `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`
1672
+ );
1673
+ }
1674
+ function read16BitHexCode(body, position) {
1675
+ return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
1676
+ }
1677
+ function readHexDigit(code) {
1678
+ return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
1679
+ }
1680
+ function readEscapedCharacter(lexer, position) {
1681
+ const body = lexer.source.body;
1682
+ const code = body.charCodeAt(position + 1);
1683
+ switch (code) {
1684
+ case 34:
1685
+ return {
1686
+ value: '"',
1687
+ size: 2
1688
+ };
1689
+ case 92:
1690
+ return {
1691
+ value: "\\",
1692
+ size: 2
1693
+ };
1694
+ case 47:
1695
+ return {
1696
+ value: "/",
1697
+ size: 2
1698
+ };
1699
+ case 98:
1700
+ return {
1701
+ value: "\b",
1702
+ size: 2
1703
+ };
1704
+ case 102:
1705
+ return {
1706
+ value: "\f",
1707
+ size: 2
1708
+ };
1709
+ case 110:
1710
+ return {
1711
+ value: "\n",
1712
+ size: 2
1713
+ };
1714
+ case 114:
1715
+ return {
1716
+ value: "\r",
1717
+ size: 2
1718
+ };
1719
+ case 116:
1720
+ return {
1721
+ value: " ",
1722
+ size: 2
1723
+ };
1724
+ }
1725
+ throw syntaxError(
1726
+ lexer.source,
1727
+ position,
1728
+ `Invalid character escape sequence: "${body.slice(
1729
+ position,
1730
+ position + 2
1731
+ )}".`
1732
+ );
1733
+ }
1734
+ function readBlockString(lexer, start) {
1735
+ const body = lexer.source.body;
1736
+ const bodyLength = body.length;
1737
+ let lineStart = lexer.lineStart;
1738
+ let position = start + 3;
1739
+ let chunkStart = position;
1740
+ let currentLine = "";
1741
+ const blockLines = [];
1742
+ while (position < bodyLength) {
1743
+ const code = body.charCodeAt(position);
1744
+ if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
1745
+ currentLine += body.slice(chunkStart, position);
1746
+ blockLines.push(currentLine);
1747
+ const token = createToken(
1748
+ lexer,
1749
+ TokenKind.BLOCK_STRING,
1750
+ start,
1751
+ position + 3,
1752
+ // Return a string of the lines joined with U+000A.
1753
+ dedentBlockStringLines(blockLines).join("\n")
1754
+ );
1755
+ lexer.line += blockLines.length - 1;
1756
+ lexer.lineStart = lineStart;
1757
+ return token;
1758
+ }
1759
+ if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
1760
+ currentLine += body.slice(chunkStart, position);
1761
+ chunkStart = position + 1;
1762
+ position += 4;
1763
+ continue;
1764
+ }
1765
+ if (code === 10 || code === 13) {
1766
+ currentLine += body.slice(chunkStart, position);
1767
+ blockLines.push(currentLine);
1768
+ if (code === 13 && body.charCodeAt(position + 1) === 10) {
1769
+ position += 2;
1770
+ } else {
1771
+ ++position;
1772
+ }
1773
+ currentLine = "";
1774
+ chunkStart = position;
1775
+ lineStart = position;
1776
+ continue;
1777
+ }
1778
+ if (isUnicodeScalarValue(code)) {
1779
+ ++position;
1780
+ } else if (isSupplementaryCodePoint(body, position)) {
1781
+ position += 2;
1782
+ } else {
1783
+ throw syntaxError(
1784
+ lexer.source,
1785
+ position,
1786
+ `Invalid character within String: ${printCodePointAt(
1787
+ lexer,
1788
+ position
1789
+ )}.`
1790
+ );
1791
+ }
1792
+ }
1793
+ throw syntaxError(lexer.source, position, "Unterminated string.");
1794
+ }
1795
+ function readName(lexer, start) {
1796
+ const body = lexer.source.body;
1797
+ const bodyLength = body.length;
1798
+ let position = start + 1;
1799
+ while (position < bodyLength) {
1800
+ const code = body.charCodeAt(position);
1801
+ if (isNameContinue(code)) {
1802
+ ++position;
1803
+ } else {
1804
+ break;
1805
+ }
1806
+ }
1807
+ return createToken(
1808
+ lexer,
1809
+ TokenKind.NAME,
1810
+ start,
1811
+ position,
1812
+ body.slice(start, position)
1813
+ );
1814
+ }
1815
+
1816
+ // ../../node_modules/graphql/jsutils/inspect.mjs
1817
+ var MAX_ARRAY_LENGTH = 10;
1818
+ var MAX_RECURSIVE_DEPTH = 2;
1819
+ function inspect(value) {
1820
+ return formatValue(value, []);
1821
+ }
1822
+ function formatValue(value, seenValues) {
1823
+ switch (typeof value) {
1824
+ case "string":
1825
+ return JSON.stringify(value);
1826
+ case "function":
1827
+ return value.name ? `[function ${value.name}]` : "[function]";
1828
+ case "object":
1829
+ return formatObjectValue(value, seenValues);
1830
+ default:
1831
+ return String(value);
1832
+ }
1833
+ }
1834
+ function formatObjectValue(value, previouslySeenValues) {
1835
+ if (value === null) {
1836
+ return "null";
1837
+ }
1838
+ if (previouslySeenValues.includes(value)) {
1839
+ return "[Circular]";
1840
+ }
1841
+ const seenValues = [...previouslySeenValues, value];
1842
+ if (isJSONable(value)) {
1843
+ const jsonValue = value.toJSON();
1844
+ if (jsonValue !== value) {
1845
+ return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
1846
+ }
1847
+ } else if (Array.isArray(value)) {
1848
+ return formatArray(value, seenValues);
1849
+ }
1850
+ return formatObject(value, seenValues);
1851
+ }
1852
+ function isJSONable(value) {
1853
+ return typeof value.toJSON === "function";
1854
+ }
1855
+ function formatObject(object, seenValues) {
1856
+ const entries = Object.entries(object);
1857
+ if (entries.length === 0) {
1858
+ return "{}";
1859
+ }
1860
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
1861
+ return "[" + getObjectTag(object) + "]";
1862
+ }
1863
+ const properties = entries.map(
1864
+ ([key, value]) => key + ": " + formatValue(value, seenValues)
1865
+ );
1866
+ return "{ " + properties.join(", ") + " }";
1867
+ }
1868
+ function formatArray(array, seenValues) {
1869
+ if (array.length === 0) {
1870
+ return "[]";
1871
+ }
1872
+ if (seenValues.length > MAX_RECURSIVE_DEPTH) {
1873
+ return "[Array]";
1874
+ }
1875
+ const len = Math.min(MAX_ARRAY_LENGTH, array.length);
1876
+ const remaining = array.length - len;
1877
+ const items = [];
1878
+ for (let i = 0; i < len; ++i) {
1879
+ items.push(formatValue(array[i], seenValues));
1880
+ }
1881
+ if (remaining === 1) {
1882
+ items.push("... 1 more item");
1883
+ } else if (remaining > 1) {
1884
+ items.push(`... ${remaining} more items`);
1885
+ }
1886
+ return "[" + items.join(", ") + "]";
1887
+ }
1888
+ function getObjectTag(object) {
1889
+ const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
1890
+ if (tag === "Object" && typeof object.constructor === "function") {
1891
+ const name = object.constructor.name;
1892
+ if (typeof name === "string" && name !== "") {
1893
+ return name;
1894
+ }
1895
+ }
1896
+ return tag;
1897
+ }
1898
+
1899
+ // ../../node_modules/graphql/jsutils/instanceOf.mjs
1900
+ var isProduction = globalThis.process && // eslint-disable-next-line no-undef
1901
+ process.env.NODE_ENV === "production";
1902
+ var instanceOf = (
1903
+ /* c8 ignore next 6 */
1904
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
1905
+ isProduction ? function instanceOf2(value, constructor) {
1906
+ return value instanceof constructor;
1907
+ } : function instanceOf3(value, constructor) {
1908
+ if (value instanceof constructor) {
1909
+ return true;
1910
+ }
1911
+ if (typeof value === "object" && value !== null) {
1912
+ var _value$constructor;
1913
+ const className = constructor.prototype[Symbol.toStringTag];
1914
+ const valueClassName = (
1915
+ // We still need to support constructor's name to detect conflicts with older versions of this library.
1916
+ Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name
1917
+ );
1918
+ if (className === valueClassName) {
1919
+ const stringifiedValue = inspect(value);
1920
+ throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
1921
+
1922
+ Ensure that there is only one instance of "graphql" in the node_modules
1923
+ directory. If different versions of "graphql" are the dependencies of other
1924
+ relied on modules, use "resolutions" to ensure only one version is installed.
1925
+
1926
+ https://yarnpkg.com/en/docs/selective-version-resolutions
1927
+
1928
+ Duplicate "graphql" modules cannot be used at the same time since different
1929
+ versions may have different capabilities and behavior. The data from one
1930
+ version used in the function from another could produce confusing and
1931
+ spurious results.`);
1932
+ }
1933
+ }
1934
+ return false;
1935
+ }
1936
+ );
1937
+
1938
+ // ../../node_modules/graphql/language/source.mjs
1939
+ var Source = class {
1940
+ constructor(body, name = "GraphQL request", locationOffset = {
1941
+ line: 1,
1942
+ column: 1
1943
+ }) {
1944
+ typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
1945
+ this.body = body;
1946
+ this.name = name;
1947
+ this.locationOffset = locationOffset;
1948
+ this.locationOffset.line > 0 || devAssert(
1949
+ false,
1950
+ "line in locationOffset is 1-indexed and must be positive."
1951
+ );
1952
+ this.locationOffset.column > 0 || devAssert(
1953
+ false,
1954
+ "column in locationOffset is 1-indexed and must be positive."
1955
+ );
1956
+ }
1957
+ get [Symbol.toStringTag]() {
1958
+ return "Source";
1959
+ }
1960
+ };
1961
+ function isSource(source) {
1962
+ return instanceOf(source, Source);
1963
+ }
1964
+
1965
+ // ../../node_modules/graphql/language/parser.mjs
1966
+ function parse(source, options) {
1967
+ const parser = new Parser(source, options);
1968
+ const document = parser.parseDocument();
1969
+ Object.defineProperty(document, "tokenCount", {
1970
+ enumerable: false,
1971
+ value: parser.tokenCount
1972
+ });
1973
+ return document;
1974
+ }
1975
+ var Parser = class {
1976
+ constructor(source, options = {}) {
1977
+ const sourceObj = isSource(source) ? source : new Source(source);
1978
+ this._lexer = new Lexer(sourceObj);
1979
+ this._options = options;
1980
+ this._tokenCounter = 0;
1981
+ }
1982
+ get tokenCount() {
1983
+ return this._tokenCounter;
1984
+ }
1985
+ /**
1986
+ * Converts a name lex token into a name parse node.
1987
+ */
1988
+ parseName() {
1989
+ const token = this.expectToken(TokenKind.NAME);
1990
+ return this.node(token, {
1991
+ kind: Kind.NAME,
1992
+ value: token.value
1993
+ });
1994
+ }
1995
+ // Implements the parsing rules in the Document section.
1996
+ /**
1997
+ * Document : Definition+
1998
+ */
1999
+ parseDocument() {
2000
+ return this.node(this._lexer.token, {
2001
+ kind: Kind.DOCUMENT,
2002
+ definitions: this.many(
2003
+ TokenKind.SOF,
2004
+ this.parseDefinition,
2005
+ TokenKind.EOF
2006
+ )
2007
+ });
2008
+ }
2009
+ /**
2010
+ * Definition :
2011
+ * - ExecutableDefinition
2012
+ * - TypeSystemDefinition
2013
+ * - TypeSystemExtension
2014
+ *
2015
+ * ExecutableDefinition :
2016
+ * - OperationDefinition
2017
+ * - FragmentDefinition
2018
+ *
2019
+ * TypeSystemDefinition :
2020
+ * - SchemaDefinition
2021
+ * - TypeDefinition
2022
+ * - DirectiveDefinition
2023
+ *
2024
+ * TypeDefinition :
2025
+ * - ScalarTypeDefinition
2026
+ * - ObjectTypeDefinition
2027
+ * - InterfaceTypeDefinition
2028
+ * - UnionTypeDefinition
2029
+ * - EnumTypeDefinition
2030
+ * - InputObjectTypeDefinition
2031
+ */
2032
+ parseDefinition() {
2033
+ if (this.peek(TokenKind.BRACE_L)) {
2034
+ return this.parseOperationDefinition();
2035
+ }
2036
+ const hasDescription = this.peekDescription();
2037
+ const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
2038
+ if (keywordToken.kind === TokenKind.NAME) {
2039
+ switch (keywordToken.value) {
2040
+ case "schema":
2041
+ return this.parseSchemaDefinition();
2042
+ case "scalar":
2043
+ return this.parseScalarTypeDefinition();
2044
+ case "type":
2045
+ return this.parseObjectTypeDefinition();
2046
+ case "interface":
2047
+ return this.parseInterfaceTypeDefinition();
2048
+ case "union":
2049
+ return this.parseUnionTypeDefinition();
2050
+ case "enum":
2051
+ return this.parseEnumTypeDefinition();
2052
+ case "input":
2053
+ return this.parseInputObjectTypeDefinition();
2054
+ case "directive":
2055
+ return this.parseDirectiveDefinition();
2056
+ }
2057
+ if (hasDescription) {
2058
+ throw syntaxError(
2059
+ this._lexer.source,
2060
+ this._lexer.token.start,
2061
+ "Unexpected description, descriptions are supported only on type definitions."
2062
+ );
2063
+ }
2064
+ switch (keywordToken.value) {
2065
+ case "query":
2066
+ case "mutation":
2067
+ case "subscription":
2068
+ return this.parseOperationDefinition();
2069
+ case "fragment":
2070
+ return this.parseFragmentDefinition();
2071
+ case "extend":
2072
+ return this.parseTypeSystemExtension();
2073
+ }
2074
+ }
2075
+ throw this.unexpected(keywordToken);
2076
+ }
2077
+ // Implements the parsing rules in the Operations section.
2078
+ /**
2079
+ * OperationDefinition :
2080
+ * - SelectionSet
2081
+ * - OperationType Name? VariableDefinitions? Directives? SelectionSet
2082
+ */
2083
+ parseOperationDefinition() {
2084
+ const start = this._lexer.token;
2085
+ if (this.peek(TokenKind.BRACE_L)) {
2086
+ return this.node(start, {
2087
+ kind: Kind.OPERATION_DEFINITION,
2088
+ operation: OperationTypeNode.QUERY,
2089
+ name: void 0,
2090
+ variableDefinitions: [],
2091
+ directives: [],
2092
+ selectionSet: this.parseSelectionSet()
2093
+ });
2094
+ }
2095
+ const operation = this.parseOperationType();
2096
+ let name;
2097
+ if (this.peek(TokenKind.NAME)) {
2098
+ name = this.parseName();
2099
+ }
2100
+ return this.node(start, {
2101
+ kind: Kind.OPERATION_DEFINITION,
2102
+ operation,
2103
+ name,
2104
+ variableDefinitions: this.parseVariableDefinitions(),
2105
+ directives: this.parseDirectives(false),
2106
+ selectionSet: this.parseSelectionSet()
2107
+ });
2108
+ }
2109
+ /**
2110
+ * OperationType : one of query mutation subscription
2111
+ */
2112
+ parseOperationType() {
2113
+ const operationToken = this.expectToken(TokenKind.NAME);
2114
+ switch (operationToken.value) {
2115
+ case "query":
2116
+ return OperationTypeNode.QUERY;
2117
+ case "mutation":
2118
+ return OperationTypeNode.MUTATION;
2119
+ case "subscription":
2120
+ return OperationTypeNode.SUBSCRIPTION;
2121
+ }
2122
+ throw this.unexpected(operationToken);
2123
+ }
2124
+ /**
2125
+ * VariableDefinitions : ( VariableDefinition+ )
2126
+ */
2127
+ parseVariableDefinitions() {
2128
+ return this.optionalMany(
2129
+ TokenKind.PAREN_L,
2130
+ this.parseVariableDefinition,
2131
+ TokenKind.PAREN_R
2132
+ );
2133
+ }
2134
+ /**
2135
+ * VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
2136
+ */
2137
+ parseVariableDefinition() {
2138
+ return this.node(this._lexer.token, {
2139
+ kind: Kind.VARIABLE_DEFINITION,
2140
+ variable: this.parseVariable(),
2141
+ type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
2142
+ defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
2143
+ directives: this.parseConstDirectives()
2144
+ });
2145
+ }
2146
+ /**
2147
+ * Variable : $ Name
2148
+ */
2149
+ parseVariable() {
2150
+ const start = this._lexer.token;
2151
+ this.expectToken(TokenKind.DOLLAR);
2152
+ return this.node(start, {
2153
+ kind: Kind.VARIABLE,
2154
+ name: this.parseName()
2155
+ });
2156
+ }
2157
+ /**
2158
+ * ```
2159
+ * SelectionSet : { Selection+ }
2160
+ * ```
2161
+ */
2162
+ parseSelectionSet() {
2163
+ return this.node(this._lexer.token, {
2164
+ kind: Kind.SELECTION_SET,
2165
+ selections: this.many(
2166
+ TokenKind.BRACE_L,
2167
+ this.parseSelection,
2168
+ TokenKind.BRACE_R
2169
+ )
2170
+ });
2171
+ }
2172
+ /**
2173
+ * Selection :
2174
+ * - Field
2175
+ * - FragmentSpread
2176
+ * - InlineFragment
2177
+ */
2178
+ parseSelection() {
2179
+ return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
2180
+ }
2181
+ /**
2182
+ * Field : Alias? Name Arguments? Directives? SelectionSet?
2183
+ *
2184
+ * Alias : Name :
2185
+ */
2186
+ parseField() {
2187
+ const start = this._lexer.token;
2188
+ const nameOrAlias = this.parseName();
2189
+ let alias;
2190
+ let name;
2191
+ if (this.expectOptionalToken(TokenKind.COLON)) {
2192
+ alias = nameOrAlias;
2193
+ name = this.parseName();
2194
+ } else {
2195
+ name = nameOrAlias;
2196
+ }
2197
+ return this.node(start, {
2198
+ kind: Kind.FIELD,
2199
+ alias,
2200
+ name,
2201
+ arguments: this.parseArguments(false),
2202
+ directives: this.parseDirectives(false),
2203
+ selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
2204
+ });
2205
+ }
2206
+ /**
2207
+ * Arguments[Const] : ( Argument[?Const]+ )
2208
+ */
2209
+ parseArguments(isConst) {
2210
+ const item = isConst ? this.parseConstArgument : this.parseArgument;
2211
+ return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
2212
+ }
2213
+ /**
2214
+ * Argument[Const] : Name : Value[?Const]
2215
+ */
2216
+ parseArgument(isConst = false) {
2217
+ const start = this._lexer.token;
2218
+ const name = this.parseName();
2219
+ this.expectToken(TokenKind.COLON);
2220
+ return this.node(start, {
2221
+ kind: Kind.ARGUMENT,
2222
+ name,
2223
+ value: this.parseValueLiteral(isConst)
2224
+ });
2225
+ }
2226
+ parseConstArgument() {
2227
+ return this.parseArgument(true);
2228
+ }
2229
+ // Implements the parsing rules in the Fragments section.
2230
+ /**
2231
+ * Corresponds to both FragmentSpread and InlineFragment in the spec.
2232
+ *
2233
+ * FragmentSpread : ... FragmentName Directives?
2234
+ *
2235
+ * InlineFragment : ... TypeCondition? Directives? SelectionSet
2236
+ */
2237
+ parseFragment() {
2238
+ const start = this._lexer.token;
2239
+ this.expectToken(TokenKind.SPREAD);
2240
+ const hasTypeCondition = this.expectOptionalKeyword("on");
2241
+ if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
2242
+ return this.node(start, {
2243
+ kind: Kind.FRAGMENT_SPREAD,
2244
+ name: this.parseFragmentName(),
2245
+ directives: this.parseDirectives(false)
2246
+ });
2247
+ }
2248
+ return this.node(start, {
2249
+ kind: Kind.INLINE_FRAGMENT,
2250
+ typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
2251
+ directives: this.parseDirectives(false),
2252
+ selectionSet: this.parseSelectionSet()
2253
+ });
2254
+ }
2255
+ /**
2256
+ * FragmentDefinition :
2257
+ * - fragment FragmentName on TypeCondition Directives? SelectionSet
2258
+ *
2259
+ * TypeCondition : NamedType
2260
+ */
2261
+ parseFragmentDefinition() {
2262
+ const start = this._lexer.token;
2263
+ this.expectKeyword("fragment");
2264
+ if (this._options.allowLegacyFragmentVariables === true) {
2265
+ return this.node(start, {
2266
+ kind: Kind.FRAGMENT_DEFINITION,
2267
+ name: this.parseFragmentName(),
2268
+ variableDefinitions: this.parseVariableDefinitions(),
2269
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
2270
+ directives: this.parseDirectives(false),
2271
+ selectionSet: this.parseSelectionSet()
2272
+ });
2273
+ }
2274
+ return this.node(start, {
2275
+ kind: Kind.FRAGMENT_DEFINITION,
2276
+ name: this.parseFragmentName(),
2277
+ typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
2278
+ directives: this.parseDirectives(false),
2279
+ selectionSet: this.parseSelectionSet()
2280
+ });
2281
+ }
2282
+ /**
2283
+ * FragmentName : Name but not `on`
2284
+ */
2285
+ parseFragmentName() {
2286
+ if (this._lexer.token.value === "on") {
2287
+ throw this.unexpected();
2288
+ }
2289
+ return this.parseName();
2290
+ }
2291
+ // Implements the parsing rules in the Values section.
2292
+ /**
2293
+ * Value[Const] :
2294
+ * - [~Const] Variable
2295
+ * - IntValue
2296
+ * - FloatValue
2297
+ * - StringValue
2298
+ * - BooleanValue
2299
+ * - NullValue
2300
+ * - EnumValue
2301
+ * - ListValue[?Const]
2302
+ * - ObjectValue[?Const]
2303
+ *
2304
+ * BooleanValue : one of `true` `false`
2305
+ *
2306
+ * NullValue : `null`
2307
+ *
2308
+ * EnumValue : Name but not `true`, `false` or `null`
2309
+ */
2310
+ parseValueLiteral(isConst) {
2311
+ const token = this._lexer.token;
2312
+ switch (token.kind) {
2313
+ case TokenKind.BRACKET_L:
2314
+ return this.parseList(isConst);
2315
+ case TokenKind.BRACE_L:
2316
+ return this.parseObject(isConst);
2317
+ case TokenKind.INT:
2318
+ this.advanceLexer();
2319
+ return this.node(token, {
2320
+ kind: Kind.INT,
2321
+ value: token.value
2322
+ });
2323
+ case TokenKind.FLOAT:
2324
+ this.advanceLexer();
2325
+ return this.node(token, {
2326
+ kind: Kind.FLOAT,
2327
+ value: token.value
2328
+ });
2329
+ case TokenKind.STRING:
2330
+ case TokenKind.BLOCK_STRING:
2331
+ return this.parseStringLiteral();
2332
+ case TokenKind.NAME:
2333
+ this.advanceLexer();
2334
+ switch (token.value) {
2335
+ case "true":
2336
+ return this.node(token, {
2337
+ kind: Kind.BOOLEAN,
2338
+ value: true
2339
+ });
2340
+ case "false":
2341
+ return this.node(token, {
2342
+ kind: Kind.BOOLEAN,
2343
+ value: false
2344
+ });
2345
+ case "null":
2346
+ return this.node(token, {
2347
+ kind: Kind.NULL
2348
+ });
2349
+ default:
2350
+ return this.node(token, {
2351
+ kind: Kind.ENUM,
2352
+ value: token.value
2353
+ });
2354
+ }
2355
+ case TokenKind.DOLLAR:
2356
+ if (isConst) {
2357
+ this.expectToken(TokenKind.DOLLAR);
2358
+ if (this._lexer.token.kind === TokenKind.NAME) {
2359
+ const varName = this._lexer.token.value;
2360
+ throw syntaxError(
2361
+ this._lexer.source,
2362
+ token.start,
2363
+ `Unexpected variable "$${varName}" in constant value.`
2364
+ );
2365
+ } else {
2366
+ throw this.unexpected(token);
2367
+ }
2368
+ }
2369
+ return this.parseVariable();
2370
+ default:
2371
+ throw this.unexpected();
2372
+ }
2373
+ }
2374
+ parseConstValueLiteral() {
2375
+ return this.parseValueLiteral(true);
2376
+ }
2377
+ parseStringLiteral() {
2378
+ const token = this._lexer.token;
2379
+ this.advanceLexer();
2380
+ return this.node(token, {
2381
+ kind: Kind.STRING,
2382
+ value: token.value,
2383
+ block: token.kind === TokenKind.BLOCK_STRING
2384
+ });
2385
+ }
2386
+ /**
2387
+ * ListValue[Const] :
2388
+ * - [ ]
2389
+ * - [ Value[?Const]+ ]
2390
+ */
2391
+ parseList(isConst) {
2392
+ const item = () => this.parseValueLiteral(isConst);
2393
+ return this.node(this._lexer.token, {
2394
+ kind: Kind.LIST,
2395
+ values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
2396
+ });
2397
+ }
2398
+ /**
2399
+ * ```
2400
+ * ObjectValue[Const] :
2401
+ * - { }
2402
+ * - { ObjectField[?Const]+ }
2403
+ * ```
2404
+ */
2405
+ parseObject(isConst) {
2406
+ const item = () => this.parseObjectField(isConst);
2407
+ return this.node(this._lexer.token, {
2408
+ kind: Kind.OBJECT,
2409
+ fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
2410
+ });
2411
+ }
2412
+ /**
2413
+ * ObjectField[Const] : Name : Value[?Const]
2414
+ */
2415
+ parseObjectField(isConst) {
2416
+ const start = this._lexer.token;
2417
+ const name = this.parseName();
2418
+ this.expectToken(TokenKind.COLON);
2419
+ return this.node(start, {
2420
+ kind: Kind.OBJECT_FIELD,
2421
+ name,
2422
+ value: this.parseValueLiteral(isConst)
2423
+ });
2424
+ }
2425
+ // Implements the parsing rules in the Directives section.
2426
+ /**
2427
+ * Directives[Const] : Directive[?Const]+
2428
+ */
2429
+ parseDirectives(isConst) {
2430
+ const directives = [];
2431
+ while (this.peek(TokenKind.AT)) {
2432
+ directives.push(this.parseDirective(isConst));
2433
+ }
2434
+ return directives;
2435
+ }
2436
+ parseConstDirectives() {
2437
+ return this.parseDirectives(true);
2438
+ }
2439
+ /**
2440
+ * ```
2441
+ * Directive[Const] : @ Name Arguments[?Const]?
2442
+ * ```
2443
+ */
2444
+ parseDirective(isConst) {
2445
+ const start = this._lexer.token;
2446
+ this.expectToken(TokenKind.AT);
2447
+ return this.node(start, {
2448
+ kind: Kind.DIRECTIVE,
2449
+ name: this.parseName(),
2450
+ arguments: this.parseArguments(isConst)
2451
+ });
2452
+ }
2453
+ // Implements the parsing rules in the Types section.
2454
+ /**
2455
+ * Type :
2456
+ * - NamedType
2457
+ * - ListType
2458
+ * - NonNullType
2459
+ */
2460
+ parseTypeReference() {
2461
+ const start = this._lexer.token;
2462
+ let type;
2463
+ if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
2464
+ const innerType = this.parseTypeReference();
2465
+ this.expectToken(TokenKind.BRACKET_R);
2466
+ type = this.node(start, {
2467
+ kind: Kind.LIST_TYPE,
2468
+ type: innerType
2469
+ });
2470
+ } else {
2471
+ type = this.parseNamedType();
2472
+ }
2473
+ if (this.expectOptionalToken(TokenKind.BANG)) {
2474
+ return this.node(start, {
2475
+ kind: Kind.NON_NULL_TYPE,
2476
+ type
2477
+ });
2478
+ }
2479
+ return type;
2480
+ }
2481
+ /**
2482
+ * NamedType : Name
2483
+ */
2484
+ parseNamedType() {
2485
+ return this.node(this._lexer.token, {
2486
+ kind: Kind.NAMED_TYPE,
2487
+ name: this.parseName()
2488
+ });
2489
+ }
2490
+ // Implements the parsing rules in the Type Definition section.
2491
+ peekDescription() {
2492
+ return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
2493
+ }
2494
+ /**
2495
+ * Description : StringValue
2496
+ */
2497
+ parseDescription() {
2498
+ if (this.peekDescription()) {
2499
+ return this.parseStringLiteral();
2500
+ }
2501
+ }
2502
+ /**
2503
+ * ```
2504
+ * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
2505
+ * ```
2506
+ */
2507
+ parseSchemaDefinition() {
2508
+ const start = this._lexer.token;
2509
+ const description = this.parseDescription();
2510
+ this.expectKeyword("schema");
2511
+ const directives = this.parseConstDirectives();
2512
+ const operationTypes = this.many(
2513
+ TokenKind.BRACE_L,
2514
+ this.parseOperationTypeDefinition,
2515
+ TokenKind.BRACE_R
2516
+ );
2517
+ return this.node(start, {
2518
+ kind: Kind.SCHEMA_DEFINITION,
2519
+ description,
2520
+ directives,
2521
+ operationTypes
2522
+ });
2523
+ }
2524
+ /**
2525
+ * OperationTypeDefinition : OperationType : NamedType
2526
+ */
2527
+ parseOperationTypeDefinition() {
2528
+ const start = this._lexer.token;
2529
+ const operation = this.parseOperationType();
2530
+ this.expectToken(TokenKind.COLON);
2531
+ const type = this.parseNamedType();
2532
+ return this.node(start, {
2533
+ kind: Kind.OPERATION_TYPE_DEFINITION,
2534
+ operation,
2535
+ type
2536
+ });
2537
+ }
2538
+ /**
2539
+ * ScalarTypeDefinition : Description? scalar Name Directives[Const]?
2540
+ */
2541
+ parseScalarTypeDefinition() {
2542
+ const start = this._lexer.token;
2543
+ const description = this.parseDescription();
2544
+ this.expectKeyword("scalar");
2545
+ const name = this.parseName();
2546
+ const directives = this.parseConstDirectives();
2547
+ return this.node(start, {
2548
+ kind: Kind.SCALAR_TYPE_DEFINITION,
2549
+ description,
2550
+ name,
2551
+ directives
2552
+ });
2553
+ }
2554
+ /**
2555
+ * ObjectTypeDefinition :
2556
+ * Description?
2557
+ * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
2558
+ */
2559
+ parseObjectTypeDefinition() {
2560
+ const start = this._lexer.token;
2561
+ const description = this.parseDescription();
2562
+ this.expectKeyword("type");
2563
+ const name = this.parseName();
2564
+ const interfaces = this.parseImplementsInterfaces();
2565
+ const directives = this.parseConstDirectives();
2566
+ const fields = this.parseFieldsDefinition();
2567
+ return this.node(start, {
2568
+ kind: Kind.OBJECT_TYPE_DEFINITION,
2569
+ description,
2570
+ name,
2571
+ interfaces,
2572
+ directives,
2573
+ fields
2574
+ });
2575
+ }
2576
+ /**
2577
+ * ImplementsInterfaces :
2578
+ * - implements `&`? NamedType
2579
+ * - ImplementsInterfaces & NamedType
2580
+ */
2581
+ parseImplementsInterfaces() {
2582
+ return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
2583
+ }
2584
+ /**
2585
+ * ```
2586
+ * FieldsDefinition : { FieldDefinition+ }
2587
+ * ```
2588
+ */
2589
+ parseFieldsDefinition() {
2590
+ return this.optionalMany(
2591
+ TokenKind.BRACE_L,
2592
+ this.parseFieldDefinition,
2593
+ TokenKind.BRACE_R
2594
+ );
2595
+ }
2596
+ /**
2597
+ * FieldDefinition :
2598
+ * - Description? Name ArgumentsDefinition? : Type Directives[Const]?
2599
+ */
2600
+ parseFieldDefinition() {
2601
+ const start = this._lexer.token;
2602
+ const description = this.parseDescription();
2603
+ const name = this.parseName();
2604
+ const args = this.parseArgumentDefs();
2605
+ this.expectToken(TokenKind.COLON);
2606
+ const type = this.parseTypeReference();
2607
+ const directives = this.parseConstDirectives();
2608
+ return this.node(start, {
2609
+ kind: Kind.FIELD_DEFINITION,
2610
+ description,
2611
+ name,
2612
+ arguments: args,
2613
+ type,
2614
+ directives
2615
+ });
2616
+ }
2617
+ /**
2618
+ * ArgumentsDefinition : ( InputValueDefinition+ )
2619
+ */
2620
+ parseArgumentDefs() {
2621
+ return this.optionalMany(
2622
+ TokenKind.PAREN_L,
2623
+ this.parseInputValueDef,
2624
+ TokenKind.PAREN_R
2625
+ );
2626
+ }
2627
+ /**
2628
+ * InputValueDefinition :
2629
+ * - Description? Name : Type DefaultValue? Directives[Const]?
2630
+ */
2631
+ parseInputValueDef() {
2632
+ const start = this._lexer.token;
2633
+ const description = this.parseDescription();
2634
+ const name = this.parseName();
2635
+ this.expectToken(TokenKind.COLON);
2636
+ const type = this.parseTypeReference();
2637
+ let defaultValue;
2638
+ if (this.expectOptionalToken(TokenKind.EQUALS)) {
2639
+ defaultValue = this.parseConstValueLiteral();
2640
+ }
2641
+ const directives = this.parseConstDirectives();
2642
+ return this.node(start, {
2643
+ kind: Kind.INPUT_VALUE_DEFINITION,
2644
+ description,
2645
+ name,
2646
+ type,
2647
+ defaultValue,
2648
+ directives
2649
+ });
2650
+ }
2651
+ /**
2652
+ * InterfaceTypeDefinition :
2653
+ * - Description? interface Name Directives[Const]? FieldsDefinition?
2654
+ */
2655
+ parseInterfaceTypeDefinition() {
2656
+ const start = this._lexer.token;
2657
+ const description = this.parseDescription();
2658
+ this.expectKeyword("interface");
2659
+ const name = this.parseName();
2660
+ const interfaces = this.parseImplementsInterfaces();
2661
+ const directives = this.parseConstDirectives();
2662
+ const fields = this.parseFieldsDefinition();
2663
+ return this.node(start, {
2664
+ kind: Kind.INTERFACE_TYPE_DEFINITION,
2665
+ description,
2666
+ name,
2667
+ interfaces,
2668
+ directives,
2669
+ fields
2670
+ });
2671
+ }
2672
+ /**
2673
+ * UnionTypeDefinition :
2674
+ * - Description? union Name Directives[Const]? UnionMemberTypes?
2675
+ */
2676
+ parseUnionTypeDefinition() {
2677
+ const start = this._lexer.token;
2678
+ const description = this.parseDescription();
2679
+ this.expectKeyword("union");
2680
+ const name = this.parseName();
2681
+ const directives = this.parseConstDirectives();
2682
+ const types = this.parseUnionMemberTypes();
2683
+ return this.node(start, {
2684
+ kind: Kind.UNION_TYPE_DEFINITION,
2685
+ description,
2686
+ name,
2687
+ directives,
2688
+ types
2689
+ });
2690
+ }
2691
+ /**
2692
+ * UnionMemberTypes :
2693
+ * - = `|`? NamedType
2694
+ * - UnionMemberTypes | NamedType
2695
+ */
2696
+ parseUnionMemberTypes() {
2697
+ return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
2698
+ }
2699
+ /**
2700
+ * EnumTypeDefinition :
2701
+ * - Description? enum Name Directives[Const]? EnumValuesDefinition?
2702
+ */
2703
+ parseEnumTypeDefinition() {
2704
+ const start = this._lexer.token;
2705
+ const description = this.parseDescription();
2706
+ this.expectKeyword("enum");
2707
+ const name = this.parseName();
2708
+ const directives = this.parseConstDirectives();
2709
+ const values = this.parseEnumValuesDefinition();
2710
+ return this.node(start, {
2711
+ kind: Kind.ENUM_TYPE_DEFINITION,
2712
+ description,
2713
+ name,
2714
+ directives,
2715
+ values
2716
+ });
2717
+ }
2718
+ /**
2719
+ * ```
2720
+ * EnumValuesDefinition : { EnumValueDefinition+ }
2721
+ * ```
2722
+ */
2723
+ parseEnumValuesDefinition() {
2724
+ return this.optionalMany(
2725
+ TokenKind.BRACE_L,
2726
+ this.parseEnumValueDefinition,
2727
+ TokenKind.BRACE_R
2728
+ );
2729
+ }
2730
+ /**
2731
+ * EnumValueDefinition : Description? EnumValue Directives[Const]?
2732
+ */
2733
+ parseEnumValueDefinition() {
2734
+ const start = this._lexer.token;
2735
+ const description = this.parseDescription();
2736
+ const name = this.parseEnumValueName();
2737
+ const directives = this.parseConstDirectives();
2738
+ return this.node(start, {
2739
+ kind: Kind.ENUM_VALUE_DEFINITION,
2740
+ description,
2741
+ name,
2742
+ directives
2743
+ });
2744
+ }
2745
+ /**
2746
+ * EnumValue : Name but not `true`, `false` or `null`
2747
+ */
2748
+ parseEnumValueName() {
2749
+ if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") {
2750
+ throw syntaxError(
2751
+ this._lexer.source,
2752
+ this._lexer.token.start,
2753
+ `${getTokenDesc(
2754
+ this._lexer.token
2755
+ )} is reserved and cannot be used for an enum value.`
2756
+ );
2757
+ }
2758
+ return this.parseName();
2759
+ }
2760
+ /**
2761
+ * InputObjectTypeDefinition :
2762
+ * - Description? input Name Directives[Const]? InputFieldsDefinition?
2763
+ */
2764
+ parseInputObjectTypeDefinition() {
2765
+ const start = this._lexer.token;
2766
+ const description = this.parseDescription();
2767
+ this.expectKeyword("input");
2768
+ const name = this.parseName();
2769
+ const directives = this.parseConstDirectives();
2770
+ const fields = this.parseInputFieldsDefinition();
2771
+ return this.node(start, {
2772
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
2773
+ description,
2774
+ name,
2775
+ directives,
2776
+ fields
2777
+ });
2778
+ }
2779
+ /**
2780
+ * ```
2781
+ * InputFieldsDefinition : { InputValueDefinition+ }
2782
+ * ```
2783
+ */
2784
+ parseInputFieldsDefinition() {
2785
+ return this.optionalMany(
2786
+ TokenKind.BRACE_L,
2787
+ this.parseInputValueDef,
2788
+ TokenKind.BRACE_R
2789
+ );
2790
+ }
2791
+ /**
2792
+ * TypeSystemExtension :
2793
+ * - SchemaExtension
2794
+ * - TypeExtension
2795
+ *
2796
+ * TypeExtension :
2797
+ * - ScalarTypeExtension
2798
+ * - ObjectTypeExtension
2799
+ * - InterfaceTypeExtension
2800
+ * - UnionTypeExtension
2801
+ * - EnumTypeExtension
2802
+ * - InputObjectTypeDefinition
2803
+ */
2804
+ parseTypeSystemExtension() {
2805
+ const keywordToken = this._lexer.lookahead();
2806
+ if (keywordToken.kind === TokenKind.NAME) {
2807
+ switch (keywordToken.value) {
2808
+ case "schema":
2809
+ return this.parseSchemaExtension();
2810
+ case "scalar":
2811
+ return this.parseScalarTypeExtension();
2812
+ case "type":
2813
+ return this.parseObjectTypeExtension();
2814
+ case "interface":
2815
+ return this.parseInterfaceTypeExtension();
2816
+ case "union":
2817
+ return this.parseUnionTypeExtension();
2818
+ case "enum":
2819
+ return this.parseEnumTypeExtension();
2820
+ case "input":
2821
+ return this.parseInputObjectTypeExtension();
2822
+ }
2823
+ }
2824
+ throw this.unexpected(keywordToken);
2825
+ }
2826
+ /**
2827
+ * ```
2828
+ * SchemaExtension :
2829
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
2830
+ * - extend schema Directives[Const]
2831
+ * ```
2832
+ */
2833
+ parseSchemaExtension() {
2834
+ const start = this._lexer.token;
2835
+ this.expectKeyword("extend");
2836
+ this.expectKeyword("schema");
2837
+ const directives = this.parseConstDirectives();
2838
+ const operationTypes = this.optionalMany(
2839
+ TokenKind.BRACE_L,
2840
+ this.parseOperationTypeDefinition,
2841
+ TokenKind.BRACE_R
2842
+ );
2843
+ if (directives.length === 0 && operationTypes.length === 0) {
2844
+ throw this.unexpected();
2845
+ }
2846
+ return this.node(start, {
2847
+ kind: Kind.SCHEMA_EXTENSION,
2848
+ directives,
2849
+ operationTypes
2850
+ });
2851
+ }
2852
+ /**
2853
+ * ScalarTypeExtension :
2854
+ * - extend scalar Name Directives[Const]
2855
+ */
2856
+ parseScalarTypeExtension() {
2857
+ const start = this._lexer.token;
2858
+ this.expectKeyword("extend");
2859
+ this.expectKeyword("scalar");
2860
+ const name = this.parseName();
2861
+ const directives = this.parseConstDirectives();
2862
+ if (directives.length === 0) {
2863
+ throw this.unexpected();
2864
+ }
2865
+ return this.node(start, {
2866
+ kind: Kind.SCALAR_TYPE_EXTENSION,
2867
+ name,
2868
+ directives
2869
+ });
2870
+ }
2871
+ /**
2872
+ * ObjectTypeExtension :
2873
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2874
+ * - extend type Name ImplementsInterfaces? Directives[Const]
2875
+ * - extend type Name ImplementsInterfaces
2876
+ */
2877
+ parseObjectTypeExtension() {
2878
+ const start = this._lexer.token;
2879
+ this.expectKeyword("extend");
2880
+ this.expectKeyword("type");
2881
+ const name = this.parseName();
2882
+ const interfaces = this.parseImplementsInterfaces();
2883
+ const directives = this.parseConstDirectives();
2884
+ const fields = this.parseFieldsDefinition();
2885
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
2886
+ throw this.unexpected();
2887
+ }
2888
+ return this.node(start, {
2889
+ kind: Kind.OBJECT_TYPE_EXTENSION,
2890
+ name,
2891
+ interfaces,
2892
+ directives,
2893
+ fields
2894
+ });
2895
+ }
2896
+ /**
2897
+ * InterfaceTypeExtension :
2898
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
2899
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
2900
+ * - extend interface Name ImplementsInterfaces
2901
+ */
2902
+ parseInterfaceTypeExtension() {
2903
+ const start = this._lexer.token;
2904
+ this.expectKeyword("extend");
2905
+ this.expectKeyword("interface");
2906
+ const name = this.parseName();
2907
+ const interfaces = this.parseImplementsInterfaces();
2908
+ const directives = this.parseConstDirectives();
2909
+ const fields = this.parseFieldsDefinition();
2910
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
2911
+ throw this.unexpected();
2912
+ }
2913
+ return this.node(start, {
2914
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
2915
+ name,
2916
+ interfaces,
2917
+ directives,
2918
+ fields
2919
+ });
2920
+ }
2921
+ /**
2922
+ * UnionTypeExtension :
2923
+ * - extend union Name Directives[Const]? UnionMemberTypes
2924
+ * - extend union Name Directives[Const]
2925
+ */
2926
+ parseUnionTypeExtension() {
2927
+ const start = this._lexer.token;
2928
+ this.expectKeyword("extend");
2929
+ this.expectKeyword("union");
2930
+ const name = this.parseName();
2931
+ const directives = this.parseConstDirectives();
2932
+ const types = this.parseUnionMemberTypes();
2933
+ if (directives.length === 0 && types.length === 0) {
2934
+ throw this.unexpected();
2935
+ }
2936
+ return this.node(start, {
2937
+ kind: Kind.UNION_TYPE_EXTENSION,
2938
+ name,
2939
+ directives,
2940
+ types
2941
+ });
2942
+ }
2943
+ /**
2944
+ * EnumTypeExtension :
2945
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
2946
+ * - extend enum Name Directives[Const]
2947
+ */
2948
+ parseEnumTypeExtension() {
2949
+ const start = this._lexer.token;
2950
+ this.expectKeyword("extend");
2951
+ this.expectKeyword("enum");
2952
+ const name = this.parseName();
2953
+ const directives = this.parseConstDirectives();
2954
+ const values = this.parseEnumValuesDefinition();
2955
+ if (directives.length === 0 && values.length === 0) {
2956
+ throw this.unexpected();
2957
+ }
2958
+ return this.node(start, {
2959
+ kind: Kind.ENUM_TYPE_EXTENSION,
2960
+ name,
2961
+ directives,
2962
+ values
2963
+ });
2964
+ }
2965
+ /**
2966
+ * InputObjectTypeExtension :
2967
+ * - extend input Name Directives[Const]? InputFieldsDefinition
2968
+ * - extend input Name Directives[Const]
2969
+ */
2970
+ parseInputObjectTypeExtension() {
2971
+ const start = this._lexer.token;
2972
+ this.expectKeyword("extend");
2973
+ this.expectKeyword("input");
2974
+ const name = this.parseName();
2975
+ const directives = this.parseConstDirectives();
2976
+ const fields = this.parseInputFieldsDefinition();
2977
+ if (directives.length === 0 && fields.length === 0) {
2978
+ throw this.unexpected();
2979
+ }
2980
+ return this.node(start, {
2981
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
2982
+ name,
2983
+ directives,
2984
+ fields
2985
+ });
2986
+ }
2987
+ /**
2988
+ * ```
2989
+ * DirectiveDefinition :
2990
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
2991
+ * ```
2992
+ */
2993
+ parseDirectiveDefinition() {
2994
+ const start = this._lexer.token;
2995
+ const description = this.parseDescription();
2996
+ this.expectKeyword("directive");
2997
+ this.expectToken(TokenKind.AT);
2998
+ const name = this.parseName();
2999
+ const args = this.parseArgumentDefs();
3000
+ const repeatable = this.expectOptionalKeyword("repeatable");
3001
+ this.expectKeyword("on");
3002
+ const locations = this.parseDirectiveLocations();
3003
+ return this.node(start, {
3004
+ kind: Kind.DIRECTIVE_DEFINITION,
3005
+ description,
3006
+ name,
3007
+ arguments: args,
3008
+ repeatable,
3009
+ locations
3010
+ });
3011
+ }
3012
+ /**
3013
+ * DirectiveLocations :
3014
+ * - `|`? DirectiveLocation
3015
+ * - DirectiveLocations | DirectiveLocation
3016
+ */
3017
+ parseDirectiveLocations() {
3018
+ return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
3019
+ }
3020
+ /*
3021
+ * DirectiveLocation :
3022
+ * - ExecutableDirectiveLocation
3023
+ * - TypeSystemDirectiveLocation
3024
+ *
3025
+ * ExecutableDirectiveLocation : one of
3026
+ * `QUERY`
3027
+ * `MUTATION`
3028
+ * `SUBSCRIPTION`
3029
+ * `FIELD`
3030
+ * `FRAGMENT_DEFINITION`
3031
+ * `FRAGMENT_SPREAD`
3032
+ * `INLINE_FRAGMENT`
3033
+ *
3034
+ * TypeSystemDirectiveLocation : one of
3035
+ * `SCHEMA`
3036
+ * `SCALAR`
3037
+ * `OBJECT`
3038
+ * `FIELD_DEFINITION`
3039
+ * `ARGUMENT_DEFINITION`
3040
+ * `INTERFACE`
3041
+ * `UNION`
3042
+ * `ENUM`
3043
+ * `ENUM_VALUE`
3044
+ * `INPUT_OBJECT`
3045
+ * `INPUT_FIELD_DEFINITION`
3046
+ */
3047
+ parseDirectiveLocation() {
3048
+ const start = this._lexer.token;
3049
+ const name = this.parseName();
3050
+ if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
3051
+ return name;
3052
+ }
3053
+ throw this.unexpected(start);
3054
+ }
3055
+ // Core parsing utility functions
3056
+ /**
3057
+ * Returns a node that, if configured to do so, sets a "loc" field as a
3058
+ * location object, used to identify the place in the source that created a
3059
+ * given parsed object.
3060
+ */
3061
+ node(startToken, node) {
3062
+ if (this._options.noLocation !== true) {
3063
+ node.loc = new Location(
3064
+ startToken,
3065
+ this._lexer.lastToken,
3066
+ this._lexer.source
3067
+ );
3068
+ }
3069
+ return node;
3070
+ }
3071
+ /**
3072
+ * Determines if the next token is of a given kind
3073
+ */
3074
+ peek(kind) {
3075
+ return this._lexer.token.kind === kind;
3076
+ }
3077
+ /**
3078
+ * If the next token is of the given kind, return that token after advancing the lexer.
3079
+ * Otherwise, do not change the parser state and throw an error.
3080
+ */
3081
+ expectToken(kind) {
3082
+ const token = this._lexer.token;
3083
+ if (token.kind === kind) {
3084
+ this.advanceLexer();
3085
+ return token;
3086
+ }
3087
+ throw syntaxError(
3088
+ this._lexer.source,
3089
+ token.start,
3090
+ `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
3091
+ );
3092
+ }
3093
+ /**
3094
+ * If the next token is of the given kind, return "true" after advancing the lexer.
3095
+ * Otherwise, do not change the parser state and return "false".
3096
+ */
3097
+ expectOptionalToken(kind) {
3098
+ const token = this._lexer.token;
3099
+ if (token.kind === kind) {
3100
+ this.advanceLexer();
3101
+ return true;
3102
+ }
3103
+ return false;
3104
+ }
3105
+ /**
3106
+ * If the next token is a given keyword, advance the lexer.
3107
+ * Otherwise, do not change the parser state and throw an error.
3108
+ */
3109
+ expectKeyword(value) {
3110
+ const token = this._lexer.token;
3111
+ if (token.kind === TokenKind.NAME && token.value === value) {
3112
+ this.advanceLexer();
3113
+ } else {
3114
+ throw syntaxError(
3115
+ this._lexer.source,
3116
+ token.start,
3117
+ `Expected "${value}", found ${getTokenDesc(token)}.`
3118
+ );
3119
+ }
3120
+ }
3121
+ /**
3122
+ * If the next token is a given keyword, return "true" after advancing the lexer.
3123
+ * Otherwise, do not change the parser state and return "false".
3124
+ */
3125
+ expectOptionalKeyword(value) {
3126
+ const token = this._lexer.token;
3127
+ if (token.kind === TokenKind.NAME && token.value === value) {
3128
+ this.advanceLexer();
3129
+ return true;
3130
+ }
3131
+ return false;
3132
+ }
3133
+ /**
3134
+ * Helper function for creating an error when an unexpected lexed token is encountered.
3135
+ */
3136
+ unexpected(atToken) {
3137
+ const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
3138
+ return syntaxError(
3139
+ this._lexer.source,
3140
+ token.start,
3141
+ `Unexpected ${getTokenDesc(token)}.`
3142
+ );
3143
+ }
3144
+ /**
3145
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
3146
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
3147
+ * Advances the parser to the next lex token after the closing token.
3148
+ */
3149
+ any(openKind, parseFn, closeKind) {
3150
+ this.expectToken(openKind);
3151
+ const nodes = [];
3152
+ while (!this.expectOptionalToken(closeKind)) {
3153
+ nodes.push(parseFn.call(this));
3154
+ }
3155
+ return nodes;
3156
+ }
3157
+ /**
3158
+ * Returns a list of parse nodes, determined by the parseFn.
3159
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
3160
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
3161
+ * Advances the parser to the next lex token after the closing token.
3162
+ */
3163
+ optionalMany(openKind, parseFn, closeKind) {
3164
+ if (this.expectOptionalToken(openKind)) {
3165
+ const nodes = [];
3166
+ do {
3167
+ nodes.push(parseFn.call(this));
3168
+ } while (!this.expectOptionalToken(closeKind));
3169
+ return nodes;
3170
+ }
3171
+ return [];
3172
+ }
3173
+ /**
3174
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
3175
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
3176
+ * Advances the parser to the next lex token after the closing token.
3177
+ */
3178
+ many(openKind, parseFn, closeKind) {
3179
+ this.expectToken(openKind);
3180
+ const nodes = [];
3181
+ do {
3182
+ nodes.push(parseFn.call(this));
3183
+ } while (!this.expectOptionalToken(closeKind));
3184
+ return nodes;
3185
+ }
3186
+ /**
3187
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
3188
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
3189
+ * Advances the parser to the next lex token after last item in the list.
3190
+ */
3191
+ delimitedMany(delimiterKind, parseFn) {
3192
+ this.expectOptionalToken(delimiterKind);
3193
+ const nodes = [];
3194
+ do {
3195
+ nodes.push(parseFn.call(this));
3196
+ } while (this.expectOptionalToken(delimiterKind));
3197
+ return nodes;
3198
+ }
3199
+ advanceLexer() {
3200
+ const { maxTokens } = this._options;
3201
+ const token = this._lexer.advance();
3202
+ if (token.kind !== TokenKind.EOF) {
3203
+ ++this._tokenCounter;
3204
+ if (maxTokens !== void 0 && this._tokenCounter > maxTokens) {
3205
+ throw syntaxError(
3206
+ this._lexer.source,
3207
+ token.start,
3208
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`
3209
+ );
3210
+ }
3211
+ }
3212
+ }
3213
+ };
3214
+ function getTokenDesc(token) {
3215
+ const value = token.value;
3216
+ return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
3217
+ }
3218
+ function getTokenKindDesc(kind) {
3219
+ return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
3220
+ }
3221
+
3222
+ // src/lib/bendystraw/queries/shop.ts
3223
+ var ShopPurchasesDocument = parse(
3224
+ /* GraphQL */
3225
+ `
3226
+ query ShopPurchases($where: mintNftEventFilter, $limit: Int, $offset: Int) {
3227
+ mintNftEvents(
3228
+ where: $where
3229
+ orderBy: "timestamp"
3230
+ orderDirection: "desc"
3231
+ limit: $limit
3232
+ offset: $offset
3233
+ ) {
3234
+ totalCount
3235
+ items {
3236
+ chainId
3237
+ projectId
3238
+ timestamp
3239
+ txHash
3240
+ beneficiary
3241
+ tierId
3242
+ tokenId
3243
+ totalAmountPaid
3244
+ hook
3245
+ }
3246
+ }
3247
+ }
3248
+ `
3249
+ );
3250
+ var OwnedShopItemsDocument = parse(
3251
+ /* GraphQL */
3252
+ `
3253
+ query OwnedShopItems($where: nftFilter, $limit: Int, $offset: Int) {
3254
+ nfts(
3255
+ where: $where
3256
+ orderBy: "createdAt"
3257
+ orderDirection: "desc"
3258
+ limit: $limit
3259
+ offset: $offset
3260
+ ) {
3261
+ totalCount
3262
+ items {
3263
+ chainId
3264
+ projectId
3265
+ createdAt
3266
+ mintTx
3267
+ hook {
3268
+ address
3269
+ }
3270
+ tokenId
3271
+ owner
3272
+ tierId
3273
+ }
3274
+ }
3275
+ }
3276
+ `
3277
+ );
3278
+
3279
+ // src/hooks/shop/useShopPurchases.ts
3280
+ function useShopPurchases(args) {
3281
+ const { beneficiary, limit = 100, offset = 0, enabled = true } = args ?? {};
3282
+ const { projectId, version } = useJBContractContext();
3283
+ const chainId = useJBChainId();
3284
+ const { data, ...rest } = useBendystrawQuery(
3285
+ ShopPurchasesDocument,
3286
+ {
3287
+ where: {
3288
+ projectId: Number(projectId),
3289
+ chainId: Number(chainId),
3290
+ version: Number(version),
3291
+ ...beneficiary ? { beneficiary: beneficiary.toLowerCase() } : {}
3292
+ },
3293
+ limit,
3294
+ offset
3295
+ },
3296
+ { enabled: !!chainId && !!projectId && enabled }
3297
+ );
3298
+ const purchases = useMemo3(
3299
+ () => data?.mintNftEvents.items.map((item) => ({
3300
+ ...item,
3301
+ chainId: Number(item.chainId),
3302
+ projectId: Number(item.projectId),
3303
+ timestamp: Number(item.timestamp),
3304
+ tierId: Number(item.tierId),
3305
+ tokenId: String(item.tokenId),
3306
+ totalAmountPaid: String(item.totalAmountPaid)
3307
+ })),
3308
+ [data]
3309
+ );
3310
+ return {
3311
+ data: purchases,
3312
+ totalCount: data?.mintNftEvents.totalCount,
3313
+ ...rest
3314
+ };
3315
+ }
3316
+
3317
+ // src/hooks/shop/useOwnedShopItems.ts
3318
+ import { useMemo as useMemo4 } from "react";
3319
+ function useOwnedShopItems(args) {
3320
+ const { owner, limit = 100, offset = 0, enabled = true } = args;
3321
+ const { projectId, version } = useJBContractContext();
3322
+ const chainId = useJBChainId();
3323
+ const { data, ...rest } = useBendystrawQuery(
3324
+ OwnedShopItemsDocument,
3325
+ {
3326
+ where: {
3327
+ projectId: Number(projectId),
3328
+ chainId: Number(chainId),
3329
+ version: Number(version),
3330
+ owner: (owner ?? "").toLowerCase()
3331
+ },
3332
+ limit,
3333
+ offset
3334
+ },
3335
+ { enabled: !!chainId && !!projectId && !!owner && enabled }
3336
+ );
3337
+ const items = useMemo4(
3338
+ () => data?.nfts.items.map((item) => ({
3339
+ chainId: Number(item.chainId),
3340
+ projectId: Number(item.projectId),
3341
+ createdAt: Number(item.createdAt),
3342
+ mintTx: item.mintTx,
3343
+ hook: item.hook?.address ?? "",
3344
+ tokenId: String(item.tokenId),
3345
+ owner: String(item.owner).toLowerCase(),
3346
+ tierId: Number(item.tierId)
3347
+ })),
3348
+ [data]
3349
+ );
3350
+ return {
3351
+ data: items,
3352
+ totalCount: data?.nfts.totalCount,
3353
+ ...rest
3354
+ };
3355
+ }
3356
+
720
3357
  // src/hooks/token/useNativeTokenSurplus.ts
721
3358
  import {
722
3359
  ETH_CURRENCY_ID,
@@ -1283,7 +3920,7 @@ var JBContractProvider = ({
1283
3920
  chainId,
1284
3921
  args: enabled([1 /* PrimaryNativePaymentTerminal */]) ? [projectId, chainId ? USDC_ADDRESSES[chainId] : zeroAddress4] : void 0
1285
3922
  });
1286
- const primaryNativeTerminal = useMemo3(() => {
3923
+ const primaryNativeTerminal = useMemo5(() => {
1287
3924
  return primaryNativeTerminalEth.data !== zeroAddress4 ? primaryNativeTerminalEth : primaryNativeTerminalUsdc;
1288
3925
  }, [primaryNativeTerminalEth, primaryNativeTerminalUsdc]);
1289
3926
  const controller = useReadContract11({
@@ -1297,11 +3934,11 @@ var JBContractProvider = ({
1297
3934
  staleTime: Infinity
1298
3935
  }
1299
3936
  });
1300
- const controllerAddress = useMemo3(() => controller.data, [controller.data]);
1301
- const hasController = useMemo3(() => {
3937
+ const controllerAddress = useMemo5(() => controller.data, [controller.data]);
3938
+ const hasController = useMemo5(() => {
1302
3939
  return controllerAddress && !isAddressEqual4(controllerAddress, zeroAddress4);
1303
3940
  }, [controllerAddress]);
1304
- const normalizedControllerAddress = useMemo3(() => {
3941
+ const normalizedControllerAddress = useMemo5(() => {
1305
3942
  return hasController ? controllerAddress : zeroAddress4;
1306
3943
  }, [controllerAddress, hasController]);
1307
3944
  const fundAccessLimits = useReadContract11({
@@ -1540,7 +4177,7 @@ function useGetRelayrTxQuote() {
1540
4177
  }
1541
4178
 
1542
4179
  // src/lib/relayr/hooks/useGetRelayrTxBundle.ts
1543
- import { useMemo as useMemo4, useState } from "react";
4180
+ import { useMemo as useMemo6, useState } from "react";
1544
4181
  import { useQuery as useQuery9 } from "wagmi/query";
1545
4182
  var POLL_INTERVAL = 2e3;
1546
4183
  var fetchTxBundle = async (uuid) => {
@@ -1566,7 +4203,7 @@ function useGetRelayrTxBundle() {
1566
4203
  setUuid(bundleUuid);
1567
4204
  getRelayrTxBundle.refetch();
1568
4205
  };
1569
- const isComplete = useMemo4(
4206
+ const isComplete = useMemo6(
1570
4207
  () => getRelayrTxBundle.data?.transactions?.every(
1571
4208
  (tx) => tx?.status.state === "Success"
1572
4209
  ),
@@ -1661,10 +4298,12 @@ export {
1661
4298
  useJBUpcomingRuleset,
1662
4299
  useNativeTokenSurplus,
1663
4300
  useNativeTokenSymbol,
4301
+ useOwnedShopItems,
1664
4302
  usePreparePayMetadata,
1665
4303
  useProjectMetadata,
1666
4304
  useResolveDataHook,
1667
4305
  useSendRelayrTx,
4306
+ useShopPurchases,
1668
4307
  useSuckers,
1669
4308
  useSuckersCashOutQuote,
1670
4309
  useSuckersNativeTokenBalance,