@tanstack/ai-mcp
Version:
Host-side Model Context Protocol client for TanStack AI: discover and run MCP server tools, resources, and prompts in any adapter's chat() loop, with generated end-to-end types.
1,298 lines • 59.7 kB
JavaScript
#!/usr/bin/env node
import {
__esm,
init_esm_shims
} from "./chunk-K3ER4CT6.js";
// ../../node_modules/.pnpm/prettier@3.9.9/node_modules/prettier/plugins/graphql.mjs
function m(e2) {
return O(e2), { type: Ie, contents: e2 };
}
function N(e2, t = {}) {
return O(e2), J(t.expandedStates, true), { type: ge, id: t.id, contents: e2, break: !!t.shouldBreak, expandedStates: t.expandedStates };
}
function _(e2, t = "", n = {}) {
return O(e2), t !== "" && O(t), { type: Se, breakContents: e2, flatContents: t, groupId: n.groupId };
}
function d(e2, t) {
O(e2), J(t);
let n = [];
for (let r = 0; r < t.length; r++) r !== 0 && n.push(e2), n.push(t[r]);
return n;
}
function W(e2) {
return (t, n, r) => {
if (n === false) return false;
let i = !!r?.backwards, { length: s } = t, a = n;
for (; a >= 0 && a < s; ) {
let p = t.charAt(a);
if (e2 instanceof RegExp) {
if (!e2.test(p)) return a;
} else if (!e2.includes(p)) return a;
i ? a-- : a++;
}
return a === -1 || a === s ? a : false;
};
}
function Dt(e2, t, n) {
if (t === false) return false;
let r = !!n?.backwards, i = e2.charAt(t);
if (r) {
if (e2.charAt(t - 1) === "\r" && i === `
`) return t - 2;
if (Ce(i)) return t - 1;
} else {
if (i === "\r" && e2.charAt(t + 1) === `
`) return t + 2;
if (Ce(i)) return t + 1;
}
return t;
}
function _t(e2, t, n = {}) {
let r = z(e2, n.backwards ? t - 1 : t, n), i = Z(e2, r, n);
return r !== i;
}
function It(e2, t) {
let n = e2.node;
return n.printed = true, t.printer.printComment(e2, t);
}
function ue(e2, t, n = {}) {
let { indent: r = false, marker: i, filter: s = At } = n, a = new Set(e2.node?.comments?.filter((x) => !(x.leading || x.trailing || x.marker !== i || !s(x))));
if (a.size === 0) return "";
let p = e2.map(({ node: x }) => a.has(x) ? It(e2, t) : "", "comments").filter(Boolean), E = d(l, p);
return r ? m([l, E]) : E;
}
function gt(e2) {
return Array.isArray(e2) && e2.length > 0;
}
function j(e2) {
if (K !== null && typeof K.property) {
let t = K;
return K = j.prototype = null, t;
}
return K = j.prototype = e2 ?? /* @__PURE__ */ Object.create(null), new j();
}
function de(e2) {
return j(e2);
}
function Ot(e2, t = "type") {
de(e2);
function n(r) {
let i = r[t], s = e2[i];
if (!Array.isArray(s)) throw Object.assign(new Error(`Missing visitor keys for '${i}'.`), { node: r });
return s;
}
return n;
}
function fe(e2, t) {
e2.kind === "StringValue" && e2.block && !e2.value.includes(`
`) && (t.value = e2.value.trim());
}
function kt(e2, t) {
if (t === false) return false;
if (e2.charAt(t) === "/" && e2.charAt(t + 1) === "*") {
for (let n = t + 2; n < e2.length; ++n) if (e2.charAt(n) === "*" && e2.charAt(n + 1) === "/") return n + 2;
}
return t;
}
function Ct(e2, t) {
return t === false ? false : e2.charAt(t) === "/" && e2.charAt(t + 1) === "/" ? ke(e2, t) : t;
}
function Rt(e2, t) {
let n = null, r = t;
for (; r !== n; ) n = r, r = ve(e2, r), r = Ke(e2, r), r = z(e2, r);
return r = je(e2, r), r = Z(e2, r), r !== false && Re(e2, r);
}
function I(e2, t, n, r) {
return e2.map(({ isLast: i, node: s }) => {
let a = n();
return !i && Ye(t.originalText, te(s)) ? [a, l] : a;
}, r);
}
function me(e2, t, n) {
let { node: r } = e2;
return T(r.arguments) ? N(["(", m([u, d([_("", ", "), u], I(e2, t, n, "arguments"))]), u, ")"]) : "";
}
function A(e2, t, n) {
let { node: r } = e2;
if (!r.description) return "";
let i = [n("description")];
return r.kind === "InputValueDefinition" && !r.description.block ? i.push(S) : i.push(l), i;
}
function y(e2, t) {
let { node: n } = e2;
if (!T(n.directives)) return "";
let r = d(S, e2.map(t, "directives"));
return n.kind === "FragmentDefinition" || n.kind === "OperationDefinition" ? N([S, r]) : [" ", N(m([u, r]))];
}
function he(e2, t) {
let { node: n } = e2;
return T(n.variableDefinitions) ? N(["(", m([u, d([_("", ", "), u], e2.map(t, "variableDefinitions"))]), u, ")"]) : "";
}
function Lt(e2, t, n) {
let { node: r } = e2;
switch (r.kind) {
case "Document":
return [...d(l, I(e2, t, n, "definitions")), l];
case "OperationDefinition": {
let i = t.originalText[ee(r)] !== "{", s = !!r.name;
return [A(e2, t, n), i ? r.operation : "", i && s ? [" ", n("name")] : "", i && !s && T(r.variableDefinitions) ? " " : "", he(e2, n), y(e2, n), !i && !s ? "" : " ", n("selectionSet")];
}
case "FragmentDefinition":
return [A(e2, t, n), "fragment ", n("name"), he(e2, n), " on ", n("typeCondition"), y(e2, n), " ", n("selectionSet")];
case "SelectionSet":
return ["{", m([l, d(l, I(e2, t, n, "selections"))]), l, "}"];
case "Field":
return N([r.alias ? [n("alias"), ": "] : "", n("name"), T(r.arguments) ? N(["(", m([u, d([_("", ", "), u], I(e2, t, n, "arguments"))]), u, ")"]) : "", y(e2, n), r.selectionSet ? " " : "", n("selectionSet")]);
case "Name":
return r.value;
case "StringValue":
if (r.block) {
let i = X(0, r.value, '"""', '\\"""').split(`
`);
return i.length === 1 && (i[0] = i[0].trim()), i.every((s) => s === "") && (i.length = 0), d(l, ['"""', ...i, '"""']);
}
return ['"', X(0, X(0, r.value, /["\\]/g, "\\$&"), `
`, "\\n"), '"'];
case "IntValue":
case "FloatValue":
case "EnumValue":
return r.value;
case "BooleanValue":
return r.value ? "true" : "false";
case "NullValue":
return "null";
case "Variable":
return ["$", n("name")];
case "ListValue": {
let i = !T(r.values);
return N(["[", ue(e2, t, { indent: true }), i ? "" : m([u, d([_("", ", "), u], e2.map(n, "values"))]), u, "]"]);
}
case "ObjectValue": {
let i = !T(r.fields), s = t.bracketSpacing && !i ? " " : "";
return N(["{", s, ue(e2, t, { indent: true }), i ? "" : [m([u, d([_("", ", "), u], e2.map(n, "fields"))])], u, _("", s), "}"]);
}
case "ObjectField":
case "Argument":
case "FragmentArgument":
return [n("name"), ": ", n("value")];
case "Directive":
return ["@", n("name"), me(e2, t, n)];
case "NamedType":
return n("name");
case "VariableDefinition":
return [A(e2, t, n), n("variable"), ": ", n("type"), r.defaultValue ? [" = ", n("defaultValue")] : "", y(e2, n)];
case "ObjectTypeExtension":
case "ObjectTypeDefinition":
case "InputObjectTypeExtension":
case "InputObjectTypeDefinition":
case "InterfaceTypeExtension":
case "InterfaceTypeDefinition": {
let { kind: i } = r, s = [];
return i.endsWith("TypeDefinition") ? s.push(A(e2, t, n)) : s.push("extend "), i.startsWith("ObjectType") ? s.push("type") : i.startsWith("InputObjectType") ? s.push("input") : s.push("interface"), s.push(" ", n("name")), !i.startsWith("InputObjectType") && T(r.interfaces) && s.push(" implements ", m([N([d([" &", S], e2.map(n, "interfaces"))])])), s.push(y(e2, n)), T(r.fields) && s.push([" {", m([l, d(l, I(e2, t, n, "fields"))]), l, "}"]), s;
}
case "FieldDefinition":
return [A(e2, t, n), n("name"), T(r.arguments) ? N(["(", m([u, d([_("", ", "), u], I(e2, t, n, "arguments"))]), u, ")"]) : "", ": ", n("type"), y(e2, n)];
case "DirectiveDefinition":
return [A(e2, t, n), "directive ", "@", n("name"), T(r.arguments) ? N(["(", m([u, d([_("", ", "), u], I(e2, t, n, "arguments"))]), u, ")"]) : "", y(e2, n), r.repeatable ? " repeatable" : "", " on ", ...d(" | ", e2.map(n, "locations"))];
case "DirectiveExtension":
return ["extend directive @", n("name"), y(e2, n)];
case "EnumTypeExtension":
case "EnumTypeDefinition":
return [A(e2, t, n), r.kind === "EnumTypeExtension" ? "extend " : "", "enum ", n("name"), y(e2, n), T(r.values) ? [" {", m([l, d(l, I(e2, t, n, "values"))]), l, "}"] : ""];
case "EnumValueDefinition":
return [A(e2, t, n), n("name"), y(e2, n)];
case "InputValueDefinition":
return [A(e2, t, n), n("name"), ": ", n("type"), r.defaultValue ? [" = ", n("defaultValue")] : "", y(e2, n)];
case "SchemaExtension":
return ["extend schema", y(e2, n), ...T(r.operationTypes) ? [" {", m([l, d(l, I(e2, t, n, "operationTypes"))]), l, "}"] : []];
case "SchemaDefinition":
return [A(e2, t, n), "schema", y(e2, n), " {", T(r.operationTypes) ? m([l, d(l, I(e2, t, n, "operationTypes"))]) : "", l, "}"];
case "OperationTypeDefinition":
return [r.operation, ": ", n("type")];
case "FragmentSpread":
return ["...", n("name"), me(e2, t, n), y(e2, n)];
case "InlineFragment":
return ["...", r.typeCondition ? [" on ", n("typeCondition")] : "", y(e2, n), " ", n("selectionSet")];
case "UnionTypeExtension":
case "UnionTypeDefinition":
return N([A(e2, t, n), N([r.kind === "UnionTypeExtension" ? "extend " : "", "union ", n("name"), y(e2, n), T(r.types) ? [" =", _("", " "), m([_([S, "| "]), d([S, "| "], e2.map(n, "types"))])] : ""])]);
case "ScalarTypeExtension":
case "ScalarTypeDefinition":
return [A(e2, t, n), r.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", n("name"), y(e2, n)];
case "NonNullType":
return [n("type"), "!"];
case "ListType":
return ["[", n("type"), "]"];
default:
throw new Le(r, "Graphql", "kind");
}
}
function bt(e2) {
return e2.kind !== "Comment";
}
function Ft({ node: e2 }) {
if (e2.kind === "Comment") return "#" + e2.value.trimEnd();
throw new Error("Not a comment: " + JSON.stringify(e2));
}
function Pt(e2) {
let { node: t } = e2;
return t?.comments?.some((n) => n.value.trim() === "prettier-ignore");
}
function Mt(e2, t) {
return e2?.__kind === t;
}
function Je(e2) {
return typeof e2 == "object" && e2 !== null;
}
function We(e2, t) {
if (!e2) throw new Error(t ?? "Unexpected invariant triggered.");
}
function w(e2, t) {
let n = 0, r = 1;
for (let i of e2.body.matchAll(Ut)) {
if (typeof i.index != "number" && We(false), i.index >= t) break;
n = i.index + i[0].length, r += 1;
}
return { line: r, column: t + 1 - n };
}
function Ee(e2) {
return ne(e2.source, w(e2.source, e2.start));
}
function ne(e2, t) {
let n = e2.locationOffset.column - 1, r = "".padStart(n) + e2.body, i = t.line - 1, s = e2.locationOffset.line - 1, a = t.line + s, p = t.line === 1 ? n : 0, E = t.column + p, x = `${e2.name}:${a}:${E}
`, v = r.split(/\r\n|[\n\r]/g), P = v[i];
if (P.length > 120) {
let $ = Math.floor(E / 80), G = E % 80, k = [];
for (let C = 0; C < P.length; C += 80) k.push(P.slice(C, C + 80));
return x + ze([[`${a} |`, k[0]], ...k.slice(1, $ + 1).map((C) => ["|", C]), ["|", "^".padStart(G)], ["|", k[$ + 1]]]);
}
return x + ze([[`${a - 1} |`, v[i - 1]], [`${a} |`, P], ["|", "^".padStart(E)], [`${a + 1} |`, v[i + 1]]]);
}
function ze(e2) {
let t = e2.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 Ze(e2) {
return e2 === void 0 || e2.length === 0 ? void 0 : e2;
}
function Te(e2, t) {
if (!e2) throw new Error(t);
}
function tt(e2) {
return e2 === 9 || e2 === 32;
}
function L(e2) {
return e2 >= 48 && e2 <= 57;
}
function nt(e2) {
return e2 >= 97 && e2 <= 122 || e2 >= 65 && e2 <= 90;
}
function xe(e2) {
return nt(e2) || e2 === 95;
}
function it(e2) {
return nt(e2) || L(e2) || e2 === 95;
}
function rt(e2) {
let t = Number.MAX_SAFE_INTEGER, n = null, r = -1;
for (let i = 0; i < e2.length; ++i) {
let s = e2[i], a = Mn(s);
a !== s.length && (n ?? (n = i), r = i, i !== 0 && a < t && (t = a));
}
return e2.map((i, s) => s === 0 ? i : i.slice(t)).slice(n ?? 0, r + 1);
}
function Mn(e2) {
let t = 0;
for (; t < e2.length && tt(e2.charCodeAt(t)); ) ++t;
return t;
}
function f(e2, t, n) {
return new R(`Syntax Error: ${n}`, { source: e2, positions: [t] });
}
function Un() {
let e2;
try {
let t = globalThis.process;
typeof t?.getBuiltinModule == "function" && (e2 = t.getBuiltinModule("node:diagnostics_channel"));
} catch {
}
return e2;
}
function st(e2) {
if (e2 == null) return false;
let t = e2.hasSubscribers;
if (t !== void 0) return t;
for (let n of Bn) if (e2[n].hasSubscribers) return true;
return false;
}
function at(e2) {
return e2 === o.BANG || e2 === o.DOLLAR || e2 === o.AMP || e2 === o.PAREN_L || e2 === o.PAREN_R || e2 === o.DOT || e2 === o.SPREAD || e2 === o.COLON || e2 === o.EQUALS || e2 === o.AT || e2 === o.BRACKET_L || e2 === o.BRACKET_R || e2 === o.BRACE_L || e2 === o.PIPE || e2 === o.BRACE_R;
}
function U(e2) {
return e2 >= 0 && e2 <= 55295 || e2 >= 57344 && e2 <= 1114111;
}
function re(e2, t) {
return ct(e2.charCodeAt(t)) && pt(e2.charCodeAt(t + 1));
}
function ct(e2) {
return e2 >= 55296 && e2 <= 56319;
}
function pt(e2) {
return e2 >= 56320 && e2 <= 57343;
}
function F(e2, t) {
let n = e2.source.body.codePointAt(t);
if (n === void 0) return o.EOF;
if (n >= 32 && n <= 126) {
let r = String.fromCodePoint(n);
return r === '"' ? `'"'` : `"${r}"`;
}
return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
}
function h(e2, t, n, r, i) {
let s = e2.line, a = 1 + n - e2.lineStart;
return new V(t, n, r, s, a, i);
}
function Gn(e2, t) {
let n = e2.source.body, r = n.length, i = t;
for (; i < r; ) {
let s = n.charCodeAt(i);
switch (s) {
case 65279:
case 9:
case 32:
case 44:
++i;
continue;
case 10:
++i, ++e2.line, e2.lineStart = i;
continue;
case 13:
n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e2.line, e2.lineStart = i;
continue;
case 35:
return Kn(e2, i);
case 33:
return h(e2, o.BANG, i, i + 1);
case 36:
return h(e2, o.DOLLAR, i, i + 1);
case 38:
return h(e2, o.AMP, i, i + 1);
case 40:
return h(e2, o.PAREN_L, i, i + 1);
case 41:
return h(e2, o.PAREN_R, i, i + 1);
case 46: {
let a = n.charCodeAt(i + 1);
if (a === 46 && n.charCodeAt(i + 2) === 46) return h(e2, o.SPREAD, i, i + 3);
if (a === 46) throw f(e2.source, i, 'Unexpected "..", did you mean "..."?');
if (L(a)) {
let p = e2.source.body.slice(i + 1, ie(e2, i + 1, a));
throw f(e2.source, i, `Invalid number, expected digit before ".", did you mean "0.${p}"?`);
}
break;
}
case 58:
return h(e2, o.COLON, i, i + 1);
case 61:
return h(e2, o.EQUALS, i, i + 1);
case 64:
return h(e2, o.AT, i, i + 1);
case 91:
return h(e2, o.BRACKET_L, i, i + 1);
case 93:
return h(e2, o.BRACKET_R, i, i + 1);
case 123:
return h(e2, o.BRACE_L, i, i + 1);
case 124:
return h(e2, o.PIPE, i, i + 1);
case 125:
return h(e2, o.BRACE_R, i, i + 1);
case 34:
return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? Xn(e2, i) : Yn(e2, i);
}
if (L(s) || s === 45) return jn(e2, i, s);
if (xe(s)) return Hn(e2, i);
throw f(e2.source, i, s === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : U(s) || re(n, i) ? `Unexpected character: ${F(e2, i)}.` : `Invalid character: ${F(e2, i)}.`);
}
return h(e2, o.EOF, r, r);
}
function Kn(e2, t) {
let n = e2.source.body, r = n.length, i = t + 1;
for (; i < r; ) {
let s = n.charCodeAt(i);
if (s === 10 || s === 13) break;
if (U(s)) ++i;
else if (re(n, i)) i += 2;
else break;
}
return h(e2, o.COMMENT, t, i, n.slice(t + 1, i));
}
function jn(e2, t, n) {
let r = e2.source.body, i = t, s = n, a = false;
if (s === 45 && (s = r.charCodeAt(++i)), s === 48) {
if (s = r.charCodeAt(++i), L(s)) throw f(e2.source, i, `Invalid number, unexpected digit after 0: ${F(e2, i)}.`);
} else i = ie(e2, i, s), s = r.charCodeAt(i);
if (s === 46 && (a = true, s = r.charCodeAt(++i), i = ie(e2, i, s), s = r.charCodeAt(i)), (s === 69 || s === 101) && (a = true, s = r.charCodeAt(++i), (s === 43 || s === 45) && (s = r.charCodeAt(++i)), i = ie(e2, i, s), s = r.charCodeAt(i)), s === 46 || xe(s)) throw f(e2.source, i, `Invalid number, expected digit but got: ${F(e2, i)}.`);
return h(e2, a ? o.FLOAT : o.INT, t, i, r.slice(t, i));
}
function ie(e2, t, n) {
if (!L(n)) throw f(e2.source, t, `Invalid number, expected digit but got: ${F(e2, t)}.`);
let r = e2.source.body, i = t + 1;
for (; L(r.charCodeAt(i)); ) ++i;
return i;
}
function Yn(e2, t) {
let n = e2.source.body, r = n.length, i = t + 1, s = i, a = "";
for (; i < r; ) {
let p = n.charCodeAt(i);
if (p === 34) return a += n.slice(s, i), h(e2, o.STRING, t, i + 1, a);
if (p === 92) {
a += n.slice(s, i);
let E = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? qn(e2, i) : Qn(e2, i) : $n(e2, i);
a += E.value, i += E.size, s = i;
continue;
}
if (p === 10 || p === 13) break;
if (U(p)) ++i;
else if (re(n, i)) i += 2;
else throw f(e2.source, i, `Invalid character within String: ${F(e2, i)}.`);
}
throw f(e2.source, i, "Unterminated string.");
}
function qn(e2, t) {
let n = e2.source.body, r = 0, i = 3;
for (; i < 12; ) {
let s = n.charCodeAt(t + i++);
if (s === 125) {
if (i < 5 || !U(r)) break;
return { value: String.fromCodePoint(r), size: i };
}
if (r = r << 4 | q(s), r < 0) break;
}
throw f(e2.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + i)}".`);
}
function Qn(e2, t) {
let n = e2.source.body, r = ot(n, t + 2);
if (U(r)) return { value: String.fromCodePoint(r), size: 6 };
if (ct(r) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
let i = ot(n, t + 8);
if (pt(i)) return { value: String.fromCodePoint(r, i), size: 12 };
}
throw f(e2.source, t, `Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`);
}
function ot(e2, t) {
return q(e2.charCodeAt(t)) << 12 | q(e2.charCodeAt(t + 1)) << 8 | q(e2.charCodeAt(t + 2)) << 4 | q(e2.charCodeAt(t + 3));
}
function q(e2) {
return e2 >= 48 && e2 <= 57 ? e2 - 48 : e2 >= 65 && e2 <= 70 ? e2 - 55 : e2 >= 97 && e2 <= 102 ? e2 - 87 : -1;
}
function $n(e2, t) {
let n = e2.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 f(e2.source, t, `Invalid character escape sequence: "${n.slice(t, t + 2)}".`);
}
function Xn(e2, t) {
let n = e2.source.body, r = n.length, i = e2.lineStart, s = t + 3, a = s, p = "", E = [];
for (; s < r; ) {
let x = n.charCodeAt(s);
if (x === 34 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34) {
p += n.slice(a, s), E.push(p);
let v = h(e2, o.BLOCK_STRING, t, s + 3, rt(E).join(`
`));
return e2.line += E.length - 1, e2.lineStart = i, v;
}
if (x === 92 && n.charCodeAt(s + 1) === 34 && n.charCodeAt(s + 2) === 34 && n.charCodeAt(s + 3) === 34) {
p += n.slice(a, s), a = s + 1, s += 4;
continue;
}
if (x === 10 || x === 13) {
p += n.slice(a, s), E.push(p), x === 13 && n.charCodeAt(s + 1) === 10 ? s += 2 : ++s, p = "", a = s, i = s;
continue;
}
if (U(x)) ++s;
else if (re(n, s)) s += 2;
else throw f(e2.source, s, `Invalid character within String: ${F(e2, s)}.`);
}
throw f(e2.source, s, "Unterminated string.");
}
function Hn(e2, t) {
let n = e2.source.body, r = n.length, i = t + 1;
for (; i < r; ) {
let s = n.charCodeAt(i);
if (it(s)) ++i;
else break;
}
return h(e2, o.NAME, t, i, n.slice(t, i));
}
function lt(e2) {
return He(e2, ut, B);
}
function oe(e2, t) {
return st(Ne) ? Ne.traceSync(() => dt(e2, t), { source: e2 }) : dt(e2, t);
}
function dt(e2, t) {
let n = new De(e2, t), r = n.parseDocument();
return Object.defineProperty(r, "tokenCount", { enumerable: false, value: n.tokenCount }), r;
}
function se(e2) {
let t = e2.value;
return ft(e2.kind) + (t != null ? ` "${t}"` : "");
}
function ft(e2) {
return at(e2) ? `"${e2}"` : e2;
}
function ei(e2, t) {
let n = new SyntaxError(e2 + " (" + t.loc.start.line + ":" + t.loc.start.column + ")");
return Object.assign(n, t);
}
function ti(e2) {
let t = [], { startToken: n, endToken: r } = e2.loc;
for (let i = n; i !== r; i = i.next) i.kind === "Comment" && t.push({ ...i, loc: { start: i.start, end: i.end } });
return t;
}
function ii(e2) {
if (!(e2 instanceof R)) return e2;
let { message: t, locations: [n] } = e2;
return mt(t, { loc: { start: n }, cause: e2 });
}
function ri(e2) {
let t;
try {
t = oe(e2, ni);
} catch (n) {
throw ii(n);
}
return t.comments = ti(t), t;
}
var Et, ae, ht, Ae, Tt, xt, X, yt, ce, Ie, ge, Se, H, Oe, O, J, pe, S, u, Nt, l, Ri, z, ve, ke, Ce, Z, Re, At, T, le, Le, K, St, be, D, Fe, vt, Pe, ee, te, we, Ve, Me, Ue, Be, Ge, Ke, je, Ye, wt, qe, Qe, $e, Vt, Xe, _e, He, Ut, R, Bt, et, Y, V, M, c, Gt, Kt, jt, Yt, qt, Qt, $t, Xt, Ht, Jt, Wt, zt, Zt, en, tn, nn, rn, sn, on, an, cn, pn, un, ln, dn, fn, mn, hn, En, Tn, xn, yn, Nn, Dn, _n, An, In, gn, Sn, On, vn, kn, Cn, Rn, Ln, bn, Fn, Pn, wn, Vn, ye, b, Ne, ds, fs, ms, hs, Es, Ts, Bn, o, Q, ut, B, De, mt, ni, si, oi;
var init_graphql = __esm({
"../../node_modules/.pnpm/prettier@3.9.9/node_modules/prettier/plugins/graphql.mjs"() {
init_esm_shims();
Et = Object.defineProperty;
ae = (e2, t) => {
for (var n in t) Et(e2, n, { get: t[n], enumerable: true });
};
ht = {};
ae(ht, { languages: () => Qe, options: () => Xe, parsers: () => _e, printers: () => oi });
Ae = (e2, t) => (n, r, ...i) => n | 1 && r == null ? void 0 : (t.call(r) ?? r[e2]).apply(r, i);
Tt = String.prototype.replaceAll ?? function(e2, t) {
return e2.global ? this.replace(e2, t) : this.split(e2).join(t);
};
xt = Ae("replaceAll", function() {
if (typeof this == "string") return Tt;
});
X = xt;
yt = () => {
};
ce = yt;
Ie = "indent";
ge = "group";
Se = "if-break";
H = "line";
Oe = "break-parent";
O = ce;
J = ce;
pe = { type: Oe };
S = { type: H };
u = { type: H, soft: true };
Nt = { type: H, hard: true };
l = [Nt, pe];
Ri = W(/\s/);
z = W(" ");
ve = W(",; ");
ke = W(/[^\n\r]/);
Ce = (e2) => e2 === `
` || e2 === "\r" || e2 === "\u2028" || e2 === "\u2029";
Z = Dt;
Re = _t;
At = () => true;
T = gt;
le = class extends Error {
name = "UnexpectedNodeError";
constructor(t, n, r = "type") {
super(`Unexpected ${n} node ${r}: ${JSON.stringify(t[r])}.`), this.node = t;
}
};
Le = le;
K = null;
St = 10;
for (let e2 = 0; e2 <= St; e2++) j();
be = Ot;
D = [["name"], ["name", "value"], ["type"], ["description", "name", "directives"], ["description", "name", "interfaces", "directives", "fields"], ["name", "directives"], ["name", "interfaces", "directives", "fields"]];
Fe = { Name: [], Document: ["definitions"], OperationDefinition: ["description", "name", "variableDefinitions", "directives", "selectionSet"], VariableDefinition: ["description", "variable", "type", "defaultValue", "directives"], Variable: D[0], SelectionSet: ["selections"], Field: ["alias", "name", "arguments", "directives", "selectionSet"], Argument: D[1], FragmentArgument: D[1], FragmentSpread: ["name", "arguments", "directives"], InlineFragment: ["typeCondition", "directives", "selectionSet"], FragmentDefinition: ["description", "name", "variableDefinitions", "typeCondition", "directives", "selectionSet"], IntValue: [], FloatValue: [], StringValue: [], BooleanValue: [], NullValue: [], EnumValue: [], ListValue: ["values"], ObjectValue: ["fields"], ObjectField: D[1], Directive: ["name", "arguments"], NamedType: D[0], ListType: D[2], NonNullType: D[2], SchemaDefinition: ["description", "directives", "operationTypes"], OperationTypeDefinition: D[2], ScalarTypeDefinition: D[3], ObjectTypeDefinition: D[4], FieldDefinition: ["description", "name", "arguments", "type", "directives"], InputValueDefinition: ["description", "name", "type", "defaultValue", "directives"], InterfaceTypeDefinition: D[4], UnionTypeDefinition: ["description", "name", "directives", "types"], EnumTypeDefinition: ["description", "name", "directives", "values"], EnumValueDefinition: D[3], InputObjectTypeDefinition: ["description", "name", "directives", "fields"], DirectiveDefinition: ["description", "name", "arguments", "directives", "locations"], SchemaExtension: ["directives", "operationTypes"], DirectiveExtension: D[5], ScalarTypeExtension: D[5], ObjectTypeExtension: D[6], InterfaceTypeExtension: D[6], UnionTypeExtension: ["name", "directives", "types"], EnumTypeExtension: ["name", "directives", "values"], InputObjectTypeExtension: ["name", "directives", "fields"] };
vt = be(Fe, "kind");
Pe = vt;
ee = (e2) => e2.loc.start;
te = (e2) => e2.loc.end;
fe.ignoredProperties = /* @__PURE__ */ new Set(["loc", "comments"]);
we = "format";
Ve = /^\s*#[^\S\n]*@(?:noformat|noprettier)\s*(?:\n|$)/;
Me = /^\s*#[^\S\n]*@(?:format|prettier)\s*(?:\n|$)/;
Ue = (e2) => Me.test(e2);
Be = (e2) => Ve.test(e2);
Ge = (e2) => `# @${we}
${e2}`;
Ke = kt;
je = Ct;
Ye = Rt;
wt = { print: Lt, massageAstNode: fe, hasPrettierIgnore: Pt, insertPragma: Ge, printComment: Ft, canAttachComment: bt, getVisitorKeys: Pe };
qe = wt;
Qe = [{ name: "GraphQL", type: "data", aceMode: "graphqlschema", extensions: [".graphql", ".gql", ".graphqls"], tmScope: "source.graphql", parsers: ["graphql"], vscodeLanguageIds: ["graphql"], linguistLanguageId: 139 }];
$e = { bracketSpacing: { category: "Common", type: "boolean", default: true, description: "Print spaces between brackets.", oppositeDescription: "Do not print spaces between brackets." }, objectWrap: { category: "Common", type: "choice", default: "preserve", description: "How to wrap object literals.", choices: [{ value: "preserve", description: "Keep as multi-line, if there is a newline between the opening brace and first property." }, { value: "collapse", description: "Fit to a single line when possible." }] }, singleQuote: { category: "Common", type: "boolean", default: false, description: "Use single quotes instead of double quotes." }, proseWrap: { category: "Common", type: "choice", default: "preserve", description: "How to wrap prose.", choices: [{ value: "always", description: "Wrap prose if it exceeds the print width." }, { value: "never", description: "Do not wrap prose." }, { value: "preserve", description: "Wrap prose as-is." }] }, bracketSameLine: { category: "Common", type: "boolean", default: false, description: "Put > of opening tags on the last line instead of on a new line." }, singleAttributePerLine: { category: "Common", type: "boolean", default: false, description: "Enforce single attribute per line in HTML, Vue and JSX." } };
Vt = { bracketSpacing: $e.bracketSpacing };
Xe = Vt;
_e = {};
ae(_e, { graphql: () => si });
He = Mt;
Ut = /\r\n|[\n\r]/g;
R = class e extends Error {
constructor(t, n = {}) {
let { nodes: r, source: i, positions: s, path: a, originalError: p, cause: E, extensions: x } = n, v = "cause" in n, P = v ? E : p, $ = v || p != null ? { cause: P } : void 0;
super(t, $), this.name = "GraphQLError", this.path = a ?? void 0;
let G = p ?? (E instanceof Error ? E : void 0);
this.originalError = G, this.nodes = Ze(Array.isArray(r) ? r : r ? [r] : void 0);
let k = Ze(this.nodes?.map((g) => g.loc).filter((g) => g != null));
this.source = i ?? k?.[0]?.source, this.positions = s ?? k?.map((g) => g.start), this.locations = s && i ? s.map((g) => w(i, g)) : k?.map((g) => w(g.source, g.start));
let C = Je(G?.extensions) ? G.extensions : void 0;
this.extensions = x ?? C ?? /* @__PURE__ */ Object.create(null), Object.defineProperties(this, { message: { writable: true, enumerable: true }, name: { enumerable: false }, nodes: { enumerable: false }, source: { enumerable: false }, positions: { enumerable: false }, originalError: { enumerable: false } }), p?.stack != null ? Object.defineProperty(this, "stack", { value: p.stack, writable: true, configurable: true }) : Error.captureStackTrace != null ? Error.captureStackTrace(this, e) : Object.defineProperty(this, "stack", { value: Error().stack, writable: true, configurable: true });
}
get [Symbol.toStringTag]() {
return "GraphQLError";
}
toString() {
let t = this.message;
if (this.nodes) for (let n of this.nodes) n.loc && (t += `
` + Ee(n.loc));
else if (this.source && this.locations) for (let n of this.locations) t += `
` + ne(this.source, n);
return t;
}
toJSON() {
let 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;
}
};
Bt = Object.hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty);
et = Bt;
Y = class {
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 };
}
};
V = class {
constructor(t, n, r, i, s, a) {
this.kind = t, this.start = n, this.end = r, this.line = i, this.column = s, 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 };
}
};
M = { QUERY: "query", MUTATION: "mutation", SUBSCRIPTION: "subscription" };
c = {};
ae(c, { ARGUMENT: () => $t, ARGUMENT_COORDINATE: () => Pn, BOOLEAN: () => nn, DIRECTIVE: () => pn, DIRECTIVE_ARGUMENT_COORDINATE: () => Vn, DIRECTIVE_COORDINATE: () => wn, DIRECTIVE_DEFINITION: () => In, DIRECTIVE_EXTENSION: () => Sn, DOCUMENT: () => Kt, ENUM: () => sn, ENUM_TYPE_DEFINITION: () => Dn, ENUM_TYPE_EXTENSION: () => Rn, ENUM_VALUE_DEFINITION: () => _n, FIELD: () => Qt, FIELD_DEFINITION: () => Tn, FLOAT: () => en, FRAGMENT_ARGUMENT: () => Xt, FRAGMENT_DEFINITION: () => Wt, FRAGMENT_SPREAD: () => Ht, INLINE_FRAGMENT: () => Jt, INPUT_OBJECT_TYPE_DEFINITION: () => An, INPUT_OBJECT_TYPE_EXTENSION: () => Ln, INPUT_VALUE_DEFINITION: () => xn, INT: () => Zt, INTERFACE_TYPE_DEFINITION: () => yn, INTERFACE_TYPE_EXTENSION: () => kn, LIST: () => on, LIST_TYPE: () => ln, MEMBER_COORDINATE: () => Fn, NAME: () => Gt, NAMED_TYPE: () => un, NON_NULL_TYPE: () => dn, NULL: () => rn, OBJECT: () => an, OBJECT_FIELD: () => cn, OBJECT_TYPE_DEFINITION: () => En, OBJECT_TYPE_EXTENSION: () => vn, OPERATION_DEFINITION: () => jt, OPERATION_TYPE_DEFINITION: () => mn, SCALAR_TYPE_DEFINITION: () => hn, SCALAR_TYPE_EXTENSION: () => On, SCHEMA_DEFINITION: () => fn, SCHEMA_EXTENSION: () => gn, SELECTION_SET: () => qt, STRING: () => tn, TYPE_COORDINATE: () => bn, UNION_TYPE_DEFINITION: () => Nn, UNION_TYPE_EXTENSION: () => Cn, VARIABLE: () => zt, VARIABLE_DEFINITION: () => Yt });
Gt = "Name";
Kt = "Document";
jt = "OperationDefinition";
Yt = "VariableDefinition";
qt = "SelectionSet";
Qt = "Field";
$t = "Argument";
Xt = "FragmentArgument";
Ht = "FragmentSpread";
Jt = "InlineFragment";
Wt = "FragmentDefinition";
zt = "Variable";
Zt = "IntValue";
en = "FloatValue";
tn = "StringValue";
nn = "BooleanValue";
rn = "NullValue";
sn = "EnumValue";
on = "ListValue";
an = "ObjectValue";
cn = "ObjectField";
pn = "Directive";
un = "NamedType";
ln = "ListType";
dn = "NonNullType";
fn = "SchemaDefinition";
mn = "OperationTypeDefinition";
hn = "ScalarTypeDefinition";
En = "ObjectTypeDefinition";
Tn = "FieldDefinition";
xn = "InputValueDefinition";
yn = "InterfaceTypeDefinition";
Nn = "UnionTypeDefinition";
Dn = "EnumTypeDefinition";
_n = "EnumValueDefinition";
An = "InputObjectTypeDefinition";
In = "DirectiveDefinition";
gn = "SchemaExtension";
Sn = "DirectiveExtension";
On = "ScalarTypeExtension";
vn = "ObjectTypeExtension";
kn = "InterfaceTypeExtension";
Cn = "UnionTypeExtension";
Rn = "EnumTypeExtension";
Ln = "InputObjectTypeExtension";
bn = "TypeCoordinate";
Fn = "MemberCoordinate";
Pn = "ArgumentCoordinate";
wn = "DirectiveCoordinate";
Vn = "DirectiveArgumentCoordinate";
ye = { QUERY: "QUERY", MUTATION: "MUTATION", SUBSCRIPTION: "SUBSCRIPTION", FIELD: "FIELD", FRAGMENT_DEFINITION: "FRAGMENT_DEFINITION", FRAGMENT_SPREAD: "FRAGMENT_SPREAD", INLINE_FRAGMENT: "INLINE_FRAGMENT", VARIABLE_DEFINITION: "VARIABLE_DEFINITION", FRAGMENT_VARIABLE_DEFINITION: "FRAGMENT_VARIABLE_DEFINITION", SCHEMA: "SCHEMA", SCALAR: "SCALAR", OBJECT: "OBJECT", FIELD_DEFINITION: "FIELD_DEFINITION", ARGUMENT_DEFINITION: "ARGUMENT_DEFINITION", INTERFACE: "INTERFACE", UNION: "UNION", ENUM: "ENUM", ENUM_VALUE: "ENUM_VALUE", INPUT_OBJECT: "INPUT_OBJECT", INPUT_FIELD_DEFINITION: "INPUT_FIELD_DEFINITION", DIRECTIVE_DEFINITION: "DIRECTIVE_DEFINITION" };
b = Un();
Ne = b?.tracingChannel("graphql:parse");
ds = b?.tracingChannel("graphql:validate");
fs = b?.tracingChannel("graphql:execute");
ms = b?.tracingChannel("graphql:execute:variableCoercion");
hs = b?.tracingChannel("graphql:execute:rootSelectionSet");
Es = b?.tracingChannel("graphql:subscribe");
Ts = b?.tracingChannel("graphql:resolve");
Bn = ["start", "end", "asyncStart", "asyncEnd", "error"];
o = { SOF: "<SOF>", EOF: "<EOF>", BANG: "!", DOLLAR: "$", AMP: "&", PAREN_L: "(", PAREN_R: ")", DOT: ".", SPREAD: "...", COLON: ":", EQUALS: "=", AT: "@", BRACKET_L: "[", BRACKET_R: "]", BRACE_L: "{", PIPE: "|", BRACE_R: "}", NAME: "Name", INT: "Int", FLOAT: "Float", STRING: "String", BLOCK_STRING: "BlockString", COMMENT: "Comment" };
Q = class {
constructor(t) {
let n = new V(o.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";
}
advance() {
return this.lastToken = this.token, this.token = this.lookahead();
}
lookahead() {
let t = this.token;
if (t.kind !== o.EOF) do
if (t.next) t = t.next;
else {
let n = Gn(this, t.end);
t.next = n, n.prev = t, t = n;
}
while (t.kind === o.COMMENT);
return t;
}
};
ut = /* @__PURE__ */ Symbol("Source");
B = class {
constructor(t, n = "GraphQL request", r = { line: 1, column: 1 }) {
this.__kind = ut, this.body = t, this.name = n, this.locationOffset = r, this.locationOffset.line > 0 || Te(false, "line in locationOffset is 1-indexed and must be positive."), this.locationOffset.column > 0 || Te(false, "column in locationOffset is 1-indexed and must be positive.");
}
get [Symbol.toStringTag]() {
return "Source";
}
};
De = class {
constructor(t, n = {}) {
let { lexer: r, ...i } = n;
if (r) this._lexer = r;
else {
let s = lt(t) ? t : new B(t);
this._lexer = new Q(s);
}
this._options = i, this._tokenCounter = 0;
}
get tokenCount() {
return this._tokenCounter;
}
parseName() {
let t = this.expectToken(o.NAME);
return this.node(t, { kind: c.NAME, value: t.value });
}
parseDocument() {
return this.node(this._lexer.token, { kind: c.DOCUMENT, definitions: this.many(o.SOF, this.parseDefinition, o.EOF) });
}
parseDefinition() {
if (this.peek(o.BRACE_L)) return this.parseOperationDefinition();
let t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
if (t && n.kind === o.BRACE_L) throw f(this._lexer.source, this._lexer.token.start, "Unexpected description, descriptions are not supported on shorthand queries.");
if (n.kind === o.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();
}
switch (n.value) {
case "query":
case "mutation":
case "subscription":
return this.parseOperationDefinition();
case "fragment":
return this.parseFragmentDefinition();
}
if (t) throw f(this._lexer.source, this._lexer.token.start, "Unexpected description, only GraphQL definitions support descriptions.");
if (n.value === "extend") return this.parseTypeSystemExtension();
}
throw this.unexpected(n);
}
parseOperationDefinition() {
let t = this._lexer.token;
if (this.peek(o.BRACE_L)) return this.node(t, { kind: c.OPERATION_DEFINITION, operation: M.QUERY, description: void 0, name: void 0, variableDefinitions: void 0, directives: void 0, selectionSet: this.parseSelectionSet() });
let n = this.parseDescription(), r = this.parseOperationType(), i;
return this.peek(o.NAME) && (i = this.parseName()), this.node(t, { kind: c.OPERATION_DEFINITION, operation: r, description: n, name: i, variableDefinitions: this.parseVariableDefinitions(), directives: this.parseDirectives(false), selectionSet: this.parseSelectionSet() });
}
parseOperationType() {
let t = this.expectToken(o.NAME);
switch (t.value) {
case "query":
return M.QUERY;
case "mutation":
return M.MUTATION;
case "subscription":
return M.SUBSCRIPTION;
}
throw this.unexpected(t);
}
parseVariableDefinitions() {
return this.optionalMany(o.PAREN_L, this.parseVariableDefinition, o.PAREN_R);
}
parseVariableDefinition() {
return this.node(this._lexer.token, { kind: c.VARIABLE_DEFINITION, description: this.parseDescription(), variable: this.parseVariable(), type: (this.expectToken(o.COLON), this.parseTypeReference()), defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0, directives: this.parseConstDirectives() });
}
parseVariable() {
let t = this._lexer.token;
return this.expectToken(o.DOLLAR), this.node(t, { kind: c.VARIABLE, name: this.parseName() });
}
parseSelectionSet() {
return this.node(this._lexer.token, { kind: c.SELECTION_SET, selections: this.many(o.BRACE_L, this.parseSelection, o.BRACE_R) });
}
parseSelection() {
return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField();
}
parseField() {
let t = this._lexer.token, n = this.parseName(), r, i;
return this.expectOptionalToken(o.COLON) ? (r = n, i = this.parseName()) : i = n, this.node(t, { kind: c.FIELD, alias: r, name: i, arguments: this.parseArguments(false), directives: this.parseDirectives(false), selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0 });
}
parseArguments(t) {
let n = t ? this.parseConstArgument : this.parseArgument;
return this.optionalMany(o.PAREN_L, n, o.PAREN_R);
}
parseFragmentArguments() {
let t = this.parseFragmentArgument;
return this.optionalMany(o.PAREN_L, t, o.PAREN_R);
}
parseArgument(t = false) {
let n = this._lexer.token, r = this.parseName();
return this.expectToken(o.COLON), this.node(n, { kind: c.ARGUMENT, name: r, value: this.parseValueLiteral(t) });
}
parseConstArgument() {
return this.parseArgument(true);
}
parseFragmentArgument() {
let t = this._lexer.token, n = this.parseName();
return this.expectToken(o.COLON), this.node(t, { kind: c.FRAGMENT_ARGUMENT, name: n, value: this.parseValueLiteral(false) });
}
parseFragment() {
let t = this._lexer.token;
this.expectToken(o.SPREAD);
let n = this.expectOptionalKeyword("on");
if (!n && this.peek(o.NAME)) {
let r = this.parseFragmentName();
return this.peek(o.PAREN_L) && this._options.experimentalFragmentArguments ? this.node(t, { kind: c.FRAGMENT_SPREAD, name: r, arguments: this.parseFragmentArguments(), directives: this.parseDirectives(false) }) : this.node(t, { kind: c.FRAGMENT_SPREAD, name: r, directives: this.parseDirectives(false) });
}
return this.node(t, { kind: c.INLINE_FRAGMENT, typeCondition: n ? this.parseNamedType() : void 0, directives: this.parseDirectives(false), selectionSet: this.parseSelectionSet() });
}
parseFragmentDefinition() {
let t = this._lexer.token, n = this.parseDescription();
return this.expectKeyword("fragment"), this._options.experimentalFragmentArguments === true ? this.node(t, { kind: c.FRAGMENT_DEFINITION, description: n, name: this.parseFragmentName(), variableDefinitions: this.parseVariableDefinitions(), typeCondition: (this.expectKeyword("on"), this.parseNamedType()), directives: this.parseDirectives(false), selectionSet: this.parseSelectionSet() }) : this.node(t, { kind: c.FRAGMENT_DEFINITION, description: n, name: this.parseFragmentName(), typeCondition: (this.expectKeyword("on"), this.parseNamedType()), directives: this.parseDirectives(false), selectionSet: this.parseSelectionSet() });
}
parseFragmentName() {
if (this._lexer.token.value === "on") throw this.unexpected();
return this.parseName();
}
parseValueLiteral(t) {
let n = this._lexer.token;
switch (n.kind) {
case o.BRACKET_L:
return this.parseList(t);
case o.BRACE_L:
return this.parseObject(t);
case o.INT:
return this.advanceLexer(), this.node(n, { kind: c.INT, value: n.value });
case o.FLOAT:
return this.advanceLexer(), this.node(n, { kind: c.FLOAT, value: n.value });
case o.STRING:
case o.BLOCK_STRING:
return this.parseStringLiteral();
case o.NAME:
switch (this.advanceLexer(), n.value) {
case "true":
return this.node(n, { kind: c.BOOLEAN, value: true });
case "false":
return this.node(n, { kind: c.BOOLEAN, value: false });
case "null":
return this.node(n, { kind: c.NULL });
default:
return this.node(n, { kind: c.ENUM, value: n.value });
}
case o.DOLLAR:
if (t) if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) {
let r = this._lexer.token.value;
throw f(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(true);
}
parseStringLiteral() {
let t = this._lexer.token;
return this.advanceLexer(), this.node(t, { kind: c.STRING, value: t.value, block: t.kind === o.BLOCK_STRING });
}
parseList(t) {
let n = () => this.parseValueLiteral(t);
return this.node(this._lexer.token, { kind: c.LIST, values: this.any(o.BRACKET_L, n, o.BRACKET_R) });
}
parseObject(t) {
let n = () => this.parseObjectField(t);
return this.node(this._lexer.token, { kind: c.OBJECT, fields: this.any(o.BRACE_L, n, o.BRACE_R) });
}
parseObjectField(t) {
let n = this._lexer.token, r = this.parseName();
return this.expectToken(o.COLON), this.node(n, { kind: c.OBJECT_FIELD, name: r, value: this.parseValueLiteral(t) });
}
parseDirectives(t) {
let n = [];
for (; this.peek(o.AT); ) n.push(this.parseDirective(t));
if (n.length) return n;
}
parseConstDirectives() {
return this.parseDirectives(true);
}
parseDirective(t) {
let n = this._lexer.token;
return this.expectToken(o.AT), this.node(n, { kind: c.DIRECTIVE, name: this.parseName(), arguments: this.parseArguments(t) });
}
parseTypeReference() {
let t = this._lexer.token, n;
if (this.expectOptionalToken(o.BRACKET_L)) {
let r = this.parseTypeReference();
this.expectToken(o.BRACKET_R), n = this.node(t, { kind: c.LIST_TYPE, type: r });
} else n = this.parseNamedType();
return this.expectOptionalToken(o.BANG) ? this.node(t, { kind: c.NON_NULL_TYPE, type: n }) : n;
}
parseNamedType() {
return this.node(this._lexer.token, { kind: c.NAMED_TYPE, name: this.parseName() });
}
peekDescription() {
return this.peek(o.STRING) || this.peek(o.BLOCK_STRING);
}
parseDescription() {
if (this.peekDescription()) return this.parseStringLiteral();
}
parseSchemaDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("schema");
let r = this.parseConstDirectives(), i = this.many(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R);
return this.node(t, { kind: c.SCHEMA_DEFINITION, description: n, directives: r, operationTypes: i });
}
parseOperationTypeDefinition() {
let t = this._lexer.token, n = this.parseOperationType();
this.expectToken(o.COLON);
let r = this.parseNamedType();
return this.node(t, { kind: c.OPERATION_TYPE_DEFINITION, operation: n, type: r });
}
parseScalarTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("scalar");
let r = this.parseName(), i = this.parseConstDirectives();
return this.node(t, { kind: c.SCALAR_TYPE_DEFINITION, description: n, name: r, directives: i });
}
parseObjectTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("type");
let r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(t, { kind: c.OBJECT_TYPE_DEFINITION, description: n, name: r, interfaces: i, directives: s, fields: a });
}
parseImplementsInterfaces() {
return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : void 0;
}
parseFieldsDefinition() {
return this.optionalMany(o.BRACE_L, this.parseFieldDefinition, o.BRACE_R);
}
parseFieldDefinition() {
let t = this._lexer.token, n = this.parseDescription(), r = this.parseName(), i = this.parseArgumentDefs();
this.expectToken(o.COLON);
let s = this.parseTypeReference(), a = this.parseConstDirectives();
return this.node(t, { kind: c.FIELD_DEFINITION, description: n, name: r, arguments: i, type: s, directives: a });
}
parseArgumentDefs() {
return this.optionalMany(o.PAREN_L, this.parseInputValueDef, o.PAREN_R);
}
parseInputValueDef() {
let t = this._lexer.token, n = this.parseDescription(), r = this.parseName();
this.expectToken(o.COLON);
let i = this.parseTypeReference(), s;
this.expectOptionalToken(o.EQUALS) && (s = this.parseConstValueLiteral());
let a = this.parseConstDirectives();
return this.node(t, { kind: c.INPUT_VALUE_DEFINITION, description: n, name: r, type: i, defaultValue: s, directives: a });
}
parseInterfaceTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("interface");
let r = this.parseName(), i = this.parseImplementsInterfaces(), s = this.parseConstDirectives(), a = this.parseFieldsDefinition();
return this.node(t, { kind: c.INTERFACE_TYPE_DEFINITION, description: n, name: r, interfaces: i, directives: s, fields: a });
}
parseUnionTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("union");
let r = this.parseName(), i = this.parseConstDirectives(), s = this.parseUnionMemberTypes();
return this.node(t, { kind: c.UNION_TYPE_DEFINITION, description: n, name: r, directives: i, types: s });
}
parseUnionMemberTypes() {
return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : void 0;
}
parseEnumTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("enum");
let r = this.parseName(), i = this.parseConstDirectives(), s = this.parseEnumValuesDefinition();
return this.node(t, { kind: c.ENUM_TYPE_DEFINITION, description: n, name: r, directives: i, values: s });
}
parseEnumValuesDefinition() {
return this.optionalMany(o.BRACE_L, this.parseEnumValueDefinition, o.BRACE_R);
}
parseEnumValueDefinition() {
let t = this._lexer.token, n = this.parseDescription(), r = this.parseEnumValueName(), i = this.parseConstDirectives();
return this.node(t, { kind: c.ENUM_VALUE_DEFINITION, description: n, name: r, directives: i });
}
parseEnumValueName() {
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") throw f(this._lexer.source, this._lexer.token.start, `${se(this._lexer.token)} is reserved and cannot be used for an enum value.`);
return this.parseName();
}
parseInputObjectTypeDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("input");
let r = this.parseName(), i = this.parseConstDirectives(), s = this.parseInputFieldsDefinition();
return this.node(t, { kind: c.INPUT_OBJECT_TYPE_DEFINITION, description: n, name: r, directives: i, fields: s });
}
parseInputFieldsDefinition() {
return this.optionalMany(o.BRACE_L, this.parseInputValueDef, o.BRACE_R);
}
parseTypeSystemExtension() {
let t = this._lexer.lookahead();
if (t.kind === o.NAME) switch (t.value) {
case "schema":
return this.parseSchemaExtension();
case "scalar":
return this.parseScalarTypeExtension();
case "type":
return this.parseObjectTypeExtension();
case "interface":
return this.parseInterfaceTypeExtension();
case "union":
return this.parseUnionTypeExtension();
case "enum":
return this.parseEnumTypeExtension();
case "input":
return this.parseInputObjectTypeExtension();
case "directive":
return this.parseDirectiveExtension();
}
throw this.unexpected(t);
}
parseSchemaExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("schema");
let n = this.parseConstDirectives(), r = this.optionalMany(o.BRACE_L, this.parseOperationTypeDefinition, o.BRACE_R);
if (n === void 0 && r === void 0) throw this.unexpected();
return this.node(t, { kind: c.SCHEMA_EXTENSION, directives: n, operationTypes: r });
}
parseScalarTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("scalar");
let n = this.parseName(), r = this.parseConstDirectives();
if (r === void 0) throw this.unexpected();
return this.node(t, { kind: c.SCALAR_TYPE_EXTENSION, name: n, directives: r });
}
parseObjectTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("type");
let n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
if (r === void 0 && i === void 0 && s === void 0) throw this.unexpected();
return this.node(t, { kind: c.OBJECT_TYPE_EXTENSION, name: n, interfaces: r, directives: i, fields: s });
}
parseInterfaceTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("interface");
let n = this.parseName(), r = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), s = this.parseFieldsDefinition();
if (r === void 0 && i === void 0 && s === void 0) throw this.unexpected();
return this.node(t, { kind: c.INTERFACE_TYPE_EXTENSION, name: n, interfaces: r, directives: i, fields: s });
}
parseUnionTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("union");
let n = this.parseName(), r = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
if (r === void 0 && i === void 0) throw this.unexpected();
return this.node(t, { kind: c.UNION_TYPE_EXTENSION, name: n, directives: r, types: i });
}
parseEnumTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("enum");
let n = this.parseName(), r = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
if (r === void 0 && i === void 0) throw this.unexpected();
return this.node(t, { kind: c.ENUM_TYPE_EXTENSION, name: n, directives: r, values: i });
}
parseInputObjectTypeExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("input");
let n = this.parseName(), r = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
if (r === void 0 && i === void 0) throw this.unexpected();
return this.node(t, { kind: c.INPUT_OBJECT_TYPE_EXTENSION, name: n, directives: r, fields: i });
}
parseDirectiveExtension() {
let t = this._lexer.token;
this.expectKeyword("extend"), this.expectKeyword("directive"), this.expectToken(o.AT);
let n = this.parseName(), r = this.parseConstDirectives();
if (r === void 0) throw this.unexpected();
return this.node(t, { kind: c.DIRECTIVE_EXTENSION, name: n, directives: r });
}
parseDirectiveDefinition() {
let t = this._lexer.token, n = this.parseDescription();
this.expectKeyword("directive"), this.expectToken(o.AT);
let r = this.parseName(), i = this.parseArgumentDefs(), s = this.parseConstDirectives(), a = this.expectOptionalKeyword("repeatable");
this.expectKeyword("on");
let p = this.parseDirectiveLocations();
return this.node(t, { kind: c.DIRECTIVE_DEFINITION, description: n, name: r, arguments: i, directives: s, repeatable: a, locations: p });
}
parseDirectiveLocations() {
return this.delimitedMany(o.PIPE, this.parseDirectiveLocation);
}
parseDirectiveLocation() {
let t = this._lexer.token, n = this.parseName();
if (et(ye, n.value)) return n;
throw this.unexpected(t);
}
parseSchemaCoordinate() {
let t = this._lexer.token, n = this.expectOptionalToken(o.AT), r = this.parseName(), i;
!n && this.expectOptionalToken(o.DOT) && (i = this.parseName());
let s;
return (n || i) && this.expectOptionalToken(o.PAREN_L) && (s = this.parseName(), this.expectToken(o.COLON), this.expectToken(o.PAREN_R)), n ? s ? this.node(t, { kind: c.DIRECTIVE_ARGUMENT_COORDINATE, name: r, argumentName: s }) : this.node(t, { kind: c.DIRECTIVE_COORDINATE, name: r }) : i ? s ? this.node(t, { kind: c.ARGUMENT_COORDINATE, name: r, fieldName: i, argumentName: s }) : this.node(t, { kind: c.MEMBER_COORDINATE, name: r, memberName: i }) : this.node(t, { kind: c.TYPE_COORDINATE, name: r });
}
node(t, n) {
return this._options.noLocation !== true && (n.loc = new Y(t, this._lexer.lastToken, this._lexer.source)), n;
}
peek(t) {
return this._lexer.token.kind === t;
}
expectToken(t) {
let n = this._lexer.token;
if (n.kind === t) return this.advanceLexer(), n;
throw f(this._lexer.source, n.start, `Expected ${ft(t)}, found ${se(n)}.`);
}
expectOptionalToken(t) {
return this._lexer.token.kind === t ? (this.advanceLexer(), true) : false;
}
expectKeyword(t) {
let n = this._lexer.token;
if (n.kind === o.NAME && n.value === t) this.advanceLexer();
else throw f(this._lexer.source, n.start, `Expected "${t}", found ${se(n)}.`);
}
expectOptionalKeyword(t) {
let n = this._lexer.token;
return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), true) : false;
}
unexpected(t) {
let n = t ?? this._lexer.token;
return f(this._lexer.source, n.start, `Unexpected ${se(n)}.`);
}
any(t, n, r) {
this.expectToken(t);
let i = [];
for (; !this.expectOptionalToken(r); ) i.push(n.call(this));
return i;
}
optionalMany(t, n, r) {
if (this.expectOptionalToken(t)) {
let i = [];
do
i.push(n.call(this));
while (!this.expectOptionalToken(r));
return i;
}
}
many(t, n, r) {
this.expectToken(t);
let i = [];
do
i.push(n.call(this));
while (!this.expectOptionalToken(r));
return i;
}
delimitedMany(t, n) {
this.expectOptionalToken(t);
let r = [];
do
r.push(n.call(this));
while (this.expectOptionalToken(t));
return r;
}
advanceLexer() {
let { maxTokens: t } = this._options, n = this._lexer.advance();
if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t)) throw f(this._lexer.source, n.start, `Document contains more than ${t} tokens. Parsing aborted.`);
}
};
mt = ei;
ni = { experimentalFragmentArguments: true };
si = { parse: ri, astFormat: "graphql", hasPragma: Ue, hasIgnorePragma: Be, locStart: ee, locEnd: te };
oi = { graphql: qe };
}
});
init_graphql();
export {
ht as default,
Qe as languages,
Xe as options,
_e as parsers,
oi as printers
};