UNPKG

@spiffcommerce/core

Version:

Core client API for interacting with the Spiff Commerce backend.

1,752 lines (1,747 loc) • 2.49 MB
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 as(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 es(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 ts(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 ra(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 zm = "Invariant Violation", Pb = Object.setPrototypeOf, tD = Pb === void 0 ? function(r, e) { return r.__proto__ = e, r; } : Pb, o2 = ( /** @class */ (function(r) { va(e, r); function e(t) { t === void 0 && (t = zm); var n = r.call(this, typeof t == "number" ? zm + ": " + t + " (see https://github.com/apollographql/invariant-packages)" : t) || this; return n.framesToPop = 1, n.name = zm, tD(n, e.prototype), n; } return e; })(Error) ); function pl(r, e) { if (!r) throw new o2(e); } var l2 = ["debug", "log", "warn", "error", "silent"], rD = l2.indexOf("log"); function Bh(r) { return function() { if (l2.indexOf(r) >= rD) { var e = console[r] || console.log; return e.apply(console, arguments); } }; } (function(r) { r.debug = Bh("debug"), r.log = Bh("log"), r.warn = Bh("warn"), r.error = Bh("error"); })(pl || (pl = {})); var aA = "3.14.1"; function Da(r) { try { return r(); } catch { } } const Zp = 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 Rb = /* @__PURE__ */ new Map(); function qv(r) { var e = Rb.get(r) || 1; return Rb.set(r, e + 1), "".concat(r, ":").concat(e, ":").concat(Math.random().toString(36).slice(2)); } function nD(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 Mh(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 || pl(e, sA(t, n) || oA(t, n)); }, { debug: Mh(pl.debug), log: Mh(pl.log), warn: Mh(pl.warn), error: Mh(pl.error) }); function qi(r) { for (var e = [], t = 1; t < arguments.length; t++) e[t - 1] = arguments[t]; return new o2(sA(r, e) || oA(r, e)); } var Ob = /* @__PURE__ */ Symbol.for("ApolloErrorMessageHandler_" + aA); function u2(r) { if (typeof r == "string") return r; try { return nD(r, 2).slice(0, 1e3); } catch { return "<non-serializable>"; } } function sA(r, e) { if (e === void 0 && (e = []), !!r) return Zp[Ob] && Zp[Ob](r, e.map(u2)); } 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(u2) }))); } function Pp(r, e) { if (!!!r) throw new Error(e); } function iD(r) { return typeof r == "object" && r !== null; } function aD(r, e) { if (!!!r) throw new Error( "Unexpected invariant triggered." ); } const sD = /\r\n|[\n\r]/g; function Wv(r, e) { let t = 0, n = 1; for (const i of r.body.matchAll(sD)) { if (typeof i.index == "number" || aD(!1), i.index >= e) break; t = i.index + i[0].length, n += 1; } return { line: n, column: e + 1 - t }; } function oD(r) { return c2( r.source, Wv(r.source, r.start) ); } function c2(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 + Bb([ [`${s} |`, g[0]], ...g.slice(1, f + 1).map((v) => ["|", v]), ["|", "^".padStart(d)], ["|", g[f + 1]] ]); } return u + Bb([ // Lines specified like this: ["prefix", "string"], [`${s - 1} |`, c[i - 1]], [`${s} |`, h], ["|", "^".padStart(l)], [`${s + 1} |`, c[i + 1]] ]); } function Bb(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 lD(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 } = lD(t); super(e), this.name = "GraphQLError", this.path = u ?? void 0, this.originalError = c ?? void 0, this.nodes = Mb( Array.isArray(s) ? s : s ? [s] : void 0 ); const f = Mb( (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 = iD( 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 += ` ` + oD(t.loc)); else if (this.source && this.locations) for (const t of this.locations) e += ` ` + c2(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 Mb(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 uD { /** * 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 f2 = 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 d2 = { 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"] }, cD = new Set(Object.keys(d2)); function _b(r) { const e = r?.kind; return typeof e == "string" && cD.has(e); } var Iu; (function(r) { r.QUERY = "query", r.MUTATION = "mutation", r.SUBSCRIPTION = "subscription"; })(Iu || (Iu = {})); 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 h2(r) { return r >= 97 && r <= 122 || // A-Z r >= 65 && r <= 90; } function p2(r) { return h2(r) || r === 95; } function fD(r) { return h2(r) || od(r) || r === 95; } function dD(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 = hD(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 hD(r) { let e = 0; for (; e < r.length && Yv(r.charCodeAt(e)); ) ++e; return e; } function pD(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 Re; (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"; })(Re || (Re = {})); class gD { /** * 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 f2(Re.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 !== Re.EOF) do if (e.next) e = e.next; else { const t = vD(this, e.end); e.next = t, t.prev = e, e = t; } while (e.kind === Re.COMMENT); return e; } } function mD(r) { return r === Re.BANG || r === Re.DOLLAR || r === Re.AMP || r === Re.PAREN_L || r === Re.PAREN_R || r === Re.DOT || r === Re.SPREAD || r === Re.COLON || r === Re.EQUALS || r === Re.AT || r === Re.BRACKET_L || r === Re.BRACKET_R || r === Re.BRACE_L || r === Re.PIPE || r === Re.BRACE_R; } function sc(r) { return r >= 0 && r <= 55295 || r >= 57344 && r <= 1114111; } function Sg(r, e) { return g2(r.charCodeAt(e)) && m2(r.charCodeAt(e + 1)); } function g2(r) { return r >= 55296 && r <= 56319; } function m2(r) { return r >= 56320 && r <= 57343; } function Sl(r, e) { const t = r.source.body.codePointAt(e); if (t === void 0) return Re.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 f2(e, t, n, a, s, i); } function vD(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 yD(r, i); // Token :: // - Punctuator // - Name // - IntValue // - FloatValue // - StringValue // // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } case 33: return ni(r, Re.BANG, i, i + 1); case 36: return ni(r, Re.DOLLAR, i, i + 1); case 38: return ni(r, Re.AMP, i, i + 1); case 40: return ni(r, Re.PAREN_L, i, i + 1); case 41: return ni(r, Re.PAREN_R, i, i + 1); case 46: if (t.charCodeAt(i + 1) === 46 && t.charCodeAt(i + 2) === 46) return ni(r, Re.SPREAD, i, i + 3); break; case 58: return ni(r, Re.COLON, i, i + 1); case 61: return ni(r, Re.EQUALS, i, i + 1); case 64: return ni(r, Re.AT, i, i + 1); case 91: return ni(r, Re.BRACKET_L, i, i + 1); case 93: return ni(r, Re.BRACKET_R, i, i + 1); case 123: return ni(r, Re.BRACE_L, i, i + 1); case 124: return ni(r, Re.PIPE, i, i + 1); case 125: return ni(r, Re.BRACE_R, i, i + 1); // StringValue case 34: return t.charCodeAt(i + 1) === 34 && t.charCodeAt(i + 2) === 34 ? SD(r, i) : bD(r, i); } if (od(a) || a === 45) return AD(r, i, a); if (p2(a)) return ED(r, i); throw li( r.source, i, a === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : sc(a) || Sg(t, i) ? `Unexpected character: ${Sl(r, i)}.` : `Invalid character: ${Sl(r, i)}.` ); } return ni(r, Re.EOF, n, n); } function yD(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 (Sg(t, i)) i += 2; else break; } return ni( r, Re.COMMENT, e, i, t.slice(e + 1, i) ); } function AD(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: ${Sl( r, i )}.` ); } else i = Hm(r, i, a), a = n.charCodeAt(i); if (a === 46 && (s = !0, a = n.charCodeAt(++i), i = Hm(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 = Hm(r, i, a), a = n.charCodeAt(i)), a === 46 || p2(a)) throw li( r.source, i, `Invalid number, expected digit but got: ${Sl( r, i )}.` ); return ni( r, s ? Re.FLOAT : Re.INT, e, i, n.slice(e, i) ); } function Hm(r, e, t) { if (!od(t)) throw li( r.source, e, `Invalid number, expected digit but got: ${Sl( r, e )}.` ); const n = r.source.body; let i = e + 1; for (; od(n.charCodeAt(i)); ) ++i; return i; } function bD(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, Re.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 ? wD(r, i) : xD(r, i) : CD(r, i); s += l.value, i += l.size, a = i; continue; } if (o === 10 || o === 13) break; if (sc(o)) ++i; else if (Sg(t, i)) i += 2; else throw li( r.source, i, `Invalid character within String: ${Sl( r, i )}.` ); } throw li(r.source, i, "Unterminated string."); } function wD(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 xD(r, e) { const t = r.source.body, n = Nb(t, e + 2); if (sc(n)) return { value: String.fromCodePoint(n), size: 6 }; if (g2(n) && t.charCodeAt(e + 6) === 92 && t.charCodeAt(e + 7) === 117) { const i = Nb(t, e + 8); if (m2(i)) return { value: String.fromCodePoint(n, i), size: 12 }; } throw li( r.source, e, `Invalid Unicode escape sequence: "${t.slice(e, e + 6)}".` ); } function Nb(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 CD(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 SD(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, Re.BLOCK_STRING, e, a + 3, // Return a string of the lines joined with U+000A. dD(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 (Sg(t, a)) a += 2; else throw li( r.source, a, `Invalid character within String: ${Sl( r, a )}.` ); } throw li(r.source, a, "Unterminated string."); } function ED(r, e) { const t = r.source.body, n = t.length; let i = e + 1; for (; i < n; ) { const a = t.charCodeAt(i); if (fD(a)) ++i; else break; } return ni( r, Re.NAME, e, i, t.slice(e, i) ); } const kD = 10, v2 = 2; function uA(r) { return Eg(r, []); } function Eg(r, e) { switch (typeof r) { case "string": return JSON.stringify(r); case "function": return r.name ? `[function ${r.name}]` : "[function]"; case "object": return FD(r, e); default: return String(r); } } function FD(r, e) { if (r === null) return "null"; if (e.includes(r)) return "[Circular]"; const t = [...e, r]; if (TD(r)) { const n = r.toJSON(); if (n !== r) return typeof n == "string" ? n : Eg(n, t); } else if (Array.isArray(r)) return DD(r, t); return ID(r, t); } function TD(r) { return typeof r.toJSON == "function"; } function ID(r, e) { const t = Object.entries(r); return t.length === 0 ? "{}" : e.length > v2 ? "[" + PD(r) + "]" : "{ " + t.map( ([i, a]) => i + ": " + Eg(a, e) ).join(", ") + " }"; } function DD(r, e) { if (r.length === 0) return "[]"; if (e.length > v2) return "[Array]"; const t = Math.min(kD, r.length), n = r.length - t, i = []; for (let a = 0; a < t; ++a) i.push(Eg(r[a], e)); return n === 1 ? i.push("... 1 more item") : n > 1 && i.push(`... ${n} more items`), "[" + i.join(", ") + "]"; } function PD(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 RD = globalThis.process && // eslint-disable-next-line no-undef process.env.NODE_ENV === "production", OD = ( /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 RD ? 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 y2 { constructor(e, t = "GraphQL request", n = { line: 1, column: 1 }) { typeof e == "string" || Pp(!1, `Body must be a string. Received: ${uA(e)}.`), this.body = e, this.name = t, this.locationOffset = n, this.locationOffset.line > 0 || Pp( !1, "line in locationOffset is 1-indexed and must be positive." ), this.locationOffset.column > 0 || Pp( !1, "column in locationOffset is 1-indexed and must be positive." ); } get [Symbol.toStringTag]() { return "Source"; } } function BD(r) { return OD(r, y2); } function MD(r, e) { const t = new _D(r, e), n = t.parseDocument(); return Object.defineProperty(n, "tokenCount", { enumerable: !1, value: t.tokenCount }), n; } let _D = class { constructor(e, t = {}) { const { lexer: n, ...i } = t; if (n) this._lexer = n; else { const a = BD(e) ? e : new y2(e); this._lexer = new gD(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(Re.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( Re.SOF, this.parseDefinition, Re.EOF ) }); } /** * Definition : * - ExecutableDefinition * - TypeSystemDefinition * - TypeSystemExtension * * ExecutableDefinition : * - OperationDefinition * - FragmentDefinition * * TypeSystemDefinition : * - SchemaDefinition * - TypeDefinition * - DirectiveDefinition * * TypeDefinition : * - ScalarTypeDefinition * - ObjectTypeDefinition * - InterfaceTypeDefinition * - UnionTypeDefinition * - EnumTypeDefinition * - InputObjectTypeDefinition */ parseDefinition() { if (this.peek(Re.BRACE_L)) return this.parseOperationDefinition(); const e = this.peekDescription(), t = e ? this._lexer.lookahead() : this._lexer.token; if (e && t.kind === Re.BRACE_L) throw li( this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries." ); if (t.kind === Re.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(Re.BRACE_L)) return this.node(e, { kind: et.OPERATION_DEFINITION, operation: Iu.QUERY, description: void 0, name: void 0, variableDefinitions: [], directives: [], selectionSet: this.parseSelectionSet() }); const t = this.parseDescription(), n = this.parseOperationType(); let i; return this.peek(Re.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(Re.NAME); switch (e.value) { case "query": return Iu.QUERY; case "mutation": return Iu.MUTATION; case "subscription": return Iu.SUBSCRIPTION; } throw this.unexpected(e); } /** * VariableDefinitions : ( VariableDefinition+ ) */ parseVariableDefinitions() { return this.optionalMany( Re.PAREN_L, this.parseVariableDefinition, Re.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(Re.COLON), this.parseTypeReference()), defaultValue: this.expectOptionalToken(Re.EQUALS) ? this.parseConstValueLiteral() : void 0, directives: this.parseConstDirectives() }); } /** * Variable : $ Name */ parseVariable() { const e = this._lexer.token; return this.expectToken(Re.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( Re.BRACE_L, this.parseSelection, Re.BRACE_R ) }); } /** * Selection : * - Field * - FragmentSpread * - InlineFragment */ parseSelection() { return this.peek(Re.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(Re.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(Re.BRACE_L) ? this.parseSelectionSet() : void 0 }); } /** * Arguments[Const] : ( Argument[?Const]+ ) */ parseArguments(e) { const t = e ? this.parseConstArgument : this.parseArgument; return this.optionalMany(Re.PAREN_L, t, Re.PAREN_R); } /** * Argument[Const] : Name : Value[?Const] */ parseArgument(e = !1) { const t = this._lexer.token, n = this.parseName(); return this.expectToken(Re.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(Re.SPREAD); const t = this.expectOptionalKeyword("on"); return !t && this.peek(Re.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 Re.BRACKET_L: return this.parseList(e); case Re.BRACE_L: return this.parseObject(e); case Re.INT: return this.advanceLexer(), this.node(t, { kind: et.INT, value: t.value }); case Re.FLOAT: return this.advanceLexer(), this.node(t, { kind: et.FLOAT, value: t.value }); case Re.STRING: case Re.BLOCK_STRING: return this.parseStringLiteral(); case Re.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 Re.DOLLAR: if (e) if (this.expectToken(Re.DOLLAR), this._lexer.token.kind === Re.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 === Re.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(Re.BRACKET_L, t, Re.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(Re.BRACE_L, t, Re.BRACE_R) }); } /** * ObjectField[Const] : Name : Value[?Const] */ parseObjectField(e) { const t = this._lexer.token, n = this.parseName(); return this.expectToken(Re.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(Re.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(Re.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(Re.BRACKET_L)) { const n = this.parseTypeReference(); this.expectToken(Re.BRACKET_R), t = this.node(e, { kind: et.LIST_TYPE, type: n }); } else t = this.parseNamedType(); return this.expectOptionalToken(Re.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(Re.STRING) || this.peek(Re.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( Re.BRACE_L, this.parseOperationTypeDefinition, Re.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(Re.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 }); } /** *