@launchdarkly/observability
Version:
Browser observability for your web app. Capture frontend metrics, errors, logs and traces.
1,754 lines (1,749 loc) • 480 kB
JavaScript
var Iu = Object.defineProperty, Pu = (e, t, r) => t in e ? Iu(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, mt = (e, t, r) => Pu(e, typeof t != "symbol" ? t + "" : t, r), ku = (e, t, 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(e, t)).next());
});
const ki = /* @__PURE__ */ Object.create(null), Ut = (e, t, ...r) => {
const n = `[@launchdarkly plugins]: (${e}): `;
console[t].apply(console, [n, ...r]), Mu(n, ...r);
}, se = (e, t, r, ...n) => {
ki[`${e}-${t}`] || (ki[`${e}-${t}`] = !0, Ut(e, r, ...n));
}, Mu = (e, ...t) => ku(void 0, null, function* () {
try {
const { LDObserve: r } = yield Promise.resolve().then(() => Ql);
r.recordLog(`${e}${t}`, "warn");
} catch {
}
});
class Du {
constructor(t, r) {
mt(this, "debug"), mt(this, "name"), this.debug = t, this.name = r;
}
log(...t) {
if (this.debug) {
let r = `[${Date.now()}]`;
this.name && (r += ` - ${this.name}`), console.log.apply(console, [r, ...t]);
}
}
warn(...t) {
let r = `[${Date.now()}]`;
this.name && (r += ` - ${this.name}`), console.warn.apply(console, [r, ...t]);
}
}
class ya {
constructor() {
mt(this, "_sdk"), mt(this, "_isLoaded", !1), mt(this, "_callBuffer", []), mt(this, "_capacity", 1e5), mt(this, "_droppedEvents", 0), mt(this, "_exceededCapacity", !1), mt(this, "_logger", new Du());
}
_bufferCall(t, r) {
if (this._isLoaded)
try {
return this._sdk[t](...r);
} catch (n) {
Ut(
`Error executing buffered call to ${t}:`,
"error",
n
);
}
else {
this._enqueue({ method: t, args: r });
return;
}
}
_enqueue(t) {
this._callBuffer.length < this._capacity ? (this._callBuffer.push(t), this._exceededCapacity = !1) : (this._exceededCapacity || (this._exceededCapacity = !0, Ut(
"Exceeded event queue capacity. Increase capacity to avoid dropping events.",
"warn"
)), this._droppedEvents += 1);
}
load(t) {
this._sdk = t, this._isLoaded = !0;
for (const { method: r, args: n } of this._callBuffer)
try {
this._sdk[r](...n);
} catch (i) {
Ut(
`Error executing buffered call to ${r}:`,
"error",
i
);
}
this._callBuffer = [];
}
}
var Uu = Object.defineProperty, $u = Object.defineProperties, ju = Object.getOwnPropertyDescriptors, _r = Object.getOwnPropertySymbols, ga = Object.prototype.hasOwnProperty, _a = Object.prototype.propertyIsEnumerable, Mn = (e, t, r) => t in e ? Uu(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, L = (e, t) => {
for (var r in t || (t = {}))
ga.call(t, r) && Mn(e, r, t[r]);
if (_r)
for (var r of _r(t))
_a.call(t, r) && Mn(e, r, t[r]);
return e;
}, oe = (e, t) => $u(e, ju(t)), Ae = (e, t) => {
var r = {};
for (var n in e)
ga.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
if (e != null && _r)
for (var n of _r(e))
t.indexOf(n) < 0 && _a.call(e, n) && (r[n] = e[n]);
return r;
}, Pe = (e, t, r) => Mn(e, typeof t != "symbol" ? t + "" : t, r), ue = (e, t, 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(e, t)).next());
});
function Bu(e, t) {
for (var r = 0; r < t.length; r++) {
const n = t[r];
if (typeof n != "string" && !Array.isArray(n)) {
for (const i in n)
if (i !== "default" && !(i in e)) {
const o = Object.getOwnPropertyDescriptor(n, i);
o && Object.defineProperty(e, i, o.get ? o : {
enumerable: !0,
get: () => n[i]
});
}
}
}
return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
}
function cr(e, t) {
throw new Error(t);
}
function Fu(e) {
return typeof e == "object" && e !== null;
}
function Vu(e, t) {
throw new Error(
"Unexpected invariant triggered."
);
}
const Hu = /\r\n|[\n\r]/g;
function Dn(e, t) {
let r = 0, n = 1;
for (const i of e.body.matchAll(Hu)) {
if (typeof i.index == "number" || Vu(), i.index >= t)
break;
r = i.index + i[0].length, n += 1;
}
return {
line: n,
column: t + 1 - r
};
}
function Gu(e) {
return ba(
e.source,
Dn(e.source, e.start)
);
}
function ba(e, t) {
const r = e.locationOffset.column - 1, n = "".padStart(r) + e.body, i = t.line - 1, o = e.locationOffset.line - 1, a = t.line + o, u = t.line === 1 ? r : 0, c = t.column + u, s = `${e.name}:${a}:${c}
`, l = n.split(/\r\n|[\n\r]/g), p = l[i];
if (p.length > 120) {
const f = Math.floor(c / 80), m = c % 80, v = [];
for (let y = 0; y < p.length; y += 80)
v.push(p.slice(y, y + 80));
return s + Mi([
[`${a} |`, v[0]],
...v.slice(1, f + 1).map((y) => ["|", y]),
["|", "^".padStart(m)],
["|", v[f + 1]]
]);
}
return s + Mi([
// Lines specified like this: ["prefix", "string"],
[`${a - 1} |`, l[i - 1]],
[`${a} |`, p],
["|", "^".padStart(c)],
[`${a + 1} |`, l[i + 1]]
]);
}
function Mi(e) {
const t = e.filter(([n, i]) => i !== void 0), r = Math.max(...t.map(([n]) => n.length));
return t.map(([n, i]) => n.padStart(r) + (i ? " " + i : "")).join(`
`);
}
function zu(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;
}
let qu = class Ea 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, ...r) {
var n, i, o;
const { nodes: a, source: u, positions: c, path: s, originalError: l, extensions: p } = zu(r);
super(t), this.name = "GraphQLError", this.path = s ?? void 0, this.originalError = l ?? void 0, this.nodes = Di(
Array.isArray(a) ? a : a ? [a] : void 0
);
const f = Di(
(n = this.nodes) === null || n === void 0 ? void 0 : n.map((v) => v.loc).filter((v) => v != null)
);
this.source = u ?? (f == null || (i = f[0]) === null || i === void 0 ? void 0 : i.source), this.positions = c ?? f?.map((v) => v.start), this.locations = c && u ? c.map((v) => Dn(u, v)) : f?.map((v) => Dn(v.source, v.start));
const m = Fu(
l?.extensions
) ? l?.extensions : void 0;
this.extensions = (o = p ?? m) !== 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, Ea) : 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 r of this.nodes)
r.loc && (t += `
` + Gu(r.loc));
else if (this.source && this.locations)
for (const r of this.locations)
t += `
` + ba(this.source, r);
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 Di(e) {
return e === void 0 || e.length === 0 ? void 0 : e;
}
function H(e, t, r) {
return new qu(`Syntax Error: ${r}`, {
source: e,
positions: [t]
});
}
let Xu = 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(t, r, n) {
this.start = t.start, this.end = r.end, this.startToken = t, this.endToken = r, this.source = n;
}
get [Symbol.toStringTag]() {
return "Location";
}
toJSON() {
return {
start: this.start,
end: this.end
};
}
}, Ta = 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(t, r, n, i, o, a) {
this.kind = t, 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 wa = {
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"]
}, Ku = new Set(Object.keys(wa));
function Ui(e) {
const t = e?.kind;
return typeof t == "string" && Ku.has(t);
}
var re;
(function(e) {
e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
})(re || (re = {}));
var Un;
(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";
})(Un || (Un = {}));
var w;
(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";
})(w || (w = {}));
function $n(e) {
return e === 9 || e === 32;
}
function ke(e) {
return e >= 48 && e <= 57;
}
function Sa(e) {
return e >= 97 && e <= 122 || // A-Z
e >= 65 && e <= 90;
}
function Oa(e) {
return Sa(e) || e === 95;
}
function Wu(e) {
return Sa(e) || ke(e) || e === 95;
}
function Yu(e) {
var t;
let r = Number.MAX_SAFE_INTEGER, n = null, i = -1;
for (let a = 0; a < e.length; ++a) {
var o;
const u = e[a], c = Ju(u);
c !== u.length && (n = (o = n) !== null && o !== void 0 ? o : a, i = a, a !== 0 && c < r && (r = c));
}
return e.map((a, u) => u === 0 ? a : a.slice(r)).slice(
(t = n) !== null && t !== void 0 ? t : 0,
i + 1
);
}
function Ju(e) {
let t = 0;
for (; t < e.length && $n(e.charCodeAt(t)); )
++t;
return t;
}
function Qu(e, t) {
const r = e.replace(/"""/g, '\\"""'), n = r.split(/\r\n|[\n\r]/g), i = n.length === 1, o = n.length > 1 && n.slice(1).every((m) => m.length === 0 || $n(m.charCodeAt(0))), a = r.endsWith('\\"""'), u = e.endsWith('"') && !a, c = e.endsWith("\\"), s = u || c, l = (
// add leading and trailing new lines only if it improves readability
!i || e.length > 70 || s || o || a
);
let p = "";
const f = i && $n(e.charCodeAt(0));
return (l && !f || o) && (p += `
`), p += r, (l || s) && (p += `
`), '"""' + p + '"""';
}
var d;
(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";
})(d || (d = {}));
let Zu = 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(t) {
const r = new Ta(d.SOF, 0, 0, 0, 0);
this.source = t, 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 t = this.token;
if (t.kind !== d.EOF)
do
if (t.next)
t = t.next;
else {
const r = ec(this, t.end);
t.next = r, r.prev = t, t = r;
}
while (t.kind === d.COMMENT);
return t;
}
};
function tc(e) {
return e === d.BANG || e === d.DOLLAR || e === d.AMP || e === d.PAREN_L || e === d.PAREN_R || e === d.SPREAD || e === d.COLON || e === d.EQUALS || e === d.AT || e === d.BRACKET_L || e === d.BRACKET_R || e === d.BRACE_L || e === d.PIPE || e === d.BRACE_R;
}
function fe(e) {
return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
}
function Mr(e, t) {
return Aa(e.charCodeAt(t)) && xa(e.charCodeAt(t + 1));
}
function Aa(e) {
return e >= 55296 && e <= 56319;
}
function xa(e) {
return e >= 56320 && e <= 57343;
}
function jt(e, t) {
const r = e.source.body.codePointAt(t);
if (r === void 0)
return d.EOF;
if (r >= 32 && r <= 126) {
const n = String.fromCodePoint(r);
return n === '"' ? `'"'` : `"${n}"`;
}
return "U+" + r.toString(16).toUpperCase().padStart(4, "0");
}
function B(e, t, r, n, i) {
const o = e.line, a = 1 + r - e.lineStart;
return new Ta(t, r, n, o, a, i);
}
function ec(e, t) {
const r = e.source.body, n = r.length;
let i = t;
for (; i < n; ) {
const o = r.charCodeAt(i);
switch (o) {
case 65279:
case 9:
case 32:
case 44:
++i;
continue;
case 10:
++i, ++e.line, e.lineStart = i;
continue;
case 13:
r.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
continue;
case 35:
return rc(e, i);
case 33:
return B(e, d.BANG, i, i + 1);
case 36:
return B(e, d.DOLLAR, i, i + 1);
case 38:
return B(e, d.AMP, i, i + 1);
case 40:
return B(e, d.PAREN_L, i, i + 1);
case 41:
return B(e, d.PAREN_R, i, i + 1);
case 46:
if (r.charCodeAt(i + 1) === 46 && r.charCodeAt(i + 2) === 46)
return B(e, d.SPREAD, i, i + 3);
break;
case 58:
return B(e, d.COLON, i, i + 1);
case 61:
return B(e, d.EQUALS, i, i + 1);
case 64:
return B(e, d.AT, i, i + 1);
case 91:
return B(e, d.BRACKET_L, i, i + 1);
case 93:
return B(e, d.BRACKET_R, i, i + 1);
case 123:
return B(e, d.BRACE_L, i, i + 1);
case 124:
return B(e, d.PIPE, i, i + 1);
case 125:
return B(e, d.BRACE_R, i, i + 1);
case 34:
return r.charCodeAt(i + 1) === 34 && r.charCodeAt(i + 2) === 34 ? uc(e, i) : ic(e, i);
}
if (ke(o) || o === 45)
return nc(e, i, o);
if (Oa(o))
return cc(e, i);
throw H(
e.source,
i,
o === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : fe(o) || Mr(r, i) ? `Unexpected character: ${jt(e, i)}.` : `Invalid character: ${jt(e, i)}.`
);
}
return B(e, d.EOF, n, n);
}
function rc(e, t) {
const r = e.source.body, n = r.length;
let i = t + 1;
for (; i < n; ) {
const o = r.charCodeAt(i);
if (o === 10 || o === 13)
break;
if (fe(o))
++i;
else if (Mr(r, i))
i += 2;
else
break;
}
return B(
e,
d.COMMENT,
t,
i,
r.slice(t + 1, i)
);
}
function nc(e, t, r) {
const n = e.source.body;
let i = t, o = r, a = !1;
if (o === 45 && (o = n.charCodeAt(++i)), o === 48) {
if (o = n.charCodeAt(++i), ke(o))
throw H(
e.source,
i,
`Invalid number, unexpected digit after 0: ${jt(
e,
i
)}.`
);
} else
i = Kr(e, i, o), o = n.charCodeAt(i);
if (o === 46 && (a = !0, o = n.charCodeAt(++i), i = Kr(e, 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 = Kr(e, i, o), o = n.charCodeAt(i)), o === 46 || Oa(o))
throw H(
e.source,
i,
`Invalid number, expected digit but got: ${jt(
e,
i
)}.`
);
return B(
e,
a ? d.FLOAT : d.INT,
t,
i,
n.slice(t, i)
);
}
function Kr(e, t, r) {
if (!ke(r))
throw H(
e.source,
t,
`Invalid number, expected digit but got: ${jt(
e,
t
)}.`
);
const n = e.source.body;
let i = t + 1;
for (; ke(n.charCodeAt(i)); )
++i;
return i;
}
function ic(e, t) {
const r = e.source.body, n = r.length;
let i = t + 1, o = i, a = "";
for (; i < n; ) {
const u = r.charCodeAt(i);
if (u === 34)
return a += r.slice(o, i), B(e, d.STRING, t, i + 1, a);
if (u === 92) {
a += r.slice(o, i);
const c = r.charCodeAt(i + 1) === 117 ? r.charCodeAt(i + 2) === 123 ? oc(e, i) : ac(e, i) : sc(e, i);
a += c.value, i += c.size, o = i;
continue;
}
if (u === 10 || u === 13)
break;
if (fe(u))
++i;
else if (Mr(r, i))
i += 2;
else
throw H(
e.source,
i,
`Invalid character within String: ${jt(
e,
i
)}.`
);
}
throw H(e.source, i, "Unterminated string.");
}
function oc(e, t) {
const r = e.source.body;
let n = 0, i = 3;
for (; i < 12; ) {
const o = r.charCodeAt(t + i++);
if (o === 125) {
if (i < 5 || !fe(n))
break;
return {
value: String.fromCodePoint(n),
size: i
};
}
if (n = n << 4 | Se(o), n < 0)
break;
}
throw H(
e.source,
t,
`Invalid Unicode escape sequence: "${r.slice(
t,
t + i
)}".`
);
}
function ac(e, t) {
const r = e.source.body, n = $i(r, t + 2);
if (fe(n))
return {
value: String.fromCodePoint(n),
size: 6
};
if (Aa(n) && r.charCodeAt(t + 6) === 92 && r.charCodeAt(t + 7) === 117) {
const i = $i(r, t + 8);
if (xa(i))
return {
value: String.fromCodePoint(n, i),
size: 12
};
}
throw H(
e.source,
t,
`Invalid Unicode escape sequence: "${r.slice(t, t + 6)}".`
);
}
function $i(e, t) {
return Se(e.charCodeAt(t)) << 12 | Se(e.charCodeAt(t + 1)) << 8 | Se(e.charCodeAt(t + 2)) << 4 | Se(e.charCodeAt(t + 3));
}
function Se(e) {
return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
}
function sc(e, t) {
const r = e.source.body;
switch (r.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 H(
e.source,
t,
`Invalid character escape sequence: "${r.slice(
t,
t + 2
)}".`
);
}
function uc(e, t) {
const r = e.source.body, n = r.length;
let i = e.lineStart, o = t + 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 = B(
e,
d.BLOCK_STRING,
t,
o + 3,
// Return a string of the lines joined with U+000A.
Yu(c).join(`
`)
);
return e.line += c.length - 1, e.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 (fe(s))
++o;
else if (Mr(r, o))
o += 2;
else
throw H(
e.source,
o,
`Invalid character within String: ${jt(
e,
o
)}.`
);
}
throw H(e.source, o, "Unterminated string.");
}
function cc(e, t) {
const r = e.source.body, n = r.length;
let i = t + 1;
for (; i < n; ) {
const o = r.charCodeAt(i);
if (Wu(o))
++i;
else
break;
}
return B(
e,
d.NAME,
t,
i,
r.slice(t, i)
);
}
const lc = 10, La = 2;
function li(e) {
return Dr(e, []);
}
function Dr(e, t) {
switch (typeof e) {
case "string":
return JSON.stringify(e);
case "function":
return e.name ? `[function ${e.name}]` : "[function]";
case "object":
return pc(e, t);
default:
return String(e);
}
}
function pc(e, t) {
if (e === null)
return "null";
if (t.includes(e))
return "[Circular]";
const r = [...t, e];
if (fc(e)) {
const n = e.toJSON();
if (n !== e)
return typeof n == "string" ? n : Dr(n, r);
} else if (Array.isArray(e))
return dc(e, r);
return hc(e, r);
}
function fc(e) {
return typeof e.toJSON == "function";
}
function hc(e, t) {
const r = Object.entries(e);
return r.length === 0 ? "{}" : t.length > La ? "[" + vc(e) + "]" : "{ " + r.map(
([n, i]) => n + ": " + Dr(i, t)
).join(", ") + " }";
}
function dc(e, t) {
if (e.length === 0)
return "[]";
if (t.length > La)
return "[Array]";
const r = Math.min(lc, e.length), n = e.length - r, i = [];
for (let o = 0; o < r; ++o)
i.push(Dr(e[o], t));
return n === 1 ? i.push("... 1 more item") : n > 1 && i.push(`... ${n} more items`), "[" + i.join(", ") + "]";
}
function vc(e) {
const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
if (t === "Object" && typeof e.constructor == "function") {
const r = e.constructor.name;
if (typeof r == "string" && r !== "")
return r;
}
return t;
}
const mc = (
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
globalThis.process && globalThis.process.env.NODE_ENV === "production" ? function(e, t) {
return e instanceof t;
} : function(e, t) {
if (e instanceof t)
return !0;
if (typeof e == "object" && e !== null) {
var r;
const n = t.prototype[Symbol.toStringTag], i = (
// We still need to support constructor's name to detect conflicts with older versions of this library.
Symbol.toStringTag in e ? e[Symbol.toStringTag] : (r = e.constructor) === null || r === void 0 ? void 0 : r.name
);
if (n === i) {
const o = li(e);
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;
}
);
class Na {
constructor(t, r = "GraphQL request", n = {
line: 1,
column: 1
}) {
typeof t == "string" || cr(!1, `Body must be a string. Received: ${li(t)}.`), this.body = t, this.name = r, this.locationOffset = n, this.locationOffset.line > 0 || cr(
!1,
"line in locationOffset is 1-indexed and must be positive."
), this.locationOffset.column > 0 || cr(
!1,
"column in locationOffset is 1-indexed and must be positive."
);
}
get [Symbol.toStringTag]() {
return "Source";
}
}
function yc(e) {
return mc(e, Na);
}
function pi(e, t) {
return new gc(e, t).parseDocument();
}
let gc = class {
constructor(t, r = {}) {
const n = yc(t) ? t : new Na(t);
this._lexer = new Zu(n), this._options = r, this._tokenCounter = 0;
}
/**
* Converts a name lex token into a name parse node.
*/
parseName() {
const t = this.expectToken(d.NAME);
return this.node(t, {
kind: w.NAME,
value: t.value
});
}
// Implements the parsing rules in the Document section.
/**
* Document : Definition+
*/
parseDocument() {
return this.node(this._lexer.token, {
kind: w.DOCUMENT,
definitions: this.many(
d.SOF,
this.parseDefinition,
d.EOF
)
});
}
/**
* Definition :
* - ExecutableDefinition
* - TypeSystemDefinition
* - TypeSystemExtension
*
* ExecutableDefinition :
* - OperationDefinition
* - FragmentDefinition
*
* TypeSystemDefinition :
* - SchemaDefinition
* - TypeDefinition
* - DirectiveDefinition
*
* TypeDefinition :
* - ScalarTypeDefinition
* - ObjectTypeDefinition
* - InterfaceTypeDefinition
* - UnionTypeDefinition
* - EnumTypeDefinition
* - InputObjectTypeDefinition
*/
parseDefinition() {
if (this.peek(d.BRACE_L))
return this.parseOperationDefinition();
const t = this.peekDescription(), r = t ? this._lexer.lookahead() : this._lexer.token;
if (r.kind === d.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 (t)
throw H(
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 t = this._lexer.token;
if (this.peek(d.BRACE_L))
return this.node(t, {
kind: w.OPERATION_DEFINITION,
operation: re.QUERY,
name: void 0,
variableDefinitions: [],
directives: [],
selectionSet: this.parseSelectionSet()
});
const r = this.parseOperationType();
let n;
return this.peek(d.NAME) && (n = this.parseName()), this.node(t, {
kind: w.OPERATION_DEFINITION,
operation: r,
name: n,
variableDefinitions: this.parseVariableDefinitions(),
directives: this.parseDirectives(!1),
selectionSet: this.parseSelectionSet()
});
}
/**
* OperationType : one of query mutation subscription
*/
parseOperationType() {
const t = this.expectToken(d.NAME);
switch (t.value) {
case "query":
return re.QUERY;
case "mutation":
return re.MUTATION;
case "subscription":
return re.SUBSCRIPTION;
}
throw this.unexpected(t);
}
/**
* VariableDefinitions : ( VariableDefinition+ )
*/
parseVariableDefinitions() {
return this.optionalMany(
d.PAREN_L,
this.parseVariableDefinition,
d.PAREN_R
);
}
/**
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
*/
parseVariableDefinition() {
return this.node(this._lexer.token, {
kind: w.VARIABLE_DEFINITION,
variable: this.parseVariable(),
type: (this.expectToken(d.COLON), this.parseTypeReference()),
defaultValue: this.expectOptionalToken(d.EQUALS) ? this.parseConstValueLiteral() : void 0,
directives: this.parseConstDirectives()
});
}
/**
* Variable : $ Name
*/
parseVariable() {
const t = this._lexer.token;
return this.expectToken(d.DOLLAR), this.node(t, {
kind: w.VARIABLE,
name: this.parseName()
});
}
/**
* ```
* SelectionSet : { Selection+ }
* ```
*/
parseSelectionSet() {
return this.node(this._lexer.token, {
kind: w.SELECTION_SET,
selections: this.many(
d.BRACE_L,
this.parseSelection,
d.BRACE_R
)
});
}
/**
* Selection :
* - Field
* - FragmentSpread
* - InlineFragment
*/
parseSelection() {
return this.peek(d.SPREAD) ? this.parseFragment() : this.parseField();
}
/**
* Field : Alias? Name Arguments? Directives? SelectionSet?
*
* Alias : Name :
*/
parseField() {
const t = this._lexer.token, r = this.parseName();
let n, i;
return this.expectOptionalToken(d.COLON) ? (n = r, i = this.parseName()) : i = r, this.node(t, {
kind: w.FIELD,
alias: n,
name: i,
arguments: this.parseArguments(!1),
directives: this.parseDirectives(!1),
selectionSet: this.peek(d.BRACE_L) ? this.parseSelectionSet() : void 0
});
}
/**
* Arguments[Const] : ( Argument[?Const]+ )
*/
parseArguments(t) {
const r = t ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(d.PAREN_L, r, d.PAREN_R);
}
/**
* Argument[Const] : Name : Value[?Const]
*/
parseArgument(t = !1) {
const r = this._lexer.token, n = this.parseName();
return this.expectToken(d.COLON), this.node(r, {
kind: w.ARGUMENT,
name: n,
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(d.SPREAD);
const r = this.expectOptionalKeyword("on");
return !r && this.peek(d.NAME) ? this.node(t, {
kind: w.FRAGMENT_SPREAD,
name: this.parseFragmentName(),
directives: this.parseDirectives(!1)
}) : this.node(t, {
kind: w.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 t = this._lexer.token;
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
kind: w.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: w.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 r = this._lexer.token;
switch (r.kind) {
case d.BRACKET_L:
return this.parseList(t);
case d.BRACE_L:
return this.parseObject(t);
case d.INT:
return this.advanceLexer(), this.node(r, {
kind: w.INT,
value: r.value
});
case d.FLOAT:
return this.advanceLexer(), this.node(r, {
kind: w.FLOAT,
value: r.value
});
case d.STRING:
case d.BLOCK_STRING:
return this.parseStringLiteral();
case d.NAME:
switch (this.advanceLexer(), r.value) {
case "true":
return this.node(r, {
kind: w.BOOLEAN,
value: !0
});
case "false":
return this.node(r, {
kind: w.BOOLEAN,
value: !1
});
case "null":
return this.node(r, {
kind: w.NULL
});
default:
return this.node(r, {
kind: w.ENUM,
value: r.value
});
}
case d.DOLLAR:
if (t)
if (this.expectToken(d.DOLLAR), this._lexer.token.kind === d.NAME) {
const n = this._lexer.token.value;
throw H(
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 t = this._lexer.token;
return this.advanceLexer(), this.node(t, {
kind: w.STRING,
value: t.value,
block: t.kind === d.BLOCK_STRING
});
}
/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
parseList(t) {
const r = () => this.parseValueLiteral(t);
return this.node(this._lexer.token, {
kind: w.LIST,
values: this.any(d.BRACKET_L, r, d.BRACKET_R)
});
}
/**
* ```
* ObjectValue[Const] :
* - { }
* - { ObjectField[?Const]+ }
* ```
*/
parseObject(t) {
const r = () => this.parseObjectField(t);
return this.node(this._lexer.token, {
kind: w.OBJECT,
fields: this.any(d.BRACE_L, r, d.BRACE_R)
});
}
/**
* ObjectField[Const] : Name : Value[?Const]
*/
parseObjectField(t) {
const r = this._lexer.token, n = this.parseName();
return this.expectToken(d.COLON), this.node(r, {
kind: w.OBJECT_FIELD,
name: n,
value: this.parseValueLiteral(t)
});
}
// Implements the parsing rules in the Directives section.
/**
* Directives[Const] : Directive[?Const]+
*/
parseDirectives(t) {
const r = [];
for (; this.peek(d.AT); )
r.push(this.parseDirective(t));
return r;
}
parseConstDirectives() {
return this.parseDirectives(!0);
}
/**
* ```
* Directive[Const] : @ Name Arguments[?Const]?
* ```
*/
parseDirective(t) {
const r = this._lexer.token;
return this.expectToken(d.AT), this.node(r, {
kind: w.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 r;
if (this.expectOptionalToken(d.BRACKET_L)) {
const n = this.parseTypeReference();
this.expectToken(d.BRACKET_R), r = this.node(t, {
kind: w.LIST_TYPE,
type: n
});
} else
r = this.parseNamedType();
return this.expectOptionalToken(d.BANG) ? this.node(t, {
kind: w.NON_NULL_TYPE,
type: r
}) : r;
}
/**
* NamedType : Name
*/
parseNamedType() {
return this.node(this._lexer.token, {
kind: w.NAMED_TYPE,
name: this.parseName()
});
}
// Implements the parsing rules in the Type Definition section.
peekDescription() {
return this.peek(d.STRING) || this.peek(d.BLOCK_STRING);
}
/**
* Description : StringValue
*/
parseDescription() {
if (this.peekDescription())
return this.parseStringLiteral();
}
/**
* ```
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
* ```
*/
parseSchemaDefinition() {
const t = this._lexer.token, r = this.parseDescription();
this.expectKeyword("schema");
const n = this.parseConstDirectives(), i = this.many(
d.BRACE_L,
this.parseOperationTypeDefinition,
d.BRACE_R
);
return this.node(t, {
kind: w.SCHEMA_DEFINITION,
description: r,
directives: n,
operationTypes: i
});
}
/**
* OperationTypeDefinition : OperationType : NamedType
*/
parseOperationTypeDefinition() {
const t = this._lexer.token, r = this.parseOperationType();
this.expectToken(d.COLON);
const n = this.parseNamedType();
return this.node(t, {
kind: w.OPERATION_TYPE_DEFINITION,
operation: r,
type: n
});
}
/**
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
*/
parseScalarTypeDefinition() {
const t = this._lexer.token, r = this.parseDescription();
this.expectKeyword("scalar");
const n = this.parseName(), i = this.parseConstDirectives();
return this.node(t, {
kind: w.SCALAR_TYPE_DEFINITION,
description: r,
name: n,
directives: i
});
}
/**
* ObjectTypeDefinition :
* Description?
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
*/
parseObjectTypeDefinition() {
const t = 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(t, {
kind: w.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(d.AMP, this.parseNamedType) : [];
}
/**
* ```
* FieldsDefinition : { FieldDefinition+ }
* ```
*/
parseFieldsDefinition() {
return this.optionalMany(
d.BRACE_L,
this.parseFieldDefinition,
d.BRACE_R
);
}
/**
* FieldDefinition :
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
*/
parseFieldDefinition() {
const t = this._lexer.token, r = this.parseDescription(), n = this.parseName(), i = this.parseArgumentDefs();
this.expectToken(d.COLON);
const o = this.parseTypeReference(), a = this.parseConstDirectives();
return this.node(t, {
kind: w.FIELD_DEFINITION,
description: r,
name: n,
arguments: i,
type: o,
directives: a
});
}
/**
* ArgumentsDefinition : ( InputValueDefinition+ )
*/
parseArgumentDefs() {
return this.optionalMany(
d.PAREN_L,
this.parseInputValueDef,
d.PAREN_R
);
}
/**
* InputValueDefinition :
* - Description? Name : Type DefaultValue? Directives[Const]?
*/
parseInputValueDef() {
const t = this._lexer.token, r = this.parseDescription(), n = this.parseName();
this.expectToken(d.COLON);
const i = this.parseTypeReference();
let o;
this.expectOptionalToken(d.EQUALS) && (o = this.parseConstValueLiteral());
const a = this.parseConstDirectives();
return this.node(t, {
kind: w.INPUT_VALUE_DEFINITION,
description: r,
name: n,
type: i,
defaultValue: o,
directives: a
});
}
/**
* InterfaceTypeDefinition :
* - Description? interface Name Directives[Const]? FieldsDefinition?
*/
parseInterfaceTypeDefinition() {
const t = 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(t, {
kind: w.INTERFACE_TYPE_DEFINITION,
description: r,
name: n,
interfaces: i,
directives: o,
fields: a
});
}
/**
* UnionTypeDefinition :
* - Description? union Name Directives[Const]? UnionMemberTypes?
*/
parseUnionTypeDefinition() {
const t = this._lexer.token, r = this.parseDescription();
this.expectKeyword("union");
const n = this.parseName(), i = this.parseConstDirectives(), o = this.parseUnionMemberTypes();
return this.node(t, {
kind: w.UNION_TYPE_DEFINITION,
description: r,
name: n,
directives: i,
types: o
});
}
/**
* UnionMemberTypes :
* - = `|`? NamedType
* - UnionMemberTypes | NamedType
*/
parseUnionMemberTypes() {
return this.expectOptionalToken(d.EQUALS) ? this.delimitedMany(d.PIPE, this.parseNamedType) : [];
}
/**
* EnumTypeDefinition :
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
*/
parseEnumTypeDefinition() {
const t = this._lexer.token, r = this.parseDescription();
this.expectKeyword("enum");
const n = this.parseName(), i = this.parseConstDirectives(), o = this.parseEnumValuesDefinition();
return this.node(t, {
kind: w.ENUM_TYPE_DEFINITION,
description: r,
name: n,
directives: i,
values: o
});
}
/**
* ```
* EnumValuesDefinition : { EnumValueDefinition+ }
* ```
*/
parseEnumValuesDefinition() {
return this.optionalMany(
d.BRACE_L,
this.parseEnumValueDefinition,
d.BRACE_R
);
}
/**
* EnumValueDefinition : Description? EnumValue Directives[Const]?
*/
parseEnumValueDefinition() {
const t = this._lexer.token, r = this.parseDescription(), n = this.parseEnumValueName(), i = this.parseConstDirectives();
return this.node(t, {
kind: w.ENUM_VALUE_DEFINITION,
description: r,
name: n,
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 H(
this._lexer.source,
this._lexer.token.start,
`${Ke(
this._lexer.token
)} is reserved and cannot be used for an enum value.`
);
return this.parseName();
}
/**
* InputObjectTypeDefinition :
* - Description? input Name Directives[Const]? InputFiel