@gh-symphony/cli 0.1.2 → 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-GHVDABFO.js → chunk-DW63WPRE.js} +4 -1
- package/dist/{chunk-VFHMHHZW.js → chunk-E7OCBNB2.js} +76 -8
- package/dist/{chunk-GPRCOJDJ.js → chunk-EWTMSDCE.js} +3179 -201
- package/dist/{chunk-B4ZJMAZL.js → chunk-HT3FAJAO.js} +3 -3
- package/dist/{chunk-WM2B6BJ7.js → chunk-RHLUIMBN.js} +1 -1
- package/dist/{chunk-DLZAJXZL.js → chunk-YIARPBOR.js} +1 -1
- package/dist/{doctor-EEPNFCGF.js → doctor-I32MANQ4.js} +4 -4
- package/dist/index.js +6 -6
- package/dist/{repo-RX4OK7XH.js → repo-IH6UWE4H.js} +344 -12
- package/dist/{setup-XNHHRBGU.js → setup-UJC2WYHQ.js} +3 -3
- package/dist/{upgrade-NS53EO2B.js → upgrade-XYHCUGHT.js} +2 -2
- package/dist/{version-2RHFZ5CI.js → version-B2AYYGLM.js} +1 -1
- package/dist/worker-entry.js +43 -3
- package/dist/{workflow-26QNZZWH.js → workflow-WSXHMO5B.js} +4 -4
- package/package.json +4 -4
|
@@ -25,6 +25,7 @@ function normalizeWorkflowState(state) {
|
|
|
25
25
|
var DEFAULT_CODEX_COMMAND = "codex app-server";
|
|
26
26
|
var DEFAULT_CLAUDE_COMMAND = "claude";
|
|
27
27
|
var DEFAULT_AGENT_COMMAND = DEFAULT_CODEX_COMMAND;
|
|
28
|
+
var DEFAULT_LINEAR_GRAPHQL_URL = "https://api.linear.app/graphql";
|
|
28
29
|
var DEFAULT_HOOK_TIMEOUT_MS = 6e4;
|
|
29
30
|
var DEFAULT_POLL_INTERVAL_MS = 3e4;
|
|
30
31
|
var DEFAULT_MAX_RETRY_BACKOFF_MS = 3e5;
|
|
@@ -129,6 +130,7 @@ function parseWorkflowMarkdown(markdown, env = process.env, options = {}) {
|
|
|
129
130
|
const hasRuntime = runtimeNode !== null;
|
|
130
131
|
const codex = hasRuntime ? readObject(frontMatter, "codex") : readRequiredObject(frontMatter, "codex");
|
|
131
132
|
const trackerKind = readRequiredString(tracker, "kind", env);
|
|
133
|
+
validateTrackerConfig(tracker, trackerKind, env);
|
|
132
134
|
const activeStates = readStringList(tracker, "active_states") ?? DEFAULT_WORKFLOW_TRACKER.activeStates;
|
|
133
135
|
const terminalStates = readStringList(tracker, "terminal_states") ?? DEFAULT_WORKFLOW_TRACKER.terminalStates;
|
|
134
136
|
const blockerCheckStates = readStringList(tracker, "blocker_check_states") ?? DEFAULT_WORKFLOW_TRACKER.blockerCheckStates;
|
|
@@ -160,7 +162,7 @@ function parseWorkflowMarkdown(markdown, env = process.env, options = {}) {
|
|
|
160
162
|
),
|
|
161
163
|
tracker: {
|
|
162
164
|
kind: trackerKind,
|
|
163
|
-
endpoint: readOptionalString(tracker, "endpoint", env),
|
|
165
|
+
endpoint: readOptionalString(tracker, "endpoint", env) ?? (trackerKind === "linear" ? DEFAULT_LINEAR_GRAPHQL_URL : null),
|
|
164
166
|
apiKey: readOptionalString(tracker, "api_key", env),
|
|
165
167
|
projectSlug: readOptionalString(tracker, "project_slug", env),
|
|
166
168
|
activeStates,
|
|
@@ -207,6 +209,32 @@ function parseWorkflowMarkdown(markdown, env = process.env, options = {}) {
|
|
|
207
209
|
};
|
|
208
210
|
return parsed;
|
|
209
211
|
}
|
|
212
|
+
function validateTrackerConfig(tracker, trackerKind, env) {
|
|
213
|
+
if (trackerKind !== "linear") {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
for (const key of ["project_id", "projectId", "teamId", "team_id"]) {
|
|
217
|
+
if (key in tracker) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Workflow front matter field "tracker.${key}" is not supported for tracker.kind "linear"; use "tracker.project_slug".`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const projectSlug = readOptionalString(tracker, "project_slug", env);
|
|
224
|
+
if (!projectSlug || projectSlug.trim().length === 0) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
'Workflow front matter field "tracker.project_slug" is required for tracker.kind "linear".'
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
if ("endpoint" in tracker) {
|
|
230
|
+
const endpoint = readOptionalString(tracker, "endpoint", env);
|
|
231
|
+
if (!endpoint || endpoint.trim().length === 0) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
'Workflow front matter field "tracker.endpoint" must be a non-empty string when provided for tracker.kind "linear".'
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
210
238
|
function parseLegacyWorkflowMarkdown(markdown) {
|
|
211
239
|
const promptGuidelines = matchOptionalSection(markdown, "Prompt Guidelines") ?? "";
|
|
212
240
|
return {
|
|
@@ -372,7 +400,9 @@ function splitInlineArrayEntries(inner) {
|
|
|
372
400
|
current += char;
|
|
373
401
|
}
|
|
374
402
|
if (quote) {
|
|
375
|
-
throw new Error(
|
|
403
|
+
throw new Error(
|
|
404
|
+
"Workflow front matter inline array has an unterminated string."
|
|
405
|
+
);
|
|
376
406
|
}
|
|
377
407
|
pushInlineArrayEntry(entries, current, "end");
|
|
378
408
|
return entries;
|
|
@@ -564,6 +594,16 @@ function resolveEnvironmentValue(value, env) {
|
|
|
564
594
|
}
|
|
565
595
|
return resolved;
|
|
566
596
|
}
|
|
597
|
+
const dollarEnvTokenMatch = value.match(/^\$([A-Z0-9_]+)$/);
|
|
598
|
+
if (dollarEnvTokenMatch) {
|
|
599
|
+
const resolved = env[dollarEnvTokenMatch[1]];
|
|
600
|
+
if (!resolved) {
|
|
601
|
+
throw new Error(
|
|
602
|
+
`Workflow front matter requires environment variable ${dollarEnvTokenMatch[1]}.`
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
return resolved;
|
|
606
|
+
}
|
|
567
607
|
return value.replace(/\$\{([A-Z0-9_]+)\}/g, (_, name) => {
|
|
568
608
|
const resolved = env[name];
|
|
569
609
|
if (!resolved) {
|
|
@@ -1488,6 +1528,42 @@ function parseRunEventLine(line) {
|
|
|
1488
1528
|
}
|
|
1489
1529
|
}
|
|
1490
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
|
+
|
|
1491
1567
|
// ../core/src/observability/status-assembler.ts
|
|
1492
1568
|
function isMatchingIssueRun(run, issueId, issueIdentifier) {
|
|
1493
1569
|
return Boolean(
|
|
@@ -2185,233 +2261,3119 @@ function createGitHubGraphQLMcpServerEntry(options = {}) {
|
|
|
2185
2261
|
};
|
|
2186
2262
|
}
|
|
2187
2263
|
|
|
2188
|
-
//
|
|
2189
|
-
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
await mkdir(dirname(finalPath), { recursive: true });
|
|
2195
|
-
await writeFile3(finalPath, JSON.stringify(mergedConfig, null, 2) + "\n", "utf8");
|
|
2196
|
-
return {
|
|
2197
|
-
finalPath,
|
|
2198
|
-
extraArgv: strictMode ? ["--strict-mcp-config", "--mcp-config", finalPath] : [],
|
|
2199
|
-
...strictMode ? { cleanupPath: finalPath } : {}
|
|
2200
|
-
};
|
|
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
|
+
}
|
|
2201
2270
|
}
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
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
|
+
);
|
|
2212
2284
|
}
|
|
2213
2285
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
githubTokenBrokerSecret: env.GITHUB_TOKEN_BROKER_SECRET,
|
|
2225
|
-
githubTokenCachePath: env.GITHUB_TOKEN_CACHE_PATH,
|
|
2226
|
-
githubProjectId: env.GITHUB_PROJECT_ID
|
|
2227
|
-
})
|
|
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;
|
|
2228
2296
|
}
|
|
2297
|
+
lastLineStart = match.index + match[0].length;
|
|
2298
|
+
line += 1;
|
|
2299
|
+
}
|
|
2300
|
+
return {
|
|
2301
|
+
line,
|
|
2302
|
+
column: position + 1 - lastLineStart
|
|
2229
2303
|
};
|
|
2230
2304
|
}
|
|
2231
|
-
function resolveStrictMcpConfigPath(workspaceRoot, env) {
|
|
2232
|
-
const normalizedWorkspaceRoot = resolve4(workspaceRoot);
|
|
2233
|
-
const runtimeDir = env.WORKSPACE_RUNTIME_DIR ?? join3(normalizedWorkspaceRoot, ".runtime", basename(normalizedWorkspaceRoot));
|
|
2234
|
-
return join3(runtimeDir, "mcp.json");
|
|
2235
|
-
}
|
|
2236
|
-
function isRecord3(value) {
|
|
2237
|
-
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
2238
|
-
}
|
|
2239
|
-
function isNodeError(error) {
|
|
2240
|
-
return error instanceof Error && "code" in error;
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
// ../runtime-claude/src/spawn.ts
|
|
2244
|
-
import { spawn as spawn2 } from "child_process";
|
|
2245
|
-
import { finished } from "stream/promises";
|
|
2246
2305
|
|
|
2247
|
-
//
|
|
2248
|
-
function
|
|
2249
|
-
return
|
|
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
|
+
);
|
|
2250
2312
|
}
|
|
2251
|
-
function
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
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");
|
|
2259
2351
|
}
|
|
2260
2352
|
|
|
2261
|
-
//
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
if (!trimmedLine) {
|
|
2266
|
-
return null;
|
|
2267
|
-
}
|
|
2268
|
-
try {
|
|
2269
|
-
const parsed = JSON.parse(trimmedLine);
|
|
2270
|
-
if (!asRecord(parsed)) {
|
|
2271
|
-
return {
|
|
2272
|
-
line: trimmedLine,
|
|
2273
|
-
parseError: "Claude stream-json line is not a JSON object."
|
|
2274
|
-
};
|
|
2275
|
-
}
|
|
2276
|
-
return {
|
|
2277
|
-
line: trimmedLine,
|
|
2278
|
-
message: parsed
|
|
2279
|
-
};
|
|
2280
|
-
} catch (error) {
|
|
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) {
|
|
2281
2357
|
return {
|
|
2282
|
-
|
|
2283
|
-
|
|
2358
|
+
nodes: firstArg,
|
|
2359
|
+
source: args[1],
|
|
2360
|
+
positions: args[2],
|
|
2361
|
+
path: args[3],
|
|
2362
|
+
originalError: args[4],
|
|
2363
|
+
extensions: args[5]
|
|
2284
2364
|
};
|
|
2285
2365
|
}
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
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
|
+
});
|
|
2301
2462
|
}
|
|
2302
|
-
return this.mapMessage(record.message);
|
|
2303
2463
|
}
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
events.push(this.buildTurnStartedEvent(message, type));
|
|
2315
|
-
this.hasStartedTurn = true;
|
|
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
|
+
}
|
|
2316
2474
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2475
|
+
} else if (this.source && this.locations) {
|
|
2476
|
+
for (const location of this.locations) {
|
|
2477
|
+
output += "\n\n" + printSourceLocation(this.source, location);
|
|
2320
2478
|
}
|
|
2321
2479
|
}
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
observabilityEvent: observabilityEventName(type),
|
|
2331
|
-
params: message,
|
|
2332
|
-
delta: extractDeltaText(message),
|
|
2333
|
-
itemId: extractItemId(message)
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2480
|
+
return output;
|
|
2481
|
+
}
|
|
2482
|
+
toJSON() {
|
|
2483
|
+
const formattedError = {
|
|
2484
|
+
message: this.message
|
|
2485
|
+
};
|
|
2486
|
+
if (this.locations != null) {
|
|
2487
|
+
formattedError.locations = this.locations;
|
|
2336
2488
|
}
|
|
2337
|
-
if (
|
|
2338
|
-
|
|
2339
|
-
const rateLimit = extractRateLimit(message);
|
|
2340
|
-
if (rateLimit) {
|
|
2341
|
-
this.sawRateLimit = true;
|
|
2342
|
-
events.push({
|
|
2343
|
-
name: "agent.rateLimit",
|
|
2344
|
-
payload: {
|
|
2345
|
-
observabilityEvent: observabilityEventName(type),
|
|
2346
|
-
params: {
|
|
2347
|
-
source: "claude",
|
|
2348
|
-
rate_limit: rateLimit,
|
|
2349
|
-
usage: asRecord(message.usage),
|
|
2350
|
-
result: message
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
if (isClaudeResultError(message)) {
|
|
2356
|
-
events.push(buildClaudeErrorEvent(message, type));
|
|
2357
|
-
} else {
|
|
2358
|
-
events.push({
|
|
2359
|
-
name: "agent.turnCompleted",
|
|
2360
|
-
payload: {
|
|
2361
|
-
observabilityEvent: observabilityEventName(type),
|
|
2362
|
-
params: message,
|
|
2363
|
-
inputRequired: false
|
|
2364
|
-
}
|
|
2365
|
-
});
|
|
2366
|
-
}
|
|
2489
|
+
if (this.path != null) {
|
|
2490
|
+
formattedError.path = this.path;
|
|
2367
2491
|
}
|
|
2368
|
-
if (
|
|
2369
|
-
|
|
2370
|
-
events.push(buildClaudeErrorEvent(message, type));
|
|
2492
|
+
if (this.extensions != null && Object.keys(this.extensions).length > 0) {
|
|
2493
|
+
formattedError.extensions = this.extensions;
|
|
2371
2494
|
}
|
|
2372
|
-
return
|
|
2495
|
+
return formattedError;
|
|
2373
2496
|
}
|
|
2374
|
-
|
|
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() {
|
|
2375
2538
|
return {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
latestErrorEvent: this.latestErrorEvent,
|
|
2379
|
-
sawRateLimit: this.sawRateLimit
|
|
2539
|
+
start: this.start,
|
|
2540
|
+
end: this.end
|
|
2380
2541
|
};
|
|
2381
2542
|
}
|
|
2382
|
-
|
|
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() {
|
|
2383
2585
|
return {
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
}
|
|
2586
|
+
kind: this.kind,
|
|
2587
|
+
value: this.value,
|
|
2588
|
+
line: this.line,
|
|
2589
|
+
column: this.column
|
|
2389
2590
|
};
|
|
2390
2591
|
}
|
|
2391
2592
|
};
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
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;
|
|
2396
2778
|
}
|
|
2397
|
-
function
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
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
|
+
}
|
|
2402
2811
|
}
|
|
2403
|
-
return
|
|
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
|
+
);
|
|
2404
2816
|
}
|
|
2405
|
-
function
|
|
2406
|
-
|
|
2407
|
-
|
|
2817
|
+
function leadingWhitespace(str) {
|
|
2818
|
+
let i = 0;
|
|
2819
|
+
while (i < str.length && isWhiteSpace(str.charCodeAt(i))) {
|
|
2820
|
+
++i;
|
|
2408
2821
|
}
|
|
2409
|
-
return
|
|
2822
|
+
return i;
|
|
2410
2823
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
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
|
+
});
|
|
4598
|
+
}
|
|
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
|
+
});
|
|
4719
|
+
}
|
|
4720
|
+
return this.node(start, {
|
|
4721
|
+
kind: Kind.TYPE_COORDINATE,
|
|
4722
|
+
name
|
|
4723
|
+
});
|
|
4724
|
+
}
|
|
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
|
+
);
|
|
4762
|
+
}
|
|
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;
|
|
4772
|
+
}
|
|
4773
|
+
return false;
|
|
4774
|
+
}
|
|
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
|
+
}
|
|
4790
|
+
}
|
|
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;
|
|
4802
|
+
}
|
|
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
|
+
);
|
|
4813
|
+
}
|
|
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 [];
|
|
4842
|
+
}
|
|
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
|
+
}
|
|
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;
|
|
4890
|
+
}
|
|
4891
|
+
|
|
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);
|
|
4897
|
+
const response = await fetchImpl(
|
|
4898
|
+
config.apiUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL,
|
|
4899
|
+
{
|
|
4900
|
+
method: "POST",
|
|
4901
|
+
headers: {
|
|
4902
|
+
"content-type": "application/json",
|
|
4903
|
+
authorization
|
|
4904
|
+
},
|
|
4905
|
+
body: JSON.stringify(invocation)
|
|
4906
|
+
}
|
|
4907
|
+
);
|
|
4908
|
+
const payload = await response.json();
|
|
4909
|
+
if (!response.ok) {
|
|
4910
|
+
throw new Error(
|
|
4911
|
+
`Linear GraphQL request failed with status ${response.status}: ${JSON.stringify(payload)}`
|
|
4912
|
+
);
|
|
4913
|
+
}
|
|
4914
|
+
if (payload.errors?.length) {
|
|
4915
|
+
throw new Error(payload.errors.map((error) => error.message).join("; "));
|
|
4916
|
+
}
|
|
4917
|
+
return payload;
|
|
4918
|
+
}
|
|
4919
|
+
function validateLinearGraphQLInvocation(invocation) {
|
|
4920
|
+
if (typeof invocation.query !== "string" || invocation.query.trim() === "") {
|
|
4921
|
+
throw new Error(
|
|
4922
|
+
"linear_graphql requires a non-empty GraphQL query string."
|
|
4923
|
+
);
|
|
4924
|
+
}
|
|
4925
|
+
const document = parse(invocation.query);
|
|
4926
|
+
const operationCount = document.definitions.filter(
|
|
4927
|
+
(definition) => definition.kind === "OperationDefinition"
|
|
4928
|
+
).length;
|
|
4929
|
+
if (operationCount !== 1) {
|
|
4930
|
+
throw new Error(
|
|
4931
|
+
"linear_graphql accepts exactly one GraphQL operation per request; split multi-operation documents before calling Linear."
|
|
4932
|
+
);
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
function resolveLinearAuthorizationHeader(config) {
|
|
4936
|
+
if (config.authorizationHeader) {
|
|
4937
|
+
return config.authorizationHeader;
|
|
4938
|
+
}
|
|
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
|
+
);
|
|
4945
|
+
}
|
|
4946
|
+
async function readStdin2() {
|
|
4947
|
+
const chunks = [];
|
|
4948
|
+
for await (const chunk of process.stdin) {
|
|
4949
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
4950
|
+
}
|
|
4951
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
4952
|
+
}
|
|
4953
|
+
async function main3() {
|
|
4954
|
+
const rawInput = await readStdin2();
|
|
4955
|
+
const invocation = JSON.parse(rawInput);
|
|
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
|
|
4960
|
+
});
|
|
4961
|
+
process.stdout.write(`${JSON.stringify(result)}
|
|
4962
|
+
`);
|
|
4963
|
+
}
|
|
4964
|
+
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
4965
|
+
main3().catch((error) => {
|
|
4966
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
4967
|
+
process.stderr.write(`${message}
|
|
4968
|
+
`);
|
|
4969
|
+
process.exitCode = 1;
|
|
4970
|
+
});
|
|
4971
|
+
}
|
|
4972
|
+
|
|
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.",
|
|
4978
|
+
inputSchema: {
|
|
4979
|
+
type: "object",
|
|
4980
|
+
properties: {
|
|
4981
|
+
query: {
|
|
4982
|
+
type: "string",
|
|
4983
|
+
description: "Single GraphQL query or mutation document."
|
|
4984
|
+
},
|
|
4985
|
+
variables: {
|
|
4986
|
+
type: "object",
|
|
4987
|
+
description: "Variables for the GraphQL document."
|
|
4988
|
+
},
|
|
4989
|
+
operationName: {
|
|
4990
|
+
type: "string",
|
|
4991
|
+
description: "Optional GraphQL operation name."
|
|
4992
|
+
}
|
|
4993
|
+
},
|
|
4994
|
+
required: ["query"],
|
|
4995
|
+
additionalProperties: false
|
|
4996
|
+
}
|
|
4997
|
+
};
|
|
4998
|
+
var lineBuffer2 = "";
|
|
4999
|
+
function resolveLinearGraphQLMcpServerEntryPoint() {
|
|
5000
|
+
return fileURLToPath2(new URL("./mcp-server.js", import.meta.url));
|
|
5001
|
+
}
|
|
5002
|
+
function sendResponse2(id, result) {
|
|
5003
|
+
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, result })}
|
|
5004
|
+
`);
|
|
5005
|
+
}
|
|
5006
|
+
function sendError2(id, code, message) {
|
|
5007
|
+
process.stdout.write(
|
|
5008
|
+
`${JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } })}
|
|
5009
|
+
`
|
|
5010
|
+
);
|
|
5011
|
+
}
|
|
5012
|
+
async function handleRequest2(msg) {
|
|
5013
|
+
const id = msg.id ?? null;
|
|
5014
|
+
switch (msg.method) {
|
|
5015
|
+
case "initialize": {
|
|
5016
|
+
sendResponse2(id, {
|
|
5017
|
+
protocolVersion: "2024-11-05",
|
|
5018
|
+
capabilities: { tools: {} },
|
|
5019
|
+
serverInfo: {
|
|
5020
|
+
name: "github-symphony-linear-graphql",
|
|
5021
|
+
version: "0.1.0"
|
|
5022
|
+
}
|
|
5023
|
+
});
|
|
5024
|
+
process.stdout.write(
|
|
5025
|
+
`${JSON.stringify({
|
|
5026
|
+
jsonrpc: "2.0",
|
|
5027
|
+
method: "notifications/initialized"
|
|
5028
|
+
})}
|
|
5029
|
+
`
|
|
5030
|
+
);
|
|
5031
|
+
break;
|
|
5032
|
+
}
|
|
5033
|
+
case "tools/list": {
|
|
5034
|
+
sendResponse2(id, { tools: [TOOL_SCHEMA2] });
|
|
5035
|
+
break;
|
|
5036
|
+
}
|
|
5037
|
+
case "tools/call": {
|
|
5038
|
+
const params = msg.params;
|
|
5039
|
+
if (params.name !== "linear_graphql") {
|
|
5040
|
+
sendError2(id, -32602, `Unknown tool: ${params.name}`);
|
|
5041
|
+
return;
|
|
5042
|
+
}
|
|
5043
|
+
const args = params.arguments ?? {};
|
|
5044
|
+
const invocation = {
|
|
5045
|
+
query: args.query,
|
|
5046
|
+
variables: args.variables,
|
|
5047
|
+
operationName: args.operationName
|
|
5048
|
+
};
|
|
5049
|
+
try {
|
|
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
|
|
5054
|
+
});
|
|
5055
|
+
sendResponse2(id, {
|
|
5056
|
+
content: [
|
|
5057
|
+
{
|
|
5058
|
+
type: "text",
|
|
5059
|
+
text: JSON.stringify(result, null, 2)
|
|
5060
|
+
}
|
|
5061
|
+
]
|
|
5062
|
+
});
|
|
5063
|
+
} catch (err) {
|
|
5064
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
5065
|
+
sendResponse2(id, {
|
|
5066
|
+
content: [{ type: "text", text: message }],
|
|
5067
|
+
isError: true
|
|
5068
|
+
});
|
|
5069
|
+
}
|
|
5070
|
+
break;
|
|
5071
|
+
}
|
|
5072
|
+
case "notifications/initialized":
|
|
5073
|
+
case "ping": {
|
|
5074
|
+
if (id !== null && id !== void 0) {
|
|
5075
|
+
sendResponse2(id, {});
|
|
5076
|
+
}
|
|
5077
|
+
break;
|
|
5078
|
+
}
|
|
5079
|
+
default: {
|
|
5080
|
+
if (id !== null && id !== void 0) {
|
|
5081
|
+
sendError2(id, -32601, `Method not found: ${msg.method}`);
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
async function main4() {
|
|
5087
|
+
process.stdin.setEncoding("utf8");
|
|
5088
|
+
process.stdin.on("data", (chunk) => {
|
|
5089
|
+
lineBuffer2 += chunk;
|
|
5090
|
+
const lines = lineBuffer2.split("\n");
|
|
5091
|
+
lineBuffer2 = lines.pop() ?? "";
|
|
5092
|
+
for (const line of lines) {
|
|
5093
|
+
const trimmed = line.trim();
|
|
5094
|
+
if (!trimmed) continue;
|
|
5095
|
+
try {
|
|
5096
|
+
const msg = JSON.parse(trimmed);
|
|
5097
|
+
void handleRequest2(msg);
|
|
5098
|
+
} catch (err) {
|
|
5099
|
+
process.stderr.write(
|
|
5100
|
+
`[linear-graphql-mcp] parse error: ${err instanceof Error ? err.message : String(err)}
|
|
5101
|
+
`
|
|
5102
|
+
);
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
});
|
|
5106
|
+
process.stdin.on("end", () => {
|
|
5107
|
+
process.exit(0);
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
if (import.meta.url === new URL(process.argv[1] ?? "", "file:").href) {
|
|
5111
|
+
main4().catch((err) => {
|
|
5112
|
+
process.stderr.write(
|
|
5113
|
+
`[linear-graphql-mcp] fatal: ${err instanceof Error ? err.message : String(err)}
|
|
5114
|
+
`
|
|
5115
|
+
);
|
|
5116
|
+
process.exitCode = 1;
|
|
5117
|
+
});
|
|
5118
|
+
}
|
|
5119
|
+
|
|
5120
|
+
// ../tool-linear-graphql/src/mcp-entry.ts
|
|
5121
|
+
function createLinearGraphQLMcpServerEntry(options = {}) {
|
|
5122
|
+
return {
|
|
5123
|
+
command: "node",
|
|
5124
|
+
args: [resolveLinearGraphQLMcpServerEntryPoint()],
|
|
5125
|
+
env: {
|
|
5126
|
+
LINEAR_GRAPHQL_URL: options.linearGraphqlUrl ?? DEFAULT_LINEAR_GRAPHQL_API_URL
|
|
5127
|
+
}
|
|
5128
|
+
};
|
|
5129
|
+
}
|
|
5130
|
+
|
|
5131
|
+
// ../runtime-claude/src/mcp-compose.ts
|
|
5132
|
+
async function composeClaudeMcpConfig(workspaceRoot, strictMode, symphonyTokenEnv = {}) {
|
|
5133
|
+
const workspaceMcpPath = join3(workspaceRoot, ".mcp.json");
|
|
5134
|
+
const finalPath = resolveRuntimeMcpConfigPath(
|
|
5135
|
+
workspaceRoot,
|
|
5136
|
+
symphonyTokenEnv
|
|
5137
|
+
);
|
|
5138
|
+
const baseConfig = await readBaseMcpConfig(workspaceMcpPath);
|
|
5139
|
+
const mergedConfig = mergeSymphonyMcpServers(baseConfig, symphonyTokenEnv);
|
|
5140
|
+
await mkdir(dirname(finalPath), { recursive: true });
|
|
5141
|
+
await writeFile3(
|
|
5142
|
+
finalPath,
|
|
5143
|
+
JSON.stringify(mergedConfig, null, 2) + "\n",
|
|
5144
|
+
"utf8"
|
|
5145
|
+
);
|
|
5146
|
+
return {
|
|
5147
|
+
finalPath,
|
|
5148
|
+
extraArgv: strictMode ? ["--strict-mcp-config", "--mcp-config", finalPath] : ["--mcp-config", finalPath],
|
|
5149
|
+
cleanupPath: finalPath
|
|
5150
|
+
};
|
|
5151
|
+
}
|
|
5152
|
+
async function readBaseMcpConfig(workspaceMcpPath) {
|
|
5153
|
+
try {
|
|
5154
|
+
const raw = await readFile6(workspaceMcpPath, "utf8");
|
|
5155
|
+
const parsed = JSON.parse(raw);
|
|
5156
|
+
return isRecord4(parsed) ? parsed : { mcpServers: {} };
|
|
5157
|
+
} catch (error) {
|
|
5158
|
+
if (isNodeError(error) && error.code === "ENOENT") {
|
|
5159
|
+
return { mcpServers: {} };
|
|
5160
|
+
}
|
|
5161
|
+
throw error;
|
|
5162
|
+
}
|
|
5163
|
+
}
|
|
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
|
+
}
|
|
5184
|
+
return {
|
|
5185
|
+
...baseConfig,
|
|
5186
|
+
mcpServers: mergedServers
|
|
5187
|
+
};
|
|
5188
|
+
}
|
|
5189
|
+
function resolveRuntimeMcpConfigPath(workspaceRoot, env) {
|
|
5190
|
+
const normalizedWorkspaceRoot = resolve4(workspaceRoot);
|
|
5191
|
+
const runtimeDir = env.WORKSPACE_RUNTIME_DIR ?? join3(
|
|
5192
|
+
dirname(normalizedWorkspaceRoot),
|
|
5193
|
+
".runtime",
|
|
5194
|
+
basename(normalizedWorkspaceRoot)
|
|
5195
|
+
);
|
|
5196
|
+
return join3(runtimeDir, "mcp.json");
|
|
5197
|
+
}
|
|
5198
|
+
function isRecord4(value) {
|
|
5199
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
5200
|
+
}
|
|
5201
|
+
function isNodeError(error) {
|
|
5202
|
+
return error instanceof Error && "code" in error;
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5205
|
+
// ../runtime-claude/src/spawn.ts
|
|
5206
|
+
import { spawn as spawn2 } from "child_process";
|
|
5207
|
+
import { finished } from "stream/promises";
|
|
5208
|
+
|
|
5209
|
+
// ../runtime-claude/src/internal.ts
|
|
5210
|
+
function asRecord(value) {
|
|
5211
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
5212
|
+
}
|
|
5213
|
+
function getString(value) {
|
|
5214
|
+
if (typeof value === "string") {
|
|
5215
|
+
return value;
|
|
5216
|
+
}
|
|
5217
|
+
if (typeof value === "number") {
|
|
5218
|
+
return String(value);
|
|
5219
|
+
}
|
|
5220
|
+
return void 0;
|
|
5221
|
+
}
|
|
5222
|
+
|
|
5223
|
+
// ../runtime-claude/src/events.ts
|
|
5224
|
+
var CLAUDE_OBSERVABILITY_PREFIX = "claude-print/";
|
|
5225
|
+
function parseClaudePrintNdjsonLine(line) {
|
|
5226
|
+
const trimmedLine = line.trim();
|
|
5227
|
+
if (!trimmedLine) {
|
|
5228
|
+
return null;
|
|
5229
|
+
}
|
|
5230
|
+
try {
|
|
5231
|
+
const parsed = JSON.parse(trimmedLine);
|
|
5232
|
+
if (!asRecord(parsed)) {
|
|
5233
|
+
return {
|
|
5234
|
+
line: trimmedLine,
|
|
5235
|
+
parseError: "Claude stream-json line is not a JSON object."
|
|
5236
|
+
};
|
|
5237
|
+
}
|
|
5238
|
+
return {
|
|
5239
|
+
line: trimmedLine,
|
|
5240
|
+
message: parsed
|
|
5241
|
+
};
|
|
5242
|
+
} catch (error) {
|
|
5243
|
+
return {
|
|
5244
|
+
line: trimmedLine,
|
|
5245
|
+
parseError: error instanceof Error ? error.message : "Unknown JSON parse error."
|
|
5246
|
+
};
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
var ClaudePrintEventMapper = class {
|
|
5250
|
+
constructor(options = {}) {
|
|
5251
|
+
this.options = options;
|
|
5252
|
+
}
|
|
5253
|
+
hasStartedTurn = false;
|
|
5254
|
+
latestResultEvent = null;
|
|
5255
|
+
// Claude -p stream-json does not define an ordered collection of error
|
|
5256
|
+
// records for one turn; keep the terminal/latest error for exit classification.
|
|
5257
|
+
latestErrorEvent = null;
|
|
5258
|
+
sawRateLimit = false;
|
|
5259
|
+
mapLine(line) {
|
|
5260
|
+
const record = parseClaudePrintNdjsonLine(line);
|
|
5261
|
+
if (!record?.message) {
|
|
5262
|
+
return [];
|
|
5263
|
+
}
|
|
5264
|
+
return this.mapMessage(record.message);
|
|
5265
|
+
}
|
|
5266
|
+
mapMessage(message) {
|
|
5267
|
+
const type = getEventType(message);
|
|
5268
|
+
const events = [];
|
|
5269
|
+
if (type === "message_start") {
|
|
5270
|
+
events.push(this.buildTurnStartedEvent(message, type));
|
|
5271
|
+
this.hasStartedTurn = true;
|
|
5272
|
+
return events;
|
|
5273
|
+
}
|
|
5274
|
+
if (type === "content_block_start" || type === "tool_use") {
|
|
5275
|
+
if (!this.hasStartedTurn) {
|
|
5276
|
+
events.push(this.buildTurnStartedEvent(message, type));
|
|
5277
|
+
this.hasStartedTurn = true;
|
|
5278
|
+
}
|
|
5279
|
+
const toolUseEvent = mapToolUseEvent(message, this.options);
|
|
5280
|
+
if (toolUseEvent) {
|
|
5281
|
+
events.push(toolUseEvent);
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
if (type === "content_block_delta") {
|
|
5285
|
+
if (!this.hasStartedTurn) {
|
|
5286
|
+
events.push(this.buildTurnStartedEvent(message, type));
|
|
5287
|
+
this.hasStartedTurn = true;
|
|
5288
|
+
}
|
|
5289
|
+
events.push({
|
|
5290
|
+
name: "agent.messageDelta",
|
|
5291
|
+
payload: {
|
|
5292
|
+
observabilityEvent: observabilityEventName(type),
|
|
5293
|
+
params: message,
|
|
5294
|
+
delta: extractDeltaText(message),
|
|
5295
|
+
itemId: extractItemId(message)
|
|
5296
|
+
}
|
|
5297
|
+
});
|
|
5298
|
+
}
|
|
5299
|
+
if (type === "result") {
|
|
5300
|
+
this.latestResultEvent = message;
|
|
5301
|
+
const rateLimit = extractRateLimit(message);
|
|
5302
|
+
if (rateLimit) {
|
|
5303
|
+
this.sawRateLimit = true;
|
|
5304
|
+
events.push({
|
|
5305
|
+
name: "agent.rateLimit",
|
|
5306
|
+
payload: {
|
|
5307
|
+
observabilityEvent: observabilityEventName(type),
|
|
5308
|
+
params: {
|
|
5309
|
+
source: "claude",
|
|
5310
|
+
rate_limit: rateLimit,
|
|
5311
|
+
usage: asRecord(message.usage),
|
|
5312
|
+
result: message
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
});
|
|
5316
|
+
}
|
|
5317
|
+
if (isClaudeResultError(message)) {
|
|
5318
|
+
events.push(buildClaudeErrorEvent(message, type));
|
|
5319
|
+
} else {
|
|
5320
|
+
events.push({
|
|
5321
|
+
name: "agent.turnCompleted",
|
|
5322
|
+
payload: {
|
|
5323
|
+
observabilityEvent: observabilityEventName(type),
|
|
5324
|
+
params: message,
|
|
5325
|
+
inputRequired: false
|
|
5326
|
+
}
|
|
5327
|
+
});
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
if (type === "error") {
|
|
5331
|
+
this.latestErrorEvent = message;
|
|
5332
|
+
events.push(buildClaudeErrorEvent(message, type));
|
|
5333
|
+
}
|
|
5334
|
+
return events;
|
|
5335
|
+
}
|
|
5336
|
+
snapshot() {
|
|
5337
|
+
return {
|
|
5338
|
+
hasStartedTurn: this.hasStartedTurn,
|
|
5339
|
+
latestResultEvent: this.latestResultEvent,
|
|
5340
|
+
latestErrorEvent: this.latestErrorEvent,
|
|
5341
|
+
sawRateLimit: this.sawRateLimit
|
|
5342
|
+
};
|
|
5343
|
+
}
|
|
5344
|
+
buildTurnStartedEvent(message, type) {
|
|
5345
|
+
return {
|
|
5346
|
+
name: "agent.turnStarted",
|
|
5347
|
+
payload: {
|
|
5348
|
+
observabilityEvent: observabilityEventName(type),
|
|
5349
|
+
params: message
|
|
5350
|
+
}
|
|
5351
|
+
};
|
|
5352
|
+
}
|
|
5353
|
+
};
|
|
5354
|
+
function isClaudeResultError(message) {
|
|
5355
|
+
const subtype = getString(message.subtype);
|
|
5356
|
+
const stopReason = getString(message.stop_reason);
|
|
5357
|
+
return message.is_error === true || subtype !== void 0 && subtype.startsWith("error") || stopReason !== void 0 && stopReason.startsWith("error");
|
|
5358
|
+
}
|
|
5359
|
+
function extractRateLimit(message) {
|
|
5360
|
+
const usage = asRecord(message.usage);
|
|
5361
|
+
const rateLimit = usage ? asRecord(usage.rate_limit) : null;
|
|
5362
|
+
if (rateLimit) {
|
|
5363
|
+
return rateLimit;
|
|
5364
|
+
}
|
|
5365
|
+
return asRecord(message.rate_limit);
|
|
5366
|
+
}
|
|
5367
|
+
function getClaudeResultStatus(message) {
|
|
5368
|
+
if (!message) {
|
|
5369
|
+
return void 0;
|
|
5370
|
+
}
|
|
5371
|
+
return getString(message.subtype) ?? getString(message.stop_reason);
|
|
5372
|
+
}
|
|
5373
|
+
function mapToolUseEvent(message, options) {
|
|
5374
|
+
const type = getEventType(message);
|
|
5375
|
+
const contentBlock = asRecord(message.content_block);
|
|
5376
|
+
const toolUse = type === "tool_use" ? message : contentBlock && getString(contentBlock.type) === "tool_use" ? contentBlock : null;
|
|
2415
5377
|
if (!toolUse) {
|
|
2416
5378
|
return null;
|
|
2417
5379
|
}
|
|
@@ -2600,6 +5562,7 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2600
5562
|
spawnErrorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
2601
5563
|
});
|
|
2602
5564
|
if ((classification.kind === "app-error" || classification.kind === "process-error") && !emittedErrorEvent) {
|
|
5565
|
+
const stderrSummary = summarizeClaudeStderr(records);
|
|
2603
5566
|
emitEvent({
|
|
2604
5567
|
name: "agent.error",
|
|
2605
5568
|
payload: {
|
|
@@ -2608,9 +5571,10 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2608
5571
|
exitCode: outcome.exitCode,
|
|
2609
5572
|
signal: outcome.signal,
|
|
2610
5573
|
classification,
|
|
2611
|
-
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
5574
|
+
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0,
|
|
5575
|
+
stderr: stderrSummary ?? void 0
|
|
2612
5576
|
},
|
|
2613
|
-
error: classification.reason
|
|
5577
|
+
error: stderrSummary ? `${classification.reason}: ${stderrSummary}` : classification.reason
|
|
2614
5578
|
}
|
|
2615
5579
|
});
|
|
2616
5580
|
}
|
|
@@ -2626,6 +5590,13 @@ async function spawnClaudeTurn(input, dependencies = {}) {
|
|
|
2626
5590
|
errorMessage: "errorMessage" in outcome ? outcome.errorMessage : void 0
|
|
2627
5591
|
};
|
|
2628
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
|
+
}
|
|
2629
5600
|
async function collectNdjsonStream(stream, channel, records, eventMapper, onEvent) {
|
|
2630
5601
|
if (!stream) {
|
|
2631
5602
|
return;
|
|
@@ -2804,7 +5775,7 @@ var ClaudeSessionStore = class {
|
|
|
2804
5775
|
}
|
|
2805
5776
|
};
|
|
2806
5777
|
function parseClaudeSessionFile(value) {
|
|
2807
|
-
if (!
|
|
5778
|
+
if (!isRecord5(value)) {
|
|
2808
5779
|
throw new Error("Claude session file must be a JSON object.");
|
|
2809
5780
|
}
|
|
2810
5781
|
if (value.protocol !== CLAUDE_SESSION_PROTOCOL) {
|
|
@@ -2821,7 +5792,7 @@ function parseClaudeSessionFile(value) {
|
|
|
2821
5792
|
if ("parentRunId" in value && value.parentRunId !== void 0 && typeof value.parentRunId !== "string") {
|
|
2822
5793
|
throw new Error("Claude session file parentRunId must be a string.");
|
|
2823
5794
|
}
|
|
2824
|
-
if ("protocolState" in value && value.protocolState !== void 0 && !
|
|
5795
|
+
if ("protocolState" in value && value.protocolState !== void 0 && !isRecord5(value.protocolState)) {
|
|
2825
5796
|
throw new Error("Claude session file protocolState must be an object.");
|
|
2826
5797
|
}
|
|
2827
5798
|
return {
|
|
@@ -2829,10 +5800,10 @@ function parseClaudeSessionFile(value) {
|
|
|
2829
5800
|
sessionId: value.sessionId,
|
|
2830
5801
|
createdAt: value.createdAt,
|
|
2831
5802
|
parentRunId: typeof value.parentRunId === "string" ? value.parentRunId : void 0,
|
|
2832
|
-
protocolState:
|
|
5803
|
+
protocolState: isRecord5(value.protocolState) ? value.protocolState : {}
|
|
2833
5804
|
};
|
|
2834
5805
|
}
|
|
2835
|
-
function
|
|
5806
|
+
function isRecord5(value) {
|
|
2836
5807
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2837
5808
|
}
|
|
2838
5809
|
function isFileNotFoundError(error) {
|
|
@@ -3287,6 +6258,10 @@ function buildClaudeMcpTokenEnvironment(options) {
|
|
|
3287
6258
|
GITHUB_TOKEN_BROKER_SECRET: source.GITHUB_TOKEN_BROKER_SECRET,
|
|
3288
6259
|
GITHUB_TOKEN_CACHE_PATH: source.GITHUB_TOKEN_CACHE_PATH,
|
|
3289
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,
|
|
3290
6265
|
WORKSPACE_RUNTIME_DIR: options.runtimeDirectory ?? source.WORKSPACE_RUNTIME_DIR
|
|
3291
6266
|
};
|
|
3292
6267
|
}
|
|
@@ -3297,6 +6272,7 @@ export {
|
|
|
3297
6272
|
isStateActive,
|
|
3298
6273
|
isStateTerminal,
|
|
3299
6274
|
matchesWorkflowState,
|
|
6275
|
+
DEFAULT_LINEAR_GRAPHQL_URL,
|
|
3300
6276
|
DEFAULT_MAX_FAILURE_RETRIES,
|
|
3301
6277
|
resolveWorkflowRuntimeCommand,
|
|
3302
6278
|
resolveWorkflowRuntimeTimeouts,
|
|
@@ -3327,10 +6303,12 @@ export {
|
|
|
3327
6303
|
safeReadDir,
|
|
3328
6304
|
isFileMissing,
|
|
3329
6305
|
parseRecentEvents,
|
|
6306
|
+
redactObservabilitySecrets,
|
|
3330
6307
|
isMatchingIssueRun,
|
|
3331
6308
|
mapIssueOrchestrationStateToStatus,
|
|
3332
6309
|
resolveGitHubGraphQLToken,
|
|
3333
6310
|
createGitHubGraphQLMcpServerEntry,
|
|
6311
|
+
createLinearGraphQLMcpServerEntry,
|
|
3334
6312
|
createClaudePrintRuntimeAdapter,
|
|
3335
6313
|
runClaudePreflight,
|
|
3336
6314
|
formatClaudePreflightText,
|