@spiffcommerce/core
Version:
Core client API for interacting with the Spiff Commerce backend.
1,752 lines (1,747 loc) • 2.5 MB
JavaScript
var $v = function(r, e) {
return $v = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
t.__proto__ = n;
} || function(t, n) {
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]);
}, $v(r, e);
};
function va(r, e) {
if (typeof e != "function" && e !== null)
throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
$v(r, e);
function t() {
this.constructor = r;
}
r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
}
var me = function() {
return me = Object.assign || function(e) {
for (var t, n = 1, i = arguments.length; n < i; n++) {
t = arguments[n];
for (var a in t) Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
}
return e;
}, me.apply(this, arguments);
};
function ss(r, e) {
var t = {};
for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
if (r != null && typeof Object.getOwnPropertySymbols == "function")
for (var i = 0, n = Object.getOwnPropertySymbols(r); i < n.length; i++)
e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[i]) && (t[n[i]] = r[n[i]]);
return t;
}
function ts(r, e, t, n) {
function i(a) {
return a instanceof t ? a : new t(function(s) {
s(a);
});
}
return new (t || (t = Promise))(function(a, s) {
function o(c) {
try {
u(n.next(c));
} catch (h) {
s(h);
}
}
function l(c) {
try {
u(n.throw(c));
} catch (h) {
s(h);
}
}
function u(c) {
c.done ? a(c.value) : i(c.value).then(o, l);
}
u((n = n.apply(r, e || [])).next());
});
}
function rs(r, e) {
var t = { label: 0, sent: function() {
if (a[0] & 1) throw a[1];
return a[1];
}, trys: [], ops: [] }, n, i, a, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
return s.next = o(0), s.throw = o(1), s.return = o(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
return this;
}), s;
function o(u) {
return function(c) {
return l([u, c]);
};
}
function l(u) {
if (n) throw new TypeError("Generator is already executing.");
for (; s && (s = 0, u[0] && (t = 0)), t; ) try {
if (n = 1, i && (a = u[0] & 2 ? i.return : u[0] ? i.throw || ((a = i.return) && a.call(i), 0) : i.next) && !(a = a.call(i, u[1])).done) return a;
switch (i = 0, a && (u = [u[0] & 2, a.value]), u[0]) {
case 0:
case 1:
a = u;
break;
case 4:
return t.label++, { value: u[1], done: !1 };
case 5:
t.label++, i = u[1], u = [0];
continue;
case 7:
u = t.ops.pop(), t.trys.pop();
continue;
default:
if (a = t.trys, !(a = a.length > 0 && a[a.length - 1]) && (u[0] === 6 || u[0] === 2)) {
t = 0;
continue;
}
if (u[0] === 3 && (!a || u[1] > a[0] && u[1] < a[3])) {
t.label = u[1];
break;
}
if (u[0] === 6 && t.label < a[1]) {
t.label = a[1], a = u;
break;
}
if (a && t.label < a[2]) {
t.label = a[2], t.ops.push(u);
break;
}
a[2] && t.ops.pop(), t.trys.pop();
continue;
}
u = e.call(r, t);
} catch (c) {
u = [6, c], i = 0;
} finally {
n = a = 0;
}
if (u[0] & 5) throw u[1];
return { value: u[0] ? u[1] : void 0, done: !0 };
}
}
function na(r, e, t) {
if (t || arguments.length === 2) for (var n = 0, i = e.length, a; n < i; n++)
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
return r.concat(a || Array.prototype.slice.call(e));
}
var Um = "Invariant Violation", Rb = Object.setPrototypeOf, nD = Rb === void 0 ? function(r, e) {
return r.__proto__ = e, r;
} : Rb, l2 = (
/** @class */
(function(r) {
va(e, r);
function e(t) {
t === void 0 && (t = Um);
var n = r.call(this, typeof t == "number" ? Um + ": " + t + " (see https://github.com/apollographql/invariant-packages)" : t) || this;
return n.framesToPop = 1, n.name = Um, nD(n, e.prototype), n;
}
return e;
})(Error)
);
function gl(r, e) {
if (!r)
throw new l2(e);
}
var u2 = ["debug", "log", "warn", "error", "silent"], iD = u2.indexOf("log");
function Ph(r) {
return function() {
if (u2.indexOf(r) >= iD) {
var e = console[r] || console.log;
return e.apply(console, arguments);
}
};
}
(function(r) {
r.debug = Ph("debug"), r.log = Ph("log"), r.warn = Ph("warn"), r.error = Ph("error");
})(gl || (gl = {}));
var aA = "3.14.1";
function Da(r) {
try {
return r();
} catch {
}
}
const Yp = Da(function() {
return globalThis;
}) || Da(function() {
return window;
}) || Da(function() {
return self;
}) || Da(function() {
return global;
}) || // We don't expect the Function constructor ever to be invoked at runtime, as
// long as at least one of globalThis, window, self, or global is defined, so
// we are under no obligation to make it easy for static analysis tools to
// detect syntactic usage of the Function constructor. If you think you can
// improve your static analysis to detect this obfuscation, think again. This
// is an arms race you cannot win, at least not in JavaScript.
Da(function() {
return Da.constructor("return this")();
});
var Ob = /* @__PURE__ */ new Map();
function qv(r) {
var e = Ob.get(r) || 1;
return Ob.set(r, e + 1), "".concat(r, ":").concat(e, ":").concat(Math.random().toString(36).slice(2));
}
function aD(r, e) {
var t = qv("stringifyForDisplay");
return JSON.stringify(r, function(n, i) {
return i === void 0 ? t : i;
}, e).split(JSON.stringify(t)).join("<undefined>");
}
function Rh(r) {
return function(e) {
for (var t = [], n = 1; n < arguments.length; n++)
t[n - 1] = arguments[n];
if (typeof e == "number") {
var i = e;
e = sA(i), e || (e = oA(i, t), t = []);
}
r.apply(void 0, [e].concat(t));
};
}
var Mr = Object.assign(function(e, t) {
for (var n = [], i = 2; i < arguments.length; i++)
n[i - 2] = arguments[i];
e || gl(e, sA(t, n) || oA(t, n));
}, {
debug: Rh(gl.debug),
log: Rh(gl.log),
warn: Rh(gl.warn),
error: Rh(gl.error)
});
function qi(r) {
for (var e = [], t = 1; t < arguments.length; t++)
e[t - 1] = arguments[t];
return new l2(sA(r, e) || oA(r, e));
}
var Bb = /* @__PURE__ */ Symbol.for("ApolloErrorMessageHandler_" + aA);
function c2(r) {
if (typeof r == "string")
return r;
try {
return aD(r, 2).slice(0, 1e3);
} catch {
return "<non-serializable>";
}
}
function sA(r, e) {
if (e === void 0 && (e = []), !!r)
return Yp[Bb] && Yp[Bb](r, e.map(c2));
}
function oA(r, e) {
if (e === void 0 && (e = []), !!r)
return "An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
version: aA,
message: r,
args: e.map(c2)
})));
}
function Fp(r, e) {
if (!!!r)
throw new Error(e);
}
function sD(r) {
return typeof r == "object" && r !== null;
}
function oD(r, e) {
if (!!!r)
throw new Error(
"Unexpected invariant triggered."
);
}
const lD = /\r\n|[\n\r]/g;
function Wv(r, e) {
let t = 0, n = 1;
for (const i of r.body.matchAll(lD)) {
if (typeof i.index == "number" || oD(!1), i.index >= e)
break;
t = i.index + i[0].length, n += 1;
}
return {
line: n,
column: e + 1 - t
};
}
function uD(r) {
return f2(
r.source,
Wv(r.source, r.start)
);
}
function f2(r, e) {
const t = r.locationOffset.column - 1, n = "".padStart(t) + r.body, i = e.line - 1, a = r.locationOffset.line - 1, s = e.line + a, o = e.line === 1 ? t : 0, l = e.column + o, u = `${r.name}:${s}:${l}
`, c = n.split(/\r\n|[\n\r]/g), h = c[i];
if (h.length > 120) {
const f = Math.floor(l / 80), d = l % 80, g = [];
for (let v = 0; v < h.length; v += 80)
g.push(h.slice(v, v + 80));
return u + Mb([
[`${s} |`, g[0]],
...g.slice(1, f + 1).map((v) => ["|", v]),
["|", "^".padStart(d)],
["|", g[f + 1]]
]);
}
return u + Mb([
// Lines specified like this: ["prefix", "string"],
[`${s - 1} |`, c[i - 1]],
[`${s} |`, h],
["|", "^".padStart(l)],
[`${s + 1} |`, c[i + 1]]
]);
}
function Mb(r) {
const e = r.filter(([n, i]) => i !== void 0), t = Math.max(...e.map(([n]) => n.length));
return e.map(([n, i]) => n.padStart(t) + (i ? " " + i : "")).join(`
`);
}
function cD(r) {
const e = r[0];
return e == null || "kind" in e || "length" in e ? {
nodes: e,
source: r[1],
positions: r[2],
path: r[3],
originalError: r[4],
extensions: r[5]
} : e;
}
class lA extends Error {
/**
* An array of `{ line, column }` locations within the source GraphQL document
* which correspond to this error.
*
* Errors during validation often contain multiple locations, for example to
* point out two things with the same name. Errors during execution include a
* single location, the field which produced the error.
*
* Enumerable, and appears in the result of JSON.stringify().
*/
/**
* An array describing the JSON-path into the execution response which
* corresponds to this error. Only included for errors during execution.
*
* Enumerable, and appears in the result of JSON.stringify().
*/
/**
* An array of GraphQL AST Nodes corresponding to this error.
*/
/**
* The source GraphQL document for the first location of this error.
*
* Note that if this Error represents more than one node, the source may not
* represent nodes after the first node.
*/
/**
* An array of character offsets within the source GraphQL document
* which correspond to this error.
*/
/**
* The original error thrown from a field resolver during execution.
*/
/**
* Extension fields to add to the formatted error.
*/
/**
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
*/
constructor(e, ...t) {
var n, i, a;
const { nodes: s, source: o, positions: l, path: u, originalError: c, extensions: h } = cD(t);
super(e), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = c ?? void 0, this.nodes = _b(
Array.isArray(s) ? s : s ? [s] : void 0
);
const f = _b(
(n = this.nodes) === null || n === void 0 ? void 0 : n.map((g) => g.loc).filter((g) => g != null)
);
this.source = o ?? (f == null || (i = f[0]) === null || i === void 0 ? void 0 : i.source), this.positions = l ?? f?.map((g) => g.start), this.locations = l && o ? l.map((g) => Wv(o, g)) : f?.map((g) => Wv(g.source, g.start));
const d = sD(
c?.extensions
) ? c?.extensions : void 0;
this.extensions = (a = h ?? d) !== null && a !== void 0 ? a : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
message: {
writable: !0,
enumerable: !0
},
name: {
enumerable: !1
},
nodes: {
enumerable: !1
},
source: {
enumerable: !1
},
positions: {
enumerable: !1
},
originalError: {
enumerable: !1
}
}), c != null && c.stack ? Object.defineProperty(this, "stack", {
value: c.stack,
writable: !0,
configurable: !0
}) : Error.captureStackTrace ? Error.captureStackTrace(this, lA) : Object.defineProperty(this, "stack", {
value: Error().stack,
writable: !0,
configurable: !0
});
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
toString() {
let e = this.message;
if (this.nodes)
for (const t of this.nodes)
t.loc && (e += `
` + uD(t.loc));
else if (this.source && this.locations)
for (const t of this.locations)
e += `
` + f2(this.source, t);
return e;
}
toJSON() {
const e = {
message: this.message
};
return this.locations != null && (e.locations = this.locations), this.path != null && (e.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (e.extensions = this.extensions), e;
}
}
function _b(r) {
return r === void 0 || r.length === 0 ? void 0 : r;
}
function li(r, e, t) {
return new lA(`Syntax Error: ${t}`, {
source: r,
positions: [e]
});
}
class fD {
/**
* The character offset at which this Node begins.
*/
/**
* The character offset at which this Node ends.
*/
/**
* The Token at which this Node begins.
*/
/**
* The Token at which this Node ends.
*/
/**
* The Source document the AST represents.
*/
constructor(e, t, n) {
this.start = e.start, this.end = t.end, this.startToken = e, this.endToken = t, this.source = n;
}
get [Symbol.toStringTag]() {
return "Location";
}
toJSON() {
return {
start: this.start,
end: this.end
};
}
}
let d2 = class {
/**
* The kind of Token.
*/
/**
* The character offset at which this Node begins.
*/
/**
* The character offset at which this Node ends.
*/
/**
* The 1-indexed line number on which this Token appears.
*/
/**
* The 1-indexed column number at which this Token begins.
*/
/**
* For non-punctuation tokens, represents the interpreted value of the token.
*
* Note: is undefined for punctuation tokens, but typed as string for
* convenience in the parser.
*/
/**
* Tokens exist as nodes in a double-linked-list amongst all tokens
* including ignored tokens. <SOF> is always the first node and <EOF>
* the last.
*/
constructor(e, t, n, i, a, s) {
this.kind = e, this.start = t, this.end = n, this.line = i, this.column = a, this.value = s, this.prev = null, this.next = null;
}
get [Symbol.toStringTag]() {
return "Token";
}
toJSON() {
return {
kind: this.kind,
value: this.value,
line: this.line,
column: this.column
};
}
};
const h2 = {
Name: [],
Document: ["definitions"],
OperationDefinition: [
"description",
"name",
"variableDefinitions",
"directives",
"selectionSet"
],
VariableDefinition: [
"description",
"variable",
"type",
"defaultValue",
"directives"
],
Variable: ["name"],
SelectionSet: ["selections"],
Field: ["alias", "name", "arguments", "directives", "selectionSet"],
Argument: ["name", "value"],
FragmentSpread: ["name", "directives"],
InlineFragment: ["typeCondition", "directives", "selectionSet"],
FragmentDefinition: [
"description",
"name",
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
"variableDefinitions",
"typeCondition",
"directives",
"selectionSet"
],
IntValue: [],
FloatValue: [],
StringValue: [],
BooleanValue: [],
NullValue: [],
EnumValue: [],
ListValue: ["values"],
ObjectValue: ["fields"],
ObjectField: ["name", "value"],
Directive: ["name", "arguments"],
NamedType: ["name"],
ListType: ["type"],
NonNullType: ["type"],
SchemaDefinition: ["description", "directives", "operationTypes"],
OperationTypeDefinition: ["type"],
ScalarTypeDefinition: ["description", "name", "directives"],
ObjectTypeDefinition: [
"description",
"name",
"interfaces",
"directives",
"fields"
],
FieldDefinition: ["description", "name", "arguments", "type", "directives"],
InputValueDefinition: [
"description",
"name",
"type",
"defaultValue",
"directives"
],
InterfaceTypeDefinition: [
"description",
"name",
"interfaces",
"directives",
"fields"
],
UnionTypeDefinition: ["description", "name", "directives", "types"],
EnumTypeDefinition: ["description", "name", "directives", "values"],
EnumValueDefinition: ["description", "name", "directives"],
InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
DirectiveDefinition: ["description", "name", "arguments", "locations"],
SchemaExtension: ["directives", "operationTypes"],
ScalarTypeExtension: ["name", "directives"],
ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
UnionTypeExtension: ["name", "directives", "types"],
EnumTypeExtension: ["name", "directives", "values"],
InputObjectTypeExtension: ["name", "directives", "fields"],
TypeCoordinate: ["name"],
MemberCoordinate: ["name", "memberName"],
ArgumentCoordinate: ["name", "fieldName", "argumentName"],
DirectiveCoordinate: ["name"],
DirectiveArgumentCoordinate: ["name", "argumentName"]
}, dD = new Set(Object.keys(h2));
function Nb(r) {
const e = r?.kind;
return typeof e == "string" && dD.has(e);
}
var Pu;
(function(r) {
r.QUERY = "query", r.MUTATION = "mutation", r.SUBSCRIPTION = "subscription";
})(Pu || (Pu = {}));
var Qv;
(function(r) {
r.QUERY = "QUERY", r.MUTATION = "MUTATION", r.SUBSCRIPTION = "SUBSCRIPTION", r.FIELD = "FIELD", r.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", r.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", r.INLINE_FRAGMENT = "INLINE_FRAGMENT", r.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", r.SCHEMA = "SCHEMA", r.SCALAR = "SCALAR", r.OBJECT = "OBJECT", r.FIELD_DEFINITION = "FIELD_DEFINITION", r.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", r.INTERFACE = "INTERFACE", r.UNION = "UNION", r.ENUM = "ENUM", r.ENUM_VALUE = "ENUM_VALUE", r.INPUT_OBJECT = "INPUT_OBJECT", r.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
})(Qv || (Qv = {}));
var et;
(function(r) {
r.NAME = "Name", r.DOCUMENT = "Document", r.OPERATION_DEFINITION = "OperationDefinition", r.VARIABLE_DEFINITION = "VariableDefinition", r.SELECTION_SET = "SelectionSet", r.FIELD = "Field", r.ARGUMENT = "Argument", r.FRAGMENT_SPREAD = "FragmentSpread", r.INLINE_FRAGMENT = "InlineFragment", r.FRAGMENT_DEFINITION = "FragmentDefinition", r.VARIABLE = "Variable", r.INT = "IntValue", r.FLOAT = "FloatValue", r.STRING = "StringValue", r.BOOLEAN = "BooleanValue", r.NULL = "NullValue", r.ENUM = "EnumValue", r.LIST = "ListValue", r.OBJECT = "ObjectValue", r.OBJECT_FIELD = "ObjectField", r.DIRECTIVE = "Directive", r.NAMED_TYPE = "NamedType", r.LIST_TYPE = "ListType", r.NON_NULL_TYPE = "NonNullType", r.SCHEMA_DEFINITION = "SchemaDefinition", r.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", r.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", r.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", r.FIELD_DEFINITION = "FieldDefinition", r.INPUT_VALUE_DEFINITION = "InputValueDefinition", r.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", r.UNION_TYPE_DEFINITION = "UnionTypeDefinition", r.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", r.ENUM_VALUE_DEFINITION = "EnumValueDefinition", r.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", r.DIRECTIVE_DEFINITION = "DirectiveDefinition", r.SCHEMA_EXTENSION = "SchemaExtension", r.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", r.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", r.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", r.UNION_TYPE_EXTENSION = "UnionTypeExtension", r.ENUM_TYPE_EXTENSION = "EnumTypeExtension", r.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension", r.TYPE_COORDINATE = "TypeCoordinate", r.MEMBER_COORDINATE = "MemberCoordinate", r.ARGUMENT_COORDINATE = "ArgumentCoordinate", r.DIRECTIVE_COORDINATE = "DirectiveCoordinate", r.DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate";
})(et || (et = {}));
function Yv(r) {
return r === 9 || r === 32;
}
function od(r) {
return r >= 48 && r <= 57;
}
function p2(r) {
return r >= 97 && r <= 122 || // A-Z
r >= 65 && r <= 90;
}
function g2(r) {
return p2(r) || r === 95;
}
function hD(r) {
return p2(r) || od(r) || r === 95;
}
function pD(r) {
var e;
let t = Number.MAX_SAFE_INTEGER, n = null, i = -1;
for (let s = 0; s < r.length; ++s) {
var a;
const o = r[s], l = gD(o);
l !== o.length && (n = (a = n) !== null && a !== void 0 ? a : s, i = s, s !== 0 && l < t && (t = l));
}
return r.map((s, o) => o === 0 ? s : s.slice(t)).slice(
(e = n) !== null && e !== void 0 ? e : 0,
i + 1
);
}
function gD(r) {
let e = 0;
for (; e < r.length && Yv(r.charCodeAt(e)); )
++e;
return e;
}
function mD(r, e) {
const t = r.replace(/"""/g, '\\"""'), n = t.split(/\r\n|[\n\r]/g), i = n.length === 1, a = n.length > 1 && n.slice(1).every((d) => d.length === 0 || Yv(d.charCodeAt(0))), s = t.endsWith('\\"""'), o = r.endsWith('"') && !s, l = r.endsWith("\\"), u = o || l, c = (
// add leading and trailing new lines only if it improves readability
!i || r.length > 70 || u || a || s
);
let h = "";
const f = i && Yv(r.charCodeAt(0));
return (c && !f || a) && (h += `
`), h += t, (c || u) && (h += `
`), '"""' + h + '"""';
}
var Pe;
(function(r) {
r.SOF = "<SOF>", r.EOF = "<EOF>", r.BANG = "!", r.DOLLAR = "$", r.AMP = "&", r.PAREN_L = "(", r.PAREN_R = ")", r.DOT = ".", r.SPREAD = "...", r.COLON = ":", r.EQUALS = "=", r.AT = "@", r.BRACKET_L = "[", r.BRACKET_R = "]", r.BRACE_L = "{", r.PIPE = "|", r.BRACE_R = "}", r.NAME = "Name", r.INT = "Int", r.FLOAT = "Float", r.STRING = "String", r.BLOCK_STRING = "BlockString", r.COMMENT = "Comment";
})(Pe || (Pe = {}));
class vD {
/**
* The previously focused non-ignored token.
*/
/**
* The currently focused non-ignored token.
*/
/**
* The (1-indexed) line containing the current token.
*/
/**
* The character offset at which the current line begins.
*/
constructor(e) {
const t = new d2(Pe.SOF, 0, 0, 0, 0);
this.source = e, this.lastToken = t, this.token = t, this.line = 1, this.lineStart = 0;
}
get [Symbol.toStringTag]() {
return "Lexer";
}
/**
* Advances the token stream to the next non-ignored token.
*/
advance() {
return this.lastToken = this.token, this.token = this.lookahead();
}
/**
* Looks ahead and returns the next non-ignored token, but does not change
* the state of Lexer.
*/
lookahead() {
let e = this.token;
if (e.kind !== Pe.EOF)
do
if (e.next)
e = e.next;
else {
const t = AD(this, e.end);
e.next = t, t.prev = e, e = t;
}
while (e.kind === Pe.COMMENT);
return e;
}
}
function yD(r) {
return r === Pe.BANG || r === Pe.DOLLAR || r === Pe.AMP || r === Pe.PAREN_L || r === Pe.PAREN_R || r === Pe.DOT || r === Pe.SPREAD || r === Pe.COLON || r === Pe.EQUALS || r === Pe.AT || r === Pe.BRACKET_L || r === Pe.BRACKET_R || r === Pe.BRACE_L || r === Pe.PIPE || r === Pe.BRACE_R;
}
function sc(r) {
return r >= 0 && r <= 55295 || r >= 57344 && r <= 1114111;
}
function wg(r, e) {
return m2(r.charCodeAt(e)) && v2(r.charCodeAt(e + 1));
}
function m2(r) {
return r >= 55296 && r <= 56319;
}
function v2(r) {
return r >= 56320 && r <= 57343;
}
function El(r, e) {
const t = r.source.body.codePointAt(e);
if (t === void 0)
return Pe.EOF;
if (t >= 32 && t <= 126) {
const n = String.fromCodePoint(t);
return n === '"' ? `'"'` : `"${n}"`;
}
return "U+" + t.toString(16).toUpperCase().padStart(4, "0");
}
function ni(r, e, t, n, i) {
const a = r.line, s = 1 + t - r.lineStart;
return new d2(e, t, n, a, s, i);
}
function AD(r, e) {
const t = r.source.body, n = t.length;
let i = e;
for (; i < n; ) {
const a = t.charCodeAt(i);
switch (a) {
// Ignored ::
// - UnicodeBOM
// - WhiteSpace
// - LineTerminator
// - Comment
// - Comma
//
// UnicodeBOM :: "Byte Order Mark (U+FEFF)"
//
// WhiteSpace ::
// - "Horizontal Tab (U+0009)"
// - "Space (U+0020)"
//
// Comma :: ,
case 65279:
// <BOM>
case 9:
// \t
case 32:
// <space>
case 44:
++i;
continue;
// LineTerminator ::
// - "New Line (U+000A)"
// - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
// - "Carriage Return (U+000D)" "New Line (U+000A)"
case 10:
++i, ++r.line, r.lineStart = i;
continue;
case 13:
t.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++r.line, r.lineStart = i;
continue;
// Comment
case 35:
return bD(r, i);
// Token ::
// - Punctuator
// - Name
// - IntValue
// - FloatValue
// - StringValue
//
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
case 33:
return ni(r, Pe.BANG, i, i + 1);
case 36:
return ni(r, Pe.DOLLAR, i, i + 1);
case 38:
return ni(r, Pe.AMP, i, i + 1);
case 40:
return ni(r, Pe.PAREN_L, i, i + 1);
case 41:
return ni(r, Pe.PAREN_R, i, i + 1);
case 46:
if (t.charCodeAt(i + 1) === 46 && t.charCodeAt(i + 2) === 46)
return ni(r, Pe.SPREAD, i, i + 3);
break;
case 58:
return ni(r, Pe.COLON, i, i + 1);
case 61:
return ni(r, Pe.EQUALS, i, i + 1);
case 64:
return ni(r, Pe.AT, i, i + 1);
case 91:
return ni(r, Pe.BRACKET_L, i, i + 1);
case 93:
return ni(r, Pe.BRACKET_R, i, i + 1);
case 123:
return ni(r, Pe.BRACE_L, i, i + 1);
case 124:
return ni(r, Pe.PIPE, i, i + 1);
case 125:
return ni(r, Pe.BRACE_R, i, i + 1);
// StringValue
case 34:
return t.charCodeAt(i + 1) === 34 && t.charCodeAt(i + 2) === 34 ? kD(r, i) : xD(r, i);
}
if (od(a) || a === 45)
return wD(r, i, a);
if (g2(a))
return FD(r, i);
throw li(
r.source,
i,
a === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : sc(a) || wg(t, i) ? `Unexpected character: ${El(r, i)}.` : `Invalid character: ${El(r, i)}.`
);
}
return ni(r, Pe.EOF, n, n);
}
function bD(r, e) {
const t = r.source.body, n = t.length;
let i = e + 1;
for (; i < n; ) {
const a = t.charCodeAt(i);
if (a === 10 || a === 13)
break;
if (sc(a))
++i;
else if (wg(t, i))
i += 2;
else
break;
}
return ni(
r,
Pe.COMMENT,
e,
i,
t.slice(e + 1, i)
);
}
function wD(r, e, t) {
const n = r.source.body;
let i = e, a = t, s = !1;
if (a === 45 && (a = n.charCodeAt(++i)), a === 48) {
if (a = n.charCodeAt(++i), od(a))
throw li(
r.source,
i,
`Invalid number, unexpected digit after 0: ${El(
r,
i
)}.`
);
} else
i = Vm(r, i, a), a = n.charCodeAt(i);
if (a === 46 && (s = !0, a = n.charCodeAt(++i), i = Vm(r, i, a), a = n.charCodeAt(i)), (a === 69 || a === 101) && (s = !0, a = n.charCodeAt(++i), (a === 43 || a === 45) && (a = n.charCodeAt(++i)), i = Vm(r, i, a), a = n.charCodeAt(i)), a === 46 || g2(a))
throw li(
r.source,
i,
`Invalid number, expected digit but got: ${El(
r,
i
)}.`
);
return ni(
r,
s ? Pe.FLOAT : Pe.INT,
e,
i,
n.slice(e, i)
);
}
function Vm(r, e, t) {
if (!od(t))
throw li(
r.source,
e,
`Invalid number, expected digit but got: ${El(
r,
e
)}.`
);
const n = r.source.body;
let i = e + 1;
for (; od(n.charCodeAt(i)); )
++i;
return i;
}
function xD(r, e) {
const t = r.source.body, n = t.length;
let i = e + 1, a = i, s = "";
for (; i < n; ) {
const o = t.charCodeAt(i);
if (o === 34)
return s += t.slice(a, i), ni(r, Pe.STRING, e, i + 1, s);
if (o === 92) {
s += t.slice(a, i);
const l = t.charCodeAt(i + 1) === 117 ? t.charCodeAt(i + 2) === 123 ? CD(r, i) : SD(r, i) : ED(r, i);
s += l.value, i += l.size, a = i;
continue;
}
if (o === 10 || o === 13)
break;
if (sc(o))
++i;
else if (wg(t, i))
i += 2;
else
throw li(
r.source,
i,
`Invalid character within String: ${El(
r,
i
)}.`
);
}
throw li(r.source, i, "Unterminated string.");
}
function CD(r, e) {
const t = r.source.body;
let n = 0, i = 3;
for (; i < 12; ) {
const a = t.charCodeAt(e + i++);
if (a === 125) {
if (i < 5 || !sc(n))
break;
return {
value: String.fromCodePoint(n),
size: i
};
}
if (n = n << 4 | Mf(a), n < 0)
break;
}
throw li(
r.source,
e,
`Invalid Unicode escape sequence: "${t.slice(
e,
e + i
)}".`
);
}
function SD(r, e) {
const t = r.source.body, n = Lb(t, e + 2);
if (sc(n))
return {
value: String.fromCodePoint(n),
size: 6
};
if (m2(n) && t.charCodeAt(e + 6) === 92 && t.charCodeAt(e + 7) === 117) {
const i = Lb(t, e + 8);
if (v2(i))
return {
value: String.fromCodePoint(n, i),
size: 12
};
}
throw li(
r.source,
e,
`Invalid Unicode escape sequence: "${t.slice(e, e + 6)}".`
);
}
function Lb(r, e) {
return Mf(r.charCodeAt(e)) << 12 | Mf(r.charCodeAt(e + 1)) << 8 | Mf(r.charCodeAt(e + 2)) << 4 | Mf(r.charCodeAt(e + 3));
}
function Mf(r) {
return r >= 48 && r <= 57 ? r - 48 : r >= 65 && r <= 70 ? r - 55 : r >= 97 && r <= 102 ? r - 87 : -1;
}
function ED(r, e) {
const t = r.source.body;
switch (t.charCodeAt(e + 1)) {
case 34:
return {
value: '"',
size: 2
};
case 92:
return {
value: "\\",
size: 2
};
case 47:
return {
value: "/",
size: 2
};
case 98:
return {
value: "\b",
size: 2
};
case 102:
return {
value: "\f",
size: 2
};
case 110:
return {
value: `
`,
size: 2
};
case 114:
return {
value: "\r",
size: 2
};
case 116:
return {
value: " ",
size: 2
};
}
throw li(
r.source,
e,
`Invalid character escape sequence: "${t.slice(
e,
e + 2
)}".`
);
}
function kD(r, e) {
const t = r.source.body, n = t.length;
let i = r.lineStart, a = e + 3, s = a, o = "";
const l = [];
for (; a < n; ) {
const u = t.charCodeAt(a);
if (u === 34 && t.charCodeAt(a + 1) === 34 && t.charCodeAt(a + 2) === 34) {
o += t.slice(s, a), l.push(o);
const c = ni(
r,
Pe.BLOCK_STRING,
e,
a + 3,
// Return a string of the lines joined with U+000A.
pD(l).join(`
`)
);
return r.line += l.length - 1, r.lineStart = i, c;
}
if (u === 92 && t.charCodeAt(a + 1) === 34 && t.charCodeAt(a + 2) === 34 && t.charCodeAt(a + 3) === 34) {
o += t.slice(s, a), s = a + 1, a += 4;
continue;
}
if (u === 10 || u === 13) {
o += t.slice(s, a), l.push(o), u === 13 && t.charCodeAt(a + 1) === 10 ? a += 2 : ++a, o = "", s = a, i = a;
continue;
}
if (sc(u))
++a;
else if (wg(t, a))
a += 2;
else
throw li(
r.source,
a,
`Invalid character within String: ${El(
r,
a
)}.`
);
}
throw li(r.source, a, "Unterminated string.");
}
function FD(r, e) {
const t = r.source.body, n = t.length;
let i = e + 1;
for (; i < n; ) {
const a = t.charCodeAt(i);
if (hD(a))
++i;
else
break;
}
return ni(
r,
Pe.NAME,
e,
i,
t.slice(e, i)
);
}
const TD = 10, y2 = 2;
function uA(r) {
return xg(r, []);
}
function xg(r, e) {
switch (typeof r) {
case "string":
return JSON.stringify(r);
case "function":
return r.name ? `[function ${r.name}]` : "[function]";
case "object":
return ID(r, e);
default:
return String(r);
}
}
function ID(r, e) {
if (r === null)
return "null";
if (e.includes(r))
return "[Circular]";
const t = [...e, r];
if (DD(r)) {
const n = r.toJSON();
if (n !== r)
return typeof n == "string" ? n : xg(n, t);
} else if (Array.isArray(r))
return RD(r, t);
return PD(r, t);
}
function DD(r) {
return typeof r.toJSON == "function";
}
function PD(r, e) {
const t = Object.entries(r);
return t.length === 0 ? "{}" : e.length > y2 ? "[" + OD(r) + "]" : "{ " + t.map(
([i, a]) => i + ": " + xg(a, e)
).join(", ") + " }";
}
function RD(r, e) {
if (r.length === 0)
return "[]";
if (e.length > y2)
return "[Array]";
const t = Math.min(TD, r.length), n = r.length - t, i = [];
for (let a = 0; a < t; ++a)
i.push(xg(r[a], e));
return n === 1 ? i.push("... 1 more item") : n > 1 && i.push(`... ${n} more items`), "[" + i.join(", ") + "]";
}
function OD(r) {
const e = Object.prototype.toString.call(r).replace(/^\[object /, "").replace(/]$/, "");
if (e === "Object" && typeof r.constructor == "function") {
const t = r.constructor.name;
if (typeof t == "string" && t !== "")
return t;
}
return e;
}
const BD = globalThis.process && // eslint-disable-next-line no-undef
process.env.NODE_ENV === "production", MD = (
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
BD ? function(e, t) {
return e instanceof t;
} : function(e, t) {
if (e instanceof t)
return !0;
if (typeof e == "object" && e !== null) {
var n;
const i = t.prototype[Symbol.toStringTag], a = (
// We still need to support constructor's name to detect conflicts with older versions of this library.
Symbol.toStringTag in e ? e[Symbol.toStringTag] : (n = e.constructor) === null || n === void 0 ? void 0 : n.name
);
if (i === a) {
const s = uA(e);
throw new Error(`Cannot use ${i} "${s}" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.`);
}
}
return !1;
}
);
class A2 {
constructor(e, t = "GraphQL request", n = {
line: 1,
column: 1
}) {
typeof e == "string" || Fp(!1, `Body must be a string. Received: ${uA(e)}.`), this.body = e, this.name = t, this.locationOffset = n, this.locationOffset.line > 0 || Fp(
!1,
"line in locationOffset is 1-indexed and must be positive."
), this.locationOffset.column > 0 || Fp(
!1,
"column in locationOffset is 1-indexed and must be positive."
);
}
get [Symbol.toStringTag]() {
return "Source";
}
}
function _D(r) {
return MD(r, A2);
}
function ND(r, e) {
const t = new LD(r, e), n = t.parseDocument();
return Object.defineProperty(n, "tokenCount", {
enumerable: !1,
value: t.tokenCount
}), n;
}
let LD = class {
constructor(e, t = {}) {
const { lexer: n, ...i } = t;
if (n)
this._lexer = n;
else {
const a = _D(e) ? e : new A2(e);
this._lexer = new vD(a);
}
this._options = i, this._tokenCounter = 0;
}
get tokenCount() {
return this._tokenCounter;
}
/**
* Converts a name lex token into a name parse node.
*/
parseName() {
const e = this.expectToken(Pe.NAME);
return this.node(e, {
kind: et.NAME,
value: e.value
});
}
// Implements the parsing rules in the Document section.
/**
* Document : Definition+
*/
parseDocument() {
return this.node(this._lexer.token, {
kind: et.DOCUMENT,
definitions: this.many(
Pe.SOF,
this.parseDefinition,
Pe.EOF
)
});
}
/**
* Definition :
* - ExecutableDefinition
* - TypeSystemDefinition
* - TypeSystemExtension
*
* ExecutableDefinition :
* - OperationDefinition
* - FragmentDefinition
*
* TypeSystemDefinition :
* - SchemaDefinition
* - TypeDefinition
* - DirectiveDefinition
*
* TypeDefinition :
* - ScalarTypeDefinition
* - ObjectTypeDefinition
* - InterfaceTypeDefinition
* - UnionTypeDefinition
* - EnumTypeDefinition
* - InputObjectTypeDefinition
*/
parseDefinition() {
if (this.peek(Pe.BRACE_L))
return this.parseOperationDefinition();
const e = this.peekDescription(), t = e ? this._lexer.lookahead() : this._lexer.token;
if (e && t.kind === Pe.BRACE_L)
throw li(
this._lexer.source,
this._lexer.token.start,
"Unexpected description, descriptions are not supported on shorthand queries."
);
if (t.kind === Pe.NAME) {
switch (t.value) {
case "schema":
return this.parseSchemaDefinition();
case "scalar":
return this.parseScalarTypeDefinition();
case "type":
return this.parseObjectTypeDefinition();
case "interface":
return this.parseInterfaceTypeDefinition();
case "union":
return this.parseUnionTypeDefinition();
case "enum":
return this.parseEnumTypeDefinition();
case "input":
return this.parseInputObjectTypeDefinition();
case "directive":
return this.parseDirectiveDefinition();
}
switch (t.value) {
case "query":
case "mutation":
case "subscription":
return this.parseOperationDefinition();
case "fragment":
return this.parseFragmentDefinition();
}
if (e)
throw li(
this._lexer.source,
this._lexer.token.start,
"Unexpected description, only GraphQL definitions support descriptions."
);
if (t.value === "extend")
return this.parseTypeSystemExtension();
}
throw this.unexpected(t);
}
// Implements the parsing rules in the Operations section.
/**
* OperationDefinition :
* - SelectionSet
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
*/
parseOperationDefinition() {
const e = this._lexer.token;
if (this.peek(Pe.BRACE_L))
return this.node(e, {
kind: et.OPERATION_DEFINITION,
operation: Pu.QUERY,
description: void 0,
name: void 0,
variableDefinitions: [],
directives: [],
selectionSet: this.parseSelectionSet()
});
const t = this.parseDescription(), n = this.parseOperationType();
let i;
return this.peek(Pe.NAME) && (i = this.parseName()), this.node(e, {
kind: et.OPERATION_DEFINITION,
operation: n,
description: t,
name: i,
variableDefinitions: this.parseVariableDefinitions(),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* OperationType : one of query mutation subscription
*/
parseOperationType() {
const e = this.expectToken(Pe.NAME);
switch (e.value) {
case "query":
return Pu.QUERY;
case "mutation":
return Pu.MUTATION;
case "subscription":
return Pu.SUBSCRIPTION;
}
throw this.unexpected(e);
}
/**
* VariableDefinitions : ( VariableDefinition+ )
*/
parseVariableDefinitions() {
return this.optionalMany(
Pe.PAREN_L,
this.parseVariableDefinition,
Pe.PAREN_R
);
}
/**
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
*/
parseVariableDefinition() {
return this.node(this._lexer.token, {
kind: et.VARIABLE_DEFINITION,
description: this.parseDescription(),
variable: this.parseVariable(),
type: (this.expectToken(Pe.COLON), this.parseTypeReference()),
defaultValue: this.expectOptionalToken(Pe.EQUALS) ? this.parseConstValueLiteral() : void 0,
directives: this.parseConstDirectives()
});
}
/**
* Variable : $ Name
*/
parseVariable() {
const e = this._lexer.token;
return this.expectToken(Pe.DOLLAR), this.node(e, {
kind: et.VARIABLE,
name: this.parseName()
});
}
/**
* ```
* SelectionSet : { Selection+ }
* ```
*/
parseSelectionSet() {
return this.node(this._lexer.token, {
kind: et.SELECTION_SET,
selections: this.many(
Pe.BRACE_L,
this.parseSelection,
Pe.BRACE_R
)
});
}
/**
* Selection :
* - Field
* - FragmentSpread
* - InlineFragment
*/
parseSelection() {
return this.peek(Pe.SPREAD) ? this.parseFragment() : this.parseField();
}
/**
* Field : Alias? Name Arguments? Directives? SelectionSet?
*
* Alias : Name :
*/
parseField() {
const e = this._lexer.token, t = this.parseName();
let n, i;
return this.expectOptionalToken(Pe.COLON) ? (n = t, i = this.parseName()) : i = t, this.node(e, {
kind: et.FIELD,
alias: n,
name: i,
arguments: this.parseArguments(!1),
directives: this.parseDirectives(!1),
selectionSet: this.peek(Pe.BRACE_L) ? this.parseSelectionSet() : void 0
});
}
/**
* Arguments[Const] : ( Argument[?Const]+ )
*/
parseArguments(e) {
const t = e ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(Pe.PAREN_L, t, Pe.PAREN_R);
}
/**
* Argument[Const] : Name : Value[?Const]
*/
parseArgument(e = !1) {
const t = this._lexer.token, n = this.parseName();
return this.expectToken(Pe.COLON), this.node(t, {
kind: et.ARGUMENT,
name: n,
value: this.parseValueLiteral(e)
});
}
parseConstArgument() {
return this.parseArgument(!0);
}
// Implements the parsing rules in the Fragments section.
/**
* Corresponds to both FragmentSpread and InlineFragment in the spec.
*
* FragmentSpread : ... FragmentName Directives?
*
* InlineFragment : ... TypeCondition? Directives? SelectionSet
*/
parseFragment() {
const e = this._lexer.token;
this.expectToken(Pe.SPREAD);
const t = this.expectOptionalKeyword("on");
return !t && this.peek(Pe.NAME) ? this.node(e, {
kind: et.FRAGMENT_SPREAD,
name: this.parseFragmentName(),
directives: this.parseDirectives(!1)
}) : this.node(e, {
kind: et.INLINE_FRAGMENT,
typeCondition: t ? this.parseNamedType() : void 0,
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* FragmentDefinition :
* - fragment FragmentName on TypeCondition Directives? SelectionSet
*
* TypeCondition : NamedType
*/
parseFragmentDefinition() {
const e = this._lexer.token, t = this.parseDescription();
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(e, {
kind: et.FRAGMENT_DEFINITION,
description: t,
name: this.parseFragmentName(),
variableDefinitions: this.parseVariableDefinitions(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
}) : this.node(e, {
kind: et.FRAGMENT_DEFINITION,
description: t,
name: this.parseFragmentName(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* FragmentName : Name but not `on`
*/
parseFragmentName() {
if (this._lexer.token.value === "on")
throw this.unexpected();
return this.parseName();
}
// Implements the parsing rules in the Values section.
/**
* Value[Const] :
* - [~Const] Variable
* - IntValue
* - FloatValue
* - StringValue
* - BooleanValue
* - NullValue
* - EnumValue
* - ListValue[?Const]
* - ObjectValue[?Const]
*
* BooleanValue : one of `true` `false`
*
* NullValue : `null`
*
* EnumValue : Name but not `true`, `false` or `null`
*/
parseValueLiteral(e) {
const t = this._lexer.token;
switch (t.kind) {
case Pe.BRACKET_L:
return this.parseList(e);
case Pe.BRACE_L:
return this.parseObject(e);
case Pe.INT:
return this.advanceLexer(), this.node(t, {
kind: et.INT,
value: t.value
});
case Pe.FLOAT:
return this.advanceLexer(), this.node(t, {
kind: et.FLOAT,
value: t.value
});
case Pe.STRING:
case Pe.BLOCK_STRING:
return this.parseStringLiteral();
case Pe.NAME:
switch (this.advanceLexer(), t.value) {
case "true":
return this.node(t, {
kind: et.BOOLEAN,
value: !0
});
case "false":
return this.node(t, {
kind: et.BOOLEAN,
value: !1
});
case "null":
return this.node(t, {
kind: et.NULL
});
default:
return this.node(t, {
kind: et.ENUM,
value: t.value
});
}
case Pe.DOLLAR:
if (e)
if (this.expectToken(Pe.DOLLAR), this._lexer.token.kind === Pe.NAME) {
const n = this._lexer.token.value;
throw li(
this._lexer.source,
t.start,
`Unexpected variable "$${n}" in constant value.`
);
} else
throw this.unexpected(t);
return this.parseVariable();
default:
throw this.unexpected();
}
}
parseConstValueLiteral() {
return this.parseValueLiteral(!0);
}
parseStringLiteral() {
const e = this._lexer.token;
return this.advanceLexer(), this.node(e, {
kind: et.STRING,
value: e.value,
block: e.kind === Pe.BLOCK_STRING
});
}
/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
parseList(e) {
const t = () => this.parseValueLiteral(e);
return this.node(this._lexer.token, {
kind: et.LIST,
values: this.any(Pe.BRACKET_L, t, Pe.BRACKET_R)
});
}
/**
* ```
* ObjectValue[Const] :
* - { }
* - { ObjectField[?Const]+ }
* ```
*/
parseObject(e) {
const t = () => this.parseObjectField(e);
return this.node(this._lexer.token, {
kind: et.OBJECT,
fields: this.any(Pe.BRACE_L, t, Pe.BRACE_R)
});
}
/**
* ObjectField[Const] : Name : Value[?Const]
*/
parseObjectField(e) {
const t = this._lexer.token, n = this.parseName();
return this.expectToken(Pe.COLON), this.node(t, {
kind: et.OBJECT_FIELD,
name: n,
value: this.parseValueLiteral(e)
});
}
// Implements the parsing rules in the Directives section.
/**
* Directives[Const] : Directive[?Const]+
*/
parseDirectives(e) {
const t = [];
for (; this.peek(Pe.AT); )
t.push(this.parseDirective(e));
return t;
}
parseConstDirectives() {
return this.parseDirectives(!0);
}
/**
* ```
* Directive[Const] : @ Name Arguments[?Const]?
* ```
*/
parseDirective(e) {
const t = this._lexer.token;
return this.expectToken(Pe.AT), this.node(t, {
kind: et.DIRECTIVE,
name: this.parseName(),
arguments: this.parseArguments(e)
});
}
// Implements the parsing rules in the Types section.
/**
* Type :
* - NamedType
* - ListType
* - NonNullType
*/
parseTypeReference() {
const e = this._lexer.token;
let t;
if (this.expectOptionalToken(Pe.BRACKET_L)) {
const n = this.parseTypeReference();
this.expectToken(Pe.BRACKET_R), t = this.node(e, {
kind: et.LIST_TYPE,
type: n
});
} else
t = this.parseNamedType();
return this.expectOptionalToken(Pe.BANG) ? this.node(e, {
kind: et.NON_NULL_TYPE,
type: t
}) : t;
}
/**
* NamedType : Name
*/
parseNamedType() {
return this.node(this._lexer.token, {
kind: et.NAMED_TYPE,
name: this.parseName()
});
}
// Implements the parsing rules in the Type Definition section.
peekDescription() {
return this.peek(Pe.STRING) || this.peek(Pe.BLOCK_STRING);
}
/**
* Description : StringValue
*/
parseDescription() {
if (this.peekDescription())
return this.parseStringLiteral();
}
/**
* ```
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
* ```
*/
parseSchemaDefinition() {
const e = this._lexer.token, t = this.parseDescription();
this.expectKeyword("schema");
const n = this.parseConstDirectives(), i = this.many(
Pe.BRACE_L,
this.parseOperationTypeDefinition,
Pe.BRACE_R
);
return this.node(e, {
kind: et.SCHEMA_DEFINITION,
description: t,
directives: n,
operationTypes: i
});
}
/**
* OperationTypeDefinition : OperationType : NamedType
*/
parseOperationTypeDefinition() {
const e = this._lexer.token, t = this.parseOperationType();
this.expectToken(Pe.COLON);
const n = this.parseNamedType();
return this.node(e, {
kind: et.OPERATION_TYPE_DEFINITION,
operation: t,
type: n
});
}
/**
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
*/
parseScalarTypeDefinition() {
const e = this._lexer.token, t = this.parseDescription();
this.expectKeyword("scalar");
const n = this.parseName(), i = this.parseConstDirectives();
return this.node(e, {
kind: et.SCALAR_TYPE_DEFINITION,
description: t,
name: n,
directives: i
});
}
/**
*