@gh-symphony/cli 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-PG332ZS4.js → chunk-DW63WPRE.js} +1 -1
- package/dist/{chunk-PEZUBHWJ.js → chunk-E7OCBNB2.js} +76 -8
- package/dist/{chunk-WCOIVNHH.js → chunk-EWTMSDCE.js} +3154 -224
- package/dist/{chunk-NESHTYXQ.js → chunk-HT3FAJAO.js} +3 -3
- package/dist/{chunk-2YF7PQUC.js → chunk-RHLUIMBN.js} +1 -1
- package/dist/{chunk-HQ7A3C7K.js → chunk-YIARPBOR.js} +1 -1
- package/dist/{doctor-2AXHIEAP.js → doctor-I32MANQ4.js} +4 -4
- package/dist/index.js +6 -6
- package/dist/{repo-SUXYT4OK.js → repo-IH6UWE4H.js} +10 -11
- package/dist/{setup-UBHOMXUG.js → setup-UJC2WYHQ.js} +3 -3
- package/dist/{upgrade-355SQJ5P.js → upgrade-XYHCUGHT.js} +2 -2
- package/dist/{version-4ILSDZQH.js → version-B2AYYGLM.js} +1 -1
- package/dist/worker-entry.js +43 -3
- package/dist/{workflow-S6YSZPQT.js → workflow-WSXHMO5B.js} +4 -4
- package/package.json +5 -5
|
@@ -1528,6 +1528,42 @@ function parseRunEventLine(line) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
}
|
|
1530
1530
|
|
|
1531
|
+
// ../core/src/observability/redaction.ts
|
|
1532
|
+
var REDACTED = "[REDACTED]";
|
|
1533
|
+
var SENSITIVE_KEY_SUBSTRINGS = [
|
|
1534
|
+
"authorization",
|
|
1535
|
+
"secret",
|
|
1536
|
+
"apiKey",
|
|
1537
|
+
"api-key",
|
|
1538
|
+
"api_key"
|
|
1539
|
+
];
|
|
1540
|
+
function redactObservabilitySecrets(value) {
|
|
1541
|
+
return redactValue(value);
|
|
1542
|
+
}
|
|
1543
|
+
function redactValue(value) {
|
|
1544
|
+
if (Array.isArray(value)) {
|
|
1545
|
+
return value.map((item) => redactValue(item));
|
|
1546
|
+
}
|
|
1547
|
+
if (!isRecord3(value)) {
|
|
1548
|
+
return value;
|
|
1549
|
+
}
|
|
1550
|
+
return Object.fromEntries(
|
|
1551
|
+
Object.entries(value).map(([key, nested]) => [
|
|
1552
|
+
key,
|
|
1553
|
+
shouldRedactKey(key) ? REDACTED : redactValue(nested)
|
|
1554
|
+
])
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
function shouldRedactKey(key) {
|
|
1558
|
+
const normalizedKey = key.toLowerCase();
|
|
1559
|
+
return normalizedKey === "token" || normalizedKey.endsWith("token") || SENSITIVE_KEY_SUBSTRINGS.some(
|
|
1560
|
+
(pattern) => normalizedKey.includes(pattern.toLowerCase())
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
function isRecord3(value) {
|
|
1564
|
+
return value != null && typeof value === "object";
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1531
1567
|
// ../core/src/observability/status-assembler.ts
|
|
1532
1568
|
function isMatchingIssueRun(run, issueId, issueIdentifier) {
|
|
1533
1569
|
return Boolean(
|
|
@@ -1853,108 +1889,3018 @@ function resolveShellCommandClaudeBinary(command) {
|
|
|
1853
1889
|
}
|
|
1854
1890
|
}
|
|
1855
1891
|
}
|
|
1856
|
-
return null;
|
|
1857
|
-
}
|
|
1858
|
-
function isClaudeBinaryName(command) {
|
|
1859
|
-
const normalized = (command.split(/[\\/]/).pop() ?? command).toLowerCase().replace(/\.(exe|cmd|bat)$/i, "");
|
|
1860
|
-
return normalized === "claude" || normalized === "claude-code";
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
|
-
// ../runtime-claude/src/adapter.ts
|
|
1864
|
-
import { randomUUID } from "crypto";
|
|
1865
|
-
import { rm } from "fs/promises";
|
|
1866
|
-
import { join as join5 } from "path";
|
|
1867
|
-
|
|
1868
|
-
// ../runtime-claude/src/argv.ts
|
|
1869
|
-
var DEFAULT_CLAUDE_PRINT_ARGS = [
|
|
1870
|
-
"-p",
|
|
1871
|
-
"--output-format",
|
|
1872
|
-
"stream-json",
|
|
1873
|
-
"--input-format",
|
|
1874
|
-
"stream-json",
|
|
1875
|
-
"--include-partial-messages",
|
|
1876
|
-
// Claude stream-json output requires verbose mode when partial message
|
|
1877
|
-
// events are included; keep this even when callers provide custom args.
|
|
1878
|
-
"--verbose",
|
|
1879
|
-
"--permission-mode",
|
|
1880
|
-
"bypassPermissions"
|
|
1881
|
-
];
|
|
1882
|
-
function buildClaudePrintArgv(options = {}) {
|
|
1883
|
-
const args = options.baseArgs ? withRequiredClaudePrintArgs(options.baseArgs) : [...DEFAULT_CLAUDE_PRINT_ARGS];
|
|
1884
|
-
const { session, isolation, extraArgs } = options;
|
|
1885
|
-
if (session?.mode === "start") {
|
|
1886
|
-
ensureFlagValue(args, "--session-id", session.sessionId);
|
|
1892
|
+
return null;
|
|
1893
|
+
}
|
|
1894
|
+
function isClaudeBinaryName(command) {
|
|
1895
|
+
const normalized = (command.split(/[\\/]/).pop() ?? command).toLowerCase().replace(/\.(exe|cmd|bat)$/i, "");
|
|
1896
|
+
return normalized === "claude" || normalized === "claude-code";
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
// ../runtime-claude/src/adapter.ts
|
|
1900
|
+
import { randomUUID } from "crypto";
|
|
1901
|
+
import { rm } from "fs/promises";
|
|
1902
|
+
import { join as join5 } from "path";
|
|
1903
|
+
|
|
1904
|
+
// ../runtime-claude/src/argv.ts
|
|
1905
|
+
var DEFAULT_CLAUDE_PRINT_ARGS = [
|
|
1906
|
+
"-p",
|
|
1907
|
+
"--output-format",
|
|
1908
|
+
"stream-json",
|
|
1909
|
+
"--input-format",
|
|
1910
|
+
"stream-json",
|
|
1911
|
+
"--include-partial-messages",
|
|
1912
|
+
// Claude stream-json output requires verbose mode when partial message
|
|
1913
|
+
// events are included; keep this even when callers provide custom args.
|
|
1914
|
+
"--verbose",
|
|
1915
|
+
"--permission-mode",
|
|
1916
|
+
"bypassPermissions"
|
|
1917
|
+
];
|
|
1918
|
+
function buildClaudePrintArgv(options = {}) {
|
|
1919
|
+
const args = options.baseArgs ? withRequiredClaudePrintArgs(options.baseArgs) : [...DEFAULT_CLAUDE_PRINT_ARGS];
|
|
1920
|
+
const { session, isolation, extraArgs } = options;
|
|
1921
|
+
if (session?.mode === "start") {
|
|
1922
|
+
ensureFlagValue(args, "--session-id", session.sessionId);
|
|
1923
|
+
}
|
|
1924
|
+
if (session?.mode === "resume") {
|
|
1925
|
+
ensureFlagValue(args, "--resume", session.sessionId);
|
|
1926
|
+
if (session.forkSession) {
|
|
1927
|
+
ensureFlag(args, "--fork-session");
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
if (isolation?.bare) {
|
|
1931
|
+
ensureFlag(args, "--bare");
|
|
1932
|
+
}
|
|
1933
|
+
if (isolation?.strictMcpConfig) {
|
|
1934
|
+
ensureFlag(args, "--strict-mcp-config");
|
|
1935
|
+
if (isolation.mcpConfigPath) {
|
|
1936
|
+
ensureFlagValue(args, "--mcp-config", isolation.mcpConfigPath);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
if (extraArgs?.length) {
|
|
1940
|
+
args.push(...extraArgs);
|
|
1941
|
+
}
|
|
1942
|
+
return args;
|
|
1943
|
+
}
|
|
1944
|
+
function withRequiredClaudePrintArgs(baseArgs) {
|
|
1945
|
+
const args = [...baseArgs];
|
|
1946
|
+
ensureFlag(args, "-p");
|
|
1947
|
+
ensureFlagValue(args, "--output-format", "stream-json");
|
|
1948
|
+
ensureFlagValue(args, "--input-format", "stream-json");
|
|
1949
|
+
ensureFlag(args, "--include-partial-messages");
|
|
1950
|
+
ensureFlag(args, "--verbose");
|
|
1951
|
+
ensureFlagValue(args, "--permission-mode", "bypassPermissions");
|
|
1952
|
+
return args;
|
|
1953
|
+
}
|
|
1954
|
+
function ensureFlag(args, flag) {
|
|
1955
|
+
if (!args.includes(flag)) {
|
|
1956
|
+
args.push(flag);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
function ensureFlagValue(args, flag, value) {
|
|
1960
|
+
const index = args.indexOf(flag);
|
|
1961
|
+
if (index === -1) {
|
|
1962
|
+
args.push(flag, value);
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const existingValue = args[index + 1];
|
|
1966
|
+
if (existingValue?.startsWith("-")) {
|
|
1967
|
+
args.splice(index + 1, 0, value);
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
if (existingValue !== value) {
|
|
1971
|
+
args.splice(index + 1, existingValue === void 0 ? 0 : 1, value);
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
// ../runtime-claude/src/mcp-compose.ts
|
|
1976
|
+
import { mkdir, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
|
|
1977
|
+
import { basename, dirname, join as join3, resolve as resolve4 } from "path";
|
|
1978
|
+
|
|
1979
|
+
// ../tool-github-graphql/src/tool.ts
|
|
1980
|
+
import { readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
|
|
1981
|
+
var DEFAULT_GITHUB_GRAPHQL_API_URL = "https://api.github.com/graphql";
|
|
1982
|
+
var TOKEN_REUSE_WINDOW_MS2 = 60 * 1e3;
|
|
1983
|
+
async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
|
|
1984
|
+
const token = await resolveGitHubGraphQLToken(config, {
|
|
1985
|
+
fetchImpl
|
|
1986
|
+
});
|
|
1987
|
+
const response = await fetchImpl(
|
|
1988
|
+
config.apiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL,
|
|
1989
|
+
{
|
|
1990
|
+
method: "POST",
|
|
1991
|
+
headers: {
|
|
1992
|
+
"content-type": "application/json",
|
|
1993
|
+
authorization: `Bearer ${token}`
|
|
1994
|
+
},
|
|
1995
|
+
body: JSON.stringify(invocation)
|
|
1996
|
+
}
|
|
1997
|
+
);
|
|
1998
|
+
const payload = await response.json();
|
|
1999
|
+
if (!response.ok) {
|
|
2000
|
+
throw new Error(
|
|
2001
|
+
`GitHub GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
|
|
2002
|
+
);
|
|
2003
|
+
}
|
|
2004
|
+
if (payload.errors?.length) {
|
|
2005
|
+
throw new Error(payload.errors.map((error) => error.message).join("; "));
|
|
2006
|
+
}
|
|
2007
|
+
return payload;
|
|
2008
|
+
}
|
|
2009
|
+
async function resolveGitHubGraphQLToken(config, dependencies = {}) {
|
|
2010
|
+
if (config.token) {
|
|
2011
|
+
return config.token;
|
|
2012
|
+
}
|
|
2013
|
+
if (!config.tokenBrokerUrl || !config.tokenBrokerSecret) {
|
|
2014
|
+
throw new Error(
|
|
2015
|
+
"Either GITHUB_GRAPHQL_TOKEN or the runtime token broker configuration is required."
|
|
2016
|
+
);
|
|
2017
|
+
}
|
|
2018
|
+
const now = dependencies.now ?? /* @__PURE__ */ new Date();
|
|
2019
|
+
const readFileImpl = dependencies.readFileImpl ?? readFile5;
|
|
2020
|
+
const writeFileImpl = dependencies.writeFileImpl ?? writeFile2;
|
|
2021
|
+
const cachedToken = config.tokenCachePath ? await readCachedToken(config.tokenCachePath, readFileImpl) : null;
|
|
2022
|
+
if (cachedToken && cachedToken.expiresAt.getTime() - now.getTime() > TOKEN_REUSE_WINDOW_MS2) {
|
|
2023
|
+
return cachedToken.token;
|
|
2024
|
+
}
|
|
2025
|
+
const fetchImpl = dependencies.fetchImpl ?? fetch;
|
|
2026
|
+
const response = await fetchImpl(config.tokenBrokerUrl, {
|
|
2027
|
+
method: "POST",
|
|
2028
|
+
headers: {
|
|
2029
|
+
accept: "application/json",
|
|
2030
|
+
authorization: `Bearer ${config.tokenBrokerSecret}`
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
const payload = await response.json();
|
|
2034
|
+
if (!response.ok || !payload.token || !payload.expiresAt) {
|
|
2035
|
+
throw new Error(
|
|
2036
|
+
payload.error ?? `Runtime token broker request failed with status ${response.status}.`
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
if (config.tokenCachePath) {
|
|
2040
|
+
await writeFileImpl(config.tokenCachePath, JSON.stringify(payload), "utf8");
|
|
2041
|
+
}
|
|
2042
|
+
return payload.token;
|
|
2043
|
+
}
|
|
2044
|
+
async function readStdin() {
|
|
2045
|
+
const chunks = [];
|
|
2046
|
+
for await (const chunk of process.stdin) {
|
|
2047
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
2048
|
+
}
|
|
2049
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
2050
|
+
}
|
|
2051
|
+
async function main() {
|
|
2052
|
+
const rawInput = await readStdin();
|
|
2053
|
+
const invocation = JSON.parse(rawInput);
|
|
2054
|
+
const result = await executeGitHubGraphQL(invocation, {
|
|
2055
|
+
token: process.env.GITHUB_GRAPHQL_TOKEN,
|
|
2056
|
+
apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
|
|
2057
|
+
tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
|
|
2058
|
+
tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2059
|
+
tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
|
|
2060
|
+
});
|
|
2061
|
+
process.stdout.write(`${JSON.stringify(result)}
|
|
2062
|
+
`);
|
|
2063
|
+
}
|
|
2064
|
+
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
2065
|
+
main().catch((error) => {
|
|
2066
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
2067
|
+
process.stderr.write(`${message}
|
|
2068
|
+
`);
|
|
2069
|
+
process.exitCode = 1;
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
async function readCachedToken(path, readFileImpl) {
|
|
2073
|
+
try {
|
|
2074
|
+
const payload = JSON.parse(await readFileImpl(path, "utf8"));
|
|
2075
|
+
if (!payload.token || !payload.expiresAt) {
|
|
2076
|
+
return null;
|
|
2077
|
+
}
|
|
2078
|
+
return {
|
|
2079
|
+
token: payload.token,
|
|
2080
|
+
expiresAt: new Date(payload.expiresAt)
|
|
2081
|
+
};
|
|
2082
|
+
} catch {
|
|
2083
|
+
return null;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
// ../tool-github-graphql/src/mcp-server.ts
|
|
2088
|
+
import { fileURLToPath } from "url";
|
|
2089
|
+
var TOOL_SCHEMA = {
|
|
2090
|
+
name: "github_graphql",
|
|
2091
|
+
description: "Execute GitHub GraphQL queries for the active workspace so the agent can mutate project and issue state directly.",
|
|
2092
|
+
inputSchema: {
|
|
2093
|
+
type: "object",
|
|
2094
|
+
properties: {
|
|
2095
|
+
query: {
|
|
2096
|
+
type: "string",
|
|
2097
|
+
description: "GraphQL query or mutation document."
|
|
2098
|
+
},
|
|
2099
|
+
variables: {
|
|
2100
|
+
type: "object",
|
|
2101
|
+
description: "Variables for the GraphQL document."
|
|
2102
|
+
},
|
|
2103
|
+
operationName: {
|
|
2104
|
+
type: "string",
|
|
2105
|
+
description: "Optional GraphQL operation name."
|
|
2106
|
+
}
|
|
2107
|
+
},
|
|
2108
|
+
required: ["query"],
|
|
2109
|
+
additionalProperties: false
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
var lineBuffer = "";
|
|
2113
|
+
function resolveGitHubGraphQLMcpServerEntryPoint() {
|
|
2114
|
+
return fileURLToPath(new URL("./mcp-server.js", import.meta.url));
|
|
2115
|
+
}
|
|
2116
|
+
function sendResponse(id, result) {
|
|
2117
|
+
const msg = JSON.stringify({ jsonrpc: "2.0", id, result });
|
|
2118
|
+
process.stdout.write(msg + "\n");
|
|
2119
|
+
}
|
|
2120
|
+
function sendError(id, code, message) {
|
|
2121
|
+
const msg = JSON.stringify({
|
|
2122
|
+
jsonrpc: "2.0",
|
|
2123
|
+
id,
|
|
2124
|
+
error: { code, message }
|
|
2125
|
+
});
|
|
2126
|
+
process.stdout.write(msg + "\n");
|
|
2127
|
+
}
|
|
2128
|
+
async function handleRequest(msg) {
|
|
2129
|
+
const id = msg.id ?? null;
|
|
2130
|
+
switch (msg.method) {
|
|
2131
|
+
case "initialize": {
|
|
2132
|
+
sendResponse(id, {
|
|
2133
|
+
protocolVersion: "2024-11-05",
|
|
2134
|
+
capabilities: { tools: {} },
|
|
2135
|
+
serverInfo: {
|
|
2136
|
+
name: "github-symphony-graphql",
|
|
2137
|
+
version: "0.1.0"
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
process.stdout.write(
|
|
2141
|
+
JSON.stringify({
|
|
2142
|
+
jsonrpc: "2.0",
|
|
2143
|
+
method: "notifications/initialized"
|
|
2144
|
+
}) + "\n"
|
|
2145
|
+
);
|
|
2146
|
+
break;
|
|
2147
|
+
}
|
|
2148
|
+
case "tools/list": {
|
|
2149
|
+
sendResponse(id, { tools: [TOOL_SCHEMA] });
|
|
2150
|
+
break;
|
|
2151
|
+
}
|
|
2152
|
+
case "tools/call": {
|
|
2153
|
+
const params = msg.params;
|
|
2154
|
+
if (params.name !== "github_graphql") {
|
|
2155
|
+
sendError(id, -32602, `Unknown tool: ${params.name}`);
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
const args = params.arguments ?? {};
|
|
2159
|
+
const invocation = {
|
|
2160
|
+
query: args.query,
|
|
2161
|
+
variables: args.variables,
|
|
2162
|
+
operationName: args.operationName
|
|
2163
|
+
};
|
|
2164
|
+
try {
|
|
2165
|
+
const result = await executeGitHubGraphQL(invocation, {
|
|
2166
|
+
token: process.env.GITHUB_GRAPHQL_TOKEN,
|
|
2167
|
+
apiUrl: process.env.GITHUB_GRAPHQL_API_URL,
|
|
2168
|
+
tokenBrokerUrl: process.env.GITHUB_TOKEN_BROKER_URL,
|
|
2169
|
+
tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2170
|
+
tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
|
|
2171
|
+
});
|
|
2172
|
+
sendResponse(id, {
|
|
2173
|
+
content: [
|
|
2174
|
+
{
|
|
2175
|
+
type: "text",
|
|
2176
|
+
text: JSON.stringify(result, null, 2)
|
|
2177
|
+
}
|
|
2178
|
+
]
|
|
2179
|
+
});
|
|
2180
|
+
} catch (err) {
|
|
2181
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2182
|
+
sendResponse(id, {
|
|
2183
|
+
content: [{ type: "text", text: message }],
|
|
2184
|
+
isError: true
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
break;
|
|
2188
|
+
}
|
|
2189
|
+
case "notifications/initialized":
|
|
2190
|
+
case "ping": {
|
|
2191
|
+
if (id !== null && id !== void 0) {
|
|
2192
|
+
sendResponse(id, {});
|
|
2193
|
+
}
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
default: {
|
|
2197
|
+
if (id !== null && id !== void 0) {
|
|
2198
|
+
sendError(id, -32601, `Method not found: ${msg.method}`);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
async function main2() {
|
|
2204
|
+
process.stdin.setEncoding("utf8");
|
|
2205
|
+
process.stdin.on("data", (chunk) => {
|
|
2206
|
+
lineBuffer += chunk;
|
|
2207
|
+
const lines = lineBuffer.split("\n");
|
|
2208
|
+
lineBuffer = lines.pop() ?? "";
|
|
2209
|
+
for (const line of lines) {
|
|
2210
|
+
const trimmed = line.trim();
|
|
2211
|
+
if (!trimmed) continue;
|
|
2212
|
+
try {
|
|
2213
|
+
const msg = JSON.parse(trimmed);
|
|
2214
|
+
void handleRequest(msg);
|
|
2215
|
+
} catch (err) {
|
|
2216
|
+
process.stderr.write(
|
|
2217
|
+
`[github-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
|
|
2218
|
+
`
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
process.stdin.on("end", () => {
|
|
2224
|
+
process.exit(0);
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
2228
|
+
main2().catch((err) => {
|
|
2229
|
+
process.stderr.write(
|
|
2230
|
+
`[github-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
|
|
2231
|
+
`
|
|
2232
|
+
);
|
|
2233
|
+
process.exitCode = 1;
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
// ../tool-github-graphql/src/mcp-entry.ts
|
|
2238
|
+
var DEFAULT_GITHUB_GRAPHQL_API_URL2 = "https://api.github.com/graphql";
|
|
2239
|
+
function createGitHubGraphQLMcpServerEntry(options = {}) {
|
|
2240
|
+
return {
|
|
2241
|
+
command: "node",
|
|
2242
|
+
args: [resolveGitHubGraphQLMcpServerEntryPoint()],
|
|
2243
|
+
env: {
|
|
2244
|
+
GITHUB_GRAPHQL_API_URL: options.githubGraphqlApiUrl ?? DEFAULT_GITHUB_GRAPHQL_API_URL2,
|
|
2245
|
+
...options.githubToken ? {
|
|
2246
|
+
GITHUB_GRAPHQL_TOKEN: options.githubToken
|
|
2247
|
+
} : {},
|
|
2248
|
+
...options.githubTokenBrokerUrl ? {
|
|
2249
|
+
GITHUB_TOKEN_BROKER_URL: options.githubTokenBrokerUrl
|
|
2250
|
+
} : {},
|
|
2251
|
+
...options.githubTokenBrokerSecret ? {
|
|
2252
|
+
GITHUB_TOKEN_BROKER_SECRET: options.githubTokenBrokerSecret
|
|
2253
|
+
} : {},
|
|
2254
|
+
...options.githubTokenCachePath ? {
|
|
2255
|
+
GITHUB_TOKEN_CACHE_PATH: options.githubTokenCachePath
|
|
2256
|
+
} : {},
|
|
2257
|
+
...options.githubProjectId ? {
|
|
2258
|
+
GITHUB_PROJECT_ID: options.githubProjectId
|
|
2259
|
+
} : {}
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/devAssert.mjs
|
|
2265
|
+
function devAssert(condition, message) {
|
|
2266
|
+
const booleanCondition = Boolean(condition);
|
|
2267
|
+
if (!booleanCondition) {
|
|
2268
|
+
throw new Error(message);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/isObjectLike.mjs
|
|
2273
|
+
function isObjectLike(value) {
|
|
2274
|
+
return typeof value == "object" && value !== null;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/invariant.mjs
|
|
2278
|
+
function invariant(condition, message) {
|
|
2279
|
+
const booleanCondition = Boolean(condition);
|
|
2280
|
+
if (!booleanCondition) {
|
|
2281
|
+
throw new Error(
|
|
2282
|
+
message != null ? message : "Unexpected invariant triggered."
|
|
2283
|
+
);
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/location.mjs
|
|
2288
|
+
var LineRegExp = /\r\n|[\n\r]/g;
|
|
2289
|
+
function getLocation(source, position) {
|
|
2290
|
+
let lastLineStart = 0;
|
|
2291
|
+
let line = 1;
|
|
2292
|
+
for (const match of source.body.matchAll(LineRegExp)) {
|
|
2293
|
+
typeof match.index === "number" || invariant(false);
|
|
2294
|
+
if (match.index >= position) {
|
|
2295
|
+
break;
|
|
2296
|
+
}
|
|
2297
|
+
lastLineStart = match.index + match[0].length;
|
|
2298
|
+
line += 1;
|
|
2299
|
+
}
|
|
2300
|
+
return {
|
|
2301
|
+
line,
|
|
2302
|
+
column: position + 1 - lastLineStart
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/printLocation.mjs
|
|
2307
|
+
function printLocation(location) {
|
|
2308
|
+
return printSourceLocation(
|
|
2309
|
+
location.source,
|
|
2310
|
+
getLocation(location.source, location.start)
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
function printSourceLocation(source, sourceLocation) {
|
|
2314
|
+
const firstLineColumnOffset = source.locationOffset.column - 1;
|
|
2315
|
+
const body = "".padStart(firstLineColumnOffset) + source.body;
|
|
2316
|
+
const lineIndex = sourceLocation.line - 1;
|
|
2317
|
+
const lineOffset = source.locationOffset.line - 1;
|
|
2318
|
+
const lineNum = sourceLocation.line + lineOffset;
|
|
2319
|
+
const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
|
|
2320
|
+
const columnNum = sourceLocation.column + columnOffset;
|
|
2321
|
+
const locationStr = `${source.name}:${lineNum}:${columnNum}
|
|
2322
|
+
`;
|
|
2323
|
+
const lines = body.split(/\r\n|[\n\r]/g);
|
|
2324
|
+
const locationLine = lines[lineIndex];
|
|
2325
|
+
if (locationLine.length > 120) {
|
|
2326
|
+
const subLineIndex = Math.floor(columnNum / 80);
|
|
2327
|
+
const subLineColumnNum = columnNum % 80;
|
|
2328
|
+
const subLines = [];
|
|
2329
|
+
for (let i = 0; i < locationLine.length; i += 80) {
|
|
2330
|
+
subLines.push(locationLine.slice(i, i + 80));
|
|
2331
|
+
}
|
|
2332
|
+
return locationStr + printPrefixedLines([
|
|
2333
|
+
[`${lineNum} |`, subLines[0]],
|
|
2334
|
+
...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
|
|
2335
|
+
["|", "^".padStart(subLineColumnNum)],
|
|
2336
|
+
["|", subLines[subLineIndex + 1]]
|
|
2337
|
+
]);
|
|
2338
|
+
}
|
|
2339
|
+
return locationStr + printPrefixedLines([
|
|
2340
|
+
// Lines specified like this: ["prefix", "string"],
|
|
2341
|
+
[`${lineNum - 1} |`, lines[lineIndex - 1]],
|
|
2342
|
+
[`${lineNum} |`, locationLine],
|
|
2343
|
+
["|", "^".padStart(columnNum)],
|
|
2344
|
+
[`${lineNum + 1} |`, lines[lineIndex + 1]]
|
|
2345
|
+
]);
|
|
2346
|
+
}
|
|
2347
|
+
function printPrefixedLines(lines) {
|
|
2348
|
+
const existingLines = lines.filter(([_, line]) => line !== void 0);
|
|
2349
|
+
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
2350
|
+
return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/error/GraphQLError.mjs
|
|
2354
|
+
function toNormalizedOptions(args) {
|
|
2355
|
+
const firstArg = args[0];
|
|
2356
|
+
if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
|
|
2357
|
+
return {
|
|
2358
|
+
nodes: firstArg,
|
|
2359
|
+
source: args[1],
|
|
2360
|
+
positions: args[2],
|
|
2361
|
+
path: args[3],
|
|
2362
|
+
originalError: args[4],
|
|
2363
|
+
extensions: args[5]
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2366
|
+
return firstArg;
|
|
2367
|
+
}
|
|
2368
|
+
var GraphQLError = class _GraphQLError extends Error {
|
|
2369
|
+
/**
|
|
2370
|
+
* An array of `{ line, column }` locations within the source GraphQL document
|
|
2371
|
+
* which correspond to this error.
|
|
2372
|
+
*
|
|
2373
|
+
* Errors during validation often contain multiple locations, for example to
|
|
2374
|
+
* point out two things with the same name. Errors during execution include a
|
|
2375
|
+
* single location, the field which produced the error.
|
|
2376
|
+
*
|
|
2377
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
2378
|
+
*/
|
|
2379
|
+
/**
|
|
2380
|
+
* An array describing the JSON-path into the execution response which
|
|
2381
|
+
* corresponds to this error. Only included for errors during execution.
|
|
2382
|
+
*
|
|
2383
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
2384
|
+
*/
|
|
2385
|
+
/**
|
|
2386
|
+
* An array of GraphQL AST Nodes corresponding to this error.
|
|
2387
|
+
*/
|
|
2388
|
+
/**
|
|
2389
|
+
* The source GraphQL document for the first location of this error.
|
|
2390
|
+
*
|
|
2391
|
+
* Note that if this Error represents more than one node, the source may not
|
|
2392
|
+
* represent nodes after the first node.
|
|
2393
|
+
*/
|
|
2394
|
+
/**
|
|
2395
|
+
* An array of character offsets within the source GraphQL document
|
|
2396
|
+
* which correspond to this error.
|
|
2397
|
+
*/
|
|
2398
|
+
/**
|
|
2399
|
+
* The original error thrown from a field resolver during execution.
|
|
2400
|
+
*/
|
|
2401
|
+
/**
|
|
2402
|
+
* Extension fields to add to the formatted error.
|
|
2403
|
+
*/
|
|
2404
|
+
/**
|
|
2405
|
+
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
2406
|
+
*/
|
|
2407
|
+
constructor(message, ...rawArgs) {
|
|
2408
|
+
var _this$nodes, _nodeLocations$, _ref;
|
|
2409
|
+
const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
2410
|
+
super(message);
|
|
2411
|
+
this.name = "GraphQLError";
|
|
2412
|
+
this.path = path !== null && path !== void 0 ? path : void 0;
|
|
2413
|
+
this.originalError = originalError !== null && originalError !== void 0 ? originalError : void 0;
|
|
2414
|
+
this.nodes = undefinedIfEmpty(
|
|
2415
|
+
Array.isArray(nodes) ? nodes : nodes ? [nodes] : void 0
|
|
2416
|
+
);
|
|
2417
|
+
const nodeLocations = undefinedIfEmpty(
|
|
2418
|
+
(_this$nodes = this.nodes) === null || _this$nodes === void 0 ? void 0 : _this$nodes.map((node) => node.loc).filter((loc) => loc != null)
|
|
2419
|
+
);
|
|
2420
|
+
this.source = source !== null && source !== void 0 ? source : nodeLocations === null || nodeLocations === void 0 ? void 0 : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === void 0 ? void 0 : _nodeLocations$.source;
|
|
2421
|
+
this.positions = positions !== null && positions !== void 0 ? positions : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => loc.start);
|
|
2422
|
+
this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === void 0 ? void 0 : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
|
|
2423
|
+
const originalExtensions = isObjectLike(
|
|
2424
|
+
originalError === null || originalError === void 0 ? void 0 : originalError.extensions
|
|
2425
|
+
) ? originalError === null || originalError === void 0 ? void 0 : originalError.extensions : void 0;
|
|
2426
|
+
this.extensions = (_ref = extensions !== null && extensions !== void 0 ? extensions : originalExtensions) !== null && _ref !== void 0 ? _ref : /* @__PURE__ */ Object.create(null);
|
|
2427
|
+
Object.defineProperties(this, {
|
|
2428
|
+
message: {
|
|
2429
|
+
writable: true,
|
|
2430
|
+
enumerable: true
|
|
2431
|
+
},
|
|
2432
|
+
name: {
|
|
2433
|
+
enumerable: false
|
|
2434
|
+
},
|
|
2435
|
+
nodes: {
|
|
2436
|
+
enumerable: false
|
|
2437
|
+
},
|
|
2438
|
+
source: {
|
|
2439
|
+
enumerable: false
|
|
2440
|
+
},
|
|
2441
|
+
positions: {
|
|
2442
|
+
enumerable: false
|
|
2443
|
+
},
|
|
2444
|
+
originalError: {
|
|
2445
|
+
enumerable: false
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
if (originalError !== null && originalError !== void 0 && originalError.stack) {
|
|
2449
|
+
Object.defineProperty(this, "stack", {
|
|
2450
|
+
value: originalError.stack,
|
|
2451
|
+
writable: true,
|
|
2452
|
+
configurable: true
|
|
2453
|
+
});
|
|
2454
|
+
} else if (Error.captureStackTrace) {
|
|
2455
|
+
Error.captureStackTrace(this, _GraphQLError);
|
|
2456
|
+
} else {
|
|
2457
|
+
Object.defineProperty(this, "stack", {
|
|
2458
|
+
value: Error().stack,
|
|
2459
|
+
writable: true,
|
|
2460
|
+
configurable: true
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
get [Symbol.toStringTag]() {
|
|
2465
|
+
return "GraphQLError";
|
|
2466
|
+
}
|
|
2467
|
+
toString() {
|
|
2468
|
+
let output = this.message;
|
|
2469
|
+
if (this.nodes) {
|
|
2470
|
+
for (const node of this.nodes) {
|
|
2471
|
+
if (node.loc) {
|
|
2472
|
+
output += "\n\n" + printLocation(node.loc);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
} else if (this.source && this.locations) {
|
|
2476
|
+
for (const location of this.locations) {
|
|
2477
|
+
output += "\n\n" + printSourceLocation(this.source, location);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
return output;
|
|
2481
|
+
}
|
|
2482
|
+
toJSON() {
|
|
2483
|
+
const formattedError = {
|
|
2484
|
+
message: this.message
|
|
2485
|
+
};
|
|
2486
|
+
if (this.locations != null) {
|
|
2487
|
+
formattedError.locations = this.locations;
|
|
2488
|
+
}
|
|
2489
|
+
if (this.path != null) {
|
|
2490
|
+
formattedError.path = this.path;
|
|
2491
|
+
}
|
|
2492
|
+
if (this.extensions != null && Object.keys(this.extensions).length > 0) {
|
|
2493
|
+
formattedError.extensions = this.extensions;
|
|
2494
|
+
}
|
|
2495
|
+
return formattedError;
|
|
2496
|
+
}
|
|
2497
|
+
};
|
|
2498
|
+
function undefinedIfEmpty(array) {
|
|
2499
|
+
return array === void 0 || array.length === 0 ? void 0 : array;
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/error/syntaxError.mjs
|
|
2503
|
+
function syntaxError(source, position, description) {
|
|
2504
|
+
return new GraphQLError(`Syntax Error: ${description}`, {
|
|
2505
|
+
source,
|
|
2506
|
+
positions: [position]
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/ast.mjs
|
|
2511
|
+
var Location = class {
|
|
2512
|
+
/**
|
|
2513
|
+
* The character offset at which this Node begins.
|
|
2514
|
+
*/
|
|
2515
|
+
/**
|
|
2516
|
+
* The character offset at which this Node ends.
|
|
2517
|
+
*/
|
|
2518
|
+
/**
|
|
2519
|
+
* The Token at which this Node begins.
|
|
2520
|
+
*/
|
|
2521
|
+
/**
|
|
2522
|
+
* The Token at which this Node ends.
|
|
2523
|
+
*/
|
|
2524
|
+
/**
|
|
2525
|
+
* The Source document the AST represents.
|
|
2526
|
+
*/
|
|
2527
|
+
constructor(startToken, endToken, source) {
|
|
2528
|
+
this.start = startToken.start;
|
|
2529
|
+
this.end = endToken.end;
|
|
2530
|
+
this.startToken = startToken;
|
|
2531
|
+
this.endToken = endToken;
|
|
2532
|
+
this.source = source;
|
|
2533
|
+
}
|
|
2534
|
+
get [Symbol.toStringTag]() {
|
|
2535
|
+
return "Location";
|
|
2536
|
+
}
|
|
2537
|
+
toJSON() {
|
|
2538
|
+
return {
|
|
2539
|
+
start: this.start,
|
|
2540
|
+
end: this.end
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
var Token = class {
|
|
2545
|
+
/**
|
|
2546
|
+
* The kind of Token.
|
|
2547
|
+
*/
|
|
2548
|
+
/**
|
|
2549
|
+
* The character offset at which this Node begins.
|
|
2550
|
+
*/
|
|
2551
|
+
/**
|
|
2552
|
+
* The character offset at which this Node ends.
|
|
2553
|
+
*/
|
|
2554
|
+
/**
|
|
2555
|
+
* The 1-indexed line number on which this Token appears.
|
|
2556
|
+
*/
|
|
2557
|
+
/**
|
|
2558
|
+
* The 1-indexed column number at which this Token begins.
|
|
2559
|
+
*/
|
|
2560
|
+
/**
|
|
2561
|
+
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
2562
|
+
*
|
|
2563
|
+
* Note: is undefined for punctuation tokens, but typed as string for
|
|
2564
|
+
* convenience in the parser.
|
|
2565
|
+
*/
|
|
2566
|
+
/**
|
|
2567
|
+
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
2568
|
+
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
2569
|
+
* the last.
|
|
2570
|
+
*/
|
|
2571
|
+
constructor(kind, start, end, line, column, value) {
|
|
2572
|
+
this.kind = kind;
|
|
2573
|
+
this.start = start;
|
|
2574
|
+
this.end = end;
|
|
2575
|
+
this.line = line;
|
|
2576
|
+
this.column = column;
|
|
2577
|
+
this.value = value;
|
|
2578
|
+
this.prev = null;
|
|
2579
|
+
this.next = null;
|
|
2580
|
+
}
|
|
2581
|
+
get [Symbol.toStringTag]() {
|
|
2582
|
+
return "Token";
|
|
2583
|
+
}
|
|
2584
|
+
toJSON() {
|
|
2585
|
+
return {
|
|
2586
|
+
kind: this.kind,
|
|
2587
|
+
value: this.value,
|
|
2588
|
+
line: this.line,
|
|
2589
|
+
column: this.column
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
};
|
|
2593
|
+
var QueryDocumentKeys = {
|
|
2594
|
+
Name: [],
|
|
2595
|
+
Document: ["definitions"],
|
|
2596
|
+
OperationDefinition: [
|
|
2597
|
+
"description",
|
|
2598
|
+
"name",
|
|
2599
|
+
"variableDefinitions",
|
|
2600
|
+
"directives",
|
|
2601
|
+
"selectionSet"
|
|
2602
|
+
],
|
|
2603
|
+
VariableDefinition: [
|
|
2604
|
+
"description",
|
|
2605
|
+
"variable",
|
|
2606
|
+
"type",
|
|
2607
|
+
"defaultValue",
|
|
2608
|
+
"directives"
|
|
2609
|
+
],
|
|
2610
|
+
Variable: ["name"],
|
|
2611
|
+
SelectionSet: ["selections"],
|
|
2612
|
+
Field: ["alias", "name", "arguments", "directives", "selectionSet"],
|
|
2613
|
+
Argument: ["name", "value"],
|
|
2614
|
+
FragmentSpread: ["name", "directives"],
|
|
2615
|
+
InlineFragment: ["typeCondition", "directives", "selectionSet"],
|
|
2616
|
+
FragmentDefinition: [
|
|
2617
|
+
"description",
|
|
2618
|
+
"name",
|
|
2619
|
+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
|
|
2620
|
+
"variableDefinitions",
|
|
2621
|
+
"typeCondition",
|
|
2622
|
+
"directives",
|
|
2623
|
+
"selectionSet"
|
|
2624
|
+
],
|
|
2625
|
+
IntValue: [],
|
|
2626
|
+
FloatValue: [],
|
|
2627
|
+
StringValue: [],
|
|
2628
|
+
BooleanValue: [],
|
|
2629
|
+
NullValue: [],
|
|
2630
|
+
EnumValue: [],
|
|
2631
|
+
ListValue: ["values"],
|
|
2632
|
+
ObjectValue: ["fields"],
|
|
2633
|
+
ObjectField: ["name", "value"],
|
|
2634
|
+
Directive: ["name", "arguments"],
|
|
2635
|
+
NamedType: ["name"],
|
|
2636
|
+
ListType: ["type"],
|
|
2637
|
+
NonNullType: ["type"],
|
|
2638
|
+
SchemaDefinition: ["description", "directives", "operationTypes"],
|
|
2639
|
+
OperationTypeDefinition: ["type"],
|
|
2640
|
+
ScalarTypeDefinition: ["description", "name", "directives"],
|
|
2641
|
+
ObjectTypeDefinition: [
|
|
2642
|
+
"description",
|
|
2643
|
+
"name",
|
|
2644
|
+
"interfaces",
|
|
2645
|
+
"directives",
|
|
2646
|
+
"fields"
|
|
2647
|
+
],
|
|
2648
|
+
FieldDefinition: ["description", "name", "arguments", "type", "directives"],
|
|
2649
|
+
InputValueDefinition: [
|
|
2650
|
+
"description",
|
|
2651
|
+
"name",
|
|
2652
|
+
"type",
|
|
2653
|
+
"defaultValue",
|
|
2654
|
+
"directives"
|
|
2655
|
+
],
|
|
2656
|
+
InterfaceTypeDefinition: [
|
|
2657
|
+
"description",
|
|
2658
|
+
"name",
|
|
2659
|
+
"interfaces",
|
|
2660
|
+
"directives",
|
|
2661
|
+
"fields"
|
|
2662
|
+
],
|
|
2663
|
+
UnionTypeDefinition: ["description", "name", "directives", "types"],
|
|
2664
|
+
EnumTypeDefinition: ["description", "name", "directives", "values"],
|
|
2665
|
+
EnumValueDefinition: ["description", "name", "directives"],
|
|
2666
|
+
InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
|
|
2667
|
+
DirectiveDefinition: [
|
|
2668
|
+
"description",
|
|
2669
|
+
"name",
|
|
2670
|
+
"arguments",
|
|
2671
|
+
"directives",
|
|
2672
|
+
"locations"
|
|
2673
|
+
],
|
|
2674
|
+
SchemaExtension: ["directives", "operationTypes"],
|
|
2675
|
+
DirectiveExtension: ["name", "directives"],
|
|
2676
|
+
ScalarTypeExtension: ["name", "directives"],
|
|
2677
|
+
ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
|
|
2678
|
+
InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
|
|
2679
|
+
UnionTypeExtension: ["name", "directives", "types"],
|
|
2680
|
+
EnumTypeExtension: ["name", "directives", "values"],
|
|
2681
|
+
InputObjectTypeExtension: ["name", "directives", "fields"],
|
|
2682
|
+
TypeCoordinate: ["name"],
|
|
2683
|
+
MemberCoordinate: ["name", "memberName"],
|
|
2684
|
+
ArgumentCoordinate: ["name", "fieldName", "argumentName"],
|
|
2685
|
+
DirectiveCoordinate: ["name"],
|
|
2686
|
+
DirectiveArgumentCoordinate: ["name", "argumentName"]
|
|
2687
|
+
};
|
|
2688
|
+
var kindValues = new Set(Object.keys(QueryDocumentKeys));
|
|
2689
|
+
var OperationTypeNode;
|
|
2690
|
+
(function(OperationTypeNode2) {
|
|
2691
|
+
OperationTypeNode2["QUERY"] = "query";
|
|
2692
|
+
OperationTypeNode2["MUTATION"] = "mutation";
|
|
2693
|
+
OperationTypeNode2["SUBSCRIPTION"] = "subscription";
|
|
2694
|
+
})(OperationTypeNode || (OperationTypeNode = {}));
|
|
2695
|
+
|
|
2696
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/directiveLocation.mjs
|
|
2697
|
+
var DirectiveLocation;
|
|
2698
|
+
(function(DirectiveLocation2) {
|
|
2699
|
+
DirectiveLocation2["QUERY"] = "QUERY";
|
|
2700
|
+
DirectiveLocation2["MUTATION"] = "MUTATION";
|
|
2701
|
+
DirectiveLocation2["SUBSCRIPTION"] = "SUBSCRIPTION";
|
|
2702
|
+
DirectiveLocation2["FIELD"] = "FIELD";
|
|
2703
|
+
DirectiveLocation2["FRAGMENT_DEFINITION"] = "FRAGMENT_DEFINITION";
|
|
2704
|
+
DirectiveLocation2["FRAGMENT_SPREAD"] = "FRAGMENT_SPREAD";
|
|
2705
|
+
DirectiveLocation2["INLINE_FRAGMENT"] = "INLINE_FRAGMENT";
|
|
2706
|
+
DirectiveLocation2["VARIABLE_DEFINITION"] = "VARIABLE_DEFINITION";
|
|
2707
|
+
DirectiveLocation2["SCHEMA"] = "SCHEMA";
|
|
2708
|
+
DirectiveLocation2["SCALAR"] = "SCALAR";
|
|
2709
|
+
DirectiveLocation2["OBJECT"] = "OBJECT";
|
|
2710
|
+
DirectiveLocation2["FIELD_DEFINITION"] = "FIELD_DEFINITION";
|
|
2711
|
+
DirectiveLocation2["ARGUMENT_DEFINITION"] = "ARGUMENT_DEFINITION";
|
|
2712
|
+
DirectiveLocation2["INTERFACE"] = "INTERFACE";
|
|
2713
|
+
DirectiveLocation2["UNION"] = "UNION";
|
|
2714
|
+
DirectiveLocation2["ENUM"] = "ENUM";
|
|
2715
|
+
DirectiveLocation2["ENUM_VALUE"] = "ENUM_VALUE";
|
|
2716
|
+
DirectiveLocation2["INPUT_OBJECT"] = "INPUT_OBJECT";
|
|
2717
|
+
DirectiveLocation2["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
|
|
2718
|
+
DirectiveLocation2["DIRECTIVE_DEFINITION"] = "DIRECTIVE_DEFINITION";
|
|
2719
|
+
})(DirectiveLocation || (DirectiveLocation = {}));
|
|
2720
|
+
|
|
2721
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/kinds.mjs
|
|
2722
|
+
var Kind;
|
|
2723
|
+
(function(Kind2) {
|
|
2724
|
+
Kind2["NAME"] = "Name";
|
|
2725
|
+
Kind2["DOCUMENT"] = "Document";
|
|
2726
|
+
Kind2["OPERATION_DEFINITION"] = "OperationDefinition";
|
|
2727
|
+
Kind2["VARIABLE_DEFINITION"] = "VariableDefinition";
|
|
2728
|
+
Kind2["SELECTION_SET"] = "SelectionSet";
|
|
2729
|
+
Kind2["FIELD"] = "Field";
|
|
2730
|
+
Kind2["ARGUMENT"] = "Argument";
|
|
2731
|
+
Kind2["FRAGMENT_SPREAD"] = "FragmentSpread";
|
|
2732
|
+
Kind2["INLINE_FRAGMENT"] = "InlineFragment";
|
|
2733
|
+
Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition";
|
|
2734
|
+
Kind2["VARIABLE"] = "Variable";
|
|
2735
|
+
Kind2["INT"] = "IntValue";
|
|
2736
|
+
Kind2["FLOAT"] = "FloatValue";
|
|
2737
|
+
Kind2["STRING"] = "StringValue";
|
|
2738
|
+
Kind2["BOOLEAN"] = "BooleanValue";
|
|
2739
|
+
Kind2["NULL"] = "NullValue";
|
|
2740
|
+
Kind2["ENUM"] = "EnumValue";
|
|
2741
|
+
Kind2["LIST"] = "ListValue";
|
|
2742
|
+
Kind2["OBJECT"] = "ObjectValue";
|
|
2743
|
+
Kind2["OBJECT_FIELD"] = "ObjectField";
|
|
2744
|
+
Kind2["DIRECTIVE"] = "Directive";
|
|
2745
|
+
Kind2["NAMED_TYPE"] = "NamedType";
|
|
2746
|
+
Kind2["LIST_TYPE"] = "ListType";
|
|
2747
|
+
Kind2["NON_NULL_TYPE"] = "NonNullType";
|
|
2748
|
+
Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition";
|
|
2749
|
+
Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
|
|
2750
|
+
Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
|
|
2751
|
+
Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
|
|
2752
|
+
Kind2["FIELD_DEFINITION"] = "FieldDefinition";
|
|
2753
|
+
Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
|
|
2754
|
+
Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
|
|
2755
|
+
Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
|
|
2756
|
+
Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
|
|
2757
|
+
Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
|
|
2758
|
+
Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
|
|
2759
|
+
Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
|
|
2760
|
+
Kind2["SCHEMA_EXTENSION"] = "SchemaExtension";
|
|
2761
|
+
Kind2["DIRECTIVE_EXTENSION"] = "DirectiveExtension";
|
|
2762
|
+
Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
|
|
2763
|
+
Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
|
|
2764
|
+
Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
|
|
2765
|
+
Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
|
|
2766
|
+
Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
|
|
2767
|
+
Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
|
|
2768
|
+
Kind2["TYPE_COORDINATE"] = "TypeCoordinate";
|
|
2769
|
+
Kind2["MEMBER_COORDINATE"] = "MemberCoordinate";
|
|
2770
|
+
Kind2["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
|
|
2771
|
+
Kind2["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
|
|
2772
|
+
Kind2["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
|
|
2773
|
+
})(Kind || (Kind = {}));
|
|
2774
|
+
|
|
2775
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/characterClasses.mjs
|
|
2776
|
+
function isWhiteSpace(code) {
|
|
2777
|
+
return code === 9 || code === 32;
|
|
2778
|
+
}
|
|
2779
|
+
function isDigit(code) {
|
|
2780
|
+
return code >= 48 && code <= 57;
|
|
2781
|
+
}
|
|
2782
|
+
function isLetter(code) {
|
|
2783
|
+
return code >= 97 && code <= 122 || // A-Z
|
|
2784
|
+
code >= 65 && code <= 90;
|
|
2785
|
+
}
|
|
2786
|
+
function isNameStart(code) {
|
|
2787
|
+
return isLetter(code) || code === 95;
|
|
2788
|
+
}
|
|
2789
|
+
function isNameContinue(code) {
|
|
2790
|
+
return isLetter(code) || isDigit(code) || code === 95;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/blockString.mjs
|
|
2794
|
+
function dedentBlockStringLines(lines) {
|
|
2795
|
+
var _firstNonEmptyLine2;
|
|
2796
|
+
let commonIndent = Number.MAX_SAFE_INTEGER;
|
|
2797
|
+
let firstNonEmptyLine = null;
|
|
2798
|
+
let lastNonEmptyLine = -1;
|
|
2799
|
+
for (let i = 0; i < lines.length; ++i) {
|
|
2800
|
+
var _firstNonEmptyLine;
|
|
2801
|
+
const line = lines[i];
|
|
2802
|
+
const indent = leadingWhitespace(line);
|
|
2803
|
+
if (indent === line.length) {
|
|
2804
|
+
continue;
|
|
2805
|
+
}
|
|
2806
|
+
firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i;
|
|
2807
|
+
lastNonEmptyLine = i;
|
|
2808
|
+
if (i !== 0 && indent < commonIndent) {
|
|
2809
|
+
commonIndent = indent;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
return lines.map((line, i) => i === 0 ? line : line.slice(commonIndent)).slice(
|
|
2813
|
+
(_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0,
|
|
2814
|
+
lastNonEmptyLine + 1
|
|
2815
|
+
);
|
|
2816
|
+
}
|
|
2817
|
+
function leadingWhitespace(str) {
|
|
2818
|
+
let i = 0;
|
|
2819
|
+
while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
|
|
2820
|
+
++i;
|
|
2821
|
+
}
|
|
2822
|
+
return i;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/tokenKind.mjs
|
|
2826
|
+
var TokenKind;
|
|
2827
|
+
(function(TokenKind2) {
|
|
2828
|
+
TokenKind2["SOF"] = "<SOF>";
|
|
2829
|
+
TokenKind2["EOF"] = "<EOF>";
|
|
2830
|
+
TokenKind2["BANG"] = "!";
|
|
2831
|
+
TokenKind2["DOLLAR"] = "$";
|
|
2832
|
+
TokenKind2["AMP"] = "&";
|
|
2833
|
+
TokenKind2["PAREN_L"] = "(";
|
|
2834
|
+
TokenKind2["PAREN_R"] = ")";
|
|
2835
|
+
TokenKind2["DOT"] = ".";
|
|
2836
|
+
TokenKind2["SPREAD"] = "...";
|
|
2837
|
+
TokenKind2["COLON"] = ":";
|
|
2838
|
+
TokenKind2["EQUALS"] = "=";
|
|
2839
|
+
TokenKind2["AT"] = "@";
|
|
2840
|
+
TokenKind2["BRACKET_L"] = "[";
|
|
2841
|
+
TokenKind2["BRACKET_R"] = "]";
|
|
2842
|
+
TokenKind2["BRACE_L"] = "{";
|
|
2843
|
+
TokenKind2["PIPE"] = "|";
|
|
2844
|
+
TokenKind2["BRACE_R"] = "}";
|
|
2845
|
+
TokenKind2["NAME"] = "Name";
|
|
2846
|
+
TokenKind2["INT"] = "Int";
|
|
2847
|
+
TokenKind2["FLOAT"] = "Float";
|
|
2848
|
+
TokenKind2["STRING"] = "String";
|
|
2849
|
+
TokenKind2["BLOCK_STRING"] = "BlockString";
|
|
2850
|
+
TokenKind2["COMMENT"] = "Comment";
|
|
2851
|
+
})(TokenKind || (TokenKind = {}));
|
|
2852
|
+
|
|
2853
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/lexer.mjs
|
|
2854
|
+
var Lexer = class {
|
|
2855
|
+
/**
|
|
2856
|
+
* The previously focused non-ignored token.
|
|
2857
|
+
*/
|
|
2858
|
+
/**
|
|
2859
|
+
* The currently focused non-ignored token.
|
|
2860
|
+
*/
|
|
2861
|
+
/**
|
|
2862
|
+
* The (1-indexed) line containing the current token.
|
|
2863
|
+
*/
|
|
2864
|
+
/**
|
|
2865
|
+
* The character offset at which the current line begins.
|
|
2866
|
+
*/
|
|
2867
|
+
constructor(source) {
|
|
2868
|
+
const startOfFileToken = new Token(TokenKind.SOF, 0, 0, 0, 0);
|
|
2869
|
+
this.source = source;
|
|
2870
|
+
this.lastToken = startOfFileToken;
|
|
2871
|
+
this.token = startOfFileToken;
|
|
2872
|
+
this.line = 1;
|
|
2873
|
+
this.lineStart = 0;
|
|
2874
|
+
}
|
|
2875
|
+
get [Symbol.toStringTag]() {
|
|
2876
|
+
return "Lexer";
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Advances the token stream to the next non-ignored token.
|
|
2880
|
+
*/
|
|
2881
|
+
advance() {
|
|
2882
|
+
this.lastToken = this.token;
|
|
2883
|
+
const token = this.token = this.lookahead();
|
|
2884
|
+
return token;
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* Looks ahead and returns the next non-ignored token, but does not change
|
|
2888
|
+
* the state of Lexer.
|
|
2889
|
+
*/
|
|
2890
|
+
lookahead() {
|
|
2891
|
+
let token = this.token;
|
|
2892
|
+
if (token.kind !== TokenKind.EOF) {
|
|
2893
|
+
do {
|
|
2894
|
+
if (token.next) {
|
|
2895
|
+
token = token.next;
|
|
2896
|
+
} else {
|
|
2897
|
+
const nextToken = readNextToken(this, token.end);
|
|
2898
|
+
token.next = nextToken;
|
|
2899
|
+
nextToken.prev = token;
|
|
2900
|
+
token = nextToken;
|
|
2901
|
+
}
|
|
2902
|
+
} while (token.kind === TokenKind.COMMENT);
|
|
2903
|
+
}
|
|
2904
|
+
return token;
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
function isPunctuatorTokenKind(kind) {
|
|
2908
|
+
return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.DOT || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
|
|
2909
|
+
}
|
|
2910
|
+
function isUnicodeScalarValue(code) {
|
|
2911
|
+
return code >= 0 && code <= 55295 || code >= 57344 && code <= 1114111;
|
|
2912
|
+
}
|
|
2913
|
+
function isSupplementaryCodePoint(body, location) {
|
|
2914
|
+
return isLeadingSurrogate(body.charCodeAt(location)) && isTrailingSurrogate(body.charCodeAt(location + 1));
|
|
2915
|
+
}
|
|
2916
|
+
function isLeadingSurrogate(code) {
|
|
2917
|
+
return code >= 55296 && code <= 56319;
|
|
2918
|
+
}
|
|
2919
|
+
function isTrailingSurrogate(code) {
|
|
2920
|
+
return code >= 56320 && code <= 57343;
|
|
2921
|
+
}
|
|
2922
|
+
function printCodePointAt(lexer, location) {
|
|
2923
|
+
const code = lexer.source.body.codePointAt(location);
|
|
2924
|
+
if (code === void 0) {
|
|
2925
|
+
return TokenKind.EOF;
|
|
2926
|
+
} else if (code >= 32 && code <= 126) {
|
|
2927
|
+
const char = String.fromCodePoint(code);
|
|
2928
|
+
return char === '"' ? `'"'` : `"${char}"`;
|
|
2929
|
+
}
|
|
2930
|
+
return "U+" + code.toString(16).toUpperCase().padStart(4, "0");
|
|
2931
|
+
}
|
|
2932
|
+
function createToken(lexer, kind, start, end, value) {
|
|
2933
|
+
const line = lexer.line;
|
|
2934
|
+
const col = 1 + start - lexer.lineStart;
|
|
2935
|
+
return new Token(kind, start, end, line, col, value);
|
|
2936
|
+
}
|
|
2937
|
+
function readNextToken(lexer, start) {
|
|
2938
|
+
const body = lexer.source.body;
|
|
2939
|
+
const bodyLength = body.length;
|
|
2940
|
+
let position = start;
|
|
2941
|
+
while (position < bodyLength) {
|
|
2942
|
+
const code = body.charCodeAt(position);
|
|
2943
|
+
switch (code) {
|
|
2944
|
+
// Ignored ::
|
|
2945
|
+
// - UnicodeBOM
|
|
2946
|
+
// - WhiteSpace
|
|
2947
|
+
// - LineTerminator
|
|
2948
|
+
// - Comment
|
|
2949
|
+
// - Comma
|
|
2950
|
+
//
|
|
2951
|
+
// UnicodeBOM :: "Byte Order Mark (U+FEFF)"
|
|
2952
|
+
//
|
|
2953
|
+
// WhiteSpace ::
|
|
2954
|
+
// - "Horizontal Tab (U+0009)"
|
|
2955
|
+
// - "Space (U+0020)"
|
|
2956
|
+
//
|
|
2957
|
+
// Comma :: ,
|
|
2958
|
+
case 65279:
|
|
2959
|
+
// <BOM>
|
|
2960
|
+
case 9:
|
|
2961
|
+
// \t
|
|
2962
|
+
case 32:
|
|
2963
|
+
// <space>
|
|
2964
|
+
case 44:
|
|
2965
|
+
++position;
|
|
2966
|
+
continue;
|
|
2967
|
+
// LineTerminator ::
|
|
2968
|
+
// - "New Line (U+000A)"
|
|
2969
|
+
// - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
|
|
2970
|
+
// - "Carriage Return (U+000D)" "New Line (U+000A)"
|
|
2971
|
+
case 10:
|
|
2972
|
+
++position;
|
|
2973
|
+
++lexer.line;
|
|
2974
|
+
lexer.lineStart = position;
|
|
2975
|
+
continue;
|
|
2976
|
+
case 13:
|
|
2977
|
+
if (body.charCodeAt(position + 1) === 10) {
|
|
2978
|
+
position += 2;
|
|
2979
|
+
} else {
|
|
2980
|
+
++position;
|
|
2981
|
+
}
|
|
2982
|
+
++lexer.line;
|
|
2983
|
+
lexer.lineStart = position;
|
|
2984
|
+
continue;
|
|
2985
|
+
// Comment
|
|
2986
|
+
case 35:
|
|
2987
|
+
return readComment(lexer, position);
|
|
2988
|
+
// Token ::
|
|
2989
|
+
// - Punctuator
|
|
2990
|
+
// - Name
|
|
2991
|
+
// - IntValue
|
|
2992
|
+
// - FloatValue
|
|
2993
|
+
// - StringValue
|
|
2994
|
+
//
|
|
2995
|
+
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
|
|
2996
|
+
case 33:
|
|
2997
|
+
return createToken(lexer, TokenKind.BANG, position, position + 1);
|
|
2998
|
+
case 36:
|
|
2999
|
+
return createToken(lexer, TokenKind.DOLLAR, position, position + 1);
|
|
3000
|
+
case 38:
|
|
3001
|
+
return createToken(lexer, TokenKind.AMP, position, position + 1);
|
|
3002
|
+
case 40:
|
|
3003
|
+
return createToken(lexer, TokenKind.PAREN_L, position, position + 1);
|
|
3004
|
+
case 41:
|
|
3005
|
+
return createToken(lexer, TokenKind.PAREN_R, position, position + 1);
|
|
3006
|
+
case 46:
|
|
3007
|
+
if (body.charCodeAt(position + 1) === 46 && body.charCodeAt(position + 2) === 46) {
|
|
3008
|
+
return createToken(lexer, TokenKind.SPREAD, position, position + 3);
|
|
3009
|
+
}
|
|
3010
|
+
break;
|
|
3011
|
+
case 58:
|
|
3012
|
+
return createToken(lexer, TokenKind.COLON, position, position + 1);
|
|
3013
|
+
case 61:
|
|
3014
|
+
return createToken(lexer, TokenKind.EQUALS, position, position + 1);
|
|
3015
|
+
case 64:
|
|
3016
|
+
return createToken(lexer, TokenKind.AT, position, position + 1);
|
|
3017
|
+
case 91:
|
|
3018
|
+
return createToken(lexer, TokenKind.BRACKET_L, position, position + 1);
|
|
3019
|
+
case 93:
|
|
3020
|
+
return createToken(lexer, TokenKind.BRACKET_R, position, position + 1);
|
|
3021
|
+
case 123:
|
|
3022
|
+
return createToken(lexer, TokenKind.BRACE_L, position, position + 1);
|
|
3023
|
+
case 124:
|
|
3024
|
+
return createToken(lexer, TokenKind.PIPE, position, position + 1);
|
|
3025
|
+
case 125:
|
|
3026
|
+
return createToken(lexer, TokenKind.BRACE_R, position, position + 1);
|
|
3027
|
+
// StringValue
|
|
3028
|
+
case 34:
|
|
3029
|
+
if (body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
|
|
3030
|
+
return readBlockString(lexer, position);
|
|
3031
|
+
}
|
|
3032
|
+
return readString(lexer, position);
|
|
3033
|
+
}
|
|
3034
|
+
if (isDigit(code) || code === 45) {
|
|
3035
|
+
return readNumber(lexer, position, code);
|
|
3036
|
+
}
|
|
3037
|
+
if (isNameStart(code)) {
|
|
3038
|
+
return readName(lexer, position);
|
|
3039
|
+
}
|
|
3040
|
+
throw syntaxError(
|
|
3041
|
+
lexer.source,
|
|
3042
|
+
position,
|
|
3043
|
+
code === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) ? `Unexpected character: ${printCodePointAt(lexer, position)}.` : `Invalid character: ${printCodePointAt(lexer, position)}.`
|
|
3044
|
+
);
|
|
3045
|
+
}
|
|
3046
|
+
return createToken(lexer, TokenKind.EOF, bodyLength, bodyLength);
|
|
3047
|
+
}
|
|
3048
|
+
function readComment(lexer, start) {
|
|
3049
|
+
const body = lexer.source.body;
|
|
3050
|
+
const bodyLength = body.length;
|
|
3051
|
+
let position = start + 1;
|
|
3052
|
+
while (position < bodyLength) {
|
|
3053
|
+
const code = body.charCodeAt(position);
|
|
3054
|
+
if (code === 10 || code === 13) {
|
|
3055
|
+
break;
|
|
3056
|
+
}
|
|
3057
|
+
if (isUnicodeScalarValue(code)) {
|
|
3058
|
+
++position;
|
|
3059
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
3060
|
+
position += 2;
|
|
3061
|
+
} else {
|
|
3062
|
+
break;
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
return createToken(
|
|
3066
|
+
lexer,
|
|
3067
|
+
TokenKind.COMMENT,
|
|
3068
|
+
start,
|
|
3069
|
+
position,
|
|
3070
|
+
body.slice(start + 1, position)
|
|
3071
|
+
);
|
|
3072
|
+
}
|
|
3073
|
+
function readNumber(lexer, start, firstCode) {
|
|
3074
|
+
const body = lexer.source.body;
|
|
3075
|
+
let position = start;
|
|
3076
|
+
let code = firstCode;
|
|
3077
|
+
let isFloat = false;
|
|
3078
|
+
if (code === 45) {
|
|
3079
|
+
code = body.charCodeAt(++position);
|
|
3080
|
+
}
|
|
3081
|
+
if (code === 48) {
|
|
3082
|
+
code = body.charCodeAt(++position);
|
|
3083
|
+
if (isDigit(code)) {
|
|
3084
|
+
throw syntaxError(
|
|
3085
|
+
lexer.source,
|
|
3086
|
+
position,
|
|
3087
|
+
`Invalid number, unexpected digit after 0: ${printCodePointAt(
|
|
3088
|
+
lexer,
|
|
3089
|
+
position
|
|
3090
|
+
)}.`
|
|
3091
|
+
);
|
|
3092
|
+
}
|
|
3093
|
+
} else {
|
|
3094
|
+
position = readDigits(lexer, position, code);
|
|
3095
|
+
code = body.charCodeAt(position);
|
|
3096
|
+
}
|
|
3097
|
+
if (code === 46) {
|
|
3098
|
+
isFloat = true;
|
|
3099
|
+
code = body.charCodeAt(++position);
|
|
3100
|
+
position = readDigits(lexer, position, code);
|
|
3101
|
+
code = body.charCodeAt(position);
|
|
3102
|
+
}
|
|
3103
|
+
if (code === 69 || code === 101) {
|
|
3104
|
+
isFloat = true;
|
|
3105
|
+
code = body.charCodeAt(++position);
|
|
3106
|
+
if (code === 43 || code === 45) {
|
|
3107
|
+
code = body.charCodeAt(++position);
|
|
3108
|
+
}
|
|
3109
|
+
position = readDigits(lexer, position, code);
|
|
3110
|
+
code = body.charCodeAt(position);
|
|
3111
|
+
}
|
|
3112
|
+
if (code === 46 || isNameStart(code)) {
|
|
3113
|
+
throw syntaxError(
|
|
3114
|
+
lexer.source,
|
|
3115
|
+
position,
|
|
3116
|
+
`Invalid number, expected digit but got: ${printCodePointAt(
|
|
3117
|
+
lexer,
|
|
3118
|
+
position
|
|
3119
|
+
)}.`
|
|
3120
|
+
);
|
|
3121
|
+
}
|
|
3122
|
+
return createToken(
|
|
3123
|
+
lexer,
|
|
3124
|
+
isFloat ? TokenKind.FLOAT : TokenKind.INT,
|
|
3125
|
+
start,
|
|
3126
|
+
position,
|
|
3127
|
+
body.slice(start, position)
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
function readDigits(lexer, start, firstCode) {
|
|
3131
|
+
if (!isDigit(firstCode)) {
|
|
3132
|
+
throw syntaxError(
|
|
3133
|
+
lexer.source,
|
|
3134
|
+
start,
|
|
3135
|
+
`Invalid number, expected digit but got: ${printCodePointAt(
|
|
3136
|
+
lexer,
|
|
3137
|
+
start
|
|
3138
|
+
)}.`
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
const body = lexer.source.body;
|
|
3142
|
+
let position = start + 1;
|
|
3143
|
+
while (isDigit(body.charCodeAt(position))) {
|
|
3144
|
+
++position;
|
|
3145
|
+
}
|
|
3146
|
+
return position;
|
|
3147
|
+
}
|
|
3148
|
+
function readString(lexer, start) {
|
|
3149
|
+
const body = lexer.source.body;
|
|
3150
|
+
const bodyLength = body.length;
|
|
3151
|
+
let position = start + 1;
|
|
3152
|
+
let chunkStart = position;
|
|
3153
|
+
let value = "";
|
|
3154
|
+
while (position < bodyLength) {
|
|
3155
|
+
const code = body.charCodeAt(position);
|
|
3156
|
+
if (code === 34) {
|
|
3157
|
+
value += body.slice(chunkStart, position);
|
|
3158
|
+
return createToken(lexer, TokenKind.STRING, start, position + 1, value);
|
|
3159
|
+
}
|
|
3160
|
+
if (code === 92) {
|
|
3161
|
+
value += body.slice(chunkStart, position);
|
|
3162
|
+
const escape = body.charCodeAt(position + 1) === 117 ? body.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
|
|
3163
|
+
value += escape.value;
|
|
3164
|
+
position += escape.size;
|
|
3165
|
+
chunkStart = position;
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3168
|
+
if (code === 10 || code === 13) {
|
|
3169
|
+
break;
|
|
3170
|
+
}
|
|
3171
|
+
if (isUnicodeScalarValue(code)) {
|
|
3172
|
+
++position;
|
|
3173
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
3174
|
+
position += 2;
|
|
3175
|
+
} else {
|
|
3176
|
+
throw syntaxError(
|
|
3177
|
+
lexer.source,
|
|
3178
|
+
position,
|
|
3179
|
+
`Invalid character within String: ${printCodePointAt(
|
|
3180
|
+
lexer,
|
|
3181
|
+
position
|
|
3182
|
+
)}.`
|
|
3183
|
+
);
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
throw syntaxError(lexer.source, position, "Unterminated string.");
|
|
3187
|
+
}
|
|
3188
|
+
function readEscapedUnicodeVariableWidth(lexer, position) {
|
|
3189
|
+
const body = lexer.source.body;
|
|
3190
|
+
let point = 0;
|
|
3191
|
+
let size = 3;
|
|
3192
|
+
while (size < 12) {
|
|
3193
|
+
const code = body.charCodeAt(position + size++);
|
|
3194
|
+
if (code === 125) {
|
|
3195
|
+
if (size < 5 || !isUnicodeScalarValue(point)) {
|
|
3196
|
+
break;
|
|
3197
|
+
}
|
|
3198
|
+
return {
|
|
3199
|
+
value: String.fromCodePoint(point),
|
|
3200
|
+
size
|
|
3201
|
+
};
|
|
3202
|
+
}
|
|
3203
|
+
point = point << 4 | readHexDigit(code);
|
|
3204
|
+
if (point < 0) {
|
|
3205
|
+
break;
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
throw syntaxError(
|
|
3209
|
+
lexer.source,
|
|
3210
|
+
position,
|
|
3211
|
+
`Invalid Unicode escape sequence: "${body.slice(
|
|
3212
|
+
position,
|
|
3213
|
+
position + size
|
|
3214
|
+
)}".`
|
|
3215
|
+
);
|
|
3216
|
+
}
|
|
3217
|
+
function readEscapedUnicodeFixedWidth(lexer, position) {
|
|
3218
|
+
const body = lexer.source.body;
|
|
3219
|
+
const code = read16BitHexCode(body, position + 2);
|
|
3220
|
+
if (isUnicodeScalarValue(code)) {
|
|
3221
|
+
return {
|
|
3222
|
+
value: String.fromCodePoint(code),
|
|
3223
|
+
size: 6
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
if (isLeadingSurrogate(code)) {
|
|
3227
|
+
if (body.charCodeAt(position + 6) === 92 && body.charCodeAt(position + 7) === 117) {
|
|
3228
|
+
const trailingCode = read16BitHexCode(body, position + 8);
|
|
3229
|
+
if (isTrailingSurrogate(trailingCode)) {
|
|
3230
|
+
return {
|
|
3231
|
+
value: String.fromCodePoint(code, trailingCode),
|
|
3232
|
+
size: 12
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
throw syntaxError(
|
|
3238
|
+
lexer.source,
|
|
3239
|
+
position,
|
|
3240
|
+
`Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
function read16BitHexCode(body, position) {
|
|
3244
|
+
return readHexDigit(body.charCodeAt(position)) << 12 | readHexDigit(body.charCodeAt(position + 1)) << 8 | readHexDigit(body.charCodeAt(position + 2)) << 4 | readHexDigit(body.charCodeAt(position + 3));
|
|
3245
|
+
}
|
|
3246
|
+
function readHexDigit(code) {
|
|
3247
|
+
return code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
|
|
3248
|
+
}
|
|
3249
|
+
function readEscapedCharacter(lexer, position) {
|
|
3250
|
+
const body = lexer.source.body;
|
|
3251
|
+
const code = body.charCodeAt(position + 1);
|
|
3252
|
+
switch (code) {
|
|
3253
|
+
case 34:
|
|
3254
|
+
return {
|
|
3255
|
+
value: '"',
|
|
3256
|
+
size: 2
|
|
3257
|
+
};
|
|
3258
|
+
case 92:
|
|
3259
|
+
return {
|
|
3260
|
+
value: "\\",
|
|
3261
|
+
size: 2
|
|
3262
|
+
};
|
|
3263
|
+
case 47:
|
|
3264
|
+
return {
|
|
3265
|
+
value: "/",
|
|
3266
|
+
size: 2
|
|
3267
|
+
};
|
|
3268
|
+
case 98:
|
|
3269
|
+
return {
|
|
3270
|
+
value: "\b",
|
|
3271
|
+
size: 2
|
|
3272
|
+
};
|
|
3273
|
+
case 102:
|
|
3274
|
+
return {
|
|
3275
|
+
value: "\f",
|
|
3276
|
+
size: 2
|
|
3277
|
+
};
|
|
3278
|
+
case 110:
|
|
3279
|
+
return {
|
|
3280
|
+
value: "\n",
|
|
3281
|
+
size: 2
|
|
3282
|
+
};
|
|
3283
|
+
case 114:
|
|
3284
|
+
return {
|
|
3285
|
+
value: "\r",
|
|
3286
|
+
size: 2
|
|
3287
|
+
};
|
|
3288
|
+
case 116:
|
|
3289
|
+
return {
|
|
3290
|
+
value: " ",
|
|
3291
|
+
size: 2
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
throw syntaxError(
|
|
3295
|
+
lexer.source,
|
|
3296
|
+
position,
|
|
3297
|
+
`Invalid character escape sequence: "${body.slice(
|
|
3298
|
+
position,
|
|
3299
|
+
position + 2
|
|
3300
|
+
)}".`
|
|
3301
|
+
);
|
|
3302
|
+
}
|
|
3303
|
+
function readBlockString(lexer, start) {
|
|
3304
|
+
const body = lexer.source.body;
|
|
3305
|
+
const bodyLength = body.length;
|
|
3306
|
+
let lineStart = lexer.lineStart;
|
|
3307
|
+
let position = start + 3;
|
|
3308
|
+
let chunkStart = position;
|
|
3309
|
+
let currentLine = "";
|
|
3310
|
+
const blockLines = [];
|
|
3311
|
+
while (position < bodyLength) {
|
|
3312
|
+
const code = body.charCodeAt(position);
|
|
3313
|
+
if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
|
|
3314
|
+
currentLine += body.slice(chunkStart, position);
|
|
3315
|
+
blockLines.push(currentLine);
|
|
3316
|
+
const token = createToken(
|
|
3317
|
+
lexer,
|
|
3318
|
+
TokenKind.BLOCK_STRING,
|
|
3319
|
+
start,
|
|
3320
|
+
position + 3,
|
|
3321
|
+
// Return a string of the lines joined with U+000A.
|
|
3322
|
+
dedentBlockStringLines(blockLines).join("\n")
|
|
3323
|
+
);
|
|
3324
|
+
lexer.line += blockLines.length - 1;
|
|
3325
|
+
lexer.lineStart = lineStart;
|
|
3326
|
+
return token;
|
|
3327
|
+
}
|
|
3328
|
+
if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
|
|
3329
|
+
currentLine += body.slice(chunkStart, position);
|
|
3330
|
+
chunkStart = position + 1;
|
|
3331
|
+
position += 4;
|
|
3332
|
+
continue;
|
|
3333
|
+
}
|
|
3334
|
+
if (code === 10 || code === 13) {
|
|
3335
|
+
currentLine += body.slice(chunkStart, position);
|
|
3336
|
+
blockLines.push(currentLine);
|
|
3337
|
+
if (code === 13 && body.charCodeAt(position + 1) === 10) {
|
|
3338
|
+
position += 2;
|
|
3339
|
+
} else {
|
|
3340
|
+
++position;
|
|
3341
|
+
}
|
|
3342
|
+
currentLine = "";
|
|
3343
|
+
chunkStart = position;
|
|
3344
|
+
lineStart = position;
|
|
3345
|
+
continue;
|
|
3346
|
+
}
|
|
3347
|
+
if (isUnicodeScalarValue(code)) {
|
|
3348
|
+
++position;
|
|
3349
|
+
} else if (isSupplementaryCodePoint(body, position)) {
|
|
3350
|
+
position += 2;
|
|
3351
|
+
} else {
|
|
3352
|
+
throw syntaxError(
|
|
3353
|
+
lexer.source,
|
|
3354
|
+
position,
|
|
3355
|
+
`Invalid character within String: ${printCodePointAt(
|
|
3356
|
+
lexer,
|
|
3357
|
+
position
|
|
3358
|
+
)}.`
|
|
3359
|
+
);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
throw syntaxError(lexer.source, position, "Unterminated string.");
|
|
3363
|
+
}
|
|
3364
|
+
function readName(lexer, start) {
|
|
3365
|
+
const body = lexer.source.body;
|
|
3366
|
+
const bodyLength = body.length;
|
|
3367
|
+
let position = start + 1;
|
|
3368
|
+
while (position < bodyLength) {
|
|
3369
|
+
const code = body.charCodeAt(position);
|
|
3370
|
+
if (isNameContinue(code)) {
|
|
3371
|
+
++position;
|
|
3372
|
+
} else {
|
|
3373
|
+
break;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
return createToken(
|
|
3377
|
+
lexer,
|
|
3378
|
+
TokenKind.NAME,
|
|
3379
|
+
start,
|
|
3380
|
+
position,
|
|
3381
|
+
body.slice(start, position)
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/inspect.mjs
|
|
3386
|
+
var MAX_ARRAY_LENGTH = 10;
|
|
3387
|
+
var MAX_RECURSIVE_DEPTH = 2;
|
|
3388
|
+
function inspect(value) {
|
|
3389
|
+
return formatValue(value, []);
|
|
3390
|
+
}
|
|
3391
|
+
function formatValue(value, seenValues) {
|
|
3392
|
+
switch (typeof value) {
|
|
3393
|
+
case "string":
|
|
3394
|
+
return JSON.stringify(value);
|
|
3395
|
+
case "function":
|
|
3396
|
+
return value.name ? `[function ${value.name}]` : "[function]";
|
|
3397
|
+
case "object":
|
|
3398
|
+
return formatObjectValue(value, seenValues);
|
|
3399
|
+
default:
|
|
3400
|
+
return String(value);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
function formatObjectValue(value, previouslySeenValues) {
|
|
3404
|
+
if (value === null) {
|
|
3405
|
+
return "null";
|
|
3406
|
+
}
|
|
3407
|
+
if (previouslySeenValues.includes(value)) {
|
|
3408
|
+
return "[Circular]";
|
|
3409
|
+
}
|
|
3410
|
+
const seenValues = [...previouslySeenValues, value];
|
|
3411
|
+
if (isJSONable(value)) {
|
|
3412
|
+
const jsonValue = value.toJSON();
|
|
3413
|
+
if (jsonValue !== value) {
|
|
3414
|
+
return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues);
|
|
3415
|
+
}
|
|
3416
|
+
} else if (Array.isArray(value)) {
|
|
3417
|
+
return formatArray(value, seenValues);
|
|
3418
|
+
}
|
|
3419
|
+
return formatObject(value, seenValues);
|
|
3420
|
+
}
|
|
3421
|
+
function isJSONable(value) {
|
|
3422
|
+
return typeof value.toJSON === "function";
|
|
3423
|
+
}
|
|
3424
|
+
function formatObject(object, seenValues) {
|
|
3425
|
+
const entries = Object.entries(object);
|
|
3426
|
+
if (entries.length === 0) {
|
|
3427
|
+
return "{}";
|
|
3428
|
+
}
|
|
3429
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
3430
|
+
return "[" + getObjectTag(object) + "]";
|
|
3431
|
+
}
|
|
3432
|
+
const properties = entries.map(
|
|
3433
|
+
([key, value]) => key + ": " + formatValue(value, seenValues)
|
|
3434
|
+
);
|
|
3435
|
+
return "{ " + properties.join(", ") + " }";
|
|
3436
|
+
}
|
|
3437
|
+
function formatArray(array, seenValues) {
|
|
3438
|
+
if (array.length === 0) {
|
|
3439
|
+
return "[]";
|
|
3440
|
+
}
|
|
3441
|
+
if (seenValues.length > MAX_RECURSIVE_DEPTH) {
|
|
3442
|
+
return "[Array]";
|
|
3443
|
+
}
|
|
3444
|
+
const len = Math.min(MAX_ARRAY_LENGTH, array.length);
|
|
3445
|
+
const remaining = array.length - len;
|
|
3446
|
+
const items = [];
|
|
3447
|
+
for (let i = 0; i < len; ++i) {
|
|
3448
|
+
items.push(formatValue(array[i], seenValues));
|
|
3449
|
+
}
|
|
3450
|
+
if (remaining === 1) {
|
|
3451
|
+
items.push("... 1 more item");
|
|
3452
|
+
} else if (remaining > 1) {
|
|
3453
|
+
items.push(`... ${remaining} more items`);
|
|
3454
|
+
}
|
|
3455
|
+
return "[" + items.join(", ") + "]";
|
|
3456
|
+
}
|
|
3457
|
+
function getObjectTag(object) {
|
|
3458
|
+
const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, "");
|
|
3459
|
+
if (tag === "Object" && typeof object.constructor === "function") {
|
|
3460
|
+
const name = object.constructor.name;
|
|
3461
|
+
if (typeof name === "string" && name !== "") {
|
|
3462
|
+
return name;
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
return tag;
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/jsutils/instanceOf.mjs
|
|
3469
|
+
var isProduction = globalThis.process && // eslint-disable-next-line no-undef
|
|
3470
|
+
process.env.NODE_ENV === "production";
|
|
3471
|
+
var instanceOf = (
|
|
3472
|
+
/* c8 ignore next 6 */
|
|
3473
|
+
// FIXME: https://github.com/graphql/graphql-js/issues/2317
|
|
3474
|
+
isProduction ? function instanceOf2(value, constructor) {
|
|
3475
|
+
return value instanceof constructor;
|
|
3476
|
+
} : function instanceOf3(value, constructor) {
|
|
3477
|
+
if (value instanceof constructor) {
|
|
3478
|
+
return true;
|
|
3479
|
+
}
|
|
3480
|
+
if (typeof value === "object" && value !== null) {
|
|
3481
|
+
var _value$constructor;
|
|
3482
|
+
const className = constructor.prototype[Symbol.toStringTag];
|
|
3483
|
+
const valueClassName = (
|
|
3484
|
+
// We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
3485
|
+
Symbol.toStringTag in value ? value[Symbol.toStringTag] : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name
|
|
3486
|
+
);
|
|
3487
|
+
if (className === valueClassName) {
|
|
3488
|
+
const stringifiedValue = inspect(value);
|
|
3489
|
+
throw new Error(`Cannot use ${className} "${stringifiedValue}" from another module or realm.
|
|
3490
|
+
|
|
3491
|
+
Ensure that there is only one instance of "graphql" in the node_modules
|
|
3492
|
+
directory. If different versions of "graphql" are the dependencies of other
|
|
3493
|
+
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
3494
|
+
|
|
3495
|
+
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
3496
|
+
|
|
3497
|
+
Duplicate "graphql" modules cannot be used at the same time since different
|
|
3498
|
+
versions may have different capabilities and behavior. The data from one
|
|
3499
|
+
version used in the function from another could produce confusing and
|
|
3500
|
+
spurious results.`);
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
return false;
|
|
3504
|
+
}
|
|
3505
|
+
);
|
|
3506
|
+
|
|
3507
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/source.mjs
|
|
3508
|
+
var Source = class {
|
|
3509
|
+
constructor(body, name = "GraphQL request", locationOffset = {
|
|
3510
|
+
line: 1,
|
|
3511
|
+
column: 1
|
|
3512
|
+
}) {
|
|
3513
|
+
typeof body === "string" || devAssert(false, `Body must be a string. Received: ${inspect(body)}.`);
|
|
3514
|
+
this.body = body;
|
|
3515
|
+
this.name = name;
|
|
3516
|
+
this.locationOffset = locationOffset;
|
|
3517
|
+
this.locationOffset.line > 0 || devAssert(
|
|
3518
|
+
false,
|
|
3519
|
+
"line in locationOffset is 1-indexed and must be positive."
|
|
3520
|
+
);
|
|
3521
|
+
this.locationOffset.column > 0 || devAssert(
|
|
3522
|
+
false,
|
|
3523
|
+
"column in locationOffset is 1-indexed and must be positive."
|
|
3524
|
+
);
|
|
3525
|
+
}
|
|
3526
|
+
get [Symbol.toStringTag]() {
|
|
3527
|
+
return "Source";
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
function isSource(source) {
|
|
3531
|
+
return instanceOf(source, Source);
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3534
|
+
// ../../node_modules/.pnpm/graphql@16.14.0/node_modules/graphql/language/parser.mjs
|
|
3535
|
+
function parse(source, options) {
|
|
3536
|
+
const parser = new Parser(source, options);
|
|
3537
|
+
const document = parser.parseDocument();
|
|
3538
|
+
Object.defineProperty(document, "tokenCount", {
|
|
3539
|
+
enumerable: false,
|
|
3540
|
+
value: parser.tokenCount
|
|
3541
|
+
});
|
|
3542
|
+
return document;
|
|
3543
|
+
}
|
|
3544
|
+
var Parser = class {
|
|
3545
|
+
constructor(source, options = {}) {
|
|
3546
|
+
const { lexer, ..._options } = options;
|
|
3547
|
+
if (lexer) {
|
|
3548
|
+
this._lexer = lexer;
|
|
3549
|
+
} else {
|
|
3550
|
+
const sourceObj = isSource(source) ? source : new Source(source);
|
|
3551
|
+
this._lexer = new Lexer(sourceObj);
|
|
3552
|
+
}
|
|
3553
|
+
this._options = _options;
|
|
3554
|
+
this._tokenCounter = 0;
|
|
3555
|
+
}
|
|
3556
|
+
get tokenCount() {
|
|
3557
|
+
return this._tokenCounter;
|
|
3558
|
+
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Converts a name lex token into a name parse node.
|
|
3561
|
+
*/
|
|
3562
|
+
parseName() {
|
|
3563
|
+
const token = this.expectToken(TokenKind.NAME);
|
|
3564
|
+
return this.node(token, {
|
|
3565
|
+
kind: Kind.NAME,
|
|
3566
|
+
value: token.value
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
// Implements the parsing rules in the Document section.
|
|
3570
|
+
/**
|
|
3571
|
+
* Document : Definition+
|
|
3572
|
+
*/
|
|
3573
|
+
parseDocument() {
|
|
3574
|
+
return this.node(this._lexer.token, {
|
|
3575
|
+
kind: Kind.DOCUMENT,
|
|
3576
|
+
definitions: this.many(
|
|
3577
|
+
TokenKind.SOF,
|
|
3578
|
+
this.parseDefinition,
|
|
3579
|
+
TokenKind.EOF
|
|
3580
|
+
)
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
/**
|
|
3584
|
+
* Definition :
|
|
3585
|
+
* - ExecutableDefinition
|
|
3586
|
+
* - TypeSystemDefinition
|
|
3587
|
+
* - TypeSystemExtension
|
|
3588
|
+
*
|
|
3589
|
+
* ExecutableDefinition :
|
|
3590
|
+
* - OperationDefinition
|
|
3591
|
+
* - FragmentDefinition
|
|
3592
|
+
*
|
|
3593
|
+
* TypeSystemDefinition :
|
|
3594
|
+
* - SchemaDefinition
|
|
3595
|
+
* - TypeDefinition
|
|
3596
|
+
* - DirectiveDefinition
|
|
3597
|
+
*
|
|
3598
|
+
* TypeDefinition :
|
|
3599
|
+
* - ScalarTypeDefinition
|
|
3600
|
+
* - ObjectTypeDefinition
|
|
3601
|
+
* - InterfaceTypeDefinition
|
|
3602
|
+
* - UnionTypeDefinition
|
|
3603
|
+
* - EnumTypeDefinition
|
|
3604
|
+
* - InputObjectTypeDefinition
|
|
3605
|
+
*/
|
|
3606
|
+
parseDefinition() {
|
|
3607
|
+
if (this.peek(TokenKind.BRACE_L)) {
|
|
3608
|
+
return this.parseOperationDefinition();
|
|
3609
|
+
}
|
|
3610
|
+
const hasDescription = this.peekDescription();
|
|
3611
|
+
const keywordToken = hasDescription ? this._lexer.lookahead() : this._lexer.token;
|
|
3612
|
+
if (hasDescription && keywordToken.kind === TokenKind.BRACE_L) {
|
|
3613
|
+
throw syntaxError(
|
|
3614
|
+
this._lexer.source,
|
|
3615
|
+
this._lexer.token.start,
|
|
3616
|
+
"Unexpected description, descriptions are not supported on shorthand queries."
|
|
3617
|
+
);
|
|
3618
|
+
}
|
|
3619
|
+
if (keywordToken.kind === TokenKind.NAME) {
|
|
3620
|
+
switch (keywordToken.value) {
|
|
3621
|
+
case "schema":
|
|
3622
|
+
return this.parseSchemaDefinition();
|
|
3623
|
+
case "scalar":
|
|
3624
|
+
return this.parseScalarTypeDefinition();
|
|
3625
|
+
case "type":
|
|
3626
|
+
return this.parseObjectTypeDefinition();
|
|
3627
|
+
case "interface":
|
|
3628
|
+
return this.parseInterfaceTypeDefinition();
|
|
3629
|
+
case "union":
|
|
3630
|
+
return this.parseUnionTypeDefinition();
|
|
3631
|
+
case "enum":
|
|
3632
|
+
return this.parseEnumTypeDefinition();
|
|
3633
|
+
case "input":
|
|
3634
|
+
return this.parseInputObjectTypeDefinition();
|
|
3635
|
+
case "directive":
|
|
3636
|
+
return this.parseDirectiveDefinition();
|
|
3637
|
+
}
|
|
3638
|
+
switch (keywordToken.value) {
|
|
3639
|
+
case "query":
|
|
3640
|
+
case "mutation":
|
|
3641
|
+
case "subscription":
|
|
3642
|
+
return this.parseOperationDefinition();
|
|
3643
|
+
case "fragment":
|
|
3644
|
+
return this.parseFragmentDefinition();
|
|
3645
|
+
}
|
|
3646
|
+
if (hasDescription) {
|
|
3647
|
+
throw syntaxError(
|
|
3648
|
+
this._lexer.source,
|
|
3649
|
+
this._lexer.token.start,
|
|
3650
|
+
"Unexpected description, only GraphQL definitions support descriptions."
|
|
3651
|
+
);
|
|
3652
|
+
}
|
|
3653
|
+
switch (keywordToken.value) {
|
|
3654
|
+
case "extend":
|
|
3655
|
+
return this.parseTypeSystemExtension();
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
throw this.unexpected(keywordToken);
|
|
3659
|
+
}
|
|
3660
|
+
// Implements the parsing rules in the Operations section.
|
|
3661
|
+
/**
|
|
3662
|
+
* OperationDefinition :
|
|
3663
|
+
* - SelectionSet
|
|
3664
|
+
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
3665
|
+
*/
|
|
3666
|
+
parseOperationDefinition() {
|
|
3667
|
+
const start = this._lexer.token;
|
|
3668
|
+
if (this.peek(TokenKind.BRACE_L)) {
|
|
3669
|
+
return this.node(start, {
|
|
3670
|
+
kind: Kind.OPERATION_DEFINITION,
|
|
3671
|
+
operation: OperationTypeNode.QUERY,
|
|
3672
|
+
description: void 0,
|
|
3673
|
+
name: void 0,
|
|
3674
|
+
variableDefinitions: [],
|
|
3675
|
+
directives: [],
|
|
3676
|
+
selectionSet: this.parseSelectionSet()
|
|
3677
|
+
});
|
|
3678
|
+
}
|
|
3679
|
+
const description = this.parseDescription();
|
|
3680
|
+
const operation = this.parseOperationType();
|
|
3681
|
+
let name;
|
|
3682
|
+
if (this.peek(TokenKind.NAME)) {
|
|
3683
|
+
name = this.parseName();
|
|
3684
|
+
}
|
|
3685
|
+
return this.node(start, {
|
|
3686
|
+
kind: Kind.OPERATION_DEFINITION,
|
|
3687
|
+
operation,
|
|
3688
|
+
description,
|
|
3689
|
+
name,
|
|
3690
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
3691
|
+
directives: this.parseDirectives(false),
|
|
3692
|
+
selectionSet: this.parseSelectionSet()
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
/**
|
|
3696
|
+
* OperationType : one of query mutation subscription
|
|
3697
|
+
*/
|
|
3698
|
+
parseOperationType() {
|
|
3699
|
+
const operationToken = this.expectToken(TokenKind.NAME);
|
|
3700
|
+
switch (operationToken.value) {
|
|
3701
|
+
case "query":
|
|
3702
|
+
return OperationTypeNode.QUERY;
|
|
3703
|
+
case "mutation":
|
|
3704
|
+
return OperationTypeNode.MUTATION;
|
|
3705
|
+
case "subscription":
|
|
3706
|
+
return OperationTypeNode.SUBSCRIPTION;
|
|
3707
|
+
}
|
|
3708
|
+
throw this.unexpected(operationToken);
|
|
3709
|
+
}
|
|
3710
|
+
/**
|
|
3711
|
+
* VariableDefinitions : ( VariableDefinition+ )
|
|
3712
|
+
*/
|
|
3713
|
+
parseVariableDefinitions() {
|
|
3714
|
+
return this.optionalMany(
|
|
3715
|
+
TokenKind.PAREN_L,
|
|
3716
|
+
this.parseVariableDefinition,
|
|
3717
|
+
TokenKind.PAREN_R
|
|
3718
|
+
);
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
3722
|
+
*/
|
|
3723
|
+
parseVariableDefinition() {
|
|
3724
|
+
return this.node(this._lexer.token, {
|
|
3725
|
+
kind: Kind.VARIABLE_DEFINITION,
|
|
3726
|
+
description: this.parseDescription(),
|
|
3727
|
+
variable: this.parseVariable(),
|
|
3728
|
+
type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),
|
|
3729
|
+
defaultValue: this.expectOptionalToken(TokenKind.EQUALS) ? this.parseConstValueLiteral() : void 0,
|
|
3730
|
+
directives: this.parseConstDirectives()
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Variable : $ Name
|
|
3735
|
+
*/
|
|
3736
|
+
parseVariable() {
|
|
3737
|
+
const start = this._lexer.token;
|
|
3738
|
+
this.expectToken(TokenKind.DOLLAR);
|
|
3739
|
+
return this.node(start, {
|
|
3740
|
+
kind: Kind.VARIABLE,
|
|
3741
|
+
name: this.parseName()
|
|
3742
|
+
});
|
|
3743
|
+
}
|
|
3744
|
+
/**
|
|
3745
|
+
* ```
|
|
3746
|
+
* SelectionSet : { Selection+ }
|
|
3747
|
+
* ```
|
|
3748
|
+
*/
|
|
3749
|
+
parseSelectionSet() {
|
|
3750
|
+
return this.node(this._lexer.token, {
|
|
3751
|
+
kind: Kind.SELECTION_SET,
|
|
3752
|
+
selections: this.many(
|
|
3753
|
+
TokenKind.BRACE_L,
|
|
3754
|
+
this.parseSelection,
|
|
3755
|
+
TokenKind.BRACE_R
|
|
3756
|
+
)
|
|
3757
|
+
});
|
|
3758
|
+
}
|
|
3759
|
+
/**
|
|
3760
|
+
* Selection :
|
|
3761
|
+
* - Field
|
|
3762
|
+
* - FragmentSpread
|
|
3763
|
+
* - InlineFragment
|
|
3764
|
+
*/
|
|
3765
|
+
parseSelection() {
|
|
3766
|
+
return this.peek(TokenKind.SPREAD) ? this.parseFragment() : this.parseField();
|
|
3767
|
+
}
|
|
3768
|
+
/**
|
|
3769
|
+
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
3770
|
+
*
|
|
3771
|
+
* Alias : Name :
|
|
3772
|
+
*/
|
|
3773
|
+
parseField() {
|
|
3774
|
+
const start = this._lexer.token;
|
|
3775
|
+
const nameOrAlias = this.parseName();
|
|
3776
|
+
let alias;
|
|
3777
|
+
let name;
|
|
3778
|
+
if (this.expectOptionalToken(TokenKind.COLON)) {
|
|
3779
|
+
alias = nameOrAlias;
|
|
3780
|
+
name = this.parseName();
|
|
3781
|
+
} else {
|
|
3782
|
+
name = nameOrAlias;
|
|
3783
|
+
}
|
|
3784
|
+
return this.node(start, {
|
|
3785
|
+
kind: Kind.FIELD,
|
|
3786
|
+
alias,
|
|
3787
|
+
name,
|
|
3788
|
+
arguments: this.parseArguments(false),
|
|
3789
|
+
directives: this.parseDirectives(false),
|
|
3790
|
+
selectionSet: this.peek(TokenKind.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
3791
|
+
});
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* Arguments[Const] : ( Argument[?Const]+ )
|
|
3795
|
+
*/
|
|
3796
|
+
parseArguments(isConst) {
|
|
3797
|
+
const item = isConst ? this.parseConstArgument : this.parseArgument;
|
|
3798
|
+
return this.optionalMany(TokenKind.PAREN_L, item, TokenKind.PAREN_R);
|
|
3799
|
+
}
|
|
3800
|
+
/**
|
|
3801
|
+
* Argument[Const] : Name : Value[?Const]
|
|
3802
|
+
*/
|
|
3803
|
+
parseArgument(isConst = false) {
|
|
3804
|
+
const start = this._lexer.token;
|
|
3805
|
+
const name = this.parseName();
|
|
3806
|
+
this.expectToken(TokenKind.COLON);
|
|
3807
|
+
return this.node(start, {
|
|
3808
|
+
kind: Kind.ARGUMENT,
|
|
3809
|
+
name,
|
|
3810
|
+
value: this.parseValueLiteral(isConst)
|
|
3811
|
+
});
|
|
3812
|
+
}
|
|
3813
|
+
parseConstArgument() {
|
|
3814
|
+
return this.parseArgument(true);
|
|
3815
|
+
}
|
|
3816
|
+
// Implements the parsing rules in the Fragments section.
|
|
3817
|
+
/**
|
|
3818
|
+
* Corresponds to both FragmentSpread and InlineFragment in the spec.
|
|
3819
|
+
*
|
|
3820
|
+
* FragmentSpread : ... FragmentName Directives?
|
|
3821
|
+
*
|
|
3822
|
+
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
3823
|
+
*/
|
|
3824
|
+
parseFragment() {
|
|
3825
|
+
const start = this._lexer.token;
|
|
3826
|
+
this.expectToken(TokenKind.SPREAD);
|
|
3827
|
+
const hasTypeCondition = this.expectOptionalKeyword("on");
|
|
3828
|
+
if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
|
|
3829
|
+
return this.node(start, {
|
|
3830
|
+
kind: Kind.FRAGMENT_SPREAD,
|
|
3831
|
+
name: this.parseFragmentName(),
|
|
3832
|
+
directives: this.parseDirectives(false)
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
return this.node(start, {
|
|
3836
|
+
kind: Kind.INLINE_FRAGMENT,
|
|
3837
|
+
typeCondition: hasTypeCondition ? this.parseNamedType() : void 0,
|
|
3838
|
+
directives: this.parseDirectives(false),
|
|
3839
|
+
selectionSet: this.parseSelectionSet()
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
/**
|
|
3843
|
+
* FragmentDefinition :
|
|
3844
|
+
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
3845
|
+
*
|
|
3846
|
+
* TypeCondition : NamedType
|
|
3847
|
+
*/
|
|
3848
|
+
parseFragmentDefinition() {
|
|
3849
|
+
const start = this._lexer.token;
|
|
3850
|
+
const description = this.parseDescription();
|
|
3851
|
+
this.expectKeyword("fragment");
|
|
3852
|
+
if (this._options.allowLegacyFragmentVariables === true) {
|
|
3853
|
+
return this.node(start, {
|
|
3854
|
+
kind: Kind.FRAGMENT_DEFINITION,
|
|
3855
|
+
description,
|
|
3856
|
+
name: this.parseFragmentName(),
|
|
3857
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
3858
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
3859
|
+
directives: this.parseDirectives(false),
|
|
3860
|
+
selectionSet: this.parseSelectionSet()
|
|
3861
|
+
});
|
|
3862
|
+
}
|
|
3863
|
+
return this.node(start, {
|
|
3864
|
+
kind: Kind.FRAGMENT_DEFINITION,
|
|
3865
|
+
description,
|
|
3866
|
+
name: this.parseFragmentName(),
|
|
3867
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
3868
|
+
directives: this.parseDirectives(false),
|
|
3869
|
+
selectionSet: this.parseSelectionSet()
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
/**
|
|
3873
|
+
* FragmentName : Name but not `on`
|
|
3874
|
+
*/
|
|
3875
|
+
parseFragmentName() {
|
|
3876
|
+
if (this._lexer.token.value === "on") {
|
|
3877
|
+
throw this.unexpected();
|
|
3878
|
+
}
|
|
3879
|
+
return this.parseName();
|
|
3880
|
+
}
|
|
3881
|
+
// Implements the parsing rules in the Values section.
|
|
3882
|
+
/**
|
|
3883
|
+
* Value[Const] :
|
|
3884
|
+
* - [~Const] Variable
|
|
3885
|
+
* - IntValue
|
|
3886
|
+
* - FloatValue
|
|
3887
|
+
* - StringValue
|
|
3888
|
+
* - BooleanValue
|
|
3889
|
+
* - NullValue
|
|
3890
|
+
* - EnumValue
|
|
3891
|
+
* - ListValue[?Const]
|
|
3892
|
+
* - ObjectValue[?Const]
|
|
3893
|
+
*
|
|
3894
|
+
* BooleanValue : one of `true` `false`
|
|
3895
|
+
*
|
|
3896
|
+
* NullValue : `null`
|
|
3897
|
+
*
|
|
3898
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
3899
|
+
*/
|
|
3900
|
+
parseValueLiteral(isConst) {
|
|
3901
|
+
const token = this._lexer.token;
|
|
3902
|
+
switch (token.kind) {
|
|
3903
|
+
case TokenKind.BRACKET_L:
|
|
3904
|
+
return this.parseList(isConst);
|
|
3905
|
+
case TokenKind.BRACE_L:
|
|
3906
|
+
return this.parseObject(isConst);
|
|
3907
|
+
case TokenKind.INT:
|
|
3908
|
+
this.advanceLexer();
|
|
3909
|
+
return this.node(token, {
|
|
3910
|
+
kind: Kind.INT,
|
|
3911
|
+
value: token.value
|
|
3912
|
+
});
|
|
3913
|
+
case TokenKind.FLOAT:
|
|
3914
|
+
this.advanceLexer();
|
|
3915
|
+
return this.node(token, {
|
|
3916
|
+
kind: Kind.FLOAT,
|
|
3917
|
+
value: token.value
|
|
3918
|
+
});
|
|
3919
|
+
case TokenKind.STRING:
|
|
3920
|
+
case TokenKind.BLOCK_STRING:
|
|
3921
|
+
return this.parseStringLiteral();
|
|
3922
|
+
case TokenKind.NAME:
|
|
3923
|
+
this.advanceLexer();
|
|
3924
|
+
switch (token.value) {
|
|
3925
|
+
case "true":
|
|
3926
|
+
return this.node(token, {
|
|
3927
|
+
kind: Kind.BOOLEAN,
|
|
3928
|
+
value: true
|
|
3929
|
+
});
|
|
3930
|
+
case "false":
|
|
3931
|
+
return this.node(token, {
|
|
3932
|
+
kind: Kind.BOOLEAN,
|
|
3933
|
+
value: false
|
|
3934
|
+
});
|
|
3935
|
+
case "null":
|
|
3936
|
+
return this.node(token, {
|
|
3937
|
+
kind: Kind.NULL
|
|
3938
|
+
});
|
|
3939
|
+
default:
|
|
3940
|
+
return this.node(token, {
|
|
3941
|
+
kind: Kind.ENUM,
|
|
3942
|
+
value: token.value
|
|
3943
|
+
});
|
|
3944
|
+
}
|
|
3945
|
+
case TokenKind.DOLLAR:
|
|
3946
|
+
if (isConst) {
|
|
3947
|
+
this.expectToken(TokenKind.DOLLAR);
|
|
3948
|
+
if (this._lexer.token.kind === TokenKind.NAME) {
|
|
3949
|
+
const varName = this._lexer.token.value;
|
|
3950
|
+
throw syntaxError(
|
|
3951
|
+
this._lexer.source,
|
|
3952
|
+
token.start,
|
|
3953
|
+
`Unexpected variable "$${varName}" in constant value.`
|
|
3954
|
+
);
|
|
3955
|
+
} else {
|
|
3956
|
+
throw this.unexpected(token);
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
return this.parseVariable();
|
|
3960
|
+
default:
|
|
3961
|
+
throw this.unexpected();
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
parseConstValueLiteral() {
|
|
3965
|
+
return this.parseValueLiteral(true);
|
|
3966
|
+
}
|
|
3967
|
+
parseStringLiteral() {
|
|
3968
|
+
const token = this._lexer.token;
|
|
3969
|
+
this.advanceLexer();
|
|
3970
|
+
return this.node(token, {
|
|
3971
|
+
kind: Kind.STRING,
|
|
3972
|
+
value: token.value,
|
|
3973
|
+
block: token.kind === TokenKind.BLOCK_STRING
|
|
3974
|
+
});
|
|
3975
|
+
}
|
|
3976
|
+
/**
|
|
3977
|
+
* ListValue[Const] :
|
|
3978
|
+
* - [ ]
|
|
3979
|
+
* - [ Value[?Const]+ ]
|
|
3980
|
+
*/
|
|
3981
|
+
parseList(isConst) {
|
|
3982
|
+
const item = () => this.parseValueLiteral(isConst);
|
|
3983
|
+
return this.node(this._lexer.token, {
|
|
3984
|
+
kind: Kind.LIST,
|
|
3985
|
+
values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R)
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
/**
|
|
3989
|
+
* ```
|
|
3990
|
+
* ObjectValue[Const] :
|
|
3991
|
+
* - { }
|
|
3992
|
+
* - { ObjectField[?Const]+ }
|
|
3993
|
+
* ```
|
|
3994
|
+
*/
|
|
3995
|
+
parseObject(isConst) {
|
|
3996
|
+
const item = () => this.parseObjectField(isConst);
|
|
3997
|
+
return this.node(this._lexer.token, {
|
|
3998
|
+
kind: Kind.OBJECT,
|
|
3999
|
+
fields: this.any(TokenKind.BRACE_L, item, TokenKind.BRACE_R)
|
|
4000
|
+
});
|
|
4001
|
+
}
|
|
4002
|
+
/**
|
|
4003
|
+
* ObjectField[Const] : Name : Value[?Const]
|
|
4004
|
+
*/
|
|
4005
|
+
parseObjectField(isConst) {
|
|
4006
|
+
const start = this._lexer.token;
|
|
4007
|
+
const name = this.parseName();
|
|
4008
|
+
this.expectToken(TokenKind.COLON);
|
|
4009
|
+
return this.node(start, {
|
|
4010
|
+
kind: Kind.OBJECT_FIELD,
|
|
4011
|
+
name,
|
|
4012
|
+
value: this.parseValueLiteral(isConst)
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
4015
|
+
// Implements the parsing rules in the Directives section.
|
|
4016
|
+
/**
|
|
4017
|
+
* Directives[Const] : Directive[?Const]+
|
|
4018
|
+
*/
|
|
4019
|
+
parseDirectives(isConst) {
|
|
4020
|
+
const directives = [];
|
|
4021
|
+
while (this.peek(TokenKind.AT)) {
|
|
4022
|
+
directives.push(this.parseDirective(isConst));
|
|
4023
|
+
}
|
|
4024
|
+
return directives;
|
|
4025
|
+
}
|
|
4026
|
+
parseConstDirectives() {
|
|
4027
|
+
return this.parseDirectives(true);
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* ```
|
|
4031
|
+
* Directive[Const] : @ Name Arguments[?Const]?
|
|
4032
|
+
* ```
|
|
4033
|
+
*/
|
|
4034
|
+
parseDirective(isConst) {
|
|
4035
|
+
const start = this._lexer.token;
|
|
4036
|
+
this.expectToken(TokenKind.AT);
|
|
4037
|
+
return this.node(start, {
|
|
4038
|
+
kind: Kind.DIRECTIVE,
|
|
4039
|
+
name: this.parseName(),
|
|
4040
|
+
arguments: this.parseArguments(isConst)
|
|
4041
|
+
});
|
|
4042
|
+
}
|
|
4043
|
+
// Implements the parsing rules in the Types section.
|
|
4044
|
+
/**
|
|
4045
|
+
* Type :
|
|
4046
|
+
* - NamedType
|
|
4047
|
+
* - ListType
|
|
4048
|
+
* - NonNullType
|
|
4049
|
+
*/
|
|
4050
|
+
parseTypeReference() {
|
|
4051
|
+
const start = this._lexer.token;
|
|
4052
|
+
let type;
|
|
4053
|
+
if (this.expectOptionalToken(TokenKind.BRACKET_L)) {
|
|
4054
|
+
const innerType = this.parseTypeReference();
|
|
4055
|
+
this.expectToken(TokenKind.BRACKET_R);
|
|
4056
|
+
type = this.node(start, {
|
|
4057
|
+
kind: Kind.LIST_TYPE,
|
|
4058
|
+
type: innerType
|
|
4059
|
+
});
|
|
4060
|
+
} else {
|
|
4061
|
+
type = this.parseNamedType();
|
|
4062
|
+
}
|
|
4063
|
+
if (this.expectOptionalToken(TokenKind.BANG)) {
|
|
4064
|
+
return this.node(start, {
|
|
4065
|
+
kind: Kind.NON_NULL_TYPE,
|
|
4066
|
+
type
|
|
4067
|
+
});
|
|
4068
|
+
}
|
|
4069
|
+
return type;
|
|
4070
|
+
}
|
|
4071
|
+
/**
|
|
4072
|
+
* NamedType : Name
|
|
4073
|
+
*/
|
|
4074
|
+
parseNamedType() {
|
|
4075
|
+
return this.node(this._lexer.token, {
|
|
4076
|
+
kind: Kind.NAMED_TYPE,
|
|
4077
|
+
name: this.parseName()
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
// Implements the parsing rules in the Type Definition section.
|
|
4081
|
+
peekDescription() {
|
|
4082
|
+
return this.peek(TokenKind.STRING) || this.peek(TokenKind.BLOCK_STRING);
|
|
4083
|
+
}
|
|
4084
|
+
/**
|
|
4085
|
+
* Description : StringValue
|
|
4086
|
+
*/
|
|
4087
|
+
parseDescription() {
|
|
4088
|
+
if (this.peekDescription()) {
|
|
4089
|
+
return this.parseStringLiteral();
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
/**
|
|
4093
|
+
* ```
|
|
4094
|
+
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
4095
|
+
* ```
|
|
4096
|
+
*/
|
|
4097
|
+
parseSchemaDefinition() {
|
|
4098
|
+
const start = this._lexer.token;
|
|
4099
|
+
const description = this.parseDescription();
|
|
4100
|
+
this.expectKeyword("schema");
|
|
4101
|
+
const directives = this.parseConstDirectives();
|
|
4102
|
+
const operationTypes = this.many(
|
|
4103
|
+
TokenKind.BRACE_L,
|
|
4104
|
+
this.parseOperationTypeDefinition,
|
|
4105
|
+
TokenKind.BRACE_R
|
|
4106
|
+
);
|
|
4107
|
+
return this.node(start, {
|
|
4108
|
+
kind: Kind.SCHEMA_DEFINITION,
|
|
4109
|
+
description,
|
|
4110
|
+
directives,
|
|
4111
|
+
operationTypes
|
|
4112
|
+
});
|
|
4113
|
+
}
|
|
4114
|
+
/**
|
|
4115
|
+
* OperationTypeDefinition : OperationType : NamedType
|
|
4116
|
+
*/
|
|
4117
|
+
parseOperationTypeDefinition() {
|
|
4118
|
+
const start = this._lexer.token;
|
|
4119
|
+
const operation = this.parseOperationType();
|
|
4120
|
+
this.expectToken(TokenKind.COLON);
|
|
4121
|
+
const type = this.parseNamedType();
|
|
4122
|
+
return this.node(start, {
|
|
4123
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
4124
|
+
operation,
|
|
4125
|
+
type
|
|
4126
|
+
});
|
|
4127
|
+
}
|
|
4128
|
+
/**
|
|
4129
|
+
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
4130
|
+
*/
|
|
4131
|
+
parseScalarTypeDefinition() {
|
|
4132
|
+
const start = this._lexer.token;
|
|
4133
|
+
const description = this.parseDescription();
|
|
4134
|
+
this.expectKeyword("scalar");
|
|
4135
|
+
const name = this.parseName();
|
|
4136
|
+
const directives = this.parseConstDirectives();
|
|
4137
|
+
return this.node(start, {
|
|
4138
|
+
kind: Kind.SCALAR_TYPE_DEFINITION,
|
|
4139
|
+
description,
|
|
4140
|
+
name,
|
|
4141
|
+
directives
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
/**
|
|
4145
|
+
* ObjectTypeDefinition :
|
|
4146
|
+
* Description?
|
|
4147
|
+
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
4148
|
+
*/
|
|
4149
|
+
parseObjectTypeDefinition() {
|
|
4150
|
+
const start = this._lexer.token;
|
|
4151
|
+
const description = this.parseDescription();
|
|
4152
|
+
this.expectKeyword("type");
|
|
4153
|
+
const name = this.parseName();
|
|
4154
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4155
|
+
const directives = this.parseConstDirectives();
|
|
4156
|
+
const fields = this.parseFieldsDefinition();
|
|
4157
|
+
return this.node(start, {
|
|
4158
|
+
kind: Kind.OBJECT_TYPE_DEFINITION,
|
|
4159
|
+
description,
|
|
4160
|
+
name,
|
|
4161
|
+
interfaces,
|
|
4162
|
+
directives,
|
|
4163
|
+
fields
|
|
4164
|
+
});
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* ImplementsInterfaces :
|
|
4168
|
+
* - implements `&`? NamedType
|
|
4169
|
+
* - ImplementsInterfaces & NamedType
|
|
4170
|
+
*/
|
|
4171
|
+
parseImplementsInterfaces() {
|
|
4172
|
+
return this.expectOptionalKeyword("implements") ? this.delimitedMany(TokenKind.AMP, this.parseNamedType) : [];
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
* ```
|
|
4176
|
+
* FieldsDefinition : { FieldDefinition+ }
|
|
4177
|
+
* ```
|
|
4178
|
+
*/
|
|
4179
|
+
parseFieldsDefinition() {
|
|
4180
|
+
return this.optionalMany(
|
|
4181
|
+
TokenKind.BRACE_L,
|
|
4182
|
+
this.parseFieldDefinition,
|
|
4183
|
+
TokenKind.BRACE_R
|
|
4184
|
+
);
|
|
4185
|
+
}
|
|
4186
|
+
/**
|
|
4187
|
+
* FieldDefinition :
|
|
4188
|
+
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
4189
|
+
*/
|
|
4190
|
+
parseFieldDefinition() {
|
|
4191
|
+
const start = this._lexer.token;
|
|
4192
|
+
const description = this.parseDescription();
|
|
4193
|
+
const name = this.parseName();
|
|
4194
|
+
const args = this.parseArgumentDefs();
|
|
4195
|
+
this.expectToken(TokenKind.COLON);
|
|
4196
|
+
const type = this.parseTypeReference();
|
|
4197
|
+
const directives = this.parseConstDirectives();
|
|
4198
|
+
return this.node(start, {
|
|
4199
|
+
kind: Kind.FIELD_DEFINITION,
|
|
4200
|
+
description,
|
|
4201
|
+
name,
|
|
4202
|
+
arguments: args,
|
|
4203
|
+
type,
|
|
4204
|
+
directives
|
|
4205
|
+
});
|
|
4206
|
+
}
|
|
4207
|
+
/**
|
|
4208
|
+
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
4209
|
+
*/
|
|
4210
|
+
parseArgumentDefs() {
|
|
4211
|
+
return this.optionalMany(
|
|
4212
|
+
TokenKind.PAREN_L,
|
|
4213
|
+
this.parseInputValueDef,
|
|
4214
|
+
TokenKind.PAREN_R
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
4217
|
+
/**
|
|
4218
|
+
* InputValueDefinition :
|
|
4219
|
+
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
4220
|
+
*/
|
|
4221
|
+
parseInputValueDef() {
|
|
4222
|
+
const start = this._lexer.token;
|
|
4223
|
+
const description = this.parseDescription();
|
|
4224
|
+
const name = this.parseName();
|
|
4225
|
+
this.expectToken(TokenKind.COLON);
|
|
4226
|
+
const type = this.parseTypeReference();
|
|
4227
|
+
let defaultValue;
|
|
4228
|
+
if (this.expectOptionalToken(TokenKind.EQUALS)) {
|
|
4229
|
+
defaultValue = this.parseConstValueLiteral();
|
|
4230
|
+
}
|
|
4231
|
+
const directives = this.parseConstDirectives();
|
|
4232
|
+
return this.node(start, {
|
|
4233
|
+
kind: Kind.INPUT_VALUE_DEFINITION,
|
|
4234
|
+
description,
|
|
4235
|
+
name,
|
|
4236
|
+
type,
|
|
4237
|
+
defaultValue,
|
|
4238
|
+
directives
|
|
4239
|
+
});
|
|
4240
|
+
}
|
|
4241
|
+
/**
|
|
4242
|
+
* InterfaceTypeDefinition :
|
|
4243
|
+
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
4244
|
+
*/
|
|
4245
|
+
parseInterfaceTypeDefinition() {
|
|
4246
|
+
const start = this._lexer.token;
|
|
4247
|
+
const description = this.parseDescription();
|
|
4248
|
+
this.expectKeyword("interface");
|
|
4249
|
+
const name = this.parseName();
|
|
4250
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4251
|
+
const directives = this.parseConstDirectives();
|
|
4252
|
+
const fields = this.parseFieldsDefinition();
|
|
4253
|
+
return this.node(start, {
|
|
4254
|
+
kind: Kind.INTERFACE_TYPE_DEFINITION,
|
|
4255
|
+
description,
|
|
4256
|
+
name,
|
|
4257
|
+
interfaces,
|
|
4258
|
+
directives,
|
|
4259
|
+
fields
|
|
4260
|
+
});
|
|
4261
|
+
}
|
|
4262
|
+
/**
|
|
4263
|
+
* UnionTypeDefinition :
|
|
4264
|
+
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
4265
|
+
*/
|
|
4266
|
+
parseUnionTypeDefinition() {
|
|
4267
|
+
const start = this._lexer.token;
|
|
4268
|
+
const description = this.parseDescription();
|
|
4269
|
+
this.expectKeyword("union");
|
|
4270
|
+
const name = this.parseName();
|
|
4271
|
+
const directives = this.parseConstDirectives();
|
|
4272
|
+
const types = this.parseUnionMemberTypes();
|
|
4273
|
+
return this.node(start, {
|
|
4274
|
+
kind: Kind.UNION_TYPE_DEFINITION,
|
|
4275
|
+
description,
|
|
4276
|
+
name,
|
|
4277
|
+
directives,
|
|
4278
|
+
types
|
|
4279
|
+
});
|
|
4280
|
+
}
|
|
4281
|
+
/**
|
|
4282
|
+
* UnionMemberTypes :
|
|
4283
|
+
* - = `|`? NamedType
|
|
4284
|
+
* - UnionMemberTypes | NamedType
|
|
4285
|
+
*/
|
|
4286
|
+
parseUnionMemberTypes() {
|
|
4287
|
+
return this.expectOptionalToken(TokenKind.EQUALS) ? this.delimitedMany(TokenKind.PIPE, this.parseNamedType) : [];
|
|
4288
|
+
}
|
|
4289
|
+
/**
|
|
4290
|
+
* EnumTypeDefinition :
|
|
4291
|
+
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
4292
|
+
*/
|
|
4293
|
+
parseEnumTypeDefinition() {
|
|
4294
|
+
const start = this._lexer.token;
|
|
4295
|
+
const description = this.parseDescription();
|
|
4296
|
+
this.expectKeyword("enum");
|
|
4297
|
+
const name = this.parseName();
|
|
4298
|
+
const directives = this.parseConstDirectives();
|
|
4299
|
+
const values = this.parseEnumValuesDefinition();
|
|
4300
|
+
return this.node(start, {
|
|
4301
|
+
kind: Kind.ENUM_TYPE_DEFINITION,
|
|
4302
|
+
description,
|
|
4303
|
+
name,
|
|
4304
|
+
directives,
|
|
4305
|
+
values
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
/**
|
|
4309
|
+
* ```
|
|
4310
|
+
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
4311
|
+
* ```
|
|
4312
|
+
*/
|
|
4313
|
+
parseEnumValuesDefinition() {
|
|
4314
|
+
return this.optionalMany(
|
|
4315
|
+
TokenKind.BRACE_L,
|
|
4316
|
+
this.parseEnumValueDefinition,
|
|
4317
|
+
TokenKind.BRACE_R
|
|
4318
|
+
);
|
|
4319
|
+
}
|
|
4320
|
+
/**
|
|
4321
|
+
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
4322
|
+
*/
|
|
4323
|
+
parseEnumValueDefinition() {
|
|
4324
|
+
const start = this._lexer.token;
|
|
4325
|
+
const description = this.parseDescription();
|
|
4326
|
+
const name = this.parseEnumValueName();
|
|
4327
|
+
const directives = this.parseConstDirectives();
|
|
4328
|
+
return this.node(start, {
|
|
4329
|
+
kind: Kind.ENUM_VALUE_DEFINITION,
|
|
4330
|
+
description,
|
|
4331
|
+
name,
|
|
4332
|
+
directives
|
|
4333
|
+
});
|
|
4334
|
+
}
|
|
4335
|
+
/**
|
|
4336
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
4337
|
+
*/
|
|
4338
|
+
parseEnumValueName() {
|
|
4339
|
+
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null") {
|
|
4340
|
+
throw syntaxError(
|
|
4341
|
+
this._lexer.source,
|
|
4342
|
+
this._lexer.token.start,
|
|
4343
|
+
`${getTokenDesc(
|
|
4344
|
+
this._lexer.token
|
|
4345
|
+
)} is reserved and cannot be used for an enum value.`
|
|
4346
|
+
);
|
|
4347
|
+
}
|
|
4348
|
+
return this.parseName();
|
|
4349
|
+
}
|
|
4350
|
+
/**
|
|
4351
|
+
* InputObjectTypeDefinition :
|
|
4352
|
+
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
4353
|
+
*/
|
|
4354
|
+
parseInputObjectTypeDefinition() {
|
|
4355
|
+
const start = this._lexer.token;
|
|
4356
|
+
const description = this.parseDescription();
|
|
4357
|
+
this.expectKeyword("input");
|
|
4358
|
+
const name = this.parseName();
|
|
4359
|
+
const directives = this.parseConstDirectives();
|
|
4360
|
+
const fields = this.parseInputFieldsDefinition();
|
|
4361
|
+
return this.node(start, {
|
|
4362
|
+
kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
4363
|
+
description,
|
|
4364
|
+
name,
|
|
4365
|
+
directives,
|
|
4366
|
+
fields
|
|
4367
|
+
});
|
|
4368
|
+
}
|
|
4369
|
+
/**
|
|
4370
|
+
* ```
|
|
4371
|
+
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
4372
|
+
* ```
|
|
4373
|
+
*/
|
|
4374
|
+
parseInputFieldsDefinition() {
|
|
4375
|
+
return this.optionalMany(
|
|
4376
|
+
TokenKind.BRACE_L,
|
|
4377
|
+
this.parseInputValueDef,
|
|
4378
|
+
TokenKind.BRACE_R
|
|
4379
|
+
);
|
|
4380
|
+
}
|
|
4381
|
+
/**
|
|
4382
|
+
* TypeSystemExtension :
|
|
4383
|
+
* - SchemaExtension
|
|
4384
|
+
* - TypeExtension
|
|
4385
|
+
*
|
|
4386
|
+
* TypeExtension :
|
|
4387
|
+
* - ScalarTypeExtension
|
|
4388
|
+
* - ObjectTypeExtension
|
|
4389
|
+
* - InterfaceTypeExtension
|
|
4390
|
+
* - UnionTypeExtension
|
|
4391
|
+
* - EnumTypeExtension
|
|
4392
|
+
* - InputObjectTypeDefinition
|
|
4393
|
+
* - DirectiveDefinitionExtension
|
|
4394
|
+
*/
|
|
4395
|
+
parseTypeSystemExtension() {
|
|
4396
|
+
const keywordToken = this._lexer.lookahead();
|
|
4397
|
+
if (keywordToken.kind === TokenKind.NAME) {
|
|
4398
|
+
switch (keywordToken.value) {
|
|
4399
|
+
case "schema":
|
|
4400
|
+
return this.parseSchemaExtension();
|
|
4401
|
+
case "scalar":
|
|
4402
|
+
return this.parseScalarTypeExtension();
|
|
4403
|
+
case "type":
|
|
4404
|
+
return this.parseObjectTypeExtension();
|
|
4405
|
+
case "interface":
|
|
4406
|
+
return this.parseInterfaceTypeExtension();
|
|
4407
|
+
case "union":
|
|
4408
|
+
return this.parseUnionTypeExtension();
|
|
4409
|
+
case "enum":
|
|
4410
|
+
return this.parseEnumTypeExtension();
|
|
4411
|
+
case "input":
|
|
4412
|
+
return this.parseInputObjectTypeExtension();
|
|
4413
|
+
case "directive":
|
|
4414
|
+
if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
|
|
4415
|
+
return this.parseDirectiveDefinitionExtension();
|
|
4416
|
+
}
|
|
4417
|
+
break;
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
throw this.unexpected(keywordToken);
|
|
4421
|
+
}
|
|
4422
|
+
/**
|
|
4423
|
+
* ```
|
|
4424
|
+
* SchemaExtension :
|
|
4425
|
+
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
4426
|
+
* - extend schema Directives[Const]
|
|
4427
|
+
* ```
|
|
4428
|
+
*/
|
|
4429
|
+
parseSchemaExtension() {
|
|
4430
|
+
const start = this._lexer.token;
|
|
4431
|
+
this.expectKeyword("extend");
|
|
4432
|
+
this.expectKeyword("schema");
|
|
4433
|
+
const directives = this.parseConstDirectives();
|
|
4434
|
+
const operationTypes = this.optionalMany(
|
|
4435
|
+
TokenKind.BRACE_L,
|
|
4436
|
+
this.parseOperationTypeDefinition,
|
|
4437
|
+
TokenKind.BRACE_R
|
|
4438
|
+
);
|
|
4439
|
+
if (directives.length === 0 && operationTypes.length === 0) {
|
|
4440
|
+
throw this.unexpected();
|
|
4441
|
+
}
|
|
4442
|
+
return this.node(start, {
|
|
4443
|
+
kind: Kind.SCHEMA_EXTENSION,
|
|
4444
|
+
directives,
|
|
4445
|
+
operationTypes
|
|
4446
|
+
});
|
|
4447
|
+
}
|
|
4448
|
+
/**
|
|
4449
|
+
* ScalarTypeExtension :
|
|
4450
|
+
* - extend scalar Name Directives[Const]
|
|
4451
|
+
*/
|
|
4452
|
+
parseScalarTypeExtension() {
|
|
4453
|
+
const start = this._lexer.token;
|
|
4454
|
+
this.expectKeyword("extend");
|
|
4455
|
+
this.expectKeyword("scalar");
|
|
4456
|
+
const name = this.parseName();
|
|
4457
|
+
const directives = this.parseConstDirectives();
|
|
4458
|
+
if (directives.length === 0) {
|
|
4459
|
+
throw this.unexpected();
|
|
4460
|
+
}
|
|
4461
|
+
return this.node(start, {
|
|
4462
|
+
kind: Kind.SCALAR_TYPE_EXTENSION,
|
|
4463
|
+
name,
|
|
4464
|
+
directives
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4467
|
+
/**
|
|
4468
|
+
* ObjectTypeExtension :
|
|
4469
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
4470
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
4471
|
+
* - extend type Name ImplementsInterfaces
|
|
4472
|
+
*/
|
|
4473
|
+
parseObjectTypeExtension() {
|
|
4474
|
+
const start = this._lexer.token;
|
|
4475
|
+
this.expectKeyword("extend");
|
|
4476
|
+
this.expectKeyword("type");
|
|
4477
|
+
const name = this.parseName();
|
|
4478
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4479
|
+
const directives = this.parseConstDirectives();
|
|
4480
|
+
const fields = this.parseFieldsDefinition();
|
|
4481
|
+
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
|
|
4482
|
+
throw this.unexpected();
|
|
4483
|
+
}
|
|
4484
|
+
return this.node(start, {
|
|
4485
|
+
kind: Kind.OBJECT_TYPE_EXTENSION,
|
|
4486
|
+
name,
|
|
4487
|
+
interfaces,
|
|
4488
|
+
directives,
|
|
4489
|
+
fields
|
|
4490
|
+
});
|
|
4491
|
+
}
|
|
4492
|
+
/**
|
|
4493
|
+
* InterfaceTypeExtension :
|
|
4494
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
4495
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
4496
|
+
* - extend interface Name ImplementsInterfaces
|
|
4497
|
+
*/
|
|
4498
|
+
parseInterfaceTypeExtension() {
|
|
4499
|
+
const start = this._lexer.token;
|
|
4500
|
+
this.expectKeyword("extend");
|
|
4501
|
+
this.expectKeyword("interface");
|
|
4502
|
+
const name = this.parseName();
|
|
4503
|
+
const interfaces = this.parseImplementsInterfaces();
|
|
4504
|
+
const directives = this.parseConstDirectives();
|
|
4505
|
+
const fields = this.parseFieldsDefinition();
|
|
4506
|
+
if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
|
|
4507
|
+
throw this.unexpected();
|
|
4508
|
+
}
|
|
4509
|
+
return this.node(start, {
|
|
4510
|
+
kind: Kind.INTERFACE_TYPE_EXTENSION,
|
|
4511
|
+
name,
|
|
4512
|
+
interfaces,
|
|
4513
|
+
directives,
|
|
4514
|
+
fields
|
|
4515
|
+
});
|
|
4516
|
+
}
|
|
4517
|
+
/**
|
|
4518
|
+
* UnionTypeExtension :
|
|
4519
|
+
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
4520
|
+
* - extend union Name Directives[Const]
|
|
4521
|
+
*/
|
|
4522
|
+
parseUnionTypeExtension() {
|
|
4523
|
+
const start = this._lexer.token;
|
|
4524
|
+
this.expectKeyword("extend");
|
|
4525
|
+
this.expectKeyword("union");
|
|
4526
|
+
const name = this.parseName();
|
|
4527
|
+
const directives = this.parseConstDirectives();
|
|
4528
|
+
const types = this.parseUnionMemberTypes();
|
|
4529
|
+
if (directives.length === 0 && types.length === 0) {
|
|
4530
|
+
throw this.unexpected();
|
|
4531
|
+
}
|
|
4532
|
+
return this.node(start, {
|
|
4533
|
+
kind: Kind.UNION_TYPE_EXTENSION,
|
|
4534
|
+
name,
|
|
4535
|
+
directives,
|
|
4536
|
+
types
|
|
4537
|
+
});
|
|
4538
|
+
}
|
|
4539
|
+
/**
|
|
4540
|
+
* EnumTypeExtension :
|
|
4541
|
+
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
4542
|
+
* - extend enum Name Directives[Const]
|
|
4543
|
+
*/
|
|
4544
|
+
parseEnumTypeExtension() {
|
|
4545
|
+
const start = this._lexer.token;
|
|
4546
|
+
this.expectKeyword("extend");
|
|
4547
|
+
this.expectKeyword("enum");
|
|
4548
|
+
const name = this.parseName();
|
|
4549
|
+
const directives = this.parseConstDirectives();
|
|
4550
|
+
const values = this.parseEnumValuesDefinition();
|
|
4551
|
+
if (directives.length === 0 && values.length === 0) {
|
|
4552
|
+
throw this.unexpected();
|
|
4553
|
+
}
|
|
4554
|
+
return this.node(start, {
|
|
4555
|
+
kind: Kind.ENUM_TYPE_EXTENSION,
|
|
4556
|
+
name,
|
|
4557
|
+
directives,
|
|
4558
|
+
values
|
|
4559
|
+
});
|
|
4560
|
+
}
|
|
4561
|
+
/**
|
|
4562
|
+
* InputObjectTypeExtension :
|
|
4563
|
+
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
4564
|
+
* - extend input Name Directives[Const]
|
|
4565
|
+
*/
|
|
4566
|
+
parseInputObjectTypeExtension() {
|
|
4567
|
+
const start = this._lexer.token;
|
|
4568
|
+
this.expectKeyword("extend");
|
|
4569
|
+
this.expectKeyword("input");
|
|
4570
|
+
const name = this.parseName();
|
|
4571
|
+
const directives = this.parseConstDirectives();
|
|
4572
|
+
const fields = this.parseInputFieldsDefinition();
|
|
4573
|
+
if (directives.length === 0 && fields.length === 0) {
|
|
4574
|
+
throw this.unexpected();
|
|
4575
|
+
}
|
|
4576
|
+
return this.node(start, {
|
|
4577
|
+
kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
|
|
4578
|
+
name,
|
|
4579
|
+
directives,
|
|
4580
|
+
fields
|
|
4581
|
+
});
|
|
4582
|
+
}
|
|
4583
|
+
parseDirectiveDefinitionExtension() {
|
|
4584
|
+
const start = this._lexer.token;
|
|
4585
|
+
this.expectKeyword("extend");
|
|
4586
|
+
this.expectKeyword("directive");
|
|
4587
|
+
this.expectToken(TokenKind.AT);
|
|
4588
|
+
const name = this.parseName();
|
|
4589
|
+
const directives = this.parseConstDirectives();
|
|
4590
|
+
if (directives.length === 0) {
|
|
4591
|
+
throw this.unexpected();
|
|
4592
|
+
}
|
|
4593
|
+
return this.node(start, {
|
|
4594
|
+
kind: Kind.DIRECTIVE_EXTENSION,
|
|
4595
|
+
name,
|
|
4596
|
+
directives
|
|
4597
|
+
});
|
|
1887
4598
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
4599
|
+
/**
|
|
4600
|
+
* ```
|
|
4601
|
+
* DirectiveDefinition :
|
|
4602
|
+
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
4603
|
+
* ```
|
|
4604
|
+
*/
|
|
4605
|
+
parseDirectiveDefinition() {
|
|
4606
|
+
const start = this._lexer.token;
|
|
4607
|
+
const description = this.parseDescription();
|
|
4608
|
+
this.expectKeyword("directive");
|
|
4609
|
+
this.expectToken(TokenKind.AT);
|
|
4610
|
+
const name = this.parseName();
|
|
4611
|
+
const args = this.parseArgumentDefs();
|
|
4612
|
+
const directives = this._options.experimentalDirectivesOnDirectiveDefinitions ? this.parseConstDirectives() : [];
|
|
4613
|
+
const repeatable = this.expectOptionalKeyword("repeatable");
|
|
4614
|
+
this.expectKeyword("on");
|
|
4615
|
+
const locations = this.parseDirectiveLocations();
|
|
4616
|
+
return this.node(start, {
|
|
4617
|
+
kind: Kind.DIRECTIVE_DEFINITION,
|
|
4618
|
+
description,
|
|
4619
|
+
name,
|
|
4620
|
+
arguments: args,
|
|
4621
|
+
directives,
|
|
4622
|
+
repeatable,
|
|
4623
|
+
locations
|
|
4624
|
+
});
|
|
4625
|
+
}
|
|
4626
|
+
/**
|
|
4627
|
+
* DirectiveLocations :
|
|
4628
|
+
* - `|`? DirectiveLocation
|
|
4629
|
+
* - DirectiveLocations | DirectiveLocation
|
|
4630
|
+
*/
|
|
4631
|
+
parseDirectiveLocations() {
|
|
4632
|
+
return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
|
|
4633
|
+
}
|
|
4634
|
+
/*
|
|
4635
|
+
* DirectiveLocation :
|
|
4636
|
+
* - ExecutableDirectiveLocation
|
|
4637
|
+
* - TypeSystemDirectiveLocation
|
|
4638
|
+
*
|
|
4639
|
+
* ExecutableDirectiveLocation : one of
|
|
4640
|
+
* `QUERY`
|
|
4641
|
+
* `MUTATION`
|
|
4642
|
+
* `SUBSCRIPTION`
|
|
4643
|
+
* `FIELD`
|
|
4644
|
+
* `FRAGMENT_DEFINITION`
|
|
4645
|
+
* `FRAGMENT_SPREAD`
|
|
4646
|
+
* `INLINE_FRAGMENT`
|
|
4647
|
+
*
|
|
4648
|
+
* TypeSystemDirectiveLocation : one of
|
|
4649
|
+
* `SCHEMA`
|
|
4650
|
+
* `SCALAR`
|
|
4651
|
+
* `OBJECT`
|
|
4652
|
+
* `FIELD_DEFINITION`
|
|
4653
|
+
* `ARGUMENT_DEFINITION`
|
|
4654
|
+
* `INTERFACE`
|
|
4655
|
+
* `UNION`
|
|
4656
|
+
* `ENUM`
|
|
4657
|
+
* `ENUM_VALUE`
|
|
4658
|
+
* `INPUT_OBJECT`
|
|
4659
|
+
* `INPUT_FIELD_DEFINITION`
|
|
4660
|
+
* `DIRECTIVE_DEFINITION`
|
|
4661
|
+
*/
|
|
4662
|
+
parseDirectiveLocation() {
|
|
4663
|
+
const start = this._lexer.token;
|
|
4664
|
+
const name = this.parseName();
|
|
4665
|
+
if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
|
|
4666
|
+
return name;
|
|
4667
|
+
}
|
|
4668
|
+
throw this.unexpected(start);
|
|
4669
|
+
}
|
|
4670
|
+
// Schema Coordinates
|
|
4671
|
+
/**
|
|
4672
|
+
* SchemaCoordinate :
|
|
4673
|
+
* - Name
|
|
4674
|
+
* - Name . Name
|
|
4675
|
+
* - Name . Name ( Name : )
|
|
4676
|
+
* - \@ Name
|
|
4677
|
+
* - \@ Name ( Name : )
|
|
4678
|
+
*/
|
|
4679
|
+
parseSchemaCoordinate() {
|
|
4680
|
+
const start = this._lexer.token;
|
|
4681
|
+
const ofDirective = this.expectOptionalToken(TokenKind.AT);
|
|
4682
|
+
const name = this.parseName();
|
|
4683
|
+
let memberName;
|
|
4684
|
+
if (!ofDirective && this.expectOptionalToken(TokenKind.DOT)) {
|
|
4685
|
+
memberName = this.parseName();
|
|
4686
|
+
}
|
|
4687
|
+
let argumentName;
|
|
4688
|
+
if ((ofDirective || memberName) && this.expectOptionalToken(TokenKind.PAREN_L)) {
|
|
4689
|
+
argumentName = this.parseName();
|
|
4690
|
+
this.expectToken(TokenKind.COLON);
|
|
4691
|
+
this.expectToken(TokenKind.PAREN_R);
|
|
4692
|
+
}
|
|
4693
|
+
if (ofDirective) {
|
|
4694
|
+
if (argumentName) {
|
|
4695
|
+
return this.node(start, {
|
|
4696
|
+
kind: Kind.DIRECTIVE_ARGUMENT_COORDINATE,
|
|
4697
|
+
name,
|
|
4698
|
+
argumentName
|
|
4699
|
+
});
|
|
4700
|
+
}
|
|
4701
|
+
return this.node(start, {
|
|
4702
|
+
kind: Kind.DIRECTIVE_COORDINATE,
|
|
4703
|
+
name
|
|
4704
|
+
});
|
|
4705
|
+
} else if (memberName) {
|
|
4706
|
+
if (argumentName) {
|
|
4707
|
+
return this.node(start, {
|
|
4708
|
+
kind: Kind.ARGUMENT_COORDINATE,
|
|
4709
|
+
name,
|
|
4710
|
+
fieldName: memberName,
|
|
4711
|
+
argumentName
|
|
4712
|
+
});
|
|
4713
|
+
}
|
|
4714
|
+
return this.node(start, {
|
|
4715
|
+
kind: Kind.MEMBER_COORDINATE,
|
|
4716
|
+
name,
|
|
4717
|
+
memberName
|
|
4718
|
+
});
|
|
1892
4719
|
}
|
|
4720
|
+
return this.node(start, {
|
|
4721
|
+
kind: Kind.TYPE_COORDINATE,
|
|
4722
|
+
name
|
|
4723
|
+
});
|
|
1893
4724
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
4725
|
+
// Core parsing utility functions
|
|
4726
|
+
/**
|
|
4727
|
+
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
4728
|
+
* location object, used to identify the place in the source that created a
|
|
4729
|
+
* given parsed object.
|
|
4730
|
+
*/
|
|
4731
|
+
node(startToken, node) {
|
|
4732
|
+
if (this._options.noLocation !== true) {
|
|
4733
|
+
node.loc = new Location(
|
|
4734
|
+
startToken,
|
|
4735
|
+
this._lexer.lastToken,
|
|
4736
|
+
this._lexer.source
|
|
4737
|
+
);
|
|
4738
|
+
}
|
|
4739
|
+
return node;
|
|
4740
|
+
}
|
|
4741
|
+
/**
|
|
4742
|
+
* Determines if the next token is of a given kind
|
|
4743
|
+
*/
|
|
4744
|
+
peek(kind) {
|
|
4745
|
+
return this._lexer.token.kind === kind;
|
|
4746
|
+
}
|
|
4747
|
+
/**
|
|
4748
|
+
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
4749
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
4750
|
+
*/
|
|
4751
|
+
expectToken(kind) {
|
|
4752
|
+
const token = this._lexer.token;
|
|
4753
|
+
if (token.kind === kind) {
|
|
4754
|
+
this.advanceLexer();
|
|
4755
|
+
return token;
|
|
4756
|
+
}
|
|
4757
|
+
throw syntaxError(
|
|
4758
|
+
this._lexer.source,
|
|
4759
|
+
token.start,
|
|
4760
|
+
`Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
|
|
4761
|
+
);
|
|
1896
4762
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
4763
|
+
/**
|
|
4764
|
+
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
4765
|
+
* Otherwise, do not change the parser state and return "false".
|
|
4766
|
+
*/
|
|
4767
|
+
expectOptionalToken(kind) {
|
|
4768
|
+
const token = this._lexer.token;
|
|
4769
|
+
if (token.kind === kind) {
|
|
4770
|
+
this.advanceLexer();
|
|
4771
|
+
return true;
|
|
1901
4772
|
}
|
|
4773
|
+
return false;
|
|
1902
4774
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
4775
|
+
/**
|
|
4776
|
+
* If the next token is a given keyword, advance the lexer.
|
|
4777
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
4778
|
+
*/
|
|
4779
|
+
expectKeyword(value) {
|
|
4780
|
+
const token = this._lexer.token;
|
|
4781
|
+
if (token.kind === TokenKind.NAME && token.value === value) {
|
|
4782
|
+
this.advanceLexer();
|
|
4783
|
+
} else {
|
|
4784
|
+
throw syntaxError(
|
|
4785
|
+
this._lexer.source,
|
|
4786
|
+
token.start,
|
|
4787
|
+
`Expected "${value}", found ${getTokenDesc(token)}.`
|
|
4788
|
+
);
|
|
4789
|
+
}
|
|
1905
4790
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
}
|
|
1918
|
-
function ensureFlag(args, flag) {
|
|
1919
|
-
if (!args.includes(flag)) {
|
|
1920
|
-
args.push(flag);
|
|
4791
|
+
/**
|
|
4792
|
+
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
4793
|
+
* Otherwise, do not change the parser state and return "false".
|
|
4794
|
+
*/
|
|
4795
|
+
expectOptionalKeyword(value) {
|
|
4796
|
+
const token = this._lexer.token;
|
|
4797
|
+
if (token.kind === TokenKind.NAME && token.value === value) {
|
|
4798
|
+
this.advanceLexer();
|
|
4799
|
+
return true;
|
|
4800
|
+
}
|
|
4801
|
+
return false;
|
|
1921
4802
|
}
|
|
1922
|
-
|
|
1923
|
-
function
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
return
|
|
4803
|
+
/**
|
|
4804
|
+
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
4805
|
+
*/
|
|
4806
|
+
unexpected(atToken) {
|
|
4807
|
+
const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
|
|
4808
|
+
return syntaxError(
|
|
4809
|
+
this._lexer.source,
|
|
4810
|
+
token.start,
|
|
4811
|
+
`Unexpected ${getTokenDesc(token)}.`
|
|
4812
|
+
);
|
|
1928
4813
|
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
4814
|
+
/**
|
|
4815
|
+
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
4816
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4817
|
+
* Advances the parser to the next lex token after the closing token.
|
|
4818
|
+
*/
|
|
4819
|
+
any(openKind, parseFn, closeKind) {
|
|
4820
|
+
this.expectToken(openKind);
|
|
4821
|
+
const nodes = [];
|
|
4822
|
+
while (!this.expectOptionalToken(closeKind)) {
|
|
4823
|
+
nodes.push(parseFn.call(this));
|
|
4824
|
+
}
|
|
4825
|
+
return nodes;
|
|
4826
|
+
}
|
|
4827
|
+
/**
|
|
4828
|
+
* Returns a list of parse nodes, determined by the parseFn.
|
|
4829
|
+
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
4830
|
+
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4831
|
+
* Advances the parser to the next lex token after the closing token.
|
|
4832
|
+
*/
|
|
4833
|
+
optionalMany(openKind, parseFn, closeKind) {
|
|
4834
|
+
if (this.expectOptionalToken(openKind)) {
|
|
4835
|
+
const nodes = [];
|
|
4836
|
+
do {
|
|
4837
|
+
nodes.push(parseFn.call(this));
|
|
4838
|
+
} while (!this.expectOptionalToken(closeKind));
|
|
4839
|
+
return nodes;
|
|
4840
|
+
}
|
|
4841
|
+
return [];
|
|
1933
4842
|
}
|
|
1934
|
-
|
|
1935
|
-
|
|
4843
|
+
/**
|
|
4844
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
4845
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
4846
|
+
* Advances the parser to the next lex token after the closing token.
|
|
4847
|
+
*/
|
|
4848
|
+
many(openKind, parseFn, closeKind) {
|
|
4849
|
+
this.expectToken(openKind);
|
|
4850
|
+
const nodes = [];
|
|
4851
|
+
do {
|
|
4852
|
+
nodes.push(parseFn.call(this));
|
|
4853
|
+
} while (!this.expectOptionalToken(closeKind));
|
|
4854
|
+
return nodes;
|
|
4855
|
+
}
|
|
4856
|
+
/**
|
|
4857
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
4858
|
+
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
4859
|
+
* Advances the parser to the next lex token after last item in the list.
|
|
4860
|
+
*/
|
|
4861
|
+
delimitedMany(delimiterKind, parseFn) {
|
|
4862
|
+
this.expectOptionalToken(delimiterKind);
|
|
4863
|
+
const nodes = [];
|
|
4864
|
+
do {
|
|
4865
|
+
nodes.push(parseFn.call(this));
|
|
4866
|
+
} while (this.expectOptionalToken(delimiterKind));
|
|
4867
|
+
return nodes;
|
|
4868
|
+
}
|
|
4869
|
+
advanceLexer() {
|
|
4870
|
+
const { maxTokens } = this._options;
|
|
4871
|
+
const token = this._lexer.advance();
|
|
4872
|
+
if (token.kind !== TokenKind.EOF) {
|
|
4873
|
+
++this._tokenCounter;
|
|
4874
|
+
if (maxTokens !== void 0 && this._tokenCounter > maxTokens) {
|
|
4875
|
+
throw syntaxError(
|
|
4876
|
+
this._lexer.source,
|
|
4877
|
+
token.start,
|
|
4878
|
+
`Document contains more that ${maxTokens} tokens. Parsing aborted.`
|
|
4879
|
+
);
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
1936
4882
|
}
|
|
4883
|
+
};
|
|
4884
|
+
function getTokenDesc(token) {
|
|
4885
|
+
const value = token.value;
|
|
4886
|
+
return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
|
|
4887
|
+
}
|
|
4888
|
+
function getTokenKindDesc(kind) {
|
|
4889
|
+
return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
|
|
1937
4890
|
}
|
|
1938
4891
|
|
|
1939
|
-
// ../
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
import { readFile as readFile5, writeFile as writeFile2 } from "fs/promises";
|
|
1945
|
-
var DEFAULT_GITHUB_GRAPHQL_API_URL = "https://api.github.com/graphql";
|
|
1946
|
-
var TOKEN_REUSE_WINDOW_MS2 = 60 * 1e3;
|
|
1947
|
-
async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
|
|
1948
|
-
const token = await resolveGitHubGraphQLToken(config, {
|
|
1949
|
-
fetchImpl
|
|
1950
|
-
});
|
|
4892
|
+
// ../tool-linear-graphql/src/tool.ts
|
|
4893
|
+
var DEFAULT_LINEAR_GRAPHQL_API_URL = "https://api.linear.app/graphql";
|
|
4894
|
+
async function executeLinearGraphQL(invocation, config, fetchImpl = fetch) {
|
|
4895
|
+
validateLinearGraphQLInvocation(invocation);
|
|
4896
|
+
const authorization = resolveLinearAuthorizationHeader(config);
|
|
1951
4897
|
const response = await fetchImpl(
|
|
1952
|
-
config.apiUrl ??
|
|
4898
|
+
config.apiUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL,
|
|
1953
4899
|
{
|
|
1954
4900
|
method: "POST",
|
|
1955
4901
|
headers: {
|
|
1956
4902
|
"content-type": "application/json",
|
|
1957
|
-
authorization
|
|
4903
|
+
authorization
|
|
1958
4904
|
},
|
|
1959
4905
|
body: JSON.stringify(invocation)
|
|
1960
4906
|
}
|
|
@@ -1962,7 +4908,7 @@ async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
|
|
|
1962
4908
|
const payload = await response.json();
|
|
1963
4909
|
if (!response.ok) {
|
|
1964
4910
|
throw new Error(
|
|
1965
|
-
`
|
|
4911
|
+
`Linear GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
|
|
1966
4912
|
);
|
|
1967
4913
|
}
|
|
1968
4914
|
if (payload.errors?.length) {
|
|
@@ -1970,95 +4916,71 @@ async function executeGitHubGraphQL(invocation, config, fetchImpl = fetch) {
|
|
|
1970
4916
|
}
|
|
1971
4917
|
return payload;
|
|
1972
4918
|
}
|
|
1973
|
-
|
|
1974
|
-
if (
|
|
1975
|
-
return config.token;
|
|
1976
|
-
}
|
|
1977
|
-
if (!config.tokenBrokerUrl || !config.tokenBrokerSecret) {
|
|
4919
|
+
function validateLinearGraphQLInvocation(invocation) {
|
|
4920
|
+
if (typeof invocation.query !== "string" || invocation.query.trim() === "") {
|
|
1978
4921
|
throw new Error(
|
|
1979
|
-
"
|
|
4922
|
+
"linear_graphql requires a non-empty GraphQL query string."
|
|
1980
4923
|
);
|
|
1981
4924
|
}
|
|
1982
|
-
const
|
|
1983
|
-
const
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
if (
|
|
1987
|
-
return cachedToken.token;
|
|
1988
|
-
}
|
|
1989
|
-
const fetchImpl = dependencies.fetchImpl ?? fetch;
|
|
1990
|
-
const response = await fetchImpl(config.tokenBrokerUrl, {
|
|
1991
|
-
method: "POST",
|
|
1992
|
-
headers: {
|
|
1993
|
-
accept: "application/json",
|
|
1994
|
-
authorization: `Bearer ${config.tokenBrokerSecret}`
|
|
1995
|
-
}
|
|
1996
|
-
});
|
|
1997
|
-
const payload = await response.json();
|
|
1998
|
-
if (!response.ok || !payload.token || !payload.expiresAt) {
|
|
4925
|
+
const document = parse(invocation.query);
|
|
4926
|
+
const operationCount = document.definitions.filter(
|
|
4927
|
+
(definition) => definition.kind === "OperationDefinition"
|
|
4928
|
+
).length;
|
|
4929
|
+
if (operationCount !== 1) {
|
|
1999
4930
|
throw new Error(
|
|
2000
|
-
|
|
4931
|
+
"linear_graphql accepts exactly one GraphQL operation per request; split multi-operation documents before calling Linear."
|
|
2001
4932
|
);
|
|
2002
4933
|
}
|
|
2003
|
-
|
|
2004
|
-
|
|
4934
|
+
}
|
|
4935
|
+
function resolveLinearAuthorizationHeader(config) {
|
|
4936
|
+
if (config.authorizationHeader) {
|
|
4937
|
+
return config.authorizationHeader;
|
|
2005
4938
|
}
|
|
2006
|
-
|
|
4939
|
+
if (config.apiKey) {
|
|
4940
|
+
return `Bearer ${config.apiKey}`;
|
|
4941
|
+
}
|
|
4942
|
+
throw new Error(
|
|
4943
|
+
"Linear GraphQL auth is not configured; provide runtime LINEAR_AUTHORIZATION or LINEAR_API_KEY."
|
|
4944
|
+
);
|
|
2007
4945
|
}
|
|
2008
|
-
async function
|
|
4946
|
+
async function readStdin2() {
|
|
2009
4947
|
const chunks = [];
|
|
2010
4948
|
for await (const chunk of process.stdin) {
|
|
2011
4949
|
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
2012
4950
|
}
|
|
2013
4951
|
return Buffer.concat(chunks).toString("utf8");
|
|
2014
4952
|
}
|
|
2015
|
-
async function
|
|
2016
|
-
const rawInput = await
|
|
4953
|
+
async function main3() {
|
|
4954
|
+
const rawInput = await readStdin2();
|
|
2017
4955
|
const invocation = JSON.parse(rawInput);
|
|
2018
|
-
const result = await
|
|
2019
|
-
|
|
2020
|
-
apiUrl: process.env.
|
|
2021
|
-
|
|
2022
|
-
tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2023
|
-
tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
|
|
4956
|
+
const result = await executeLinearGraphQL(invocation, {
|
|
4957
|
+
apiKey: process.env.LINEAR_API_KEY,
|
|
4958
|
+
apiUrl: process.env.LINEAR_GRAPHQL_URL,
|
|
4959
|
+
authorizationHeader: process.env.LINEAR_AUTHORIZATION
|
|
2024
4960
|
});
|
|
2025
4961
|
process.stdout.write(`${JSON.stringify(result)}
|
|
2026
4962
|
`);
|
|
2027
4963
|
}
|
|
2028
4964
|
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
2029
|
-
|
|
4965
|
+
main3().catch((error) => {
|
|
2030
4966
|
const message = error instanceof Error ? error.message : "Unknown error";
|
|
2031
4967
|
process.stderr.write(`${message}
|
|
2032
4968
|
`);
|
|
2033
4969
|
process.exitCode = 1;
|
|
2034
4970
|
});
|
|
2035
4971
|
}
|
|
2036
|
-
async function readCachedToken(path, readFileImpl) {
|
|
2037
|
-
try {
|
|
2038
|
-
const payload = JSON.parse(await readFileImpl(path, "utf8"));
|
|
2039
|
-
if (!payload.token || !payload.expiresAt) {
|
|
2040
|
-
return null;
|
|
2041
|
-
}
|
|
2042
|
-
return {
|
|
2043
|
-
token: payload.token,
|
|
2044
|
-
expiresAt: new Date(payload.expiresAt)
|
|
2045
|
-
};
|
|
2046
|
-
} catch {
|
|
2047
|
-
return null;
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
4972
|
|
|
2051
|
-
// ../tool-
|
|
2052
|
-
import { fileURLToPath } from "url";
|
|
2053
|
-
var
|
|
2054
|
-
name: "
|
|
2055
|
-
description: "Execute
|
|
4973
|
+
// ../tool-linear-graphql/src/mcp-server.ts
|
|
4974
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4975
|
+
var TOOL_SCHEMA2 = {
|
|
4976
|
+
name: "linear_graphql",
|
|
4977
|
+
description: "Execute a single Linear GraphQL query or mutation for the active Linear issue using runtime-managed auth.",
|
|
2056
4978
|
inputSchema: {
|
|
2057
4979
|
type: "object",
|
|
2058
4980
|
properties: {
|
|
2059
4981
|
query: {
|
|
2060
4982
|
type: "string",
|
|
2061
|
-
description: "GraphQL query or mutation document."
|
|
4983
|
+
description: "Single GraphQL query or mutation document."
|
|
2062
4984
|
},
|
|
2063
4985
|
variables: {
|
|
2064
4986
|
type: "object",
|
|
@@ -2073,50 +4995,49 @@ var TOOL_SCHEMA = {
|
|
|
2073
4995
|
additionalProperties: false
|
|
2074
4996
|
}
|
|
2075
4997
|
};
|
|
2076
|
-
var
|
|
2077
|
-
function
|
|
2078
|
-
return
|
|
4998
|
+
var lineBuffer2 = "";
|
|
4999
|
+
function resolveLinearGraphQLMcpServerEntryPoint() {
|
|
5000
|
+
return fileURLToPath2(new URL("./mcp-server.js", import.meta.url));
|
|
2079
5001
|
}
|
|
2080
|
-
function
|
|
2081
|
-
|
|
2082
|
-
|
|
5002
|
+
function sendResponse2(id, result) {
|
|
5003
|
+
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, result })}
|
|
5004
|
+
`);
|
|
2083
5005
|
}
|
|
2084
|
-
function
|
|
2085
|
-
|
|
2086
|
-
jsonrpc: "2.0",
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
});
|
|
2090
|
-
process.stdout.write(msg + "\n");
|
|
5006
|
+
function sendError2(id, code, message) {
|
|
5007
|
+
process.stdout.write(
|
|
5008
|
+
`${JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } })}
|
|
5009
|
+
`
|
|
5010
|
+
);
|
|
2091
5011
|
}
|
|
2092
|
-
async function
|
|
5012
|
+
async function handleRequest2(msg) {
|
|
2093
5013
|
const id = msg.id ?? null;
|
|
2094
5014
|
switch (msg.method) {
|
|
2095
5015
|
case "initialize": {
|
|
2096
|
-
|
|
5016
|
+
sendResponse2(id, {
|
|
2097
5017
|
protocolVersion: "2024-11-05",
|
|
2098
5018
|
capabilities: { tools: {} },
|
|
2099
5019
|
serverInfo: {
|
|
2100
|
-
name: "github-symphony-graphql",
|
|
5020
|
+
name: "github-symphony-linear-graphql",
|
|
2101
5021
|
version: "0.1.0"
|
|
2102
5022
|
}
|
|
2103
5023
|
});
|
|
2104
5024
|
process.stdout.write(
|
|
2105
|
-
JSON.stringify({
|
|
5025
|
+
`${JSON.stringify({
|
|
2106
5026
|
jsonrpc: "2.0",
|
|
2107
5027
|
method: "notifications/initialized"
|
|
2108
|
-
})
|
|
5028
|
+
})}
|
|
5029
|
+
`
|
|
2109
5030
|
);
|
|
2110
5031
|
break;
|
|
2111
5032
|
}
|
|
2112
5033
|
case "tools/list": {
|
|
2113
|
-
|
|
5034
|
+
sendResponse2(id, { tools: [TOOL_SCHEMA2] });
|
|
2114
5035
|
break;
|
|
2115
5036
|
}
|
|
2116
5037
|
case "tools/call": {
|
|
2117
5038
|
const params = msg.params;
|
|
2118
|
-
if (params.name !== "
|
|
2119
|
-
|
|
5039
|
+
if (params.name !== "linear_graphql") {
|
|
5040
|
+
sendError2(id, -32602, `Unknown tool: ${params.name}`);
|
|
2120
5041
|
return;
|
|
2121
5042
|
}
|
|
2122
5043
|
const args = params.arguments ?? {};
|
|
@@ -2126,14 +5047,12 @@ async function handleRequest(msg) {
|
|
|
2126
5047
|
operationName: args.operationName
|
|
2127
5048
|
};
|
|
2128
5049
|
try {
|
|
2129
|
-
const result = await
|
|
2130
|
-
|
|
2131
|
-
apiUrl: process.env.
|
|
2132
|
-
|
|
2133
|
-
tokenBrokerSecret: process.env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2134
|
-
tokenCachePath: process.env.GITHUB_TOKEN_CACHE_PATH
|
|
5050
|
+
const result = await executeLinearGraphQL(invocation, {
|
|
5051
|
+
apiKey: process.env.LINEAR_API_KEY,
|
|
5052
|
+
apiUrl: process.env.LINEAR_GRAPHQL_URL,
|
|
5053
|
+
authorizationHeader: process.env.LINEAR_AUTHORIZATION
|
|
2135
5054
|
});
|
|
2136
|
-
|
|
5055
|
+
sendResponse2(id, {
|
|
2137
5056
|
content: [
|
|
2138
5057
|
{
|
|
2139
5058
|
type: "text",
|
|
@@ -2143,7 +5062,7 @@ async function handleRequest(msg) {
|
|
|
2143
5062
|
});
|
|
2144
5063
|
} catch (err) {
|
|
2145
5064
|
const message = err instanceof Error ? err.message : String(err);
|
|
2146
|
-
|
|
5065
|
+
sendResponse2(id, {
|
|
2147
5066
|
content: [{ type: "text", text: message }],
|
|
2148
5067
|
isError: true
|
|
2149
5068
|
});
|
|
@@ -2153,32 +5072,32 @@ async function handleRequest(msg) {
|
|
|
2153
5072
|
case "notifications/initialized":
|
|
2154
5073
|
case "ping": {
|
|
2155
5074
|
if (id !== null && id !== void 0) {
|
|
2156
|
-
|
|
5075
|
+
sendResponse2(id, {});
|
|
2157
5076
|
}
|
|
2158
5077
|
break;
|
|
2159
5078
|
}
|
|
2160
5079
|
default: {
|
|
2161
5080
|
if (id !== null && id !== void 0) {
|
|
2162
|
-
|
|
5081
|
+
sendError2(id, -32601, `Method not found: ${msg.method}`);
|
|
2163
5082
|
}
|
|
2164
5083
|
}
|
|
2165
5084
|
}
|
|
2166
5085
|
}
|
|
2167
|
-
async function
|
|
5086
|
+
async function main4() {
|
|
2168
5087
|
process.stdin.setEncoding("utf8");
|
|
2169
5088
|
process.stdin.on("data", (chunk) => {
|
|
2170
|
-
|
|
2171
|
-
const lines =
|
|
2172
|
-
|
|
5089
|
+
lineBuffer2 += chunk;
|
|
5090
|
+
const lines = lineBuffer2.split("\n");
|
|
5091
|
+
lineBuffer2 = lines.pop() ?? "";
|
|
2173
5092
|
for (const line of lines) {
|
|
2174
5093
|
const trimmed = line.trim();
|
|
2175
5094
|
if (!trimmed) continue;
|
|
2176
5095
|
try {
|
|
2177
5096
|
const msg = JSON.parse(trimmed);
|
|
2178
|
-
void
|
|
5097
|
+
void handleRequest2(msg);
|
|
2179
5098
|
} catch (err) {
|
|
2180
5099
|
process.stderr.write(
|
|
2181
|
-
`[
|
|
5100
|
+
`[linear-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
|
|
2182
5101
|
`
|
|
2183
5102
|
);
|
|
2184
5103
|
}
|
|
@@ -2189,38 +5108,22 @@ async function main2() {
|
|
|
2189
5108
|
});
|
|
2190
5109
|
}
|
|
2191
5110
|
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
2192
|
-
|
|
5111
|
+
main4().catch((err) => {
|
|
2193
5112
|
process.stderr.write(
|
|
2194
|
-
`[
|
|
5113
|
+
`[linear-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
|
|
2195
5114
|
`
|
|
2196
5115
|
);
|
|
2197
5116
|
process.exitCode = 1;
|
|
2198
5117
|
});
|
|
2199
5118
|
}
|
|
2200
5119
|
|
|
2201
|
-
// ../tool-
|
|
2202
|
-
|
|
2203
|
-
function createGitHubGraphQLMcpServerEntry(options = {}) {
|
|
5120
|
+
// ../tool-linear-graphql/src/mcp-entry.ts
|
|
5121
|
+
function createLinearGraphQLMcpServerEntry(options = {}) {
|
|
2204
5122
|
return {
|
|
2205
5123
|
command: "node",
|
|
2206
|
-
args: [
|
|
5124
|
+
args: [resolveLinearGraphQLMcpServerEntryPoint()],
|
|
2207
5125
|
env: {
|
|
2208
|
-
|
|
2209
|
-
...options.githubToken ? {
|
|
2210
|
-
GITHUB_GRAPHQL_TOKEN: options.githubToken
|
|
2211
|
-
} : {},
|
|
2212
|
-
...options.githubTokenBrokerUrl ? {
|
|
2213
|
-
GITHUB_TOKEN_BROKER_URL: options.githubTokenBrokerUrl
|
|
2214
|
-
} : {},
|
|
2215
|
-
...options.githubTokenBrokerSecret ? {
|
|
2216
|
-
GITHUB_TOKEN_BROKER_SECRET: options.githubTokenBrokerSecret
|
|
2217
|
-
} : {},
|
|
2218
|
-
...options.githubTokenCachePath ? {
|
|
2219
|
-
GITHUB_TOKEN_CACHE_PATH: options.githubTokenCachePath
|
|
2220
|
-
} : {},
|
|
2221
|
-
...options.githubProjectId ? {
|
|
2222
|
-
GITHUB_PROJECT_ID: options.githubProjectId
|
|
2223
|
-
} : {}
|
|
5126
|
+
LINEAR_GRAPHQL_URL: options.linearGraphqlUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL
|
|
2224
5127
|
}
|
|
2225
5128
|
};
|
|
2226
5129
|
}
|
|
@@ -2233,9 +5136,13 @@ async function composeClaudeMcpConfig(workspaceRoot, strictMode, symphonyTokenEn
|
|
|
2233
5136
|
symphonyTokenEnv
|
|
2234
5137
|
);
|
|
2235
5138
|
const baseConfig = await readBaseMcpConfig(workspaceMcpPath);
|
|
2236
|
-
const mergedConfig =
|
|
5139
|
+
const mergedConfig = mergeSymphonyMcpServers(baseConfig, symphonyTokenEnv);
|
|
2237
5140
|
await mkdir(dirname(finalPath), { recursive: true });
|
|
2238
|
-
await writeFile3(
|
|
5141
|
+
await writeFile3(
|
|
5142
|
+
finalPath,
|
|
5143
|
+
JSON.stringify(mergedConfig, null, 2) + "\n",
|
|
5144
|
+
"utf8"
|
|
5145
|
+
);
|
|
2239
5146
|
return {
|
|
2240
5147
|
finalPath,
|
|
2241
5148
|
extraArgv: strictMode ? ["--strict-mcp-config", "--mcp-config", finalPath] : ["--mcp-config", finalPath],
|
|
@@ -2246,7 +5153,7 @@ async function readBaseMcpConfig(workspaceMcpPath) {
|
|
|
2246
5153
|
try {
|
|
2247
5154
|
const raw = await readFile6(workspaceMcpPath, "utf8");
|
|
2248
5155
|
const parsed = JSON.parse(raw);
|
|
2249
|
-
return
|
|
5156
|
+
return isRecord4(parsed) ? parsed : { mcpServers: {} };
|
|
2250
5157
|
} catch (error) {
|
|
2251
5158
|
if (isNodeError(error) && error.code === "ENOENT") {
|
|
2252
5159
|
return { mcpServers: {} };
|
|
@@ -2254,21 +5161,29 @@ async function readBaseMcpConfig(workspaceMcpPath) {
|
|
|
2254
5161
|
throw error;
|
|
2255
5162
|
}
|
|
2256
5163
|
}
|
|
2257
|
-
function
|
|
2258
|
-
const mcpServers =
|
|
5164
|
+
function mergeSymphonyMcpServers(baseConfig, env) {
|
|
5165
|
+
const mcpServers = isRecord4(baseConfig.mcpServers) ? baseConfig.mcpServers : {};
|
|
5166
|
+
const mergedServers = {
|
|
5167
|
+
...mcpServers,
|
|
5168
|
+
github_graphql: createGitHubGraphQLMcpServerEntry({
|
|
5169
|
+
githubToken: env.GITHUB_GRAPHQL_TOKEN,
|
|
5170
|
+
githubGraphqlApiUrl: env.GITHUB_GRAPHQL_API_URL,
|
|
5171
|
+
githubTokenBrokerUrl: env.GITHUB_TOKEN_BROKER_URL,
|
|
5172
|
+
githubTokenBrokerSecret: env.GITHUB_TOKEN_BROKER_SECRET,
|
|
5173
|
+
githubTokenCachePath: env.GITHUB_TOKEN_CACHE_PATH,
|
|
5174
|
+
githubProjectId: env.GITHUB_PROJECT_ID
|
|
5175
|
+
})
|
|
5176
|
+
};
|
|
5177
|
+
if (env.SYMPHONY_TRACKER_KIND === "linear") {
|
|
5178
|
+
mergedServers.linear_graphql = createLinearGraphQLMcpServerEntry({
|
|
5179
|
+
linearGraphqlUrl: env.LINEAR_GRAPHQL_URL
|
|
5180
|
+
});
|
|
5181
|
+
} else {
|
|
5182
|
+
delete mergedServers.linear_graphql;
|
|
5183
|
+
}
|
|
2259
5184
|
return {
|
|
2260
5185
|
...baseConfig,
|
|
2261
|
-
mcpServers:
|
|
2262
|
-
...mcpServers,
|
|
2263
|
-
github_graphql: createGitHubGraphQLMcpServerEntry({
|
|
2264
|
-
githubToken: env.GITHUB_GRAPHQL_TOKEN,
|
|
2265
|
-
githubGraphqlApiUrl: env.GITHUB_GRAPHQL_API_URL,
|
|
2266
|
-
githubTokenBrokerUrl: env.GITHUB_TOKEN_BROKER_URL,
|
|
2267
|
-
githubTokenBrokerSecret: env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2268
|
-
githubTokenCachePath: env.GITHUB_TOKEN_CACHE_PATH,
|
|
2269
|
-
githubProjectId: env.GITHUB_PROJECT_ID
|
|
2270
|
-
})
|
|
2271
|
-
}
|
|
5186
|
+
mcpServers: mergedServers
|
|
2272
5187
|
};
|
|
2273
5188
|
}
|
|
2274
5189
|
function resolveRuntimeMcpConfigPath(workspaceRoot, env) {
|
|
@@ -2280,7 +5195,7 @@ function resolveRuntimeMcpConfigPath(workspaceRoot, env) {
|
|
|
2280
5195
|
);
|
|
2281
5196
|
return join3(runtimeDir, "mcp.json");
|
|
2282
5197
|
}
|
|
2283
|
-
function
|
|
5198
|
+
function isRecord4(value) {
|
|
2284
5199
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
2285
5200
|
}
|
|
2286
5201
|
function isNodeError(error) {
|
|
@@ -2647,6 +5562,7 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2647
5562
|
spawnErrorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
2648
5563
|
});
|
|
2649
5564
|
if ((classification.kind === "app-error" || classification.kind === "process-error") && !emittedErrorEvent) {
|
|
5565
|
+
const stderrSummary = summarizeClaudeStderr(records);
|
|
2650
5566
|
emitEvent({
|
|
2651
5567
|
name: "agent.error",
|
|
2652
5568
|
payload: {
|
|
@@ -2655,9 +5571,10 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2655
5571
|
exitCode: outcome.exitCode,
|
|
2656
5572
|
signal: outcome.signal,
|
|
2657
5573
|
classification,
|
|
2658
|
-
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
5574
|
+
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0,
|
|
5575
|
+
stderr: stderrSummary ?? void 0
|
|
2659
5576
|
},
|
|
2660
|
-
error: classification.reason
|
|
5577
|
+
error: stderrSummary ? `${classification.reason}: ${stderrSummary}` : classification.reason
|
|
2661
5578
|
}
|
|
2662
5579
|
});
|
|
2663
5580
|
}
|
|
@@ -2673,6 +5590,13 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2673
5590
|
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
2674
5591
|
};
|
|
2675
5592
|
}
|
|
5593
|
+
function summarizeClaudeStderr(records) {
|
|
5594
|
+
const stderrLines = records.filter((record) => record.stream === "stderr").map((record) => record.line || record.parseError).filter((line) => Boolean(line?.trim())).map((line) => line.trim());
|
|
5595
|
+
if (stderrLines.length === 0) {
|
|
5596
|
+
return null;
|
|
5597
|
+
}
|
|
5598
|
+
return stderrLines.slice(-3).join(" | ").slice(0, 1e3);
|
|
5599
|
+
}
|
|
2676
5600
|
async function collectNdjsonStream(stream, channel, records, eventMapper, onEvent) {
|
|
2677
5601
|
if (!stream) {
|
|
2678
5602
|
return;
|
|
@@ -2851,7 +5775,7 @@ var ClaudeSessionStore = class {
|
|
|
2851
5775
|
}
|
|
2852
5776
|
};
|
|
2853
5777
|
function parseClaudeSessionFile(value) {
|
|
2854
|
-
if (!
|
|
5778
|
+
if (!isRecord5(value)) {
|
|
2855
5779
|
throw new Error("Claude session file must be a JSON object.");
|
|
2856
5780
|
}
|
|
2857
5781
|
if (value.protocol !== CLAUDE_SESSION_PROTOCOL) {
|
|
@@ -2868,7 +5792,7 @@ function parseClaudeSessionFile(value) {
|
|
|
2868
5792
|
if ("parentRunId" in value && value.parentRunId !== void 0 && typeof value.parentRunId !== "string") {
|
|
2869
5793
|
throw new Error("Claude session file parentRunId must be a string.");
|
|
2870
5794
|
}
|
|
2871
|
-
if ("protocolState" in value && value.protocolState !== void 0 && !
|
|
5795
|
+
if ("protocolState" in value && value.protocolState !== void 0 && !isRecord5(value.protocolState)) {
|
|
2872
5796
|
throw new Error("Claude session file protocolState must be an object.");
|
|
2873
5797
|
}
|
|
2874
5798
|
return {
|
|
@@ -2876,10 +5800,10 @@ function parseClaudeSessionFile(value) {
|
|
|
2876
5800
|
sessionId: value.sessionId,
|
|
2877
5801
|
createdAt: value.createdAt,
|
|
2878
5802
|
parentRunId: typeof value.parentRunId === "string" ? value.parentRunId : void 0,
|
|
2879
|
-
protocolState:
|
|
5803
|
+
protocolState: isRecord5(value.protocolState) ? value.protocolState : {}
|
|
2880
5804
|
};
|
|
2881
5805
|
}
|
|
2882
|
-
function
|
|
5806
|
+
function isRecord5(value) {
|
|
2883
5807
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2884
5808
|
}
|
|
2885
5809
|
function isFileNotFoundError(error) {
|
|
@@ -3334,6 +6258,10 @@ function buildClaudeMcpTokenEnvironment(options) {
|
|
|
3334
6258
|
GITHUB_TOKEN_BROKER_SECRET: source.GITHUB_TOKEN_BROKER_SECRET,
|
|
3335
6259
|
GITHUB_TOKEN_CACHE_PATH: source.GITHUB_TOKEN_CACHE_PATH,
|
|
3336
6260
|
GITHUB_PROJECT_ID: source.GITHUB_PROJECT_ID,
|
|
6261
|
+
LINEAR_API_KEY: source.LINEAR_API_KEY,
|
|
6262
|
+
LINEAR_AUTHORIZATION: source.LINEAR_AUTHORIZATION,
|
|
6263
|
+
LINEAR_GRAPHQL_URL: source.LINEAR_GRAPHQL_URL,
|
|
6264
|
+
SYMPHONY_TRACKER_KIND: source.SYMPHONY_TRACKER_KIND,
|
|
3337
6265
|
WORKSPACE_RUNTIME_DIR: options.runtimeDirectory ?? source.WORKSPACE_RUNTIME_DIR
|
|
3338
6266
|
};
|
|
3339
6267
|
}
|
|
@@ -3375,10 +6303,12 @@ export {
|
|
|
3375
6303
|
safeReadDir,
|
|
3376
6304
|
isFileMissing,
|
|
3377
6305
|
parseRecentEvents,
|
|
6306
|
+
redactObservabilitySecrets,
|
|
3378
6307
|
isMatchingIssueRun,
|
|
3379
6308
|
mapIssueOrchestrationStateToStatus,
|
|
3380
6309
|
resolveGitHubGraphQLToken,
|
|
3381
6310
|
createGitHubGraphQLMcpServerEntry,
|
|
6311
|
+
createLinearGraphQLMcpServerEntry,
|
|
3382
6312
|
createClaudePrintRuntimeAdapter,
|
|
3383
6313
|
runClaudePreflight,
|
|
3384
6314
|
formatClaudePreflightText,
|