UNPKG

highlight.run

Version:

Open source, fullstack monitoring. Capture frontend errors, record server side logs, and visualize what broke with session replay.

1,771 lines (1,765 loc) 130 kB
var tn = Object.defineProperty, nn = Object.defineProperties; var rn = Object.getOwnPropertyDescriptors; var ce = Object.getOwnPropertySymbols; var rt = Object.prototype.hasOwnProperty, it = Object.prototype.propertyIsEnumerable; var Oe = (e, t) => (t = Symbol[e]) ? t : Symbol.for("Symbol." + e), sn = (e) => { throw TypeError(e); }; var De = (e, t, n) => t in e ? tn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, _ = (e, t) => { for (var n in t || (t = {})) rt.call(t, n) && De(e, n, t[n]); if (ce) for (var n of ce(t)) it.call(t, n) && De(e, n, t[n]); return e; }, q = (e, t) => nn(e, rn(t)); var H = (e, t) => { var n = {}; for (var r in e) rt.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (e != null && ce) for (var r of ce(e)) t.indexOf(r) < 0 && it.call(e, r) && (n[r] = e[r]); return n; }; var G = (e, t, n) => De(e, typeof t != "symbol" ? t + "" : t, n); var U = (e, t, n) => new Promise((r, i) => { var s = (c) => { try { a(n.next(c)); } catch (f) { i(f); } }, o = (c) => { try { a(n.throw(c)); } catch (f) { i(f); } }, a = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(s, o); a((n = n.apply(e, t)).next()); }), on = function(e, t) { this[0] = e, this[1] = t; }; var we = (e) => { var t = e[Oe("asyncIterator")], n = !1, r, i = {}; return t == null ? (t = e[Oe("iterator")](), r = (s) => i[s] = (o) => t[s](o)) : (t = t.call(e), r = (s) => i[s] = (o) => { if (n) { if (n = !1, s === "throw") throw o; return o; } return n = !0, { done: !1, value: new on(new Promise((a) => { var c = t[s](o); c instanceof Object || sn("Object expected"), a(c); }), 1) }; }), i[Oe("iterator")] = () => i, r("next"), "throw" in t ? r("throw") : i.throw = (s) => { throw s; }, "return" in t && r("return"), i; }; import { a as K, B as an, i as st } from "./buffer-DIFxvF2Q.js"; function de(e, t) { if (!!!e) throw new Error(t); } function cn(e) { return typeof e == "object" && e !== null; } function un(e, t) { if (!!!e) throw new Error( "Unexpected invariant triggered." ); } const ln = /\r\n|[\n\r]/g; function Ue(e, t) { let n = 0, r = 1; for (const i of e.body.matchAll(ln)) { if (typeof i.index == "number" || un(!1), i.index >= t) break; n = i.index + i[0].length, r += 1; } return { line: r, column: t + 1 - n }; } function fn(e) { return At( e.source, Ue(e.source, e.start) ); } function At(e, t) { const n = e.locationOffset.column - 1, r = "".padStart(n) + e.body, i = t.line - 1, s = e.locationOffset.line - 1, o = t.line + s, a = t.line === 1 ? n : 0, c = t.column + a, f = `${e.name}:${o}:${c} `, h = r.split(/\r\n|[\n\r]/g), m = h[i]; if (m.length > 120) { const E = Math.floor(c / 80), S = c % 80, y = []; for (let N = 0; N < m.length; N += 80) y.push(m.slice(N, N + 80)); return f + ot([ [`${o} |`, y[0]], ...y.slice(1, E + 1).map((N) => ["|", N]), ["|", "^".padStart(S)], ["|", y[E + 1]] ]); } return f + ot([ // Lines specified like this: ["prefix", "string"], [`${o - 1} |`, h[i - 1]], [`${o} |`, m], ["|", "^".padStart(c)], [`${o + 1} |`, h[i + 1]] ]); } function ot(e) { const t = e.filter(([r, i]) => i !== void 0), n = Math.max(...t.map(([r]) => r.length)); return t.map(([r, i]) => r.padStart(n) + (i ? " " + i : "")).join(` `); } function hn(e) { const t = e[0]; return t == null || "kind" in t || "length" in t ? { nodes: t, source: e[1], positions: e[2], path: e[3], originalError: e[4], extensions: e[5] } : t; } class Qe 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(t, ...n) { var r, i, s; const { nodes: o, source: a, positions: c, path: f, originalError: h, extensions: m } = hn(n); super(t), this.name = "GraphQLError", this.path = f != null ? f : void 0, this.originalError = h != null ? h : void 0, this.nodes = at( Array.isArray(o) ? o : o ? [o] : void 0 ); const E = at( (r = this.nodes) === null || r === void 0 ? void 0 : r.map((y) => y.loc).filter((y) => y != null) ); this.source = a != null ? a : E == null || (i = E[0]) === null || i === void 0 ? void 0 : i.source, this.positions = c != null ? c : E == null ? void 0 : E.map((y) => y.start), this.locations = c && a ? c.map((y) => Ue(a, y)) : E == null ? void 0 : E.map((y) => Ue(y.source, y.start)); const S = cn( h == null ? void 0 : h.extensions ) ? h == null ? void 0 : h.extensions : void 0; this.extensions = (s = m != null ? m : S) !== null && s !== void 0 ? s : /* @__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 } }), h != null && h.stack ? Object.defineProperty(this, "stack", { value: h.stack, writable: !0, configurable: !0 }) : Error.captureStackTrace ? Error.captureStackTrace(this, Qe) : Object.defineProperty(this, "stack", { value: Error().stack, writable: !0, configurable: !0 }); } get [Symbol.toStringTag]() { return "GraphQLError"; } toString() { let t = this.message; if (this.nodes) for (const n of this.nodes) n.loc && (t += ` ` + fn(n.loc)); else if (this.source && this.locations) for (const n of this.locations) t += ` ` + At(this.source, n); return t; } toJSON() { const t = { message: this.message }; return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t; } } function at(e) { return e === void 0 || e.length === 0 ? void 0 : e; } function O(e, t, n) { return new Qe(`Syntax Error: ${n}`, { source: e, positions: [t] }); } class dn { /** * 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(t, n, r) { this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = r; } get [Symbol.toStringTag]() { return "Location"; } toJSON() { return { start: this.start, end: this.end }; } } class Nt { /** * 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(t, n, r, i, s, o) { this.kind = t, this.start = n, this.end = r, this.line = i, this.column = s, this.value = o, 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 It = { Name: [], Document: ["definitions"], OperationDefinition: [ "name", "variableDefinitions", "directives", "selectionSet" ], VariableDefinition: ["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: [ "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"] }, pn = new Set(Object.keys(It)); function ct(e) { const t = e == null ? void 0 : e.kind; return typeof t == "string" && pn.has(t); } var J; (function(e) { e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription"; })(J || (J = {})); var Be; (function(e) { e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION"; })(Be || (Be = {})); var g; (function(e) { e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension"; })(g || (g = {})); function Ve(e) { return e === 9 || e === 32; } function ie(e) { return e >= 48 && e <= 57; } function bt(e) { return e >= 97 && e <= 122 || // A-Z e >= 65 && e <= 90; } function xt(e) { return bt(e) || e === 95; } function mn(e) { return bt(e) || ie(e) || e === 95; } function gn(e) { var t; let n = Number.MAX_SAFE_INTEGER, r = null, i = -1; for (let o = 0; o < e.length; ++o) { var s; const a = e[o], c = yn(a); c !== a.length && (r = (s = r) !== null && s !== void 0 ? s : o, i = o, o !== 0 && c < n && (n = c)); } return e.map((o, a) => a === 0 ? o : o.slice(n)).slice( (t = r) !== null && t !== void 0 ? t : 0, i + 1 ); } function yn(e) { let t = 0; for (; t < e.length && Ve(e.charCodeAt(t)); ) ++t; return t; } function En(e, t) { const n = e.replace(/"""/g, '\\"""'), r = n.split(/\r\n|[\n\r]/g), i = r.length === 1, s = r.length > 1 && r.slice(1).every((S) => S.length === 0 || Ve(S.charCodeAt(0))), o = n.endsWith('\\"""'), a = e.endsWith('"') && !o, c = e.endsWith("\\"), f = a || c, h = ( // add leading and trailing new lines only if it improves readability !i || e.length > 70 || f || s || o ); let m = ""; const E = i && Ve(e.charCodeAt(0)); return (h && !E || s) && (m += ` `), m += n, (h || f) && (m += ` `), '"""' + m + '"""'; } var l; (function(e) { e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment"; })(l || (l = {})); class _n { /** * 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(t) { const n = new Nt(l.SOF, 0, 0, 0, 0); this.source = t, this.lastToken = n, this.token = n, 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 t = this.token; if (t.kind !== l.EOF) do if (t.next) t = t.next; else { const n = vn(this, t.end); t.next = n, n.prev = t, t = n; } while (t.kind === l.COMMENT); return t; } } function Tn(e) { return e === l.BANG || e === l.DOLLAR || e === l.AMP || e === l.PAREN_L || e === l.PAREN_R || e === l.SPREAD || e === l.COLON || e === l.EQUALS || e === l.AT || e === l.BRACKET_L || e === l.BRACKET_R || e === l.BRACE_L || e === l.PIPE || e === l.BRACE_R; } function Z(e) { return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111; } function ve(e, t) { return Ot(e.charCodeAt(t)) && Dt(e.charCodeAt(t + 1)); } function Ot(e) { return e >= 55296 && e <= 56319; } function Dt(e) { return e >= 56320 && e <= 57343; } function B(e, t) { const n = e.source.body.codePointAt(t); if (n === void 0) return l.EOF; if (n >= 32 && n <= 126) { const r = String.fromCodePoint(n); return r === '"' ? `'"'` : `"${r}"`; } return "U+" + n.toString(16).toUpperCase().padStart(4, "0"); } function I(e, t, n, r, i) { const s = e.line, o = 1 + n - e.lineStart; return new Nt(t, n, r, s, o, i); } function vn(e, t) { const n = e.source.body, r = n.length; let i = t; for (; i < r; ) { const s = n.charCodeAt(i); switch (s) { // 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, ++e.line, e.lineStart = i; continue; case 13: n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i; continue; // Comment case 35: return Sn(e, i); // Token :: // - Punctuator // - Name // - IntValue // - FloatValue // - StringValue // // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } case 33: return I(e, l.BANG, i, i + 1); case 36: return I(e, l.DOLLAR, i, i + 1); case 38: return I(e, l.AMP, i, i + 1); case 40: return I(e, l.PAREN_L, i, i + 1); case 41: return I(e, l.PAREN_R, i, i + 1); case 46: if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46) return I(e, l.SPREAD, i, i + 3); break; case 58: return I(e, l.COLON, i, i + 1); case 61: return I(e, l.EQUALS, i, i + 1); case 64: return I(e, l.AT, i, i + 1); case 91: return I(e, l.BRACKET_L, i, i + 1); case 93: return I(e, l.BRACKET_R, i, i + 1); case 123: return I(e, l.BRACE_L, i, i + 1); case 124: return I(e, l.PIPE, i, i + 1); case 125: return I(e, l.BRACE_R, i, i + 1); // StringValue case 34: return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? On(e, i) : Nn(e, i); } if (ie(s) || s === 45) return An(e, i, s); if (xt(s)) return Dn(e, i); throw O( e.source, i, s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : Z(s) || ve(n, i) ? `Unexpected character: ${B(e, i)}.` : `Invalid character: ${B(e, i)}.` ); } return I(e, l.EOF, r, r); } function Sn(e, t) { const n = e.source.body, r = n.length; let i = t + 1; for (; i < r; ) { const s = n.charCodeAt(i); if (s === 10 || s === 13) break; if (Z(s)) ++i; else if (ve(n, i)) i += 2; else break; } return I( e, l.COMMENT, t, i, n.slice(t + 1, i) ); } function An(e, t, n) { const r = e.source.body; let i = t, s = n, o = !1; if (s === 45 && (s = r.charCodeAt(++i)), s === 48) { if (s = r.charCodeAt(++i), ie(s)) throw O( e.source, i, `Invalid number, unexpected digit after 0: ${B( e, i )}.` ); } else i = Ce(e, i, s), s = r.charCodeAt(i); if (s === 46 && (o = !0, s = r.charCodeAt(++i), i = Ce(e, i, s), s = r.charCodeAt(i)), (s === 69 || s === 101) && (o = !0, s = r.charCodeAt(++i), (s === 43 || s === 45) && (s = r.charCodeAt(++i)), i = Ce(e, i, s), s = r.charCodeAt(i)), s === 46 || xt(s)) throw O( e.source, i, `Invalid number, expected digit but got: ${B( e, i )}.` ); return I( e, o ? l.FLOAT : l.INT, t, i, r.slice(t, i) ); } function Ce(e, t, n) { if (!ie(n)) throw O( e.source, t, `Invalid number, expected digit but got: ${B( e, t )}.` ); const r = e.source.body; let i = t + 1; for (; ie(r.charCodeAt(i)); ) ++i; return i; } function Nn(e, t) { const n = e.source.body, r = n.length; let i = t + 1, s = i, o = ""; for (; i < r; ) { const a = n.charCodeAt(i); if (a === 34) return o += n.slice(s, i), I(e, l.STRING, t, i + 1, o); if (a === 92) { o += n.slice(s, i); const c = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? In(e, i) : bn(e, i) : xn(e, i); o += c.value, i += c.size, s = i; continue; } if (a === 10 || a === 13) break; if (Z(a)) ++i; else if (ve(n, i)) i += 2; else throw O( e.source, i, `Invalid character within String: ${B( e, i )}.` ); } throw O(e.source, i, "Unterminated string."); } function In(e, t) { const n = e.source.body; let r = 0, i = 3; for (; i < 12; ) { const s = n.charCodeAt(t + i++); if (s === 125) { if (i < 5 || !Z(r)) break; return { value: String.fromCodePoint(r), size: i }; } if (r = r << 4 | re(s), r < 0) break; } throw O( e.source, t, `Invalid Unicode escape sequence: "${n.slice( t, t + i )}".` ); } function bn(e, t) { const n = e.source.body, r = ut(n, t + 2); if (Z(r)) return { value: String.fromCodePoint(r), size: 6 }; if (Ot(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) { const i = ut(n, t + 8); if (Dt(i)) return { value: String.fromCodePoint(r, i), size: 12 }; } throw O( e.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".` ); } function ut(e, t) { return re(e.charCodeAt(t)) << 12 | re(e.charCodeAt(t + 1)) << 8 | re(e.charCodeAt(t + 2)) << 4 | re(e.charCodeAt(t + 3)); } function re(e) { return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1; } function xn(e, t) { const n = e.source.body; switch (n.charCodeAt(t + 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 O( e.source, t, `Invalid character escape sequence: "${n.slice( t, t + 2 )}".` ); } function On(e, t) { const n = e.source.body, r = n.length; let i = e.lineStart, s = t + 3, o = s, a = ""; const c = []; for (; s < r; ) { const f = n.charCodeAt(s); if (f === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) { a += n.slice(o, s), c.push(a); const h = I( e, l.BLOCK_STRING, t, s + 3, // Return a string of the lines joined with U+000A. gn(c).join(` `) ); return e.line += c.length - 1, e.lineStart = i, h; } if (f === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) { a += n.slice(o, s), o = s + 1, s += 4; continue; } if (f === 10 || f === 13) { a += n.slice(o, s), c.push(a), f === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, a = "", o = s, i = s; continue; } if (Z(f)) ++s; else if (ve(n, s)) s += 2; else throw O( e.source, s, `Invalid character within String: ${B( e, s )}.` ); } throw O(e.source, s, "Unterminated string."); } function Dn(e, t) { const n = e.source.body, r = n.length; let i = t + 1; for (; i < r; ) { const s = n.charCodeAt(i); if (mn(s)) ++i; else break; } return I( e, l.NAME, t, i, n.slice(t, i) ); } const wn = 10, wt = 2; function Ke(e) { return Se(e, []); } function Se(e, t) { switch (typeof e) { case "string": return JSON.stringify(e); case "function": return e.name ? `[function ${e.name}]` : "[function]"; case "object": return Cn(e, t); default: return String(e); } } function Cn(e, t) { if (e === null) return "null"; if (t.includes(e)) return "[Circular]"; const n = [...t, e]; if (Rn(e)) { const r = e.toJSON(); if (r !== e) return typeof r == "string" ? r : Se(r, n); } else if (Array.isArray(e)) return Ln(e, n); return kn(e, n); } function Rn(e) { return typeof e.toJSON == "function"; } function kn(e, t) { const n = Object.entries(e); return n.length === 0 ? "{}" : t.length > wt ? "[" + Pn(e) + "]" : "{ " + n.map( ([i, s]) => i + ": " + Se(s, t) ).join(", ") + " }"; } function Ln(e, t) { if (e.length === 0) return "[]"; if (t.length > wt) return "[Array]"; const n = Math.min(wn, e.length), r = e.length - n, i = []; for (let s = 0; s < n; ++s) i.push(Se(e[s], t)); return r === 1 ? i.push("... 1 more item") : r > 1 && i.push(`... ${r} more items`), "[" + i.join(", ") + "]"; } function Pn(e) { const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, ""); if (t === "Object" && typeof e.constructor == "function") { const n = e.constructor.name; if (typeof n == "string" && n !== "") return n; } return t; } const Fn = globalThis.process && // eslint-disable-next-line no-undef process.env.NODE_ENV === "production", Mn = ( /* c8 ignore next 6 */ // FIXME: https://github.com/graphql/graphql-js/issues/2317 Fn ? function(t, n) { return t instanceof n; } : function(t, n) { if (t instanceof n) return !0; if (typeof t == "object" && t !== null) { var r; const i = n.prototype[Symbol.toStringTag], s = ( // We still need to support constructor's name to detect conflicts with older versions of this library. Symbol.toStringTag in t ? t[Symbol.toStringTag] : (r = t.constructor) === null || r === void 0 ? void 0 : r.name ); if (i === s) { const o = Ke(t); throw new Error(`Cannot use ${i} "${o}" 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 Ct { constructor(t, n = "GraphQL request", r = { line: 1, column: 1 }) { typeof t == "string" || de(!1, `Body must be a string. Received: ${Ke(t)}.`), this.body = t, this.name = n, this.locationOffset = r, this.locationOffset.line > 0 || de( !1, "line in locationOffset is 1-indexed and must be positive." ), this.locationOffset.column > 0 || de( !1, "column in locationOffset is 1-indexed and must be positive." ); } get [Symbol.toStringTag]() { return "Source"; } } function $n(e) { return Mn(e, Ct); } function Rt(e, t) { const n = new Un(e, t), r = n.parseDocument(); return Object.defineProperty(r, "tokenCount", { enumerable: !1, value: n.tokenCount }), r; } class Un { constructor(t, n = {}) { const r = $n(t) ? t : new Ct(t); this._lexer = new _n(r), this._options = n, this._tokenCounter = 0; } get tokenCount() { return this._tokenCounter; } /** * Converts a name lex token into a name parse node. */ parseName() { const t = this.expectToken(l.NAME); return this.node(t, { kind: g.NAME, value: t.value }); } // Implements the parsing rules in the Document section. /** * Document : Definition+ */ parseDocument() { return this.node(this._lexer.token, { kind: g.DOCUMENT, definitions: this.many( l.SOF, this.parseDefinition, l.EOF ) }); } /** * Definition : * - ExecutableDefinition * - TypeSystemDefinition * - TypeSystemExtension * * ExecutableDefinition : * - OperationDefinition * - FragmentDefinition * * TypeSystemDefinition : * - SchemaDefinition * - TypeDefinition * - DirectiveDefinition * * TypeDefinition : * - ScalarTypeDefinition * - ObjectTypeDefinition * - InterfaceTypeDefinition * - UnionTypeDefinition * - EnumTypeDefinition * - InputObjectTypeDefinition */ parseDefinition() { if (this.peek(l.BRACE_L)) return this.parseOperationDefinition(); const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token; if (n.kind === l.NAME) { switch (n.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(); } if (t) throw O( this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are supported only on type definitions." ); switch (n.value) { case "query": case "mutation": case "subscription": return this.parseOperationDefinition(); case "fragment": return this.parseFragmentDefinition(); case "extend": return this.parseTypeSystemExtension(); } } throw this.unexpected(n); } // Implements the parsing rules in the Operations section. /** * OperationDefinition : * - SelectionSet * - OperationType Name? VariableDefinitions? Directives? SelectionSet */ parseOperationDefinition() { const t = this._lexer.token; if (this.peek(l.BRACE_L)) return this.node(t, { kind: g.OPERATION_DEFINITION, operation: J.QUERY, name: void 0, variableDefinitions: [], directives: [], selectionSet: this.parseSelectionSet() }); const n = this.parseOperationType(); let r; return this.peek(l.NAME) && (r = this.parseName()), this.node(t, { kind: g.OPERATION_DEFINITION, operation: n, name: r, variableDefinitions: this.parseVariableDefinitions(), directives: this.parseDirectives(!1), selectionSet: this.parseSelectionSet() }); } /** * OperationType : one of query mutation subscription */ parseOperationType() { const t = this.expectToken(l.NAME); switch (t.value) { case "query": return J.QUERY; case "mutation": return J.MUTATION; case "subscription": return J.SUBSCRIPTION; } throw this.unexpected(t); } /** * VariableDefinitions : ( VariableDefinition+ ) */ parseVariableDefinitions() { return this.optionalMany( l.PAREN_L, this.parseVariableDefinition, l.PAREN_R ); } /** * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? */ parseVariableDefinition() { return this.node(this._lexer.token, { kind: g.VARIABLE_DEFINITION, variable: this.parseVariable(), type: (this.expectToken(l.COLON), this.parseTypeReference()), defaultValue: this.expectOptionalToken(l.EQUALS) ? this.parseConstValueLiteral() : void 0, directives: this.parseConstDirectives() }); } /** * Variable : $ Name */ parseVariable() { const t = this._lexer.token; return this.expectToken(l.DOLLAR), this.node(t, { kind: g.VARIABLE, name: this.parseName() }); } /** * ``` * SelectionSet : { Selection+ } * ``` */ parseSelectionSet() { return this.node(this._lexer.token, { kind: g.SELECTION_SET, selections: this.many( l.BRACE_L, this.parseSelection, l.BRACE_R ) }); } /** * Selection : * - Field * - FragmentSpread * - InlineFragment */ parseSelection() { return this.peek(l.SPREAD) ? this.parseFragment() : this.parseField(); } /** * Field : Alias? Name Arguments? Directives? SelectionSet? * * Alias : Name : */ parseField() { const t = this._lexer.token, n = this.parseName(); let r, i; return this.expectOptionalToken(l.COLON) ? (r = n, i = this.parseName()) : i = n, this.node(t, { kind: g.FIELD, alias: r, name: i, arguments: this.parseArguments(!1), directives: this.parseDirectives(!1), selectionSet: this.peek(l.BRACE_L) ? this.parseSelectionSet() : void 0 }); } /** * Arguments[Const] : ( Argument[?Const]+ ) */ parseArguments(t) { const n = t ? this.parseConstArgument : this.parseArgument; return this.optionalMany(l.PAREN_L, n, l.PAREN_R); } /** * Argument[Const] : Name : Value[?Const] */ parseArgument(t = !1) { const n = this._lexer.token, r = this.parseName(); return this.expectToken(l.COLON), this.node(n, { kind: g.ARGUMENT, name: r, value: this.parseValueLiteral(t) }); } 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 t = this._lexer.token; this.expectToken(l.SPREAD); const n = this.expectOptionalKeyword("on"); return !n && this.peek(l.NAME) ? this.node(t, { kind: g.FRAGMENT_SPREAD, name: this.parseFragmentName(), directives: this.parseDirectives(!1) }) : this.node(t, { kind: g.INLINE_FRAGMENT, typeCondition: n ? this.parseNamedType() : void 0, directives: this.parseDirectives(!1), selectionSet: this.parseSelectionSet() }); } /** * FragmentDefinition : * - fragment FragmentName on TypeCondition Directives? SelectionSet * * TypeCondition : NamedType */ parseFragmentDefinition() { const t = this._lexer.token; return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, { kind: g.FRAGMENT_DEFINITION, name: this.parseFragmentName(), variableDefinitions: this.parseVariableDefinitions(), typeCondition: (this.expectKeyword("on"), this.parseNamedType()), directives: this.parseDirectives(!1), selectionSet: this.parseSelectionSet() }) : this.node(t, { kind: g.FRAGMENT_DEFINITION, 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(t) { const n = this._lexer.token; switch (n.kind) { case l.BRACKET_L: return this.parseList(t); case l.BRACE_L: return this.parseObject(t); case l.INT: return this.advanceLexer(), this.node(n, { kind: g.INT, value: n.value }); case l.FLOAT: return this.advanceLexer(), this.node(n, { kind: g.FLOAT, value: n.value }); case l.STRING: case l.BLOCK_STRING: return this.parseStringLiteral(); case l.NAME: switch (this.advanceLexer(), n.value) { case "true": return this.node(n, { kind: g.BOOLEAN, value: !0 }); case "false": return this.node(n, { kind: g.BOOLEAN, value: !1 }); case "null": return this.node(n, { kind: g.NULL }); default: return this.node(n, { kind: g.ENUM, value: n.value }); } case l.DOLLAR: if (t) if (this.expectToken(l.DOLLAR), this._lexer.token.kind === l.NAME) { const r = this._lexer.token.value; throw O( this._lexer.source, n.start, `Unexpected variable "$${r}" in constant value.` ); } else throw this.unexpected(n); return this.parseVariable(); default: throw this.unexpected(); } } parseConstValueLiteral() { return this.parseValueLiteral(!0); } parseStringLiteral() { const t = this._lexer.token; return this.advanceLexer(), this.node(t, { kind: g.STRING, value: t.value, block: t.kind === l.BLOCK_STRING }); } /** * ListValue[Const] : * - [ ] * - [ Value[?Const]+ ] */ parseList(t) { const n = () => this.parseValueLiteral(t); return this.node(this._lexer.token, { kind: g.LIST, values: this.any(l.BRACKET_L, n, l.BRACKET_R) }); } /** * ``` * ObjectValue[Const] : * - { } * - { ObjectField[?Const]+ } * ``` */ parseObject(t) { const n = () => this.parseObjectField(t); return this.node(this._lexer.token, { kind: g.OBJECT, fields: this.any(l.BRACE_L, n, l.BRACE_R) }); } /** * ObjectField[Const] : Name : Value[?Const] */ parseObjectField(t) { const n = this._lexer.token, r = this.parseName(); return this.expectToken(l.COLON), this.node(n, { kind: g.OBJECT_FIELD, name: r, value: this.parseValueLiteral(t) }); } // Implements the parsing rules in the Directives section. /** * Directives[Const] : Directive[?Const]+ */ parseDirectives(t) { const n = []; for (; this.peek(l.AT); ) n.push(this.parseDirective(t)); return n; } parseConstDirectives() { return this.parseDirectives(!0); } /** * ``` * Directive[Const] : @ Name Arguments[?Const]? * ``` */ parseDirective(t) { const n = this._lexer.token; return this.expectToken(l.AT), this.node(n, { kind: g.DIRECTIVE, name: this.parseName(), arguments: this.parseArguments(t) }); } // Implements the parsing rules in the Types section. /** * Type : * - NamedType * - ListType * - NonNullType */ parseTypeReference() { const t = this._lexer.token; let n; if (this.expectOptionalToken(l.BRACKET_L)) { const r = this.parseTypeReference(); this.expectToken(l.BRACKET_R), n = this.node(t, { kind: g.LIST_TYPE, type: r }); } else n = this.parseNamedType(); return this.expectOptionalToken(l.BANG) ? this.node(t, { kind: g.NON_NULL_TYPE, type: n }) : n; } /** * NamedType : Name */ parseNamedType() { return this.node(this._lexer.token, { kind: g.NAMED_TYPE, name: this.parseName() }); } // Implements the parsing rules in the Type Definition section. peekDescription() { return this.peek(l.STRING) || this.peek(l.BLOCK_STRING); } /** * Description : StringValue */ parseDescription() { if (this.peekDescription()) return this.parseStringLiteral(); } /** * ``` * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } * ``` */ parseSchemaDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("schema"); const r = this.parseConstDirectives(), i = this.many( l.BRACE_L, this.parseOperationTypeDefinition, l.BRACE_R ); return this.node(t, { kind: g.SCHEMA_DEFINITION, description: n, directives: r, operationTypes: i }); } /** * OperationTypeDefinition : OperationType : NamedType */ parseOperationTypeDefinition() { const t = this._lexer.token, n = this.parseOperationType(); this.expectToken(l.COLON); const r = this.parseNamedType(); return this.node(t, { kind: g.OPERATION_TYPE_DEFINITION, operation: n, type: r }); } /** * ScalarTypeDefinition : Description? scalar Name Directives[Const]? */ parseScalarTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("scalar"); const r = this.parseName(), i = this.parseConstDirectives(); return this.node(t, { kind: g.SCALAR_TYPE_DEFINITION, description: n, name: r, directives: i }); } /** * ObjectTypeDefinition : * Description? * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? */ parseObjectTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("type"); const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), o = this.parseFieldsDefinition(); return this.node(t, { kind: g.OBJECT_TYPE_DEFINITION, description: n, name: r, interfaces: i, directives: s, fields: o }); } /** * ImplementsInterfaces : * - implements `&`? NamedType * - ImplementsInterfaces & NamedType */ parseImplementsInterfaces() { return this.expectOptionalKeyword("implements") ? this.delimitedMany(l.AMP, this.parseNamedType) : []; } /** * ``` * FieldsDefinition : { FieldDefinition+ } * ``` */ parseFieldsDefinition() { return this.optionalMany( l.BRACE_L, this.parseFieldDefinition, l.BRACE_R ); } /** * FieldDefinition : * - Description? Name ArgumentsDefinition? : Type Directives[Const]? */ parseFieldDefinition() { const t = this._lexer.token, n = this.parseDescription(), r = this.parseName(), i = this.parseArgumentDefs(); this.expectToken(l.COLON); const s = this.parseTypeReference(), o = this.parseConstDirectives(); return this.node(t, { kind: g.FIELD_DEFINITION, description: n, name: r, arguments: i, type: s, directives: o }); } /** * ArgumentsDefinition : ( InputValueDefinition+ ) */ parseArgumentDefs() { return this.optionalMany( l.PAREN_L, this.parseInputValueDef, l.PAREN_R ); } /** * InputValueDefinition : * - Description? Name : Type DefaultValue? Directives[Const]? */ parseInputValueDef() { const t = this._lexer.token, n = this.parseDescription(), r = this.parseName(); this.expectToken(l.COLON); const i = this.parseTypeReference(); let s; this.expectOptionalToken(l.EQUALS) && (s = this.parseConstValueLiteral()); const o = this.parseConstDirectives(); return this.node(t, { kind: g.INPUT_VALUE_DEFINITION, description: n, name: r, type: i, defaultValue: s, directives: o }); } /** * InterfaceTypeDefinition : * - Description? interface Name Directives[Const]? FieldsDefinition? */ parseInterfaceTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("interface"); const r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), o = this.parseFieldsDefinition(); return this.node(t, { kind: g.INTERFACE_TYPE_DEFINITION, description: n, name: r, interfaces: i, directives: s, fields: o }); } /** * UnionTypeDefinition : * - Description? union Name Directives[Const]? UnionMemberTypes? */ parseUnionTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("union"); const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseUnionMemberTypes(); return this.node(t, { kind: g.UNION_TYPE_DEFINITION, description: n, name: r, directives: i, types: s }); } /** * UnionMemberTypes : * - = `|`? NamedType * - UnionMemberTypes | NamedType */ parseUnionMemberTypes() { return this.expectOptionalToken(l.EQUALS) ? this.delimitedMany(l.PIPE, this.parseNamedType) : []; } /** * EnumTypeDefinition : * - Description? enum Name Directives[Const]? EnumValuesDefinition? */ parseEnumTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("enum"); const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseEnumValuesDefinition(); return this.node(t, { kind: g.ENUM_TYPE_DEFINITION, description: n, name: r, directives: i, values: s }); } /** * ``` * EnumValuesDefinition : { EnumValueDefinition+ } * ``` */ parseEnumValuesDefinition() { return this.optionalMany( l.BRACE_L, this.parseEnumValueDefinition, l.BRACE_R ); } /** * EnumValueDefinition : Description? EnumValue Directives[Const]? */ parseEnumValueDefinition() { const t = this._lexer.token, n = this.parseDescription(), r = this.parseEnumValueName(), i = this.parseConstDirectives(); return this.node(t, { kind: g.ENUM_VALUE_DEFINITION, description: n, name: r, directives: i }); } /** * EnumValue : Name but not `true`, `false` or `null` */ parseEnumValueName() { if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw O( this._lexer.source, this._lexer.token.start, `${ue( this._lexer.token )} is reserved and cannot be used for an enum value.` ); return this.parseName(); } /** * InputObjectTypeDefinition : * - Description? input Name Directives[Const]? InputFieldsDefinition? */ parseInputObjectTypeDefinition() { const t = this._lexer.token, n = this.parseDescription(); this.expectKeyword("input"); const r = this.parseName(), i = this.parseConstDirectives(), s = this.parseInputFieldsDefinition(); return this.node(t, { kind: g.INPUT_OBJECT_TYPE_DEFINITION, description: n, name: r, directives: i, fields: s }); } /** * ``` * InputFieldsDefinition : { InputValueDefinition+ } * ``` */ parseInputFieldsDefinition() { return this.optionalMany( l.BRACE_L, this.parseInputValueDef, l.BRACE_R ); } /** * TypeSystemExtension : * - SchemaExtension * - TypeExtension * * TypeExtension : * - ScalarTypeExtension * - ObjectTypeExtension * - InterfaceTypeExtension * - UnionTypeExtension * - EnumTypeExtension * - InputObjectTypeDefinition */ parseTypeSystemExtension() { const t = this._lexer.lookahead(); if (t.kind === l.NAME) switch (t.value) { case "schema":