@launchdarkly/observability
Version:
Browser observability for your web app. Capture frontend metrics, errors, logs and traces.
1,762 lines (1,757 loc) • 511 kB
JavaScript
var Oc = Object.defineProperty, Sc = (t, e, r) => e in t ? Oc(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, yt = (t, e, r) => Sc(t, typeof e != "symbol" ? e + "" : e, r), wc = (t, e, r) => new Promise((n, i) => {
var o = (c) => {
try {
u(r.next(c));
} catch (s) {
i(s);
}
}, a = (c) => {
try {
u(r.throw(c));
} catch (s) {
i(s);
}
}, u = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(o, a);
u((r = r.apply(t, e)).next());
});
const yo = /* @__PURE__ */ Object.create(null), Lt = (t, e, ...r) => {
const n = `[@launchdarkly plugins]: (${t}): `;
console[e].apply(console, [n, ...r]), Ac(n, ...r);
}, Rt = (t, e, r, ...n) => {
yo[`${t}-${e}`] || (yo[`${t}-${e}`] = !0, Lt(t, r, ...n));
}, Ac = (t, ...e) => wc(void 0, null, function* () {
try {
const { LDObserve: r } = yield Promise.resolve().then(() => Gp);
r.recordLog(`${t}${e}`, "warn");
} catch {
}
});
class Lc {
constructor(e, r) {
yt(this, "debug"), yt(this, "name"), this.debug = e, this.name = r;
}
log(...e) {
if (this.debug) {
let r = `[${Date.now()}]`;
this.name && (r += ` - ${this.name}`), console.log.apply(console, [r, ...e]);
}
}
warn(...e) {
let r = `[${Date.now()}]`;
this.name && (r += ` - ${this.name}`), console.warn.apply(console, [r, ...e]);
}
}
let is = class {
constructor() {
yt(this, "_sdk"), yt(this, "_isLoaded", !1), yt(this, "_callBuffer", []), yt(this, "_capacity", 1e5), yt(this, "_droppedEvents", 0), yt(this, "_exceededCapacity", !1), yt(this, "_logger", new Lc());
}
_bufferCall(e, r) {
if (this._isLoaded)
try {
return this._sdk[e](...r);
} catch (n) {
Lt(
`Error executing buffered call to ${e}:`,
"error",
n
);
}
else {
this._enqueue({ method: e, args: r });
return;
}
}
_enqueue(e) {
this._callBuffer.length < this._capacity ? (this._callBuffer.push(e), this._exceededCapacity = !1) : (this._exceededCapacity || (this._exceededCapacity = !0, Lt(
"Exceeded event queue capacity. Increase capacity to avoid dropping events.",
"warn"
)), this._droppedEvents += 1);
}
load(e) {
this._sdk = e, this._isLoaded = !0;
for (const { method: r, args: n } of this._callBuffer)
try {
this._sdk[r](...n);
} catch (i) {
Lt(
`Error executing buffered call to ${r}:`,
"error",
i
);
}
this._callBuffer = [];
}
};
var Rc = Object.defineProperty, Cc = Object.defineProperties, Nc = Object.getOwnPropertyDescriptors, wr = Object.getOwnPropertySymbols, os = Object.prototype.hasOwnProperty, as = Object.prototype.propertyIsEnumerable, Qn = (t, e, r) => e in t ? Rc(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, N = (t, e) => {
for (var r in e || (e = {}))
os.call(e, r) && Qn(t, r, e[r]);
if (wr)
for (var r of wr(e))
as.call(e, r) && Qn(t, r, e[r]);
return t;
}, Ar = (t, e) => Cc(t, Nc(e)), xe = (t, e) => {
var r = {};
for (var n in t)
os.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]);
if (t != null && wr)
for (var n of wr(t))
e.indexOf(n) < 0 && as.call(t, n) && (r[n] = t[n]);
return r;
}, Ue = (t, e, r) => Qn(t, typeof e != "symbol" ? e + "" : e, r), he = (t, e, r) => new Promise((n, i) => {
var o = (c) => {
try {
u(r.next(c));
} catch (s) {
i(s);
}
}, a = (c) => {
try {
u(r.throw(c));
} catch (s) {
i(s);
}
}, u = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(o, a);
u((r = r.apply(t, e)).next());
});
function vr(t, e) {
throw new Error(e);
}
function xc(t) {
return typeof t == "object" && t !== null;
}
function Pc(t, e) {
throw new Error(
"Unexpected invariant triggered."
);
}
const Ic = /\r\n|[\n\r]/g;
function Zn(t, e) {
let r = 0, n = 1;
for (const i of t.body.matchAll(Ic)) {
if (typeof i.index == "number" || Pc(), i.index >= e)
break;
r = i.index + i[0].length, n += 1;
}
return {
line: n,
column: e + 1 - r
};
}
function Mc(t) {
return ss(
t.source,
Zn(t.source, t.start)
);
}
function ss(t, e) {
const r = t.locationOffset.column - 1, n = "".padStart(r) + t.body, i = e.line - 1, o = t.locationOffset.line - 1, a = e.line + o, u = e.line === 1 ? r : 0, c = e.column + u, s = `${t.name}:${a}:${c}
`, l = n.split(/\r\n|[\n\r]/g), p = l[i];
if (p.length > 120) {
const f = Math.floor(c / 80), y = c % 80, d = [];
for (let m = 0; m < p.length; m += 80)
d.push(p.slice(m, m + 80));
return s + mo([
[`${a} |`, d[0]],
...d.slice(1, f + 1).map((m) => ["|", m]),
["|", "^".padStart(y)],
["|", d[f + 1]]
]);
}
return s + mo([
// Lines specified like this: ["prefix", "string"],
[`${a - 1} |`, l[i - 1]],
[`${a} |`, p],
["|", "^".padStart(c)],
[`${a + 1} |`, l[i + 1]]
]);
}
function mo(t) {
const e = t.filter(([n, i]) => i !== void 0), r = Math.max(...e.map(([n]) => n.length));
return e.map(([n, i]) => n.padStart(r) + (i ? " " + i : "")).join(`
`);
}
function kc(t) {
const e = t[0];
return e == null || "kind" in e || "length" in e ? {
nodes: e,
source: t[1],
positions: t[2],
path: t[3],
originalError: t[4],
extensions: t[5]
} : e;
}
let Dc = class us 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, ...r) {
var n, i, o;
const { nodes: a, source: u, positions: c, path: s, originalError: l, extensions: p } = kc(r);
super(e), this.name = "GraphQLError", this.path = s ?? void 0, this.originalError = l ?? void 0, this.nodes = _o(
Array.isArray(a) ? a : a ? [a] : void 0
);
const f = _o(
(n = this.nodes) === null || n === void 0 ? void 0 : n.map((d) => d.loc).filter((d) => d != null)
);
this.source = u ?? (f == null || (i = f[0]) === null || i === void 0 ? void 0 : i.source), this.positions = c ?? f?.map((d) => d.start), this.locations = c && u ? c.map((d) => Zn(u, d)) : f?.map((d) => Zn(d.source, d.start));
const y = xc(
l?.extensions
) ? l?.extensions : void 0;
this.extensions = (o = p ?? y) !== null && o !== void 0 ? o : /* @__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
}
}), l != null && l.stack ? Object.defineProperty(this, "stack", {
value: l.stack,
writable: !0,
configurable: !0
}) : Error.captureStackTrace ? Error.captureStackTrace(this, us) : 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 r of this.nodes)
r.loc && (e += `
` + Mc(r.loc));
else if (this.source && this.locations)
for (const r of this.locations)
e += `
` + ss(this.source, r);
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 _o(t) {
return t === void 0 || t.length === 0 ? void 0 : t;
}
function z(t, e, r) {
return new Dc(`Syntax Error: ${r}`, {
source: t,
positions: [e]
});
}
let Uc = class {
/**
* 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, r, n) {
this.start = e.start, this.end = r.end, this.startToken = e, this.endToken = r, this.source = n;
}
get [Symbol.toStringTag]() {
return "Location";
}
toJSON() {
return {
start: this.start,
end: this.end
};
}
}, cs = 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, r, n, i, o, a) {
this.kind = e, this.start = r, this.end = n, this.line = i, this.column = o, this.value = a, 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 ls = {
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"]
}, jc = new Set(Object.keys(ls));
function go(t) {
const e = t?.kind;
return typeof e == "string" && jc.has(e);
}
var ae;
(function(t) {
t.QUERY = "query", t.MUTATION = "mutation", t.SUBSCRIPTION = "subscription";
})(ae || (ae = {}));
var ti;
(function(t) {
t.QUERY = "QUERY", t.MUTATION = "MUTATION", t.SUBSCRIPTION = "SUBSCRIPTION", t.FIELD = "FIELD", t.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", t.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", t.INLINE_FRAGMENT = "INLINE_FRAGMENT", t.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", t.SCHEMA = "SCHEMA", t.SCALAR = "SCALAR", t.OBJECT = "OBJECT", t.FIELD_DEFINITION = "FIELD_DEFINITION", t.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", t.INTERFACE = "INTERFACE", t.UNION = "UNION", t.ENUM = "ENUM", t.ENUM_VALUE = "ENUM_VALUE", t.INPUT_OBJECT = "INPUT_OBJECT", t.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
})(ti || (ti = {}));
var O;
(function(t) {
t.NAME = "Name", t.DOCUMENT = "Document", t.OPERATION_DEFINITION = "OperationDefinition", t.VARIABLE_DEFINITION = "VariableDefinition", t.SELECTION_SET = "SelectionSet", t.FIELD = "Field", t.ARGUMENT = "Argument", t.FRAGMENT_SPREAD = "FragmentSpread", t.INLINE_FRAGMENT = "InlineFragment", t.FRAGMENT_DEFINITION = "FragmentDefinition", t.VARIABLE = "Variable", t.INT = "IntValue", t.FLOAT = "FloatValue", t.STRING = "StringValue", t.BOOLEAN = "BooleanValue", t.NULL = "NullValue", t.ENUM = "EnumValue", t.LIST = "ListValue", t.OBJECT = "ObjectValue", t.OBJECT_FIELD = "ObjectField", t.DIRECTIVE = "Directive", t.NAMED_TYPE = "NamedType", t.LIST_TYPE = "ListType", t.NON_NULL_TYPE = "NonNullType", t.SCHEMA_DEFINITION = "SchemaDefinition", t.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", t.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", t.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", t.FIELD_DEFINITION = "FieldDefinition", t.INPUT_VALUE_DEFINITION = "InputValueDefinition", t.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", t.UNION_TYPE_DEFINITION = "UnionTypeDefinition", t.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", t.ENUM_VALUE_DEFINITION = "EnumValueDefinition", t.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", t.DIRECTIVE_DEFINITION = "DirectiveDefinition", t.SCHEMA_EXTENSION = "SchemaExtension", t.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", t.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", t.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", t.UNION_TYPE_EXTENSION = "UnionTypeExtension", t.ENUM_TYPE_EXTENSION = "EnumTypeExtension", t.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
})(O || (O = {}));
function ei(t) {
return t === 9 || t === 32;
}
function je(t) {
return t >= 48 && t <= 57;
}
function ps(t) {
return t >= 97 && t <= 122 || // A-Z
t >= 65 && t <= 90;
}
function fs(t) {
return ps(t) || t === 95;
}
function Bc(t) {
return ps(t) || je(t) || t === 95;
}
function $c(t) {
var e;
let r = Number.MAX_SAFE_INTEGER, n = null, i = -1;
for (let a = 0; a < t.length; ++a) {
var o;
const u = t[a], c = Fc(u);
c !== u.length && (n = (o = n) !== null && o !== void 0 ? o : a, i = a, a !== 0 && c < r && (r = c));
}
return t.map((a, u) => u === 0 ? a : a.slice(r)).slice(
(e = n) !== null && e !== void 0 ? e : 0,
i + 1
);
}
function Fc(t) {
let e = 0;
for (; e < t.length && ei(t.charCodeAt(e)); )
++e;
return e;
}
function Vc(t, e) {
const r = t.replace(/"""/g, '\\"""'), n = r.split(/\r\n|[\n\r]/g), i = n.length === 1, o = n.length > 1 && n.slice(1).every((y) => y.length === 0 || ei(y.charCodeAt(0))), a = r.endsWith('\\"""'), u = t.endsWith('"') && !a, c = t.endsWith("\\"), s = u || c, l = (
// add leading and trailing new lines only if it improves readability
!i || t.length > 70 || s || o || a
);
let p = "";
const f = i && ei(t.charCodeAt(0));
return (l && !f || o) && (p += `
`), p += r, (l || s) && (p += `
`), '"""' + p + '"""';
}
var v;
(function(t) {
t.SOF = "<SOF>", t.EOF = "<EOF>", t.BANG = "!", t.DOLLAR = "$", t.AMP = "&", t.PAREN_L = "(", t.PAREN_R = ")", t.SPREAD = "...", t.COLON = ":", t.EQUALS = "=", t.AT = "@", t.BRACKET_L = "[", t.BRACKET_R = "]", t.BRACE_L = "{", t.PIPE = "|", t.BRACE_R = "}", t.NAME = "Name", t.INT = "Int", t.FLOAT = "Float", t.STRING = "String", t.BLOCK_STRING = "BlockString", t.COMMENT = "Comment";
})(v || (v = {}));
let Hc = class {
/**
* 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 r = new cs(v.SOF, 0, 0, 0, 0);
this.source = e, this.lastToken = r, this.token = r, 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 !== v.EOF)
do
if (e.next)
e = e.next;
else {
const r = qc(this, e.end);
e.next = r, r.prev = e, e = r;
}
while (e.kind === v.COMMENT);
return e;
}
};
function Gc(t) {
return t === v.BANG || t === v.DOLLAR || t === v.AMP || t === v.PAREN_L || t === v.PAREN_R || t === v.SPREAD || t === v.COLON || t === v.EQUALS || t === v.AT || t === v.BRACKET_L || t === v.BRACKET_R || t === v.BRACE_L || t === v.PIPE || t === v.BRACE_R;
}
function me(t) {
return t >= 0 && t <= 55295 || t >= 57344 && t <= 1114111;
}
function Gr(t, e) {
return hs(t.charCodeAt(e)) && ds(t.charCodeAt(e + 1));
}
function hs(t) {
return t >= 55296 && t <= 56319;
}
function ds(t) {
return t >= 56320 && t <= 57343;
}
function Ht(t, e) {
const r = t.source.body.codePointAt(e);
if (r === void 0)
return v.EOF;
if (r >= 32 && r <= 126) {
const n = String.fromCodePoint(r);
return n === '"' ? `'"'` : `"${n}"`;
}
return "U+" + r.toString(16).toUpperCase().padStart(4, "0");
}
function $(t, e, r, n, i) {
const o = t.line, a = 1 + r - t.lineStart;
return new cs(e, r, n, o, a, i);
}
function qc(t, e) {
const r = t.source.body, n = r.length;
let i = e;
for (; i < n; ) {
const o = r.charCodeAt(i);
switch (o) {
// 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, ++t.line, t.lineStart = i;
continue;
case 13:
r.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++t.line, t.lineStart = i;
continue;
// Comment
case 35:
return zc(t, i);
// Token ::
// - Punctuator
// - Name
// - IntValue
// - FloatValue
// - StringValue
//
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
case 33:
return $(t, v.BANG, i, i + 1);
case 36:
return $(t, v.DOLLAR, i, i + 1);
case 38:
return $(t, v.AMP, i, i + 1);
case 40:
return $(t, v.PAREN_L, i, i + 1);
case 41:
return $(t, v.PAREN_R, i, i + 1);
case 46:
if (r.charCodeAt(i + 1) === 46 && r.charCodeAt(i + 2) === 46)
return $(t, v.SPREAD, i, i + 3);
break;
case 58:
return $(t, v.COLON, i, i + 1);
case 61:
return $(t, v.EQUALS, i, i + 1);
case 64:
return $(t, v.AT, i, i + 1);
case 91:
return $(t, v.BRACKET_L, i, i + 1);
case 93:
return $(t, v.BRACKET_R, i, i + 1);
case 123:
return $(t, v.BRACE_L, i, i + 1);
case 124:
return $(t, v.PIPE, i, i + 1);
case 125:
return $(t, v.BRACE_R, i, i + 1);
// StringValue
case 34:
return r.charCodeAt(i + 1) === 34 && r.charCodeAt(i + 2) === 34 ? Qc(t, i) : Kc(t, i);
}
if (je(o) || o === 45)
return Xc(t, i, o);
if (fs(o))
return Zc(t, i);
throw z(
t.source,
i,
o === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : me(o) || Gr(r, i) ? `Unexpected character: ${Ht(t, i)}.` : `Invalid character: ${Ht(t, i)}.`
);
}
return $(t, v.EOF, n, n);
}
function zc(t, e) {
const r = t.source.body, n = r.length;
let i = e + 1;
for (; i < n; ) {
const o = r.charCodeAt(i);
if (o === 10 || o === 13)
break;
if (me(o))
++i;
else if (Gr(r, i))
i += 2;
else
break;
}
return $(
t,
v.COMMENT,
e,
i,
r.slice(e + 1, i)
);
}
function Xc(t, e, r) {
const n = t.source.body;
let i = e, o = r, a = !1;
if (o === 45 && (o = n.charCodeAt(++i)), o === 48) {
if (o = n.charCodeAt(++i), je(o))
throw z(
t.source,
i,
`Invalid number, unexpected digit after 0: ${Ht(
t,
i
)}.`
);
} else
i = en(t, i, o), o = n.charCodeAt(i);
if (o === 46 && (a = !0, o = n.charCodeAt(++i), i = en(t, i, o), o = n.charCodeAt(i)), (o === 69 || o === 101) && (a = !0, o = n.charCodeAt(++i), (o === 43 || o === 45) && (o = n.charCodeAt(++i)), i = en(t, i, o), o = n.charCodeAt(i)), o === 46 || fs(o))
throw z(
t.source,
i,
`Invalid number, expected digit but got: ${Ht(
t,
i
)}.`
);
return $(
t,
a ? v.FLOAT : v.INT,
e,
i,
n.slice(e, i)
);
}
function en(t, e, r) {
if (!je(r))
throw z(
t.source,
e,
`Invalid number, expected digit but got: ${Ht(
t,
e
)}.`
);
const n = t.source.body;
let i = e + 1;
for (; je(n.charCodeAt(i)); )
++i;
return i;
}
function Kc(t, e) {
const r = t.source.body, n = r.length;
let i = e + 1, o = i, a = "";
for (; i < n; ) {
const u = r.charCodeAt(i);
if (u === 34)
return a += r.slice(o, i), $(t, v.STRING, e, i + 1, a);
if (u === 92) {
a += r.slice(o, i);
const c = r.charCodeAt(i + 1) === 117 ? r.charCodeAt(i + 2) === 123 ? Wc(t, i) : Yc(t, i) : Jc(t, i);
a += c.value, i += c.size, o = i;
continue;
}
if (u === 10 || u === 13)
break;
if (me(u))
++i;
else if (Gr(r, i))
i += 2;
else
throw z(
t.source,
i,
`Invalid character within String: ${Ht(
t,
i
)}.`
);
}
throw z(t.source, i, "Unterminated string.");
}
function Wc(t, e) {
const r = t.source.body;
let n = 0, i = 3;
for (; i < 12; ) {
const o = r.charCodeAt(e + i++);
if (o === 125) {
if (i < 5 || !me(n))
break;
return {
value: String.fromCodePoint(n),
size: i
};
}
if (n = n << 4 | Ce(o), n < 0)
break;
}
throw z(
t.source,
e,
`Invalid Unicode escape sequence: "${r.slice(
e,
e + i
)}".`
);
}
function Yc(t, e) {
const r = t.source.body, n = Eo(r, e + 2);
if (me(n))
return {
value: String.fromCodePoint(n),
size: 6
};
if (hs(n) && r.charCodeAt(e + 6) === 92 && r.charCodeAt(e + 7) === 117) {
const i = Eo(r, e + 8);
if (ds(i))
return {
value: String.fromCodePoint(n, i),
size: 12
};
}
throw z(
t.source,
e,
`Invalid Unicode escape sequence: "${r.slice(e, e + 6)}".`
);
}
function Eo(t, e) {
return Ce(t.charCodeAt(e)) << 12 | Ce(t.charCodeAt(e + 1)) << 8 | Ce(t.charCodeAt(e + 2)) << 4 | Ce(t.charCodeAt(e + 3));
}
function Ce(t) {
return t >= 48 && t <= 57 ? t - 48 : t >= 65 && t <= 70 ? t - 55 : t >= 97 && t <= 102 ? t - 87 : -1;
}
function Jc(t, e) {
const r = t.source.body;
switch (r.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 z(
t.source,
e,
`Invalid character escape sequence: "${r.slice(
e,
e + 2
)}".`
);
}
function Qc(t, e) {
const r = t.source.body, n = r.length;
let i = t.lineStart, o = e + 3, a = o, u = "";
const c = [];
for (; o < n; ) {
const s = r.charCodeAt(o);
if (s === 34 && r.charCodeAt(o + 1) === 34 && r.charCodeAt(o + 2) === 34) {
u += r.slice(a, o), c.push(u);
const l = $(
t,
v.BLOCK_STRING,
e,
o + 3,
// Return a string of the lines joined with U+000A.
$c(c).join(`
`)
);
return t.line += c.length - 1, t.lineStart = i, l;
}
if (s === 92 && r.charCodeAt(o + 1) === 34 && r.charCodeAt(o + 2) === 34 && r.charCodeAt(o + 3) === 34) {
u += r.slice(a, o), a = o + 1, o += 4;
continue;
}
if (s === 10 || s === 13) {
u += r.slice(a, o), c.push(u), s === 13 && r.charCodeAt(o + 1) === 10 ? o += 2 : ++o, u = "", a = o, i = o;
continue;
}
if (me(s))
++o;
else if (Gr(r, o))
o += 2;
else
throw z(
t.source,
o,
`Invalid character within String: ${Ht(
t,
o
)}.`
);
}
throw z(t.source, o, "Unterminated string.");
}
function Zc(t, e) {
const r = t.source.body, n = r.length;
let i = e + 1;
for (; i < n; ) {
const o = r.charCodeAt(i);
if (Bc(o))
++i;
else
break;
}
return $(
t,
v.NAME,
e,
i,
r.slice(e, i)
);
}
const tl = 10, vs = 2;
function Vi(t) {
return qr(t, []);
}
function qr(t, e) {
switch (typeof t) {
case "string":
return JSON.stringify(t);
case "function":
return t.name ? `[function ${t.name}]` : "[function]";
case "object":
return el(t, e);
default:
return String(t);
}
}
function el(t, e) {
if (t === null)
return "null";
if (e.includes(t))
return "[Circular]";
const r = [...e, t];
if (rl(t)) {
const n = t.toJSON();
if (n !== t)
return typeof n == "string" ? n : qr(n, r);
} else if (Array.isArray(t))
return il(t, r);
return nl(t, r);
}
function rl(t) {
return typeof t.toJSON == "function";
}
function nl(t, e) {
const r = Object.entries(t);
return r.length === 0 ? "{}" : e.length > vs ? "[" + ol(t) + "]" : "{ " + r.map(
([n, i]) => n + ": " + qr(i, e)
).join(", ") + " }";
}
function il(t, e) {
if (t.length === 0)
return "[]";
if (e.length > vs)
return "[Array]";
const r = Math.min(tl, t.length), n = t.length - r, i = [];
for (let o = 0; o < r; ++o)
i.push(qr(t[o], e));
return n === 1 ? i.push("... 1 more item") : n > 1 && i.push(`... ${n} more items`), "[" + i.join(", ") + "]";
}
function ol(t) {
const e = Object.prototype.toString.call(t).replace(/^\[object /, "").replace(/]$/, "");
if (e === "Object" && typeof t.constructor == "function") {
const r = t.constructor.name;
if (typeof r == "string" && r !== "")
return r;
}
return e;
}
const al = globalThis.process && // eslint-disable-next-line no-undef
process.env.NODE_ENV === "production", sl = (
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
al ? function(t, e) {
return t instanceof e;
} : function(t, e) {
if (t instanceof e)
return !0;
if (typeof t == "object" && t !== null) {
var r;
const n = e.prototype[Symbol.toStringTag], i = (
// 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 (n === i) {
const o = Vi(t);
throw new Error(`Cannot use ${n} "${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;
}
);
let ys = class {
constructor(e, r = "GraphQL request", n = {
line: 1,
column: 1
}) {
typeof e == "string" || vr(!1, `Body must be a string. Received: ${Vi(e)}.`), this.body = e, this.name = r, this.locationOffset = n, this.locationOffset.line > 0 || vr(
!1,
"line in locationOffset is 1-indexed and must be positive."
), this.locationOffset.column > 0 || vr(
!1,
"column in locationOffset is 1-indexed and must be positive."
);
}
get [Symbol.toStringTag]() {
return "Source";
}
};
function ul(t) {
return sl(t, ys);
}
function ms(t, e) {
const r = new cl(t, e), n = r.parseDocument();
return Object.defineProperty(n, "tokenCount", {
enumerable: !1,
value: r.tokenCount
}), n;
}
let cl = class {
constructor(e, r = {}) {
const n = ul(e) ? e : new ys(e);
this._lexer = new Hc(n), this._options = r, this._tokenCounter = 0;
}
get tokenCount() {
return this._tokenCounter;
}
/**
* Converts a name lex token into a name parse node.
*/
parseName() {
const e = this.expectToken(v.NAME);
return this.node(e, {
kind: O.NAME,
value: e.value
});
}
// Implements the parsing rules in the Document section.
/**
* Document : Definition+
*/
parseDocument() {
return this.node(this._lexer.token, {
kind: O.DOCUMENT,
definitions: this.many(
v.SOF,
this.parseDefinition,
v.EOF
)
});
}
/**
* Definition :
* - ExecutableDefinition
* - TypeSystemDefinition
* - TypeSystemExtension
*
* ExecutableDefinition :
* - OperationDefinition
* - FragmentDefinition
*
* TypeSystemDefinition :
* - SchemaDefinition
* - TypeDefinition
* - DirectiveDefinition
*
* TypeDefinition :
* - ScalarTypeDefinition
* - ObjectTypeDefinition
* - InterfaceTypeDefinition
* - UnionTypeDefinition
* - EnumTypeDefinition
* - InputObjectTypeDefinition
*/
parseDefinition() {
if (this.peek(v.BRACE_L))
return this.parseOperationDefinition();
const e = this.peekDescription(), r = e ? this._lexer.lookahead() : this._lexer.token;
if (r.kind === v.NAME) {
switch (r.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 (e)
throw z(
this._lexer.source,
this._lexer.token.start,
"Unexpected description, descriptions are supported only on type definitions."
);
switch (r.value) {
case "query":
case "mutation":
case "subscription":
return this.parseOperationDefinition();
case "fragment":
return this.parseFragmentDefinition();
case "extend":
return this.parseTypeSystemExtension();
}
}
throw this.unexpected(r);
}
// Implements the parsing rules in the Operations section.
/**
* OperationDefinition :
* - SelectionSet
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
*/
parseOperationDefinition() {
const e = this._lexer.token;
if (this.peek(v.BRACE_L))
return this.node(e, {
kind: O.OPERATION_DEFINITION,
operation: ae.QUERY,
name: void 0,
variableDefinitions: [],
directives: [],
selectionSet: this.parseSelectionSet()
});
const r = this.parseOperationType();
let n;
return this.peek(v.NAME) && (n = this.parseName()), this.node(e, {
kind: O.OPERATION_DEFINITION,
operation: r,
name: n,
variableDefinitions: this.parseVariableDefinitions(),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* OperationType : one of query mutation subscription
*/
parseOperationType() {
const e = this.expectToken(v.NAME);
switch (e.value) {
case "query":
return ae.QUERY;
case "mutation":
return ae.MUTATION;
case "subscription":
return ae.SUBSCRIPTION;
}
throw this.unexpected(e);
}
/**
* VariableDefinitions : ( VariableDefinition+ )
*/
parseVariableDefinitions() {
return this.optionalMany(
v.PAREN_L,
this.parseVariableDefinition,
v.PAREN_R
);
}
/**
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
*/
parseVariableDefinition() {
return this.node(this._lexer.token, {
kind: O.VARIABLE_DEFINITION,
variable: this.parseVariable(),
type: (this.expectToken(v.COLON), this.parseTypeReference()),
defaultValue: this.expectOptionalToken(v.EQUALS) ? this.parseConstValueLiteral() : void 0,
directives: this.parseConstDirectives()
});
}
/**
* Variable : $ Name
*/
parseVariable() {
const e = this._lexer.token;
return this.expectToken(v.DOLLAR), this.node(e, {
kind: O.VARIABLE,
name: this.parseName()
});
}
/**
* ```
* SelectionSet : { Selection+ }
* ```
*/
parseSelectionSet() {
return this.node(this._lexer.token, {
kind: O.SELECTION_SET,
selections: this.many(
v.BRACE_L,
this.parseSelection,
v.BRACE_R
)
});
}
/**
* Selection :
* - Field
* - FragmentSpread
* - InlineFragment
*/
parseSelection() {
return this.peek(v.SPREAD) ? this.parseFragment() : this.parseField();
}
/**
* Field : Alias? Name Arguments? Directives? SelectionSet?
*
* Alias : Name :
*/
parseField() {
const e = this._lexer.token, r = this.parseName();
let n, i;
return this.expectOptionalToken(v.COLON) ? (n = r, i = this.parseName()) : i = r, this.node(e, {
kind: O.FIELD,
alias: n,
name: i,
arguments: this.parseArguments(!1),
directives: this.parseDirectives(!1),
selectionSet: this.peek(v.BRACE_L) ? this.parseSelectionSet() : void 0
});
}
/**
* Arguments[Const] : ( Argument[?Const]+ )
*/
parseArguments(e) {
const r = e ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(v.PAREN_L, r, v.PAREN_R);
}
/**
* Argument[Const] : Name : Value[?Const]
*/
parseArgument(e = !1) {
const r = this._lexer.token, n = this.parseName();
return this.expectToken(v.COLON), this.node(r, {
kind: O.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(v.SPREAD);
const r = this.expectOptionalKeyword("on");
return !r && this.peek(v.NAME) ? this.node(e, {
kind: O.FRAGMENT_SPREAD,
name: this.parseFragmentName(),
directives: this.parseDirectives(!1)
}) : this.node(e, {
kind: O.INLINE_FRAGMENT,
typeCondition: r ? 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;
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(e, {
kind: O.FRAGMENT_DEFINITION,
name: this.parseFragmentName(),
variableDefinitions: this.parseVariableDefinitions(),
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
}) : this.node(e, {
kind: O.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(e) {
const r = this._lexer.token;
switch (r.kind) {
case v.BRACKET_L:
return this.parseList(e);
case v.BRACE_L:
return this.parseObject(e);
case v.INT:
return this.advanceLexer(), this.node(r, {
kind: O.INT,
value: r.value
});
case v.FLOAT:
return this.advanceLexer(), this.node(r, {
kind: O.FLOAT,
value: r.value
});
case v.STRING:
case v.BLOCK_STRING:
return this.parseStringLiteral();
case v.NAME:
switch (this.advanceLexer(), r.value) {
case "true":
return this.node(r, {
kind: O.BOOLEAN,
value: !0
});
case "false":
return this.node(r, {
kind: O.BOOLEAN,
value: !1
});
case "null":
return this.node(r, {
kind: O.NULL
});
default:
return this.node(r, {
kind: O.ENUM,
value: r.value
});
}
case v.DOLLAR:
if (e)
if (this.expectToken(v.DOLLAR), this._lexer.token.kind === v.NAME) {
const n = this._lexer.token.value;
throw z(
this._lexer.source,
r.start,
`Unexpected variable "$${n}" in constant value.`
);
} else
throw this.unexpected(r);
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: O.STRING,
value: e.value,
block: e.kind === v.BLOCK_STRING
});
}
/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
parseList(e) {
const r = () => this.parseValueLiteral(e);
return this.node(this._lexer.token, {
kind: O.LIST,
values: this.any(v.BRACKET_L, r, v.BRACKET_R)
});
}
/**
* ```
* ObjectValue[Const] :
* - { }
* - { ObjectField[?Const]+ }
* ```
*/
parseObject(e) {
const r = () => this.parseObjectField(e);
return this.node(this._lexer.token, {
kind: O.OBJECT,
fields: this.any(v.BRACE_L, r, v.BRACE_R)
});
}
/**
* ObjectField[Const] : Name : Value[?Const]
*/
parseObjectField(e) {
const r = this._lexer.token, n = this.parseName();
return this.expectToken(v.COLON), this.node(r, {
kind: O.OBJECT_FIELD,
name: n,
value: this.parseValueLiteral(e)
});
}
// Implements the parsing rules in the Directives section.
/**
* Directives[Const] : Directive[?Const]+
*/
parseDirectives(e) {
const r = [];
for (; this.peek(v.AT); )
r.push(this.parseDirective(e));
return r;
}
parseConstDirectives() {
return this.parseDirectives(!0);
}
/**
* ```
* Directive[Const] : @ Name Arguments[?Const]?
* ```
*/
parseDirective(e) {
const r = this._lexer.token;
return this.expectToken(v.AT), this.node(r, {
kind: O.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 r;
if (this.expectOptionalToken(v.BRACKET_L)) {
const n = this.parseTypeReference();
this.expectToken(v.BRACKET_R), r = this.node(e, {
kind: O.LIST_TYPE,
type: n
});
} else
r = this.parseNamedType();
return this.expectOptionalToken(v.BANG) ? this.node(e, {
kind: O.NON_NULL_TYPE,
type: r
}) : r;
}
/**
* NamedType : Name
*/
parseNamedType() {
return this.node(this._lexer.token, {
kind: O.NAMED_TYPE,
name: this.parseName()
});
}
// Implements the parsing rules in the Type Definition section.
peekDescription() {
return this.peek(v.STRING) || this.peek(v.BLOCK_STRING);
}
/**
* Description : StringValue
*/
parseDescription() {
if (this.peekDescription())
return this.parseStringLiteral();
}
/**
* ```
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
* ```
*/
parseSchemaDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("schema");
const n = this.parseConstDirectives(), i = this.many(
v.BRACE_L,
this.parseOperationTypeDefinition,
v.BRACE_R
);
return this.node(e, {
kind: O.SCHEMA_DEFINITION,
description: r,
directives: n,
operationTypes: i
});
}
/**
* OperationTypeDefinition : OperationType : NamedType
*/
parseOperationTypeDefinition() {
const e = this._lexer.token, r = this.parseOperationType();
this.expectToken(v.COLON);
const n = this.parseNamedType();
return this.node(e, {
kind: O.OPERATION_TYPE_DEFINITION,
operation: r,
type: n
});
}
/**
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
*/
parseScalarTypeDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("scalar");
const n = this.parseName(), i = this.parseConstDirectives();
return this.node(e, {
kind: O.SCALAR_TYPE_DEFINITION,
description: r,
name: n,
directives: i
});
}
/**
* ObjectTypeDefinition :
* Description?
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
*/
parseObjectTypeDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("type");
const n = this.parseName(), i = this.parseImplementsInterfaces(), o = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(e, {
kind: O.OBJECT_TYPE_DEFINITION,
description: r,
name: n,
interfaces: i,
directives: o,
fields: a
});
}
/**
* ImplementsInterfaces :
* - implements `&`? NamedType
* - ImplementsInterfaces & NamedType
*/
parseImplementsInterfaces() {
return this.expectOptionalKeyword("implements") ? this.delimitedMany(v.AMP, this.parseNamedType) : [];
}
/**
* ```
* FieldsDefinition : { FieldDefinition+ }
* ```
*/
parseFieldsDefinition() {
return this.optionalMany(
v.BRACE_L,
this.parseFieldDefinition,
v.BRACE_R
);
}
/**
* FieldDefinition :
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
*/
parseFieldDefinition() {
const e = this._lexer.token, r = this.parseDescription(), n = this.parseName(), i = this.parseArgumentDefs();
this.expectToken(v.COLON);
const o = this.parseTypeReference(), a = this.parseConstDirectives();
return this.node(e, {
kind: O.FIELD_DEFINITION,
description: r,
name: n,
arguments: i,
type: o,
directives: a
});
}
/**
* ArgumentsDefinition : ( InputValueDefinition+ )
*/
parseArgumentDefs() {
return this.optionalMany(
v.PAREN_L,
this.parseInputValueDef,
v.PAREN_R
);
}
/**
* InputValueDefinition :
* - Description? Name : Type DefaultValue? Directives[Const]?
*/
parseInputValueDef() {
const e = this._lexer.token, r = this.parseDescription(), n = this.parseName();
this.expectToken(v.COLON);
const i = this.parseTypeReference();
let o;
this.expectOptionalToken(v.EQUALS) && (o = this.parseConstValueLiteral());
const a = this.parseConstDirectives();
return this.node(e, {
kind: O.INPUT_VALUE_DEFINITION,
description: r,
name: n,
type: i,
defaultValue: o,
directives: a
});
}
/**
* InterfaceTypeDefinition :
* - Description? interface Name Directives[Const]? FieldsDefinition?
*/
parseInterfaceTypeDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("interface");
const n = this.parseName(), i = this.parseImplementsInterfaces(), o = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(e, {
kind: O.INTERFACE_TYPE_DEFINITION,
description: r,
name: n,
interfaces: i,
directives: o,
fields: a
});
}
/**
* UnionTypeDefinition :
* - Description? union Name Directives[Const]? UnionMemberTypes?
*/
parseUnionTypeDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("union");
const n = this.parseName(), i = this.parseConstDirectives(), o = this.parseUnionMemberTypes();
return this.node(e, {
kind: O.UNION_TYPE_DEFINITION,
description: r,
name: n,
directives: i,
types: o
});
}
/**
* UnionMemberTypes :
* - = `|`? NamedType
* - UnionMemberTypes | NamedType
*/
parseUnionMemberTypes() {
return this.expectOptionalToken(v.EQUALS) ? this.delimitedMany(v.PIPE, this.parseNamedType) : [];
}
/**
* EnumTypeDefinition :
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
*/
parseEnumTypeDefinition() {
const e = this._lexer.token, r = this.parseDescription();
this.expectKeyword("enum");
const n = this.parseName(), i = this.parseConstDirectives(), o = this.parseEnumValuesDefinition();
return this.node(e, {
kind: O.ENUM_TYPE_DEFINITION,
description: r,
name: n,
directives: i,
values: o
});
}
/**
* ```
* EnumValuesDefinition : { EnumValueDefinition+ }
* ```
*/
parseEnumValuesDefinition() {
return this.optionalMany(
v.BRACE_L,
this.parseEnumValueDefinition,
v.BRACE_R
);
}
/**
* EnumValueDefinition : Description? EnumValue Directives[Const]?
*/
parseEnumValueDefinition() {
const e = this._lexer.token, r = this.parseDescription(), n = this.parseEnumValueName(), i = this.parseConstDirectives();
return this.node(e, {
kind: O.ENUM_VALUE_DEFINITION,
description: r,
name: n,
directives: i
});
}
/**
* EnumVa