@devries-cameron20 / t3code Mirror · read-only / commits / c3a36af872
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 13:00 UTC

refactor(github): all GitHub GraphQL on effect/graphql, one request policy for REST and GraphQL (#19224)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 15, 2026 at 15:29 UTC c3a36af8728c8a25933cb5fd46c7a6426ed5e49d
55 files changed +85341 -5486
.gitattributes
+3
@@ -3,3 +3,6 @@
3 # Batch files need CRLF for cmd.exe to parse them reliably.
4 *.cmd text eol=crlf
5 *.bat text eol=crlf
6 +# GitHub's GraphQL schema and the operations graphqlgen writes from it.
7 +packages/source-control-github/schema/** linguist-generated
8 +**/*.graphql.ts linguist-generated
.github/workflows/ci.yml
+3
@@ -52,6 +52,9 @@ jobs:
52 - name: Check unused code
53 run: vp run knip:check
54
55 + - name: Check generated GitHub GraphQL operations
56 + run: vp run --filter @t3tools/source-control-github generate --check
57 +
58 - name: Check
59 run: vp check
60
apps/server/scripts/measure-pr-preview.ts
+51 -54
@@ -1,23 +1,21 @@
1 // Run with: node apps/server/scripts/measure-pr-preview.ts owner/repo 123 456
2 // Numbers form a session with shared repository-permission caches. Browser and
3 // service caches are excluded. Uses real GitHub reads, without a server or database.
4 -// Each GraphQL read asks for `rateLimit` here, so its cost is read off its own answer.
4 +// Requests are counted at the HTTP client. A GraphQL request's cost is how far it moved GitHub's
5 +// `x-ratelimit-used` for the `graphql` resource, which is approximate when anything else spends
6 +// the same token's quota while this runs.
7 import * as NodeServices from "@effect/platform-node/NodeServices";
8 import * as Effect from "effect/Effect";
9 import * as Console from "effect/Console";
10 import * as Layer from "effect/Layer";
9 -import * as Option from "effect/Option";
11 import * as Schema from "effect/Schema";
11 -import { FetchHttpClient } from "effect/http";
12 +import { FetchHttpClient, HttpClient } from "effect/http";
13
14 import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
15 import * as GitHubPullRequestProvider from "@t3tools/source-control-github/server/GitHubPullRequestProvider";
15 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
16 -import * as GitHubCredentials from "@t3tools/source-control-github/server/GitHubCredentials";
16 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
17 import * as ServerConfig from "../src/config.ts";
18 import * as ServerSettings from "../src/serverSettings.ts";
19 -import * as GitHubQuota from "@t3tools/source-control-github/server/GitHubQuota";
20 -import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
19 import * as ServerSourceControlHost from "../src/sourceControl/ServerSourceControlHost.ts";
20 import * as GitVcsDriver from "../src/vcs/GitVcsDriver.ts";
21 import * as VcsDriverRegistry from "../src/vcs/VcsDriverRegistry.ts";
@@ -31,21 +29,50 @@ if (!repository || numbers.length === 0 || numbers.some((number) => !/^\d+$/.tes
29
30 type Read = { graphqlRequests: number; restRequests: number; cost: number };
31 const reads: Read[] = [];
34 -const decodeCost = Schema.decodeUnknownOption(
32 +
33 +/** The `graphql` quota's use so far, and the window it counts in. */
34 +let graphqlUsed: { used: number; reset: string } | null = null;
35 +const decodeRateLimit = Schema.decodeUnknownSync(
36 Schema.fromJsonString(
37 Schema.Struct({
37 - data: Schema.Struct({ rateLimit: Schema.Struct({ cost: Schema.Number }) }),
38 + resources: Schema.Struct({
39 + graphql: Schema.Struct({ used: Schema.Number, reset: Schema.Number }),
40 + }),
41 }),
42 ),
43 );
41 -/** The query with GitHub's own count of what it cost, for a read rather than a mutation. */
42 -function withRateLimit(query: string): string {
43 - const end = query.lastIndexOf("}");
44 - return query.trimStart().startsWith("mutation") || end === -1
45 - ? query
46 - : `${query.slice(0, end)}\n rateLimit { cost }\n${query.slice(end)}`;
44 +
45 +/**
46 + * What one GraphQL answer spent: how far it moved `used` past the highest value seen, so requests
47 + * answered out of order still add up to the window's total. A new window starts from zero.
48 + */
49 +function graphqlCost(headers: Readonly<Record<string, string | undefined>>): number {
50 + const used = Number(headers["x-ratelimit-used"]);
51 + const reset = headers["x-ratelimit-reset"] ?? "";
52 + if (headers["x-ratelimit-resource"] !== "graphql" || !Number.isFinite(used)) return 0;
53 + const previous = graphqlUsed?.reset === reset ? graphqlUsed.used : 0;
54 + graphqlUsed = { used: Math.max(previous, used), reset };
55 + return Math.max(0, used - previous);
56 }
57
58 +/** The HTTP client the GitHub transports send through, recording each request as it is answered. */
59 +const measuredHttp = Layer.effect(
60 + HttpClient.HttpClient,
61 + Effect.gen(function* () {
62 + const client = yield* HttpClient.HttpClient;
63 + return HttpClient.tap(client, (response) =>
64 + Effect.sync(() => {
65 + const graphql = new URL(response.request.url).pathname.endsWith("/graphql");
66 + reads.push({
67 + graphqlRequests: graphql ? 1 : 0,
68 + restRequests: graphql ? 0 : 1,
69 + cost: graphql ? graphqlCost(response.headers) : 0,
70 + });
71 + }),
72 + );
73 + }),
74 +).pipe(Layer.provide(FetchHttpClient.layer));
75 +
76 // The server's host port over default settings: gh's own account choice, no saved token.
77 const sourceControlHost = ServerSourceControlHost.layer.pipe(
78 Layer.provide(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProjectConfig.layer))),
@@ -57,46 +84,9 @@ const sourceControlHost = ServerSourceControlHost.layer.pipe(
84 Layer.provideMerge(NodeServices.layer),
85 );
86
60 -const measuredApi = Layer.effect(
61 - GitHubApi.GitHubApi,
62 - Effect.gen(function* () {
63 - const api = yield* GitHubApi.make;
64 - return GitHubApi.GitHubApi.of({
65 - ...api,
66 - graphql: (input) =>
67 - api.graphql({ ...input, query: withRateLimit(input.query) }).pipe(
68 - Effect.tap((body) =>
69 - Effect.sync(() =>
70 - reads.push({
71 - graphqlRequests: 1,
72 - restRequests: 0,
73 - cost: Option.match(decodeCost(body), {
74 - onNone: () => 0,
75 - onSome: (decoded) => decoded.data.rateLimit.cost,
76 - }),
77 - }),
78 - ),
79 - ),
80 - ),
81 - rest: (input) =>
82 - api
83 - .rest(input)
84 - .pipe(
85 - Effect.tap(() =>
86 - Effect.sync(() => reads.push({ graphqlRequests: 0, restRequests: 1, cost: 0 })),
87 - ),
88 - ),
89 - });
90 - }),
91 -).pipe(
92 - Layer.provide(GitHubCredentials.layer),
93 - Layer.provide(GitHubQuota.layer),
94 - Layer.provide(SourceControlRateLimit.layer),
95 - Layer.provide(FetchHttpClient.layer),
96 -);
97 -
87 const services = GitHubPullRequestApi.layer.pipe(
99 - Layer.provideMerge(measuredApi),
88 + Layer.provideMerge(GitHubRest.layerWithDependencies),
89 + Layer.provideMerge(measuredHttp),
90 Layer.provideMerge(sourceControlHost),
91 );
92
@@ -108,6 +98,13 @@ for (const mode of ["detail", "preview"] as const) {
98 Effect.scoped(
99 Effect.gen(function* () {
100 const provider = yield* GitHubPullRequestProvider.make;
101 + // Where the `graphql` quota stands before the first read. `rate_limit` is free.
102 + const api = yield* GitHubRest.GitHubRest;
103 + const limits = decodeRateLimit(
104 + (yield* api.rest({ host: "github.com", operation: "rateLimit", path: "rate_limit" }))
105 + .body,
106 + ).resources.graphql;
107 + graphqlUsed = { used: limits.used, reset: String(limits.reset) };
108 return yield* Effect.forEach(numbers.map(Number), (number) =>
109 Effect.gen(function* () {
110 const input = { cwd: process.cwd(), repository, host: "github.com", number };
apps/server/src/project/AgentSessionScanner.ts
+3 -8
@@ -592,8 +592,8 @@ function transcriptIdentity(filePath: string, stats: FileSystem.File.Info) {
592 filePath,
593 size: Number(stats.size),
594 mtimeMs: Option.match(stats.mtime, { onNone: () => null, onSome: (date) => date.getTime() }),
595 - device: stats.dev,
596 - inode: Option.getOrNull(stats.ino),
595 + device: Number(stats.dev),
596 + inode: Option.match(stats.ino, { onNone: () => null, onSome: Number }),
597 birthtimeMs: Option.match(stats.birthtime, {
598 onNone: () => null,
599 onSome: (date) => date.getTime(),
@@ -671,12 +671,7 @@ export const make = Effect.gen(function* () {
671 ) {
672 const resolved = path.resolve(target);
673 const stats = knownStats === undefined ? yield* statOption(resolved) : Option.some(knownStats);
674 - if (
675 - Option.isSome(stats) &&
676 - Option.isSome(stats.value.ino) &&
677 - Number.isSafeInteger(stats.value.ino.value) &&
678 - stats.value.ino.value > 0
679 - ) {
674 + if (Option.isSome(stats) && Option.isSome(stats.value.ino) && stats.value.ino.value > 0n) {
675 return `inode:${stats.value.dev}:${stats.value.ino.value}`;
676 }
677 const realPath = yield* fileSystem
apps/server/src/pullRequest/PullRequestProviderRateLimit.test.ts
+3 -2
@@ -3,7 +3,8 @@ import { assert, it } from "@effect/vitest";
3
4 import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsCli";
5 import * as BitbucketApi from "@t3tools/source-control-bitbucket/server/BitbucketApi";
6 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
6 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
7 +import * as GitHubRequestPolicy from "@t3tools/source-control-github/server/GitHubRequestPolicy";
8 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
9 import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";
10 import { azureDevOpsProviderFailure } from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestProvider";
@@ -16,7 +17,7 @@ const cause = new Error("redacted provider failure");
17 it("classifies rate limits from every pull-request provider", () => {
18 assert.deepStrictEqual(
19 gitHubProviderFailure(
19 - new GitHubApi.GitHubApiRateLimitError({ host: "github.com", operation: "execute" }),
20 + new GitHubRequestPolicy.GitHubApiRateLimitError({ host: "github.com", operation: "execute" }),
21 ),
22 { reason: "rate-limited" },
23 );
apps/server/src/pullRequest/PullRequestService.test.ts
+15 -8
@@ -36,7 +36,7 @@ import * as SourceControlProviderRegistry from "../sourceControl/SourceControlPr
36 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
37 import * as ForgejoCli from "@t3tools/source-control-forgejo/server/ForgejoCli";
38 import * as ForgejoPullRequestProvider from "@t3tools/source-control-forgejo/server/ForgejoPullRequestProvider";
39 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
39 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
40 import * as GitHubCredentials from "@t3tools/source-control-github/server/GitHubCredentials";
41 import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
42 import * as GitHubPullRequestProvider from "@t3tools/source-control-github/server/GitHubPullRequestProvider";
@@ -1750,13 +1750,14 @@ it.effect("keeps branch deletion on the credential that passed source repository
1750 body = {
1751 data: {
1752 node: {
1753 + __typename: "Repository",
1754 defaultBranchRef: { name: "main" },
1754 - ref: { target: { oid: "abc123" } },
1755 + ref: { target: { __typename: "Commit", oid: "abc123" } },
1756 },
1757 },
1758 };
1759 } else if (operation.includes("updateRefs(")) {
1759 - body = { data: { updateRefs: {} } };
1760 + body = { data: { updateRefs: { clientMutationId: null } } };
1761 } else {
1762 activeToken = "account-b";
1763 body = {
@@ -1775,18 +1776,24 @@ it.effect("keeps branch deletion on the credential that passed source repository
1776 },
1777 };
1778 }
1778 - return HttpClientResponse.fromWeb(request, new Response(JSON.stringify(body)));
1779 + return HttpClientResponse.fromWeb(
1780 + request,
1781 + new Response(JSON.stringify(body), {
1782 + headers: { "content-type": "application/json" },
1783 + }),
1784 + );
1785 }),
1786 ),
1787 );
1788 const provider = yield* GitHubPullRequestProvider.make.pipe(
1789 Effect.provide(
1790 GitHubPullRequestApi.layer.pipe(
1791 + // GraphQL reads go over `http` too, through the same credential and quota as REST.
1792 Layer.provide(
1786 - GitHubApi.layer.pipe(
1787 - Layer.provide(Layer.mergeAll(credentials, http)),
1788 - Layer.provide(GitHubQuota.layer),
1789 - Layer.provide(SourceControlRateLimit.layer),
1793 + GitHubRest.layer.pipe(
1794 + Layer.provideMerge(Layer.mergeAll(credentials, http)),
1795 + Layer.provideMerge(GitHubQuota.layer),
1796 + Layer.provideMerge(SourceControlRateLimit.layer),
1797 ),
1798 ),
1799 Layer.provide(TestSourceControlHost.layer()),
apps/server/src/sourceControl/SourceControlDiscovery.test.ts
+9 -2
@@ -21,7 +21,8 @@ import * as AzureDevOpsCli from "@t3tools/source-control-azure-devops/server/Azu
21 import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli";
22 import * as BitbucketApi from "@t3tools/source-control-bitbucket/server/BitbucketApi";
23 import * as BitbucketPullRequestApi from "@t3tools/source-control-bitbucket/server/BitbucketPullRequestApi";
24 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
24 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
25 +import * as GitHubRequestPolicy from "@t3tools/source-control-github/server/GitHubRequestPolicy";
26 import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
27 import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";
28 import * as GitLabPullRequestCli from "@t3tools/source-control-gitlab/server/GitLabPullRequestCli";
@@ -51,7 +52,13 @@ const layerSourceControlProviderRegistryTest = (input: {
52 Layer.mock(BitbucketPullRequestApi.BitbucketPullRequestApi)({}),
53 ServerSettings.ServerSettingsService.layerTest(),
54 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({}),
54 - Layer.mock(GitHubApi.GitHubApi)({}),
55 + Layer.mock(GitHubRest.GitHubRest)({}),
56 + // The GitHub provider's GraphQL reads go through these; no test here makes one.
57 + Layer.mock(GitHubRequestPolicy.GitHubRequestPolicy)({}),
58 + Layer.succeed(
59 + HttpClient.HttpClient,
60 + HttpClient.make(() => Effect.die(new Error("Unexpected GitHub GraphQL read"))),
61 + ),
62 Layer.mock(GitVcsDriver.GitVcsDriver)({}),
63 Layer.mock(GitLabCli.GitLabCli)({}),
64 Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({}),
apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
+11 -3
@@ -12,6 +12,7 @@ import * as PubSub from "effect/PubSub";
12 import * as Redacted from "effect/Redacted";
13 import * as Stream from "effect/Stream";
14 import * as TestClock from "effect/testing/TestClock";
15 +import { HttpClient } from "effect/http";
16 import { ChildProcessSpawner } from "effect/process";
17 import {
18 DEFAULT_SERVER_SETTINGS,
@@ -30,7 +31,8 @@ import * as AzureDevOpsPullRequestCli from "@t3tools/source-control-azure-devops
31 import * as BitbucketApi from "@t3tools/source-control-bitbucket/server/BitbucketApi";
32 import * as BitbucketPullRequestApi from "@t3tools/source-control-bitbucket/server/BitbucketPullRequestApi";
33 import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
33 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
34 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
35 +import * as GitHubRequestPolicy from "@t3tools/source-control-github/server/GitHubRequestPolicy";
36 import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
37 import * as GitHubCredentials from "@t3tools/source-control-github/server/GitHubCredentials";
38 import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";
@@ -63,7 +65,7 @@ function makeRegistry(input: {
65 readonly url: string;
66 }>;
67 readonly process?: Partial<VcsProcess.VcsProcess["Service"]>;
66 - readonly githubApi?: Partial<GitHubApi.GitHubApi["Service"]>;
68 + readonly githubApi?: Partial<GitHubRest.GitHubRest["Service"]>;
69 readonly gitlab?: Partial<GitLabCli.GitLabCli["Service"]>;
70 readonly forgejo?: Partial<ForgejoCli.ForgejoCli["Service"]>;
71 readonly settings?: Partial<ServerSettings.ServerSettingsService["Service"]>;
@@ -135,7 +137,13 @@ function makeRegistry(input: {
137 ? Layer.mock(ServerSettings.ServerSettingsService)(input.settings)
138 : ServerSettings.ServerSettingsService.layerTest(),
139 Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({}),
138 - Layer.mock(GitHubApi.GitHubApi)({
140 + // The GitHub provider's GraphQL reads go through these; no test here makes one.
141 + Layer.mock(GitHubRequestPolicy.GitHubRequestPolicy)({}),
142 + Layer.succeed(
143 + HttpClient.HttpClient,
144 + HttpClient.make(() => Effect.die(new Error("Unexpected GitHub GraphQL read"))),
145 + ),
146 + Layer.mock(GitHubRest.GitHubRest)({
147 // No GitHub credential unless a test supplies one, so custom hosts stay unclaimed.
148 credential: (host) => Effect.fail(new GitHubCredentials.GitHubNotSignedInError({ host })),
149 ...input.githubApi,
apps/server/src/sourceControl/builtInDrivers.ts
+3 -3
@@ -18,7 +18,7 @@ import * as ForgejoDriver from "@t3tools/source-control-forgejo/server/driver";
18 import * as GitCafeApi from "@t3tools/source-control-gitcafe/server/GitCafeApi";
19 import * as GitCafeCredentials from "@t3tools/source-control-gitcafe/server/GitCafeCredentials";
20 import * as GitCafeDriver from "@t3tools/source-control-gitcafe/server/driver";
21 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
21 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
22 import * as GitHubPullRequestApi from "@t3tools/source-control-github/server/GitHubPullRequestApi";
23 import * as GitHubDriver from "@t3tools/source-control-github/server/driver";
24 import * as GitLabCli from "@t3tools/source-control-gitlab/server/GitLabCli";
@@ -49,9 +49,9 @@ export const BUILT_IN_SOURCE_CONTROL_DRIVERS: ReadonlyArray<
49
50 /** The services the built-in drivers' packages own, plus the host port they all run against. */
51 export const layer = Layer.mergeAll(
52 - // `GitHubApi.layerWithDependencies` carries the quota reserve and rate-limit pause every GitHub
52 + // `GitHubRest.layerWithDependencies` carries the quota reserve and rate-limit pause every GitHub
53 // reader shares, so the server builds it once, here.
54 - GitHubPullRequestApi.layer.pipe(Layer.provideMerge(GitHubApi.layerWithDependencies)),
54 + GitHubPullRequestApi.layer.pipe(Layer.provideMerge(GitHubRest.layerWithDependencies)),
55 AzureDevOpsPullRequestCli.layer.pipe(Layer.provideMerge(AzureDevOpsCli.layer)),
56 BitbucketPullRequestApi.layer.pipe(Layer.provideMerge(BitbucketApi.layer)),
57 ForgejoCli.layer,
apps/server/src/sourceControl/githubStackRebase.test.ts
+2 -2
@@ -5,7 +5,7 @@ import * as FileSystem from "effect/FileSystem";
5 import * as Layer from "effect/Layer";
6 import * as Redacted from "effect/Redacted";
7
8 -import * as GitHubApi from "@t3tools/source-control-github/server/GitHubApi";
8 +import * as GitHubRest from "@t3tools/source-control-github/server/GitHubRest";
9 import { cascadeRebaseStack } from "@t3tools/source-control-github/server/githubStackRebase";
10
11 import * as ServerSettings from "../serverSettings.ts";
@@ -15,7 +15,7 @@ import * as VcsProcess from "../vcs/VcsProcess.ts";
15 import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
16
17 const layer = Layer.mergeAll(
18 - Layer.mock(GitHubApi.GitHubApi)({
18 + Layer.mock(GitHubRest.GitHubRest)({
19 credential: () => Effect.succeed({ token: Redacted.make("token"), fingerprint: "fp" }),
20 }),
21 // The cascade runs real git through the server's host; the git driver itself is never asked.
knip.jsonc
+5
@@ -110,5 +110,10 @@
110 "entry": ["test/fixtures/*.ts"],
111 "ignoreIssues": { "src/_generated/**": ["exports", "types"] },
112 },
113 + "packages/source-control-github": {
114 + // graphqlgen reads its config; the generated operations export every selection's class.
115 + "entry": ["graphql.config.ts"],
116 + "ignoreIssues": { "**/*.graphql.ts": ["exports", "types", "namespaceMembers"] },
117 + },
118 },
119 }
packages/shared/src/nodeRuntime.ts
+1 -2
@@ -100,8 +100,7 @@ export const resolveNodeExecutable = Effect.fn("nodeRuntime.resolveNodeExecutabl
100 hostInfo.value.dev === nodeInfo.value.dev &&
101 Option.isSome(hostInfo.value.ino) &&
102 Option.isSome(nodeInfo.value.ino) &&
103 - Number.isSafeInteger(hostInfo.value.ino.value) &&
104 - hostInfo.value.ino.value > 0 &&
103 + hostInfo.value.ino.value > 0n &&
104 hostInfo.value.ino.value === nodeInfo.value.ino.value
105 ) {
106 return yield* new NodeRuntimeUnavailableError({ feature });
packages/source-control-github/graphql.config.ts new
+16
@@ -0,0 +1,16 @@
1 +import { defineConfig } from "@effect/graphql-generator/Config";
2 +
3 +// `schema/github.graphql` is github.com's public schema
4 +// (https://docs.github.com/public/fpt/schema.docs.graphql). Enterprise Server lacks some of its
5 +// fields, such as pull request stacks, so a document asks for those under `@include`.
6 +export default defineConfig({
7 + schema: "./schema/github.graphql",
8 + documents: ["src/**/*.graphql"],
9 + scalars: {
10 + GitObjectID: "effect/Schema#String",
11 + // A fully qualified ref name such as `refs/heads/main`.
12 + GitRefname: "effect/Schema#String",
13 + // Kept as GitHub sends it: callers compare these strings with other reads of the same field.
14 + DateTime: "effect/Schema#String",
15 + },
16 +});
packages/source-control-github/package.json
+9 -7
@@ -11,9 +11,9 @@
11 "types": "./src/server/driver.ts",
12 "import": "./src/server/driver.ts"
13 },
14 - "./server/GitHubApi": {
15 - "types": "./src/server/GitHubApi.ts",
16 - "import": "./src/server/GitHubApi.ts"
14 + "./server/GitHubRest": {
15 + "types": "./src/server/GitHubRest.ts",
16 + "import": "./src/server/GitHubRest.ts"
17 },
18 "./server/gitHubAuthStatus": {
19 "types": "./src/server/gitHubAuthStatus.ts",
@@ -31,9 +31,9 @@
31 "types": "./src/server/GitHubCredentials.ts",
32 "import": "./src/server/GitHubCredentials.ts"
33 },
34 - "./server/githubGraphQl": {
35 - "types": "./src/server/githubGraphQl.ts",
36 - "import": "./src/server/githubGraphQl.ts"
34 + "./server/GitHubRequestPolicy": {
35 + "types": "./src/server/GitHubRequestPolicy.ts",
36 + "import": "./src/server/GitHubRequestPolicy.ts"
37 },
38 "./server/GitHubPullRequestApi": {
39 "types": "./src/server/GitHubPullRequestApi.ts",
@@ -74,7 +74,8 @@
74 },
75 "scripts": {
76 "typecheck": "tsc-rs --noEmit",
77 - "test": "vp test run --config ../../vite.config.ts --dir ."
77 + "test": "vp test run --config ../../vite.config.ts --dir .",
78 + "generate": "graphqlgen"
79 },
80 "dependencies": {
81 "@t3tools/contracts": "workspace:*",
@@ -84,6 +85,7 @@
85 "effect": "catalog:"
86 },
87 "devDependencies": {
88 + "@effect/graphql-generator": "catalog:",
89 "@effect/platform-node": "catalog:",
90 "@effect/vitest": "catalog:",
91 "@t3tools/source-control-testing": "workspace:*",
packages/source-control-github/schema/github.graphql new
+75217
@@ -0,0 +1,75217 @@
1 +"""
2 +Marks an element of a GraphQL schema as only available via a preview header
3 +"""
4 +directive @preview(
5 + """
6 + The identifier of the API preview that toggles this field.
7 + """
8 + toggledBy: String!
9 +) on ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION
10 +
11 +"""
12 +Defines what type of global IDs are accepted for a mutation argument of type ID.
13 +"""
14 +directive @possibleTypes(
15 + """
16 + Abstract type of accepted global ID
17 + """
18 + abstractType: String
19 +
20 + """
21 + Accepted types of global IDs.
22 + """
23 + concreteTypes: [String!]!
24 +) on INPUT_FIELD_DEFINITION
25 +
26 +"""
27 +Assigns a documentation category for docs.github.com, aligned with REST API reference sections.
28 +"""
29 +directive @docsCategory(
30 + """
31 + The category slug (e.g. "issues", "pulls", "repos").
32 + """
33 + name: String!
34 +) on ENUM | FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | UNION
35 +
36 +"""
37 +Autogenerated input type of AbortQueuedMigrations
38 +"""
39 +input AbortQueuedMigrationsInput {
40 + """
41 + A unique identifier for the client performing the mutation.
42 + """
43 + clientMutationId: String
44 +
45 + """
46 + The ID of the organization that is running the migrations.
47 + """
48 + ownerId: ID! @possibleTypes(concreteTypes: ["Organization"])
49 +}
50 +
51 +"""
52 +Autogenerated return type of AbortQueuedMigrations.
53 +"""
54 +type AbortQueuedMigrationsPayload {
55 + """
56 + A unique identifier for the client performing the mutation.
57 + """
58 + clientMutationId: String
59 +
60 + """
61 + Did the operation succeed?
62 + """
63 + success: Boolean
64 +}
65 +
66 +"""
67 +Autogenerated input type of AbortRepositoryMigration
68 +"""
69 +input AbortRepositoryMigrationInput {
70 + """
71 + A unique identifier for the client performing the mutation.
72 + """
73 + clientMutationId: String
74 +
75 + """
76 + The ID of the migration to be aborted.
77 + """
78 + migrationId: ID! @possibleTypes(concreteTypes: ["RepositoryMigration"])
79 +}
80 +
81 +"""
82 +Autogenerated return type of AbortRepositoryMigration.
83 +"""
84 +type AbortRepositoryMigrationPayload {
85 + """
86 + A unique identifier for the client performing the mutation.
87 + """
88 + clientMutationId: String
89 +
90 + """
91 + Did the operation succeed?
92 + """
93 + success: Boolean
94 +}
95 +
96 +"""
97 +Autogenerated input type of AcceptEnterpriseAdministratorInvitation
98 +"""
99 +input AcceptEnterpriseAdministratorInvitationInput {
100 + """
101 + A unique identifier for the client performing the mutation.
102 + """
103 + clientMutationId: String
104 +
105 + """
106 + The id of the invitation being accepted
107 + """
108 + invitationId: ID! @possibleTypes(concreteTypes: ["EnterpriseAdministratorInvitation"])
109 +}
110 +
111 +"""
112 +Autogenerated return type of AcceptEnterpriseAdministratorInvitation.
113 +"""
114 +type AcceptEnterpriseAdministratorInvitationPayload {
115 + """
116 + A unique identifier for the client performing the mutation.
117 + """
118 + clientMutationId: String
119 +
120 + """
121 + The invitation that was accepted.
122 + """
123 + invitation: EnterpriseAdministratorInvitation
124 +
125 + """
126 + A message confirming the result of accepting an administrator invitation.
127 + """
128 + message: String
129 +}
130 +
131 +"""
132 +Autogenerated input type of AcceptEnterpriseMemberInvitation
133 +"""
134 +input AcceptEnterpriseMemberInvitationInput {
135 + """
136 + A unique identifier for the client performing the mutation.
137 + """
138 + clientMutationId: String
139 +
140 + """
141 + The id of the invitation being accepted
142 + """
143 + invitationId: ID! @possibleTypes(concreteTypes: ["EnterpriseMemberInvitation"])
144 +}
145 +
146 +"""
147 +Autogenerated return type of AcceptEnterpriseMemberInvitation.
148 +"""
149 +type AcceptEnterpriseMemberInvitationPayload {
150 + """
151 + A unique identifier for the client performing the mutation.
152 + """
153 + clientMutationId: String
154 +
155 + """
156 + The invitation that was accepted.
157 + """
158 + invitation: EnterpriseMemberInvitation
159 +
160 + """
161 + A message confirming the result of accepting an unaffiliated member invitation.
162 + """
163 + message: String
164 +}
165 +
166 +"""
167 +Autogenerated input type of AcceptTopicSuggestion
168 +"""
169 +input AcceptTopicSuggestionInput {
170 + """
171 + A unique identifier for the client performing the mutation.
172 + """
173 + clientMutationId: String
174 +
175 + """
176 + The name of the suggested topic.
177 +
178 + **Upcoming Change on 2024-04-01 UTC**
179 + **Description:** `name` will be removed.
180 + **Reason:** Suggested topics are no longer supported
181 + """
182 + name: String
183 +
184 + """
185 + The Node ID of the repository.
186 +
187 + **Upcoming Change on 2024-04-01 UTC**
188 + **Description:** `repositoryId` will be removed.
189 + **Reason:** Suggested topics are no longer supported
190 + """
191 + repositoryId: ID @possibleTypes(concreteTypes: ["Repository"])
192 +}
193 +
194 +"""
195 +Autogenerated return type of AcceptTopicSuggestion.
196 +"""
197 +type AcceptTopicSuggestionPayload {
198 + """
199 + A unique identifier for the client performing the mutation.
200 + """
201 + clientMutationId: String
202 +
203 + """
204 + The accepted topic.
205 + """
206 + topic: Topic @deprecated(reason: "Suggested topics are no longer supported Removal on 2024-04-01 UTC.")
207 +}
208 +
209 +"""
210 +Autogenerated input type of AccessUserNamespaceRepository
211 +"""
212 +input AccessUserNamespaceRepositoryInput {
213 + """
214 + A unique identifier for the client performing the mutation.
215 + """
216 + clientMutationId: String
217 +
218 + """
219 + The ID of the enterprise owning the user namespace repository.
220 + """
221 + enterpriseId: ID! @possibleTypes(concreteTypes: ["Enterprise"])
222 +
223 + """
224 + The ID of the user namespace repository to access.
225 + """
226 + repositoryId: ID!
227 +}
228 +
229 +"""
230 +Autogenerated return type of AccessUserNamespaceRepository.
231 +"""
232 +type AccessUserNamespaceRepositoryPayload {
233 + """
234 + A unique identifier for the client performing the mutation.
235 + """
236 + clientMutationId: String
237 +
238 + """
239 + The time that repository access expires at
240 + """
241 + expiresAt: DateTime
242 +
243 + """
244 + The repository that is temporarily accessible.
245 + """
246 + repository: Repository
247 +}
248 +
249 +"""
250 +Represents an object which can take actions on GitHub. Typically a User or Bot.
251 +"""
252 +interface Actor @docsCategory(name: "users") {
253 + """
254 + A URL pointing to the actor's public avatar.
255 + """
256 + avatarUrl(
257 + """
258 + The size of the resulting square image.
259 + """
260 + size: Int
261 + ): URI!
262 +
263 + """
264 + The username of the actor.
265 + """
266 + login: String!
267 +
268 + """
269 + The HTTP path for this actor.
270 + """
271 + resourcePath: URI!
272 +
273 + """
274 + The HTTP URL for this actor.
275 + """
276 + url: URI!
277 +}
278 +
279 +"""
280 +The connection type for Actor.
281 +"""
282 +type ActorConnection {
283 + """
284 + A list of edges.
285 + """
286 + edges: [ActorEdge]
287 +
288 + """
289 + A list of nodes.
290 + """
291 + nodes: [Actor]
292 +
293 + """
294 + Information to aid in pagination.
295 + """
296 + pageInfo: PageInfo!
297 +
298 + """
299 + Identifies the total count of items in the connection.
300 + """
301 + totalCount: Int!
302 +}
303 +
304 +"""
305 +An edge in a connection.
306 +"""
307 +type ActorEdge {
308 + """
309 + A cursor for use in pagination.
310 + """
311 + cursor: String!
312 +
313 + """
314 + The item at the end of the edge.
315 + """
316 + node: Actor
317 +}
318 +
319 +"""
320 +Location information for an actor
321 +"""
322 +type ActorLocation @docsCategory(name: "users") {
323 + """
324 + City
325 + """
326 + city: String
327 +
328 + """
329 + Country name
330 + """
331 + country: String
332 +
333 + """
334 + Country code
335 + """
336 + countryCode: String
337 +
338 + """
339 + Region name
340 + """
341 + region: String
342 +
343 + """
344 + Region or state code
345 + """
346 + regionCode: String
347 +}
348 +
349 +"""
350 +The actor's type.
351 +"""
352 +enum ActorType @docsCategory(name: "users") {
353 + """
354 + Indicates a team actor.
355 + """
356 + TEAM
357 +
358 + """
359 + Indicates a user actor.
360 + """
361 + USER
362 +}
363 +
364 +"""
365 +Autogenerated input type of AddAssigneesToAssignable
366 +"""
367 +input AddAssigneesToAssignableInput {
368 + """
369 + Configuration for assigning Copilot to this issue.
370 + """
371 + agentAssignment: AgentAssignmentInput
372 +
373 + """
374 + The id of the assignable object to add assignees to.
375 + """
376 + assignableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Assignable")
377 +
378 + """
379 + The ids of actors (users or bots) to add as assignees. Mutually exclusive with `assignees`.
380 + """
381 + assigneeIds: [ID!]
382 + @possibleTypes(
383 + concreteTypes: ["Bot", "EnterpriseUserAccount", "Mannequin", "Organization", "User"]
384 + abstractType: "Actor"
385 + )
386 +
387 + """
388 + An array of actors to add as assignees, each with optional rationale or
389 + suggest flag. Mutually exclusive with `assigneeIds`.
390 + """
391 + assignees: [AssigneeUpdateInput!]
392 +
393 + """
394 + A unique identifier for the client performing the mutation.
395 + """
396 + clientMutationId: String
397 +}
398 +
399 +"""
400 +Autogenerated return type of AddAssigneesToAssignable.
401 +"""
402 +type AddAssigneesToAssignablePayload {
403 + """
404 + The item that was assigned.
405 + """
406 + assignable: Assignable
407 +
408 + """
409 + A unique identifier for the client performing the mutation.
410 + """
411 + clientMutationId: String
412 +}
413 +
414 +"""
415 +Autogenerated input type of AddBlockedBy
416 +"""
417 +input AddBlockedByInput {
418 + """
419 + The ID of the issue that blocks the given issue.
420 + """
421 + blockingIssueId: ID! @possibleTypes(concreteTypes: ["Issue"])
422 +
423 + """
424 + A unique identifier for the client performing the mutation.
425 + """
426 + clientMutationId: String
427 +
428 + """
429 + The ID of the issue to be blocked.
430 + """
431 + issueId: ID! @possibleTypes(concreteTypes: ["Issue"])
432 +}
433 +
434 +"""
435 +Autogenerated return type of AddBlockedBy.
436 +"""
437 +type AddBlockedByPayload {
438 + """
439 + The issue that is blocking the given issue.
440 + """
441 + blockingIssue: Issue
442 +
443 + """
444 + A unique identifier for the client performing the mutation.
445 + """
446 + clientMutationId: String
447 +
448 + """
449 + The issue that is blocked.
450 + """
451 + issue: Issue
452 +}
453 +
454 +"""
455 +Autogenerated input type of AddCloseIssueReferences
456 +"""
457 +input AddCloseIssueReferencesInput {
458 + """
459 + A unique identifier for the client performing the mutation.
460 + """
461 + clientMutationId: String
462 +
463 + """
464 + ID of the issue to add closing references to.
465 + """
466 + issueId: ID! @possibleTypes(concreteTypes: ["Issue"])
467 +
468 + """
469 + IDs of the pull requests to link as closing references. Limit: 10.
470 + """
471 + pullRequestIds: [ID!]! @possibleTypes(concreteTypes: ["PullRequest"])
472 +}
473 +
474 +"""
475 +Autogenerated return type of AddCloseIssueReferences.
476 +"""
477 +type AddCloseIssueReferencesPayload {
478 + """
479 + A unique identifier for the client performing the mutation.
480 + """
481 + clientMutationId: String
482 +
483 + """
484 + The issue the closing references were added to.
485 + """
486 + issue: Issue
487 +}
488 +
489 +"""
490 +Autogenerated input type of AddComment
491 +"""
492 +input AddCommentInput {
493 + """
494 + The contents of the comment.
495 + """
496 + body: String!
497 +
498 + """
499 + A unique identifier for the client performing the mutation.
500 + """
501 + clientMutationId: String
502 +
503 + """
504 + The Node ID of the subject to modify.
505 + """
506 + subjectId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "IssueOrPullRequest")
507 +}
508 +
509 +"""
510 +Autogenerated return type of AddComment.
511 +"""
512 +type AddCommentPayload {
513 + """
514 + A unique identifier for the client performing the mutation.
515 + """
516 + clientMutationId: String
517 +
518 + """
519 + The edge from the subject's comment connection.
520 + """
521 + commentEdge: IssueCommentEdge
522 +
523 + """
524 + The subject
525 + """
526 + subject: Node
527 +
528 + """
529 + The edge from the subject's timeline connection.
530 + """
531 + timelineEdge: IssueTimelineItemEdge
532 +}
533 +
534 +"""
535 +Autogenerated input type of AddDiscussionComment
536 +"""
537 +input AddDiscussionCommentInput {
538 + """
539 + The contents of the comment.
540 + """
541 + body: String!
542 +
543 + """
544 + A unique identifier for the client performing the mutation.
545 + """
546 + clientMutationId: String
547 +
548 + """
549 + The Node ID of the discussion to comment on.
550 + """
551 + discussionId: ID! @possibleTypes(concreteTypes: ["Discussion"])
552 +
553 + """
554 + The Node ID of the discussion comment within this discussion to reply to.
555 + """
556 + replyToId: ID @possibleTypes(concreteTypes: ["DiscussionComment"])
557 +}
558 +
559 +"""
560 +Autogenerated return type of AddDiscussionComment.
561 +"""
562 +type AddDiscussionCommentPayload {
563 + """
564 + A unique identifier for the client performing the mutation.
565 + """
566 + clientMutationId: String
567 +
568 + """
569 + The newly created discussion comment.
570 + """
571 + comment: DiscussionComment
572 +}
573 +
574 +"""
575 +Autogenerated input type of AddDiscussionPollVote
576 +"""
577 +input AddDiscussionPollVoteInput {
578 + """
579 + A unique identifier for the client performing the mutation.
580 + """
581 + clientMutationId: String
582 +
583 + """
584 + The Node ID of the discussion poll option to vote for.
585 + """
586 + pollOptionId: ID! @possibleTypes(concreteTypes: ["DiscussionPollOption"])
587 +}
588 +
589 +"""
590 +Autogenerated return type of AddDiscussionPollVote.
591 +"""
592 +type AddDiscussionPollVotePayload {
593 + """
594 + A unique identifier for the client performing the mutation.
595 + """
596 + clientMutationId: String
597 +
598 + """
599 + The poll option that a vote was added to.
600 + """
601 + pollOption: DiscussionPollOption
602 +}
603 +
604 +"""
605 +Autogenerated input type of AddEnterpriseOrganizationMember
606 +"""
607 +input AddEnterpriseOrganizationMemberInput {
608 + """
609 + A unique identifier for the client performing the mutation.
610 + """
611 + clientMutationId: String
612 +
613 + """
614 + The ID of the enterprise which owns the organization.
615 + """
616 + enterpriseId: ID! @possibleTypes(concreteTypes: ["Enterprise"])
617 +
618 + """
619 + The ID of the organization the users will be added to.
620 + """
621 + organizationId: ID! @possibleTypes(concreteTypes: ["Organization"])
622 +
623 + """
624 + The role to assign the users in the organization
625 + """
626 + role: OrganizationMemberRole
627 +
628 + """
629 + The IDs of the enterprise members to add.
630 + """
631 + userIds: [ID!]!
632 +}
633 +
634 +"""
635 +Autogenerated return type of AddEnterpriseOrganizationMember.
636 +"""
637 +type AddEnterpriseOrganizationMemberPayload {
638 + """
639 + A unique identifier for the client performing the mutation.
640 + """
641 + clientMutationId: String
642 +
643 + """
644 + The users who were added to the organization.
645 + """
646 + users: [User!]
647 +}
648 +
649 +"""
650 +Autogenerated input type of AddEnterpriseSupportEntitlement
651 +"""
652 +input AddEnterpriseSupportEntitlementInput {
653 + """
654 + A unique identifier for the client performing the mutation.
655 + """
656 + clientMutationId: String
657 +
658 + """
659 + The ID of the Enterprise which the admin belongs to.
660 + """
661 + enterpriseId: ID! @possibleTypes(concreteTypes: ["Enterprise"])
662 +
663 + """
664 + The login of a member who will receive the support entitlement.
665 + """
666 + login: String!
667 +}
668 +
669 +"""
670 +Autogenerated return type of AddEnterpriseSupportEntitlement.
671 +"""
672 +type AddEnterpriseSupportEntitlementPayload {
673 + """
674 + A unique identifier for the client performing the mutation.
675 + """
676 + clientMutationId: String
677 +
678 + """
679 + A message confirming the result of adding the support entitlement.
680 + """
681 + message: String
682 +}
683 +
684 +"""
685 +Autogenerated input type of AddLabelsToLabelable
686 +"""
687 +input AddLabelsToLabelableInput {
688 + """
689 + A unique identifier for the client performing the mutation.
690 + """
691 + clientMutationId: String
692 +
693 + """
694 + The ids of the labels to add.
695 + """
696 + labelIds: [ID!] @possibleTypes(concreteTypes: ["Label"])
697 +
698 + """
699 + The id of the labelable object to add labels to.
700 + """
701 + labelableId: ID! @possibleTypes(concreteTypes: ["Discussion", "Issue", "PullRequest"], abstractType: "Labelable")
702 +
703 + """
704 + The labels to add, each with optional `rationale` or a `suggest` flag that
705 + stores the addition as a pending suggestion. Mutually exclusive with `labelIds`.
706 + """
707 + labels: [LabelUpdateInput!]
708 +}
709 +
710 +"""
711 +Autogenerated return type of AddLabelsToLabelable.
712 +"""
713 +type AddLabelsToLabelablePayload {
714 + """
715 + A unique identifier for the client performing the mutation.
716 + """
717 + clientMutationId: String
718 +
719 + """
720 + The item that was labeled.
721 + """
722 + labelable: Labelable
723 +}
724 +
725 +"""
726 +Autogenerated input type of AddProjectCard
727 +"""
728 +input AddProjectCardInput {
729 + """
730 + A unique identifier for the client performing the mutation.
731 + """
732 + clientMutationId: String
733 +
734 + """
735 + The content of the card. Must be a member of the ProjectCardItem union
736 + """
737 + contentId: ID @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "ProjectCardItem")
738 +
739 + """
740 + The note on the card.
741 + """
742 + note: String
743 +
744 + """
745 + The Node ID of the ProjectColumn.
746 + """
747 + projectColumnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"])
748 +}
749 +
750 +"""
751 +Autogenerated return type of AddProjectCard.
752 +"""
753 +type AddProjectCardPayload {
754 + """
755 + The edge from the ProjectColumn's card connection.
756 + """
757 + cardEdge: ProjectCardEdge
758 +
759 + """
760 + A unique identifier for the client performing the mutation.
761 + """
762 + clientMutationId: String
763 +
764 + """
765 + The ProjectColumn
766 + """
767 + projectColumn: ProjectColumn
768 +}
769 +
770 +"""
771 +Autogenerated input type of AddProjectColumn
772 +"""
773 +input AddProjectColumnInput {
774 + """
775 + A unique identifier for the client performing the mutation.
776 + """
777 + clientMutationId: String
778 +
779 + """
780 + The name of the column.
781 + """
782 + name: String!
783 +
784 + """
785 + The Node ID of the project.
786 + """
787 + projectId: ID! @possibleTypes(concreteTypes: ["Project"])
788 +}
789 +
790 +"""
791 +Autogenerated return type of AddProjectColumn.
792 +"""
793 +type AddProjectColumnPayload {
794 + """
795 + A unique identifier for the client performing the mutation.
796 + """
797 + clientMutationId: String
798 +
799 + """
800 + The edge from the project's column connection.
801 + """
802 + columnEdge: ProjectColumnEdge
803 +
804 + """
805 + The project
806 + """
807 + project: Project
808 +}
809 +
810 +"""
811 +Autogenerated input type of AddProjectV2DraftIssue
812 +"""
813 +input AddProjectV2DraftIssueInput {
814 + """
815 + The IDs of the assignees of the draft issue.
816 + """
817 + assigneeIds: [ID!] @possibleTypes(concreteTypes: ["User"])
818 +
819 + """
820 + The body of the draft issue.
821 + """
822 + body: String
823 +
824 + """
825 + A unique identifier for the client performing the mutation.
826 + """
827 + clientMutationId: String
828 +
829 + """
830 + The ID of the Project to add the draft issue to.
831 + """
832 + projectId: ID! @possibleTypes(concreteTypes: ["ProjectV2"])
833 +
834 + """
835 + The title of the draft issue. A project item can also be created by providing
836 + the URL of an Issue or Pull Request if you have access.
837 + """
838 + title: String!
839 +}
840 +
841 +"""
842 +Autogenerated return type of AddProjectV2DraftIssue.
843 +"""
844 +type AddProjectV2DraftIssuePayload {
845 + """
846 + A unique identifier for the client performing the mutation.
847 + """
848 + clientMutationId: String
849 +
850 + """
851 + The draft issue added to the project.
852 + """
853 + projectItem: ProjectV2Item
854 +}
855 +
856 +"""
857 +Autogenerated input type of AddProjectV2ItemById
858 +"""
859 +input AddProjectV2ItemByIdInput {
860 + """
861 + A unique identifier for the client performing the mutation.
862 + """
863 + clientMutationId: String
864 +
865 + """
866 + The id of the Issue or Pull Request to add.
867 + """
868 + contentId: ID!
869 + @possibleTypes(concreteTypes: ["DraftIssue", "Issue", "PullRequest"], abstractType: "ProjectV2ItemContent")
870 +
871 + """
872 + The ID of the Project to add the item to.
873 + """
874 + projectId: ID! @possibleTypes(concreteTypes: ["ProjectV2"])
875 +}
876 +
877 +"""
878 +Autogenerated return type of AddProjectV2ItemById.
879 +"""
880 +type AddProjectV2ItemByIdPayload {
881 + """
882 + A unique identifier for the client performing the mutation.
883 + """
884 + clientMutationId: String
885 +
886 + """
887 + The item added to the project.
888 + """
889 + item: ProjectV2Item
890 +}
891 +
892 +"""
893 +Autogenerated input type of AddPullRequestCreationCapBypassUsers
894 +"""
895 +input AddPullRequestCreationCapBypassUsersInput {
896 + """
897 + A unique identifier for the client performing the mutation.
898 + """
899 + clientMutationId: String
900 +
901 + """
902 + The Node ID of the repository.
903 + """
904 + repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"])
905 +
906 + """
907 + The Node IDs of the users to add to the bypass list.
908 + """
909 + userIds: [ID!]! @possibleTypes(concreteTypes: ["User"])
910 +}
911 +
912 +"""
913 +Autogenerated return type of AddPullRequestCreationCapBypassUsers.
914 +"""
915 +type AddPullRequestCreationCapBypassUsersPayload {
916 + """
917 + A unique identifier for the client performing the mutation.
918 + """
919 + clientMutationId: String
920 +
921 + """
922 + The repository with the updated bypass list.
923 + """
924 + repository: Repository
925 +}
926 +
927 +"""
928 +Autogenerated input type of AddPullRequestReviewComment
929 +"""
930 +input AddPullRequestReviewCommentInput {
931 + """
932 + The text of the comment. This field is required
933 +
934 + **Upcoming Change on 2023-10-01 UTC**
935 + **Description:** `body` will be removed. use addPullRequestReviewThread or addPullRequestReviewThreadReply instead
936 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
937 + """
938 + body: String
939 +
940 + """
941 + A unique identifier for the client performing the mutation.
942 + """
943 + clientMutationId: String
944 +
945 + """
946 + The SHA of the commit to comment on.
947 +
948 + **Upcoming Change on 2023-10-01 UTC**
949 + **Description:** `commitOID` will be removed. use addPullRequestReviewThread or addPullRequestReviewThreadReply instead
950 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
951 + """
952 + commitOID: GitObjectID
953 +
954 + """
955 + The comment id to reply to.
956 +
957 + **Upcoming Change on 2023-10-01 UTC**
958 + **Description:** `inReplyTo` will be removed. use addPullRequestReviewThread or addPullRequestReviewThreadReply instead
959 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
960 + """
961 + inReplyTo: ID @possibleTypes(concreteTypes: ["PullRequestReviewComment"])
962 +
963 + """
964 + The relative path of the file to comment on.
965 +
966 + **Upcoming Change on 2023-10-01 UTC**
967 + **Description:** `path` will be removed. use addPullRequestReviewThread or addPullRequestReviewThreadReply instead
968 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
969 + """
970 + path: String
971 +
972 + """
973 + The line index in the diff to comment on.
974 +
975 + **Upcoming Change on 2023-10-01 UTC**
976 + **Description:** `position` will be removed. use addPullRequestReviewThread or addPullRequestReviewThreadReply instead
977 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
978 + """
979 + position: Int
980 +
981 + """
982 + The node ID of the pull request reviewing
983 +
984 + **Upcoming Change on 2023-10-01 UTC**
985 + **Description:** `pullRequestId` will be removed. use
986 + addPullRequestReviewThread or addPullRequestReviewThreadReply instead
987 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
988 + """
989 + pullRequestId: ID @possibleTypes(concreteTypes: ["PullRequest"])
990 +
991 + """
992 + The Node ID of the review to modify.
993 +
994 + **Upcoming Change on 2023-10-01 UTC**
995 + **Description:** `pullRequestReviewId` will be removed. use
996 + addPullRequestReviewThread or addPullRequestReviewThreadReply instead
997 + **Reason:** We are deprecating the addPullRequestReviewComment mutation
998 + """
999 + pullRequestReviewId: ID @possibleTypes(concreteTypes: ["PullRequestReview"])
1000 +}
1001 +
1002 +"""
1003 +Autogenerated return type of AddPullRequestReviewComment.
1004 +"""
1005 +type AddPullRequestReviewCommentPayload {
1006 + """
1007 + A unique identifier for the client performing the mutation.
1008 + """
1009 + clientMutationId: String
1010 +
1011 + """
1012 + The newly created comment.
1013 + """
1014 + comment: PullRequestReviewComment
1015 +
1016 + """
1017 + The edge from the review's comment connection.
1018 + """
1019 + commentEdge: PullRequestReviewCommentEdge
1020 +}
1021 +
1022 +"""
1023 +Autogenerated input type of AddPullRequestReview
1024 +"""
1025 +input AddPullRequestReviewInput {
1026 + """
1027 + The contents of the review body comment.
1028 + """
1029 + body: String
1030 +
1031 + """
1032 + A unique identifier for the client performing the mutation.
1033 + """
1034 + clientMutationId: String
1035 +
1036 + """
1037 + The review line comments.
1038 +
1039 + **Upcoming Change on 2023-10-01 UTC**
1040 + **Description:** `comments` will be removed. use the `threads` argument instead
1041 + **Reason:** We are deprecating comment fields that use diff-relative positioning
1042 + """
1043 + comments: [DraftPullRequestReviewComment]
1044 +
1045 + """
1046 + The commit OID the review pertains to.
1047 + """
1048 + commitOID: GitObjectID
1049 +
1050 + """
1051 + The event to perform on the pull request review.
1052 + """
1053 + event: PullRequestReviewEvent
1054 +
1055 + """
1056 + The Node ID of the pull request to modify.
1057 + """
1058 + pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"])
1059 +
1060 + """
1061 + The review line comment threads.
1062 + """
1063 + threads: [DraftPullRequestReviewThread]
1064 +}
1065 +
1066 +"""
1067 +Autogenerated return type of AddPullRequestReview.
1068 +"""
1069 +type AddPullRequestReviewPayload {
1070 + """
1071 + A unique identifier for the client performing the mutation.
1072 + """
1073 + clientMutationId: String
1074 +
1075 + """
1076 + The newly created pull request review.
1077 + """
1078 + pullRequestReview: PullRequestReview
1079 +
1080 + """
1081 + The edge from the pull request's review connection.
1082 + """
1083 + reviewEdge: PullRequestReviewEdge
1084 +}
1085 +
1086 +"""
1087 +Autogenerated input type of AddPullRequestReviewThread
1088 +"""
1089 +input AddPullRequestReviewThreadInput {
1090 + """
1091 + Body of the thread's first comment.
1092 + """
1093 + body: String!
1094 +
1095 + """
1096 + A unique identifier for the client performing the mutation.
1097 + """
1098 + clientMutationId: String
1099 +
1100 + """
1101 + The line of the blob to which the thread refers, required for line-level
1102 + threads. The end of the line range for multi-line comments.
1103 + """
1104 + line: Int
1105 +
1106 + """
1107 + Path to the file being commented on.
1108 + """
1109 + path: String
1110 +
1111 + """
1112 + The node ID of the pull request reviewing
1113 + """
1114 + pullRequestId: ID @possibleTypes(concreteTypes: ["PullRequest"])
1115 +
1116 + """
1117 + The Node ID of the review to modify.
1118 + """
1119 + pullRequestReviewId: ID @possibleTypes(concreteTypes: ["PullRequestReview"])
1120 +
1121 + """
1122 + The side of the diff on which the line resides. For multi-line comments, this is the side for the end of the line range.
1123 + """
1124 + side: DiffSide = RIGHT
1125 +
1126 + """
1127 + The first line of the range to which the comment refers.
1128 + """
1129 + startLine: Int
1130 +
1131 + """
1132 + The side of the diff on which the start line resides.
1133 + """
1134 + startSide: DiffSide = RIGHT
1135 +
1136 + """
1137 + The level at which the comments in the corresponding thread are targeted, can be a diff line or a file
1138 + """
1139 + subjectType: PullRequestReviewThreadSubjectType = LINE
1140 +}
1141 +
1142 +"""
1143 +Autogenerated return type of AddPullRequestReviewThread.
1144 +"""
1145 +type AddPullRequestReviewThreadPayload {
1146 + """
1147 + A unique identifier for the client performing the mutation.
1148 + """
1149 + clientMutationId: String
1150 +
1151 + """
1152 + The newly created thread.
1153 + """
1154 + thread: PullRequestReviewThread
1155 +}
1156 +
1157 +"""
1158 +Autogenerated input type of AddPullRequestReviewThreadReply
1159 +"""
1160 +input AddPullRequestReviewThreadReplyInput {
1161 + """
1162 + The text of the reply.
1163 + """
1164 + body: String!
1165 +
1166 + """
1167 + A unique identifier for the client performing the mutation.
1168 + """
1169 + clientMutationId: String
1170 +
1171 + """
1172 + The Node ID of the pending review to which the reply will belong.
1173 + """
1174 + pullRequestReviewId: ID @possibleTypes(concreteTypes: ["PullRequestReview"])
1175 +
1176 + """
1177 + The Node ID of the thread to which this reply is being written.
1178 + """
1179 + pullRequestReviewThreadId: ID! @possibleTypes(concreteTypes: ["PullRequestReviewThread"])
1180 +}
1181 +
1182 +"""
1183 +Autogenerated return type of AddPullRequestReviewThreadReply.
1184 +"""
1185 +type AddPullRequestReviewThreadReplyPayload {
1186 + """
1187 + A unique identifier for the client performing the mutation.
1188 + """
1189 + clientMutationId: String
1190 +
1191 + """
1192 + The newly created reply.
1193 + """
1194 + comment: PullRequestReviewComment
1195 +}
1196 +
1197 +"""
1198 +Autogenerated input type of AddReaction
1199 +"""
1200 +input AddReactionInput {
1201 + """
1202 + A unique identifier for the client performing the mutation.
1203 + """
1204 + clientMutationId: String
1205 +
1206 + """
1207 + The name of the emoji to react with.
1208 + """
1209 + content: ReactionContent!
1210 +
1211 + """
1212 + The Node ID of the subject to modify.
1213 + """
1214 + subjectId: ID!
1215 + @possibleTypes(
1216 + concreteTypes: [
1217 + "CommitComment"
1218 + "Discussion"
1219 + "DiscussionComment"
1220 + "Issue"
1221 + "IssueComment"
1222 + "PullRequest"
1223 + "PullRequestReview"
1224 + "PullRequestReviewComment"
1225 + "Release"
1226 + ]
1227 + abstractType: "Reactable"
1228 + )
1229 +}
1230 +
1231 +"""
1232 +Autogenerated return type of AddReaction.
1233 +"""
1234 +type AddReactionPayload {
1235 + """
1236 + A unique identifier for the client performing the mutation.
1237 + """
1238 + clientMutationId: String
1239 +
1240 + """
1241 + The reaction object.
1242 + """
1243 + reaction: Reaction
1244 +
1245 + """
1246 + The reaction groups for the subject.
1247 + """
1248 + reactionGroups: [ReactionGroup!]
1249 +
1250 + """
1251 + The reactable subject.
1252 + """
1253 + subject: Reactable
1254 +}
1255 +
1256 +"""
1257 +Autogenerated input type of AddRelatesTo
1258 +"""
1259 +input AddRelatesToInput {
1260 + """
1261 + A unique identifier for the client performing the mutation.
1262 + """
1263 + clientMutationId: String
1264 +
1265 + """
1266 + The ID of the issue.
1267 + """
1268 + issueId: ID! @possibleTypes(concreteTypes: ["Issue"])
1269 +
1270 + """
1271 + The ID of the related issue.
1272 + """
1273 + relatedIssueId: ID! @possibleTypes(concreteTypes: ["Issue"])
1274 +}
1275 +
1276 +"""
1277 +Autogenerated return type of AddRelatesTo.
1278 +"""
1279 +type AddRelatesToPayload {
1280 + """
1281 + A unique identifier for the client performing the mutation.
1282 + """
1283 + clientMutationId: String
1284 +
1285 + """
1286 + The source issue.
1287 + """
1288 + issue: Issue
1289 +
1290 + """
1291 + The related issue.
1292 + """
1293 + relatedIssue: Issue
1294 +}
1295 +
1296 +"""
1297 +Autogenerated input type of AddStar
1298 +"""
1299 +input AddStarInput {
1300 + """
1301 + A unique identifier for the client performing the mutation.
1302 + """
1303 + clientMutationId: String
1304 +
1305 + """
1306 + The Starrable ID to star.
1307 + """
1308 + starrableId: ID! @possibleTypes(concreteTypes: ["Gist", "Repository", "Topic"], abstractType: "Starrable")
1309 +}
1310 +
1311 +"""
1312 +Autogenerated return type of AddStar.
1313 +"""
1314 +type AddStarPayload {
1315 + """
1316 + A unique identifier for the client performing the mutation.
1317 + """
1318 + clientMutationId: String
1319 +
1320 + """
1321 + The starrable.
1322 + """
1323 + starrable: Starrable
1324 +}
1325 +
1326 +"""
1327 +Autogenerated input type of AddSubIssue
1328 +"""
1329 +input AddSubIssueInput {
1330 + """
1331 + A unique identifier for the client performing the mutation.
1332 + """
1333 + clientMutationId: String
1334 +
1335 + """
1336 + The id of the issue.
1337 + """
1338 + issueId: ID! @possibleTypes(concreteTypes: ["Issue"])
1339 +
1340 + """
1341 + Option to replace parent issue if one already exists
1342 + """
1343 + replaceParent: Boolean
1344 +
1345 + """
1346 + The id of the sub-issue.
1347 + """
1348 + subIssueId: ID @possibleTypes(concreteTypes: ["Issue"])
1349 +
1350 + """
1351 + The url of the sub-issue.
1352 + """
1353 + subIssueUrl: String
1354 +}
1355 +
1356 +"""
1357 +Autogenerated return type of AddSubIssue.
1358 +"""
1359 +type AddSubIssuePayload {
1360 + """
1361 + A unique identifier for the client performing the mutation.
1362 + """
1363 + clientMutationId: String
1364 +
1365 + """
1366 + The parent issue that the sub-issue was added to.
1367 + """
1368 + issue: Issue
1369 +
1370 + """
1371 + The sub-issue of the parent.
1372 + """
1373 + subIssue: Issue
1374 +}
1375 +
1376 +"""
1377 +Autogenerated input type of AddUpvote
1378 +"""
1379 +input AddUpvoteInput {
1380 + """
1381 + A unique identifier for the client performing the mutation.
1382 + """
1383 + clientMutationId: String
1384 +
1385 + """
1386 + The Node ID of the discussion or comment to upvote.
1387 + """
1388 + subjectId: ID! @possibleTypes(concreteTypes: ["Discussion", "DiscussionComment"], abstractType: "Votable")
1389 +}
1390 +
1391 +"""
1392 +Autogenerated return type of AddUpvote.
1393 +"""
1394 +type AddUpvotePayload {
1395 + """
1396 + A unique identifier for the client performing the mutation.
1397 + """
1398 + clientMutationId: String
1399 +
1400 + """
1401 + The votable subject.
1402 + """
1403 + subject: Votable
1404 +}
1405 +
1406 +"""
1407 +Autogenerated input type of AddVerifiableDomain
1408 +"""
1409 +input AddVerifiableDomainInput {
1410 + """
1411 + A unique identifier for the client performing the mutation.
1412 + """
1413 + clientMutationId: String
1414 +
1415 + """
1416 + The URL of the domain
1417 + """
1418 + domain: URI!
1419 +
1420 + """
1421 + The ID of the owner to add the domain to
1422 + """
1423 + ownerId: ID! @possibleTypes(concreteTypes: ["Enterprise", "Organization"], abstractType: "VerifiableDomainOwner")
1424 +}
1425 +
1426 +"""
1427 +Autogenerated return type of AddVerifiableDomain.
1428 +"""
1429 +type AddVerifiableDomainPayload {
1430 + """
1431 + A unique identifier for the client performing the mutation.
1432 + """
1433 + clientMutationId: String
1434 +
1435 + """
1436 + The verifiable domain that was added.
1437 + """
1438 + domain: VerifiableDomain
1439 +}
1440 +
1441 +"""
1442 +Represents an 'added_to_merge_queue' event on a given pull request.
1443 +"""
1444 +type AddedToMergeQueueEvent implements Node @docsCategory(name: "pulls") {
1445 + """
1446 + Identifies the actor who performed the event.
1447 + """
1448 + actor: Actor
1449 +
1450 + """
1451 + Identifies the date and time when the object was created.
1452 + """
1453 + createdAt: DateTime!
1454 +
1455 + """
1456 + The user who added this Pull Request to the merge queue
1457 + """
1458 + enqueuer: User
1459 +
1460 + """
1461 + The Node ID of the AddedToMergeQueueEvent object
1462 + """
1463 + id: ID!
1464 +
1465 + """
1466 + The merge queue where this pull request was added to.
1467 + """
1468 + mergeQueue: MergeQueue
1469 +
1470 + """
1471 + PullRequest referenced by event.
1472 + """
1473 + pullRequest: PullRequest
1474 +}
1475 +
1476 +"""
1477 +Represents a 'added_to_project' event on a given issue or pull request.
1478 +"""
1479 +type AddedToProjectEvent implements Node @docsCategory(name: "projects-classic") {
1480 + """
1481 + Identifies the actor who performed the event.
1482 + """
1483 + actor: Actor
1484 +
1485 + """
1486 + Identifies the date and time when the object was created.
1487 + """
1488 + createdAt: DateTime!
1489 +
1490 + """
1491 + Identifies the primary key from the database.
1492 + """
1493 + databaseId: Int
1494 + @deprecated(
1495 + reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
1496 + )
1497 +
1498 + """
1499 + The Node ID of the AddedToProjectEvent object
1500 + """
1501 + id: ID!
1502 +
1503 + """
1504 + Project referenced by event.
1505 + """
1506 + project: Project
1507 + @deprecated(
1508 + reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
1509 + )
1510 +
1511 + """
1512 + Project card referenced by this project event.
1513 + """
1514 + projectCard: ProjectCard
1515 + @deprecated(
1516 + reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
1517 + )
1518 +
1519 + """
1520 + Column name referenced by this project event.
1521 + """
1522 + projectColumnName: String!
1523 + @deprecated(
1524 + reason: "Projects (classic) is being deprecated in favor of the new Projects experience, see: https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/. Removal on 2025-04-01 UTC."
1525 + )
1526 +}
1527 +
1528 +"""
1529 +Represents a 'added_to_project_v2' event on a given issue or pull request.
1530 +"""
1531 +type AddedToProjectV2Event implements Node & ProjectV2Event @docsCategory(name: "projects") {
1532 + """
1533 + Identifies the actor who performed the event.
1534 + """
1535 + actor: Actor
1536 +
1537 + """
1538 + Identifies the date and time when the object was created.
1539 + """
1540 + createdAt: DateTime!
1541 +
1542 + """
1543 + The Node ID of the AddedToProjectV2Event object
1544 + """
1545 + id: ID!
1546 +
1547 + """
1548 + Project referenced by event.
1549 + """
1550 + project: ProjectV2
1551 +
1552 + """
1553 + Did this event result from workflow automation?
1554 + """
1555 + wasAutomated: Boolean!
1556 +}
1557 +
1558 +"""
1559 +Represents an 'added_to_stack' event on a given pull request.
1560 +"""
1561 +type AddedToStackEvent implements Node @docsCategory(name: "pulls") {
1562 + """
1563 + Identifies the actor who performed the event.
1564 + """
1565 + actor: Actor
1566 +
1567 + """
1568 + Identifies the date and time when the object was created.
1569 + """
1570 + createdAt: DateTime!
1571 +
1572 + """
1573 + The Node ID of the AddedToStackEvent object
1574 + """
1575 + id: ID!
1576 +
1577 + """
1578 + Pull request added to the stack.
1579 + """
1580 + pullRequest: PullRequest
1581 +
1582 + """
1583 + Database ID of the stack.
1584 + """
1585 + stackId: BigInt
1586 +
1587 + """
1588 + Number of the stack in its repository.
1589 + """
1590 + stackNumber: Int
1591 +}
1592 +
1593 +"""
1594 +Represents configuration for assigning Copilot to an issue (public variant)
1595 +"""
1596 +input AgentAssignmentInput @docsCategory(name: "users") {
1597 + """
1598 + The base ref/branch for the repository. Defaults to the default branch if not provided.
1599 + """
1600 + baseRef: String
1601 +
1602 + """
1603 + Custom agent for Copilot.
1604 + """
1605 + customAgent: String
1606 +
1607 + """
1608 + Custom instructions for Copilot.
1609 + """
1610 + customInstructions: String
1611 +
1612 + """
1613 + The Node ID of the target repository where Copilot should work. Defaults to the issue's repository if not provided.
1614 + """
1615 + targetRepositoryId: ID @possibleTypes(concreteTypes: ["Repository"])
1616 +}
1617 +
1618 +"""
1619 +Copilot Agentic fields in context of the current viewer.
1620 +"""
1621 +interface Agentic @docsCategory(name: "copilot") {
1622 + """
1623 + Channel value for subscribing to live updates for session creations.
1624 + """
1625 + viewerCopilotAgentCreatesChannel: String
1626 +
1627 + """
1628 + Channel value for subscribing to live updates for session log updates.
1629 + """
1630 + viewerCopilotAgentLogUpdatesChannel: String
1631 +
1632 + """
1633 + Channel value for subscribing to live updates for task updates.
1634 + """
1635 + viewerCopilotAgentTaskUpdatesChannel: String
1636 +
1637 + """
1638 + Channel value for subscribing to live updates for session updates.
1639 + """
1640 + viewerCopilotAgentUpdatesChannel: String
1641 +}
1642 +
1643 +"""
1644 +An announcement banner for an enterprise or organization.
1645 +"""
1646 +type AnnouncementBanner @docsCategory(name: "enterprise-admin") {
1647 + """
1648 + The date the announcement was created
1649 + """
1650 + createdAt: DateTime!
1651 +
1652 + """
1653 + The expiration date of the announcement, if any
1654 + """
1655 + expiresAt: DateTime
1656 +
1657 + """
1658 + Whether the announcement can be dismissed by the user
1659 + """
1660 + isUserDismissible: Boolean!
1661 +
1662 + """
1663 + The text of the announcement
1664 + """
1665 + message: String
1666 +}
1667 +
1668 +"""
1669 +A GitHub App.
1670 +"""
1671 +type App implements Node @docsCategory(name: "apps") {
1672 + """
1673 + The client ID of the app.
1674 + """
1675 + clientId: String
1676 +
1677 + """
1678 + Identifies the date and time when the object was created.
1679 + """
1680 + createdAt: DateTime!
1681 +
1682 + """
1683 + Identifies the primary key from the database.
1684 + """
1685 + databaseId: Int
1686 +
1687 + """
1688 + The description of the app.
1689 + """
1690 + description: String
1691 +
1692 + """
1693 + The Node ID of the App object
1694 + """
1695 + id: ID!
1696 +
1697 + """
1698 + The IP addresses of the app.
1699 + """
1700 + ipAllowListEntries(
1701 + """
1702 + Returns the elements in the list that come after the specified cursor.
1703 + """
1704 + after: String
1705 +
1706 + """
1707 + Returns the elements in the list that come before the specified cursor.
1708 + """
1709 + before: String
1710 +
1711 + """
1712 + Returns the first _n_ elements from the list.
1713 + """
1714 + first: Int
1715 +
1716 + """
1717 + Returns the last _n_ elements from the list.
1718 + """
1719 + last: Int
1720 +
1721 + """
1722 + Ordering options for IP allow list entries returned.
1723 + """
1724 + orderBy: IpAllowListEntryOrder = {field: ALLOW_LIST_VALUE, direction: ASC}
1725 + ): IpAllowListEntryConnection!
1726 +
1727 + """
1728 + The hex color code, without the leading '#', for the logo background.
1729 + """
1730 + logoBackgroundColor: String!
1731 +
1732 + """
1733 + A URL pointing to the app's logo.
1734 + """
1735 + logoUrl(
1736 + """
1737 + The size of the resulting image.
1738 + """
1739 + size: Int
1740 + ): URI!
1741 +
1742 + """
1743 + The name of the app.
1744 + """
1745 + name: String!
1746 +
1747 + """
1748 + A slug based on the name of the app for use in URLs.
1749 + """
1750 + slug: String!
1751 +
1752 + """
1753 + Identifies the date and time when the object was last updated.
1754 + """
1755 + updatedAt: DateTime!
1756 +
1757 + """
1758 + The URL to the app's homepage.
1759 + """
1760 + url: URI!
1761 +}
1762 +
1763 +"""
1764 +Autogenerated input type of ApplyPendingIssueSuggestions
1765 +"""
1766 +input ApplyPendingIssueSuggestionsInput {
1767 + """
1768 + The ID of the actor whose suggestions to apply.
1769 + """
1770 + actorId: ID!
1771 + @possibleTypes(
1772 + concreteTypes: ["Bot", "EnterpriseUserAccount", "Mannequin", "Organization", "User"]
1773 + abstractType: "Actor"
1774 + )
1775 +
1776 + """
1777 + A unique identifier for the client performing the mutation.
1778 + """
1779 + clientMutationId: String
1780 +
1781 + """
1782 + The ID of the issue the suggestions apply to.
1783 + """
1784 + issueId: ID! @possibleTypes(concreteTypes: ["Issue"])
1785 +
1786 + """
1787 + The pending suggestions to apply.
1788 + """
1789 + suggestions: [PendingIssueSuggestionRef!]!
1790 +}
1791 +
1792 +"""
1793 +Autogenerated return type of ApplyPendingIssueSuggestions.
1794 +"""
1795 +type ApplyPendingIssueSuggestionsPayload {
1796 + """
1797 + A unique identifier for the client performing the mutation.
1798 + """
1799 + clientMutationId: String
1800 +
1801 + """
1802 + The updated issue.
1803 + """
1804 + issue: Issue
1805 +}
1806 +
1807 +"""
1808 +Autogenerated input type of ApproveDeployments
1809 +"""
1810 +input ApproveDeploymentsInput {
1811 + """
1812 + A unique identifier for the client performing the mutation.
1813 + """
1814 + clientMutationId: String
1815 +
1816 + """
1817 + Optional comment for approving deployments
1818 + """
1819 + comment: String = ""
1820 +
1821 + """
1822 + The ids of environments to reject deployments
1823 + """
1824 + environmentIds: [ID!]!
1825 +
1826 + """
1827 + The node ID of the workflow run containing the pending deployments.
1828 + """
1829 + workflowRunId: ID! @possibleTypes(concreteTypes: ["WorkflowRun"])
1830 +}
1831 +
1832 +"""
1833 +Autogenerated return type of ApproveDeployments.
1834 +"""
1835 +type ApproveDeploymentsPayload {
1836 + """
1837 + A unique identifier for the client performing the mutation.
1838 + """
1839 + clientMutationId: String
1840 +
1841 + """
1842 + The affected deployments.
1843 + """
1844 + deployments: [Deployment!]
1845 +}
1846 +
1847 +"""
1848 +Autogenerated input type of ApproveVerifiableDomain
1849 +"""
1850 +input ApproveVerifiableDomainInput {
1851 + """
1852 + A unique identifier for the client performing the mutation.
1853 + """
1854 + clientMutationId: String
1855 +
1856 + """
1857 + The ID of the verifiable domain to approve.
1858 + """
1859 + id: ID! @possibleTypes(concreteTypes: ["VerifiableDomain"])
1860 +}
1861 +
1862 +"""
1863 +Autogenerated return type of ApproveVerifiableDomain.
1864 +"""
1865 +type ApproveVerifiableDomainPayload {
1866 + """
1867 + A unique identifier for the client performing the mutation.
1868 + """
1869 + clientMutationId: String
1870 +
1871 + """
1872 + The verifiable domain that was approved.
1873 + """
1874 + domain: VerifiableDomain
1875 +}
1876 +
1877 +"""
1878 +Autogenerated input type of ArchiveProjectV2Item
1879 +"""
1880 +input ArchiveProjectV2ItemInput {
1881 + """
1882 + A unique identifier for the client performing the mutation.
1883 + """
1884 + clientMutationId: String
1885 +
1886 + """
1887 + The ID of the ProjectV2Item to archive.
1888 + """
1889 + itemId: ID! @possibleTypes(concreteTypes: ["ProjectV2Item"])
1890 +
1891 + """
1892 + The ID of the Project to archive the item from.
1893 + """
1894 + projectId: ID! @possibleTypes(concreteTypes: ["ProjectV2"])
1895 +}
1896 +
1897 +"""
1898 +Autogenerated return type of ArchiveProjectV2Item.
1899 +"""
1900 +type ArchiveProjectV2ItemPayload {
1901 + """
1902 + A unique identifier for the client performing the mutation.
1903 + """
1904 + clientMutationId: String
1905 +
1906 + """
1907 + The item archived from the project.
1908 + """
1909 + item: ProjectV2Item
1910 +}
1911 +
1912 +"""
1913 +Autogenerated input type of ArchivePullRequest
1914 +"""
1915 +input ArchivePullRequestInput {
1916 + """
1917 + A unique identifier for the client performing the mutation.
1918 + """
1919 + clientMutationId: String
1920 +
1921 + """
1922 + The Node ID of the pull request to archive.
1923 + """
1924 + pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"])
1925 +}
1926 +
1927 +"""
1928 +Autogenerated return type of ArchivePullRequest.
1929 +"""
1930 +type ArchivePullRequestPayload {
1931 + """
1932 + A unique identifier for the client performing the mutation.
1933 + """
1934 + clientMutationId: String
1935 +
1936 + """
1937 + The pull request that was archived.
1938 + """
1939 + pullRequest: PullRequest
1940 +}
1941 +
1942 +"""
1943 +Autogenerated input type of ArchiveRepository
1944 +"""
1945 +input ArchiveRepositoryInput {
1946 + """
1947 + A unique identifier for the client performing the mutation.
1948 + """
1949 + clientMutationId: String
1950 +
1951 + """
1952 + The ID of the repository to mark as archived.
1953 + """
1954 + repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"])
1955 +}
1956 +
1957 +"""
1958 +Autogenerated return type of ArchiveRepository.
1959 +"""
1960 +type ArchiveRepositoryPayload {
1961 + """
1962 + A unique identifier for the client performing the mutation.
1963 + """
1964 + clientMutationId: String
1965 +
1966 + """
1967 + The repository that was marked as archived.
1968 + """
1969 + repository: Repository
1970 +}
1971 +
1972 +"""
1973 +An object that can have users assigned to it.
1974 +"""
1975 +interface Assignable @docsCategory(name: "issues") {
1976 + """
1977 + A list of actors assigned to this object.
1978 + """
1979 + assignedActors(
1980 + """
1981 + Returns the elements in the list that come after the specified cursor.
1982 + """
1983 + after: String
1984 +
1985 + """
1986 + Returns the elements in the list that come before the specified cursor.
1987 + """
1988 + before: String
1989 +
1990 + """
1991 + Returns the first _n_ elements from the list.
1992 + """
1993 + first: Int
1994 +
1995 + """
1996 + Returns the last _n_ elements from the list.
1997 + """
1998 + last: Int
1999 + ): AssigneeConnection!
2000 +
2001 + """
2002 + A list of Users assigned to this object.
2003 + """
2004 + assignees(
2005 + """
2006 + Returns the elements in the list that come after the specified cursor.
2007 + """
2008 + after: String
2009 +
2010 + """
2011 + Returns the elements in the list that come before the specified cursor.
2012 + """
2013 + before: String
2014 +
2015 + """
2016 + Returns the first _n_ elements from the list.
2017 + """
2018 + first: Int
2019 +
2020 + """
2021 + Returns the last _n_ elements from the list.
2022 + """
2023 + last: Int
2024 + ): UserConnection!
2025 +
2026 + """
2027 + A list of suggested actors to assign to this object
2028 + """
2029 + suggestedActors(
2030 + """
2031 + Returns the elements in the list that come after the specified cursor.
2032 + """
2033 + after: String
2034 +
2035 + """
2036 + Returns the elements in the list that come before the specified cursor.
2037 + """
2038 + before: String
2039 +
2040 + """
2041 + Returns the first _n_ elements from the list.
2042 + """
2043 + first: Int
2044 +
2045 + """
2046 + Returns the last _n_ elements from the list.
2047 + """
2048 + last: Int
2049 +
2050 + """
2051 + If provided, searches users by login or profile name
2052 + """
2053 + query: String
2054 + ): AssigneeConnection!
2055 +
2056 + """
2057 + Indicates if the viewer can edit assignees for this object.
2058 + """
2059 + viewerCanAssign: Boolean!
2060 +}
2061 +
2062 +"""
2063 +Represents an 'assigned' event on any assignable object.
2064 +"""
2065 +type AssignedEvent implements Node @docsCategory(name: "issues") {
2066 + """
2067 + Identifies the actor who performed the event.
2068 + """
2069 + actor: Actor
2070 +
2071 + """
2072 + Identifies the assignable associated with the event.
2073 + """
2074 + assignable: Assignable!
2075 +
2076 + """
2077 + Identifies the user or mannequin that was assigned.
2078 + """
2079 + assignee: Assignee
2080 +
2081 + """
2082 + Identifies the date and time when the object was created.
2083 + """
2084 + createdAt: DateTime!
2085 +
2086 + """
2087 + The Node ID of the AssignedEvent object
2088 + """
2089 + id: ID!
2090 +
2091 + """
2092 + The intent behind the agent's action, including rationale and confidence.
2093 + """
2094 + intent: IssueUpdateIntent
2095 +
2096 + """
2097 + Identifies the user who was assigned.
2098 + """
2099 + user: User
2100 + @deprecated(reason: "Assignees can now be mannequins. Use the `assignee` field instead. Removal on 2020-01-01 UTC.")
2101 +}
2102 +
2103 +"""
2104 +Types that can be assigned to issues.
2105 +"""
2106 +union Assignee @docsCategory(name: "issues") = Bot | Mannequin | Organization | User
2107 +
2108 +"""
2109 +The connection type for Assignee.
2110 +"""
2111 +type AssigneeConnection {
2112 + """
2113 + A list of edges.
2114 + """
2115 + edges: [AssigneeEdge]
2116 +
2117 + """
2118 + A list of nodes.
2119 + """
2120 + nodes: [Assignee]
2121 +
2122 + """
2123 + Information to aid in pagination.
2124 + """
2125 + pageInfo: PageInfo!
2126 +
2127 + """
2128 + Identifies the total count of items in the connection.
2129 + """
2130 + totalCount: Int!
2131 +}
2132 +
2133 +"""
2134 +An edge in a connection.
2135 +"""
2136 +type AssigneeEdge {
2137 + """
2138 + A cursor for use in pagination.
2139 + """
2140 + cursor: String!
2141 +
2142 + """
2143 + The item at the end of the edge.
2144 + """
2145 + node: Assignee
2146 +}
2147 +
2148 +"""
2149 +Specifies an actor (user or bot) to assign to an issue, with optional metadata such as a rationale.
2150 +"""
2151 +input AssigneeUpdateInput @docsCategory(name: "issues") {
2152 + """
2153 + The ID of the actor (user or bot) to assign.
2154 + """
2155 + actorId: ID!
2156 + @possibleTypes(
2157 + concreteTypes: ["Bot", "EnterpriseUserAccount", "Mannequin", "Organization", "User"]
2158 + abstractType: "Actor"
2159 + )
2160 +
2161 + """
2162 + The confidence level the agent had when selecting this value.
2163 + """
2164 + confidence: IssueEventConfidenceLevel
2165 +
2166 + """
2167 + Optional rationale describing why this value was selected. Max 280 characters.
2168 + """
2169 + rationale: String
2170 +
2171 + """
2172 + If true, the value is stored as a pending suggestion for human review rather than being applied directly.
2173 + """
2174 + suggest: Boolean
2175 +}
2176 +
2177 +"""
2178 +An entry in the audit log.
2179 +"""
2180 +interface AuditEntry @docsCategory(name: "enterprise-admin") {
2181 + """
2182 + The action name
2183 + """
2184 + action: String!
2185 + @deprecated(
2186 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2187 + )
2188 +
2189 + """
2190 + The user who initiated the action
2191 + """
2192 + actor: AuditEntryActor
2193 + @deprecated(
2194 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2195 + )
2196 +
2197 + """
2198 + The IP address of the actor
2199 + """
2200 + actorIp: String
2201 + @deprecated(
2202 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2203 + )
2204 +
2205 + """
2206 + A readable representation of the actor's location
2207 + """
2208 + actorLocation: ActorLocation
2209 + @deprecated(
2210 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2211 + )
2212 +
2213 + """
2214 + The username of the user who initiated the action
2215 + """
2216 + actorLogin: String
2217 + @deprecated(
2218 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2219 + )
2220 +
2221 + """
2222 + The HTTP path for the actor.
2223 + """
2224 + actorResourcePath: URI
2225 + @deprecated(
2226 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2227 + )
2228 +
2229 + """
2230 + The HTTP URL for the actor.
2231 + """
2232 + actorUrl: URI
2233 + @deprecated(
2234 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2235 + )
2236 +
2237 + """
2238 + The time the action was initiated
2239 + """
2240 + createdAt: PreciseDateTime!
2241 + @deprecated(
2242 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2243 + )
2244 +
2245 + """
2246 + The corresponding operation type for the action
2247 + """
2248 + operationType: OperationType
2249 + @deprecated(
2250 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2251 + )
2252 +
2253 + """
2254 + The user affected by the action
2255 + """
2256 + user: User
2257 + @deprecated(
2258 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2259 + )
2260 +
2261 + """
2262 + For actions involving two users, the actor is the initiator and the user is the affected user.
2263 + """
2264 + userLogin: String
2265 + @deprecated(
2266 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2267 + )
2268 +
2269 + """
2270 + The HTTP path for the user.
2271 + """
2272 + userResourcePath: URI
2273 + @deprecated(
2274 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2275 + )
2276 +
2277 + """
2278 + The HTTP URL for the user.
2279 + """
2280 + userUrl: URI
2281 + @deprecated(
2282 + reason: "The GraphQL audit-log is deprecated. Please use the REST API instead. Removal on 2026-04-01 UTC."
2283 + )
2284 +}
2285 +
2286 +"""
2287 +Types that can initiate an audit log event.
2288 +"""
2289 +union AuditEntryActor @docsCategory(name: "enterprise-admin") = Bot | Organization | User
2290 +
2291 +"""
2292 +Ordering options for Audit Log connections.
2293 +"""
2294 +input AuditLogOrder @docsCategory(name: "enterprise-admin") {
2295 + """
2296 + The ordering direction.
2297 + """
2298 + direction: OrderDirection
2299 +
2300 + """
2301 + The field to order Audit Logs by.
2302 + """
2303 + field: AuditLogOrderField
2304 +}
2305 +
2306 +"""
2307 +Properties by which Audit Log connections can be ordered.
2308 +"""
2309 +enum AuditLogOrderField @docsCategory(name: "enterprise-admin") {
2310 + """
2311 + Order audit log entries by timestamp
2312 + """
2313 + CREATED_AT
2314 +}
2315 +
2316 +"""
2317 +Represents a 'auto_merge_disabled' event on a given pull request.
2318 +"""
2319 +type AutoMergeDisabledEvent implements Node @docsCategory(name: "pulls") {
2320 + """
2321 + Identifies the actor who performed the event.
2322 + """
2323 + actor: Actor
2324 +
2325 + """
2326 + Identifies the date and time when the object was created.
2327 + """
2328 + createdAt: DateTime!
2329 +
2330 + """
2331 + The user who disabled auto-merge for this Pull Request
2332 + """
2333 + disabler: User
2334 +
2335 + """
2336 + The Node ID of the AutoMergeDisabledEvent object
2337 + """
2338 + id: ID!
2339 +
2340 + """
2341 + PullRequest referenced by event
2342 + """
2343 + pullRequest: PullRequest
2344 +
2345 + """
2346 + The reason auto-merge was disabled
2347 + """
2348 + reason: String
2349 +
2350 + """
2351 + The reason_code relating to why auto-merge was disabled
2352 + """
2353 + reasonCode: String
2354 +}
2355 +
2356 +"""
2357 +Represents a 'auto_merge_enabled' event on a given pull request.
2358 +"""
2359 +type AutoMergeEnabledEvent implements Node @docsCategory(name: "pulls") {
2360 + """
2361 + Identifies the actor who performed the event.
2362 + """
2363 + actor: Actor
2364 +
2365 + """
2366 + Identifies the date and time when the object was created.
2367 + """
2368 + createdAt: DateTime!
2369 +
2370 + """
2371 + The user who enabled auto-merge for this Pull Request
2372 + """
2373 + enabler: User
2374 +
2375 + """
2376 + The Node ID of the AutoMergeEnabledEvent object
2377 + """
2378 + id: ID!
2379 +
2380 + """
2381 + PullRequest referenced by event.
2382 + """
2383 + pullRequest: PullRequest
2384 +}
2385 +
2386 +"""
2387 +Represents an auto-merge request for a pull request
2388 +"""
2389 +type AutoMergeRequest @docsCategory(name: "pulls") {
2390 + """
2391 + The email address of the author of this auto-merge request.
2392 + """
2393 + authorEmail: String
2394 +
2395 + """
2396 + The commit message of the auto-merge request. If a merge queue is required by
2397 + the base branch, this value will be set by the merge queue when merging.
2398 + """
2399 + commitBody: String
2400 +
2401 + """
2402 + The commit title of the auto-merge request. If a merge queue is required by
2403 + the base branch, this value will be set by the merge queue when merging
2404 + """
2405 + commitHeadline: String
2406 +
2407 + """
2408 + When was this auto-merge request was enabled.
2409 + """
2410 + enabledAt: DateTime
2411 +
2412 + """
2413 + The actor who created the auto-merge request.
2414 + """
2415 + enabledBy: Actor
2416 +
2417 + """
2418 + The merge method of the auto-merge request. If a merge queue is required by
2419 + the base branch, this value will be set by the merge queue when merging.
2420 + """
2421 + mergeMethod: PullRequestMergeMethod!
2422 +
2423 + """
2424 + The pull request that this auto-merge request is set against.
2425 + """
2426 + pullRequest: PullRequest!
2427 +}
2428 +
2429 +"""
2430 +Represents a 'auto_rebase_enabled' event on a given pull request.
2431 +"""
2432 +type AutoRebaseEnabledEvent implements Node @docsCategory(name: "pulls") {
2433 + """
2434 + Identifies the actor who performed the event.
2435 + """
2436 + actor: Actor
2437 +
2438 + """
2439 + Identifies the date and time when the object was created.
2440 + """
2441 + createdAt: DateTime!
2442 +
2443 + """
2444 + The user who enabled auto-merge (rebase) for this Pull Request
2445 + """
2446 + enabler: User
2447 +
2448 + """
2449 + The Node ID of the AutoRebaseEnabledEvent object
2450 + """
2451 + id: ID!
2452 +
2453 + """
2454 + PullRequest referenced by event.
2455 + """
2456 + pullRequest: PullRequest
2457 +}
2458 +
2459 +"""
2460 +Represents a 'auto_squash_enabled' event on a given pull request.
2461 +"""
2462 +type AutoSquashEnabledEvent implements Node @docsCategory(name: "pulls") {
2463 + """
2464 + Identifies the actor who performed the event.
2465 + """
2466 + actor: Actor
2467 +
2468 + """
2469 + Identifies the date and time when the object was created.
2470 + """
2471 + createdAt: DateTime!
2472 +
2473 + """
2474 + The user who enabled auto-merge (squash) for this Pull Request
2475 + """
2476 + enabler: User
2477 +
2478 + """
2479 + The Node ID of the AutoSquashEnabledEvent object
2480 + """
2481 + id: ID!
2482 +
2483 + """
2484 + PullRequest referenced by event.
2485 + """
2486 + pullRequest: PullRequest
2487 +}
2488 +
2489 +"""
2490 +Represents a 'automatic_base_change_failed' event on a given pull request.
2491 +"""
2492 +type AutomaticBaseChangeFailedEvent implements Node @docsCategory(name: "pulls") {
2493 + """
2494 + Identifies the actor who performed the event.
2495 + """
2496 + actor: Actor
2497 +
2498 + """
2499 + Identifies the date and time when the object was created.
2500 + """
2501 + createdAt: DateTime!
2502 +
2503 + """
2504 + The Node ID of the AutomaticBaseChangeFailedEvent object
2505 + """
2506 + id: ID!
2507 +
2508 + """
2509 + The new base for this PR
2510 + """
2511 + newBase: String!
2512 +
2513 + """
2514 + The old base for this PR
2515 + """
2516 + oldBase: String!
2517 +
2518 + """
2519 + PullRequest referenced by event.
2520 + """
2521 + pullRequest: PullRequest!
2522 +}
2523 +
2524 +"""
2525 +Represents a 'automatic_base_change_succeeded' event on a given pull request.
2526 +"""
2527 +type AutomaticBaseChangeSucceededEvent implements Node @docsCategory(name: "pulls") {
2528 + """
2529 + Identifies the actor who performed the event.
2530 + """
2531 + actor: Actor
2532 +
2533 + """
2534 + Identifies the date and time when the object was created.
2535 + """
2536 + createdAt: DateTime!
2537 +
2538 + """
2539 + The Node ID of the AutomaticBaseChangeSucceededEvent object
2540 + """
2541 + id: ID!
2542 +
2543 + """
2544 + The new base for this PR
2545 + """
2546 + newBase: String!
2547 +
2548 + """
2549 + The old base for this PR
2550 + """
2551 + oldBase: String!
2552 +
2553 + """
2554 + PullRequest referenced by event.
2555 + """
2556 + pullRequest: PullRequest!
2557 +}
2558 +
2559 +"""
2560 +A (potentially binary) string encoded using base64.
2561 +"""
2562 +scalar Base64String
2563 +
2564 +"""
2565 +Represents a 'base_ref_changed' event on a given issue or pull request.
2566 +"""
2567 +type BaseRefChangedEvent implements Node @docsCategory(name: "pulls") {
2568 + """
2569 + Identifies the actor who performed the event.
2570 + """
2571 + actor: Actor
2572 +
2573 + """
2574 + Identifies the date and time when the object was created.
2575 + """
2576 + createdAt: DateTime!
2577 +
2578 + """
2579 + Identifies the name of the base ref for the pull request after it was changed.
2580 + """
2581 + currentRefName: String!
2582 +
2583 + """
2584 + Identifies the primary key from the database.
2585 + """
2586 + databaseId: Int
2587 +
2588 + """
2589 + The Node ID of the BaseRefChangedEvent object
2590 + """
2591 + id: ID!
2592 +
2593 + """
2594 + Identifies the name of the base ref for the pull request before it was changed.
2595 + """
2596 + previousRefName: String!
2597 +
2598 + """
2599 + PullRequest referenced by event.
2600 + """
2601 + pullRequest: PullRequest!
2602 +}
2603 +
2604 +"""
2605 +Represents a 'base_ref_deleted' event on a given pull request.
2606 +"""
2607 +type BaseRefDeletedEvent implements Node @docsCategory(name: "pulls") {
2608 + """
2609 + Identifies the actor who performed the event.
2610 + """
2611 + actor: Actor
2612 +
2613 + """
2614 + Identifies the name of the Ref associated with the `base_ref_deleted` event.
2615 + """
2616 + baseRefName: String
2617 +
2618 + """
2619 + Identifies the date and time when the object was created.
2620 + """
2621 + createdAt: DateTime!
2622 +
2623 + """
2624 + The Node ID of the BaseRefDeletedEvent object
2625 + """
2626 + id: ID!
2627 +
2628 + """
2629 + PullRequest referenced by event.
2630 + """
2631 + pullRequest: PullRequest
2632 +}
2633 +
2634 +"""
2635 +Represents a 'base_ref_force_pushed' event on a given pull request.
2636 +"""
2637 +type BaseRefForcePushedEvent implements Node @docsCategory(name: "pulls") {
2638 + """
2639 + Identifies the actor who performed the event.
2640 + """
2641 + actor: Actor
2642 +
2643 + """
2644 + Identifies the after commit SHA for the 'base_ref_force_pushed' event.
2645 + """
2646 + afterCommit: Commit
2647 +
2648 + """
2649 + Identifies the before commit SHA for the 'base_ref_force_pushed' event.
2650 + """
2651 + beforeCommit: Commit
2652 +
2653 + """
2654 + Identifies the date and time when the object was created.
2655 + """
2656 + createdAt: DateTime!
2657 +
2658 + """
2659 + The Node ID of the BaseRefForcePushedEvent object
2660 + """
2661 + id: ID!
2662 +
2663 + """
2664 + PullRequest referenced by event.
2665 + """
2666 + pullRequest: PullRequest!
2667 +
2668 + """
2669 + Identifies the fully qualified ref name for the 'base_ref_force_pushed' event.
2670 + """
2671 + ref: Ref
2672 +}
2673 +
2674 +"""
2675 +Represents non-fractional signed whole numeric values. Since the value may
2676 +exceed the size of a 32-bit integer, it's encoded as a string.
2677 +"""
2678 +scalar BigInt
2679 +
2680 +"""
2681 +Represents a Git blame.
2682 +"""
2683 +type Blame @docsCategory(name: "git") {
2684 + """
2685 + The list of ranges from a Git blame.
2686 + """
2687 + ranges: [BlameRange!]!
2688 +}
2689 +
2690 +"""
2691 +Represents a range of information from a Git blame.
2692 +"""
2693 +type BlameRange @docsCategory(name: "git") {
2694 + """
2695 + Identifies the recency of the change, from 1 (new) to 10 (old). This is
2696 + calculated as a 2-quantile and determines the length of distance between the
2697 + median age of all the changes in the file and the recency of the current
2698 + range's change.
2699 + """
2700 + age: Int!
2701 +
2702 + """
2703 + Identifies the line author
2704 + """
2705 + commit: Commit!
2706 +
2707 + """
2708 + The ending line for the range
2709 + """
2710 + endingLine: Int!
2711 +
2712 + """
2713 + The starting line for the range
2714 + """
2715 + startingLine: Int!
2716 +}
2717 +
2718 +"""
2719 +Represents a Git blob.
2720 +"""
2721 +type Blob implements GitObject & Node @docsCategory(name: "git") {
2722 + """
2723 + An abbreviated version of the Git object ID
2724 + """
2725 + abbreviatedOid: String!
2726 +
2727 + """
2728 + Byte size of Blob object
2729 + """
2730 + byteSize: Int!
2731 +
2732 + """
2733 + The HTTP path for this Git object
2734 + """
2735 + commitResourcePath: URI!
2736 +
2737 + """
2738 + The HTTP URL for this Git object
2739 + """
2740 + commitUrl: URI!
2741 +
2742 + """
2743 + The Node ID of the Blob object
2744 + """
2745 + id: ID!
2746 +
2747 + """
2748 + Indicates whether the Blob is binary or text. Returns null if unable to determine the encoding.
2749 + """
2750 + isBinary: Boolean
2751 +
2752 + """
2753 + Indicates whether the contents is truncated
2754 + """
2755 + isTruncated: Boolean!
2756 +
2757 + """
2758 + The Git object ID
2759 + """
2760 + oid: GitObjectID!
2761 +
2762 + """
2763 + The Repository the Git object belongs to
2764 + """
2765 + repository: Repository!
2766 +
2767 + """
2768 + UTF8 text data or null if the Blob is binary
2769 + """
2770 + text: String
2771 +}
2772 +
2773 +"""
2774 +Represents a 'blocked_by_added' event on a given issue.
2775 +"""
2776 +type BlockedByAddedEvent implements Node @docsCategory(name: "issues") {
2777 + """
2778 + Identifies the actor who performed the event.
2779 + """
2780 + actor: Actor
2781 +
2782 + """
2783 + The blocking issue that was added.
2784 + """
2785 + blockingIssue: Issue
2786 +
2787 + """
2788 + Identifies the date and time when the object was created.
2789 + """
2790 + createdAt: DateTime!
2791 +
2792 + """
2793 + The Node ID of the BlockedByAddedEvent object
2794 + """
2795 + id: ID!
2796 +}
2797 +
2798 +"""
2799 +Represents a 'blocked_by_removed' event on a given issue.
2800 +"""
2801 +type BlockedByRemovedEvent implements Node @docsCategory(name: "issues") {
2802 + """
2803 + Identifies the actor who performed the event.
2804 + """
2805 + actor: Actor
2806 +
2807 + """
2808 + The blocking issue that was removed.
2809 + """
2810 + blockingIssue: Issue
2811 +
2812 + """
2813 + Identifies the date and time when the object was created.
2814 + """
2815 + createdAt: DateTime!
2816 +
2817 + """
2818 + The Node ID of the BlockedByRemovedEvent object
2819 + """
2820 + id: ID!
2821 +}
2822 +
2823 +"""
2824 +Represents a 'blocking_added' event on a given issue.
2825 +"""
2826 +type BlockingAddedEvent implements Node @docsCategory(name: "issues") {
2827 + """
2828 + Identifies the actor who performed the event.
2829 + """
2830 + actor: Actor
2831 +
2832 + """
2833 + The blocked issue that was added.
2834 + """
2835 + blockedIssue: Issue
2836 +
2837 + """
2838 + Identifies the date and time when the object was created.
2839 + """
2840 + createdAt: DateTime!
2841 +
2842 + """
2843 + The Node ID of the BlockingAddedEvent object
2844 + """
2845 + id: ID!
2846 +}
2847 +
2848 +"""
2849 +Represents a 'blocking_removed' event on a given issue.
2850 +"""
2851 +type BlockingRemovedEvent implements Node @docsCategory(name: "issues") {
2852 + """
2853 + Identifies the actor who performed the event.
2854 + """
2855 + actor: Actor
2856 +
2857 + """
2858 + The blocked issue that was removed.
2859 + """
2860 + blockedIssue: Issue
2861 +
2862 + """
2863 + Identifies the date and time when the object was created.
2864 + """
2865 + createdAt: DateTime!
2866 +
2867 + """
2868 + The Node ID of the BlockingRemovedEvent object
2869 + """
2870 + id: ID!
2871 +}
2872 +
2873 +"""
2874 +A special type of user which takes actions on behalf of GitHub Apps.
2875 +"""
2876 +type Bot implements Actor & Node & UniformResourceLocatable @docsCategory(name: "apps") {
2877 + """
2878 + A URL pointing to the GitHub App's public avatar.
2879 + """
2880 + avatarUrl(
2881 + """
2882 + The size of the resulting square image.
2883 + """
2884 + size: Int
2885 + ): URI!
2886 +
2887 + """
2888 + Identifies the date and time when the object was created.
2889 + """
2890 + createdAt: DateTime!
2891 +
2892 + """
2893 + Identifies the primary key from the database.
2894 + """
2895 + databaseId: Int
2896 +
2897 + """
2898 + The Node ID of the Bot object
2899 + """
2900 + id: ID!
2901 +
2902 + """
2903 + The username of the actor.
2904 + """
2905 + login: String!
2906 +
2907 + """
2908 + The HTTP path for this bot
2909 + """
2910 + resourcePath: URI!
2911 +
2912 + """
2913 + Identifies the date and time when the object was last updated.
2914 + """
2915 + updatedAt: DateTime!
2916 +
2917 + """
2918 + The HTTP URL for this bot
2919 + """
2920 + url: URI!
2921 +}
2922 +
2923 +"""
2924 +Types which can be actors for `BranchActorAllowance` objects.
2925 +"""
2926 +union BranchActorAllowanceActor @docsCategory(name: "branches") = App | Team | User
2927 +
2928 +"""
2929 +Parameters to be used for the branch_name_pattern rule
2930 +"""
2931 +type BranchNamePatternParameters @docsCategory(name: "branches") {
2932 + """
2933 + How this rule appears when configuring it.
2934 + """
2935 + name: String
2936 +
2937 + """
2938 + If true, the rule will fail if the pattern matches.
2939 + """
2940 + negate: Boolean!
2941 +
2942 + """
2943 + The operator to use for matching.
2944 + """
2945 + operator: String!
2946 +
2947 + """
2948 + The pattern to match with.
2949 + """
2950 + pattern: String!
2951 +}
2952 +
2953 +"""
2954 +Parameters to be used for the branch_name_pattern rule
2955 +"""
2956 +input BranchNamePatternParametersInput @docsCategory(name: "branches") {
2957 + """
2958 + How this rule appears when configuring it.
2959 + """
2960 + name: String
2961 +
2962 + """
2963 + If true, the rule will fail if the pattern matches.
2964 + """
2965 + negate: Boolean
2966 +
2967 + """
2968 + The operator to use for matching.
2969 + """
2970 + operator: String!
2971 +
2972 + """
2973 + The pattern to match with.
2974 + """
2975 + pattern: String!
2976 +}
2977 +
2978 +"""
2979 +A branch protection rule.
2980 +"""
2981 +type BranchProtectionRule implements Node @docsCategory(name: "branches") {
2982 + """
2983 + Can this branch be deleted.
2984 + """
2985 + allowsDeletions: Boolean!
2986 +
2987 + """
2988 + Are force pushes allowed on this branch.
2989 + """
2990 + allowsForcePushes: Boolean!
2991 +
2992 + """
2993 + Is branch creation a protected operation.
2994 + """
2995 + blocksCreations: Boolean!
2996 +
2997 + """
2998 + A list of conflicts matching branches protection rule and other branch protection rules
2999 + """
3000 + branchProtectionRuleConflicts(
3001 + """
3002 + Returns the elements in the list that come after the specified cursor.
3003 + """
3004 + after: String
3005 +
3006 + """
3007 + Returns the elements in the list that come before the specified cursor.
3008 + """
3009 + before: String
3010 +
3011 + """
3012 + Returns the first _n_ elements from the list.
3013 + """
3014 + first: Int
3015 +
3016 + """
3017 + Returns the last _n_ elements from the list.
3018 + """
3019 + last: Int
3020 + ): BranchProtectionRuleConflictConnection!
3021 +
3022 + """
3023 + A list of actors able to force push for this branch protection rule.
3024 + """
3025 + bypassForcePushAllowances(
3026 + """
3027 + Returns the elements in the list that come after the specified cursor.
3028 + """
3029 + after: String
3030 +
3031 + """
3032 + Returns the elements in the list that come before the specified cursor.
3033 + """
3034 + before: String
3035 +
3036 + """
3037 + Returns the first _n_ elements from the list.
3038 + """
3039 + first: Int
3040 +
3041 + """
3042 + Returns the last _n_ elements from the list.
3043 + """
3044 + last: Int
3045 + ): BypassForcePushAllowanceConnection!
3046 +
3047 + """
3048 + A list of actors able to bypass PRs for this branch protection rule.
3049 + """
3050 + bypassPullRequestAllowances(
3051 + """
3052 + Returns the elements in the list that come after the specified cursor.
3053 + """
3054 + after: String
3055 +
3056 + """
3057 + Returns the elements in the list that come before the specified cursor.
3058 + """
3059 + before: String
3060 +
3061 + """
3062 + Returns the first _n_ elements from the list.
3063 + """
3064 + first: Int
3065 +
3066 + """
3067 + Returns the last _n_ elements from the list.
3068 + """
3069 + last: Int
3070 + ): BypassPullRequestAllowanceConnection!
3071 +
3072 + """
3073 + The actor who created this branch protection rule.
3074 + """
3075 + creator: Actor
3076 +
3077 + """
3078 + Identifies the primary key from the database.
3079 + """
3080 + databaseId: Int
3081 +
3082 + """
3083 + Will new commits pushed to matching branches dismiss pull request review approvals.
3084 + """
3085 + dismissesStaleReviews: Boolean!
3086 +
3087 + """
3088 + The Node ID of the BranchProtectionRule object
3089 + """
3090 + id: ID!
3091 +
3092 + """
3093 + Can admins override branch protection.
3094 + """
3095 + isAdminEnforced: Boolean!
3096 +
3097 + """
3098 + Whether users can pull changes from upstream when the branch is locked. Set to
3099 + `true` to allow fork syncing. Set to `false` to prevent fork syncing.
3100 + """
3101 + lockAllowsFetchAndMerge: Boolean!
3102 +
3103 + """
3104 + Whether to set the branch as read-only. If this is true, users will not be able to push to the branch.
3105 + """
3106 + lockBranch: Boolean!
3107 +
3108 + """
3109 + Repository refs that are protected by this rule
3110 + """
3111 + matchingRefs(
3112 + """
3113 + Returns the elements in the list that come after the specified cursor.
3114 + """
3115 + after: String
3116 +
3117 + """
3118 + Returns the elements in the list that come before the specified cursor.
3119 + """
3120 + before: String
3121 +
3122 + """
3123 + Returns the first _n_ elements from the list.
3124 + """
3125 + first: Int
3126 +
3127 + """
3128 + Returns the last _n_ elements from the list.
3129 + """
3130 + last: Int
3131 +
3132 + """
3133 + Filters refs with query on name
3134 + """
3135 + query: String
3136 + ): RefConnection!
3137 +
3138 + """
3139 + Identifies the protection rule pattern.
3140 + """
3141 + pattern: String!
3142 +
3143 + """
3144 + A list push allowances for this branch protection rule.
3145 + """
3146 + pushAllowances(
3147 + """
3148 + Returns the elements in the list that come after the specified cursor.
3149 + """
3150 + after: String
3151 +
3152 + """
3153 + Returns the elements in the list that come before the specified cursor.
3154 + """
3155 + before: String
3156 +
3157 + """
3158 + Returns the first _n_ elements from the list.
3159 + """
3160 + first: Int
3161 +
3162 + """
3163 + Returns the last _n_ elements from the list.
3164 + """
3165 + last: Int
3166 + ): PushAllowanceConnection!
3167 +
3168 + """
3169 + The repository associated with this branch protection rule.
3170 + """
3171 + repository: Repository
3172 +
3173 + """
3174 + Whether the most recent push must be approved by someone other than the person who pushed it
3175 + """
3176 + requireLastPushApproval: Boolean!
3177 +
3178 + """
3179 + Number of approving reviews required to update matching branches.
3180 + """
3181 + requiredApprovingReviewCount: Int
3182 +
3183 + """
3184 + List of required deployment environments that must be deployed successfully to update matching branches
3185 + """
3186 + requiredDeploymentEnvironments: [String]
3187 +
3188 + """
3189 + List of required status check contexts that must pass for commits to be accepted to matching branches.
3190 + """
3191 + requiredStatusCheckContexts: [String]
3192 +
3193 + """
3194 + List of required status checks that must pass for commits to be accepted to matching branches.
3195 + """
3196 + requiredStatusChecks: [RequiredStatusCheckDescription!]
3197 +
3198 + """
3199 + Are approving reviews required to update matching branches.
3200 + """
3201 + requiresApprovingReviews: Boolean!
3202 +
3203 + """
3204 + Are reviews from code owners required to update matching branches.
3205 + """
3206 + requiresCodeOwnerReviews: Boolean!
3207 +
3208 + """
3209 + Are commits required to be signed.
3210 + """
3211 + requiresCommitSignatures: Boolean!
3212 +
3213 + """
3214 + Are conversations required to be resolved before merging.
3215 + """
3216 + requiresConversationResolution: Boolean!
3217 +
3218 + """
3219 + Does this branch require deployment to specific environments before merging
3220 + """
3221 + requiresDeployments: Boolean!
3222 +
3223 + """
3224 + Are merge commits prohibited from being pushed to this branch.
3225 + """
3226 + requiresLinearHistory: Boolean!
3227 +
3228 + """
3229 + Are status checks required to update matching branches.
3230 + """
3231 + requiresStatusChecks: Boolean!
3232 +
3233 + """
3234 + Are branches required to be up to date before merging.
3235 + """
3236 + requiresStrictStatusChecks: Boolean!
3237 +
3238 + """
3239 + Is pushing to matching branches restricted.
3240 + """
3241 + restrictsPushes: Boolean!
3242 +
3243 + """
3244 + Is dismissal of pull request reviews restricted.
3245 + """
3246 + restrictsReviewDismissals: Boolean!
3247 +
3248 + """
3249 + A list review dismissal allowances for this branch protection rule.
3250 + """
3251 + reviewDismissalAllowances(
3252 + """
3253 + Returns the elements in the list that come after the specified cursor.
3254 + """
3255 + after: String
3256 +
3257 + """
3258 + Returns the elements in the list that come before the specified cursor.
3259 + """
3260 + before: String
3261 +
3262 + """
3263 + Returns the first _n_ elements from the list.
3264 + """
3265 + first: Int
3266 +
3267 + """
3268 + Returns the last _n_ elements from the list.
3269 + """
3270 + last: Int
3271 + ): ReviewDismissalAllowanceConnection!
3272 +}
3273 +
3274 +"""
3275 +A conflict between two branch protection rules.
3276 +"""
3277 +type BranchProtectionRuleConflict @docsCategory(name: "branches") {
3278 + """
3279 + Identifies the branch protection rule.
3280 + """
3281 + branchProtectionRule: BranchProtectionRule
3282 +
3283 + """
3284 + Identifies the conflicting branch protection rule.
3285 + """
3286 + conflictingBranchProtectionRule: BranchProtectionRule
3287 +
3288 + """
3289 + Identifies the branch ref that has conflicting rules
3290 + """
3291 + ref: Ref
3292 +}
3293 +
3294 +"""
3295 +The connection type for BranchProtectionRuleConflict.
3296 +"""
3297 +type BranchProtectionRuleConflictConnection {
3298 + """
3299 + A list of edges.
3300 + """
3301 + edges: [BranchProtectionRuleConflictEdge]
3302 +
3303 + """
3304 + A list of nodes.
3305 + """
3306 + nodes: [BranchProtectionRuleConflict]
3307 +
3308 + """
3309 + Information to aid in pagination.
3310 + """
3311 + pageInfo: PageInfo!
3312 +
3313 + """
3314 + Identifies the total count of items in the connection.
3315 + """
3316 + totalCount: Int!
3317 +}
3318 +
3319 +"""
3320 +An edge in a connection.
3321 +"""
3322 +type BranchProtectionRuleConflictEdge {
3323 + """
3324 + A cursor for use in pagination.
3325 + """
3326 + cursor: String!
3327 +
3328 + """
3329 + The item at the end of the edge.
3330 + """
3331 + node: BranchProtectionRuleConflict
3332 +}
3333 +
3334 +"""
3335 +The connection type for BranchProtectionRule.
3336 +"""
3337 +type BranchProtectionRuleConnection {
3338 + """
3339 + A list of edges.
3340 + """
3341 + edges: [BranchProtectionRuleEdge]
3342 +
3343 + """
3344 + A list of nodes.
3345 + """
3346 + nodes: [BranchProtectionRule]
3347 +
3348 + """
3349 + Information to aid in pagination.
3350 + """
3351 + pageInfo: PageInfo!
3352 +
3353 + """
3354 + Identifies the total count of items in the connection.
3355 + """
3356 + totalCount: Int!
3357 +}
3358 +
3359 +"""
3360 +An edge in a connection.
3361 +"""
3362 +type BranchProtectionRuleEdge {
3363 + """
3364 + A cursor for use in pagination.
3365 + """
3366 + cursor: String!
3367 +
3368 + """
3369 + The item at the end of the edge.
3370 + """
3371 + node: BranchProtectionRule
3372 +}
3373 +
3374 +"""
3375 +Information about a sponsorship to make for a user or organization with a GitHub
3376 +Sponsors profile, as part of sponsoring many users or organizations at once.
3377 +"""
3378 +input BulkSponsorship @docsCategory(name: "sponsors") {
3379 + """
3380 + The amount to pay to the sponsorable in US dollars. Valid values: 1-12000.
3381 + """
3382 + amount: Int!
3383 +
3384 + """
3385 + The ID of the user or organization who is receiving the sponsorship. Required if sponsorableLogin is not given.
3386 + """
3387 + sponsorableId: ID @possibleTypes(concreteTypes: ["Organization", "User"], abstractType: "Sponsorable")
3388 +
3389 + """
3390 + The username of the user or organization who is receiving the sponsorship. Required if sponsorableId is not given.
3391 + """
3392 + sponsorableLogin: String
3393 +}
3394 +
3395 +"""
3396 +Types that can represent a repository ruleset bypass actor.
3397 +"""
3398 +union BypassActor @docsCategory(name: "repos") = App | EnterpriseTeam | Team | User
3399 +
3400 +"""
3401 +A user, team, or app who has the ability to bypass a force push requirement on a protected branch.
3402 +"""
3403 +type BypassForcePushAllowance implements Node @docsCategory(name: "branches") {
3404 + """
3405 + The actor that can force push.
3406 + """
3407 + actor: BranchActorAllowanceActor
3408 +
3409 + """
3410 + Identifies the branch protection rule associated with the allowed user, team, or app.
3411 + """
3412 + branchProtectionRule: BranchProtectionRule
3413 +
3414 + """
3415 + The Node ID of the BypassForcePushAllowance object
3416 + """
3417 + id: ID!
3418 +}
3419 +
3420 +"""
3421 +The connection type for BypassForcePushAllowance.
3422 +"""
3423 +type BypassForcePushAllowanceConnection {
3424 + """
3425 + A list of edges.
3426 + """
3427 + edges: [BypassForcePushAllowanceEdge]
3428 +
3429 + """
3430 + A list of nodes.
3431 + """
3432 + nodes: [BypassForcePushAllowance]
3433 +
3434 + """
3435 + Information to aid in pagination.
3436 + """
3437 + pageInfo: PageInfo!
3438 +
3439 + """
3440 + Identifies the total count of items in the connection.
3441 + """
3442 + totalCount: Int!
3443 +}
3444 +
3445 +"""
3446 +An edge in a connection.
3447 +"""
3448 +type BypassForcePushAllowanceEdge {
3449 + """
3450 + A cursor for use in pagination.
3451 + """
3452 + cursor: String!
3453 +
3454 + """
3455 + The item at the end of the edge.
3456 + """
3457 + node: BypassForcePushAllowance
3458 +}
3459 +
3460 +"""
3461 +A user, team, or app who has the ability to bypass a pull request requirement on a protected branch.
3462 +"""
3463 +type BypassPullRequestAllowance implements Node @docsCategory(name: "branches") {
3464 + """
3465 + The actor that can bypass.
3466 + """
3467 + actor: BranchActorAllowanceActor
3468 +
3469 + """
3470 + Identifies the branch protection rule associated with the allowed user, team, or app.
3471 + """
3472 + branchProtectionRule: BranchProtectionRule
3473 +
3474 + """
3475 + The Node ID of the BypassPullRequestAllowance object
3476 + """
3477 + id: ID!
3478 +}
3479 +
3480 +"""
3481 +The connection type for BypassPullRequestAllowance.
3482 +"""
3483 +type BypassPullRequestAllowanceConnection {
3484 + """
3485 + A list of edges.
3486 + """
3487 + edges: [BypassPullRequestAllowanceEdge]
3488 +
3489 + """
3490 + A list of nodes.
3491 + """
3492 + nodes: [BypassPullRequestAllowance]
3493 +
3494 + """
3495 + Information to aid in pagination.
3496 + """
3497 + pageInfo: PageInfo!
3498 +
3499 + """
3500 + Identifies the total count of items in the connection.
3501 + """
3502 + totalCount: Int!
3503 +}
3504 +
3505 +"""
3506 +An edge in a connection.
3507 +"""
3508 +type BypassPullRequestAllowanceEdge {
3509 + """
3510 + A cursor for use in pagination.
3511 + """
3512 + cursor: String!
3513 +
3514 + """
3515 + The item at the end of the edge.
3516 + """
3517 + node: BypassPullRequestAllowance
3518 +}
3519 +
3520 +"""
3521 +The Common Vulnerability Scoring System
3522 +"""
3523 +type CVSS @docsCategory(name: "security-advisories") {
3524 + """
3525 + The CVSS score associated with this advisory
3526 + """
3527 + score: Float!
3528 +
3529 + """
3530 + The CVSS vector string associated with this advisory
3531 + """
3532 + vectorString: String
3533 +}
3534 +
3535 +"""
3536 +A common weakness enumeration
3537 +"""
3538 +type CWE implements Node @docsCategory(name: "security-advisories") {
3539 + """
3540 + The id of the CWE
3541 + """
3542 + cweId: String!
3543 +
3544 + """
3545 + A detailed description of this CWE
3546 + """
3547 + description: String!
3548 +
3549 + """
3550 + The Node ID of the CWE object
3551 + """
3552 + id: ID!
3553 +
3554 + """
3555 + The name of this CWE
3556 + """
3557 + name: String!
3558 +}
3559 +
3560 +"""
3561 +The connection type for CWE.
3562 +"""
3563 +type CWEConnection {
3564 + """
3565 + A list of edges.
3566 + """
3567 + edges: [CWEEdge]
3568 +
3569 + """
3570 + A list of nodes.
3571 + """
3572 + nodes: [CWE]
3573 +
3574 + """
3575 + Information to aid in pagination.
3576 + """
3577 + pageInfo: PageInfo!
3578 +
3579 + """
3580 + Identifies the total count of items in the connection.
3581 + """
3582 + totalCount: Int!
3583 +}
3584 +
3585 +"""
3586 +An edge in a connection.
3587 +"""
3588 +type CWEEdge {
3589 + """
3590 + A cursor for use in pagination.
3591 + """
3592 + cursor: String!
3593 +
3594 + """
3595 + The item at the end of the edge.
3596 + """
3597 + node: CWE
3598 +}
3599 +
3600 +"""
3601 +Autogenerated input type of CancelEnterpriseAdminInvitation
3602 +"""
3603 +input CancelEnterpriseAdminInvitationInput {
3604 + """
3605 + A unique identifier for the client performing the mutation.
3606 + """
3607 + clientMutationId: String
3608 +
3609 + """
3610 + The Node ID of the pending enterprise administrator invitation.
3611 + """
3612 + invitationId: ID! @possibleTypes(concreteTypes: ["EnterpriseAdministratorInvitation"])
3613 +}
3614 +
3615 +"""
3616 +Autogenerated return type of CancelEnterpriseAdminInvitation.
3617 +"""
3618 +type CancelEnterpriseAdminInvitationPayload {
3619 + """
3620 + A unique identifier for the client performing the mutation.
3621 + """
3622 + clientMutationId: String
3623 +
3624 + """
3625 + The invitation that was canceled.
3626 + """
3627 + invitation: EnterpriseAdministratorInvitation
3628 +
3629 + """
3630 + A message confirming the result of canceling an administrator invitation.
3631 + """
3632 + message: String
3633 +}
3634 +
3635 +"""
3636 +Autogenerated input type of CancelEnterpriseMemberInvitation
3637 +"""
3638 +input CancelEnterpriseMemberInvitationInput {
3639 + """
3640 + A unique identifier for the client performing the mutation.
3641 + """
3642 + clientMutationId: String
3643 +
3644 + """
3645 + The Node ID of the pending enterprise member invitation.
3646 + """
3647 + invitationId: ID! @possibleTypes(concreteTypes: ["EnterpriseMemberInvitation"])
3648 +}
3649 +
3650 +"""
3651 +Autogenerated return type of CancelEnterpriseMemberInvitation.
3652 +"""
3653 +type CancelEnterpriseMemberInvitationPayload {
3654 + """
3655 + A unique identifier for the client performing the mutation.
3656 + """
3657 + clientMutationId: String
3658 +
3659 + """
3660 + The invitation that was canceled.
3661 + """
3662 + invitation: EnterpriseMemberInvitation
3663 +
3664 + """
3665 + A message confirming the result of canceling an member invitation.
3666 + """
3667 + message: String
3668 +}
3669 +
3670 +"""
3671 +Autogenerated input type of CancelSponsorship
3672 +"""
3673 +input CancelSponsorshipInput {
3674 + """
3675 + A unique identifier for the client performing the mutation.
3676 + """
3677 + clientMutationId: String
3678 +
3679 + """
3680 + The ID of the user or organization who is acting as the sponsor, paying for
3681 + the sponsorship. Required if sponsorLogin is not given.
3682 + """
3683 + sponsorId: ID @possibleTypes(concreteTypes: ["Organization", "User"], abstractType: "Sponsor")
3684 +
3685 + """
3686 + The username of the user or organization who is acting as the sponsor, paying
3687 + for the sponsorship. Required if sponsorId is not given.
3688 + """
3689 + sponsorLogin: String
3690 +
3691 + """
3692 + The ID of the user or organization who is receiving the sponsorship. Required if sponsorableLogin is not given.
3693 + """
3694 + sponsorableId: ID @possibleTypes(concreteTypes: ["Organization", "User"], abstractType: "Sponsorable")
3695 +
3696 + """
3697 + The username of the user or organization who is receiving the sponsorship. Required if sponsorableId is not given.
3698 + """
3699 + sponsorableLogin: String
3700 +}
3701 +
3702 +"""
3703 +Autogenerated return type of CancelSponsorship.
3704 +"""
3705 +type CancelSponsorshipPayload {
3706 + """
3707 + A unique identifier for the client performing the mutation.
3708 + """
3709 + clientMutationId: String
3710 +
3711 + """
3712 + The tier that was being used at the time of cancellation.
3713 + """
3714 + sponsorsTier: SponsorsTier
3715 +}
3716 +
3717 +"""
3718 +Autogenerated input type of ChangeUserStatus
3719 +"""
3720 +input ChangeUserStatusInput {
3721 + """
3722 + A unique identifier for the client performing the mutation.
3723 + """
3724 + clientMutationId: String
3725 +
3726 + """
3727 + The emoji to represent your status. Can either be a native Unicode emoji or an emoji name with colons, e.g., :grinning:.
3728 + """
3729 + emoji: String
3730 +
3731 + """
3732 + If set, the user status will not be shown after this date.
3733 + """
3734 + expiresAt: DateTime
3735 +
3736 + """
3737 + Whether this status should indicate you are not fully available on GitHub, e.g., you are away.
3738 + """
3739 + limitedAvailability: Boolean = false
3740 +
3741 + """
3742 + A short description of your current status.
3743 + """
3744 + message: String
3745 +
3746 + """
3747 + The ID of the organization whose members will be allowed to see the status. If
3748 + omitted, the status will be publicly visible.
3749 + """
3750 + organizationId: ID @possibleTypes(concreteTypes: ["Organization"])
3751 +}
3752 +
3753 +"""
3754 +Autogenerated return type of ChangeUserStatus.
3755 +"""
3756 +type ChangeUserStatusPayload {
3757 + """
3758 + A unique identifier for the client performing the mutation.
3759 + """
3760 + clientMutationId: String
3761 +
3762 + """
3763 + Your updated status.
3764 + """
3765 + status: UserStatus
3766 +}
3767 +
3768 +"""
3769 +A single check annotation.
3770 +"""
3771 +type CheckAnnotation @docsCategory(name: "checks") {
3772 + """
3773 + The annotation's severity level.
3774 + """
3775 + annotationLevel: CheckAnnotationLevel
3776 +
3777 + """
3778 + The path to the file that this annotation was made on.
3779 + """
3780 + blobUrl: URI!
3781 +
3782 + """
3783 + Identifies the primary key from the database.
3784 + """
3785 + databaseId: Int
3786 + @deprecated(
3787 + reason: "`databaseId` will be removed because it does not support 64-bit signed integer identifiers. Use `fullDatabaseId` instead. Removal on 2027-01-01 UTC."
3788 + )
3789 +
3790 + """
3791 + Identifies the primary key from the database as a BigInt.
3792 + """
3793 + fullDatabaseId: BigInt
3794 +
3795 + """
3796 + The position of this annotation.
3797 + """
3798 + location: CheckAnnotationSpan!
3799 +
3800 + """
3801 + The annotation's message.
3802 + """
3803 + message: String!
3804 +
3805 + """
3806 + The path that this annotation was made on.
3807 + """
3808 + path: String!
3809 +
3810 + """
3811 + Additional information about the annotation.
3812 + """
3813 + rawDetails: String
3814 +
3815 + """
3816 + The annotation's title
3817 + """
3818 + title: String
3819 +}
3820 +
3821 +"""
3822 +The connection type for CheckAnnotation.
3823 +"""
3824 +type CheckAnnotationConnection {
3825 + """
3826 + A list of edges.
3827 + """
3828 + edges: [CheckAnnotationEdge]
3829 +
3830 + """
3831 + A list of nodes.
3832 + """
3833 + nodes: [CheckAnnotation]
3834 +
3835 + """
3836 + Information to aid in pagination.
3837 + """
3838 + pageInfo: PageInfo!
3839 +
3840 + """
3841 + Identifies the total count of items in the connection.
3842 + """
3843 + totalCount: Int!
3844 +}
3845 +
3846 +"""
3847 +Information from a check run analysis to specific lines of code.
3848 +"""
3849 +input CheckAnnotationData @docsCategory(name: "checks") {
3850 + """
3851 + Represents an annotation's information level
3852 + """
3853 + annotationLevel: CheckAnnotationLevel!
3854 +
3855 + """
3856 + The location of the annotation
3857 + """
3858 + location: CheckAnnotationRange!
3859 +
3860 + """
3861 + A short description of the feedback for these lines of code.
3862 + """
3863 + message: String!
3864 +
3865 + """
3866 + The path of the file to add an annotation to.
3867 + """
3868 + path: String!
3869 +
3870 + """
3871 + Details about this annotation.
3872 + """
3873 + rawDetails: String
3874 +
3875 + """
3876 + The title that represents the annotation.
3877 + """
3878 + title: String
3879 +}
3880 +
3881 +"""
3882 +An edge in a connection.
3883 +"""
3884 +type CheckAnnotationEdge {
3885 + """
3886 + A cursor for use in pagination.
3887 + """
3888 + cursor: String!
3889 +
3890 + """
3891 + The item at the end of the edge.
3892 + """
3893 + node: CheckAnnotation
3894 +}
3895 +
3896 +"""
3897 +Represents an annotation's information level.
3898 +"""
3899 +enum CheckAnnotationLevel @docsCategory(name: "checks") {
3900 + """
3901 + An annotation indicating an inescapable error.
3902 + """
3903 + FAILURE
3904 +
3905 + """
3906 + An annotation indicating some information.
3907 + """
3908 + NOTICE
3909 +
3910 + """
3911 + An annotation indicating an ignorable error.
3912 + """
3913 + WARNING
3914 +}
3915 +
3916 +"""
3917 +A character position in a check annotation.
3918 +"""
3919 +type CheckAnnotationPosition @docsCategory(name: "checks") {
3920 + """
3921 + Column number (1 indexed).
3922 + """
3923 + column: Int
3924 +
3925 + """
3926 + Line number (1 indexed).
3927 + """
3928 + line: Int!
3929 +}
3930 +
3931 +"""
3932 +Information from a check run analysis to specific lines of code.
3933 +"""
3934 +input CheckAnnotationRange @docsCategory(name: "checks") {
3935 + """
3936 + The ending column of the range.
3937 + """
3938 + endColumn: Int
3939 +
3940 + """
3941 + The ending line of the range.
3942 + """
3943 + endLine: Int!
3944 +
3945 + """
3946 + The starting column of the range.
3947 + """
3948 + startColumn: Int
3949 +
3950 + """
3951 + The starting line of the range.
3952 + """
3953 + startLine: Int!
3954 +}
3955 +
3956 +"""
3957 +An inclusive pair of positions for a check annotation.
3958 +"""
3959 +type CheckAnnotationSpan @docsCategory(name: "checks") {
3960 + """
3961 + End position (inclusive).
3962 + """
3963 + end: CheckAnnotationPosition!
3964 +
3965 + """
3966 + Start position (inclusive).
3967 + """
3968 + start: CheckAnnotationPosition!
3969 +}
3970 +
3971 +"""
3972 +The possible states for a check suite or run conclusion.
3973 +"""
3974 +enum CheckConclusionState @docsCategory(name: "checks") {
3975 + """
3976 + The check suite or run requires action.
3977 + """
3978 + ACTION_REQUIRED
3979 +
3980 + """
3981 + The check suite or run has been cancelled.
3982 + """
3983 + CANCELLED
3984 +
3985 + """
3986 + The check suite or run has failed.
3987 + """
3988 + FAILURE
3989 +
3990 + """
3991 + The check suite or run was neutral.
3992 + """
3993 + NEUTRAL
3994 +
3995 + """
3996 + The check suite or run was skipped.
3997 + """
3998 + SKIPPED
3999 +
4000 + """
4001 + The check suite or run was marked stale by GitHub. Only GitHub can use this conclusion.
4002 + """
4003 + STALE
4004 +
4005 + """
4006 + The check suite or run has failed at startup.
4007 + """
4008 + STARTUP_FAILURE
4009 +
4010 + """
4011 + The check suite or run has succeeded.
4012 + """
4013 + SUCCESS
4014 +
4015 + """
4016 + The check suite or run has timed out.
4017 + """
4018 + TIMED_OUT
4019 +}
4020 +
4021 +"""
4022 +A check run.
4023 +"""
4024 +type CheckRun implements Node & RequirableByPullRequest & UniformResourceLocatable @docsCategory(name: "checks") {
4025 + """
4026 + The check run's annotations
4027 + """
4028 + annotations(
4029 + """
4030 + Returns the elements in the list that come after the specified cursor.
4031 + """
4032 + after: String
4033 +
4034 + """
4035 + Returns the elements in the list that come before the specified cursor.
4036 + """
4037 + before: String
4038 +
4039 + """
4040 + Returns the first _n_ elements from the list.
4041 + """
4042 + first: Int
4043 +
4044 + """
4045 + Returns the last _n_ elements from the list.
4046 + """
4047 + last: Int
4048 + ): CheckAnnotationConnection
4049 +
4050 + """
4051 + The check suite that this run is a part of.
4052 + """
4053 + checkSuite: CheckSuite!
4054 +
4055 + """
4056 + Identifies the date and time when the check run was completed.
4057 + """
4058 + completedAt: DateTime
4059 +
4060 + """
4061 + The conclusion of the check run.
4062 + """
4063 + conclusion: CheckConclusionState
4064 +
4065 + """
4066 + Identifies the primary key from the database.
4067 + """
4068 + databaseId: Int
4069 +
4070 + """
4071 + The corresponding deployment for this job, if any
4072 + """
4073 + deployment: Deployment
4074 +
4075 + """
4076 + The URL from which to find full details of the check run on the integrator's site.
4077 + """
4078 + detailsUrl: URI
4079 +
4080 + """
4081 + A reference for the check run on the integrator's system.
4082 + """
4083 + externalId: String
4084 +
4085 + """
4086 + The Node ID of the CheckRun object
4087 + """
4088 + id: ID!
4089 +
4090 + """
4091 + Whether this is required to pass before merging for a specific pull request.
4092 + """
4093 + isRequired(
4094 + """
4095 + The id of the pull request this is required for
4096 + """
4097 + pullRequestId: ID
4098 +
4099 + """
4100 + The number of the pull request this is required for
4101 + """
4102 + pullRequestNumber: Int
4103 + ): Boolean!
4104 +
4105 + """
4106 + The name of the check for this check run.
4107 + """
4108 + name: String!
4109 +
4110 + """
4111 + Information about a pending deployment, if any, in this check run
4112 + """
4113 + pendingDeploymentRequest: DeploymentRequest
4114 +
4115 + """
4116 + The permalink to the check run summary.
4117 + """
4118 + permalink: URI!
4119 +
4120 + """
4121 + The repository associated with this check run.
4122 + """
4123 + repository: Repository!
4124 +
4125 + """
4126 + The HTTP path for this check run.
4127 + """
4128 + resourcePath: URI!
4129 +
4130 + """
4131 + Identifies the date and time when the check run was started.
4132 + """
4133 + startedAt: DateTime
4134 +
4135 + """
4136 + The current status of the check run.
4137 + """
4138 + status: CheckStatusState!
4139 +
4140 + """
4141 + The check run's steps
4142 + """
4143 + steps(
4144 + """
4145 + Returns the elements in the list that come after the specified cursor.
4146 + """
4147 + after: String
4148 +
4149 + """
4150 + Returns the elements in the list that come before the specified cursor.
4151 + """
4152 + before: String
4153 +
4154 + """
4155 + Returns the first _n_ elements from the list.
4156 + """
4157 + first: Int
4158 +
4159 + """
4160 + Returns the last _n_ elements from the list.
4161 + """
4162 + last: Int
4163 +
4164 + """
4165 + Step number
4166 + """
4167 + number: Int
4168 + ): CheckStepConnection
4169 +
4170 + """
4171 + A string representing the check run's summary
4172 + """
4173 + summary: String
4174 +
4175 + """
4176 + A string representing the check run's text
4177 + """
4178 + text: String
4179 +
4180 + """
4181 + A string representing the check run
4182 + """
4183 + title: String
4184 +
4185 + """
4186 + The HTTP URL for this check run.
4187 + """
4188 + url: URI!
4189 +}
4190 +
4191 +"""
4192 +Possible further actions the integrator can perform.
4193 +"""
4194 +input CheckRunAction @docsCategory(name: "checks") {
4195 + """
4196 + A short explanation of what this action would do.
4197 + """
4198 + description: String!
4199 +
4200 + """
4201 + A reference for the action on the integrator's system.
4202 + """
4203 + identifier: String!
4204 +
4205 + """
4206 + The text to be displayed on a button in the web UI.
4207 + """
4208 + label: String!
4209 +}
4210 +
4211 +"""
4212 +The connection type for CheckRun.
4213 +"""
4214 +type CheckRunConnection {
4215 + """
4216 + A list of edges.
4217 + """
4218 + edges: [CheckRunEdge]
4219 +
4220 + """
4221 + A list of nodes.
4222 + """
4223 + nodes: [CheckRun]
4224 +
4225 + """
4226 + Information to aid in pagination.
4227 + """
4228 + pageInfo: PageInfo!
4229 +
4230 + """
4231 + Identifies the total count of items in the connection.
4232 + """
4233 + totalCount: Int!
4234 +}
4235 +
4236 +"""
4237 +An edge in a connection.
4238 +"""
4239 +type CheckRunEdge {
4240 + """
4241 + A cursor for use in pagination.
4242 + """
4243 + cursor: String!
4244 +
4245 + """
4246 + The item at the end of the edge.
4247 + """
4248 + node: CheckRun
4249 +}
4250 +
4251 +"""
4252 +The filters that are available when fetching check runs.
4253 +"""
4254 +input CheckRunFilter @docsCategory(name: "checks") {
4255 + """
4256 + Filters the check runs created by this application ID.
4257 + """
4258 + appId: Int
4259 +
4260 + """
4261 + Filters the check runs by this name.
4262 + """
4263 + checkName: String
4264 +
4265 + """
4266 + Filters the check runs by this type.
4267 + """
4268 + checkType: CheckRunType
4269 +
4270 + """
4271 + Filters the check runs by these conclusions.
4272 + """
4273 + conclusions: [CheckConclusionState!]
4274 +
4275 + """
4276 + Filters the check runs by this status. Superceded by statuses.
4277 + """
4278 + status: CheckStatusState
4279 +
4280 + """
4281 + Filters the check runs by this status. Overrides status.
4282 + """
4283 + statuses: [CheckStatusState!]
4284 +}
4285 +
4286 +"""
4287 +Descriptive details about the check run.
4288 +"""
4289 +input CheckRunOutput @docsCategory(name: "checks") {
4290 + """
4291 + The annotations that are made as part of the check run.
4292 + """
4293 + annotations: [CheckAnnotationData!]
4294 +
4295 + """
4296 + Images attached to the check run output displayed in the GitHub pull request UI.
4297 + """
4298 + images: [CheckRunOutputImage!]
4299 +
4300 + """
4301 + The summary of the check run (supports Commonmark).
4302 + """
4303 + summary: String!
4304 +
4305 + """
4306 + The details of the check run (supports Commonmark).
4307 + """
4308 + text: String
4309 +
4310 + """
4311 + A title to provide for this check run.
4312 + """
4313 + title: String!
4314 +}
4315 +
4316 +"""
4317 +Images attached to the check run output displayed in the GitHub pull request UI.
4318 +"""
4319 +input CheckRunOutputImage @docsCategory(name: "checks") {
4320 + """
4321 + The alternative text for the image.
4322 + """
4323 + alt: String!
4324 +
4325 + """
4326 + A short image description.
4327 + """
4328 + caption: String
4329 +
4330 + """
4331 + The full URL of the image.
4332 + """
4333 + imageUrl: URI!
4334 +}
4335 +
4336 +"""
4337 +The possible states of a check run in a status rollup.
4338 +"""
4339 +enum CheckRunState @docsCategory(name: "checks") {
4340 + """
4341 + The check run requires action.
4342 + """
4343 + ACTION_REQUIRED
4344 +
4345 + """
4346 + The check run has been cancelled.
4347 + """
4348 + CANCELLED
4349 +
4350 + """
4351 + The check run has been completed.
4352 + """
4353 + COMPLETED
4354 +
4355 + """
4356 + The check run has failed.
4357 + """
4358 + FAILURE
4359 +
4360 + """
4361 + The check run is in progress.
4362 + """
4363 + IN_PROGRESS
4364 +
4365 + """
4366 + The check run was neutral.
4367 + """
4368 + NEUTRAL
4369 +
4370 + """
4371 + The check run is in pending state.
4372 + """
4373 + PENDING
4374 +
4375 + """
4376 + The check run has been queued.
4377 + """
4378 + QUEUED
4379 +
4380 + """
4381 + The check run was skipped.
4382 + """
4383 + SKIPPED
4384 +
4385 + """
4386 + The check run was marked stale by GitHub. Only GitHub can use this conclusion.
4387 + """
4388 + STALE
4389 +
4390 + """
4391 + The check run has failed at startup.
4392 + """
4393 + STARTUP_FAILURE
4394 +
4395 + """
4396 + The check run has succeeded.
4397 + """
4398 + SUCCESS
4399 +
4400 + """
4401 + The check run has timed out.
4402 + """
4403 + TIMED_OUT
4404 +
4405 + """
4406 + The check run is in waiting state.
4407 + """
4408 + WAITING
4409 +}
4410 +
4411 +"""
4412 +Represents a count of the state of a check run.
4413 +"""
4414 +type CheckRunStateCount @docsCategory(name: "checks") {
4415 + """
4416 + The number of check runs with this state.
4417 + """
4418 + count: Int!
4419 +
4420 + """
4421 + The state of a check run.
4422 + """
4423 + state: CheckRunState!
4424 +}
4425 +
4426 +"""
4427 +The possible types of check runs.
4428 +"""
4429 +enum CheckRunType @docsCategory(name: "checks") {
4430 + """
4431 + Every check run available.
4432 + """
4433 + ALL
4434 +
4435 + """
4436 + The latest check run.
4437 + """
4438 + LATEST
4439 +}
4440 +
4441 +"""
4442 +The possible states for a check suite or run status.
4443 +"""
4444 +enum CheckStatusState @docsCategory(name: "checks") {
4445 + """
4446 + The check suite or run has been completed.
4447 + """
4448 + COMPLETED
4449 +
4450 + """
4451 + The check suite or run is in progress.
4452 + """
4453 + IN_PROGRESS
4454 +
4455 + """
4456 + The check suite or run is in pending state.
4457 + """
4458 + PENDING
4459 +
4460 + """
4461 + The check suite or run has been queued.
4462 + """
4463 + QUEUED
4464 +
4465 + """
4466 + The check suite or run has been requested.
4467 + """
4468 + REQUESTED
4469 +
4470 + """
4471 + The check suite or run is in waiting state.
4472 + """
4473 + WAITING
4474 +}
4475 +
4476 +"""
4477 +A single check step.
4478 +"""
4479 +type CheckStep @docsCategory(name: "checks") {
4480 + """
4481 + Identifies the date and time when the check step was completed.
4482 + """
4483 + completedAt: DateTime
4484 +
4485 + """
4486 + The conclusion of the check step.
4487 + """
4488 + conclusion: CheckConclusionState
4489 +
4490 + """
4491 + A reference for the check step on the integrator's system.
4492 + """
4493 + externalId: String
4494 +
4495 + """
4496 + The step's name.
4497 + """
4498 + name: String!
4499 +
4500 + """
4501 + The index of the step in the list of steps of the parent check run.
4502 + """
4503 + number: Int!
4504 +
4505 + """
4506 + Number of seconds to completion.
4507 + """
4508 + secondsToCompletion: Int
4509 +
4510 + """
4511 + Identifies the date and time when the check step was started.
4512 + """
4513 + startedAt: DateTime
4514 +
4515 + """
4516 + The current status of the check step.
4517 + """
4518 + status: CheckStatusState!
4519 +}
4520 +
4521 +"""
4522 +The connection type for CheckStep.
4523 +"""
4524 +type CheckStepConnection {
4525 + """
4526 + A list of edges.
4527 + """
4528 + edges: [CheckStepEdge]
4529 +
4530 + """
4531 + A list of nodes.
4532 + """
4533 + nodes: [CheckStep]
4534 +
4535 + """
4536 + Information to aid in pagination.
4537 + """
4538 + pageInfo: PageInfo!
4539 +
4540 + """
4541 + Identifies the total count of items in the connection.
4542 + """
4543 + totalCount: Int!
4544 +}
4545 +
4546 +"""
4547 +An edge in a connection.
4548 +"""
4549 +type CheckStepEdge {
4550 + """
4551 + A cursor for use in pagination.
4552 + """
4553 + cursor: String!
4554 +
4555 + """
4556 + The item at the end of the edge.
4557 + """
4558 + node: CheckStep
4559 +}
4560 +
4561 +"""
4562 +A check suite.
4563 +"""
4564 +type CheckSuite implements Node @docsCategory(name: "checks") {
4565 + """
4566 + The GitHub App which created this check suite.
4567 + """
4568 + app: App
4569 +
4570 + """
4571 + The name of the branch for this check suite.
4572 + """
4573 + branch: Ref
4574 +
4575 + """
4576 + The check runs associated with a check suite.
4577 + """
4578 + checkRuns(
4579 + """
4580 + Returns the elements in the list that come after the specified cursor.
4581 + """
4582 + after: String
4583 +
4584 + """
4585 + Returns the elements in the list that come before the specified cursor.
4586 + """
4587 + before: String
4588 +
4589 + """
4590 + Filters the check runs by this type.
4591 + """
4592 + filterBy: CheckRunFilter
4593 +
4594 + """
4595 + Returns the first _n_ elements from the list.
4596 + """
4597 + first: Int
4598 +
4599 + """
4600 + Returns the last _n_ elements from the list.
4601 + """
4602 + last: Int
4603 + ): CheckRunConnection
4604 +
4605 + """
4606 + The commit for this check suite
4607 + """
4608 + commit: Commit!
4609 +
4610 + """
4611 + The conclusion of this check suite.
4612 + """
4613 + conclusion: CheckConclusionState
4614 +
4615 + """
4616 + Identifies the date and time when the object was created.
4617 + """
4618 + createdAt: DateTime!
4619 +
4620 + """
4621 + The user who triggered the check suite.
4622 + """
4623 + creator: User
4624 +
4625 + """
4626 + Identifies the primary key from the database.
4627 + """
4628 + databaseId: Int
4629 +
4630 + """
4631 + The Node ID of the CheckSuite object
4632 + """
4633 + id: ID!
4634 +
4635 + """
4636 + A list of open pull requests matching the check suite.
4637 + """
4638 + matchingPullRequests(
4639 + """
4640 + Returns the elements in the list that come after the specified cursor.
4641 + """
4642 + after: String
4643 +
4644 + """
4645 + The base ref name to filter the pull requests by.
4646 + """
4647 + baseRefName: String
4648 +
4649 + """
4650 + Returns the elements in the list that come before the specified cursor.
4651 + """
4652 + before: String
4653 +
4654 + """
4655 + Returns the first _n_ elements from the list.
4656 + """
4657 + first: Int
4658 +
4659 + """
4660 + The head ref name to filter the pull requests by.
4661 + """
4662 + headRefName: String
4663 +
4664 + """
4665 + A list of label names to filter the pull requests by.
4666 + """
4667 + labels: [String!]
4668 +
4669 + """
4670 + Returns the last _n_ elements from the list.
4671 + """
4672 + last: Int
4673 +
4674 + """
4675 + Ordering options for pull requests returned from the connection.
4676 + """
4677 + orderBy: IssueOrder
4678 +
4679 + """
4680 + A list of states to filter the pull requests by.
4681 + """
4682 + states: [PullRequestState!]
4683 + ): PullRequestConnection
4684 +
4685 + """
4686 + The push that triggered this check suite.
4687 + """
4688 + push: Push
4689 +
4690 + """
4691 + The repository associated with this check suite.
4692 + """
4693 + repository: Repository!
4694 +
4695 + """
4696 + The HTTP path for this check suite
4697 + """
4698 + resourcePath: URI!
4699 +
4700 + """
4701 + The status of this check suite.
4702 + """
4703 + status: CheckStatusState!
4704 +
4705 + """
4706 + Identifies the date and time when the object was last updated.
4707 + """
4708 + updatedAt: DateTime!
4709 +
4710 + """
4711 + The HTTP URL for this check suite
4712 + """
4713 + url: URI!
4714 +
4715 + """
4716 + The workflow run associated with this check suite.
4717 + """
4718 + workflowRun: WorkflowRun
4719 +}
4720 +
4721 +"""
4722 +The auto-trigger preferences that are available for check suites.
4723 +"""
4724 +input CheckSuiteAutoTriggerPreference @docsCategory(name: "checks") {
4725 + """
4726 + The node ID of the application that owns the check suite.
4727 + """
4728 + appId: ID!
4729 +
4730 + """
4731 + Set to `true` to enable automatic creation of CheckSuite events upon pushes to the repository.
4732 + """
4733 + setting: Boolean!
4734 +}
4735 +
4736 +"""
4737 +The connection type for CheckSuite.
4738 +"""
4739 +type CheckSuiteConnection {
4740 + """
4741 + A list of edges.
4742 + """
4743 + edges: [CheckSuiteEdge]
4744 +
4745 + """
4746 + A list of nodes.
4747 + """
4748 + nodes: [CheckSuite]
4749 +
4750 + """
4751 + Information to aid in pagination.
4752 + """
4753 + pageInfo: PageInfo!
4754 +
4755 + """
4756 + Identifies the total count of items in the connection.
4757 + """
4758 + totalCount: Int!
4759 +}
4760 +
4761 +"""
4762 +An edge in a connection.
4763 +"""
4764 +type CheckSuiteEdge {
4765 + """
4766 + A cursor for use in pagination.
4767 + """
4768 + cursor: String!
4769 +
4770 + """
4771 + The item at the end of the edge.
4772 + """
4773 + node: CheckSuite
4774 +}
4775 +
4776 +"""
4777 +The filters that are available when fetching check suites.
4778 +"""
4779 +input CheckSuiteFilter @docsCategory(name: "checks") {
4780 + """
4781 + Filters the check suites created by this application ID.
4782 + """
4783 + appId: Int
4784 +
4785 + """
4786 + Filters the check suites by this name.
4787 + """
4788 + checkName: String
4789 +}
4790 +
4791 +"""
4792 +An object which can have its data claimed or claim data from another.
4793 +"""
4794 +union Claimable @docsCategory(name: "users") = Mannequin | User
4795 +
4796 +"""
4797 +Autogenerated input type of ClearLabelsFromLabelable
4798 +"""
4799 +input ClearLabelsFromLabelableInput {
4800 + """
4801 + A unique identifier for the client performing the mutation.
4802 + """
4803 + clientMutationId: String
4804 +
4805 + """
4806 + The id of the labelable object to clear the labels from.
4807 + """
4808 + labelableId: ID! @possibleTypes(concreteTypes: ["Discussion", "Issue", "PullRequest"], abstractType: "Labelable")
4809 +}
4810 +
4811 +"""
4812 +Autogenerated return type of ClearLabelsFromLabelable.
4813 +"""
4814 +type ClearLabelsFromLabelablePayload {
4815 + """
4816 + A unique identifier for the client performing the mutation.
4817 + """
4818 + clientMutationId: String
4819 +
4820 + """
4821 + The item that was unlabeled.
4822 + """
4823 + labelable: Labelable
4824 +}
4825 +
4826 +"""
4827 +Autogenerated input type of ClearProjectV2ItemFieldValue
4828 +"""
4829 +input ClearProjectV2ItemFieldValueInput {
4830 + """
4831 + A unique identifier for the client performing the mutation.
4832 + """
4833 + clientMutationId: String
4834 +
4835 + """
4836 + The ID of the field to be cleared.
4837 + """
4838 + fieldId: ID!
4839 + @possibleTypes(
4840 + concreteTypes: [
4841 + "ProjectV2Field"
4842 + "ProjectV2IterationField"
4843 + "ProjectV2MultiSelectField"
4844 + "ProjectV2SingleSelectField"
4845 + ]
4846 + abstractType: "ProjectV2FieldConfiguration"
4847 + )
4848 +
4849 + """
4850 + The ID of the item to be cleared.
4851 + """
4852 + itemId: ID! @possibleTypes(concreteTypes: ["ProjectV2Item"])
4853 +
4854 + """
4855 + The ID of the Project.
4856 + """
4857 + projectId: ID! @possibleTypes(concreteTypes: ["ProjectV2"])
4858 +}
4859 +
4860 +"""
4861 +Autogenerated return type of ClearProjectV2ItemFieldValue.
4862 +"""
4863 +type ClearProjectV2ItemFieldValuePayload {
4864 + """
4865 + A unique identifier for the client performing the mutation.
4866 + """
4867 + clientMutationId: String
4868 +
4869 + """
4870 + The updated item.
4871 + """
4872 + projectV2Item: ProjectV2Item
4873 +}
4874 +
4875 +"""
4876 +Autogenerated input type of CloneProject
4877 +"""
4878 +input CloneProjectInput {
4879 + """
4880 + The description of the project.
4881 + """
4882 + body: String
4883 +
4884 + """
4885 + A unique identifier for the client performing the mutation.
4886 + """
4887 + clientMutationId: String
4888 +
4889 + """
4890 + Whether or not to clone the source project's workflows.
4891 + """
4892 + includeWorkflows: Boolean!
4893 +
4894 + """
4895 + The name of the project.
4896 + """
4897 + name: String!
4898 +
4899 + """
4900 + The visibility of the project, defaults to false (private).
4901 + """
4902 + public: Boolean
4903 +
4904 + """
4905 + The source project to clone.
4906 + """
4907 + sourceId: ID! @possibleTypes(concreteTypes: ["Project"])
4908 +
4909 + """
4910 + The owner ID to create the project under.
4911 + """
4912 + targetOwnerId: ID! @possibleTypes(concreteTypes: ["Organization", "Repository", "User"], abstractType: "ProjectOwner")
4913 +}
4914 +
4915 +"""
4916 +Autogenerated return type of CloneProject.
4917 +"""
4918 +type CloneProjectPayload {
4919 + """
4920 + A unique identifier for the client performing the mutation.
4921 + """
4922 + clientMutationId: String
4923 +
4924 + """
4925 + The id of the JobStatus for populating cloned fields.
4926 + """
4927 + jobStatusId: String
4928 +
4929 + """
4930 + The new cloned project.
4931 + """
4932 + project: Project
4933 +}
4934 +
4935 +"""
4936 +Autogenerated input type of CloneTemplateRepository
4937 +"""
4938 +input CloneTemplateRepositoryInput {
4939 + """
4940 + A unique identifier for the client performing the mutation.
4941 + """
4942 + clientMutationId: String
4943 +
4944 + """
4945 + A short description of the new repository.
4946 + """
4947 + description: String
4948 +
4949 + """
4950 + Whether to copy all branches from the template to the new repository. Defaults
4951 + to copying only the default branch of the template.
4952 + """
4953 + includeAllBranches: Boolean = false
4954 +
4955 + """
4956 + The name of the new repository.
4957 + """
4958 + name: String!
4959 +
4960 + """
4961 + The ID of the owner for the new repository.
4962 + """
4963 + ownerId: ID! @possibleTypes(concreteTypes: ["Organization", "User"], abstractType: "RepositoryOwner")
4964 +
4965 + """
4966 + The Node ID of the template repository.
4967 + """
4968 + repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"])
4969 +
4970 + """
4971 + Indicates the repository's visibility level.
4972 + """
4973 + visibility: RepositoryVisibility!
4974 +}
4975 +
4976 +"""
4977 +Autogenerated return type of CloneTemplateRepository.
4978 +"""
4979 +type CloneTemplateRepositoryPayload {
4980 + """
4981 + A unique identifier for the client performing the mutation.
4982 + """
4983 + clientMutationId: String
4984 +
4985 + """
4986 + The new repository.
4987 + """
4988 + repository: Repository
4989 +}
4990 +
4991 +"""
4992 +An object that can be closed
4993 +"""
4994 +interface Closable @docsCategory(name: "issues") {
4995 + """
4996 + Indicates if the object is closed (definition of closed may depend on type)
4997 + """
4998 + closed: Boolean!
4999 +

This file is too large to show in full.

packages/source-control-github/schema/github.graphql.ts new
+404
@@ -0,0 +1,404 @@
1 +// Generated by @effect/graphql-generator. Do not edit.
2 +import * as Schema from "effect/Schema"
3 +
4 +export const Int = Schema.Number.check(Schema.isInt32())
5 +
6 +export const ID = Schema.String
7 +
8 +/** An ISO-8601 encoded UTC date string. */
9 +export const DateTime = Schema.String
10 +
11 +/** An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string. */
12 +export const URI = Schema.String
13 +
14 +/** A Git object ID. */
15 +export const GitObjectID = Schema.String
16 +
17 +/** A fully qualified reference name (e.g. `refs/heads/master`). */
18 +export const GitRefname = Schema.String
19 +
20 +/**
21 + * The possible states for a check suite or run conclusion.
22 + *
23 + * - `ACTION_REQUIRED`: The check suite or run requires action.
24 + * - `CANCELLED`: The check suite or run has been cancelled.
25 + * - `FAILURE`: The check suite or run has failed.
26 + * - `NEUTRAL`: The check suite or run was neutral.
27 + * - `SKIPPED`: The check suite or run was skipped.
28 + * - `STALE`: The check suite or run was marked stale by GitHub. Only GitHub can use this conclusion.
29 + * - `STARTUP_FAILURE`: The check suite or run has failed at startup.
30 + * - `SUCCESS`: The check suite or run has succeeded.
31 + * - `TIMED_OUT`: The check suite or run has timed out.
32 + */
33 +export const CheckConclusionState = Schema.Literals(["ACTION_REQUIRED", "CANCELLED", "FAILURE", "NEUTRAL", "SKIPPED", "STALE", "STARTUP_FAILURE", "SUCCESS", "TIMED_OUT"])
34 +export type CheckConclusionState = typeof CheckConclusionState.Type
35 +
36 +/**
37 + * The possible states of a check run in a status rollup.
38 + *
39 + * - `ACTION_REQUIRED`: The check run requires action.
40 + * - `CANCELLED`: The check run has been cancelled.
41 + * - `COMPLETED`: The check run has been completed.
42 + * - `FAILURE`: The check run has failed.
43 + * - `IN_PROGRESS`: The check run is in progress.
44 + * - `NEUTRAL`: The check run was neutral.
45 + * - `PENDING`: The check run is in pending state.
46 + * - `QUEUED`: The check run has been queued.
47 + * - `SKIPPED`: The check run was skipped.
48 + * - `STALE`: The check run was marked stale by GitHub. Only GitHub can use this conclusion.
49 + * - `STARTUP_FAILURE`: The check run has failed at startup.
50 + * - `SUCCESS`: The check run has succeeded.
51 + * - `TIMED_OUT`: The check run has timed out.
52 + * - `WAITING`: The check run is in waiting state.
53 + */
54 +export const CheckRunState = Schema.Literals(["ACTION_REQUIRED", "CANCELLED", "COMPLETED", "FAILURE", "IN_PROGRESS", "NEUTRAL", "PENDING", "QUEUED", "SKIPPED", "STALE", "STARTUP_FAILURE", "SUCCESS", "TIMED_OUT", "WAITING"])
55 +export type CheckRunState = typeof CheckRunState.Type
56 +
57 +/**
58 + * The possible states for a check suite or run status.
59 + *
60 + * - `COMPLETED`: The check suite or run has been completed.
61 + * - `IN_PROGRESS`: The check suite or run is in progress.
62 + * - `PENDING`: The check suite or run is in pending state.
63 + * - `QUEUED`: The check suite or run has been queued.
64 + * - `REQUESTED`: The check suite or run has been requested.
65 + * - `WAITING`: The check suite or run is in waiting state.
66 + */
67 +export const CheckStatusState = Schema.Literals(["COMPLETED", "IN_PROGRESS", "PENDING", "QUEUED", "REQUESTED", "WAITING"])
68 +export type CheckStatusState = typeof CheckStatusState.Type
69 +
70 +/**
71 + * The possible sides of a diff.
72 + *
73 + * - `LEFT`: The left side of the diff.
74 + * - `RIGHT`: The right side of the diff.
75 + */
76 +export const DiffSide = Schema.Literals(["LEFT", "RIGHT"])
77 +export type DiffSide = typeof DiffSide.Type
78 +
79 +/**
80 + * The possible viewed states of a file .
81 + *
82 + * - `DISMISSED`: The file has new changes since last viewed.
83 + * - `UNVIEWED`: The file has not been marked as viewed.
84 + * - `VIEWED`: The file has been marked as viewed.
85 + */
86 +export const FileViewedState = Schema.Literals(["DISMISSED", "UNVIEWED", "VIEWED"])
87 +export type FileViewedState = typeof FileViewedState.Type
88 +
89 +/**
90 + * Detailed status information about a pull request merge.
91 + *
92 + * - `BEHIND`: The head ref is out of date.
93 + * - `BLOCKED`: The merge is blocked.
94 + * - `CLEAN`: Mergeable and passing commit status.
95 + * - `DIRTY`: The merge commit cannot be cleanly created.
96 + * - `DRAFT`: The merge is blocked due to the pull request being a draft. Deprecated: DRAFT state will be removed from this enum and `isDraft` should be used instead Use PullRequest.isDraft instead. Removal on 2021-01-01 UTC.
97 + * - `HAS_HOOKS`: Mergeable with passing commit status and pre-receive hooks.
98 + * - `UNKNOWN`: The state cannot currently be determined.
99 + * - `UNSTABLE`: Mergeable with non-passing commit status.
100 + */
101 +export const MergeStateStatus = Schema.Literals(["BEHIND", "BLOCKED", "CLEAN", "DIRTY", "DRAFT", "HAS_HOOKS", "UNKNOWN", "UNSTABLE"])
102 +export type MergeStateStatus = typeof MergeStateStatus.Type
103 +
104 +/**
105 + * Whether or not a PullRequest can be merged.
106 + *
107 + * - `CONFLICTING`: The pull request cannot be merged due to merge conflicts.
108 + * - `MERGEABLE`: The pull request can be merged.
109 + * - `UNKNOWN`: The mergeability of the pull request is still being calculated.
110 + */
111 +export const MergeableState = Schema.Literals(["CONFLICTING", "MERGEABLE", "UNKNOWN"])
112 +export type MergeableState = typeof MergeableState.Type
113 +
114 +/**
115 + * The possible methods for updating a pull request's head branch with the base branch.
116 + *
117 + * - `MERGE`: Update branch via merge
118 + * - `REBASE`: Update branch via rebase
119 + */
120 +export const PullRequestBranchUpdateMethod = Schema.Literals(["MERGE", "REBASE"])
121 +export type PullRequestBranchUpdateMethod = typeof PullRequestBranchUpdateMethod.Type
122 +
123 +/**
124 + * Represents available types of methods to use when merging a pull request.
125 + *
126 + * - `MERGE`: Add all commits from the head branch to the base branch with a merge commit.
127 + * - `REBASE`: Add all commits from the head branch onto the base branch individually.
128 + * - `SQUASH`: Combine all commits from the head branch into a single commit in the base branch.
129 + */
130 +export const PullRequestMergeMethod = Schema.Literals(["MERGE", "REBASE", "SQUASH"])
131 +export type PullRequestMergeMethod = typeof PullRequestMergeMethod.Type
132 +
133 +/**
134 + * The review status of a pull request.
135 + *
136 + * - `APPROVED`: The pull request has received an approving review.
137 + * - `CHANGES_REQUESTED`: Changes have been requested on the pull request.
138 + * - `REVIEW_REQUIRED`: A review is required before the pull request can be merged.
139 + */
140 +export const PullRequestReviewDecision = Schema.Literals(["APPROVED", "CHANGES_REQUESTED", "REVIEW_REQUIRED"])
141 +export type PullRequestReviewDecision = typeof PullRequestReviewDecision.Type
142 +
143 +/**
144 + * The possible states of a pull request review.
145 + *
146 + * - `APPROVED`: A review allowing the pull request to merge.
147 + * - `CHANGES_REQUESTED`: A review blocking the pull request from merging.
148 + * - `COMMENTED`: An informational review.
149 + * - `DISMISSED`: A review that has been dismissed.
150 + * - `PENDING`: A review that has not yet been submitted.
151 + */
152 +export const PullRequestReviewState = Schema.Literals(["APPROVED", "CHANGES_REQUESTED", "COMMENTED", "DISMISSED", "PENDING"])
153 +export type PullRequestReviewState = typeof PullRequestReviewState.Type
154 +
155 +/**
156 + * The possible states of a pull request.
157 + *
158 + * - `CLOSED`: A pull request that has been closed without being merged.
159 + * - `MERGED`: A pull request that has been closed by being merged.
160 + * - `OPEN`: A pull request that is still open.
161 + */
162 +export const PullRequestState = Schema.Literals(["CLOSED", "MERGED", "OPEN"])
163 +export type PullRequestState = typeof PullRequestState.Type
164 +
165 +/**
166 + * Emojis that can be attached to Issues, Pull Requests and Comments.
167 + *
168 + * - `CONFUSED`: Represents the `:confused:` emoji.
169 + * - `EYES`: Represents the `:eyes:` emoji.
170 + * - `HEART`: Represents the `:heart:` emoji.
171 + * - `HOORAY`: Represents the `:hooray:` emoji.
172 + * - `LAUGH`: Represents the `:laugh:` emoji.
173 + * - `ROCKET`: Represents the `:rocket:` emoji.
174 + * - `THUMBS_DOWN`: Represents the `:-1:` emoji.
175 + * - `THUMBS_UP`: Represents the `:+1:` emoji.
176 + */
177 +export const ReactionContent = Schema.Literals(["CONFUSED", "EYES", "HEART", "HOORAY", "LAUGH", "ROCKET", "THUMBS_DOWN", "THUMBS_UP"])
178 +export type ReactionContent = typeof ReactionContent.Type
179 +
180 +/**
181 + * The access level to a repository
182 + *
183 + * - `ADMIN`: Can read, clone, and push to this repository. Can also manage issues, pull requests, and repository settings, including adding collaborators
184 + * - `MAINTAIN`: Can read, clone, and push to this repository. They can also manage issues, pull requests, and some repository settings
185 + * - `READ`: Can read and clone this repository. Can also open and comment on issues and pull requests
186 + * - `TRIAGE`: Can read and clone this repository. Can also manage issues and pull requests
187 + * - `TRIAGE_PLUS`: Can read and clone this repository. Can also manage issues and pull requests, plus additional triage abilities
188 + * - `WRITE`: Can read, clone, and push to this repository. Can also manage issues and pull requests
189 + */
190 +export const RepositoryPermission = Schema.Literals(["ADMIN", "MAINTAIN", "READ", "TRIAGE", "TRIAGE_PLUS", "WRITE"])
191 +export type RepositoryPermission = typeof RepositoryPermission.Type
192 +
193 +/**
194 + * The possible commit status states.
195 + *
196 + * - `ERROR`: Status is errored.
197 + * - `EXPECTED`: Status is expected.
198 + * - `FAILURE`: Status is failing.
199 + * - `PENDING`: Status is pending.
200 + * - `SUCCESS`: Status is successful.
201 + */
202 +export const StatusState = Schema.Literals(["ERROR", "EXPECTED", "FAILURE", "PENDING", "SUCCESS"])
203 +export type StatusState = typeof StatusState.Type
204 +
205 +/** Autogenerated input type of EnablePullRequestAutoMerge */
206 +export const EnablePullRequestAutoMergeInput = Schema.Struct({
207 + /** The email address to associate with this merge. */
208 + authorEmail: Schema.optional(Schema.NullOr(Schema.String)),
209 + /** A unique identifier for the client performing the mutation. */
210 + clientMutationId: Schema.optional(Schema.NullOr(Schema.String)),
211 + /**
212 + * Commit body to use for the commit when the PR is mergable; if omitted, a
213 + * default message will be used. NOTE: when merging with a merge queue any input
214 + * value for commit message is ignored.
215 + */
216 + commitBody: Schema.optional(Schema.NullOr(Schema.String)),
217 + /**
218 + * Commit headline to use for the commit when the PR is mergable; if omitted, a
219 + * default message will be used. NOTE: when merging with a merge queue any input
220 + * value for commit headline is ignored.
221 + */
222 + commitHeadline: Schema.optional(Schema.NullOr(Schema.String)),
223 + /** The expected head OID of the pull request. */
224 + expectedHeadOid: Schema.optional(Schema.NullOr(GitObjectID)),
225 + /**
226 + * The merge method to use. If omitted, defaults to `MERGE`. NOTE: when merging
227 + * with a merge queue any input value for merge method is ignored.
228 + *
229 + * @default MERGE
230 + */
231 + mergeMethod: Schema.optional(Schema.NullOr(PullRequestMergeMethod)),
232 + /** ID of the pull request to enable auto-merge on. */
233 + pullRequestId: ID
234 +})
235 +export interface EnablePullRequestAutoMergeInput extends Schema.Struct.Type<typeof EnablePullRequestAutoMergeInput.fields> {}
236 +
237 +/** Autogenerated input type of MergePullRequest */
238 +export const MergePullRequestInput = Schema.Struct({
239 + /** The email address to associate with this merge. */
240 + authorEmail: Schema.optional(Schema.NullOr(Schema.String)),
241 + /** A unique identifier for the client performing the mutation. */
242 + clientMutationId: Schema.optional(Schema.NullOr(Schema.String)),
243 + /** Commit body to use for the merge commit; if omitted, a default message will be used */
244 + commitBody: Schema.optional(Schema.NullOr(Schema.String)),
245 + /** Commit headline to use for the merge commit; if omitted, a default message will be used. */
246 + commitHeadline: Schema.optional(Schema.NullOr(Schema.String)),
247 + /** OID that the pull request head ref must match to allow merge; if omitted, no check is performed. */
248 + expectedHeadOid: Schema.optional(Schema.NullOr(GitObjectID)),
249 + /**
250 + * The merge method to use. If omitted, defaults to 'MERGE'
251 + *
252 + * @default MERGE
253 + */
254 + mergeMethod: Schema.optional(Schema.NullOr(PullRequestMergeMethod)),
255 + /** ID of the pull request to be merged. */
256 + pullRequestId: ID
257 +})
258 +export interface MergePullRequestInput extends Schema.Struct.Type<typeof MergePullRequestInput.fields> {}
259 +
260 +/** A ref update */
261 +export const RefUpdate = Schema.Struct({
262 + /** The value this ref should be updated to. */
263 + afterOid: GitObjectID,
264 + /** The value this ref needs to point to before the update. */
265 + beforeOid: Schema.optional(Schema.NullOr(GitObjectID)),
266 + /**
267 + * Force a non fast-forward update.
268 + *
269 + * @default false
270 + */
271 + force: Schema.optional(Schema.NullOr(Schema.Boolean)),
272 + /** The fully qualified name of the ref to be update. For example `refs/heads/branch-name` */
273 + name: GitRefname
274 +})
275 +export interface RefUpdate extends Schema.Struct.Type<typeof RefUpdate.fields> {}
276 +
277 +/** Autogenerated input type of UpdateRefs */
278 +export const UpdateRefsInput = Schema.Struct({
279 + /** A unique identifier for the client performing the mutation. */
280 + clientMutationId: Schema.optional(Schema.NullOr(Schema.String)),
281 + /** A list of ref updates. */
282 + refUpdates: Schema.Array(RefUpdate),
283 + /** The Node ID of the repository. */
284 + repositoryId: ID
285 +})
286 +export interface UpdateRefsInput extends Schema.Struct.Type<typeof UpdateRefsInput.fields> {}
287 +
288 +/** The possible `__typename` values of each interface and union the operations select from. */
289 +export declare namespace Typename {
290 + /** Every possible `__typename` of interface `Actor`. */
291 + export type Actor = "Bot" | "EnterpriseUserAccount" | "Mannequin" | "Organization" | "User"
292 + /** Every possible `__typename` of interface `GitObject`. */
293 + export type GitObject = "Blob" | "Commit" | "Tag" | "Tree"
294 + /** Every possible `__typename` of interface `Node`. */
295 + export type Node =
296 + | "AddedToMergeQueueEvent" | "AddedToProjectEvent" | "AddedToProjectV2Event" | "AddedToStackEvent" | "App"
297 + | "AssignedEvent" | "AutoMergeDisabledEvent" | "AutoMergeEnabledEvent" | "AutoRebaseEnabledEvent"
298 + | "AutoSquashEnabledEvent" | "AutomaticBaseChangeFailedEvent" | "AutomaticBaseChangeSucceededEvent"
299 + | "BaseRefChangedEvent" | "BaseRefDeletedEvent" | "BaseRefForcePushedEvent" | "Blob" | "BlockedByAddedEvent"
300 + | "BlockedByRemovedEvent" | "BlockingAddedEvent" | "BlockingRemovedEvent" | "Bot" | "BranchProtectionRule"
301 + | "BypassForcePushAllowance" | "BypassPullRequestAllowance" | "CWE" | "CheckRun" | "CheckSuite" | "ClosedEvent"
302 + | "CodeOfConduct" | "CommentDeletedEvent" | "Commit" | "CommitComment" | "CommitCommentThread" | "Comparison"
303 + | "ConnectedEvent" | "ConvertToDraftEvent" | "ConvertedFromDraftEvent" | "ConvertedNoteToIssueEvent"
304 + | "ConvertedToDiscussionEvent" | "CrossReferencedEvent" | "DemilestonedEvent" | "DependencyGraphManifest"
305 + | "DeployKey" | "DeployedEvent" | "Deployment" | "DeploymentEnvironmentChangedEvent" | "DeploymentReview"
306 + | "DeploymentStatus" | "DisconnectedEvent" | "Discussion" | "DiscussionCategory" | "DiscussionComment"
307 + | "DiscussionPoll" | "DiscussionPollOption" | "DraftIssue" | "Enterprise" | "EnterpriseAdministratorInvitation"
308 + | "EnterpriseIdentityProvider" | "EnterpriseMemberInvitation" | "EnterpriseRepositoryInfo"
309 + | "EnterpriseServerInstallation" | "EnterpriseServerUserAccount" | "EnterpriseServerUserAccountEmail"
310 + | "EnterpriseServerUserAccountsUpload" | "EnterpriseTeam" | "EnterpriseUserAccount" | "Environment"
311 + | "ExternalIdentity" | "Gist" | "GistComment" | "HeadRefDeletedEvent" | "HeadRefForcePushedEvent"
312 + | "HeadRefRestoredEvent" | "IpAllowListEntry" | "Issue" | "IssueComment" | "IssueCommentPinnedEvent"
313 + | "IssueCommentUnpinnedEvent" | "IssueFieldAddedEvent" | "IssueFieldChangedEvent" | "IssueFieldDate"
314 + | "IssueFieldDateValue" | "IssueFieldMultiSelect" | "IssueFieldMultiSelectValue" | "IssueFieldNumber"
315 + | "IssueFieldNumberValue" | "IssueFieldRemovedEvent" | "IssueFieldSingleSelect" | "IssueFieldSingleSelectOption"
316 + | "IssueFieldSingleSelectValue" | "IssueFieldText" | "IssueFieldTextValue" | "IssueType" | "IssueTypeAddedEvent"
317 + | "IssueTypeChangedEvent" | "IssueTypeRemovedEvent" | "Label" | "LabeledEvent" | "Language" | "License"
318 + | "LinkedBranch" | "LockedEvent" | "Mannequin" | "MarkedAsDuplicateEvent" | "MarketplaceCategory"
319 + | "MarketplaceListing" | "MemberFeatureRequestNotification" | "MembersCanDeleteReposClearAuditEntry"
320 + | "MembersCanDeleteReposDisableAuditEntry" | "MembersCanDeleteReposEnableAuditEntry" | "MentionedEvent"
321 + | "MergeQueue" | "MergeQueueEntry" | "MergedEvent" | "MigrationSource" | "Milestone" | "MilestonedEvent"
322 + | "MovedColumnsInProjectEvent" | "OIDCProvider" | "OauthApplicationCreateAuditEntry"
323 + | "OrgAddBillingManagerAuditEntry" | "OrgAddMemberAuditEntry" | "OrgBlockUserAuditEntry"
324 + | "OrgConfigDisableCollaboratorsOnlyAuditEntry" | "OrgConfigEnableCollaboratorsOnlyAuditEntry"
325 + | "OrgCreateAuditEntry" | "OrgDisableOauthAppRestrictionsAuditEntry" | "OrgDisableSamlAuditEntry"
326 + | "OrgDisableTwoFactorRequirementAuditEntry" | "OrgEnableOauthAppRestrictionsAuditEntry" | "OrgEnableSamlAuditEntry"
327 + | "OrgEnableTwoFactorRequirementAuditEntry" | "OrgInviteMemberAuditEntry" | "OrgInviteToBusinessAuditEntry"
328 + | "OrgOauthAppAccessApprovedAuditEntry" | "OrgOauthAppAccessBlockedAuditEntry" | "OrgOauthAppAccessDeniedAuditEntry"
329 + | "OrgOauthAppAccessRequestedAuditEntry" | "OrgOauthAppAccessUnblockedAuditEntry"
330 + | "OrgRemoveBillingManagerAuditEntry" | "OrgRemoveMemberAuditEntry" | "OrgRemoveOutsideCollaboratorAuditEntry"
331 + | "OrgRestoreMemberAuditEntry" | "OrgUnblockUserAuditEntry" | "OrgUpdateDefaultRepositoryPermissionAuditEntry"
332 + | "OrgUpdateMemberAuditEntry" | "OrgUpdateMemberRepositoryCreationPermissionAuditEntry"
333 + | "OrgUpdateMemberRepositoryInvitationPermissionAuditEntry" | "Organization" | "OrganizationIdentityProvider"
334 + | "OrganizationInvitation" | "OrganizationMigration" | "Package" | "PackageFile" | "PackageTag" | "PackageVersion"
335 + | "ParentIssueAddedEvent" | "ParentIssueRemovedEvent" | "PendingAssigneeSuggestion" | "PendingCloseSuggestion"
336 + | "PendingFieldSuggestion" | "PendingLabelSuggestion" | "PendingTypeSuggestion" | "PinnedDiscussion"
337 + | "PinnedEnvironment" | "PinnedEvent" | "PinnedIssue" | "PinnedIssueComment"
338 + | "PrivateRepositoryForkingDisableAuditEntry" | "PrivateRepositoryForkingEnableAuditEntry" | "Project"
339 + | "ProjectCard" | "ProjectColumn" | "ProjectV2" | "ProjectV2Field" | "ProjectV2Item" | "ProjectV2ItemFieldDateValue"
340 + | "ProjectV2ItemFieldIterationValue" | "ProjectV2ItemFieldMultiSelectValue" | "ProjectV2ItemFieldNumberValue"
341 + | "ProjectV2ItemFieldSingleSelectValue" | "ProjectV2ItemFieldTextValue" | "ProjectV2ItemStatusChangedEvent"
342 + | "ProjectV2IterationField" | "ProjectV2MultiSelectField" | "ProjectV2SingleSelectField" | "ProjectV2StatusUpdate"
343 + | "ProjectV2View" | "ProjectV2Workflow" | "PublicKey" | "PullRequest" | "PullRequestCommit"
344 + | "PullRequestCommitCommentThread" | "PullRequestReview" | "PullRequestReviewComment" | "PullRequestReviewThread"
345 + | "PullRequestStack" | "PullRequestStackEntry" | "PullRequestThread" | "Push" | "PushAllowance" | "Query"
346 + | "Reaction" | "ReadyForReviewEvent" | "Ref" | "ReferencedEvent" | "Release" | "ReleaseAsset"
347 + | "RemovedFromMergeQueueEvent" | "RemovedFromProjectEvent" | "RemovedFromProjectV2Event" | "RemovedFromStackEvent"
348 + | "RenamedTitleEvent" | "ReopenedEvent" | "RepoAccessAuditEntry" | "RepoAddMemberAuditEntry"
349 + | "RepoAddTopicAuditEntry" | "RepoArchivedAuditEntry" | "RepoChangeMergeSettingAuditEntry"
350 + | "RepoConfigDisableAnonymousGitAccessAuditEntry" | "RepoConfigDisableCollaboratorsOnlyAuditEntry"
351 + | "RepoConfigDisableContributorsOnlyAuditEntry" | "RepoConfigDisableSockpuppetDisallowedAuditEntry"
352 + | "RepoConfigEnableAnonymousGitAccessAuditEntry" | "RepoConfigEnableCollaboratorsOnlyAuditEntry"
353 + | "RepoConfigEnableContributorsOnlyAuditEntry" | "RepoConfigEnableSockpuppetDisallowedAuditEntry"
354 + | "RepoConfigLockAnonymousGitAccessAuditEntry" | "RepoConfigUnlockAnonymousGitAccessAuditEntry"
355 + | "RepoCreateAuditEntry" | "RepoDestroyAuditEntry" | "RepoRemoveMemberAuditEntry" | "RepoRemoveTopicAuditEntry"
356 + | "Repository" | "RepositoryCustomProperty" | "RepositoryInvitation" | "RepositoryMigration" | "RepositoryRule"
357 + | "RepositoryRuleset" | "RepositoryRulesetBypassActor" | "RepositoryTopic"
358 + | "RepositoryVisibilityChangeDisableAuditEntry" | "RepositoryVisibilityChangeEnableAuditEntry"
359 + | "RepositoryVulnerabilityAlert" | "ReviewDismissalAllowance" | "ReviewDismissedEvent" | "ReviewRequest"
360 + | "ReviewRequestRemovedEvent" | "ReviewRequestedEvent" | "SavedReply" | "SecurityAdvisory" | "SponsorsActivity"
361 + | "SponsorsListing" | "SponsorsListingFeaturedItem" | "SponsorsTier" | "Sponsorship" | "SponsorshipNewsletter"
362 + | "Status" | "StatusCheckRollup" | "StatusContext" | "SubIssueAddedEvent" | "SubIssueRemovedEvent"
363 + | "SubscribedEvent" | "Tag" | "Team" | "TeamAddMemberAuditEntry" | "TeamAddRepositoryAuditEntry"
364 + | "TeamChangeParentTeamAuditEntry" | "TeamRemoveMemberAuditEntry" | "TeamRemoveRepositoryAuditEntry" | "Topic"
365 + | "TransferredEvent" | "Tree" | "UnassignedEvent" | "UnlabeledEvent" | "UnlockedEvent" | "UnmarkedAsDuplicateEvent"
366 + | "UnpinnedEvent" | "UnsubscribedEvent" | "User" | "UserBlockedEvent" | "UserContentEdit" | "UserList"
367 + | "UserNamespaceRepository" | "UserStatus" | "VerifiableDomain" | "Workflow" | "WorkflowRun" | "WorkflowRunFile"
368 + /** Every possible `__typename` of union `PullRequestTimelineItems`. */
369 + export type PullRequestTimelineItems =
370 + | "AddedToMergeQueueEvent" | "AddedToProjectEvent" | "AddedToProjectV2Event" | "AddedToStackEvent" | "AssignedEvent"
371 + | "AutoMergeDisabledEvent" | "AutoMergeEnabledEvent" | "AutoRebaseEnabledEvent" | "AutoSquashEnabledEvent"
372 + | "AutomaticBaseChangeFailedEvent" | "AutomaticBaseChangeSucceededEvent" | "BaseRefChangedEvent"
373 + | "BaseRefDeletedEvent" | "BaseRefForcePushedEvent" | "BlockedByAddedEvent" | "BlockedByRemovedEvent"
374 + | "BlockingAddedEvent" | "BlockingRemovedEvent" | "ClosedEvent" | "CommentDeletedEvent" | "ConnectedEvent"
375 + | "ConvertToDraftEvent" | "ConvertedFromDraftEvent" | "ConvertedNoteToIssueEvent" | "ConvertedToDiscussionEvent"
376 + | "CrossReferencedEvent" | "DemilestonedEvent" | "DeployedEvent" | "DeploymentEnvironmentChangedEvent"
377 + | "DisconnectedEvent" | "HeadRefDeletedEvent" | "HeadRefForcePushedEvent" | "HeadRefRestoredEvent" | "IssueComment"
378 + | "IssueCommentPinnedEvent" | "IssueCommentUnpinnedEvent" | "IssueFieldAddedEvent" | "IssueFieldChangedEvent"
379 + | "IssueFieldRemovedEvent" | "IssueTypeAddedEvent" | "IssueTypeChangedEvent" | "IssueTypeRemovedEvent"
380 + | "LabeledEvent" | "LockedEvent" | "MarkedAsDuplicateEvent" | "MentionedEvent" | "MergedEvent" | "MilestonedEvent"
381 + | "MovedColumnsInProjectEvent" | "ParentIssueAddedEvent" | "ParentIssueRemovedEvent" | "PinnedEvent"
382 + | "ProjectV2ItemStatusChangedEvent" | "PullRequestCommit" | "PullRequestCommitCommentThread" | "PullRequestReview"
383 + | "PullRequestReviewThread" | "PullRequestRevisionMarker" | "ReadyForReviewEvent" | "ReferencedEvent"
384 + | "RemovedFromMergeQueueEvent" | "RemovedFromProjectEvent" | "RemovedFromProjectV2Event" | "RemovedFromStackEvent"
385 + | "RenamedTitleEvent" | "ReopenedEvent" | "ReviewDismissedEvent" | "ReviewRequestRemovedEvent"
386 + | "ReviewRequestedEvent" | "SubIssueAddedEvent" | "SubIssueRemovedEvent" | "SubscribedEvent" | "TransferredEvent"
387 + | "UnassignedEvent" | "UnlabeledEvent" | "UnlockedEvent" | "UnmarkedAsDuplicateEvent" | "UnpinnedEvent"
388 + | "UnsubscribedEvent" | "UserBlockedEvent"
389 + /** Every possible `__typename` of interface `Reactable`. */
390 + export type Reactable =
391 + | "CommitComment" | "Discussion" | "DiscussionComment" | "Issue" | "IssueComment" | "PullRequest"
392 + | "PullRequestReview" | "PullRequestReviewComment" | "Release"
393 + /** Every possible `__typename` of union `Reactor`. */
394 + export type Reactor = "Bot" | "Mannequin" | "Organization" | "User"
395 + /** Every possible `__typename` of interface `RepositoryOwner`. */
396 + export type RepositoryOwner = "Organization" | "User"
397 + /** Every possible `__typename` of union `RequestedReviewer`. */
398 + export type RequestedReviewer = "Bot" | "EnterpriseTeam" | "Mannequin" | "Team" | "User"
399 + /** Every possible `__typename` of union `SearchResultItem`. */
400 + export type SearchResultItem =
401 + | "App" | "Discussion" | "Issue" | "MarketplaceListing" | "Organization" | "PullRequest" | "Repository" | "User"
402 + /** Every possible `__typename` of union `StatusCheckRollupContext`. */
403 + export type StatusCheckRollupContext = "CheckRun" | "StatusContext"
404 +}
packages/source-control-github/src/server/GitHubApi.ts deleted
-587
@@ -1,587 +0,0 @@
1 -import { SourceControlProviderKind } from "@t3tools/contracts";
2 -import * as Clock from "effect/Clock";
3 -import * as Context from "effect/Context";
4 -import * as Data from "effect/Data";
5 -import * as Duration from "effect/Duration";
6 -import * as Effect from "effect/Effect";
7 -import * as Layer from "effect/Layer";
8 -import * as Option from "effect/Option";
9 -import * as Redacted from "effect/Redacted";
10 -import * as Schema from "effect/Schema";
11 -import * as Semaphore from "effect/Semaphore";
12 -import { HttpClient, HttpClientRequest, type HttpClientResponse } from "effect/http";
13 -
14 -import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
15 -import * as GitHubCredentials from "./GitHubCredentials.ts";
16 -import * as GitHubQuota from "./GitHubQuota.ts";
17 -import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
18 -
19 -const DEFAULT_TIMEOUT = Duration.seconds(30);
20 -const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
21 -/** Polite to GitHub's secondary limits, which punish bursts of concurrent requests. */
22 -const CONCURRENCY = 8;
23 -const API_VERSION = "2022-11-28";
24 -
25 -/**
26 - * A credential already verified for one host. Every request made under it must target that
27 - * host, so a page cannot read one account's data with another's token mid-flight. Server-local:
28 - * never put its value in RPC payloads or cache keys.
29 - */
30 -export const PinnedGitHubCredential = Context.Reference<{
31 - readonly host: string;
32 - readonly token: Redacted.Redacted<string>;
33 - readonly credentialFingerprint: string;
34 -} | null>("@t3tools/source-control-github/server/GitHubApi/PinnedGitHubCredential", {
35 - defaultValue: () => null,
36 -});
37 -
38 -export class GitHubApiRequestError extends Schema.TaggedError<GitHubApiRequestError>()(
39 - "GitHubApiRequestError",
40 - { host: Schema.String, operation: Schema.String, cause: Schema.Defect() },
41 -) {
42 - override get message(): string {
43 - return `Could not reach GitHub at ${this.host}.`;
44 - }
45 -}
46 -
47 -export class GitHubApiAuthenticationError extends Schema.TaggedError<GitHubApiAuthenticationError>()(
48 - "GitHubApiAuthenticationError",
49 - { host: Schema.String, operation: Schema.String },
50 -) {
51 - override get message(): string {
52 - return `GitHub refused the credential for ${this.host}. Run \`gh auth login --hostname ${this.host}\` and retry.`;
53 - }
54 -}
55 -
56 -export class GitHubApiRateLimitError extends Schema.TaggedError<GitHubApiRateLimitError>()(
57 - "GitHubApiRateLimitError",
58 - {
59 - host: Schema.String,
60 - operation: Schema.String,
61 - retryAt: Schema.optionalKey(Schema.Finite),
62 - },
63 -) {
64 - override get message(): string {
65 - return "GitHub API rate limit exceeded.";
66 - }
67 -}
68 -
69 -export class GitHubApiNotFoundError extends Schema.TaggedError<GitHubApiNotFoundError>()(
70 - "GitHubApiNotFoundError",
71 - { host: Schema.String, operation: Schema.String },
72 -) {
73 - override get message(): string {
74 - return "GitHub could not find the requested resource, or the credential cannot see it.";
75 - }
76 -}
77 -
78 -/**
79 - * GitHub answered with a failure that is none of the above. `githubErrors` carries GitHub's own
80 - * error messages, from a GraphQL `errors` list or a REST `message`/`errors` body: they name the
81 - * field and the reason ("A pull request already exists for acme:feature"), never a token.
82 - */
83 -export class GitHubApiResponseError extends Schema.TaggedError<GitHubApiResponseError>()(
84 - "GitHubApiResponseError",
85 - {
86 - host: Schema.String,
87 - operation: Schema.String,
88 - status: Schema.Int,
89 - githubErrors: Schema.optionalKey(Schema.Array(Schema.String)),
90 - },
91 -) {
92 - override get message(): string {
93 - return this.githubErrors !== undefined && this.githubErrors.length > 0
94 - ? `GitHub returned an error: ${this.githubErrors.join("; ")}`
95 - : `GitHub returned HTTP ${this.status}.`;
96 - }
97 -}
98 -
99 -export type GitHubApiError =
100 - | GitHubCredentials.GitHubCredentialUnavailableError
101 - | GitHubApiRequestError
102 - | GitHubApiAuthenticationError
103 - | GitHubApiRateLimitError
104 - | GitHubApiNotFoundError
105 - | GitHubApiResponseError
106 - | SourceControlRateLimit.SourceControlRateLimitPausedError;
107 -
108 -export interface GitHubRestResponse {
109 - readonly status: number;
110 - readonly headers: Readonly<Record<string, string | undefined>>;
111 - readonly body: string;
112 - readonly truncated: boolean;
113 - /** The body was not valid UTF-8, which a raw file read takes to mean binary. */
114 - readonly invalidUtf8: boolean;
115 -}
116 -
117 -export interface GitHubRestInput {
118 - readonly host: string;
119 - readonly operation: string;
120 - readonly method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
121 - /** Relative to the API root, e.g. `repos/acme/web/pulls/7`; query string included. */
122 - readonly path: string;
123 - readonly body?: unknown;
124 - /** Defaults to `application/vnd.github+json`. */
125 - readonly accept?: string;
126 - /** Revalidates a cached answer. A 304 is returned rather than failed, and is free. */
127 - readonly ifNoneMatch?: string;
128 - readonly maxResponseBytes?: number;
129 - /** Defaults to 30 seconds; a whole pull request's patch may need longer. */
130 - readonly timeout?: Duration.Input;
131 - /** Overrides `SourceControlRateLimit.Interactive` for this one request. */
132 - readonly allowReserve?: boolean;
133 -}
134 -
135 -export interface GitHubGraphQlInput {
136 - readonly host: string;
137 - readonly operation: string;
138 - readonly query: string;
139 - readonly variables?: Readonly<Record<string, unknown>>;
140 - readonly allowReserve?: boolean;
141 - readonly maxResponseBytes?: number;
142 -}
143 -
144 -export class GitHubApi extends Context.Service<
145 - GitHubApi,
146 - {
147 - /** The raw JSON body of a successful GraphQL answer, with `rateLimit` recorded. */
148 - readonly graphql: (input: GitHubGraphQlInput) => Effect.Effect<string, GitHubApiError>;
149 - readonly rest: (input: GitHubRestInput) => Effect.Effect<GitHubRestResponse, GitHubApiError>;
150 - /** The credential a request to `host` would carry right now. */
151 - readonly credential: (
152 - host: string,
153 - ) => Effect.Effect<
154 - { readonly token: Redacted.Redacted<string>; readonly fingerprint: string },
155 - GitHubApiError
156 - >;
157 - }
158 ->()("@t3tools/source-control-github/server/GitHubApi") {}
159 -
160 -function normalizeHost(host: string): string {
161 - return host.trim().toLowerCase();
162 -}
163 -
164 -/**
165 - * Where the API for a host lives. github.com and GHE.com data residency serve it from an `api.`
166 - * subdomain; GitHub Enterprise Server serves it under `/api` on the instance itself.
167 - */
168 -export function gitHubApiUrls(host: string): { readonly rest: string; readonly graphql: string } {
169 - const normalized = normalizeHost(host);
170 - if (normalized === "github.com") {
171 - return { rest: "https://api.github.com", graphql: "https://api.github.com/graphql" };
172 - }
173 - if (normalized.endsWith(".ghe.com")) {
174 - return {
175 - rest: `https://api.${normalized}`,
176 - graphql: `https://api.${normalized}/graphql`,
177 - };
178 - }
179 - return { rest: `https://${normalized}/api/v3`, graphql: `https://${normalized}/api/graphql` };
180 -}
181 -
182 -/** GraphQL documents longer than this are cut in traces; the hash still identifies them. */
183 -const TRACED_QUERY_MAX_CHARS = 4_000;
184 -
185 -/** A stable short id for a GraphQL document, so traces group by query without its text. */
186 -function queryHash(query: string): string {
187 - let hash = 0x811c9dc5;
188 - for (let index = 0; index < query.length; index++) {
189 - hash ^= query.charCodeAt(index);
190 - hash = Math.imul(hash, 0x01000193);
191 - }
192 - return (hash >>> 0).toString(16).padStart(8, "0");
193 -}
194 -
195 -/** The numeric rate-limit headers GitHub sends, as span attributes. */
196 -function rateLimitAttributes(
197 - headers: Readonly<Record<string, string | undefined>>,
198 -): Record<string, number | string> {
199 - const attributes: Record<string, number | string> = {};
200 - for (const [header, name] of [
201 - ["x-ratelimit-limit", "github.ratelimit.limit"],
202 - ["x-ratelimit-remaining", "github.ratelimit.remaining"],
203 - ["x-ratelimit-used", "github.ratelimit.used"],
204 - ["x-ratelimit-reset", "github.ratelimit.reset"],
205 - ] as const) {
206 - const value = Number(headers[header]);
207 - if (headers[header] !== undefined && Number.isFinite(value)) attributes[name] = value;
208 - }
209 - const resource = headers["x-ratelimit-resource"];
210 - if (resource !== undefined) attributes["github.ratelimit.resource"] = resource;
211 - return attributes;
212 -}
213 -
214 -/** The pause GitHub asked for, from `retry-after` or the primary limit's reset. */
215 -function retryAtFrom(
216 - headers: Readonly<Record<string, string | undefined>>,
217 - now: number,
218 -): number | undefined {
219 - const fromRetryAfter = SourceControlRateLimit.retryAtFromHeader(headers["retry-after"], now);
220 - if (fromRetryAfter !== undefined) return fromRetryAfter;
221 - const reset = Number(headers["x-ratelimit-reset"]) * 1_000;
222 - return Number.isFinite(reset) && reset > now ? reset : undefined;
223 -}
224 -
225 -const decodeGraphQlErrors = Schema.decodeUnknownOption(
226 - Schema.fromJsonString(
227 - Schema.Struct({
228 - errors: Schema.NonEmptyArray(
229 - Schema.Struct({
230 - type: Schema.optional(Schema.String),
231 - message: Schema.optional(Schema.String),
232 - }),
233 - ),
234 - }),
235 - ),
236 -);
237 -
238 -/** A REST failure body: `{ message, errors: [{ message } | { resource, field, code }] }`. */
239 -const decodeRestErrors = Schema.decodeUnknownOption(
240 - Schema.fromJsonString(
241 - Schema.Struct({
242 - message: Schema.optional(Schema.String),
243 - errors: Schema.optional(
244 - Schema.Array(
245 - Schema.Union([
246 - Schema.String,
247 - Schema.Struct({
248 - message: Schema.optional(Schema.String),
249 - field: Schema.optional(Schema.String),
250 - code: Schema.optional(Schema.String),
251 - }),
252 - ]),
253 - ),
254 - ),
255 - }),
256 - ),
257 -);
258 -
259 -function restErrorMessages(body: string): ReadonlyArray<string> | undefined {
260 - return Option.match(decodeRestErrors(body), {
261 - onNone: () => undefined,
262 - onSome: (decoded) => {
263 - const details = (decoded.errors ?? []).flatMap((error) =>
264 - typeof error === "string"
265 - ? [error]
266 - : error.message !== undefined
267 - ? [error.message]
268 - : error.field !== undefined && error.code !== undefined
269 - ? [`${error.field} ${error.code}`]
270 - : [],
271 - );
272 - const messages = [...(decoded.message === undefined ? [] : [decoded.message]), ...details];
273 - return messages.length > 0 ? messages : undefined;
274 - },
275 - });
276 -}
277 -
278 -/** What one GitHub answer means, decided once from its status, headers and body. */
279 -type Answer = Data.TaggedEnum<{
280 - Ok: {};
281 - RateLimited: {};
282 - Unauthorized: {};
283 - NotFound: {};
284 - Failed: { readonly messages: ReadonlyArray<string> | undefined };
285 -}>;
286 -const Answer = Data.taggedEnum<Answer>();
287 -
288 -/**
289 - * GitHub reports a failed GraphQL document with HTTP 200 and an `errors` list, so a GraphQL body
290 - * is read for its error types as well as its status. `gh api graphql` failed those too, and
291 - * callers rely on that to fall back to narrower reads.
292 - */
293 -function classify(input: {
294 - readonly status: number;
295 - readonly headers: Readonly<Record<string, string | undefined>>;
296 - readonly body: string;
297 - readonly graphql: boolean;
298 - readonly acceptNotModified: boolean;
299 -}): Answer {
300 - const { status, headers, body } = input;
301 - const errors = input.graphql
302 - ? Option.getOrUndefined(decodeGraphQlErrors(body))?.errors
303 - : undefined;
304 - const types = errors?.flatMap((error) => (error.type === undefined ? [] : [error.type])) ?? [];
305 - const messages = errors?.flatMap((error) => (error.message === undefined ? [] : [error.message]));
306 - if (
307 - status === 429 ||
308 - types.includes("RATE_LIMITED") ||
309 - // An exhausted GraphQL quota can answer HTTP 200 with an untyped "API rate limit already
310 - // exceeded" error; the headers say the same thing.
311 - (input.graphql && errors !== undefined && headers["x-ratelimit-remaining"] === "0") ||
312 - (input.graphql &&
313 - messages !== undefined &&
314 - messages.some((message) => /rate limit (already )?exceeded/i.test(message))) ||
315 - (status === 403 &&
316 - (headers["x-ratelimit-remaining"] === "0" ||
317 - headers["retry-after"] !== undefined ||
318 - /rate limit/i.test(body)))
319 - ) {
320 - return Answer.RateLimited();
321 - }
322 - if (status === 401) return Answer.Unauthorized();
323 - if (
324 - status === 404 ||
325 - (errors !== undefined && errors.every((error) => error.type === "NOT_FOUND"))
326 - ) {
327 - return Answer.NotFound();
328 - }
329 - if (errors !== undefined) return Answer.Failed({ messages });
330 - if ((status >= 200 && status < 300) || (status === 304 && input.acceptNotModified)) {
331 - return Answer.Ok();
332 - }
333 - return Answer.Failed({ messages: input.graphql ? undefined : restErrorMessages(body) });
334 -}
335 -
336 -/** @public Service construction is part of the canonical Effect module API. */
337 -export const make = Effect.gen(function* () {
338 - const httpClient = yield* HttpClient.HttpClient;
339 - const credentials = yield* GitHubCredentials.GitHubCredentials;
340 - const quota = yield* GitHubQuota.GitHubQuota;
341 - const limits = yield* SourceControlRateLimit.SourceControlRateLimit;
342 - const gate = yield* Semaphore.make(CONCURRENCY);
343 -
344 - const credential: GitHubApi["Service"]["credential"] = Effect.fn("GitHubApi.credential")(
345 - function* (host) {
346 - const normalized = normalizeHost(host);
347 - const pinned = yield* PinnedGitHubCredential;
348 - if (pinned !== null) {
349 - // A pinned page only ever talks to the host it verified.
350 - if (pinned.host !== normalized) {
351 - return yield* new GitHubApiAuthenticationError({
352 - host: normalized,
353 - operation: "credential",
354 - });
355 - }
356 - return { token: pinned.token, fingerprint: pinned.credentialFingerprint };
357 - }
358 - const held = yield* credentials.get(normalized);
359 - return { token: held.token, fingerprint: held.fingerprint };
360 - },
361 - );
362 -
363 - /**
364 - * Sends one request under the host's rate-limit pause and fails a refusal with the error that
365 - * says why. `onSuccess` sees the answer only once it is known to be one.
366 - */
367 - const send = Effect.fn("GitHubApi.send")(function* (input: {
368 - readonly host: string;
369 - readonly operation: string;
370 - readonly request: HttpClientRequest.HttpClientRequest;
371 - readonly maxResponseBytes: number;
372 - readonly timeout?: Duration.Input | undefined;
373 - readonly allowReserve: boolean;
374 - readonly acceptNotModified: boolean;
375 - /** Reads the body for GraphQL `errors`, which GitHub sends with HTTP 200. */
376 - readonly graphql?: boolean;
377 - }) {
378 - const host = normalizeHost(input.host);
379 - // Only the path: a query string can carry a SHA or a branch, and never needs to be in a trace.
380 - yield* Effect.annotateCurrentSpan({
381 - "github.host": host,
382 - "github.operation": input.operation,
383 - "github.kind": input.graphql === true ? "graphql" : "rest",
384 - "http.request.method": input.request.method,
385 - "url.path": new URL(input.request.url).pathname,
386 - });
387 - const { token, fingerprint } = yield* credential(host);
388 - const scope = yield* SourceControlRateLimit.CredentialScope;
389 - // REST spends `core` and GraphQL its own quota, each with its own reserve. Every REST path
390 - // this reads today is `core`; a `search/` read would need its own resource here. A refusal
391 - // still pauses the whole host, the key PullRequestService records its own backoff under.
392 - const resource = input.graphql === true ? "graphql" : "core";
393 - const key = { provider: SourceControlProviderKind.make("github"), host };
394 - const run = Effect.gen(function* () {
395 - const lease = yield* quota
396 - .admit(host, resource, { allowReserve: input.allowReserve })
397 - .pipe(
398 - Effect.andThen(limits.check(key, input.allowReserve ? { allowPaused: true } : undefined)),
399 - )
400 - .pipe(
401 - Effect.tapError((paused) =>
402 - Effect.annotateCurrentSpan({
403 - "github.paused": true,
404 - "github.retry_at": paused.retryAt,
405 - }),
406 - ),
407 - );
408 - // One deadline covers the headers and the body: a host that answers headers and then stalls
409 - // must not hold a slot of the shared gate for undici's own five-minute body timeout.
410 - const { response, collected } = yield* Effect.gen(function* () {
411 - const response: HttpClientResponse.HttpClientResponse = yield* httpClient
412 - .execute(
413 - input.request.pipe(
414 - HttpClientRequest.bearerToken(Redacted.value(token)),
415 - HttpClientRequest.setHeaders({
416 - "x-github-api-version": API_VERSION,
417 - "user-agent": "t3code",
418 - }),
419 - ),
420 - )
421 - .pipe(
422 - // `GitHubApi.send` is the request's span. The client's own span would add `url.full`
423 - // and `url.query`, which can carry SHAs and branch names, so it is off for GitHub.
424 - Effect.provideService(HttpClient.TracerDisabledWhen, () => true),
425 - );
426 - const collected = yield* collectUint8StreamText({
427 - stream: response.stream,
428 - maxBytes: input.maxResponseBytes,
429 - }).pipe(
430 - // 204, 304 and many refusals carry no body at all, which is an empty answer.
431 - Effect.catchIf(
432 - (error) => error.reason._tag === "EmptyBodyError",
433 - () => Effect.succeed({ text: "", truncated: false, invalidUtf8: false }),
434 - ),
435 - );
436 - return { response, collected };
437 - }).pipe(
438 - Effect.timeout(input.timeout ?? DEFAULT_TIMEOUT),
439 - Effect.mapError(
440 - (cause) => new GitHubApiRequestError({ host, operation: input.operation, cause }),
441 - ),
442 - );
443 - const headers = response.headers;
444 - const status = response.status;
445 - yield* quota.observe(host, headers);
446 - yield* Effect.annotateCurrentSpan({
447 - "http.response.status_code": status,
448 - ...rateLimitAttributes(headers),
449 - });
450 - const context = { host, operation: input.operation };
451 - return yield* Answer.$match(
452 - classify({
453 - status,
454 - headers,
455 - body: collected.text,
456 - graphql: input.graphql === true,
457 - acceptNotModified: input.acceptNotModified,
458 - }),
459 - {
460 - Ok: () =>
461 - limits.recordSuccess({ ...key, lease }).pipe(
462 - Effect.as({
463 - status,
464 - headers,
465 - body: collected.text,
466 - truncated: collected.truncated,
467 - invalidUtf8: collected.invalidUtf8,
468 - }),
469 - ),
470 - RateLimited: () =>
471 - Effect.gen(function* () {
472 - const retryAt = retryAtFrom(headers, yield* Clock.currentTimeMillis);
473 - yield* limits.recordRateLimit({ ...key, lease, retryAt });
474 - yield* Effect.annotateCurrentSpan({
475 - "github.rate_limited": true,
476 - ...(retryAt === undefined ? {} : { "github.retry_at": retryAt }),
477 - });
478 - return yield* new GitHubApiRateLimitError({
479 - ...context,
480 - ...(retryAt === undefined ? {} : { retryAt }),
481 - });
482 - }),
483 - // The source may hold a newer token than the one that was refused.
484 - Unauthorized: () =>
485 - credentials
486 - .invalidate(host)
487 - .pipe(Effect.andThen(Effect.fail(new GitHubApiAuthenticationError(context)))),
488 - NotFound: () => Effect.fail(new GitHubApiNotFoundError(context)),
489 - Failed: ({ messages }) =>
490 - Effect.fail(
491 - new GitHubApiResponseError({
492 - ...context,
493 - status,
494 - ...(messages === undefined ? {} : { githubErrors: messages }),
495 - }),
496 - ),
497 - },
498 - );
499 - });
500 - // The rate-limit scope follows the credential, so a pause on one account never blocks another.
501 - return yield* gate
502 - .withPermit(run)
503 - .pipe(Effect.provideService(SourceControlRateLimit.CredentialScope, scope || fingerprint));
504 - });
505 -
506 - const rest: GitHubApi["Service"]["rest"] = (input) => {
507 - const url = `${gitHubApiUrls(input.host).rest}/${input.path.replace(/^\/+/, "")}`;
508 - const base = HttpClientRequest.make(input.method ?? "GET")(url).pipe(
509 - HttpClientRequest.setHeader("accept", input.accept ?? "application/vnd.github+json"),
510 - );
511 - const withEtag =
512 - input.ifNoneMatch === undefined
513 - ? base
514 - : base.pipe(HttpClientRequest.setHeader("if-none-match", input.ifNoneMatch));
515 - const request =
516 - input.body === undefined
517 - ? withEtag
518 - : withEtag.pipe(HttpClientRequest.bodyJsonUnsafe(input.body));
519 - return SourceControlRateLimit.Interactive.pipe(
520 - Effect.flatMap((interactive) =>
521 - send({
522 - host: input.host,
523 - operation: input.operation,
524 - request,
525 - maxResponseBytes: input.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES,
526 - timeout: input.timeout,
527 - allowReserve: input.allowReserve ?? interactive,
528 - acceptNotModified: input.ifNoneMatch !== undefined,
529 - }),
530 - ),
531 - );
532 - };
533 -
534 - const graphql: GitHubApi["Service"]["graphql"] = Effect.fn("GitHubApi.graphql")(
535 - function* (input) {
536 - const host = normalizeHost(input.host);
537 - const allowReserve = input.allowReserve ?? (yield* SourceControlRateLimit.Interactive);
538 - // The document, never its variables: user text (bodies, search terms) travels as variables.
539 - yield* Effect.annotateCurrentSpan({
540 - "github.operation": input.operation,
541 - "github.graphql.query_hash": queryHash(input.query),
542 - "github.graphql.query":
543 - input.query.length > TRACED_QUERY_MAX_CHARS
544 - ? `${input.query.slice(0, TRACED_QUERY_MAX_CHARS)}…`
545 - : input.query,
546 - });
547 - const response = yield* send({
548 - host,
549 - operation: input.operation,
550 - request: HttpClientRequest.post(gitHubApiUrls(host).graphql).pipe(
551 - HttpClientRequest.acceptJson,
552 - HttpClientRequest.bodyJsonUnsafe({
553 - query: input.query,
554 - variables: input.variables ?? {},
555 - }),
556 - ),
557 - maxResponseBytes: input.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES,
558 - allowReserve,
559 - acceptNotModified: false,
560 - graphql: true,
561 - });
562 - // A body cut at the byte cap hides any `errors` past the cut and cannot be decoded.
563 - if (response.truncated) {
564 - return yield* new GitHubApiResponseError({
565 - host,
566 - operation: input.operation,
567 - status: response.status,
568 - });
569 - }
570 - return response.body;
571 - },
572 - );
573 -
574 - return GitHubApi.of({ graphql, rest, credential });
575 -});
576 -
577 -export const layer = Layer.effect(GitHubApi, make);
578 -
579 -/**
580 - * The transport with the credential, quota reserve and rate-limit pause it reads through. An
581 - * application builds this once so every GitHub reader shares one view of each quota per host.
582 - */
583 -export const layerWithDependencies = layer.pipe(
584 - Layer.provideMerge(GitHubCredentials.layer),
585 - Layer.provideMerge(GitHubQuota.layer),
586 - Layer.provideMerge(SourceControlRateLimit.layer),
587 -);
packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
+493 -221
@@ -6,13 +6,15 @@ import * as Clock from "effect/Clock";
6 import * as Deferred from "effect/Deferred";
7 import * as Fiber from "effect/Fiber";
8 import * as Layer from "effect/Layer";
9 +import * as Result from "effect/Result";
10 import * as Schema from "effect/Schema";
11 import * as TestClock from "effect/testing/TestClock";
12 import * as Redacted from "effect/Redacted";
13
14 import { HttpClient, HttpClientResponse } from "effect/http";
15
15 -import * as GitHubApi from "./GitHubApi.ts";
16 +import * as GitHubRest from "./GitHubRest.ts";
17 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
18 import * as GitHubCredentials from "./GitHubCredentials.ts";
19 import * as GitHubQuota from "./GitHubQuota.ts";
20 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
@@ -34,6 +36,21 @@ const coreResponse = (pullRequest: Readonly<Record<string, unknown>> = {}) => ({
36 number: 7,
37 title: "Pull request 7",
38 url: "https://github.com/acme/web/pull/7",
39 + body: "",
40 + isDraft: false,
41 + mergeable: "MERGEABLE",
42 + reviewDecision: null,
43 + additions: 0,
44 + deletions: 0,
45 + changedFiles: 0,
46 + mergedAt: null,
47 + closedAt: null,
48 + isCrossRepository: false,
49 + headRepositoryOwner: null,
50 + headRepository: null,
51 + headRef: null,
52 + author: null,
53 + autoMergeRequest: null,
54 headRefName: "feature",
55 baseRefName: "main",
56 headRefOid: "abc123",
@@ -55,10 +72,19 @@ const coreResponse = (pullRequest: Readonly<Record<string, unknown>> = {}) => ({
72
73 /** One request the CLI made, as the transport received it. */
74 type ApiCall =
58 - | ({ readonly kind: "graphql" } & GitHubApi.GitHubGraphQlInput)
59 - | ({ readonly kind: "rest" } & GitHubApi.GitHubRestInput);
60 -
61 -type ApiAnswer = Effect.Effect<GitHubApi.GitHubRestResponse, GitHubApi.GitHubApiError>;
75 + | {
76 + readonly kind: "graphql";
77 + readonly partial?: boolean;
78 + /** The generated operation's name, which the routes below match on. */
79 + readonly operationName?: string;
80 + readonly host: string;
81 + readonly operation: string;
82 + readonly query: string;
83 + readonly variables?: Readonly<Record<string, unknown>>;
84 + }
85 + | ({ readonly kind: "rest" } & GitHubRest.GitHubRestInput);
86 +
87 +type ApiAnswer = Effect.Effect<GitHubRest.GitHubRestResponse, GitHubRequestPolicy.GitHubApiError>;
88
89 const mockedExecute = vi.fn<(call: ApiCall) => ApiAnswer>();
90 const defaultCredential = (host: string) =>
@@ -68,40 +94,85 @@ const mockedStackMemberships = vi.fn<(call: ApiCall) => ApiAnswer>(() =>
94 Effect.succeed(output('{"data":{}}')),
95 );
96
97 +/** The REST transport, answered from the mocks above. */
98 +const mockApi = Layer.succeed(
99 + GitHubRest.GitHubRest,
100 + GitHubRest.GitHubRest.of({
101 + rest: (input) => mockedExecute({ kind: "rest", ...input }),
102 + credential: (host) => mockedCredential(host),
103 + }),
104 +);
105 +
106 /**
72 - * A transport that answers from the mocks above but spends the real GraphQL quota from each
73 - * answer's headers, the way GitHubApi does, so the reserve behaviour is still the module's to prove.
107 + * The HTTP side of the generated GraphQL reads, answered from the same mocks: a request to a
108 + * host's GraphQL endpoint is recorded as a `graphql` call, carrying the `partial` flag the batches
109 + * read with, and answered with the mocked body, status and headers.
110 */
75 -const mockApi = Layer.effect(
76 - GitHubApi.GitHubApi,
77 - Effect.gen(function* () {
78 - const quota = yield* GitHubQuota.GitHubQuota;
79 - return GitHubApi.GitHubApi.of({
80 - graphql: (input) =>
81 - SourceControlRateLimit.Interactive.pipe(
82 - Effect.flatMap((interactive) =>
83 - quota.admit(input.host, "graphql", {
84 - allowReserve: input.allowReserve ?? interactive,
85 - }),
86 - ),
87 - Effect.andThen(() =>
88 - (input.query.includes("query PullRequestStackMemberships")
89 - ? mockedStackMemberships
90 - : mockedExecute)({ kind: "graphql", ...input }),
91 - ),
92 - Effect.tap((answer) => quota.observe(input.host, answer.headers)),
93 - Effect.map((answer) => answer.body),
94 - ),
95 - rest: (input) => mockedExecute({ kind: "rest", ...input }),
96 - credential: (host) => mockedCredential(host),
97 - });
98 - }),
111 +const mockHttp = Layer.succeed(
112 + HttpClient.HttpClient,
113 + HttpClient.make((request) =>
114 + Effect.gen(function* () {
115 + const host = new URL(request.url).hostname.replace(/^api\./, "");
116 + const sent =
117 + request.body._tag === "Uint8Array"
118 + ? (JSON.parse(new TextDecoder().decode(request.body.body)) as {
119 + readonly query: string;
120 + readonly operationName: string;
121 + readonly variables: Readonly<Record<string, unknown>>;
122 + })
123 + : { query: "", operationName: "", variables: {} };
124 + const call: ApiCall = {
125 + kind: "graphql",
126 + host,
127 + operation: "batch",
128 + operationName: sent.operationName,
129 + query: sent.query,
130 + variables: sent.variables,
131 + partial: true,
132 + };
133 + // A mocked failure with a status is what GitHub would have answered with it.
134 + const answer = yield* (
135 + sent.query.startsWith("query PullRequestStackMembership(")
136 + ? mockedStackMemberships
137 + : mockedExecute
138 + )(call).pipe(
139 + Effect.catchTags({
140 + GitHubApiResponseError: (error) =>
141 + Effect.succeed(output('{"message":"Bad gateway"}', false, false, {}, error.status)),
142 + }),
143 + Effect.orDie,
144 + );
145 + // A mutation mocked as `{}` is one whose answer the test does not read. GitHub always
146 + // answers a mutation that ran with `data`, so it is sent as the null payload it selects.
147 + const body =
148 + answer.body === "{}" && sent.query.startsWith("mutation ")
149 + ? encodeJson(mutationAnswer(sent.query))
150 + : answer.body;
151 + return HttpClientResponse.fromWeb(
152 + request,
153 + new Response(body, {
154 + status: answer.status,
155 + headers: { "content-type": "application/json", ...answer.headers },
156 + }),
157 + );
158 + }),
159 + ),
160 );
161
162 const layer = it.layer(
163 GitHubPullRequestApi.layer.pipe(
164 Layer.provideMerge(mockApi),
165 + Layer.provideMerge(GitHubRequestPolicy.layer),
166 Layer.provideMerge(GitHubQuota.layer),
167 + Layer.provideMerge(SourceControlRateLimit.layer),
168 + Layer.provideMerge(mockHttp),
169 + Layer.provideMerge(
170 + Layer.succeed(GitHubCredentials.GitHubCredentials, {
171 + get: (host) =>
172 + Effect.map(mockedCredential(host), (held) => ({ ...held, host, source: "gh" as const })),
173 + invalidate: () => Effect.void,
174 + }),
175 + ),
176 Layer.provide(NodeCrypto.layer),
177 Layer.provide(TestSourceControlHost.layer()),
178 Layer.provide(NodeServices.layer),
@@ -114,8 +185,9 @@ function output(
185 truncated = false,
186 invalidUtf8 = false,
187 headers: Readonly<Record<string, string>> = {},
117 -): GitHubApi.GitHubRestResponse {
118 - return { status: 200, headers, body, truncated, invalidUtf8 };
188 + status = 200,
189 +): GitHubRest.GitHubRestResponse {
190 + return { status, headers, body, truncated, invalidUtf8 };
191 }
192
193 /** GitHub's GraphQL quota headers, leaving `remaining` of 5,000 until `resetAt`. */
@@ -128,6 +200,23 @@ function graphqlQuota(remaining: number, resetAt = "2099-08-13T14:00:00Z") {
200 };
201 }
202
203 +/** What every listing row answers with, which a fixture overrides only where it matters. */
204 +const rowDefaults = {
205 + author: null,
206 + state: "OPEN",
207 + isDraft: false,
208 + mergeable: "UNKNOWN",
209 + reviewDecision: null,
210 + latestReviews: { nodes: [] },
211 + mergedAt: null,
212 + reviewRequests: { nodes: [] },
213 + labels: { nodes: [] },
214 + commits: { nodes: [] },
215 +};
216 +
217 +/** A connection's page info with no next page, as GitHub sends it: the cursor is always there. */
218 +const lastPage = { hasNextPage: false, endCursor: null };
219 +
220 /**
221 * Listing rows as GraphQL answers them. Overrides may use the flat shapes a test reads most
222 * easily: `reviewRequests` as `[{ login }]` or `[{ slug }]`, and `checks` as the rollup state.
@@ -144,6 +233,7 @@ function rows(
233 checks?: string;
234 } & Record<string, unknown>;
235 return {
236 + ...rowDefaults,
237 number,
238 title: `Pull request ${number}`,
239 url: `https://github.com/acme/web/pull/${number}`,
@@ -156,7 +246,12 @@ function rows(
246 ? {}
247 : {
248 reviewRequests: {
159 - nodes: reviewRequests.map((requestedReviewer) => ({ requestedReviewer })),
249 + nodes: reviewRequests.map((requestedReviewer) => ({
250 + requestedReviewer: {
251 + __typename: "slug" in requestedReviewer ? "Team" : "User",
252 + ...requestedReviewer,
253 + },
254 + })),
255 },
256 }),
257 ...(checks === undefined
@@ -175,7 +270,7 @@ function pullRequests(
270 ): string {
271 return encodeJson({
272 data: {
178 - search: { pageInfo: { hasNextPage: false }, nodes: rows(count, firstNumber, overrides) },
273 + search: { pageInfo: lastPage, nodes: rows(count, firstNumber, overrides) },
274 },
275 });
276 }
@@ -190,7 +285,7 @@ function listedPullRequests(
285 data: {
286 repository: {
287 pullRequests: {
193 - pageInfo: { hasNextPage: false },
288 + pageInfo: lastPage,
289 nodes: rows(count, firstNumber, overrides),
290 },
291 },
@@ -221,7 +316,15 @@ function threadComments(
316 return {
317 totalCount,
318 pageInfo: { hasNextPage: endCursor !== null, endCursor },
224 - nodes: ids.map((id) => ({ id, body: id, createdAt: "2026-07-01T00:00:00Z" })),
319 + nodes: ids.map((id) => ({
320 + id,
321 + author: null,
322 + body: id,
323 + createdAt: "2026-07-01T00:00:00Z",
324 + lastEditedAt: null,
325 + url: `https://github.com/acme/web/pull/7#discussion_${id}`,
326 + reactionGroups: [],
327 + })),
328 };
329 }
330
@@ -243,6 +346,7 @@ function reviewThreadsPage(
346 ): string {
347 return encodeJson({
348 data: {
349 + viewer: { login: "viewer" },
350 repository: {
351 pullRequest: {
352 reviewThreads: {
@@ -250,6 +354,16 @@ function reviewThreadsPage(
354 pageInfo: { hasNextPage: endCursor !== null, endCursor },
355 nodes,
356 },
357 + viewerCanUpdate: true,
358 + viewerDidAuthor: false,
359 + author: null,
360 + reactionGroups: [],
361 + comments: { nodes: [] },
362 + reviews: { nodes: [] },
363 + reviewRequests: { nodes: [] },
364 + latestReviews: { nodes: [] },
365 + reviewDismissals: { pageInfo: lastPage, nodes: [] },
366 + commits: { nodes: [] },
367 },
368 },
369 },
@@ -264,8 +378,10 @@ function threadCommentsPage(
378 ): string {
379 return encodeJson({
380 data: {
381 + viewer: { login: "viewer" },
382 repository: { pullRequest: { id: "PR_7" } },
383 node: {
384 + __typename: "PullRequestReviewThread",
385 pullRequest: { id: pullRequestId },
386 comments: threadComments(ids, endCursor, totalCount),
387 },
@@ -274,7 +390,7 @@ function threadCommentsPage(
390 }
391
392 /** What GitHub answers for a pull request it will not serve a whole diff for. */
277 -const diffRefused = new GitHubApi.GitHubApiResponseError({
393 +const diffRefused = new GitHubRequestPolicy.GitHubApiResponseError({
394 host: "github.com",
395 operation: "getPullRequestDiff",
396 status: 406,
@@ -315,10 +431,16 @@ function searchOfCall(index: number): string | undefined {
431 /** One row as a search answers it, which is the listing's row one connection deeper. */
432 function searchItem(number: number, repository: string, updatedAt: string) {
433 return {
434 + ...rowDefaults,
435 number,
436 title: `Pull request ${number}`,
437 url: `https://github.com/${repository}/pull/${number}`,
321 - author: { login: "octocat", avatarUrl: "https://avatars/octocat" },
438 + author: {
439 + __typename: "User",
440 + login: "octocat",
441 + avatarUrl: "https://avatars/octocat",
442 + name: null,
443 + },
444 headRefName: "feat/page",
445 baseRefName: "main",
446 state: "OPEN",
@@ -327,38 +449,64 @@ function searchItem(number: number, repository: string, updatedAt: string) {
449 createdAt: "2026-07-01T00:00:00Z",
450 updatedAt,
451 repository: { nameWithOwner: repository },
330 - reviewRequests: { nodes: [{ requestedReviewer: { login: "hubot" } }] },
452 + reviewRequests: { nodes: [{ requestedReviewer: { __typename: "User", login: "hubot" } }] },
453 labels: { nodes: [{ name: "bug", color: "ff0000" }] },
454 };
455 }
456
457 function searchPage(nodes: ReadonlyArray<unknown>, hasNextPage = false) {
336 - return output(encodeJson({ data: { search: { pageInfo: { hasNextPage }, nodes } } }));
458 + return output(
459 + encodeJson({
460 + data: {
461 + search: { pageInfo: { hasNextPage, endCursor: hasNextPage ? "next" : null }, nodes },
462 + },
463 + }),
464 + );
465 }
466
467 const searchQueryOfCall = searchOfCall;
468
469 +/** Whether a request is the GraphQL operation `needle` names, or its document or path holds it. */
470 +function matches(call: ApiCall, needle: string): boolean {
471 + return call.kind === "graphql"
472 + ? call.operationName === needle || call.query.includes(needle)
473 + : call.path.includes(needle);
474 +}
475 +
476 /**
342 - * Answers every request with the body of the first route whose needle its GraphQL document or
343 - * REST path contains, and anything unrouted with an empty object, which a mutation never reads.
477 + * Answers every request with the body of the first route whose needle it matches, and any
478 + * unrouted mutation with the empty payload each one selects, which nothing reads back.
479 */
480 function route(...routes: ReadonlyArray<readonly [needle: string, body: unknown]>): void {
481 mockedExecute.mockImplementation((call) => {
347 - const target = call.kind === "graphql" ? call.query : call.path;
348 - const match = routes.find(([needle]) => target.includes(needle));
349 - return Effect.succeed(output(match === undefined ? "{}" : encodeJson(match[1])));
482 + const match = routes.find(([needle]) => matches(call, needle));
483 + return Effect.succeed(
484 + output(
485 + match !== undefined
486 + ? encodeJson(match[1])
487 + : call.kind === "graphql" && call.query.startsWith("mutation ")
488 + ? encodeJson(mutationAnswer(call.query))
489 + : "{}",
490 + ),
491 + );
492 });
493 }
494
353 -/** The variables of every GraphQL request whose document contains `needle`, in order. */
495 +/** What a mutation answers when nothing is asked of its payload: each root field, null. */
496 +function mutationAnswer(query: string) {
497 + const root = /\)\{(\w+)(?:\(|\{|@)/.exec(query)?.[1];
498 + return { data: root === undefined ? {} : { [root]: null } };
499 +}
500 +
501 +/** The variables of every GraphQL request `needle` matches, in order. */
502 function variablesOf(needle: string): ReadonlyArray<Readonly<Record<string, unknown>>> {
503 return mockedExecute.mock.calls.flatMap(([call]) =>
356 - call.kind === "graphql" && call.query.includes(needle) ? [call.variables ?? {}] : [],
504 + call.kind === "graphql" && matches(call, needle) ? [call.variables ?? {}] : [],
505 );
506 }
507
508 /** Every REST request whose path contains `needle`, in order. */
361 -function restCallsTo(needle: string): ReadonlyArray<GitHubApi.GitHubRestInput> {
509 +function restCallsTo(needle: string): ReadonlyArray<GitHubRest.GitHubRestInput> {
510 return mockedExecute.mock.calls.flatMap(([call]) =>
511 call.kind === "rest" && call.path.includes(needle) ? [call] : [],
512 );
@@ -368,14 +516,27 @@ function restCallsTo(needle: string): ReadonlyArray<GitHubApi.GitHubRestInput> {
516 * The check that a client-given node hangs off the pull request it names. Routed before the node
517 * id lookup, whose document it contains.
518 */
371 -const SUBJECT_SCOPE_QUERY = "node(id: $subjectId)";
519 +const SUBJECT_SCOPE_QUERY = "PullRequestSubject";
520 const subjectScope = (subjectId: string, pullRequestId: string) => ({
521 data: {
522 repository: { pullRequest: { id: pullRequestId } },
375 - node: { id: subjectId, pullRequest: { id: pullRequestId } },
523 + node: { __typename: "IssueComment", id: subjectId, pullRequest: { id: pullRequestId } },
524 },
525 });
526
527 +/** A check run as the `CheckContext` fragment answers it, with `fields` over the defaults. */
528 +const checkRun = (fields: Record<string, unknown>) => ({
529 + __typename: "CheckRun",
530 + name: "",
531 + status: "COMPLETED",
532 + conclusion: null,
533 + startedAt: null,
534 + completedAt: null,
535 + detailsUrl: null,
536 + checkSuite: { workflowRun: null },
537 + ...fields,
538 +});
539 +
540 /** One page of a head commit's check contexts, the read a rollup past one page is walked by. */
541 const checkContextsPage = (
542 nodes: ReadonlyArray<Record<string, unknown>>,
@@ -412,7 +573,7 @@ const crossRepositoryDetail = (headRefOid = "abc123") =>
573 headRefName: "feat/page",
574 headRefOid,
575 isCrossRepository: true,
415 - headRepositoryOwner: { login: "octocat" },
576 + headRepositoryOwner: { __typename: "User", login: "octocat" },
577 });
578
579 /** Open pull requests on one head branch, every one of them from the same fork head. */
@@ -425,7 +586,7 @@ const heads = (numbers: ReadonlyArray<number>) => ({
586 number,
587 headRefOid: "abc123",
588 isCrossRepository: true,
428 - headRepositoryOwner: { login: "octocat" },
589 + headRepositoryOwner: { __typename: "User", login: "octocat" },
590 })),
591 },
592 },
@@ -453,7 +614,7 @@ function workflowApprovalRoutes(
614 ? call.path.endsWith("/approve")
615 ? ""
616 : encodeJson(runsAnswer)
456 - : call.query.includes("headRefName: $head")
617 + : call.operationName === "PullRequestHeads"
618 ? encodeJson(headsAnswer)
619 : encodeJson(detail()),
620 ),
@@ -462,7 +623,7 @@ function workflowApprovalRoutes(
623 }
624
625 /** The pull request node id lookup, which the layer caches for every test after the first. */
465 -const NODE_ID_QUERY = "pullRequest(number: $number) { id }";
626 +const NODE_ID_QUERY = "PullRequestNodeId";
627 const nodeIdAnswer = (id: string) => ({ data: { repository: { pullRequest: { id } } } });
628
629 afterEach(() => {
@@ -499,17 +660,25 @@ it.effect(
660 requests.push({ url: request.url, authorization: request.headers["authorization"] });
661 const body = request.url.endsWith("/user")
662 ? { id: 123, login: "same-account" }
502 - : { data: { repository: { pullRequest: { id: "PR_1" } }, addComment: {} } };
503 - return HttpClientResponse.fromWeb(request, new Response(encodeJson(body)));
663 + : {
664 + data: {
665 + repository: { pullRequest: { id: "PR_1" } },
666 + addComment: { clientMutationId: null },
667 + },
668 + };
669 + return HttpClientResponse.fromWeb(
670 + request,
671 + new Response(encodeJson(body), { headers: { "content-type": "application/json" } }),
672 + );
673 }),
674 ),
675 );
676 const cli = yield* GitHubPullRequestApi.make.pipe(
677 Effect.provide(
509 - GitHubApi.layer.pipe(
510 - Layer.provide(Layer.mergeAll(credentials, http)),
511 - Layer.provide(GitHubQuota.layer),
512 - Layer.provide(SourceControlRateLimit.layer),
678 + GitHubRest.layer.pipe(
679 + Layer.provideMerge(Layer.mergeAll(credentials, http)),
680 + Layer.provideMerge(GitHubQuota.layer),
681 + Layer.provideMerge(SourceControlRateLimit.layer),
682 Layer.merge(TestSourceControlHost.layer()),
683 Layer.provideMerge(NodeServices.layer),
684 ),
@@ -618,6 +787,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
787 isDraft: false,
788 createdAt: "2026-07-01T00:00:00Z",
789 author: {
790 + __typename: "User",
791 login: "octocat",
792 name: "Octo Cat",
793 avatarUrl: "https://github.example/avatar.png",
@@ -708,14 +878,21 @@ layer("GitHubPullRequestApi.layer", (it) => {
878 number,
879 title: `Pull request ${number}`,
880 url: `https://github.com/acme/web/pull/${number}`,
711 - author: { __typename: "User", login: "octocat", name: "Octo Cat", avatarUrl: null },
881 + author: {
882 + __typename: "User",
883 + login: "octocat",
884 + name: "Octo Cat",
885 + avatarUrl: "https://avatars.githubusercontent.com/u/1",
886 + },
887 baseRefName: "main",
888 headRefName: `feat/${number}`,
889 state: "OPEN",
890 isDraft: false,
891 mergeable: "MERGEABLE",
892 reviewDecision: null,
718 - latestReviews: { nodes: [{ state: "APPROVED", author: { login: "reviewer" } }] },
893 + latestReviews: {
894 + nodes: [{ state: "APPROVED", author: { __typename: "User", login: "reviewer" } }],
895 + },
896 additions: 12,
897 deletions: 3,
898 changedFiles: 2,
@@ -728,7 +905,10 @@ layer("GitHubPullRequestApi.layer", (it) => {
905 Effect.succeed(
906 output(
907 encodeJson({
731 - data: { s0: { pullRequest: node(7) }, s1: { pullRequest: node(8) } },
908 + data: {
909 + _0_repository: { pullRequest: node(7) },
910 + _1_repository: { pullRequest: node(8) },
911 + },
912 }),
913 ),
914 ),
@@ -774,13 +954,14 @@ layer("GitHubPullRequestApi.layer", (it) => {
954 assert.strictEqual(eight?.headBranch, "feat/8");
955 expect(mockedExecute).toHaveBeenCalledOnce();
956 expect(queryAt(0)).toContain(
777 - "s0: repository(owner: $s0_owner, name: $s0_name) { pullRequest(number: $s0_number)",
957 + "_0_repository:repository(owner:$_0_owner name:$_0_name){pullRequest(number:$_0_number)",
958 );
959 expect(varsAt(0)).toMatchObject({
780 - s0_owner: "acme",
781 - s0_name: "web",
782 - s0_number: 7,
783 - s1_number: 8,
960 + _0_owner: "acme",
961 + _0_name: "web",
962 + _0_number: 7,
963 + _0_stacks: true,
964 + _1_number: 8,
965 });
966 }),
967 );
@@ -800,7 +981,10 @@ layer("GitHubPullRequestApi.layer", (it) => {
981 Effect.succeed(
982 output(
983 JSON.stringify({
803 - data: { w0: { pullRequest: node(1) }, w1: { pullRequest: null } },
984 + data: {
985 + _0_repository: { pullRequest: node(1) },
986 + _1_repository: { pullRequest: null },
987 + },
988 }),
989 ),
990 ),
@@ -826,58 +1010,82 @@ layer("GitHubPullRequestApi.layer", (it) => {
1010 expect(eight).toBeNull();
1011 expect(mockedExecute).toHaveBeenCalledOnce();
1012 expect(queryAt(0)).toContain(
829 - "w1: repository(owner: $w1_owner, name: $w1_name) { pullRequest(number: $w1_number)",
1013 + "_1_repository:repository(owner:$_1_owner name:$_1_name){pullRequest(number:$_1_number)",
1014 );
831 - expect(varsAt(0)).toMatchObject({ w1_owner: "acme", w1_name: "web", w1_number: 8 });
1015 + expect(varsAt(0)).toMatchObject({ _1_owner: "acme", _1_name: "web", _1_number: 8 });
1016 }),
1017 );
1018
835 - it.effect("reads a pull request the batch said nothing about on its own", () =>
836 - Effect.gen(function* () {
837 - mockedExecute
838 - .mockReturnValueOnce(Effect.succeed(output('{"data":{"s0":{"pullRequest":null}}}')))
839 - .mockReturnValueOnce(
1019 + it.effect(
1020 + "fails only the pull request GitHub cannot find, and answers the rest of its batch",
1021 + () =>
1022 + Effect.gen(function* () {
1023 + mockedExecute.mockReturnValueOnce(
1024 Effect.succeed(
1025 output(
1026 encodeJson({
1027 data: {
844 - s0: {
1028 + _0_repository: { pullRequest: null },
1029 + _1_repository: {
1030 pullRequest: {
846 - number: 7,
847 - title: "Reuse the summary",
848 - url: "https://github.com/acme/web/pull/7",
849 - author: { login: "octocat", name: "Octo Cat" },
1031 + number: 8,
1032 + title: "Still here",
1033 + url: "https://github.com/acme/web/pull/8",
1034 + author: null,
1035 baseRefName: "main",
851 - headRefName: "feat/summary",
1036 + headRefName: "feat/eight",
1037 state: "OPEN",
1038 isDraft: false,
1039 mergeable: "MERGEABLE",
855 - reviewDecision: "APPROVED",
856 - additions: 12,
857 - deletions: 3,
858 - changedFiles: 2,
1040 + reviewDecision: null,
1041 + latestReviews: { nodes: [] },
1042 + additions: 1,
1043 + deletions: 1,
1044 + changedFiles: 1,
1045 updatedAt: "2026-08-24T12:34:56.000Z",
860 - commits: { nodes: [{ commit: { statusCheckRollup: { state: "SUCCESS" } } }] },
1046 + mergedAt: null,
1047 + closedAt: null,
1048 + commits: { nodes: [] },
1049 + stack: null,
1050 + stackEntry: null,
1051 },
1052 },
1053 },
1054 + errors: [
1055 + {
1056 + type: "NOT_FOUND",
1057 + path: ["_0_repository", "pullRequest"],
1058 + message: "Could not resolve to a PullRequest with the number of 7.",
1059 + },
1060 + ],
1061 }),
1062 ),
1063 ),
1064 );
868 - const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
869 -
870 - const read = yield* cli
871 - .getPullRequestSummary({ cwd: "/w", repository: "acme/web", host: "github.com", number: 7 })
872 - .pipe(Effect.forkChild);
873 - yield* TestClock.adjust("10 millis");
874 - const summary = yield* Fiber.join(read);
1065 + const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1066
876 - assert.strictEqual(summary.headBranch, "feat/summary");
877 - assert.strictEqual(summary.checksState, "passing");
878 - assert.strictEqual(mockedExecute.mock.calls.length, 2);
879 - expect(varsAt(1)).toEqual({ owner: "acme", name: "web", number: 7 });
880 - }),
1067 + const reads = yield* Effect.forEach(
1068 + [7, 8],
1069 + (number) =>
1070 + cli
1071 + .getPullRequestSummary({
1072 + cwd: "/w",
1073 + repository: "acme/web",
1074 + host: "github.com",
1075 + number,
1076 + })
1077 + .pipe(Effect.result),
1078 + { concurrency: "unbounded" },
1079 + ).pipe(Effect.forkChild);
1080 + yield* TestClock.adjust("10 millis");
1081 + const [seven, eight] = yield* Fiber.join(reads);
1082 +
1083 + expect(Result.isFailure(seven!) ? seven.failure._tag : null).toBe("GitHubApiNotFoundError");
1084 + expect(Result.isSuccess(eight!) ? eight.success.headBranch : null).toBe("feat/eight");
1085 + // One request answered both; nothing was read again on its own.
1086 + expect(mockedExecute).toHaveBeenCalledOnce();
1087 + expect(callAt(0)).toMatchObject({ kind: "graphql", partial: true });
1088 + }),
1089 );
1090
1091 it.effect("reads the stack a pull request is in through the stacks preview, on its host", () =>
@@ -990,7 +1198,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1198 Effect.gen(function* () {
1199 mockedExecute.mockReturnValueOnce(
1200 Effect.fail(
993 - new GitHubApi.GitHubApiNotFoundError({
1201 + new GitHubRequestPolicy.GitHubApiNotFoundError({
1202 host: "github.com",
1203 operation: "getPullRequestStack",
1204 }),
@@ -1013,7 +1221,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1221 Effect.gen(function* () {
1222 mockedExecute.mockReturnValueOnce(
1223 Effect.fail(
1016 - new GitHubApi.GitHubApiAuthenticationError({
1224 + new GitHubRequestPolicy.GitHubApiAuthenticationError({
1225 host: "github.com",
1226 operation: "getPullRequestStack",
1227 }),
@@ -1036,7 +1244,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1244
1245 it.effect("preserves transient stack failures instead of reporting no stack", () =>
1246 Effect.gen(function* () {
1039 - const failure = new GitHubApi.GitHubApiResponseError({
1247 + const failure = new GitHubRequestPolicy.GitHubApiResponseError({
1248 host: "github.com",
1249 operation: "getPullRequestStack",
1250 status: 503,
@@ -1094,7 +1302,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1302 assert.isFalse(batch.truncated);
1303 expect(callAt(0)).toMatchObject({ kind: "graphql", host: "github.com" });
1304 expect(searchOfCall(0)).toBe("is:pr is:open sort:updated-desc repo:acme/web");
1097 - expect(queryAt(0)).toContain("first: 11");
1305 + expect(varsAt(0)["first"]).toBe(11);
1306 }),
1307 );
1308
@@ -1153,7 +1361,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1361 Effect.gen(function* () {
1362 mockedExecute.mockImplementation((call) =>
1363 Effect.succeed(
1156 - call.kind === "graphql" && call.query.includes("pullRequests(")
1364 + call.kind === "graphql" && call.operationName === "PullRequestList"
1365 ? emptyList()
1366 : emptySearch(),
1367 ),
@@ -1179,7 +1387,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1387 Effect.gen(function* () {
1388 mockedExecute.mockImplementation((call) =>
1389 Effect.succeed(
1182 - call.kind === "graphql" && call.query.includes("pullRequests(")
1390 + call.kind === "graphql" && call.operationName === "PullRequestList"
1391 ? emptyList()
1392 : emptySearch(),
1393 ),
@@ -1204,7 +1412,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1412 Effect.gen(function* () {
1413 mockedExecute.mockImplementation((call) =>
1414 Effect.succeed(
1207 - call.kind === "graphql" && call.query.includes("pullRequests(")
1415 + call.kind === "graphql" && call.operationName === "PullRequestList"
1416 ? emptyList()
1417 : emptySearch(),
1418 ),
@@ -1419,13 +1627,13 @@ layer("GitHubPullRequestApi.layer", (it) => {
1627 output(
1628 encodeJson({
1629 data: {
1422 - s0: {
1630 + _0_repository: {
1631 pullRequest: {
1632 stack: { number: 3, size: 2, baseRefName: "main" },
1633 stackEntry: { position: 1 },
1634 },
1635 },
1428 - s1: { pullRequest: { stack: null, stackEntry: null } },
1636 + _1_repository: { pullRequest: { stack: null, stackEntry: null } },
1637 },
1638 }),
1639 ),
@@ -1464,7 +1672,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1672 mockedStackMemberships.mockImplementation((input) =>
1673 input.kind === "graphql" && Object.values(input.variables ?? {}).includes(26)
1674 ? Effect.fail(
1467 - new GitHubApi.GitHubApiResponseError({
1675 + new GitHubRequestPolicy.GitHubApiResponseError({
1676 host: "github.com",
1677 operation: "listPullRequestStackMemberships",
1678 status: 502,
@@ -1473,14 +1681,22 @@ layer("GitHubPullRequestApi.layer", (it) => {
1681 : Effect.succeed(
1682 output(
1683 encodeJson({
1476 - data: {
1477 - s0: {
1478 - pullRequest: {
1479 - stack: { number: 3, size: 2, baseRefName: "main" },
1480 - stackEntry: { position: 1 },
1481 - },
1482 - },
1483 - },
1684 + data: Object.fromEntries(
1685 + Object.keys(input.kind === "graphql" ? (input.variables ?? {}) : {})
1686 + .filter((name) => name.endsWith("_number"))
1687 + .map((name, index) => [
1688 + name.replace(/number$/, "repository"),
1689 + {
1690 + pullRequest:
1691 + index === 0
1692 + ? {
1693 + stack: { number: 3, size: 2, baseRefName: "main" },
1694 + stackEntry: { position: 1 },
1695 + }
1696 + : { stack: null, stackEntry: null },
1697 + },
1698 + ]),
1699 + ),
1700 }),
1701 ),
1702 ),
@@ -1534,11 +1750,22 @@ layer("GitHubPullRequestApi.layer", (it) => {
1750 repository: "acme/web",
1751 number: index + 1,
1752 }));
1537 - mockedExecute.mockImplementation(() =>
1538 - // Every chunk answers for its first alias only, so a row GitHub said nothing about is
1753 + mockedExecute.mockImplementation((call) =>
1754 + // Every chunk finds only its first pull request, so a row GitHub had nothing for is
1755 // dropped rather than shown as a change of no size.
1756 Effect.succeed(
1541 - output(encodeJson({ data: { s0: { pullRequest: { additions: 4, deletions: 1 } } } })),
1757 + output(
1758 + encodeJson({
1759 + data: Object.fromEntries(
1760 + Object.keys(call.kind === "graphql" ? (call.variables ?? {}) : {})
1761 + .filter((name) => name.endsWith("_number"))
1762 + .map((name, index) => [
1763 + name.replace(/number$/, "repository"),
1764 + { pullRequest: index === 0 ? { additions: 4, deletions: 1 } : null },
1765 + ]),
1766 + ),
1767 + }),
1768 + ),
1769 ),
1770 );
1771 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
@@ -1555,8 +1782,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
1782 { repository: "acme/web", number: 1, additions: 4, deletions: 1 },
1783 { repository: "acme/web", number: 26, additions: 4, deletions: 1 },
1784 ]);
1558 - expect(queryAt(0)).toContain("s0: repository(owner: $s0_owner, name: $s0_name)");
1559 - expect(varsAt(0)).toMatchObject({ s0_owner: "acme", s0_name: "web", s24_number: 25 });
1785 + expect(queryAt(0)).toContain("_0_repository:repository(owner:$_0_owner name:$_0_name)");
1786 + expect(varsAt(0)).toMatchObject({ _0_owner: "acme", _0_name: "web", _24_number: 25 });
1787 }),
1788 );
1789
@@ -1581,7 +1808,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1808 Effect.gen(function* () {
1809 mockedExecute.mockImplementation((call) =>
1810 Effect.succeed(
1584 - call.kind === "graphql" && call.query.includes("pullRequests(")
1811 + call.kind === "graphql" && call.operationName === "PullRequestList"
1812 ? emptyList()
1813 : emptySearch(),
1814 ),
@@ -1611,7 +1838,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1838 Effect.gen(function* () {
1839 mockedExecute.mockImplementation((call) =>
1840 Effect.succeed(
1614 - call.kind === "graphql" && call.query.includes("pullRequests(")
1841 + call.kind === "graphql" && call.operationName === "PullRequestList"
1842 ? emptyList()
1843 : emptySearch(),
1844 ),
@@ -1639,7 +1866,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1866 Effect.gen(function* () {
1867 mockedExecute.mockImplementation((call) =>
1868 Effect.succeed(
1642 - call.kind === "graphql" && call.query.includes("pullRequests(")
1869 + call.kind === "graphql" && call.operationName === "PullRequestList"
1870 ? emptyList()
1871 : emptySearch(),
1872 ),
@@ -1677,7 +1904,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1904 Effect.gen(function* () {
1905 mockedExecute.mockImplementation((call) =>
1906 Effect.succeed(
1680 - call.kind === "graphql" && call.query.includes("pullRequests(")
1907 + call.kind === "graphql" && call.operationName === "PullRequestList"
1908 ? emptyList()
1909 : emptySearch(),
1910 ),
@@ -1703,7 +1930,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
1930 Effect.gen(function* () {
1931 mockedExecute.mockImplementation((call) =>
1932 Effect.succeed(
1706 - call.kind === "graphql" && call.query.includes("pullRequests(")
1933 + call.kind === "graphql" && call.operationName === "PullRequestList"
1934 ? emptyList()
1935 : emptySearch(),
1936 ),
@@ -1849,7 +2076,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2076 Effect.gen(function* () {
2077 mockedExecute.mockImplementation((call) =>
2078 Effect.succeed(
1852 - call.kind === "graphql" && call.query.includes("pullRequests(")
2079 + call.kind === "graphql" && call.operationName === "PullRequestList"
2080 ? emptyList()
2081 : emptySearch(),
2082 ),
@@ -1879,7 +2106,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2106 Effect.gen(function* () {
2107 mockedExecute.mockImplementation((call) =>
2108 Effect.succeed(
1882 - call.kind === "graphql" && call.query.includes("pullRequests(")
2109 + call.kind === "graphql" && call.operationName === "PullRequestList"
2110 ? emptyList()
2111 : emptySearch(),
2112 ),
@@ -1909,7 +2136,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2136 Effect.gen(function* () {
2137 mockedExecute.mockImplementation((call) =>
2138 Effect.succeed(
1912 - call.kind === "graphql" && call.query.includes("pullRequests(")
2139 + call.kind === "graphql" && call.operationName === "PullRequestList"
2140 ? emptyList()
2141 : emptySearch(),
2142 ),
@@ -2074,8 +2301,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
2301 });
2302
2303 expect(batch.items.map((item) => item.number)).toEqual([4]);
2077 - expect(queryAt(1)).toContain("first: 3,");
2078 - expect(queryAt(2)).toContain("first: 6,");
2304 + expect(varsAt(1)["first"]).toBe(3);
2305 + expect(varsAt(2)["first"]).toBe(6);
2306 assert.isFalse(batch.truncated);
2307 }),
2308 );
@@ -2085,10 +2312,10 @@ layer("GitHubPullRequestApi.layer", (it) => {
2312 // A repository with far more pull requests than the bound, none of them for this reader.
2313 let listed = 0;
2314 mockedExecute.mockImplementation((call) => {
2088 - if (call.kind !== "graphql" || !call.query.includes("pullRequests(")) {
2315 + if (call.kind !== "graphql" || call.operationName !== "PullRequestList") {
2316 return Effect.succeed(emptySearch());
2317 }
2091 - const first = Number(/first: (\d+)/.exec(call.query)?.[1]);
2318 + const first = Number(call.variables?.["first"]);
2319 const nodes = rows(first, listed + 1, () => ({
2320 reviewRequests: [{ login: "somebody-else" }],
2321 }));
@@ -2130,7 +2357,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2357 Effect.gen(function* () {
2358 mockedExecute.mockImplementation((call) =>
2359 Effect.succeed(
2133 - call.kind === "graphql" && call.query.includes("pullRequests(")
2360 + call.kind === "graphql" && call.operationName === "PullRequestList"
2361 ? emptyList()
2362 : emptySearch(),
2363 ),
@@ -2265,7 +2492,10 @@ layer("GitHubPullRequestApi.layer", (it) => {
2492 ({ basePermission, sourcePermission, headRef, expected, actionAllowed }) =>
2493 Effect.gen(function* () {
2494 const answer = coreResponse({
2268 - headRepository: sourcePermission === null ? null : { viewerPermission: sourcePermission },
2495 + headRepository:
2496 + sourcePermission === null
2497 + ? null
2498 + : { nameWithOwner: "acme/web", viewerPermission: sourcePermission },
2499 headRef,
2500 });
2501 answer.data.repository.viewerPermission = basePermission;
@@ -2276,19 +2506,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
2506 expect((yield* cli.getPullRequestDetail(input)).viewerAccess.canDeleteBranch).toBe(
2507 expected,
2508 );
2279 - for (const [call] of mockedExecute.mock.calls) {
2280 - if (
2281 - call.kind === "graphql" &&
2282 - !call.query.includes("query PullRequestStackMemberships")
2283 - ) {
2284 - if (call.query.includes("$headRef: String!")) {
2285 - expect(call.query).toContain("headRepository { nameWithOwner viewerPermission }");
2286 - expect(call.query).toContain("headRef { id }");
2287 - } else {
2288 - expect(call.query).toContain("headRepository { viewerPermission }");
2289 - }
2290 - }
2291 - }
2509 + expect(variablesOf("ViewerPermissions")).toHaveLength(1);
2510 + expect(variablesOf("PullRequestCore")).toHaveLength(1);
2511 }),
2512 );
2513
@@ -2310,7 +2529,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2529 });
2530 expect(detail.headRepositoryNameWithOwner).toBe("contributor/web-fork");
2531 expect(detail.viewerPermissions.actions).toContain("delete-branch");
2313 - expect(queryAt(0)).toContain("headRepository { nameWithOwner viewerPermission }");
2532 + expect(queryAt(0)).toContain("headRepository{nameWithOwner viewerPermission}");
2533 }),
2534 );
2535
@@ -2331,8 +2550,9 @@ layer("GitHubPullRequestApi.layer", (it) => {
2550 const sourceBranch = (repository: Readonly<Record<string, unknown>> = {}) => ({
2551 data: {
2552 node: {
2553 + __typename: "Repository",
2554 defaultBranchRef: { name: "main" },
2335 - ref: { target: { oid: "abc123" } },
2555 + ref: { target: { __typename: "Commit", oid: "abc123" } },
2556 ...repository,
2557 },
2558 },
@@ -2341,8 +2561,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
2561 it.effect.each(["MERGED", "CLOSED"])("deletes the exact remote fork branch of a %s PR", (state) =>
2562 Effect.gen(function* () {
2563 route(
2344 - ["query PullRequestBranchToDelete", branchToDelete({ state })],
2345 - ["query PullRequestSourceBranch", sourceBranch()],
2564 + ["PullRequestBranchToDelete", branchToDelete({ state })],
2565 + ["PullRequestSourceBranch", sourceBranch()],
2566 );
2567 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2568 yield* cli.runPullRequestAction({
@@ -2352,10 +2572,10 @@ layer("GitHubPullRequestApi.layer", (it) => {
2572 number: 7,
2573 action: "delete-branch",
2574 });
2355 - expect(variablesOf("query PullRequestBranchToDelete")).toEqual([
2575 + expect(variablesOf("PullRequestBranchToDelete")).toEqual([
2576 { owner: "acme", name: "web", number: 7 },
2577 ]);
2358 - expect(variablesOf("query PullRequestSourceBranch")).toEqual([
2578 + expect(variablesOf("PullRequestSourceBranch")).toEqual([
2579 { repositoryId: "FORK_REPO", ref: "refs/heads/feat/delete" },
2580 ]);
2581 expect(variablesOf("updateRefs(")).toEqual([
@@ -2391,15 +2611,15 @@ layer("GitHubPullRequestApi.layer", (it) => {
2611 {
2612 description: "a changed branch",
2613 head: {},
2394 - source: { ref: { target: { oid: "new-commit" } } },
2614 + source: { ref: { target: { __typename: "Commit", oid: "new-commit" } } },
2615 },
2616 { description: "an unavailable source repository", head: {}, source: null },
2617 ])("refuses to delete $description", ({ head, source }) =>
2618 Effect.gen(function* () {
2619 route(
2400 - ["query PullRequestBranchToDelete", branchToDelete(head)],
2620 + ["PullRequestBranchToDelete", branchToDelete(head)],
2621 [
2402 - "query PullRequestSourceBranch",
2622 + "PullRequestSourceBranch",
2623 source === null ? { data: { node: null } } : sourceBranch(source),
2624 ],
2625 );
@@ -2421,8 +2641,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
2641 it.effect("accepts an already deleted source branch", () =>
2642 Effect.gen(function* () {
2643 route(
2424 - ["query PullRequestBranchToDelete", branchToDelete()],
2425 - ["query PullRequestSourceBranch", sourceBranch({ ref: null })],
2644 + ["PullRequestBranchToDelete", branchToDelete()],
2645 + ["PullRequestSourceBranch", sourceBranch({ ref: null })],
2646 );
2647 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2648 yield* cli.runPullRequestAction({
@@ -2439,14 +2659,14 @@ layer("GitHubPullRequestApi.layer", (it) => {
2659 it.effect("keeps the source branch when GitHub refuses deletion", () =>
2660 Effect.gen(function* () {
2661 route(
2442 - ["query PullRequestBranchToDelete", branchToDelete()],
2443 - ["query PullRequestSourceBranch", sourceBranch()],
2662 + ["PullRequestBranchToDelete", branchToDelete()],
2663 + ["PullRequestSourceBranch", sourceBranch()],
2664 );
2665 const answer = mockedExecute.getMockImplementation()!;
2666 mockedExecute.mockImplementation((call) =>
2667 call.kind === "graphql" && call.query.includes("updateRefs(")
2668 ? Effect.fail(
2449 - new GitHubApi.GitHubApiResponseError({
2669 + new GitHubRequestPolicy.GitHubApiResponseError({
2670 host: call.host,
2671 operation: call.operation,
2672 status: 422,
@@ -2716,7 +2936,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
2936 headRefName: "feat/page",
2937 headRefOid: "abc123",
2938 isCrossRepository: false,
2719 - headRepositoryOwner: { login: "acme" },
2939 + headRepositoryOwner: { __typename: "Organization", login: "acme" },
2940 baseRefName: "main",
2941 createdAt: "2026-07-01T00:00:00Z",
2942 updatedAt: "2026-07-02T00:00:00Z",
@@ -2753,11 +2973,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
2973 });
2974
2975 // Open pull requests on this head branch, and runs scoped to this exact head.
2756 - expect(variablesOf("headRefName: $head")[0]).toEqual({
2976 + // The first page sends no cursor at all, which reads from the start.
2977 + expect(variablesOf("PullRequestHeads")[0]).toEqual({
2978 owner: "acme",
2979 name: "web",
2980 head: "feat/page",
2760 - after: null,
2981 });
2982 expect(restCallsTo("actions/runs?")[0]?.path).toBe(
2983 "repos/acme/web/actions/runs?head_sha=abc123&branch=feat%2Fpage&event=pull_request&status=action_required&per_page=100&page=1",
@@ -3054,7 +3274,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
3274 Effect.gen(function* () {
3275 mockedExecute.mockImplementation((call) =>
3276 Effect.succeed(
3057 - call.kind === "graphql" && call.query.includes("pullRequests(")
3277 + call.kind === "graphql" && call.operationName === "PullRequestList"
3278 ? emptyList()
3279 : emptySearch(),
3280 ),
@@ -3082,17 +3302,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
3302
3303 it.effect("asks a GitHub Enterprise host for its own review threads", () =>
3304 Effect.gen(function* () {
3085 - mockedExecute.mockReturnValueOnce(
3086 - Effect.succeed(
3087 - output(
3088 - encodeJson({
3089 - data: {
3090 - repository: { pullRequest: { reviewThreads: { totalCount: 0, nodes: [] } } },
3091 - },
3092 - }),
3093 - ),
3094 - ),
3095 - );
3305 + mockedExecute.mockReturnValueOnce(Effect.succeed(output(reviewThreadsPage([], null))));
3306 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3307
3308 yield* cli.listReviewThreadComments({
@@ -3476,7 +3686,9 @@ layer("GitHubPullRequestApi.layer", (it) => {
3686 output(
3687 encodeJson({
3688 data: {
3479 - nodes: [{ login: "octocat", avatarUrl: "https://avatars/octocat" }],
3689 + nodes: [
3690 + { __typename: "User", login: "octocat", avatarUrl: "https://avatars/octocat" },
3691 + ],
3692 },
3693 }),
3694 ),
@@ -3548,7 +3760,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
3760 );
3761 mockedExecute.mockReturnValueOnce(
3762 Effect.fail(
3551 - new GitHubApi.GitHubApiResponseError({
3763 + new GitHubRequestPolicy.GitHubApiResponseError({
3764 host: "github.com",
3765 operation: "getRoutingIdentity",
3766 status: 502,
@@ -3682,7 +3894,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
3894 repository: { pullRequest: { id: "PR_thisOne" } },
3895 // A comment on pull request #99 of a different repository, named as though it
3896 // belonged to #7 here.
3685 - node: { id: "IC_99", pullRequest: { id: "PR_someOtherOne" } },
3897 + node: {
3898 + __typename: "IssueComment",
3899 + id: "IC_99",
3900 + pullRequest: { id: "PR_someOtherOne" },
3901 + },
3902 },
3903 }),
3904 ),
@@ -3815,7 +4031,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
4031 encodeJson({
4032 data: {
4033 repository: { pullRequest: { id: "PR_thisOne" } },
3818 - node: { id: "IC_99", pullRequest: { id: "PR_someOtherOne" } },
4034 + node: {
4035 + __typename: "IssueComment",
4036 + id: "IC_99",
4037 + pullRequest: { id: "PR_someOtherOne" },
4038 + },
4039 },
4040 }),
4041 ),
@@ -3869,7 +4089,13 @@ layer("GitHubPullRequestApi.layer", (it) => {
4089 encodeJson(
4090 coreResponse({
4091 title: "Progressive detail",
3872 - author: { login: "octocat" },
4092 + author: {
4093 + __typename: "User",
4094 + id: "U_octocat",
4095 + login: "octocat",
4096 + name: null,
4097 + avatarUrl: "https://a/o",
4098 + },
4099 body: "Core body",
4100 changedFiles: 2,
4101 }),
@@ -3884,7 +4110,12 @@ layer("GitHubPullRequestApi.layer", (it) => {
4110 data: {
4111 repository: {
4112 pullRequest: {
3887 - author: { __typename: "User", login: "octocat", avatarUrl: "https://a/o" },
4113 + author: {
4114 + __typename: "User",
4115 + login: "octocat",
4116 + avatarUrl: "https://a/o",
4117 + name: null,
4118 + },
4119 commits: { nodes: [] },
4120 comments: { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [] },
4121 reviews: { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [] },
@@ -3934,13 +4165,14 @@ layer("GitHubPullRequestApi.layer", (it) => {
4165 baseRef: null,
4166 reviewRequests: {
4167 nodes: [
3937 - { requestedReviewer: { login: "reviewer" } },
4168 + { requestedReviewer: { __typename: "User", login: "reviewer", name: null } },
4169 {
4170 requestedReviewer: {
4171 + __typename: "Team",
4172 slug: "maintainers",
4173 combinedSlug: "octo/maintainers",
3942 - name: "Maintainers",
3943 - avatarUrl: "https://avatars.githubusercontent.com/t/1",
4174 + teamName: "Maintainers",
4175 + teamAvatarUrl: "https://avatars.githubusercontent.com/t/1",
4176 },
4177 },
4178 ],
@@ -3953,20 +4185,18 @@ layer("GitHubPullRequestApi.layer", (it) => {
4185 statusCheckRollup: {
4186 contexts: {
4187 nodes: [
3956 - {
3957 - __typename: "CheckRun",
4188 + checkRun({
4189 name: "build",
4190 status: "COMPLETED",
4191 conclusion: "SUCCESS",
4192 checkSuite: { workflowRun: { workflow: { name: "linux" } } },
3962 - },
3963 - {
3964 - __typename: "CheckRun",
4193 + }),
4194 + checkRun({
4195 name: "build",
4196 status: "COMPLETED",
4197 conclusion: "FAILURE",
4198 checkSuite: { workflowRun: { workflow: { name: "windows" } } },
3969 - },
4199 + }),
4200 ],
4201 pageInfo: { hasNextPage: false },
4202 },
@@ -4017,7 +4247,13 @@ layer("GitHubPullRequestApi.layer", (it) => {
4247 commit: {
4248 statusCheckRollup: {
4249 contexts: {
4020 - nodes: [{ name: "first", status: "COMPLETED", conclusion: "SUCCESS" }],
4250 + nodes: [
4251 + checkRun({
4252 + name: "first",
4253 + status: "COMPLETED",
4254 + conclusion: "SUCCESS",
4255 + }),
4256 + ],
4257 pageInfo: { hasNextPage: true, endCursor: "c1" },
4258 },
4259 },
@@ -4035,8 +4271,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
4271 output(
4272 checkContextsPage(
4273 [
4038 - { name: "first", status: "COMPLETED", conclusion: "SUCCESS" },
4039 - { name: "last", status: "COMPLETED", conclusion: "FAILURE" },
4274 + checkRun({ name: "first", status: "COMPLETED", conclusion: "SUCCESS" }),
4275 + checkRun({ name: "last", status: "COMPLETED", conclusion: "FAILURE" }),
4276 ],
4277 null,
4278 ),
@@ -4054,7 +4290,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
4290 expect(detail.checksState).toBe("failing");
4291 expect(detail.checksTruncated).toBe(false);
4292 // The whole rollup is walked from its start, so no check is counted twice or skipped.
4057 - expect(varsAt(1)).toMatchObject({ number: 7, after: null });
4293 + expect(varsAt(1)).toMatchObject({ number: 7 });
4294 + expect(varsAt(1)).not.toHaveProperty("after");
4295 assert.strictEqual(mockedExecute.mock.calls.length, 2);
4296 }),
4297 );
@@ -4192,8 +4429,8 @@ layer("GitHubPullRequestApi.layer", (it) => {
4429 });
4430
4431 // The first page asks from the beginning; the next carries on from where it stopped.
4195 - expect(varsAt(0)["cursor"]).toBeNull();
4196 - expect(varsAt(1)["cursor"]).toBe("Y3Vyc29yOjE");
4432 + expect(varsAt(0)["after"]).toBeNull();
4433 + expect(varsAt(1)["after"]).toBe("Y3Vyc29yOjE");
4434 expect(conversation.comments.map((comment) => comment.id)).toEqual(["c1", "c2"]);
4435 assert.isFalse(conversation.truncated);
4436 }),
@@ -4280,7 +4517,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
4517 name: "web",
4518 number: 7,
4519 threadId: "PRRT_1",
4283 - cursor: "Y3Vyc29yOjI",
4520 + after: "Y3Vyc29yOjI",
4521 });
4522 assert.strictEqual(mockedExecute.mock.calls.length, 1);
4523 expect(page.comments.map((comment) => comment.id)).toEqual(["c2", "c3"]);
@@ -4324,7 +4561,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
4561 squashMergeAllowed: false,
4562 rebaseMergeAllowed: true,
4563 viewerPermission: "READ",
4327 - pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true },
4564 + pullRequest: {
4565 + viewerCanUpdate: true,
4566 + viewerDidAuthor: true,
4567 + headRepository: null,
4568 + },
4569 },
4570 },
4571 }),
@@ -4367,7 +4608,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
4608 squashMergeAllowed: false,
4609 rebaseMergeAllowed: true,
4610 viewerPermission: "READ",
4370 - pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true },
4611 + pullRequest: {
4612 + viewerCanUpdate: true,
4613 + viewerDidAuthor: true,
4614 + headRepository: null,
4615 + },
4616 },
4617 },
4618 }),
@@ -4411,7 +4656,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
4656 squashMergeAllowed: false,
4657 rebaseMergeAllowed: true,
4658 viewerPermission: "READ",
4414 - pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true },
4659 + pullRequest: {
4660 + viewerCanUpdate: true,
4661 + viewerDidAuthor: true,
4662 + headRepository: null,
4663 + },
4664 },
4665 },
4666 }),
@@ -4431,7 +4680,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
4680 squashMergeAllowed: false,
4681 rebaseMergeAllowed: true,
4682 viewerPermission: "READ",
4434 - pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true },
4683 + pullRequest: {
4684 + viewerCanUpdate: true,
4685 + viewerDidAuthor: true,
4686 + headRepository: null,
4687 + },
4688 },
4689 },
4690 }),
@@ -4526,11 +4779,26 @@ layer("GitHubPullRequestApi.layer", (it) => {
4779 repository: {
4780 assignableUsers: {
4781 pageInfo: { hasNextPage: false },
4529 - nodes: [{ login: "bilal" }, { login: "octocat" }, { login: "hubot" }],
4782 + nodes: ["bilal", "octocat", "hubot"].map((login) => ({
4783 + login,
4784 + name: null,
4785 + avatarUrl: `https://avatars/${login}`,
4786 + })),
4787 },
4788 pullRequest: {
4532 - author: { login: "bilal" },
4533 - reviewRequests: { nodes: [{ requestedReviewer: { login: "octocat" } }] },
4789 + author: { __typename: "User", login: "bilal" },
4790 + reviewRequests: {
4791 + nodes: [
4792 + {
4793 + requestedReviewer: {
4794 + __typename: "User",
4795 + login: "octocat",
4796 + name: null,
4797 + avatarUrl: "https://avatars/octocat",
4798 + },
4799 + },
4800 + ],
4801 + },
4802 },
4803 },
4804 },
@@ -4646,7 +4914,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
4914 assert.strictEqual(mockedExecute.mock.calls.length, 3);
4915 // The first page asks from the start; each one after it carries the cursor before it.
4916 expect([varsAt(0)["after"], varsAt(1)["after"], varsAt(2)["after"]]).toEqual([
4649 - null,
4917 + undefined,
4918 "cursor-0",
4919 "cursor-1",
4920 ]);
@@ -4721,12 +4989,16 @@ layer("GitHubPullRequestApi.layer", (it) => {
4989
4990 // One request to learn the pull request's node id, one for every press together.
4991 assert.strictEqual(mockedExecute.mock.calls.length, 2);
4724 - expect(queryAt(1)).toContain("f0: markFileAsViewed");
4725 - expect(queryAt(1)).toContain("f1: unmarkFileAsViewed");
4992 + expect(queryAt(1)).toContain("_0_markFileAsViewed:markFileAsViewed(");
4993 + expect(queryAt(1)).toContain("_1_unmarkFileAsViewed:unmarkFileAsViewed(");
4994 + // Each path travels as a variable, so none can be read as part of the document.
4995 expect(varsAt(1)).toEqual({
4727 - pullRequestId: "PR_1",
4728 - f0_path: "src/a.ts",
4729 - f1_path: "src/b.ts",
4996 + _0_pullRequestId: "PR_1",
4997 + _0_path: "src/a.ts",
4998 + _0_viewed: true,
4999 + _1_pullRequestId: "PR_1",
5000 + _1_path: "src/b.ts",
5001 + _1_viewed: false,
5002 });
5003 }),
5004 );
@@ -4772,11 +5044,11 @@ layer("GitHubPullRequestApi.layer", (it) => {
5044 // One lookup, then a mutation per write, every one of them addressed by the id it answered.
5045 assert.strictEqual(mockedExecute.mock.calls.length, 4);
5046 expect(varsAt(0)).toEqual({ owner: "acme", name: "web", number: 24 });
4775 - expect([1, 2, 3].map((index) => varsAt(index)["pullRequestId"])).toEqual([
4776 - "PR_24",
4777 - "PR_24",
4778 - "PR_24",
4779 - ]);
5047 + expect(
5048 + [1, 2, 3].map(
5049 + (index) => varsAt(index)["pullRequestId"] ?? varsAt(index)["_0_pullRequestId"],
5050 + ),
5051 + ).toEqual(["PR_24", "PR_24", "PR_24"]);
5052 }),
5053 );
5054
@@ -4806,7 +5078,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
5078 yield* write();
5079
5080 assert.strictEqual(mockedExecute.mock.calls.length, 3);
4809 - expect(varsAt(2)["pullRequestId"]).toEqual("PR_25");
5081 + expect(varsAt(2)["_0_pullRequestId"]).toEqual("PR_25");
5082 }),
5083 );
5084 it.effect("keeps the pull request being ticked through, not the one looked up first", () =>
@@ -4818,7 +5090,7 @@ layer("GitHubPullRequestApi.layer", (it) => {
5090 const HOT = 9_000;
5091 const lookupsOf = new Map<number, number>();
5092 mockedExecute.mockImplementation((input) => {
4821 - if (input.kind !== "graphql" || !input.query.includes(NODE_ID_QUERY)) {
5093 + if (input.kind !== "graphql" || input.operationName !== NODE_ID_QUERY) {
5094 return Effect.succeed(output("{}"));
5095 }
5096 const number = Number(input.variables?.["number"]);
packages/source-control-github/src/server/GitHubPullRequestApi.ts
+698 -864
@@ -1,20 +1,20 @@
1 import { removeAgentCredits } from "@t3tools/source-control-core/server/mergeMessage";
2 import { KnownWorkflowRuns, makeChecksRevalidator } from "./gitHubConditionalChecks.ts";
3 import { runGitHubStackAction, type GitHubStackActionError } from "./githubStackActions.ts";
4 -import * as Cause from "effect/Cause";
4 import * as Context from "effect/Context";
5 import * as Clock from "effect/Clock";
6 import * as Duration from "effect/Duration";
7 import * as Effect from "effect/Effect";
8 import * as FileSystem from "effect/FileSystem";
9 import * as Layer from "effect/Layer";
11 -import * as Exit from "effect/Exit";
10 import * as Option from "effect/Option";
13 -import * as Request from "effect/Request";
11 +import { GraphQLClient, GraphQLClientError, GraphQLGroup, GraphQLResolver } from "effect/graphql";
12 +import { HttpClient } from "effect/http";
13 import * as RequestResolver from "effect/RequestResolver";
14 import * as Result from "effect/Result";
15 import * as Schema from "effect/Schema";
16 import * as Semaphore from "effect/Semaphore";
17 +import * as Stream from "effect/Stream";
18 import {
19 resolvePullRequestAuthorFilter,
20 PositiveInt,
@@ -42,78 +42,52 @@ import {
42 type PullRequestPreview,
43 } from "@t3tools/contracts";
44
45 -import * as GitHubApi from "./GitHubApi.ts";
46 -import { readGraphQlPages } from "./githubGraphQl.ts";
45 +import * as GitHubRest from "./GitHubRest.ts";
46 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
47 +import * as GitHubGraphQlClient from "./gitHubGraphQlClient.ts";
48 +import { PullRequestBatchesGraphQLGroup } from "./pullRequestBatches.graphql.ts";
49 +import { PullRequestMutationsGraphQLGroup } from "./pullRequestMutations.graphql.ts";
50 +import { PullRequestReadsGraphQLGroup } from "./pullRequestReads.graphql.ts";
51 +import { PullRequestReviewsGraphQLGroup } from "./pullRequestReviews.graphql.ts";
52 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
53 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
54 import {
50 - ACTOR_AVATARS_GRAPHQL_QUERY,
51 - ADD_REACTION_GRAPHQL_MUTATION,
55 buildReviewSubmission,
56 buildReviewerRequest,
54 - buildSetFilesViewedGraphQlMutation,
55 - decodeActorAvatarsJson,
56 - decodePullRequestActivityJson,
57 - decodePullRequestCheckContextsJson,
58 - decodePullRequestCoreJson,
57 decodeCommitFilesJson,
60 - pullRequestCheckContextsGraphQlQuery,
58 pullRequestChecksFromContexts,
62 - pullRequestListGraphQlQuery,
63 - pullRequestSummaryGraphQlQuery,
64 - PULL_REQUEST_ACTIVITY_GRAPHQL_QUERY,
65 - PULL_REQUEST_HEADS_GRAPHQL_QUERY,
59 decodeWorkflowRunsJson,
67 - pullRequestCoreGraphQlQuery,
60 type GitHubPullRequestCore,
69 - type GitHubPullRequestSummary,
61 type GitHubPullRequestWatchFingerprint,
71 - decodePullRequestPreviewJson,
72 - PULL_REQUEST_PREVIEW_GRAPHQL_QUERY,
62 + isSubjectOfPullRequest,
63 + LenientPullRequestList,
64 + LenientPullRequestSearch,
65 + pageRows,
66 + pullRequestLookup,
67 + toActorAvatars,
68 + toLabelCandidates,
69 + toPullRequestActivityPage,
70 + toPullRequestCheckContextsPage,
71 + toPullRequestCore,
72 + toPullRequestFilesViewedPage,
73 + toPullRequestHeads,
74 + toPullRequestNodeId,
75 + toPullRequestPreview,
76 + toPullRequestRows,
77 + toPullRequestSummary,
78 + toPullRequestWatchFingerprint,
79 + toReviewDismissalsPage,
80 + toReviewerCandidates,
81 + toReviewThreadCommentsPage,
82 + toReviewThreadPage,
83 + toStackMembership,
84 + toViewerPermissions,
85 decodePullRequestFilesJson,
74 - decodePullRequestFilesViewedJson,
75 - decodePullRequestHeadsJson,
76 - decodePullRequestListJson,
77 - decodePullRequestNodeIdJson,
78 - decodePullRequestSearchJson,
86 decodePullRequestStacksJson,
80 - decodePullRequestStatsJson,
81 - decodePullRequestSummariesJson,
82 - decodePullRequestWatchFingerprintsJson,
83 - decodeReactionSubjectScopeJson,
84 - decodeReviewerCandidatesJson,
85 - decodeLabelCandidatesJson,
87 buildLabelRequest,
87 - LABEL_CANDIDATES_GRAPHQL_QUERY,
88 - decodeReviewDismissalsJson,
89 - decodeReviewThreadCommentsJson,
90 - decodeReviewThreadsJson,
91 - buildPullRequestStatsGraphQlQuery,
92 - buildPullRequestSummariesGraphQlQuery,
93 - buildPullRequestWatchFingerprintsGraphQlQuery,
94 - buildPullRequestStackMembershipsGraphQlQuery,
95 - decodePullRequestStackMembershipsJson,
96 - pullRequestSearchGraphQlQuery,
88 PULL_REQUEST_SEARCH_MAX_ROWS,
98 - PULL_REQUEST_FILES_VIEWED_GRAPHQL_QUERY,
99 - PULL_REQUEST_NODE_ID_GRAPHQL_QUERY,
100 - REACTION_SUBJECT_PULL_REQUEST_GRAPHQL_QUERY,
101 - REMOVE_REACTION_GRAPHQL_MUTATION,
102 - REVERT_PULL_REQUEST_GRAPHQL_MUTATION,
89 gitHubReactionContent,
104 - RESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION,
105 - REVIEWER_CANDIDATES_GRAPHQL_QUERY,
106 - REVIEW_THREAD_COMMENTS_GRAPHQL_QUERY,
107 - REVIEW_DISMISSALS_GRAPHQL_QUERY,
108 - REVIEW_THREAD_REPLY_GRAPHQL_MUTATION,
109 - REVIEW_THREADS_GRAPHQL_QUERY,
90 reviewThreadConversation,
111 - UNRESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION,
112 - UPDATE_ISSUE_COMMENT_GRAPHQL_MUTATION,
113 - UPDATE_PULL_REQUEST_GRAPHQL_MUTATION,
114 - UPDATE_REVIEW_COMMENT_GRAPHQL_MUTATION,
115 - VIEWER_PERMISSIONS_GRAPHQL_QUERY,
116 - decodeViewerPermissionsJson,
91 type GitHubPullRequestActivity,
92 type GitHubPullRequestActivityPage,
93 type GitHubWorkflowRunPage,
@@ -343,7 +317,7 @@ export class GitHubBranchDeletionRefusedError extends Schema.TaggedError<GitHubB
317 export type GitHubPullRequestApiError =
318 | GitHubBranchDeletionRefusedError
319 | GitHubStackActionError
346 - | GitHubApi.GitHubApiError
320 + | GitHubRequestPolicy.GitHubApiError
321 | GitHubPullRequestReadError
322 | GitHubDiffCursorError
323 | GitHubDiffCommitError
@@ -358,6 +332,11 @@ export type GitHubPullRequestApiError =
332 | GitHubViewerLoginUnavailableError
333 | GitHubPullRequestUpdatedAtUnavailableError;
334
335 +const isGraphQlClientError = (error: unknown): error is GraphQLClientError.GraphQLClientError =>
336 + GraphQLClientError.isGraphQLClientError(error);
337 +
338 +const { isNotFoundOnly } = GitHubGraphQlClient;
339 +
340 /** A large pull request can produce a multi-megabyte patch; past this it is truncated. */
341 const DIFF_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
342 const DIFF_TIMEOUT = Duration.seconds(60);
@@ -391,6 +370,8 @@ const DIFF_FILES_PAGE_SIZE = 100;
370 * hundred files: beyond this the read stops and says it was cut short.
371 */
372 const FILES_VIEWED_MAX_PAGES = 5;
373 +/** Files cleared or restored per request; a reader rarely ticks more than a page of them at once. */
374 +const FILES_VIEWED_PER_REQUEST = 100;
375
376 /**
377 * How many pull requests' node ids are remembered at once. A long-lived server sees far more of
@@ -424,11 +405,10 @@ export interface GitHubPullRequestStat {
405 }
406
407 /**
427 - * Aliased lookups per request, and requests at once. Measured over a hundred rows: one request
428 - * carrying all hundred takes ~5.2s, four of twenty-five in parallel ~2.1s.
408 + * Aliased lookups per request. Measured over a hundred rows: one request carrying all hundred
409 + * takes ~5.2s, four of twenty-five in parallel ~2.1s. `GitHubRequestPolicy` bounds how many run at once.
410 */
411 const STAT_ALIASES_PER_REQUEST = 25;
431 -const STAT_REQUEST_CONCURRENCY = 4;
412 /**
413 * How long a summary read waits for company. The background sync asks for every linked pull
414 * request at once, and each read reaches the resolver after its own cache check, so a batch
@@ -436,28 +416,6 @@ const STAT_REQUEST_CONCURRENCY = 4;
416 */
417 const SUMMARY_BATCH_WINDOW = "10 millis";
418
439 -class PullRequestSummaryRead extends Request.Class<
440 - {
441 - readonly cwd: string;
442 - readonly repository: string;
443 - readonly host: string;
444 - readonly number: number;
445 - },
446 - ProviderChangeRequestSummary,
447 - GitHubPullRequestApiError
448 -> {}
449 -
450 -class PullRequestWatchFingerprintRead extends Request.Class<
451 - {
452 - readonly cwd: string;
453 - readonly repository: string;
454 - readonly host: string;
455 - readonly number: number;
456 - },
457 - GitHubPullRequestWatchFingerprint | null,
458 - GitHubPullRequestApiError
459 -> {}
460 -
419 export interface GitHubPullRequestSearchBatch {
420 /** Rows across every repository asked for, newest update first, each naming its own. */
421 readonly items: ReadonlyArray<GitHubPullRequestSearchItem>;
@@ -1007,17 +965,6 @@ function searchQuery(input: {
965 ].join(" ");
966 }
967
1010 -const MERGE_MESSAGE_GRAPHQL_QUERY = `
1011 -query PullRequestMergeMessage($owner: String!, $name: String!, $number: Int!, $method: PullRequestMergeMethod!) {
1012 - repository(owner: $owner, name: $name) {
1013 - pullRequest(number: $number) {
1014 - isMergeQueueEnabled
1015 - headRefOid
1016 - viewerMergeBodyText(mergeType: $method)
1017 - }
1018 - }
1019 -}`;
1020 -
968 /** The two revisions a file is expanded between: a pull request's base and head, or a commit's parent and itself. */
969 const decodeRevisionRefs = Schema.decodeUnknownOption(
970 Schema.fromJsonString(
@@ -1030,165 +977,29 @@ const decodeRevisionRefs = Schema.decodeUnknownOption(
977 ),
978 );
979
1033 -const decodeMergeMessageResponse = Schema.decodeUnknownResult(
1034 - Schema.fromJsonString(
1035 - Schema.Struct({
1036 - data: Schema.Struct({
1037 - repository: Schema.Struct({
1038 - pullRequest: Schema.Struct({
1039 - isMergeQueueEnabled: Schema.Boolean,
1040 - headRefOid: Schema.String,
1041 - viewerMergeBodyText: Schema.String,
1042 - }),
1043 - }),
1044 - }),
1045 - }),
1046 - ),
1047 -);
1048 -const decodeMergeMessage = (raw: string) =>
1049 - Result.map(decodeMergeMessageResponse(raw), (response) => response.data.repository.pullRequest);
1050 -
1051 -/** What `gh pr merge` and `gh pr update-branch` read before they act. */
1052 -const ACTION_STATE_GRAPHQL_QUERY = `
1053 -query PullRequestActionState($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
1054 - repository(owner: $owner, name: $name) {
1055 - pullRequest(number: $number) {
1056 - id
1057 - headRefOid
1058 - isMergeQueueEnabled
1059 - mergeStateStatus
1060 - baseRef { compare(headRef: $headRef) { behindBy } }
1061 - }
1062 - }
1063 -}`;
1064 -
1065 -const decodeActionStateResponse = Schema.decodeUnknownResult(
1066 - Schema.fromJsonString(
1067 - Schema.Struct({
1068 - data: Schema.Struct({
1069 - repository: Schema.Struct({
1070 - pullRequest: Schema.Struct({
1071 - id: Schema.String,
1072 - headRefOid: Schema.String,
1073 - isMergeQueueEnabled: Schema.optional(Schema.Boolean),
1074 - mergeStateStatus: Schema.optional(Schema.NullOr(Schema.String)),
1075 - baseRef: Schema.optional(
1076 - Schema.NullOr(
1077 - Schema.Struct({ compare: Schema.NullOr(Schema.Struct({ behindBy: Schema.Int })) }),
1078 - ),
1079 - ),
1080 - }),
1081 - }),
1082 - }),
1083 - }),
1084 - ),
1085 -);
1086 -const decodeActionState = (raw: string) =>
1087 - Result.map(decodeActionStateResponse(raw), (response) => response.data.repository.pullRequest);
1088 -
1089 -const MERGE_PULL_REQUEST_GRAPHQL_MUTATION = `mutation($input: MergePullRequestInput!) {
1090 - mergePullRequest(input: $input) { clientMutationId }
1091 -}`;
1092 -const ENABLE_AUTO_MERGE_GRAPHQL_MUTATION = `mutation($input: EnablePullRequestAutoMergeInput!) {
1093 - enablePullRequestAutoMerge(input: $input) { clientMutationId }
1094 -}`;
1095 -
1096 -const BRANCH_TO_DELETE_GRAPHQL_QUERY = `query PullRequestBranchToDelete($owner: String!, $name: String!, $number: Int!) {
1097 - repository(owner: $owner, name: $name) {
1098 - pullRequest(number: $number) {
1099 - state
1100 - headRefName
1101 - baseRefName
1102 - headRefOid
1103 - headRepository { id }
1104 - }
1105 - }
1106 -}`;
1107 -const decodeBranchToDelete = Schema.decodeUnknownResult(
1108 - Schema.fromJsonString(
1109 - Schema.Struct({
1110 - data: Schema.Struct({
1111 - repository: Schema.Struct({
1112 - pullRequest: Schema.Struct({
1113 - state: Schema.Literals(["OPEN", "CLOSED", "MERGED"]),
1114 - headRefName: Schema.String,
1115 - baseRefName: Schema.String,
1116 - headRefOid: Schema.String,
1117 - headRepository: Schema.NullOr(Schema.Struct({ id: Schema.String })),
1118 - }),
1119 - }),
1120 - }),
1121 - }),
1122 - ),
1123 -);
1124 -const SOURCE_BRANCH_GRAPHQL_QUERY = `query PullRequestSourceBranch($repositoryId: ID!, $ref: String!) {
1125 - node(id: $repositoryId) {
1126 - ... on Repository {
1127 - defaultBranchRef { name }
1128 - ref(qualifiedName: $ref) { target { oid } }
1129 - }
1130 - }
1131 -}`;
1132 -const decodeSourceBranch = Schema.decodeUnknownResult(
1133 - Schema.fromJsonString(
1134 - Schema.Struct({
1135 - data: Schema.Struct({
1136 - node: Schema.NullOr(
1137 - Schema.Struct({
1138 - defaultBranchRef: Schema.NullOr(Schema.Struct({ name: Schema.String })),
1139 - ref: Schema.NullOr(Schema.Struct({ target: Schema.Struct({ oid: Schema.String }) })),
1140 - }),
1141 - ),
1142 - }),
1143 - }),
1144 - ),
1145 -);
1146 -const DELETE_BRANCH_GRAPHQL_MUTATION = `mutation($input: UpdateRefsInput!) {
1147 - updateRefs(input: $input) { clientMutationId }
1148 -}`;
1149 -const DISABLE_AUTO_MERGE_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1150 - disablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId }) { clientMutationId }
1151 -}`;
1152 -const UPDATE_BRANCH_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!, $expectedHeadOid: GitObjectID!, $updateMethod: PullRequestBranchUpdateMethod!) {
1153 - updatePullRequestBranch(input: { pullRequestId: $pullRequestId, expectedHeadOid: $expectedHeadOid, updateMethod: $updateMethod }) { clientMutationId }
1154 -}`;
1155 -const READY_FOR_REVIEW_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1156 - markPullRequestReadyForReview(input: { pullRequestId: $pullRequestId }) { clientMutationId }
1157 -}`;
1158 -const CONVERT_TO_DRAFT_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1159 - convertPullRequestToDraft(input: { pullRequestId: $pullRequestId }) { clientMutationId }
1160 -}`;
1161 -const CLOSE_PULL_REQUEST_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1162 - closePullRequest(input: { pullRequestId: $pullRequestId }) { clientMutationId }
1163 -}`;
1164 -const REOPEN_PULL_REQUEST_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1165 - reopenPullRequest(input: { pullRequestId: $pullRequestId }) { clientMutationId }
1166 -}`;
1167 -const ADD_COMMENT_GRAPHQL_MUTATION = `mutation($subjectId: ID!, $body: String!) {
1168 - addComment(input: { subjectId: $subjectId, body: $body }) { clientMutationId }
1169 -}`;
1170 -
980 const GRAPHQL_MERGE_METHODS = {
981 merge: "MERGE",
982 squash: "SQUASH",
983 rebase: "REBASE",
984 } as const satisfies Record<PullRequestMergeMethod, string>;
985
986 +/** Every GraphQL read and write this module makes, through GitHub's auth and rate limits. */
987 +const PullRequestGraphQLGroup = GraphQLGroup.merge(
988 + PullRequestBatchesGraphQLGroup,
989 + GraphQLGroup.make(LenientPullRequestSearch, LenientPullRequestList),
990 + PullRequestReadsGraphQLGroup,
991 + PullRequestReviewsGraphQLGroup,
992 + PullRequestMutationsGraphQLGroup,
993 +).middleware(GitHubGraphQlClient.GitHubGraphQlAuth);
994 +
995 /** States in which `gh pr merge --auto` merges at once instead of arming auto-merge. */
996 const IMMEDIATELY_MERGEABLE = new Set(["CLEAN", "HAS_HOOKS", "UNSTABLE"]);
997
1180 -/** The mutations that only need the pull request's node id. */
1181 -const SIMPLE_ACTION_MUTATIONS = {
1182 - "disable-auto-merge": DISABLE_AUTO_MERGE_GRAPHQL_MUTATION,
1183 - ready: READY_FOR_REVIEW_GRAPHQL_MUTATION,
1184 - draft: CONVERT_TO_DRAFT_GRAPHQL_MUTATION,
1185 - close: CLOSE_PULL_REQUEST_GRAPHQL_MUTATION,
1186 - reopen: REOPEN_PULL_REQUEST_GRAPHQL_MUTATION,
1187 -} as const satisfies Partial<Record<PullRequestAction, string>>;
1188 -
998 /** @public Service construction is part of the canonical Effect module API. */
999 export const make = Effect.gen(function* () {
1191 - const api = yield* GitHubApi.GitHubApi;
1000 + const api = yield* GitHubRest.GitHubRest;
1001 + const policy = yield* GitHubRequestPolicy.GitHubRequestPolicy;
1002 + const httpClient = yield* HttpClient.HttpClient;
1003 const sourceControlHost = yield* SourceControlHost.SourceControlHost;
1004 const fileSystem = yield* FileSystem.FileSystem;
1005 const revalidateChecks = yield* makeChecksRevalidator;
@@ -1235,7 +1046,7 @@ export const make = Effect.gen(function* () {
1046 const response = yield* api
1047 .rest({ host, operation: "getRoutingIdentity", path: "user", allowReserve: true })
1048 .pipe(
1238 - Effect.provideService(GitHubApi.PinnedGitHubCredential, credential),
1049 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, credential),
1050 Effect.provideService(SourceControlRateLimit.CredentialScope, key),
1051 );
1052 const identity = yield* decodeRoutingIdentity(response.body).pipe(
@@ -1264,7 +1075,7 @@ export const make = Effect.gen(function* () {
1075 Effect.flatMap(({ host, token, accountId, viewer, credentialFingerprint }) =>
1076 use({ accountId, viewer, credentialFingerprint }).pipe(
1077 Effect.provideService(SourceControlRateLimit.CredentialScope, credentialFingerprint),
1267 - Effect.provideService(GitHubApi.PinnedGitHubCredential, {
1078 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, {
1079 host,
1080 token,
1081 credentialFingerprint,
@@ -1277,6 +1088,103 @@ export const make = Effect.gen(function* () {
1088 Effect.map(({ accountId, viewer }) => ({ accountId, viewer })),
1089 );
1090
1091 + const client = yield* GraphQLClient.make(PullRequestGraphQLGroup).pipe(
1092 + Effect.provide(GitHubGraphQlClient.layer),
1093 + );
1094 +
1095 + const readError = (cwd: string, operation: string, cause: unknown) =>
1096 + new GitHubPullRequestReadError({ cwd, operation, cause });
1097 +
1098 + /**
1099 + * Runs one generated GraphQL call against `host`, reported as `operation`. GitHub's `errors`
1100 + * fail it as a not found, or a response error with GitHub's messages; an answer that does not
1101 + * decode is a read error against `operation`.
1102 + */
1103 + const graphql =
1104 + (input: {
1105 + readonly cwd: string;
1106 + readonly host: string;
1107 + readonly operation: string;
1108 + readonly allowReserve?: boolean | undefined;
1109 + }) =>
1110 + <A, E, R>(
1111 + effect: Effect.Effect<A, E, R>,
1112 + ): Effect.Effect<
1113 + A,
1114 + | Exclude<E, GraphQLClientError.GraphQLClientError>
1115 + | GitHubRequestPolicy.GitHubApiNotFoundError
1116 + | GitHubRequestPolicy.GitHubApiResponseError
1117 + | GitHubPullRequestReadError,
1118 + Exclude<R, GitHubGraphQlClient.GitHubGraphQlTarget>
1119 + > =>
1120 + effect.pipe(
1121 + GitHubGraphQlClient.call({
1122 + host: input.host,
1123 + operation: input.operation,
1124 + ...(input.allowReserve === true ? { allowReserve: true } : {}),
1125 + }),
1126 + Effect.mapError((error) =>
1127 + isGraphQlClientError(error)
1128 + ? readError(input.cwd, input.operation, error)
1129 + : (error as Exclude<typeof error, GraphQLClientError.GraphQLClientError>),
1130 + ),
1131 + );
1132 +
1133 + /** Fails a read GitHub answered with nothing for the pull request it was asked about. */
1134 + const found =
1135 + (input: { readonly host: string; readonly operation: string }) =>
1136 + <A>(value: A | null): Effect.Effect<A, GitHubRequestPolicy.GitHubApiNotFoundError> =>
1137 + value === null
1138 + ? Effect.fail(
1139 + new GitHubRequestPolicy.GitHubApiNotFoundError({
1140 + host: GitHubRequestPolicy.normalizeHost(input.host),
1141 + operation: input.operation,
1142 + }),
1143 + )
1144 + : Effect.succeed(value);
1145 +
1146 + /**
1147 + * The pages of a cursor connection, read one after another until GitHub has no more,
1148 + * `maxPages` have been read, or `until` is satisfied. `truncated` says pages remained when
1149 + * reading stopped; a cursor GitHub hands back a second time stops the read as truncated too.
1150 + */
1151 + const readPages = <Page, E, R>(
1152 + stream: Stream.Stream<Page, E | GraphQLClientError.GraphQLClientError, R>,
1153 + options: {
1154 + readonly cwd: string;
1155 + readonly operation: string;
1156 + readonly hasNextPage: (page: NoInfer<Page>) => boolean;
1157 + readonly maxPages?: number;
1158 + readonly until?: (pages: ReadonlyArray<NoInfer<Page>>) => boolean;
1159 + },
1160 + ) =>
1161 + Effect.gen(function* () {
1162 + const pages: Page[] = [];
1163 + let repeated = false;
1164 + yield* stream.pipe(
1165 + // `pages` fails a cursor GitHub hands back unchanged, which would page forever.
1166 + Stream.catch((error) =>
1167 + isGraphQlClientError(error) && error.reason._tag === "PaginationError"
1168 + ? Stream.sync(() => {
1169 + repeated = true;
1170 + }).pipe(Stream.drain)
1171 + : Stream.fail(error),
1172 + ),
1173 + Stream.runForEachWhile((page) =>
1174 + Effect.sync(() => {
1175 + pages.push(page);
1176 + return (
1177 + options.hasNextPage(page) &&
1178 + pages.length < (options.maxPages ?? Infinity) &&
1179 + options.until?.(pages) !== true
1180 + );
1181 + }),
1182 + ),
1183 + );
1184 + const last = pages.at(-1);
1185 + return { pages, truncated: repeated || (last !== undefined && options.hasNextPage(last)) };
1186 + });
1187 +
1188 /**
1189 * The pull request's own node id, which is what a mutation against the pull request itself is
1190 * addressed by: a reaction on its description, or a rewrite of its words.
@@ -1304,15 +1212,10 @@ export const make = Effect.gen(function* () {
1212 nodeIds.set(key, held);
1213 return Effect.succeed(held);
1214 }
1307 - return graphqlRead({
1308 - cwd: input.cwd,
1309 - host: input.host,
1310 - operation: input.operation,
1311 - allowReserve: true,
1312 - variables: { owner, name, number: input.number },
1313 - query: PULL_REQUEST_NODE_ID_GRAPHQL_QUERY,
1314 - decode: decodePullRequestNodeIdJson,
1315 - }).pipe(
1215 + return client.PullRequestNodeId({ owner, name, number: input.number }).pipe(
1216 + graphql({ ...input, allowReserve: true }),
1217 + Effect.map(toPullRequestNodeId),
1218 + Effect.flatMap(found(input)),
1219 Effect.tap((nodeId) =>
1220 Effect.sync(() => {
1221 if (nodeIds.size >= NODE_ID_CACHE_CAPACITY) {
@@ -1340,28 +1243,11 @@ export const make = Effect.gen(function* () {
1243 readonly operation: string;
1244 }) => {
1245 const { owner, name } = parseRepositorySelector(input.repository);
1343 - return graphqlRead({
1344 - cwd: input.cwd,
1345 - host: input.host,
1346 - operation: input.operation,
1347 - allowReserve: true,
1348 - variables: { owner, name, number: input.number, subjectId: input.subjectId },
1349 - query: REACTION_SUBJECT_PULL_REQUEST_GRAPHQL_QUERY,
1350 - decode: decodeReactionSubjectScopeJson,
1351 - });
1246 + return client
1247 + .PullRequestSubject({ owner, name, number: input.number, subjectId: input.subjectId })
1248 + .pipe(graphql({ ...input, allowReserve: true }), Effect.map(isSubjectOfPullRequest));
1249 };
1250
1354 - /** A GraphQL mutation whose answer is not read back; a GraphQL error fails it. */
1355 - const graphql = (input: {
1356 - readonly host: string;
1357 - readonly operation: string;
1358 - readonly query: string;
1359 - readonly variables: Readonly<Record<string, unknown>>;
1360 - }) => api.graphql(input).pipe(Effect.asVoid);
1361 -
1362 - const readError = (cwd: string, operation: string, cause: unknown) =>
1363 - new GitHubPullRequestReadError({ cwd, operation, cause });
1364 -
1251 /** Decodes an answer, reporting a failure against the read that made it. */
1252 const decodeWith = <A>(
1253 cwd: string,
@@ -1375,26 +1261,6 @@ export const make = Effect.gen(function* () {
1261 : Effect.fail(readError(cwd, operation, decoded.failure));
1262 };
1263
1378 - /** A GraphQL read whose answer is decoded, reporting a failure against the read that made it. */
1379 - const graphqlRead = <A>(input: {
1380 - readonly cwd: string;
1381 - readonly host: string;
1382 - readonly operation: string;
1383 - readonly allowReserve?: boolean | undefined;
1384 - readonly variables?: Readonly<Record<string, unknown>>;
1385 - readonly query: string;
1386 - readonly decode: (raw: string) => Result.Result<A, unknown>;
1387 - }): Effect.Effect<A, GitHubPullRequestApiError> =>
1388 - api
1389 - .graphql({
1390 - host: input.host,
1391 - operation: input.operation,
1392 - query: input.query,
1393 - ...(input.variables === undefined ? {} : { variables: input.variables }),
1394 - ...(input.allowReserve === true ? { allowReserve: true } : {}),
1395 - })
1396 - .pipe(Effect.flatMap((raw) => decodeWith(input.cwd, input.operation, input.decode, raw)));
1397 -
1264 /** A REST read whose JSON answer is decoded the same way. */
1265 const restRead = <A>(input: {
1266 readonly cwd: string;
@@ -1562,45 +1428,55 @@ export const make = Effect.gen(function* () {
1428 return { oldContents, newContents };
1429 });
1430
1431 + /** `isRequired` is asked for on github.com only: an older Enterprise server may not know it. */
1432 + const asksRequired = (host: string) => host.toLowerCase() === "github.com";
1433 +
1434 /**
1435 * Every check context of the head commit, a page at a time, for a rollup the detail read cut at
1436 * its first hundred. Each page names the head it read, so a push mid-walk fails rather than
1437 * mixing two revisions' checks.
1438 */
1570 - type CheckContextsPage = Result.Result.Success<
1571 - ReturnType<typeof decodePullRequestCheckContextsJson>
1572 - >;
1439 const readAllCheckContexts = (
1440 input: Parameters<GitHubPullRequestApi["Service"]["getPullRequestDetail"]>[0],
1441 allowReserve: boolean,
1442 ) =>
1443 Effect.gen(function* () {
1444 const { owner, name } = parseRepositorySelector(input.repository);
1579 - const { pages, truncated } = yield* readGraphQlPages(
1580 - (after, previous: ReadonlyArray<CheckContextsPage>) =>
1581 - graphqlRead({
1582 - cwd: input.cwd,
1583 - host: input.host,
1584 - operation: "getPullRequestDetail",
1585 - allowReserve,
1586 - variables: { owner, name, number: input.number, after },
1587 - query: pullRequestCheckContextsGraphQlQuery(input.host),
1588 - decode: decodePullRequestCheckContextsJson,
1589 - }).pipe(
1590 - // Each page names the head it read, so a push mid-walk fails rather than mixing
1591 - // two revisions' checks.
1592 - Effect.filterOrFail(
1593 - (page) => previous.length === 0 || page.headSha === previous[0]!.headSha,
1594 - () =>
1595 - readError(
1596 - input.cwd,
1597 - "getPullRequestDetail",
1598 - new Error("Pull request head changed while reading checks."),
1599 - ),
1600 - ),
1445 + const target = { ...input, operation: "getPullRequestDetail", allowReserve };
1446 + let headSha: string | null = null;
1447 + const { pages, truncated } = yield* readPages(
1448 + GraphQLClient.pages(client.PullRequestCheckContexts, {
1449 + variables: { owner, name, number: input.number, required: asksRequired(input.host) },
1450 + connection: (result) => {
1451 + const page = toPullRequestCheckContextsPage(result);
1452 + if (page === null) return null;
1453 + headSha ??= page.headSha;
1454 + return {
1455 + ...page,
1456 + // Past the first page a different head is a push mid-walk.
1457 + changed: page.headSha !== headSha,
1458 + pageInfo: { hasNextPage: page.nextCursor !== null, endCursor: page.nextCursor },
1459 + };
1460 + },
1461 + }).pipe(
1462 + Stream.mapEffect((page) =>
1463 + page.changed
1464 + ? Effect.fail(
1465 + readError(
1466 + input.cwd,
1467 + "getPullRequestDetail",
1468 + new Error("Pull request head changed while reading checks."),
1469 + ),
1470 + )
1471 + : Effect.succeed(page),
1472 ),
1602 - { maxPages: CHECK_CONTEXT_PAGES, nextCursor: (page) => page.nextCursor },
1603 - );
1473 + ),
1474 + {
1475 + ...target,
1476 + maxPages: CHECK_CONTEXT_PAGES,
1477 + hasNextPage: (page) => page.nextCursor !== null,
1478 + },
1479 + ).pipe(graphql(target));
1480 return {
1481 headSha: pages[0]?.headSha ?? null,
1482 contexts: pages.flatMap((page) => page.contexts),
@@ -1610,45 +1486,44 @@ export const make = Effect.gen(function* () {
1486
1487 const getPullRequestDetail: GitHubPullRequestApi["Service"]["getPullRequestDetail"] = (input) => {
1488 const { owner, name } = parseRepositorySelector(input.repository);
1489 + const operation = "getPullRequestDetail";
1490 return SourceControlRateLimit.Interactive.pipe(
1491 Effect.flatMap((allowReserve) =>
1615 - graphqlRead({
1616 - allowReserve,
1617 - cwd: input.cwd,
1618 - host: input.host,
1619 - operation: "getPullRequestDetail",
1620 - variables: {
1492 + client
1493 + .PullRequestCore({
1494 owner,
1495 name,
1496 number: input.number,
1497 headRef: `refs/pull/${input.number}/head`,
1625 - },
1626 - query: pullRequestCoreGraphQlQuery(input.host),
1627 - decode: decodePullRequestCoreJson,
1628 - }).pipe(
1629 - // Past a hundred checks the first page would let the rest imply success, so the whole
1630 - // rollup is walked instead.
1631 - Effect.filterOrElse(
1632 - (core) => !core.checksTruncated,
1633 - (core) =>
1634 - readAllCheckContexts(input, allowReserve).pipe(
1635 - Effect.filterOrFail(
1636 - (all) => all.headSha === core.headSha,
1637 - () =>
1638 - readError(
1639 - input.cwd,
1640 - "getPullRequestDetail",
1641 - new Error("Pull request head changed while reading checks."),
1642 - ),
1498 + required: asksRequired(input.host),
1499 + })
1500 + .pipe(
1501 + graphql({ ...input, operation, allowReserve }),
1502 + Effect.map(toPullRequestCore),
1503 + Effect.flatMap(found({ ...input, operation })),
1504 + // Past a hundred checks the first page would let the rest imply success, so the whole
1505 + // rollup is walked instead.
1506 + Effect.filterOrElse(
1507 + (core) => !core.checksTruncated,
1508 + (core) =>
1509 + readAllCheckContexts(input, allowReserve).pipe(
1510 + Effect.filterOrFail(
1511 + (all) => all.headSha === core.headSha,
1512 + () =>
1513 + readError(
1514 + input.cwd,
1515 + operation,
1516 + new Error("Pull request head changed while reading checks."),
1517 + ),
1518 + ),
1519 + Effect.map((all) => ({
1520 + ...core,
1521 + ...pullRequestChecksFromContexts(all.contexts),
1522 + checksTruncated: all.truncated,
1523 + })),
1524 ),
1644 - Effect.map((all) => ({
1645 - ...core,
1646 - ...pullRequestChecksFromContexts(all.contexts),
1647 - checksTruncated: all.truncated,
1648 - })),
1649 - ),
1525 + ),
1526 ),
1651 - ),
1527 ),
1528 );
1529 };
@@ -1671,22 +1546,28 @@ export const make = Effect.gen(function* () {
1546 const { owner, name } = parseRepositorySelector(input.repository);
1547 const countHeads = (pages: ReadonlyArray<{ readonly heads: ReadonlyArray<unknown> }>) =>
1548 pages.reduce((total, page) => total + page.heads.length, 0);
1674 - const { pages, truncated } = yield* readGraphQlPages(
1675 - (after) =>
1676 - graphqlRead({
1677 - cwd: input.cwd,
1678 - host: input.host,
1679 - operation: "listWorkflowRunsRequiringApproval",
1680 - allowReserve: true,
1681 - variables: { owner, name, head: input.headBranch, after },
1682 - query: PULL_REQUEST_HEADS_GRAPHQL_QUERY,
1683 - decode: decodePullRequestHeadsJson,
1684 - }),
1549 + const target = {
1550 + ...input,
1551 + operation: "listWorkflowRunsRequiringApproval",
1552 + allowReserve: true,
1553 + };
1554 + const { pages, truncated } = yield* readPages(
1555 + GraphQLClient.pages(client.PullRequestHeads, {
1556 + variables: { owner, name, head: input.headBranch },
1557 + connection: (result) => {
1558 + const page = toPullRequestHeads(result);
1559 + return {
1560 + ...page,
1561 + pageInfo: { hasNextPage: page.nextCursor !== null, endCursor: page.nextCursor },
1562 + };
1563 + },
1564 + }),
1565 {
1686 - nextCursor: (page) => page.nextCursor,
1566 + ...target,
1567 + hasNextPage: (page) => page.nextCursor !== null,
1568 until: (pages) => countHeads(pages) > workflowApprovalLimit,
1569 },
1689 - );
1570 + ).pipe(graphql(target));
1571 return { heads: pages.flatMap((page) => page.heads), truncated };
1572 });
1573
@@ -1801,166 +1682,123 @@ export const make = Effect.gen(function* () {
1682 { concurrency: 2 },
1683 ).pipe(Effect.map(([, runs]) => runs));
1684
1804 - /** One pull request's summary, through the same aliased query the batch uses. */
1805 - const viewPullRequestSummary = (input: PullRequestSummaryRead) => {
1806 - const { owner, name } = parseRepositorySelector(input.repository);
1807 - return graphqlRead({
1808 - cwd: input.cwd,
1809 - host: input.host,
1810 - operation: "getPullRequestSummary",
1811 - variables: { owner, name, number: input.number },
1812 - query: pullRequestSummaryGraphQlQuery(input.host === "github.com"),
1813 - decode: decodePullRequestSummariesJson,
1814 - }).pipe(
1815 - Effect.flatMap((summaries) => {
1816 - const summary = summaries.get(0);
1817 - return summary === undefined
1818 - ? Effect.fail(
1819 - readError(
1820 - input.cwd,
1821 - "getPullRequestSummary",
1822 - new Error(`GitHub answered nothing for ${input.repository}#${input.number}.`),
1823 - ),
1824 - )
1825 - : Effect.succeed(summary);
1685 + /** The mutations that only need the pull request's node id. */
1686 + const simpleActionMutations = {
1687 + "disable-auto-merge": (pullRequestId: string) =>
1688 + client.DisablePullRequestAutoMerge({ pullRequestId }).pipe(Effect.asVoid),
1689 + ready: (pullRequestId: string) =>
1690 + client.MarkPullRequestReadyForReview({ pullRequestId }).pipe(Effect.asVoid),
1691 + draft: (pullRequestId: string) =>
1692 + client.ConvertPullRequestToDraft({ pullRequestId }).pipe(Effect.asVoid),
1693 + close: (pullRequestId: string) =>
1694 + client.ClosePullRequest({ pullRequestId }).pipe(Effect.asVoid),
1695 + reopen: (pullRequestId: string) =>
1696 + client.ReopenPullRequest({ pullRequestId }).pipe(Effect.asVoid),
1697 + } satisfies Partial<Record<PullRequestAction, unknown>>;
1698 +
1699 + /**
1700 + * Runs batched lookups for one read on `host`. The resolver groups them by host and credential.
1701 + * GitHub saying one pull request does not exist fails that lookup as not found; any other client
1702 + * failure is a read error against `operation`, and a request policy failure (a rate limit, a
1703 + * refused credential) passes through as itself.
1704 + */
1705 + const batchedRead = <A, E, R>(
1706 + input: { readonly cwd: string; readonly host: string; readonly operation: string },
1707 + effect: Effect.Effect<A, E, R>,
1708 + ): Effect.Effect<
1709 + A,
1710 + | Exclude<E, GraphQLClientError.GraphQLClientError>
1711 + | GitHubPullRequestReadError
1712 + | GitHubRequestPolicy.GitHubApiNotFoundError,
1713 + Exclude<R, GitHubGraphQlClient.GitHubGraphQlTarget>
1714 + > =>
1715 + effect.pipe(
1716 + Effect.provideService(GitHubGraphQlClient.GitHubGraphQlTarget, {
1717 + host: input.host,
1718 + operation: input.operation,
1719 }),
1720 + Effect.mapError((error) =>
1721 + !isGraphQlClientError(error)
1722 + ? (error as Exclude<E, GraphQLClientError.GraphQLClientError>)
1723 + : isNotFoundOnly(error)
1724 + ? new GitHubRequestPolicy.GitHubApiNotFoundError({
1725 + host: input.host,
1726 + operation: input.operation,
1727 + })
1728 + : readError(input.cwd, input.operation, error),
1729 + ),
1730 );
1828 - };
1731
1732 /**
1733 * Summaries asked for together, on one host under one credential, share aliased GraphQL reads
1832 - * of twenty-five: the background sync reads every linked pull request each minute, and one
1833 - * `gh pr view` apiece is most of what it spends. Whatever the batch cannot answer — a selector
1834 - * GraphQL cannot address, a pull request GitHub returned nothing for — is read on its own.
1734 + * of twenty-five: the background sync reads every linked pull request each minute, and one read
1735 + * apiece is most of what it spends. A pull request GitHub cannot find fails on its own; the
1736 + * rest of its batch still answers.
1737 */
1836 - const summaryResolver = RequestResolver.makeGrouped<PullRequestSummaryRead, string>({
1837 - key: ({ request, context }) =>
1838 - JSON.stringify([
1839 - request.host.toLowerCase(),
1840 - Context.getOrElse(context, GitHubApi.PinnedGitHubCredential, () => null)
1841 - ?.credentialFingerprint ?? null,
1842 - Context.getOrElse(context, SourceControlRateLimit.CredentialScope, () => ""),
1843 - ]),
1844 - resolver: (entries) => {
1845 - const [first] = entries;
1846 - const batchable = entries.filter(
1847 - (entry) => buildPullRequestSummariesGraphQlQuery([entry.request]) !== null,
1848 - );
1849 - // Stack membership rides along where GitHub serves stacks, so the background sync can skip
1850 - // the REST stack read for pull requests that are in none.
1851 - const document = buildPullRequestSummariesGraphQlQuery(
1852 - batchable.map((entry) => entry.request),
1853 - first.request.host === "github.com",
1854 - );
1855 - const batched =
1856 - document === null
1857 - ? Effect.succeed(new Map<number, GitHubPullRequestSummary>())
1858 - : graphqlRead({
1859 - cwd: first.request.cwd,
1860 - host: first.request.host,
1861 - operation: "getPullRequestSummary",
1862 - ...document,
1863 - decode: decodePullRequestSummariesJson,
1864 - });
1865 - return batched.pipe(
1866 - // A GraphQL error anywhere fails the whole document — one repository gone or out of
1867 - // reach — so a batch that could not be read leaves every entry to its own read. A paused
1868 - // budget is the exception: reading one at a time would only spend what is being saved.
1869 - Effect.catchCauseIf(
1870 - (cause) =>
1871 - !Cause.hasInterruptsOnly(cause) &&
1872 - !Cause.findErrorOption(cause).pipe(
1873 - Option.exists((error) => error._tag === "SourceControlRateLimitPausedError"),
1874 - ),
1875 - (cause) =>
1876 - Effect.logDebug("batched pull request summary read failed", { cause }).pipe(
1877 - Effect.as(new Map<number, GitHubPullRequestSummary>()),
1878 - ),
1879 - ),
1880 - Effect.flatMap((summaries) => {
1881 - const unanswered = entries.filter((entry) => {
1882 - const summary = summaries.get(batchable.indexOf(entry));
1883 - if (summary === undefined) return true;
1884 - entry.completeUnsafe(Exit.succeed(summary));
1885 - return false;
1886 - });
1887 - return Effect.forEach(
1888 - unanswered,
1889 - (entry) =>
1890 - viewPullRequestSummary(entry.request).pipe(
1891 - Effect.exit,
1892 - Effect.map((exit) => entry.completeUnsafe(exit)),
1893 - ),
1894 - { concurrency: STAT_REQUEST_CONCURRENCY, discard: true },
1895 - );
1896 - }),
1897 - Effect.catchCause((cause) =>
1898 - Effect.sync(() => {
1899 - for (const entry of entries) entry.completeUnsafe(Exit.failCause(cause));
1900 - }),
1901 - ),
1902 - );
1903 - },
1738 + const summaryResolver = GraphQLResolver.aliased(client.PullRequestSummary, {
1739 + batchKey: GitHubGraphQlClient.batchKey,
1740 }).pipe(
1741 RequestResolver.setDelay(SUMMARY_BATCH_WINDOW),
1742 RequestResolver.batchN(STAT_ALIASES_PER_REQUEST),
1743 );
1744 const getPullRequestSummary: GitHubPullRequestApi["Service"]["getPullRequestSummary"] = (input) =>
1909 - Effect.request(new PullRequestSummaryRead(input), summaryResolver);
1745 + Effect.gen(function* () {
1746 + const lookup = pullRequestLookup(input);
1747 + if (lookup === null) {
1748 + return yield* new GitHubRepositorySelectorError({
1749 + cwd: input.cwd,
1750 + operation: "getPullRequestSummary",
1751 + });
1752 + }
1753 + const result = yield* GraphQLResolver.request(
1754 + { ...lookup, stacks: input.host.toLowerCase() === "github.com" },
1755 + summaryResolver,
1756 + );
1757 + const pullRequest = result.repository?.pullRequest;
1758 + if (pullRequest == null) {
1759 + return yield* new GitHubRequestPolicy.GitHubApiNotFoundError({
1760 + host: input.host,
1761 + operation: "getPullRequestSummary",
1762 + });
1763 + }
1764 + return toPullRequestSummary(pullRequest);
1765 + }).pipe((effect) => batchedRead({ ...input, operation: "getPullRequestSummary" }, effect));
1766
1767 // Every watched pull request on a host in one read per pass. A pull request the batch has no
1912 - // answer for gets null, and its watch reads it in full; a failed batch fails every entry.
1913 - const watchFingerprintResolver = RequestResolver.makeGrouped<
1914 - PullRequestWatchFingerprintRead,
1915 - string
1916 - >({
1917 - key: ({ request, context }) =>
1918 - JSON.stringify([
1919 - request.host.toLowerCase(),
1920 - Context.getOrElse(context, GitHubApi.PinnedGitHubCredential, () => null)
1921 - ?.credentialFingerprint ?? null,
1922 - Context.getOrElse(context, SourceControlRateLimit.CredentialScope, () => ""),
1923 - ]),
1924 - resolver: (entries) => {
1925 - const [first] = entries;
1926 - const batchable = entries.filter(
1927 - (entry) => buildPullRequestWatchFingerprintsGraphQlQuery([entry.request]) !== null,
1928 - );
1929 - const document = buildPullRequestWatchFingerprintsGraphQlQuery(
1930 - batchable.map((entry) => entry.request),
1931 - );
1932 - const read =
1933 - document === null
1934 - ? Effect.succeed(new Map<number, GitHubPullRequestWatchFingerprint>())
1935 - : graphqlRead({
1936 - cwd: first.request.cwd,
1937 - host: first.request.host,
1938 - operation: "getPullRequestWatchFingerprint",
1939 - ...document,
1940 - decode: decodePullRequestWatchFingerprintsJson,
1941 - });
1942 - return read.pipe(
1943 - Effect.map((fingerprints) => {
1944 - for (const entry of entries) {
1945 - const index = batchable.indexOf(entry);
1946 - entry.completeUnsafe(
1947 - Exit.succeed(index === -1 ? null : (fingerprints.get(index) ?? null)),
1948 - );
1949 - }
1950 - }),
1951 - Effect.catchCause((cause) =>
1952 - Effect.sync(() => {
1953 - for (const entry of entries) entry.completeUnsafe(Exit.failCause(cause));
1954 - }),
1955 - ),
1956 - );
1957 - },
1768 + // answer for gets null, and its watch reads it in full; a failed request fails every entry.
1769 + const watchFingerprintResolver = GraphQLResolver.aliased(client.PullRequestWatchFingerprint, {
1770 + batchKey: GitHubGraphQlClient.batchKey,
1771 }).pipe(
1772 RequestResolver.setDelay(SUMMARY_BATCH_WINDOW),
1773 RequestResolver.batchN(STAT_ALIASES_PER_REQUEST),
1774 );
1775 const getPullRequestWatchFingerprint: GitHubPullRequestApi["Service"]["getPullRequestWatchFingerprint"] =
1963 - (input) => Effect.request(new PullRequestWatchFingerprintRead(input), watchFingerprintResolver);
1776 + (input) => {
1777 + const lookup = pullRequestLookup(input);
1778 + if (lookup === null) return Effect.succeed(null);
1779 + return GraphQLResolver.request(lookup, watchFingerprintResolver).pipe(
1780 + Effect.map((result) => {
1781 + const pullRequest = result.repository?.pullRequest;
1782 + return pullRequest == null ? null : toPullRequestWatchFingerprint(pullRequest);
1783 + }),
1784 + Effect.catchIf(isNotFoundOnly, () => Effect.succeed(null)),
1785 + (effect) => batchedRead({ ...input, operation: "getPullRequestWatchFingerprint" }, effect),
1786 + );
1787 + };
1788 +
1789 + // Rows already on a page, enriched with what the listing query leaves out. They are many, so
1790 + // their lookups share aliased requests of twenty-five, four at a time.
1791 + const statsResolver = GraphQLResolver.aliased(client.PullRequestStats, {
1792 + batchKey: GitHubGraphQlClient.batchKey,
1793 + }).pipe(RequestResolver.batchN(STAT_ALIASES_PER_REQUEST));
1794 + const stackMembershipResolver = GraphQLResolver.aliased(client.PullRequestStackMembership, {
1795 + batchKey: GitHubGraphQlClient.batchKey,
1796 + }).pipe(RequestResolver.batchN(STAT_ALIASES_PER_REQUEST));
1797 + // A burst of ticks is one request, each file under its own alias. GitHub has no bulk form of
1798 + // `markFileAsViewed`/`unmarkFileAsViewed`, which each take a single path.
1799 + const setFileViewedResolver = GraphQLResolver.aliased(client.SetFileViewed, {
1800 + batchKey: GitHubGraphQlClient.batchKey,
1801 + }).pipe(RequestResolver.batchN(FILES_VIEWED_PER_REQUEST));
1802
1803 return GitHubPullRequestApi.of({
1804 withVerifiedCredential,
@@ -1981,7 +1819,19 @@ export const make = Effect.gen(function* () {
1819 }),
1820 );
1821 }
1984 - /** Pages of up to a hundred until `rows` have arrived or GitHub has no more. */
1822 + const target = { cwd: input.cwd, host: input.host, operation: "listPullRequests" };
1823 + const toPage = (
1824 + page: ReturnType<typeof toPullRequestRows>,
1825 + ): GitHubPullRequestListPage & { readonly pageInfo: GraphQLClient.PageInfo } => ({
1826 + items: page.rows.map((row) => row.item),
1827 + rawCount: page.rawCount,
1828 + endCursor: page.endCursor,
1829 + pageInfo: { hasNextPage: page.endCursor !== null, endCursor: page.endCursor },
1830 + });
1831 + /**
1832 + * Pages of up to a hundred until `rows` have arrived or GitHub has no more. Each page asks
1833 + * for only the rows still missing, so the last one does not overshoot.
1834 + */
1835 const collect = (
1836 rows: number,
1837 page: (
@@ -1992,44 +1842,65 @@ export const make = Effect.gen(function* () {
1842 Effect.gen(function* () {
1843 const countRows = (pages: ReadonlyArray<GitHubPullRequestListPage>) =>
1844 pages.reduce((total, read) => total + read.rawCount, 0);
1995 - const { pages, truncated } = yield* readGraphQlPages(
1996 - (after, pages: ReadonlyArray<GitHubPullRequestListPage>) =>
1997 - page(after, rows - countRows(pages)),
1998 - {
1999 - nextCursor: (read) => read.endCursor,
2000 - until: (pages) => countRows(pages) >= rows,
2001 - },
2002 - );
2003 - // `truncated` also covers a cursor GitHub repeated before `rows` arrived.
1845 + const pages: GitHubPullRequestListPage[] = [];
1846 + const seen = new Set<string>();
1847 + let after: string | null = null;
1848 + let truncated = false;
1849 + while (true) {
1850 + const read: GitHubPullRequestListPage = yield* page(after, rows - countRows(pages));
1851 + pages.push(read);
1852 + const next = read.endCursor;
1853 + if (next === null) break;
1854 + // `truncated` also covers a cursor GitHub repeated before `rows` arrived.
1855 + if (seen.has(next) || countRows(pages) >= rows) {
1856 + truncated = true;
1857 + break;
1858 + }
1859 + seen.add(next);
1860 + after = next;
1861 + }
1862 return {
1863 items: pages.flatMap((read) => read.items),
1864 rawCount: countRows(pages),
1865 truncated,
1866 };
1867 });
1868 + const stacks = input.host.toLowerCase() === "github.com";
1869 const read = (
1870 continues: boolean,
1871 requestedRows = input.limit + 1,
1872 ): Effect.Effect<GitHubPullRequestListBatch, GitHubPullRequestApiError> =>
1873 collect(requestedRows, (after, rows) =>
2015 - continues
2016 - ? graphqlRead({
2017 - cwd: input.cwd,
2018 - host: input.host,
2019 - operation: "listPullRequests",
2020 - // The reader's own words are in the query.
2021 - variables: { q: query, after },
2022 - query: pullRequestSearchGraphQlQuery(rows, false, true),
2023 - decode: decodePullRequestSearchJson,
2024 - })
2025 - : graphqlRead({
2026 - cwd: input.cwd,
2027 - host: input.host,
2028 - operation: "listPullRequests",
2029 - variables: { owner, name, states: LIST_STATES[input.state], after },
2030 - query: pullRequestListGraphQlQuery(rows),
2031 - decode: decodePullRequestListJson,
2032 - }),
1874 + (continues
1875 + ? client
1876 + .PullRequestSearch({
1877 + // The reader's own words are in the query.
1878 + q: query,
1879 + first: pageRows(rows),
1880 + after,
1881 + // Stack badges come from their own batched read below, for the rows that stay.
1882 + stacks: false,
1883 + stats: true,
1884 + })
1885 + .pipe(Effect.map((result) => toPage(toPullRequestRows(result.search))))
1886 + : client
1887 + .PullRequestList({
1888 + owner,
1889 + name,
1890 + states: LIST_STATES[input.state],
1891 + first: pageRows(rows),
1892 + after,
1893 + stacks: false,
1894 + stats: true,
1895 + })
1896 + .pipe(
1897 + // A repository the viewer cannot see answers as an empty page, which is what
1898 + // `gh pr list` printed for it too.
1899 + Effect.map((result) =>
1900 + toPage(toPullRequestRows(result.repository?.pullRequests)),
1901 + ),
1902 + )
1903 + ).pipe(graphql(target)),
1904 ).pipe(
1905 Effect.flatMap(({ items: rawItems, rawCount, truncated: cutShort }) => {
1906 const items = continues
@@ -2082,44 +1953,39 @@ export const make = Effect.gen(function* () {
1953 ),
1954 Effect.flatMap((batch) => {
1955 // Match the search query's host support, and enrich only rows that survived paging.
2085 - if (input.host !== "github.com" || batch.items.length === 0) return Effect.succeed(batch);
2086 - const chunks: Array<ReadonlyArray<GitHubPullRequestListItem>> = [];
2087 - for (let start = 0; start < batch.items.length; start += STAT_ALIASES_PER_REQUEST) {
2088 - chunks.push(batch.items.slice(start, start + STAT_ALIASES_PER_REQUEST));
2089 - }
1956 + if (!stacks || batch.items.length === 0) return Effect.succeed(batch);
1957 return Effect.forEach(
2091 - chunks,
2092 - (chunk) => {
2093 - const document = buildPullRequestStackMembershipsGraphQlQuery(
2094 - input.repository,
2095 - chunk.map((item) => item.number),
2096 - );
2097 - if (document === null) return Effect.succeed(chunk);
2098 - return graphqlRead({
2099 - cwd: input.cwd,
2100 - host: input.host,
2101 - operation: "listPullRequestStackMemberships",
2102 - ...document,
2103 - decode: decodePullRequestStackMembershipsJson,
2104 - }).pipe(
2105 - Effect.map((memberships) =>
2106 - chunk.map((item, index) => {
2107 - const stack = memberships.get(index);
2108 - return stack === undefined ? item : { ...item, stack };
2109 - }),
2110 - ),
1958 + batch.items,
1959 + (item) => {
1960 + const lookup = pullRequestLookup({
1961 + repository: input.repository,
1962 + number: item.number,
1963 + });
1964 + if (lookup === null) return Effect.succeed(item);
1965 + return GraphQLResolver.request(lookup, stackMembershipResolver).pipe(
1966 + Effect.map((result) => {
1967 + const pullRequest = result.repository?.pullRequest;
1968 + const stack = pullRequest == null ? undefined : toStackMembership(pullRequest);
1969 + return stack === undefined ? item : { ...item, stack };
1970 + }),
1971 // Optional badges must not take down a listing that already read successfully.
2112 - Effect.catch(() =>
1972 + Effect.catch((error) =>
1973 Effect.logWarning("Pull request stack membership enrichment failed", {
1974 operation: "listPullRequestStackMemberships",
1975 host: input.host,
2116 - rows: chunk.length,
2117 - }).pipe(Effect.as(chunk)),
1976 + error: error._tag,
1977 + }).pipe(Effect.as(item)),
1978 ),
1979 );
1980 },
2121 - { concurrency: STAT_REQUEST_CONCURRENCY },
2122 - ).pipe(Effect.map((chunks) => ({ ...batch, items: chunks.flat() })));
1981 + { concurrency: "unbounded" },
1982 + ).pipe(
1983 + Effect.provideService(GitHubGraphQlClient.GitHubGraphQlTarget, {
1984 + host: input.host,
1985 + operation: "listPullRequestStackMemberships",
1986 + }),
1987 + Effect.map((items) => ({ ...batch, items })),
1988 + );
1989 }),
1990 );
1991 },
@@ -2138,57 +2004,59 @@ export const make = Effect.gen(function* () {
2004 // per-repository read does — up to GitHub's own ceiling on a search page, past which
2005 // `hasNextPage` is what says there is more.
2006 const rows = Math.min(input.limit + 1, PULL_REQUEST_SEARCH_MAX_ROWS);
2141 - return graphqlRead({
2142 - cwd: input.cwd,
2143 - host: input.host,
2144 - operation: "searchPullRequests",
2145 - variables: { q: query, after: null },
2146 - query: pullRequestSearchGraphQlQuery(rows, input.host === "github.com"),
2147 - decode: decodePullRequestSearchJson,
2148 - }).pipe(
2149 - Effect.map((batch) => ({
2150 - items: batch.items.slice(0, input.limit),
2151 - truncated: batch.rawCount > input.limit || batch.hasNextPage,
2152 - })),
2153 - );
2007 + return client
2008 + .PullRequestSearch({
2009 + q: query,
2010 + first: rows,
2011 + stacks: input.host.toLowerCase() === "github.com",
2012 + stats: false,
2013 + })
2014 + .pipe(
2015 + graphql({ ...input, operation: "searchPullRequests" }),
2016 + Effect.map(({ search }) => {
2017 + const page = toPullRequestRows(search);
2018 + // A search row names its repository; one that does not cannot be placed on a page.
2019 + const items = page.rows.flatMap(({ item, repository }) =>
2020 + repository === null ? [] : [{ ...item, repository }],
2021 + );
2022 + return {
2023 + items: items.slice(0, input.limit),
2024 + truncated: page.rawCount > input.limit || page.hasNextPage,
2025 + };
2026 + }),
2027 + );
2028 },
2029
2156 - listPullRequestStats: (input) => {
2157 - const chunks: Array<ReadonlyArray<{ readonly repository: string; readonly number: number }>> =
2158 - [];
2159 - for (let start = 0; start < input.changeRequests.length; start += STAT_ALIASES_PER_REQUEST) {
2160 - chunks.push(input.changeRequests.slice(start, start + STAT_ALIASES_PER_REQUEST));
2161 - }
2162 - return Effect.forEach(
2163 - chunks,
2164 - (chunk) => {
2165 - const document = buildPullRequestStatsGraphQlQuery(chunk);
2166 - if (document === null) {
2167 - return Effect.fail(
2168 - new GitHubRepositorySelectorError({
2169 - cwd: input.cwd,
2170 - operation: "listPullRequestStats",
2171 - }),
2172 - );
2173 - }
2174 - return graphqlRead({
2030 + listPullRequestStats: (input) =>
2031 + Effect.gen(function* () {
2032 + const lookups = input.changeRequests.map((changeRequest) => ({
2033 + changeRequest,
2034 + lookup: pullRequestLookup(changeRequest),
2035 + }));
2036 + if (lookups.some(({ lookup }) => lookup === null)) {
2037 + return yield* new GitHubRepositorySelectorError({
2038 cwd: input.cwd,
2176 - host: input.host,
2039 operation: "listPullRequestStats",
2178 - ...document,
2179 - decode: decodePullRequestStatsJson,
2180 - }).pipe(
2181 - Effect.map((stats) =>
2182 - chunk.flatMap((changeRequest, index) => {
2183 - const stat = stats.get(index);
2184 - return stat === undefined ? [] : [{ ...changeRequest, ...stat }];
2040 + });
2041 + }
2042 + // A repository or pull request GitHub answered nothing for is left out, which leaves the
2043 + // row with whatever it already had.
2044 + const stats = yield* Effect.forEach(
2045 + lookups,
2046 + ({ changeRequest, lookup }) =>
2047 + GraphQLResolver.request(lookup!, statsResolver).pipe(
2048 + Effect.map((result) => {
2049 + const pullRequest = result.repository?.pullRequest;
2050 + return pullRequest == null
2051 + ? []
2052 + : [{ ...changeRequest, ...pullRequest } satisfies GitHubPullRequestStat];
2053 }),
2054 + Effect.catchIf(isNotFoundOnly, () => Effect.succeed([])),
2055 ),
2187 - );
2188 - },
2189 - { concurrency: STAT_REQUEST_CONCURRENCY },
2190 - ).pipe(Effect.map((results) => results.flat()));
2191 - },
2056 + { concurrency: "unbounded" },
2057 + );
2058 + return stats.flat();
2059 + }).pipe((effect) => batchedRead({ ...input, operation: "listPullRequestStats" }, effect)),
2060
2061 getPullRequestSummary,
2062 getPullRequestWatchFingerprint,
@@ -2196,14 +2064,14 @@ export const make = Effect.gen(function* () {
2064 getPullRequestDetail,
2065 getPullRequestPreview: (input) => {
2066 const { owner, name } = parseRepositorySelector(input.repository);
2199 - return graphqlRead({
2200 - cwd: input.cwd,
2201 - host: input.host,
2202 - operation: "getPullRequestPreview",
2203 - variables: { owner, name, number: input.number },
2204 - query: PULL_REQUEST_PREVIEW_GRAPHQL_QUERY,
2205 - decode: decodePullRequestPreviewJson,
2206 - });
2067 + const operation = "getPullRequestPreview";
2068 + return client
2069 + .PullRequestPreview({ owner, name, number: input.number })
2070 + .pipe(
2071 + graphql({ ...input, operation }),
2072 + Effect.map(toPullRequestPreview),
2073 + Effect.flatMap(found({ ...input, operation })),
2074 + );
2075 },
2076 listWorkflowRunsRequiringApproval,
2077
@@ -2245,13 +2113,11 @@ export const make = Effect.gen(function* () {
2113 let reviewsAfter: string | null = null;
2114 let withComments = true;
2115 let withReviews = true;
2116 + const target = { ...input, operation: "getPullRequestActivity" };
2117 // Both remark lists page on their own; a page asks only for the ones with more to give.
2118 for (let page = 0; page < REVIEW_THREAD_PAGES && (withComments || withReviews); page++) {
2250 - const read: GitHubPullRequestActivityPage = yield* graphqlRead({
2251 - cwd: input.cwd,
2252 - host: input.host,
2253 - operation: "getPullRequestActivity",
2254 - variables: {
2119 + const read: GitHubPullRequestActivityPage = yield* client
2120 + .PullRequestActivity({
2121 owner,
2122 name,
2123 number: input.number,
@@ -2260,10 +2126,12 @@ export const make = Effect.gen(function* () {
2126 commentsAfter,
2127 withReviews,
2128 reviewsAfter,
2263 - },
2264 - query: PULL_REQUEST_ACTIVITY_GRAPHQL_QUERY,
2265 - decode: decodePullRequestActivityJson,
2266 - });
2129 + })
2130 + .pipe(
2131 + graphql(target),
2132 + Effect.map(toPullRequestActivityPage),
2133 + Effect.flatMap(found(target)),
2134 + );
2135 if (page === 0) {
2136 author = read.author ?? null;
2137 commits = read.commits ?? [];
@@ -2344,47 +2212,40 @@ export const make = Effect.gen(function* () {
2212
2213 getReviewThreadComments: (input) => {
2214 const { owner, name } = parseRepositorySelector(input.repository);
2347 - return graphqlRead({
2348 - cwd: input.cwd,
2349 - host: input.host,
2350 - operation: "getReviewThreadComments",
2351 - variables: {
2215 + return client
2216 + .ReviewThreadComments({
2217 owner,
2218 name,
2219 number: input.number,
2220 threadId: input.threadId,
2356 - cursor: input.cursor,
2357 - },
2358 - query: REVIEW_THREAD_COMMENTS_GRAPHQL_QUERY,
2359 - decode: decodeReviewThreadCommentsJson,
2360 - }).pipe(
2361 - Effect.flatMap(({ belongsToPullRequest, comments, nextCursor }) =>
2362 - belongsToPullRequest
2363 - ? Effect.succeed({ comments, nextCursor })
2364 - : Effect.fail(
2365 - new GitHubSubjectScopeError({
2366 - cwd: input.cwd,
2367 - operation: "getReviewThreadComments",
2368 - }),
2369 - ),
2370 - ),
2371 - );
2221 + after: input.cursor,
2222 + })
2223 + .pipe(
2224 + graphql({ ...input, operation: "getReviewThreadComments" }),
2225 + Effect.map(toReviewThreadCommentsPage),
2226 + Effect.flatMap(({ belongsToPullRequest, comments, nextCursor }) =>
2227 + belongsToPullRequest
2228 + ? Effect.succeed({ comments, nextCursor })
2229 + : Effect.fail(
2230 + new GitHubSubjectScopeError({
2231 + cwd: input.cwd,
2232 + operation: "getReviewThreadComments",
2233 + }),
2234 + ),
2235 + ),
2236 + );
2237 },
2238
2239 listReviewThreadComments: (input) =>
2240 Effect.gen(function* () {
2241 const { owner, name } = parseRepositorySelector(input.repository);
2242 + const target = { ...input, operation: "listReviewThreadComments" };
2243 const threadPage = (
2378 - cursor: string | null,
2244 + after: string | null,
2245 ): Effect.Effect<GitHubReviewThreadPage, GitHubPullRequestApiError> =>
2380 - graphqlRead({
2381 - cwd: input.cwd,
2382 - host: input.host,
2383 - operation: "listReviewThreadComments",
2384 - variables: { owner, name, number: input.number, cursor },
2385 - query: REVIEW_THREADS_GRAPHQL_QUERY,
2386 - decode: decodeReviewThreadsJson,
2387 - });
2246 + client
2247 + .ReviewThreads({ owner, name, number: input.number, after })
2248 + .pipe(graphql(target), Effect.map(toReviewThreadPage), Effect.flatMap(found(target)));
2249 const entries: GitHubReviewThreadEntry[] = [];
2250 const avatarsByLogin = new Map<string, string>();
2251 const botLogins = new Set<string>();
@@ -2430,22 +2291,27 @@ export const make = Effect.gen(function* () {
2291 // ordinarily accrues. Followed so a review whose event fell past that page still finds
2292 // its reason.
2293 if (dismissalCursor !== null) {
2433 - const { pages } = yield* readGraphQlPages(
2434 - (cursor) =>
2435 - graphqlRead({
2436 - cwd: input.cwd,
2437 - host: input.host,
2438 - operation: "listReviewThreadComments",
2439 - variables: { owner, name, number: input.number, cursor },
2440 - query: REVIEW_DISMISSALS_GRAPHQL_QUERY,
2441 - decode: decodeReviewDismissalsJson,
2442 - }),
2443 - {
2444 - from: dismissalCursor,
2445 - maxPages: REVIEW_THREAD_PAGES,
2446 - nextCursor: (read) => read.nextCursor,
2447 - },
2448 - );
2294 + let after: string | null = dismissalCursor;
2295 + const pages: Array<{
2296 + readonly dismissalsByReviewId: ReadonlyMap<string, string>;
2297 + }> = [];
2298 + const seen = new Set<string>();
2299 + // Carries on from the thread read's own cursor, which `GraphQLClient.pages` cannot.
2300 + while (after !== null && pages.length < REVIEW_THREAD_PAGES && !seen.has(after)) {
2301 + seen.add(after);
2302 + const read: {
2303 + readonly dismissalsByReviewId: ReadonlyMap<string, string>;
2304 + readonly nextCursor: string | null;
2305 + } = yield* client
2306 + .ReviewDismissals({ owner, name, number: input.number, after })
2307 + .pipe(
2308 + graphql(target),
2309 + Effect.map(toReviewDismissalsPage),
2310 + Effect.flatMap(found(target)),
2311 + );
2312 + pages.push(read);
2313 + after = read.nextCursor;
2314 + }
2315 for (const read of pages)
2316 for (const [id, message] of read.dismissalsByReviewId)
2317 dismissalsByReviewId.set(id, message);
@@ -2483,40 +2349,33 @@ export const make = Effect.gen(function* () {
2349 if (input.ids.length === 0) {
2350 return Effect.succeed(new Map<string, string>());
2351 }
2486 - return graphqlRead({
2487 - cwd: input.cwd,
2488 - host: input.host,
2489 - operation: "listActorAvatars",
2490 - variables: { ids: input.ids },
2491 - query: ACTOR_AVATARS_GRAPHQL_QUERY,
2492 - decode: decodeActorAvatarsJson,
2493 - });
2352 + return client
2353 + .ActorAvatars({ ids: input.ids })
2354 + .pipe(graphql({ ...input, operation: "listActorAvatars" }), Effect.map(toActorAvatars));
2355 },
2356
2357 getViewerAccess: (input) => {
2358 const { owner, name } = parseRepositorySelector(input.repository);
2498 - return graphqlRead({
2499 - cwd: input.cwd,
2500 - host: input.host,
2501 - operation: "getViewerAccess",
2502 - ...(input.allowReserve === true ? { allowReserve: true } : {}),
2503 - variables: { owner, name, number: input.number },
2504 - query: VIEWER_PERMISSIONS_GRAPHQL_QUERY,
2505 - decode: decodeViewerPermissionsJson,
2506 - });
2359 + const operation = "getViewerAccess";
2360 + return client
2361 + .ViewerPermissions({ owner, name, number: input.number })
2362 + .pipe(
2363 + graphql({ ...input, operation }),
2364 + Effect.map(toViewerPermissions),
2365 + Effect.flatMap(found({ ...input, operation })),
2366 + );
2367 },
2368
2369 listReviewerCandidates: (input) => {
2370 const { owner, name } = parseRepositorySelector(input.repository);
2511 - return graphqlRead({
2512 - cwd: input.cwd,
2513 - host: input.host,
2514 - operation: "listReviewerCandidates",
2515 - allowReserve: true,
2516 - variables: { owner, name, number: input.number },
2517 - query: REVIEWER_CANDIDATES_GRAPHQL_QUERY,
2518 - decode: decodeReviewerCandidatesJson,
2519 - });
2371 + const operation = "listReviewerCandidates";
2372 + return client
2373 + .ReviewerCandidates({ owner, name, number: input.number })
2374 + .pipe(
2375 + graphql({ ...input, operation, allowReserve: true }),
2376 + Effect.map(toReviewerCandidates),
2377 + Effect.flatMap(found({ ...input, operation })),
2378 + );
2379 },
2380
2381 setReviewerRequest: (input) => {
@@ -2536,15 +2395,14 @@ export const make = Effect.gen(function* () {
2395
2396 listLabelCandidates: (input) => {
2397 const { owner, name } = parseRepositorySelector(input.repository);
2539 - return graphqlRead({
2540 - cwd: input.cwd,
2541 - host: input.host,
2542 - operation: "listLabelCandidates",
2543 - allowReserve: true,
2544 - variables: { owner, name, number: input.number },
2545 - query: LABEL_CANDIDATES_GRAPHQL_QUERY,
2546 - decode: decodeLabelCandidatesJson,
2547 - });
2398 + const operation = "listLabelCandidates";
2399 + return client
2400 + .LabelCandidates({ owner, name, number: input.number })
2401 + .pipe(
2402 + graphql({ ...input, operation, allowReserve: true }),
2403 + Effect.map(toLabelCandidates),
2404 + Effect.flatMap(found({ ...input, operation })),
2405 + );
2406 },
2407
2408 setLabels: (input) => {
@@ -2587,28 +2445,22 @@ export const make = Effect.gen(function* () {
2445 });
2446 }
2447 const { owner, name } = parseRepositorySelector(input.repository);
2590 - const response = yield* graphqlRead({
2591 - cwd: input.cwd,
2592 - host: input.host,
2593 - operation: "deletePullRequestBranch",
2594 - allowReserve: true,
2595 - query: BRANCH_TO_DELETE_GRAPHQL_QUERY,
2596 - variables: { owner, name, number: input.number },
2597 - decode: decodeBranchToDelete,
2598 - });
2599 - const branch = response.data.repository.pullRequest;
2448 + const target = { ...input, operation: "deletePullRequestBranch" };
2449 + const branch = yield* client
2450 + .PullRequestBranchToDelete({ owner, name, number: input.number })
2451 + .pipe(
2452 + graphql({ ...target, allowReserve: true }),
2453 + Effect.map((result) => result.repository?.pullRequest ?? null),
2454 + Effect.flatMap(found(target)),
2455 + );
2456 if (branch.state === "OPEN") {
2457 return yield* new GitHubBranchDeletionRefusedError({
2458 number: input.number,
2459 reason: "open-pr",
2460 });
2461 }
2606 - if (
2607 - branch.headRepository === null ||
2608 - !branch.headRepository.id ||
2609 - !branch.headRefName ||
2610 - !branch.headRefOid
2611 - ) {
2462 + const repositoryId = branch.headRepository?.id;
2463 + if (!repositoryId || !branch.headRefName || !branch.headRefOid) {
2464 return yield* new GitHubBranchDeletionRefusedError({
2465 number: input.number,
2466 reason: "source-unavailable",
@@ -2621,22 +2473,17 @@ export const make = Effect.gen(function* () {
2473 });
2474 }
2475 const ref = `refs/heads/${branch.headRefName}`;
2624 - const source = yield* graphqlRead({
2625 - cwd: input.cwd,
2626 - host: input.host,
2627 - operation: "deletePullRequestBranch",
2628 - allowReserve: true,
2629 - query: SOURCE_BRANCH_GRAPHQL_QUERY,
2630 - variables: { repositoryId: branch.headRepository.id, ref },
2631 - decode: decodeSourceBranch,
2632 - });
2633 - const repository = source.data.node;
2476 + const source = yield* client
2477 + .PullRequestSourceBranch({ repositoryId, ref })
2478 + .pipe(graphql({ ...target, allowReserve: true }));
2479 + const repository = source.node?.__typename === "Repository" ? source.node : null;
2480 if (repository === null) {
2481 return yield* new GitHubBranchDeletionRefusedError({
2482 number: input.number,
2483 reason: "source-unavailable",
2484 });
2485 }
2486 + // Already gone, which is what was asked for.
2487 if (repository.ref === null) return;
2488 if (
2489 repository.defaultBranchRef === null ||
@@ -2647,19 +2494,16 @@ export const make = Effect.gen(function* () {
2494 reason: "unsafe-branch",
2495 });
2496 }
2650 - if (repository.ref.target.oid !== branch.headRefOid) {
2497 + if (repository.ref.target?.oid !== branch.headRefOid) {
2498 return yield* new GitHubBranchDeletionRefusedError({
2499 number: input.number,
2500 reason: "head-changed",
2501 });
2502 }
2656 - yield* graphql({
2657 - host: input.host,
2658 - operation: "deletePullRequestBranch",
2659 - query: DELETE_BRANCH_GRAPHQL_MUTATION,
2660 - variables: {
2503 + yield* client
2504 + .DeletePullRequestBranch({
2505 input: {
2662 - repositoryId: branch.headRepository.id,
2506 + repositoryId,
2507 refUpdates: [
2508 {
2509 name: ref,
@@ -2668,26 +2512,26 @@ export const make = Effect.gen(function* () {
2512 },
2513 ],
2514 },
2671 - },
2672 - });
2515 + })
2516 + .pipe(graphql(target));
2517 });
2518 }
2519 if (input.stackNumber !== undefined)
2520 return runGitHubStackAction({ ...input, stackNumber: input.stackNumber }).pipe(
2677 - Effect.provideService(GitHubApi.GitHubApi, api),
2521 + Effect.provideService(GitHubRest.GitHubRest, api),
2522 + Effect.provideService(GitHubRequestPolicy.GitHubRequestPolicy, policy),
2523 + Effect.provideService(HttpClient.HttpClient, httpClient),
2524 Effect.provideService(SourceControlHost.SourceControlHost, sourceControlHost),
2525 Effect.provideService(FileSystem.FileSystem, fileSystem),
2526 );
2527 if (input.action === "revert") {
2528 return pullRequestNodeId({ ...input, operation: "revertPullRequest" }).pipe(
2529 Effect.flatMap((pullRequestId) =>
2684 - graphql({
2685 - host: input.host,
2686 - operation: "revertPullRequest",
2687 - query: REVERT_PULL_REQUEST_GRAPHQL_MUTATION,
2688 - variables: { pullRequestId },
2689 - }),
2530 + client
2531 + .RevertPullRequest({ pullRequestId })
2532 + .pipe(graphql({ ...input, operation: "revertPullRequest" })),
2533 ),
2534 + Effect.asVoid,
2535 );
2536 }
2537 if (input.action === "approve-workflows") {
@@ -2770,15 +2614,11 @@ export const make = Effect.gen(function* () {
2614 );
2615 }
2616 const action = input.action;
2773 - if (action in SIMPLE_ACTION_MUTATIONS) {
2617 + if (action in simpleActionMutations) {
2618 + const mutate = simpleActionMutations[action as keyof typeof simpleActionMutations];
2619 return pullRequestNodeId({ ...input, operation: "runPullRequestAction" }).pipe(
2620 Effect.flatMap((pullRequestId) =>
2776 - graphql({
2777 - host: input.host,
2778 - operation: "runPullRequestAction",
2779 - query: SIMPLE_ACTION_MUTATIONS[action as keyof typeof SIMPLE_ACTION_MUTATIONS],
2780 - variables: { pullRequestId },
2781 - }),
2621 + mutate(pullRequestId).pipe(graphql({ ...input, operation: "runPullRequestAction" })),
2622 ),
2623 );
2624 }
@@ -2786,52 +2626,46 @@ export const make = Effect.gen(function* () {
2626 const { owner, name } = parseRepositorySelector(input.repository);
2627 // Read fresh rather than from the node id cache: merging and updating act on the head
2628 // as it stands now, and the merge queue decides which mutation a merge is.
2789 - const state = yield* graphqlRead({
2790 - cwd: input.cwd,
2791 - host: input.host,
2792 - operation: "runPullRequestAction",
2793 - allowReserve: true,
2794 - query: ACTION_STATE_GRAPHQL_QUERY,
2795 - variables: {
2629 + const target = { ...input, operation: "runPullRequestAction" };
2630 + const state = yield* client
2631 + .PullRequestActionState({
2632 owner,
2633 name,
2634 number: input.number,
2635 headRef: `refs/pull/${input.number}/head`,
2800 - },
2801 - decode: decodeActionState,
2802 - });
2636 + })
2637 + .pipe(
2638 + graphql({ ...target, allowReserve: true }),
2639 + Effect.map((result) => result.repository?.pullRequest ?? null),
2640 + Effect.flatMap(found(target)),
2641 + );
2642 if (action === "update-branch") {
2643 // Already current is done, the way `gh pr update-branch` reports it.
2644 if (state.baseRef?.compare?.behindBy === 0) return;
2645 // GitHub updates with a merge commit unless asked to rebase, which is its own default.
2807 - return yield* graphql({
2808 - host: input.host,
2809 - operation: "runPullRequestAction",
2810 - query: UPDATE_BRANCH_GRAPHQL_MUTATION,
2811 - variables: {
2646 + return yield* client
2647 + .UpdatePullRequestBranch({
2648 pullRequestId: state.id,
2649 expectedHeadOid: state.headRefOid,
2650 updateMethod: input.updateMethod === "rebase" ? "REBASE" : "MERGE",
2815 - },
2816 - });
2651 + })
2652 + .pipe(graphql(target), Effect.asVoid);
2653 }
2654 let body: string | undefined;
2655 let expectedHead: string | undefined;
2656 if (input.removeAgentCreditsOnMerge === true && input.mergeMethod !== "rebase") {
2821 - const message = yield* graphqlRead({
2822 - cwd: input.cwd,
2823 - host: input.host,
2824 - operation: "runPullRequestAction",
2825 - allowReserve: true,
2826 - query: MERGE_MESSAGE_GRAPHQL_QUERY,
2827 - variables: {
2657 + const message = yield* client
2658 + .PullRequestMergeMessage({
2659 owner,
2660 name,
2661 number: input.number,
2662 method: input.mergeMethod === "squash" ? "SQUASH" : "MERGE",
2832 - },
2833 - decode: decodeMergeMessage,
2834 - });
2663 + })
2664 + .pipe(
2665 + graphql({ ...target, allowReserve: true }),
2666 + Effect.map((result) => result.repository?.pullRequest ?? null),
2667 + Effect.flatMap(found(target)),
2668 + );
2669 // GitHub's merge queue chooses its own message and ignores custom text.
2670 if (!message.isMergeQueueEnabled) {
2671 const cleaned = removeAgentCredits(message.viewerMergeBodyText);
@@ -2849,32 +2683,28 @@ export const make = Effect.gen(function* () {
2683 state.isMergeQueueEnabled === true ||
2684 (action === "enable-auto-merge" &&
2685 !IMMEDIATELY_MERGEABLE.has(state.mergeStateStatus?.toUpperCase() ?? ""));
2852 - yield* graphql({
2853 - host: input.host,
2854 - operation: "runPullRequestAction",
2855 - query: auto ? ENABLE_AUTO_MERGE_GRAPHQL_MUTATION : MERGE_PULL_REQUEST_GRAPHQL_MUTATION,
2856 - variables: {
2857 - input: {
2858 - pullRequestId: state.id,
2859 - mergeMethod: GRAPHQL_MERGE_METHODS[input.mergeMethod ?? "merge"],
2860 - ...(expectedHead === undefined ? {} : { expectedHeadOid: expectedHead }),
2861 - ...(body === undefined ? {} : { commitBody: body }),
2862 - },
2863 - },
2864 - });
2686 + const merge = {
2687 + pullRequestId: state.id,
2688 + mergeMethod: GRAPHQL_MERGE_METHODS[input.mergeMethod ?? "merge"],
2689 + ...(expectedHead === undefined ? {} : { expectedHeadOid: expectedHead }),
2690 + ...(body === undefined ? {} : { commitBody: body }),
2691 + };
2692 + yield* (
2693 + auto
2694 + ? client.EnablePullRequestAutoMerge({ input: merge }).pipe(Effect.asVoid)
2695 + : client.MergePullRequest({ input: merge }).pipe(Effect.asVoid)
2696 + ).pipe(graphql(target));
2697 });
2698 },
2699
2700 commentOnPullRequest: (input) =>
2701 pullRequestNodeId({ ...input, operation: "commentOnPullRequest" }).pipe(
2702 Effect.flatMap((subjectId) =>
2871 - graphql({
2872 - host: input.host,
2873 - operation: "commentOnPullRequest",
2874 - query: ADD_COMMENT_GRAPHQL_MUTATION,
2875 - variables: { subjectId, body: input.body },
2876 - }),
2703 + client
2704 + .AddComment({ subjectId, body: input.body })
2705 + .pipe(graphql({ ...input, operation: "commentOnPullRequest" })),
2706 ),
2707 + Effect.asVoid,
2708 ),
2709
2710 submitReview: (input) => {
@@ -2897,27 +2727,31 @@ export const make = Effect.gen(function* () {
2727 },
2728
2729 replyToReviewThread: (input) =>
2900 - graphql({
2901 - host: input.host,
2902 - operation: "replyToReviewThread",
2903 - query: REVIEW_THREAD_REPLY_GRAPHQL_MUTATION,
2904 - variables: { threadId: input.threadId, body: input.body },
2905 - }),
2730 + client
2731 + .AddReviewThreadReply({ threadId: input.threadId, body: input.body })
2732 + .pipe(graphql({ ...input, operation: "replyToReviewThread" }), Effect.asVoid),
2733
2734 getPullRequestFilesViewed: (input) => {
2735 const { owner, name } = parseRepositorySelector(input.repository);
2909 - return readGraphQlPages(
2910 - (after) =>
2911 - graphqlRead({
2912 - cwd: input.cwd,
2913 - host: input.host,
2914 - operation: "getPullRequestFilesViewed",
2915 - variables: { owner, name, number: input.number, after },
2916 - query: PULL_REQUEST_FILES_VIEWED_GRAPHQL_QUERY,
2917 - decode: decodePullRequestFilesViewedJson,
2918 - }),
2919 - { maxPages: FILES_VIEWED_MAX_PAGES, nextCursor: (page) => page.nextCursor },
2736 + const target = { ...input, operation: "getPullRequestFilesViewed" };
2737 + return readPages(
2738 + GraphQLClient.pages(client.PullRequestFilesViewed, {
2739 + variables: { owner, name, number: input.number },
2740 + connection: (result) => {
2741 + const page = toPullRequestFilesViewedPage(result);
2742 + return {
2743 + ...page,
2744 + pageInfo: { hasNextPage: page.nextCursor !== null, endCursor: page.nextCursor },
2745 + };
2746 + },
2747 + }),
2748 + {
2749 + ...target,
2750 + maxPages: FILES_VIEWED_MAX_PAGES,
2751 + hasNextPage: (page) => page.nextCursor !== null,
2752 + },
2753 ).pipe(
2754 + graphql(target),
2755 Effect.map(({ pages, truncated }) => ({
2756 files: pages.flatMap((page) => page.files),
2757 truncated,
@@ -2927,25 +2761,30 @@ export const make = Effect.gen(function* () {
2761
2762 setPullRequestFilesViewed: (input) => {
2763 if (input.files.length === 0) return Effect.void;
2930 - return pullRequestNodeId({ ...input, operation: "setPullRequestFilesViewed" }).pipe(
2931 - Effect.flatMap((pullRequestId) => {
2932 - const mutation = buildSetFilesViewedGraphQlMutation(pullRequestId, input.files);
2933 - return mutation === null
2934 - ? Effect.void
2935 - : graphql({ host: input.host, operation: "setPullRequestFilesViewed", ...mutation });
2936 - }),
2764 + const target = { ...input, operation: "setPullRequestFilesViewed" };
2765 + return pullRequestNodeId(target).pipe(
2766 + Effect.flatMap((pullRequestId) =>
2767 + // One aliased document for the burst: top-level mutation fields run in write order,
2768 + // so the last word about a path is the one that sticks.
2769 + Effect.forEach(
2770 + input.files,
2771 + (file) =>
2772 + GraphQLResolver.request(
2773 + { pullRequestId, path: file.path, viewed: file.viewed },
2774 + setFileViewedResolver,
2775 + ),
2776 + { concurrency: "unbounded", discard: true },
2777 + ),
2778 + ),
2779 + graphql(target),
2780 );
2781 },
2782
2783 setReviewThreadResolution: (input) =>
2941 - graphql({
2942 - host: input.host,
2943 - operation: "setReviewThreadResolution",
2944 - query: input.resolved
2945 - ? RESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION
2946 - : UNRESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION,
2947 - variables: { threadId: input.threadId },
2948 - }),
2784 + (input.resolved
2785 + ? client.ResolveReviewThread({ threadId: input.threadId }).pipe(Effect.asVoid)
2786 + : client.UnresolveReviewThread({ threadId: input.threadId }).pipe(Effect.asVoid)
2787 + ).pipe(graphql({ ...input, operation: "setReviewThreadResolution" })),
2788
2789 setReaction: (input) => {
2790 const givenSubjectId = input.subjectId;
@@ -2969,33 +2808,31 @@ export const make = Effect.gen(function* () {
2808 ),
2809 );
2810 return subjectId.pipe(
2972 - Effect.flatMap((subjectId) =>
2973 - graphql({
2974 - host: input.host,
2975 - operation: "setReaction",
2976 - query: input.reacted ? ADD_REACTION_GRAPHQL_MUTATION : REMOVE_REACTION_GRAPHQL_MUTATION,
2977 - variables: { subjectId, content: gitHubReactionContent(input.content) },
2978 - }),
2979 - ),
2811 + Effect.flatMap((subjectId) => {
2812 + const variables = { subjectId, content: gitHubReactionContent(input.content) };
2813 + return (
2814 + input.reacted
2815 + ? client.AddReaction(variables).pipe(Effect.asVoid)
2816 + : client.RemoveReaction(variables).pipe(Effect.asVoid)
2817 + ).pipe(graphql({ ...input, operation: "setReaction" }));
2818 + }),
2819 );
2820 },
2821
2822 updatePullRequest: (input) =>
2823 pullRequestNodeId({ ...input, operation: "updatePullRequest" }).pipe(
2824 Effect.flatMap((pullRequestId) =>
2986 - graphql({
2987 - host: input.host,
2988 - operation: "updatePullRequest",
2989 - query: UPDATE_PULL_REQUEST_GRAPHQL_MUTATION,
2990 - // A field the caller did not name is left out of the request entirely, so GitHub
2991 - // keeps the words that are there rather than being asked for an empty one.
2992 - variables: {
2825 + client
2826 + .UpdatePullRequest({
2827 pullRequestId,
2828 + // A field the caller did not name is left out of the request entirely, so GitHub
2829 + // keeps the words that are there rather than being asked for an empty one.
2830 ...(input.title === undefined ? {} : { title: input.title }),
2831 ...(input.body === undefined ? {} : { body: input.body }),
2996 - },
2997 - }),
2832 + })
2833 + .pipe(graphql({ ...input, operation: "updatePullRequest" })),
2834 ),
2835 + Effect.asVoid,
2836 ),
2837
2838 updateComment: (input) =>
@@ -3017,17 +2854,14 @@ export const make = Effect.gen(function* () {
2854 }),
2855 ),
2856 ),
3020 - Effect.flatMap((commentId) =>
3021 - graphql({
3022 - host: input.host,
3023 - operation: "updateComment",
3024 - query:
3025 - input.kind === "issue-comment"
3026 - ? UPDATE_ISSUE_COMMENT_GRAPHQL_MUTATION
3027 - : UPDATE_REVIEW_COMMENT_GRAPHQL_MUTATION,
3028 - variables: { commentId, body: input.body },
3029 - }),
3030 - ),
2857 + Effect.flatMap((commentId) => {
2858 + const variables = { commentId, body: input.body };
2859 + return (
2860 + input.kind === "issue-comment"
2861 + ? client.UpdateIssueComment(variables).pipe(Effect.asVoid)
2862 + : client.UpdateReviewComment(variables).pipe(Effect.asVoid)
2863 + ).pipe(graphql({ ...input, operation: "updateComment" }));
2864 + }),
2865 ),
2866 });
2867 });
packages/source-control-github/src/server/GitHubPullRequestProvider.test.ts
+4 -4
@@ -6,7 +6,7 @@ import * as Result from "effect/Result";
6 import type { PullRequestReaction } from "@t3tools/contracts";
7
8 import { decodePullRequestDetailJson } from "./gitHubPullRequestJson.ts";
9 -import * as GitHubApi from "./GitHubApi.ts";
9 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
10 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
11 import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
12 import type { GitHubPullRequestCore } from "./gitHubPullRequestJson.ts";
@@ -376,7 +376,7 @@ describe("gitHubViewerPermissions", () => {
376 number: 7,
377 })
378 .pipe(
379 - Effect.provideService(GitHubApi.PinnedGitHubCredential, {
379 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, {
380 host: "github.com",
381 token: Redacted.make("credential"),
382 credentialFingerprint: fingerprint,
@@ -423,7 +423,7 @@ describe("gitHubViewerPermissions", () => {
423 commits: [],
424 }).pipe(
425 Effect.flatMap((detail) =>
426 - GitHubApi.PinnedGitHubCredential.pipe(
426 + GitHubRequestPolicy.PinnedGitHubCredential.pipe(
427 Effect.map((credential) => ({
428 ...detail,
429 viewerAccess: {
@@ -711,7 +711,7 @@ it.effect("propagates workflow discovery rate limits", () =>
711 getPullRequestDetail: () => Effect.succeed(openDetail),
712 listWorkflowRunsRequiringApproval: () =>
713 Effect.fail(
714 - new GitHubApi.GitHubApiRateLimitError({
714 + new GitHubRequestPolicy.GitHubApiRateLimitError({
715 host: "github.com",
716 operation: "listWorkflowRunsRequiringApproval",
717 }),
packages/source-control-github/src/server/GitHubRequestPolicy.ts new
+357
@@ -0,0 +1,357 @@
1 +import { SourceControlProviderKind } from "@t3tools/contracts";
2 +import * as Cause from "effect/Cause";
3 +import * as Clock from "effect/Clock";
4 +import * as Context from "effect/Context";
5 +import * as Duration from "effect/Duration";
6 +import * as Effect from "effect/Effect";
7 +import * as Layer from "effect/Layer";
8 +import * as Redacted from "effect/Redacted";
9 +import * as Schema from "effect/Schema";
10 +import * as Semaphore from "effect/Semaphore";
11 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
12 +
13 +import * as GitHubCredentials from "./GitHubCredentials.ts";
14 +import * as GitHubQuota from "./GitHubQuota.ts";
15 +
16 +const DEFAULT_TIMEOUT = Duration.seconds(30);
17 +/** Polite to GitHub's secondary limits, which punish bursts of concurrent requests. */
18 +const CONCURRENCY = 8;
19 +/** The headers every GitHub request carries besides its token. */
20 +const REQUEST_HEADERS = { "x-github-api-version": "2022-11-28", "user-agent": "t3code" };
21 +
22 +/**
23 + * A credential already verified for one host. Every request made under it must target that
24 + * host, so a page cannot read one account's data with another's token mid-flight. Server-local:
25 + * never put its value in RPC payloads or cache keys.
26 + */
27 +export const PinnedGitHubCredential = Context.Reference<{
28 + readonly host: string;
29 + readonly token: Redacted.Redacted<string>;
30 + readonly credentialFingerprint: string;
31 +} | null>("@t3tools/source-control-github/server/GitHubRequestPolicy/PinnedGitHubCredential", {
32 + defaultValue: () => null,
33 +});
34 +
35 +export class GitHubApiRequestError extends Schema.TaggedError<GitHubApiRequestError>()(
36 + "GitHubApiRequestError",
37 + { host: Schema.String, operation: Schema.String, cause: Schema.Defect() },
38 +) {
39 + override get message(): string {
40 + return `Could not reach GitHub at ${this.host}.`;
41 + }
42 +}
43 +
44 +export class GitHubApiAuthenticationError extends Schema.TaggedError<GitHubApiAuthenticationError>()(
45 + "GitHubApiAuthenticationError",
46 + { host: Schema.String, operation: Schema.String },
47 +) {
48 + override get message(): string {
49 + return `GitHub refused the credential for ${this.host}. Run \`gh auth login --hostname ${this.host}\` and retry.`;
50 + }
51 +}
52 +
53 +export class GitHubApiRateLimitError extends Schema.TaggedError<GitHubApiRateLimitError>()(
54 + "GitHubApiRateLimitError",
55 + {
56 + host: Schema.String,
57 + operation: Schema.String,
58 + retryAt: Schema.optionalKey(Schema.Finite),
59 + },
60 +) {
61 + override get message(): string {
62 + return "GitHub API rate limit exceeded.";
63 + }
64 +}
65 +
66 +export class GitHubApiNotFoundError extends Schema.TaggedError<GitHubApiNotFoundError>()(
67 + "GitHubApiNotFoundError",
68 + { host: Schema.String, operation: Schema.String },
69 +) {
70 + override get message(): string {
71 + return "GitHub could not find the requested resource, or the credential cannot see it.";
72 + }
73 +}
74 +
75 +/**
76 + * GitHub answered with a failure that is none of the above. `githubErrors` carries GitHub's own
77 + * error messages, from a GraphQL `errors` list or a REST `message`/`errors` body: they name the
78 + * field and the reason ("A pull request already exists for acme:feature"), never a token.
79 + */
80 +export class GitHubApiResponseError extends Schema.TaggedError<GitHubApiResponseError>()(
81 + "GitHubApiResponseError",
82 + {
83 + host: Schema.String,
84 + operation: Schema.String,
85 + status: Schema.Int,
86 + githubErrors: Schema.optionalKey(Schema.Array(Schema.String)),
87 + },
88 +) {
89 + override get message(): string {
90 + return this.githubErrors !== undefined && this.githubErrors.length > 0
91 + ? `GitHub returned an error: ${this.githubErrors.join("; ")}`
92 + : `GitHub returned HTTP ${this.status}.`;
93 + }
94 +}
95 +
96 +export type GitHubApiError =
97 + | GitHubCredentials.GitHubCredentialUnavailableError
98 + | GitHubApiRequestError
99 + | GitHubApiAuthenticationError
100 + | GitHubApiRateLimitError
101 + | GitHubApiNotFoundError
102 + | GitHubApiResponseError
103 + | SourceControlRateLimit.SourceControlRateLimitPausedError;
104 +
105 +export function normalizeHost(host: string): string {
106 + return host.trim().toLowerCase();
107 +}
108 +
109 +/**
110 + * Where the API for a host lives. github.com and GHE.com data residency serve it from an `api.`
111 + * subdomain; GitHub Enterprise Server serves it under `/api` on the instance itself.
112 + */
113 +export function gitHubApiUrls(host: string): { readonly rest: string; readonly graphql: string } {
114 + const normalized = normalizeHost(host);
115 + if (normalized === "github.com") {
116 + return { rest: "https://api.github.com", graphql: "https://api.github.com/graphql" };
117 + }
118 + if (normalized.endsWith(".ghe.com")) {
119 + return {
120 + rest: `https://api.${normalized}`,
121 + graphql: `https://api.${normalized}/graphql`,
122 + };
123 + }
124 + return { rest: `https://${normalized}/api/v3`, graphql: `https://${normalized}/api/graphql` };
125 +}
126 +
127 +/** The numeric rate-limit headers GitHub sends, as span attributes. */
128 +function rateLimitAttributes(
129 + headers: Readonly<Record<string, string | undefined>>,
130 +): Record<string, number | string> {
131 + const attributes: Record<string, number | string> = {};
132 + for (const [header, name] of [
133 + ["x-ratelimit-limit", "github.ratelimit.limit"],
134 + ["x-ratelimit-remaining", "github.ratelimit.remaining"],
135 + ["x-ratelimit-used", "github.ratelimit.used"],
136 + ["x-ratelimit-reset", "github.ratelimit.reset"],
137 + ] as const) {
138 + const value = Number(headers[header]);
139 + if (headers[header] !== undefined && Number.isFinite(value)) attributes[name] = value;
140 + }
141 + const resource = headers["x-ratelimit-resource"];
142 + if (resource !== undefined) attributes["github.ratelimit.resource"] = resource;
143 + return attributes;
144 +}
145 +
146 +/** The pause GitHub asked for, from `retry-after` or the primary limit's reset. */
147 +function retryAtFrom(
148 + headers: Readonly<Record<string, string | undefined>>,
149 + now: number,
150 +): number | undefined {
151 + const fromRetryAfter = SourceControlRateLimit.retryAtFromHeader(headers["retry-after"], now);
152 + if (fromRetryAfter !== undefined) return fromRetryAfter;
153 + const reset = Number(headers["x-ratelimit-reset"]) * 1_000;
154 + return Number.isFinite(reset) && reset > now ? reset : undefined;
155 +}
156 +
157 +/**
158 + * Whether GitHub refused a request for its rate limit. A GraphQL answer can say so with HTTP 200:
159 + * a `RATE_LIMITED` error, or an exhausted quota that answers an untyped "API rate limit already
160 + * exceeded" error, which the headers confirm.
161 + */
162 +export function isRateLimited(input: {
163 + readonly status: number;
164 + readonly headers: Readonly<Record<string, string | undefined>>;
165 + /** The GraphQL `errors` list, when the answer is a GraphQL one and has any. */
166 + readonly graphqlErrors?: ReadonlyArray<{ readonly type?: unknown; readonly message?: unknown }>;
167 + readonly body?: string;
168 +}): boolean {
169 + const { status, headers, graphqlErrors: errors } = input;
170 + return (
171 + status === 429 ||
172 + (errors !== undefined &&
173 + (headers["x-ratelimit-remaining"] === "0" ||
174 + errors.some(
175 + (error) =>
176 + error.type === "RATE_LIMITED" ||
177 + (typeof error.message === "string" &&
178 + /rate limit (already )?exceeded/i.test(error.message)),
179 + ))) ||
180 + (status === 403 &&
181 + (headers["x-ratelimit-remaining"] === "0" ||
182 + headers["retry-after"] !== undefined ||
183 + /rate limit/i.test(input.body ?? "")))
184 + );
185 +}
186 +
187 +/**
188 + * What one GitHub answer means, as the transport that read it decided: `Ok` carries what the
189 + * request returns; every other verdict fails with the `GitHubApi*Error` that says why.
190 + */
191 +export type GitHubAnswer<A> = {
192 + /** Unset when the transport reported none. */
193 + readonly status: number | undefined;
194 + readonly headers: Readonly<Record<string, string | undefined>>;
195 +} & (
196 + | { readonly _tag: "Ok"; readonly value: A }
197 + | { readonly _tag: "RateLimited" | "Unauthorized" | "NotFound" }
198 + | { readonly _tag: "Failed"; readonly messages?: ReadonlyArray<string> | undefined }
199 +);
200 +
201 +export interface GitHubRequest {
202 + readonly host: string;
203 + readonly operation: string;
204 + /** The quota the request spends: `core` for REST, `graphql` for GraphQL. */
205 + readonly resource: string;
206 + readonly allowReserve: boolean;
207 + /** Covers sending and reading the answer. Defaults to 30 seconds. */
208 + readonly timeout?: Duration.Input | undefined;
209 +}
210 +
211 +/**
212 + * What every GitHub request goes through, REST and GraphQL alike: the host's credential, one
213 + * shared pool of request slots, the quota reserve and the host-wide pause before it is sent, and
214 + * what GitHub's answer says about them after. Each transport only sends and reads its answer.
215 + */
216 +export class GitHubRequestPolicy extends Context.Service<
217 + GitHubRequestPolicy,
218 + {
219 + /**
220 + * Sends one request. `send` receives the headers it must carry (the token and GitHub's API
221 + * version) and reports the answer; a failure of its own passes through untouched.
222 + */
223 + readonly request: <A, E, R>(
224 + input: GitHubRequest,
225 + send: (headers: Readonly<Record<string, string>>) => Effect.Effect<GitHubAnswer<A>, E, R>,
226 + ) => Effect.Effect<A, E | GitHubApiError, R>;
227 + /** The credential a request to `host` would carry right now. */
228 + readonly credential: (
229 + host: string,
230 + ) => Effect.Effect<
231 + { readonly token: Redacted.Redacted<string>; readonly fingerprint: string },
232 + GitHubApiError
233 + >;
234 + }
235 +>()("@t3tools/source-control-github/server/GitHubRequestPolicy") {}
236 +
237 +/** @public Service construction is part of the canonical Effect module API. */
238 +export const make = Effect.gen(function* () {
239 + const credentials = yield* GitHubCredentials.GitHubCredentials;
240 + const quota = yield* GitHubQuota.GitHubQuota;
241 + const limits = yield* SourceControlRateLimit.SourceControlRateLimit;
242 + const slots = yield* Semaphore.make(CONCURRENCY);
243 +
244 + const credential: GitHubRequestPolicy["Service"]["credential"] = Effect.fn(
245 + "GitHubRest.credential",
246 + )(function* (host) {
247 + const normalized = normalizeHost(host);
248 + const pinned = yield* PinnedGitHubCredential;
249 + if (pinned !== null) {
250 + // A pinned page only ever talks to the host it verified.
251 + if (pinned.host !== normalized) {
252 + return yield* new GitHubApiAuthenticationError({
253 + host: normalized,
254 + operation: "credential",
255 + });
256 + }
257 + return { token: pinned.token, fingerprint: pinned.credentialFingerprint };
258 + }
259 + const held = yield* credentials.get(normalized);
260 + return { token: held.token, fingerprint: held.fingerprint };
261 + });
262 +
263 + const request: GitHubRequestPolicy["Service"]["request"] = <A, E, R>(
264 + input: GitHubRequest,
265 + send: (headers: Readonly<Record<string, string>>) => Effect.Effect<GitHubAnswer<A>, E, R>,
266 + ) =>
267 + Effect.gen(function* () {
268 + const host = normalizeHost(input.host);
269 + const context = { host, operation: input.operation };
270 + yield* Effect.annotateCurrentSpan({
271 + "github.host": host,
272 + "github.operation": input.operation,
273 + });
274 + const { token, fingerprint } = yield* credential(host);
275 + const scope = yield* SourceControlRateLimit.CredentialScope;
276 + // A refusal pauses the whole host, whichever quota it spent: the key PullRequestService
277 + // records its own backoff under.
278 + const key = { provider: SourceControlProviderKind.make("github"), host };
279 +
280 + const settle = (lease: number, answer: GitHubAnswer<A>) =>
281 + Effect.gen(function* () {
282 + yield* quota.observe(host, answer.headers);
283 + yield* Effect.annotateCurrentSpan({
284 + ...(answer.status === undefined ? {} : { "http.response.status_code": answer.status }),
285 + ...rateLimitAttributes(answer.headers),
286 + });
287 + switch (answer._tag) {
288 + case "Ok":
289 + yield* limits.recordSuccess({ ...key, lease });
290 + return answer.value;
291 + case "RateLimited": {
292 + const retryAt = retryAtFrom(answer.headers, yield* Clock.currentTimeMillis);
293 + yield* limits.recordRateLimit({ ...key, lease, retryAt });
294 + yield* Effect.annotateCurrentSpan({
295 + "github.rate_limited": true,
296 + ...(retryAt === undefined ? {} : { "github.retry_at": retryAt }),
297 + });
298 + return yield* new GitHubApiRateLimitError({
299 + ...context,
300 + ...(retryAt === undefined ? {} : { retryAt }),
301 + });
302 + }
303 + case "Unauthorized":
304 + // The source may hold a newer token than the one that was refused.
305 + yield* credentials.invalidate(host);
306 + return yield* new GitHubApiAuthenticationError(context);
307 + case "NotFound":
308 + return yield* new GitHubApiNotFoundError(context);
309 + case "Failed":
310 + return yield* new GitHubApiResponseError({
311 + ...context,
312 + status: answer.status ?? 200,
313 + ...(answer.messages === undefined ? {} : { githubErrors: answer.messages }),
314 + });
315 + }
316 + });
317 +
318 + const run = Effect.gen(function* () {
319 + const lease = yield* quota
320 + .admit(host, input.resource, { allowReserve: input.allowReserve })
321 + .pipe(
322 + Effect.andThen(
323 + limits.check(key, input.allowReserve ? { allowPaused: true } : undefined),
324 + ),
325 + Effect.tapError((paused) =>
326 + Effect.annotateCurrentSpan({
327 + "github.paused": true,
328 + "github.retry_at": paused.retryAt,
329 + }),
330 + ),
331 + );
332 + // One deadline covers the headers and the body: a host that answers headers and then
333 + // stalls must not hold a shared slot for undici's own five-minute body timeout.
334 + const answer = yield* send({
335 + ...REQUEST_HEADERS,
336 + authorization: `Bearer ${Redacted.value(token)}`,
337 + }).pipe(
338 + Effect.timeoutOrElse({
339 + duration: input.timeout ?? DEFAULT_TIMEOUT,
340 + orElse: () =>
341 + Effect.fail(
342 + new GitHubApiRequestError({ ...context, cause: new Cause.TimeoutError() }),
343 + ),
344 + }),
345 + );
346 + return yield* settle(lease, answer);
347 + });
348 + // The rate-limit scope follows the credential, so a pause on one account never blocks another.
349 + return yield* slots
350 + .withPermit(run)
351 + .pipe(Effect.provideService(SourceControlRateLimit.CredentialScope, scope || fingerprint));
352 + });
353 +
354 + return GitHubRequestPolicy.of({ request, credential });
355 +});
356 +
357 +export const layer = Layer.effect(GitHubRequestPolicy, make);
packages/source-control-github/src/server/GitHubRest.test.ts renamed
+49 -212
@@ -10,7 +10,8 @@ import { ChildProcessSpawner } from "effect/process";
10 import { VcsProcessSpawnError, VcsProcessTimeoutError } from "@t3tools/contracts";
11 import { HttpClient, HttpClientResponse, type HttpClientRequest } from "effect/http";
12
13 -import * as GitHubApi from "./GitHubApi.ts";
13 +import * as GitHubRest from "./GitHubRest.ts";
14 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
15 import * as GitHubCredentials from "./GitHubCredentials.ts";
16 import * as GitHubQuota from "./GitHubQuota.ts";
17 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
@@ -51,7 +52,7 @@ function harness(respond: (request: HttpClientRequest.HttpClientRequest) => Resp
52 return Effect.succeed(HttpClientResponse.fromWeb(request, respond(request)));
53 }),
54 );
54 - const layer = GitHubApi.layer.pipe(
55 + const layer = GitHubRest.layer.pipe(
56 Layer.provide(Layer.mergeAll(credentials, http)),
57 Layer.provideMerge(GitHubQuota.layer),
58 Layer.provideMerge(SourceControlRateLimit.layer),
@@ -72,14 +73,14 @@ const json = (body: unknown, init?: ResponseInit) =>
73
74 describe("gitHubApiUrls", () => {
75 it("maps github.com, GHE.com and GitHub Enterprise Server", () => {
75 - expect(GitHubApi.gitHubApiUrls("GitHub.com")).toEqual({
76 + expect(GitHubRequestPolicy.gitHubApiUrls("GitHub.com")).toEqual({
77 rest: "https://api.github.com",
78 graphql: "https://api.github.com/graphql",
79 });
79 - expect(GitHubApi.gitHubApiUrls("acme.ghe.com").graphql).toBe(
80 + expect(GitHubRequestPolicy.gitHubApiUrls("acme.ghe.com").graphql).toBe(
81 "https://api.acme.ghe.com/graphql",
82 );
82 - expect(GitHubApi.gitHubApiUrls("git.acme.internal")).toEqual({
83 + expect(GitHubRequestPolicy.gitHubApiUrls("git.acme.internal")).toEqual({
84 rest: "https://git.acme.internal/api/v3",
85 graphql: "https://git.acme.internal/api/graphql",
86 });
@@ -105,184 +106,43 @@ describe("environmentToken", () => {
106 });
107 });
108
108 -describe("GitHubApi", () => {
109 - it.effect("sends GraphQL with the token, and the document as written", () => {
110 - const { layer, requests } = harness(() => json({ data: { viewer: { login: "julius" } } }));
111 - return Effect.gen(function* () {
112 - yield* TestClock.setTime(NOW);
113 - const api = yield* GitHubApi.GitHubApi;
114 - const body = yield* api.graphql({
115 - host: "github.com",
116 - operation: "viewer",
117 - query: "query { viewer { login } }",
118 - });
119 - expect(body).toContain('"login":"julius"');
120 - expect(requests[0]!.url).toBe("https://api.github.com/graphql");
121 - expect(requests[0]!.headers.authorization).toBe("Bearer first");
122 - // No `rateLimit` selection is added: the quota is read off the response headers.
123 - const sent = requests[0]!.body;
124 - expect(sent._tag === "Uint8Array" ? new TextDecoder().decode(sent.body) : "").toContain(
125 - '"query":"query { viewer { login } }"',
126 - );
127 - }).pipe(Effect.provide(layer));
128 - });
129 -
130 - it.effect("resolves GraphQL credentials once per request and refreshes after refusal", () => {
131 - const { layer, requests, invalidations, credentialReads } = harness((request) =>
132 - request.headers.authorization === "Bearer first"
133 - ? new Response(null, { status: 401 })
134 - : json({ data: { viewer: { login: "julius" } } }),
135 - );
136 - return Effect.gen(function* () {
137 - const api = yield* GitHubApi.GitHubApi;
138 - const input = {
139 - host: "github.com",
140 - operation: "viewer",
141 - query: "query { viewer { login } }",
142 - };
143 - const refused = yield* Effect.flip(api.graphql(input));
144 - expect(refused._tag).toBe("GitHubApiAuthenticationError");
145 - expect(credentialReads()).toBe(1);
146 - expect(invalidations()).toBe(1);
147 -
148 - const body = yield* api.graphql(input);
149 - expect(body).toContain('"login":"julius"');
150 - expect(credentialReads()).toBe(2);
151 - expect(requests.map((request) => request.headers.authorization)).toEqual([
152 - "Bearer first",
153 - "Bearer second",
154 - ]);
155 - }).pipe(Effect.provide(layer));
156 - });
157 -
158 - it.effect(
159 - "traces the operation, path, query and quota, never the query string or variables",
160 - () => {
161 - const spans: Array<Tracer.NativeSpan> = [];
162 - const tracer = Tracer.make({
163 - span: (options) => {
164 - const span = new Tracer.NativeSpan(options);
165 - spans.push(span);
166 - return span;
167 - },
168 - });
169 - const { layer } = harness((request) =>
170 - request.url.endsWith("/graphql")
171 - ? json(
172 - { data: { viewer: { login: "julius" } } },
173 - { headers: { "x-ratelimit-remaining": "4990", "x-ratelimit-resource": "graphql" } },
174 - )
175 - : json({ ok: true }, { headers: { "x-ratelimit-remaining": "4800" } }),
176 - );
177 - return Effect.gen(function* () {
178 - yield* TestClock.setTime(NOW);
179 - const api = yield* GitHubApi.GitHubApi;
180 - yield* api.graphql({
181 - host: "github.com",
182 - operation: "getPullRequestDetail",
183 - query: "query($body: String!) { viewer { login } }",
184 - variables: { body: "secret user text" },
185 - });
186 - yield* api.rest({
187 - host: "github.com",
188 - operation: "listWorkflowRuns",
189 - path: "repos/acme/web/actions/runs?head_sha=abc123&branch=feat%2Fx",
190 - });
191 - const byName = (name: string) => spans.filter((span) => span.name === name);
192 - const graphql = Object.fromEntries(byName("GitHubApi.graphql")[0]!.attributes);
193 - expect(graphql).toMatchObject({
194 - "github.operation": "getPullRequestDetail",
195 - "github.graphql.query": "query($body: String!) { viewer { login } }",
196 - });
197 - expect(Object.fromEntries(byName("GitHubApi.send")[0]!.attributes)).toMatchObject({
198 - "github.ratelimit.remaining": 4990,
199 - "github.ratelimit.resource": "graphql",
200 - });
201 - expect(String(graphql["github.graphql.query_hash"])).toMatch(/^[0-9a-f]{8}$/);
202 - const rest = Object.fromEntries(byName("GitHubApi.send")[1]!.attributes);
203 - expect(rest).toMatchObject({
204 - "github.operation": "listWorkflowRuns",
205 - "github.kind": "rest",
206 - "url.path": "/repos/acme/web/actions/runs",
207 - "http.response.status_code": 200,
208 - "github.ratelimit.remaining": 4800,
209 - });
210 - // Nothing recorded carries the query string, the variables, or the token.
211 - const everything = spans
212 - .flatMap((span) => [...span.attributes].map(([key, value]) => `${key}=${String(value)}`))
213 - .join("\n");
214 - expect(everything).not.toContain("head_sha");
215 - expect(everything).not.toContain("secret user text");
216 - expect(everything).not.toContain("first");
217 - expect(spans.some((span) => span.attributes.has("url.full"))).toBe(false);
218 - }).pipe(Effect.provide(layer), Effect.withTracer(tracer));
219 - },
220 - );
221 -
222 - it.effect("fails a GraphQL answer that carries errors, naming GitHub's reason", () => {
109 +describe("GitHubRest", () => {
110 + it.effect("traces the operation, path and quota, never the query string or the token", () => {
111 + const spans: Array<Tracer.NativeSpan> = [];
112 + const tracer = Tracer.make({
113 + span: (options) => {
114 + const span = new Tracer.NativeSpan(options);
115 + spans.push(span);
116 + return span;
117 + },
118 + });
119 const { layer } = harness(() =>
224 - json({ data: null, errors: [{ type: "FORBIDDEN", message: "Resource not accessible" }] }),
225 - );
226 - return Effect.gen(function* () {
227 - const api = yield* GitHubApi.GitHubApi;
228 - const error = yield* Effect.flip(
229 - api.graphql({ host: "github.com", operation: "detail", query: "query { viewer { id } }" }),
230 - );
231 - expect(error._tag).toBe("GitHubApiResponseError");
232 - expect(error.message).toContain("Resource not accessible");
233 - }).pipe(Effect.provide(layer));
234 - });
235 -
236 - it.effect(
237 - "reads a NOT_FOUND answer with another error as a failure, not a missing resource",
238 - () => {
239 - const { layer } = harness(() =>
240 - json({
241 - data: null,
242 - errors: [
243 - { type: "NOT_FOUND", message: "Could not resolve" },
244 - { message: "Something went wrong" },
245 - ],
246 - }),
247 - );
248 - return Effect.gen(function* () {
249 - const api = yield* GitHubApi.GitHubApi;
250 - const error = yield* Effect.flip(
251 - api.graphql({
252 - host: "github.com",
253 - operation: "detail",
254 - query: "query { viewer { id } }",
255 - }),
256 - );
257 - expect(error._tag).toBe("GitHubApiResponseError");
258 - }).pipe(Effect.provide(layer));
259 - },
260 - );
261 -
262 - it.effect("pauses the host after a GraphQL RATE_LIMITED answer until the reset", () => {
263 - const reset = Math.floor(NOW / 1000) + 600;
264 - const { layer, requests } = harness(() =>
265 - json(
266 - { errors: [{ type: "RATE_LIMITED", message: "API rate limit exceeded" }] },
267 - { headers: { "x-ratelimit-remaining": "0", "x-ratelimit-reset": String(reset) } },
268 - ),
120 + json({ ok: true }, { headers: { "x-ratelimit-remaining": "4800" } }),
121 );
122 return Effect.gen(function* () {
123 yield* TestClock.setTime(NOW);
272 - const api = yield* GitHubApi.GitHubApi;
273 - const first = yield* Effect.flip(
274 - api.graphql({ host: "github.com", operation: "summary", query: "query { viewer { id } }" }),
275 - );
276 - expect(first).toMatchObject({ _tag: "GitHubApiRateLimitError", retryAt: reset * 1000 });
277 - const second = yield* Effect.flip(
278 - api.rest({ host: "github.com", operation: "stack", path: "repos/acme/web/stacks" }),
279 - );
280 - expect(second).toMatchObject({
281 - _tag: "SourceControlRateLimitPausedError",
282 - retryAt: reset * 1000,
124 + const api = yield* GitHubRest.GitHubRest;
125 + yield* api.rest({
126 + host: "github.com",
127 + operation: "listWorkflowRuns",
128 + path: "repos/acme/web/actions/runs?head_sha=abc123&branch=feat%2Fx",
129 });
284 - expect(requests).toHaveLength(1);
285 - }).pipe(Effect.provide(layer));
130 + const send = spans.find((span) => span.name === "GitHubRest.send")!;
131 + expect(Object.fromEntries(send.attributes)).toMatchObject({
132 + "github.operation": "listWorkflowRuns",
133 + "github.kind": "rest",
134 + "url.path": "/repos/acme/web/actions/runs",
135 + "http.response.status_code": 200,
136 + "github.ratelimit.remaining": 4800,
137 + });
138 + // Nothing recorded carries the query string or the token.
139 + const everything = spans
140 + .flatMap((span) => [...span.attributes].map(([key, value]) => `${key}=${String(value)}`))
141 + .join("\n");
142 + expect(everything).not.toContain("head_sha");
143 + expect(everything).not.toContain("first");
144 + expect(spans.some((span) => span.attributes.has("url.full"))).toBe(false);
145 + }).pipe(Effect.provide(layer), Effect.withTracer(tracer));
146 });
147
148 it.effect("keeps the last tenth of a quota for interactive requests until it resets", () => {
@@ -294,14 +154,10 @@ describe("GitHubApi", () => {
154 "x-ratelimit-reset": String(reset),
155 });
156 let remaining = 499;
297 - const { layer, requests } = harness((request) =>
298 - request.url.endsWith("/graphql")
299 - ? json({ data: { viewer: { id: "1" } } })
300 - : json({ ok: true }, { headers: quota(remaining--) }),
301 - );
157 + const { layer, requests } = harness(() => json({ ok: true }, { headers: quota(remaining--) }));
158 return Effect.gen(function* () {
159 yield* TestClock.setTime(NOW);
304 - const api = yield* GitHubApi.GitHubApi;
160 + const api = yield* GitHubRest.GitHubRest;
161 const read = { host: "github.com", operation: "sweep", path: "repos/acme/web/pulls" };
162 // The first answer leaves 499 of 5000, under the last tenth; the next background read waits.
163 yield* api.rest(read);
@@ -310,14 +166,13 @@ describe("GitHubApi", () => {
166 _tag: "SourceControlRateLimitPausedError",
167 retryAt: reset * 1000,
168 });
313 - // A user's own request may spend the reserve, and GraphQL has a quota of its own.
169 + // A user's own request may spend the reserve.
170 yield* api.rest(read).pipe(Effect.provideService(SourceControlRateLimit.Interactive, true));
315 - yield* api.graphql({ host: "github.com", operation: "x", query: "query { viewer { id } }" });
316 - expect(requests).toHaveLength(3);
171 + expect(requests).toHaveLength(2);
172 // The reset gives the background its quota back.
173 yield* TestClock.setTime(reset * 1000);
174 yield* api.rest(read);
320 - expect(requests).toHaveLength(4);
175 + expect(requests).toHaveLength(3);
176 }).pipe(Effect.provide(layer));
177 });
178
@@ -338,7 +193,7 @@ describe("GitHubApi", () => {
193 ),
194 );
195 return Effect.gen(function* () {
341 - const api = yield* GitHubApi.GitHubApi;
196 + const api = yield* GitHubRest.GitHubRest;
197 const error = yield* Effect.flip(
198 api.rest({
199 host: "github.com",
@@ -369,7 +224,7 @@ describe("GitHubApi", () => {
224 );
225 return Effect.gen(function* () {
226 yield* TestClock.setTime(NOW);
372 - const api = yield* GitHubApi.GitHubApi;
227 + const api = yield* GitHubRest.GitHubRest;
228 const read = { host: "github.com", operation: "sweep", path: "repos/acme/web/pulls" };
229 yield* Effect.flip(api.rest(read));
230 expect((yield* Effect.flip(api.rest(read)))._tag).toBe("SourceControlRateLimitPausedError");
@@ -386,24 +241,6 @@ describe("GitHubApi", () => {
241 }).pipe(Effect.provide(layer));
242 });
243
389 - it.effect("reads an untyped GraphQL quota error as a rate limit", () => {
390 - const reset = Math.floor(NOW / 1000) + 900;
391 - const { layer } = harness(() =>
392 - json(
393 - { errors: [{ message: "API rate limit already exceeded for user ID 1." }] },
394 - { headers: { "x-ratelimit-remaining": "0", "x-ratelimit-reset": String(reset) } },
395 - ),
396 - );
397 - return Effect.gen(function* () {
398 - yield* TestClock.setTime(NOW);
399 - const api = yield* GitHubApi.GitHubApi;
400 - const error = yield* Effect.flip(
401 - api.graphql({ host: "github.com", operation: "lookup", query: "query { viewer { id } }" }),
402 - );
403 - expect(error).toMatchObject({ _tag: "GitHubApiRateLimitError", retryAt: reset * 1000 });
404 - }).pipe(Effect.provide(layer));
405 - });
406 -
244 it.effect("maps REST 403 with an exhausted quota to a rate limit, and 304 to an answer", () => {
245 let call = 0;
246 const { layer } = harness(() =>
@@ -419,7 +256,7 @@ describe("GitHubApi", () => {
256 );
257 return Effect.gen(function* () {
258 yield* TestClock.setTime(NOW);
422 - const api = yield* GitHubApi.GitHubApi;
259 + const api = yield* GitHubRest.GitHubRest;
260 const notModified = yield* api.rest({
261 host: "github.com",
262 operation: "checks",
@@ -441,7 +278,7 @@ describe("GitHubApi", () => {
278 : json({ ok: true }),
279 );
280 return Effect.gen(function* () {
444 - const api = yield* GitHubApi.GitHubApi;
281 + const api = yield* GitHubRest.GitHubRest;
282 const refused = yield* Effect.flip(
283 api.rest({ host: "github.com", operation: "user", path: "user" }),
284 );
@@ -459,11 +296,11 @@ describe("GitHubApi", () => {
296 it.effect("refuses to send a pinned credential to another host", () => {
297 const { layer, requests } = harness(() => json({}));
298 return Effect.gen(function* () {
462 - const api = yield* GitHubApi.GitHubApi;
299 + const api = yield* GitHubRest.GitHubRest;
300 const error = yield* Effect.flip(
301 api.rest({ host: "git.acme.internal", operation: "user", path: "user" }),
302 ).pipe(
466 - Effect.provideService(GitHubApi.PinnedGitHubCredential, {
303 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, {
304 host: "github.com",
305 token: Redacted.make("pinned"),
306 credentialFingerprint: "github.com:pinned",
packages/source-control-github/src/server/GitHubRest.ts new
+243
@@ -0,0 +1,243 @@
1 +import * as Context from "effect/Context";
2 +import * as Duration from "effect/Duration";
3 +import * as Effect from "effect/Effect";
4 +import * as Layer from "effect/Layer";
5 +import * as Option from "effect/Option";
6 +import * as Redacted from "effect/Redacted";
7 +import * as Schema from "effect/Schema";
8 +import { HttpClient, HttpClientRequest, type HttpClientResponse } from "effect/http";
9 +
10 +import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
11 +import * as GitHubCredentials from "./GitHubCredentials.ts";
12 +import * as GitHubQuota from "./GitHubQuota.ts";
13 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
14 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
15 +
16 +const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
17 +const { gitHubApiUrls, normalizeHost } = GitHubRequestPolicy;
18 +type GitHubApiError = GitHubRequestPolicy.GitHubApiError;
19 +
20 +export interface GitHubRestResponse {
21 + readonly status: number;
22 + readonly headers: Readonly<Record<string, string | undefined>>;
23 + readonly body: string;
24 + readonly truncated: boolean;
25 + /** The body was not valid UTF-8, which a raw file read takes to mean binary. */
26 + readonly invalidUtf8: boolean;
27 +}
28 +
29 +export interface GitHubRestInput {
30 + readonly host: string;
31 + readonly operation: string;
32 + readonly method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
33 + /** Relative to the API root, e.g. `repos/acme/web/pulls/7`; query string included. */
34 + readonly path: string;
35 + readonly body?: unknown;
36 + /** Defaults to `application/vnd.github+json`. */
37 + readonly accept?: string;
38 + /** Revalidates a cached answer. A 304 is returned rather than failed, and is free. */
39 + readonly ifNoneMatch?: string;
40 + readonly maxResponseBytes?: number;
41 + /** Defaults to 30 seconds; a whole pull request's patch may need longer. */
42 + readonly timeout?: Duration.Input;
43 + /** Overrides `SourceControlRateLimit.Interactive` for this one request. */
44 + readonly allowReserve?: boolean;
45 +}
46 +
47 +export class GitHubRest extends Context.Service<
48 + GitHubRest,
49 + {
50 + readonly rest: (input: GitHubRestInput) => Effect.Effect<GitHubRestResponse, GitHubApiError>;
51 + /** The credential a request to `host` would carry right now. */
52 + readonly credential: (
53 + host: string,
54 + ) => Effect.Effect<
55 + { readonly token: Redacted.Redacted<string>; readonly fingerprint: string },
56 + GitHubApiError
57 + >;
58 + }
59 +>()("@t3tools/source-control-github/server/GitHubRest") {}
60 +
61 +/** A REST failure body: `{ message, errors: [{ message } | { resource, field, code }] }`. */
62 +const decodeRestErrors = Schema.decodeUnknownOption(
63 + Schema.fromJsonString(
64 + Schema.Struct({
65 + message: Schema.optional(Schema.String),
66 + errors: Schema.optional(
67 + Schema.Array(
68 + Schema.Union([
69 + Schema.String,
70 + Schema.Struct({
71 + message: Schema.optional(Schema.String),
72 + field: Schema.optional(Schema.String),
73 + code: Schema.optional(Schema.String),
74 + }),
75 + ]),
76 + ),
77 + ),
78 + }),
79 + ),
80 +);
81 +
82 +function restErrorMessages(body: string): ReadonlyArray<string> | undefined {
83 + return Option.match(decodeRestErrors(body), {
84 + onNone: () => undefined,
85 + onSome: (decoded) => {
86 + const details = (decoded.errors ?? []).flatMap((error) =>
87 + typeof error === "string"
88 + ? [error]
89 + : error.message !== undefined
90 + ? [error.message]
91 + : error.field !== undefined && error.code !== undefined
92 + ? [`${error.field} ${error.code}`]
93 + : [],
94 + );
95 + const messages = [...(decoded.message === undefined ? [] : [decoded.message]), ...details];
96 + return messages.length > 0 ? messages : undefined;
97 + },
98 + });
99 +}
100 +
101 +/** What a REST answer means: a 304 is an answer only when the request revalidated a cached one. */
102 +function classify(input: {
103 + readonly answer: GitHubRestResponse;
104 + readonly acceptNotModified: boolean;
105 +}): GitHubRequestPolicy.GitHubAnswer<GitHubRestResponse> {
106 + const { status, headers, body } = input.answer;
107 + const meta = { status, headers };
108 + if (GitHubRequestPolicy.isRateLimited({ status, headers, body })) {
109 + return { _tag: "RateLimited", ...meta };
110 + }
111 + if (status === 401) return { _tag: "Unauthorized", ...meta };
112 + if (status === 404) return { _tag: "NotFound", ...meta };
113 + if ((status >= 200 && status < 300) || (status === 304 && input.acceptNotModified)) {
114 + return { _tag: "Ok", value: input.answer, ...meta };
115 + }
116 + return { _tag: "Failed", messages: restErrorMessages(body), ...meta };
117 +}
118 +
119 +/** @public Service construction is part of the canonical Effect module API. */
120 +export const make = Effect.gen(function* () {
121 + const httpClient = yield* HttpClient.HttpClient;
122 + const policy = yield* GitHubRequestPolicy.GitHubRequestPolicy;
123 +
124 + /**
125 + * Sends one request through the request policy and fails a refusal with the error that says
126 + * why. The answer is returned only once it is known to be one.
127 + */
128 + const send = Effect.fn("GitHubRest.send")(function* (input: {
129 + readonly host: string;
130 + readonly operation: string;
131 + readonly request: HttpClientRequest.HttpClientRequest;
132 + readonly maxResponseBytes: number;
133 + readonly timeout?: Duration.Input | undefined;
134 + readonly allowReserve: boolean;
135 + readonly acceptNotModified: boolean;
136 + }) {
137 + const host = normalizeHost(input.host);
138 + // Only the path: a query string can carry a SHA or a branch, and never needs to be in a trace.
139 + yield* Effect.annotateCurrentSpan({
140 + "github.kind": "rest",
141 + "http.request.method": input.request.method,
142 + "url.path": new URL(input.request.url).pathname,
143 + });
144 + return yield* policy.request(
145 + {
146 + host,
147 + operation: input.operation,
148 + // Every REST path this reads today spends `core`; a `search/` read would need its own
149 + // resource here.
150 + resource: "core",
151 + allowReserve: input.allowReserve,
152 + timeout: input.timeout,
153 + },
154 + (headers) =>
155 + Effect.gen(function* () {
156 + const response: HttpClientResponse.HttpClientResponse = yield* httpClient
157 + .execute(input.request.pipe(HttpClientRequest.setHeaders(headers)))
158 + .pipe(
159 + // `GitHubRest.send` is the request's span. The client's own span would add
160 + // `url.full` and `url.query`, which can carry SHAs and branch names, so it is off.
161 + Effect.provideService(HttpClient.TracerDisabledWhen, () => true),
162 + );
163 + const collected = yield* collectUint8StreamText({
164 + stream: response.stream,
165 + maxBytes: input.maxResponseBytes,
166 + }).pipe(
167 + // 204, 304 and many refusals carry no body at all, which is an empty answer.
168 + Effect.catchIf(
169 + (error) => error.reason._tag === "EmptyBodyError",
170 + () => Effect.succeed({ text: "", truncated: false, invalidUtf8: false }),
171 + ),
172 + );
173 + const { status, headers: responseHeaders } = response;
174 + const answer = {
175 + status,
176 + headers: responseHeaders,
177 + body: collected.text,
178 + truncated: collected.truncated,
179 + invalidUtf8: collected.invalidUtf8,
180 + };
181 + return classify({ answer, acceptNotModified: input.acceptNotModified });
182 + }).pipe(
183 + Effect.mapError(
184 + (cause) =>
185 + new GitHubRequestPolicy.GitHubApiRequestError({
186 + host,
187 + operation: input.operation,
188 + cause,
189 + }),
190 + ),
191 + ),
192 + );
193 + });
194 +
195 + const rest: GitHubRest["Service"]["rest"] = (input) => {
196 + const url = `${gitHubApiUrls(input.host).rest}/${input.path.replace(/^\/+/, "")}`;
197 + const base = HttpClientRequest.make(input.method ?? "GET")(url).pipe(
198 + HttpClientRequest.setHeader("accept", input.accept ?? "application/vnd.github+json"),
199 + );
200 + const withEtag =
201 + input.ifNoneMatch === undefined
202 + ? base
203 + : base.pipe(HttpClientRequest.setHeader("if-none-match", input.ifNoneMatch));
204 + const request =
205 + input.body === undefined
206 + ? withEtag
207 + : withEtag.pipe(HttpClientRequest.bodyJsonUnsafe(input.body));
208 + return SourceControlRateLimit.Interactive.pipe(
209 + Effect.flatMap((interactive) =>
210 + send({
211 + host: input.host,
212 + operation: input.operation,
213 + request,
214 + maxResponseBytes: input.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES,
215 + timeout: input.timeout,
216 + allowReserve: input.allowReserve ?? interactive,
217 + acceptNotModified: input.ifNoneMatch !== undefined,
218 + }),
219 + ),
220 + );
221 + };
222 +
223 + return GitHubRest.of({ rest, credential: policy.credential });
224 +});
225 +
226 +/**
227 + * The REST transport together with the request policy it sends through. The generated GraphQL
228 + * client sends through the same policy, so REST and GraphQL share one set of request slots.
229 + */
230 +export const layer = Layer.effect(GitHubRest, make).pipe(
231 + Layer.provideMerge(GitHubRequestPolicy.layer),
232 +);
233 +
234 +/**
235 + * REST and the request policy, with the credential, quota reserve and rate-limit pause the policy
236 + * reads through: everything both transports need. An application builds this once so every GitHub
237 + * reader shares one view of each quota per host.
238 + */
239 +export const layerWithDependencies = layer.pipe(
240 + Layer.provideMerge(GitHubCredentials.layer),
241 + Layer.provideMerge(GitHubQuota.layer),
242 + Layer.provideMerge(SourceControlRateLimit.layer),
243 +);
packages/source-control-github/src/server/GitHubSourceControlProvider.test.ts
+264 -145
@@ -7,14 +7,19 @@ import * as Fiber from "effect/Fiber";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Layer from "effect/Layer";
9 import * as Option from "effect/Option";
10 +import * as Redacted from "effect/Redacted";
11 import * as Schema from "effect/Schema";
12 +import { HttpClient, HttpClientResponse } from "effect/http";
13 import { ChildProcessSpawner } from "effect/process";
14 import * as TestClock from "effect/testing/TestClock";
15 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
16
17 import type * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
18 import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
16 -import * as GitHubApi from "./GitHubApi.ts";
19 +import * as GitHubRest from "./GitHubRest.ts";
20 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
21 import * as GitHubCredentials from "./GitHubCredentials.ts";
22 +import * as GitHubQuota from "./GitHubQuota.ts";
23 import { parseGitHubAuthStatus } from "./gitHubAuthStatus.ts";
24 import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
25
@@ -50,7 +55,7 @@ const remotesOutput = (...entries: ReadonlyArray<readonly [string, string]>) =>
55 .flatMap(([name, url]) => [`${name}\t${url} (fetch)`, `${name}\t${url} (push)`])
56 .join("\n");
57
53 -const restResponse = (body: unknown, status = 200): GitHubApi.GitHubRestResponse => ({
58 +const restResponse = (body: unknown, status = 200): GitHubRest.GitHubRestResponse => ({
59 status,
60 headers: {},
61 body: body === undefined ? "" : encodeJson(body),
@@ -64,26 +69,113 @@ const node = (number: number, headRefName: string, owner = "acme") => ({
69 url: `https://github.com/acme/web/pull/${number}`,
70 baseRefName: "main",
71 headRefName,
72 + headRefOid: "f".repeat(40),
73 state: "OPEN",
74 + isDraft: false,
75 + mergedAt: null,
76 + closedAt: null,
77 isCrossRepository: owner !== "acme",
78 updatedAt: "2026-01-02T00:00:00Z",
79 headRepository: { name: "web", nameWithOwner: `${owner}/web` },
71 - headRepositoryOwner: { login: owner },
80 + headRepositoryOwner: { __typename: "User", login: owner },
81 });
82
83 /**
75 - * The provider over a mocked GitHubApi, git driver and process. `remotes` is what
76 - * `git remote -v` prints; `git` records every driver call.
84 + * One GraphQL request as the fake GitHub saw it. An aliased batch is split back into its
85 + * lookups, each with its own variables, in order.
86 + */
87 +interface GraphQlCall {
88 + readonly host: string;
89 + readonly operationName: string;
90 + readonly query: string;
91 + readonly lookups: ReadonlyArray<Readonly<Record<string, unknown>>>;
92 +}
93 +
94 +/**
95 + * What GitHub answers for one lookup: the `repository` it reads, or a whole HTTP response for the
96 + * request (a refusal, a rate limit).
97 + */
98 +type GraphQlAnswer = unknown;
99 +type GraphQlRespond = (
100 + lookup: Readonly<Record<string, unknown>>,
101 + call: GraphQlCall,
102 +) => GraphQlAnswer | Response;
103 +
104 +/** GitHub's GraphQL endpoint for the generated reads: answers each lookup with `respond`. */
105 +function graphQlHttp(respond: GraphQlRespond, calls: Array<GraphQlCall>) {
106 + return HttpClient.make((request) =>
107 + Effect.sync(() => {
108 + const sent =
109 + request.body._tag === "Uint8Array"
110 + ? (JSON.parse(new TextDecoder().decode(request.body.body)) as {
111 + readonly query: string;
112 + readonly operationName: string;
113 + readonly variables: Readonly<Record<string, unknown>>;
114 + })
115 + : { query: "", operationName: "", variables: {} };
116 + const prefixes = [
117 + ...new Set(Object.keys(sent.variables).flatMap((key) => /^_\d+_/.exec(key) ?? [])),
118 + ];
119 + const lookups =
120 + prefixes.length === 0
121 + ? [sent.variables]
122 + : prefixes.map((prefix) =>
123 + Object.fromEntries(
124 + Object.entries(sent.variables)
125 + .filter(([key]) => key.startsWith(prefix))
126 + .map(([key, value]) => [key.slice(prefix.length), value]),
127 + ),
128 + );
129 + const call: GraphQlCall = {
130 + host: new URL(request.url).hostname.replace(/^api\./, ""),
131 + operationName: sent.operationName,
132 + query: sent.query,
133 + lookups,
134 + };
135 + calls.push(call);
136 + const answers = lookups.map((lookup) => respond(lookup, call));
137 + const refusal = answers.find((answer) => answer instanceof Response);
138 + const response =
139 + refusal ??
140 + new Response(
141 + encodeJson({
142 + data: Object.fromEntries(
143 + answers.map((answer, index) => [
144 + prefixes.length === 0 ? "repository" : `${prefixes[index]}repository`,
145 + answer,
146 + ]),
147 + ),
148 + }),
149 + { headers: { "content-type": "application/json" } },
150 + );
151 + return HttpClientResponse.fromWeb(request, response);
152 + }),
153 + );
154 +}
155 +
156 +/**
157 + * The provider over a mocked GitHubRest, git driver and process. `remotes` is what
158 + * `git remote -v` prints; `git` records every driver call. GraphQL reads go over HTTP to
159 + * `graphql`, through the real request policy; `graphqlCalls` records each request.
160 */
161 function harness(input: {
162 readonly remotes: string;
80 - readonly api: Partial<GitHubApi.GitHubApi["Service"]>;
163 + readonly api?: Partial<GitHubRest.GitHubRest["Service"]>;
164 + readonly graphql?: GraphQlRespond;
165 + /** The credential a GraphQL read is sent with; github.com's token by default. */
166 + readonly credential?: (
167 + host: string,
168 + ) => Effect.Effect<
169 + GitHubCredentials.GitHubCredential,
170 + GitHubCredentials.GitHubCredentialUnavailableError
171 + >;
172 readonly localBranches?: ReadonlyArray<string>;
173 readonly resolved?: string;
174 /** Fails the local branch listing, the first git read a checkout makes. */
175 readonly gitFailure?: unknown;
176 }) {
177 const git: Array<readonly [string, unknown]> = [];
178 + const graphqlCalls: Array<GraphQlCall> = [];
179 const record =
180 <A>(name: string, value: A) =>
181 (args: unknown) =>
@@ -124,17 +216,44 @@ function harness(input: {
216 ),
217 },
218 });
219 + const graphql =
220 + input.graphql ??
221 + (() => {
222 + throw new Error("Unexpected GraphQL read");
223 + });
224 + const policy = GitHubRequestPolicy.layer.pipe(
225 + Layer.provide(
226 + Layer.mergeAll(
227 + Layer.succeed(GitHubCredentials.GitHubCredentials, {
228 + get:
229 + input.credential ??
230 + ((host) =>
231 + Effect.succeed({
232 + host,
233 + token: Redacted.make("token"),
234 + source: "gh" as const,
235 + fingerprint: `${host}:token`,
236 + })),
237 + invalidate: () => Effect.void,
238 + }),
239 + GitHubQuota.layer,
240 + SourceControlRateLimit.layer,
241 + ),
242 + ),
243 + );
244 const layer = Layer.mergeAll(
245 host,
129 - Layer.mock(GitHubApi.GitHubApi)(input.api),
246 + Layer.mock(GitHubRest.GitHubRest)(input.api ?? {}),
247 + policy,
248 + Layer.succeed(HttpClient.HttpClient, graphQlHttp(graphql, graphqlCalls)),
249 NodeServices.layer,
250 );
132 - return { layer, git };
251 + return { layer, git, graphqlCalls };
252 }
253
254 /** The provider context for a checkout whose remote is on `host`. */
136 -/** The provider over a mocked GitHubApi, for reads that never touch the checkout. */
137 -const makeProvider = (api: Partial<GitHubApi.GitHubApi["Service"]>) =>
255 +/** The provider over a mocked GitHubRest, for reads that never touch the checkout. */
256 +const makeProvider = (api: Partial<GitHubRest.GitHubRest["Service"]>) =>
257 GitHubSourceControlProvider.make.pipe(Effect.provide(harness({ remotes: "", api }).layer));
258
259 const githubContext = (host: string) => ({
@@ -207,7 +326,10 @@ describe("GitHubSourceControlProvider repository resolution", () => {
326 api: {
327 rest: (input) =>
328 Effect.fail(
210 - new GitHubApi.GitHubApiNotFoundError({ host: input.host, operation: input.operation }),
329 + new GitHubRequestPolicy.GitHubApiNotFoundError({
330 + host: input.host,
331 + operation: input.operation,
332 + }),
333 ),
334 },
335 });
@@ -236,23 +358,16 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
358 const remotes = remotesOutput(["origin", "git@github.com:acme/web.git"]);
359
360 it.effect("reads a background sweep's staggered heads in one GraphQL document", () => {
239 - const documents: Array<GitHubApi.GitHubGraphQlInput> = [];
240 - const { layer } = harness({
361 + const { layer, graphqlCalls } = harness({
362 remotes,
242 - api: {
243 - graphql: (input) =>
244 - Effect.sync(() => {
245 - documents.push(input);
246 - return encodeJson({
247 - data: {
248 - repository: {
249 - h0: { nodes: [{ ...node(7, "feature/a"), headRefOid: "a".repeat(40) }] },
250 - h1: { nodes: [] },
251 - },
252 - },
253 - });
254 - }),
255 - },
363 + graphql: (lookup) => ({
364 + pullRequests: {
365 + nodes:
366 + lookup.head === "feature/a"
367 + ? [{ ...node(7, "feature/a"), headRefOid: "a".repeat(40) }]
368 + : [],
369 + },
370 + }),
371 });
372 return Effect.gen(function* () {
373 const gh = yield* GitHubSourceControlProvider.make;
@@ -279,33 +394,70 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
394 );
395 assert.strictEqual(first?.[0]?.headSha, "a".repeat(40));
396 assert.deepStrictEqual(second, []);
282 - assert.strictEqual(documents.length, 1);
283 - assert.include(documents[0]!.query, "headRefOid");
284 - assert.deepStrictEqual(documents[0]!.variables, {
285 - owner: "acme",
286 - name: "web",
287 - h0: "feature/a",
288 - s0: ["OPEN", "CLOSED", "MERGED"],
289 - h1: "feature/b",
290 - s1: ["OPEN", "CLOSED", "MERGED"],
291 - });
397 + assert.strictEqual(graphqlCalls.length, 1);
398 + assert.include(graphqlCalls[0]!.query, "headRefOid");
399 + assert.deepStrictEqual(graphqlCalls[0]!.lookups, [
400 + {
401 + owner: "acme",
402 + name: "web",
403 + head: "feature/a",
404 + states: ["OPEN", "CLOSED", "MERGED"],
405 + first: 100,
406 + },
407 + {
408 + owner: "acme",
409 + name: "web",
410 + head: "feature/b",
411 + states: ["OPEN", "CLOSED", "MERGED"],
412 + first: 100,
413 + },
414 + ]);
415 + }).pipe(Effect.provide(layer));
416 + });
417 +
418 + it.effect("skips a row that does not decode and keeps the rest of the batch", () => {
419 + const { layer, graphqlCalls } = harness({
420 + remotes,
421 + graphql: (lookup) => ({
422 + pullRequests: {
423 + nodes:
424 + lookup.head === "feature/a"
425 + ? [{ ...node(8, "feature/a"), number: "eight" }, node(7, "feature/a")]
426 + : [node(9, "feature/b")],
427 + },
428 + }),
429 + });
430 + return Effect.gen(function* () {
431 + const gh = yield* GitHubSourceControlProvider.make;
432 + const lookup = (headSelector: string) =>
433 + gh.listChangeRequests({
434 + cwd: "/repo",
435 + headSelector,
436 + state: "all",
437 + limit: 100,
438 + context: githubContext("github.com"),
439 + });
440 + const both = yield* Effect.all([lookup("feature/a"), lookup("feature/b")], {
441 + concurrency: "unbounded",
442 + }).pipe(Effect.forkChild);
443 + yield* TestClock.adjust("500 millis");
444 + const [first, second] = yield* Fiber.join(both);
445 + assert.strictEqual(graphqlCalls.length, 1);
446 + assert.deepStrictEqual(
447 + first.map((pr) => pr.number),
448 + [7],
449 + );
450 + assert.deepStrictEqual(
451 + second.map((pr) => pr.number),
452 + [9],
453 + );
454 }).pipe(Effect.provide(layer));
455 });
456
457 it.effect("caps a background document at twenty-five heads", () => {
296 - const headCounts: Array<number> = [];
297 - const { layer } = harness({
458 + const { layer, graphqlCalls } = harness({
459 remotes,
299 - api: {
300 - graphql: (input) =>
301 - Effect.sync(() => {
302 - const heads = Object.keys(input.variables ?? {}).filter((key) => /^h\d+$/.test(key));
303 - headCounts.push(heads.length);
304 - return encodeJson({
305 - data: { repository: Object.fromEntries(heads.map((key) => [key, { nodes: [] }])) },
306 - });
307 - }),
308 - },
460 + graphql: () => ({ pullRequests: { nodes: [] } }),
461 });
462 return Effect.gen(function* () {
463 const gh = yield* GitHubSourceControlProvider.make;
@@ -324,7 +476,7 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
476 yield* TestClock.adjust("500 millis");
477 yield* Fiber.join(lookups);
478 assert.deepStrictEqual(
327 - headCounts.toSorted((a, b) => a - b),
479 + graphqlCalls.map((call) => call.lookups.length).toSorted((a, b) => a - b),
480 [1, 25],
481 );
482 }).pipe(Effect.provide(layer));
@@ -333,23 +485,14 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
485 it.effect("matches an owner:branch selector on the head owner", () => {
486 const { layer } = harness({
487 remotes,
336 - api: {
337 - graphql: (input) =>
338 - Effect.succeed(
339 - encodeJson({
340 - data: {
341 - repository: {
342 - h0: {
343 - nodes:
344 - input.variables?.h0 === "main"
345 - ? [node(9, "main", "someone"), node(8, "main", "me"), node(7, "main", "me")]
346 - : [],
347 - },
348 - },
349 - },
350 - }),
351 - ),
352 - },
488 + graphql: (lookup) => ({
489 + pullRequests: {
490 + nodes:
491 + lookup.head === "main"
492 + ? [node(9, "main", "someone"), node(8, "main", "me"), node(7, "main", "me")]
493 + : [],
494 + },
495 + }),
496 });
497 return Effect.gen(function* () {
498 const gh = yield* GitHubSourceControlProvider.make;
@@ -365,20 +508,23 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
508 });
509
510 it.effect("maps API failures onto the errors callers handle", () => {
511 + let signedIn = false;
512 const { layer } = harness({
513 remotes,
370 - api: {
371 - graphql: (input) =>
372 - Effect.fail(
373 - input.variables?.h0 === "missing"
374 - ? new GitHubCredentials.GitHubCliMissingError({ host: "github.com" })
375 - : new GitHubApi.GitHubApiRateLimitError({
376 - host: "github.com",
377 - operation: "x",
378 - retryAt: 123,
379 - }),
380 - ),
381 - },
514 + credential: (host) =>
515 + signedIn
516 + ? Effect.succeed({
517 + host,
518 + token: Redacted.make("token"),
519 + source: "gh" as const,
520 + fingerprint: "fp",
521 + })
522 + : Effect.fail(new GitHubCredentials.GitHubCliMissingError({ host })),
523 + graphql: () =>
524 + new Response(encodeJson({ message: "API rate limit exceeded" }), {
525 + status: 403,
526 + headers: { "x-ratelimit-remaining": "0", "x-ratelimit-reset": "123" },
527 + }),
528 });
529 return Effect.gen(function* () {
530 const gh = yield* GitHubSourceControlProvider.make;
@@ -389,27 +535,21 @@ describe("GitHubSourceControlProvider change request lookups by head", () => {
535 const missing = yield* read("missing");
536 yield* TestClock.adjust("500 millis");
537 assert.include((yield* Fiber.join(missing)).detail, "No GitHub credential on the server");
538 + signedIn = true;
539 const limited = yield* read("limited");
540 yield* TestClock.adjust("500 millis");
541 const error = yield* Fiber.join(limited);
542 assert.include(error.detail, "rate limit exceeded");
396 - assert.propertyVal(error.cause, "retryAt", 123);
543 + assert.propertyVal(error.cause, "retryAt", 123_000);
544 }).pipe(Effect.provide(layer));
545 });
546 });
547
548 describe("GitHubSourceControlProvider.getChangeRequest", () => {
549 it.effect("reads a pull request by number, and by URL on its own repository", () => {
403 - const variables: Array<unknown> = [];
404 - const { layer } = harness({
550 + const { layer, graphqlCalls } = harness({
551 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
406 - api: {
407 - graphql: (input) =>
408 - Effect.sync(() => {
409 - variables.push(input.variables);
410 - return encodeJson({ data: { repository: { pullRequest: node(42, "feature") } } });
411 - }),
412 - },
552 + graphql: () => ({ pullRequest: node(42, "feature") }),
553 });
554 return Effect.gen(function* () {
555 const gh = yield* GitHubSourceControlProvider.make;
@@ -421,19 +561,20 @@ describe("GitHubSourceControlProvider.getChangeRequest", () => {
561 cwd: "/repo",
562 reference: "https://github.com/other/thing/pull/42",
563 });
424 - assert.deepStrictEqual(variables, [
425 - { owner: "acme", name: "web", number: 42 },
426 - { owner: "other", name: "thing", number: 42 },
427 - ]);
564 + assert.deepStrictEqual(
565 + graphqlCalls.flatMap((call) => call.lookups),
566 + [
567 + { owner: "acme", name: "web", number: 42 },
568 + { owner: "other", name: "thing", number: 42 },
569 + ],
570 + );
571 }).pipe(Effect.provide(layer));
572 });
573
574 it.effect("fails a missing pull request as not found", () => {
575 const { layer } = harness({
576 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
434 - api: {
435 - graphql: () => Effect.succeed(encodeJson({ data: { repository: { pullRequest: null } } })),
436 - },
577 + graphql: () => ({ pullRequest: null }),
578 });
579 return Effect.gen(function* () {
580 const gh = yield* GitHubSourceControlProvider.make;
@@ -445,7 +586,7 @@ describe("GitHubSourceControlProvider.getChangeRequest", () => {
586
587 describe("GitHubSourceControlProvider writes", () => {
588 it.effect("creates a cross-repository pull request with an owner:branch head", () => {
448 - const requests: Array<GitHubApi.GitHubRestInput> = [];
589 + const requests: Array<GitHubRest.GitHubRestInput> = [];
590 const { layer } = harness({
591 remotes: remotesOutput(
592 ["origin", "git@github.com:me/web.git"],
@@ -573,12 +714,7 @@ describe("GitHubSourceControlProvider.checkoutChangeRequest", () => {
714 it.effect("checks a same-repository pull request out from its head branch", () => {
715 const { layer, git } = harness({
716 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
576 - api: {
577 - graphql: () =>
578 - Effect.succeed(
579 - encodeJson({ data: { repository: { pullRequest: node(5, "feature/x") } } }),
580 - ),
581 - },
717 + graphql: () => ({ pullRequest: node(5, "feature/x") }),
718 });
719 return Effect.gen(function* () {
720 const gh = yield* GitHubSourceControlProvider.make;
@@ -602,14 +738,11 @@ describe("GitHubSourceControlProvider.checkoutChangeRequest", () => {
738 const { layer, git } = harness({
739 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
740 localBranches: ["main"],
741 + graphql: () => ({ pullRequest: node(6, "main", "someone") }),
742 api: {
606 - graphql: () =>
607 - Effect.succeed(
608 - encodeJson({ data: { repository: { pullRequest: node(6, "main", "someone") } } }),
609 - ),
743 rest: () =>
744 Effect.fail(
612 - new GitHubApi.GitHubApiRequestError({
745 + new GitHubRequestPolicy.GitHubApiRequestError({
746 host: "github.com",
747 operation: "x",
748 cause: "offline",
@@ -629,11 +762,8 @@ describe("GitHubSourceControlProvider.checkoutChangeRequest", () => {
762 const { layer, git } = harness({
763 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
764 localBranches: ["someone/main"],
765 + graphql: () => ({ pullRequest: node(6, "main", "someone") }),
766 api: {
633 - graphql: () =>
634 - Effect.succeed(
635 - encodeJson({ data: { repository: { pullRequest: node(6, "main", "someone") } } }),
636 - ),
767 rest: (input) =>
768 Effect.succeed(repository(input.path === "repos/acme/web" ? "acme/web" : "someone/web")),
769 },
@@ -664,12 +794,7 @@ describe("GitHubSourceControlProvider.checkoutChangeRequest", () => {
794 const { layer } = harness({
795 remotes: remotesOutput(["origin", "git@github.com:acme/web.git"]),
796 gitFailure: new Error("fatal: /home/me/secret-path: permission denied"),
667 - api: {
668 - graphql: () =>
669 - Effect.succeed(
670 - encodeJson({ data: { repository: { pullRequest: node(5, "feature/x") } } }),
671 - ),
672 - },
797 + graphql: () => ({ pullRequest: node(5, "feature/x") }),
798 });
799 return Effect.gen(function* () {
800 const gh = yield* GitHubSourceControlProvider.make;
@@ -924,7 +1049,7 @@ it.effect.each(["read", "decode"] as const)(
1049 "retains the %s failure without exposing its raw contents",
1050 (stage) =>
1051 Effect.gen(function* () {
927 - const cause = new GitHubApi.GitHubApiResponseError({
1052 + const cause = new GitHubRequestPolicy.GitHubApiResponseError({
1053 host: "github.com",
1054 operation: "resolveLink",
1055 status: 500,
@@ -1026,26 +1151,15 @@ it.live.each([
1151 "ssh://git@code.example.test/team/project.git",
1152 "https://code.example.test/team/project.git",
1153 ])("keeps Enterprise operations on the selected remote: %s", (remoteUrl) => {
1029 - const graphql: GitHubApi.GitHubGraphQlInput[] = [];
1030 - const rest: GitHubApi.GitHubRestInput[] = [];
1154 + const rest: GitHubRest.GitHubRestInput[] = [];
1155 + const pr = {
1156 + ...node(42, "feature", "team"),
1157 + url: "https://code.example.test/team/project/pull/42",
1158 + isCrossRepository: false,
1159 + headRepository: { name: "project", nameWithOwner: "team/project" },
1160 + };
1161 const api = {
1032 - graphql: (input: GitHubApi.GitHubGraphQlInput) =>
1033 - Effect.sync(() => {
1034 - graphql.push(input);
1035 - const pr = {
1036 - ...node(42, "feature", "team"),
1037 - url: "https://code.example.test/team/project/pull/42",
1038 - isCrossRepository: false,
1039 - headRepository: { name: "project", nameWithOwner: "team/project" },
1040 - };
1041 - return encodeJson({
1042 - data: {
1043 - repository:
1044 - input.operation === "getPullRequest" ? { pullRequest: pr } : { h0: { nodes: [pr] } },
1045 - },
1046 - });
1047 - }),
1048 - rest: (input: GitHubApi.GitHubRestInput) =>
1162 + rest: (input: GitHubRest.GitHubRestInput) =>
1163 Effect.sync(() => {
1164 rest.push(input);
1165 return restResponse({
@@ -1056,12 +1170,16 @@ it.live.each([
1170 });
1171 }),
1172 };
1059 - const { layer, git } = harness({
1173 + const { layer, git, graphqlCalls } = harness({
1174 remotes: remotesOutput(
1175 ["origin", "git@github.com:team/project.git"],
1176 ["enterprise", remoteUrl],
1177 ),
1178 api,
1179 + graphql: (_, call) =>
1180 + call.operationName === "PullRequestByNumber"
1181 + ? { pullRequest: pr }
1182 + : { pullRequests: { nodes: [pr] } },
1183 });
1184 return Effect.gen(function* () {
1185 const provider = yield* GitHubSourceControlProvider.make;
@@ -1101,12 +1219,13 @@ it.live.each([
1219 yield* provider.checkoutChangeRequest({ ...input, reference: "42" });
1220 yield* provider.getRepositoryCloneUrls({ ...input, repository: "team/other" });
1221 yield* provider.getRepositoryCloneUrls({ ...input, repository: "github.com/team/explicit" });
1104 - assert.strictEqual(graphql.length, 5);
1105 - for (const request of graphql) {
1106 - assert.strictEqual(request.host, "code.example.test");
1107 - assert.strictEqual(request.variables?.owner, "team");
1108 - assert.strictEqual(request.variables?.name, "project");
1109 - }
1222 + const lookups = graphqlCalls.flatMap((call) =>
1223 + call.lookups.map(({ owner, name }) => [call.host, owner, name]),
1224 + );
1225 + assert.deepStrictEqual(
1226 + lookups,
1227 + Array.from({ length: 5 }, () => ["code.example.test", "team", "project"]),
1228 + );
1229 assert.deepStrictEqual(
1230 rest.map(({ host, path }) => [host, path]),
1231 [
packages/source-control-github/src/server/GitHubSourceControlProvider.ts
+134 -154
@@ -1,11 +1,16 @@
1 import { SourceControlProviderKind } from "@t3tools/contracts";
2 -import * as Context from "effect/Context";
2 import * as Data from "effect/Data";
3 +import * as DateTime from "effect/DateTime";
4 import * as Effect from "effect/Effect";
5 -import * as Exit from "effect/Exit";
5 import * as FileSystem from "effect/FileSystem";
6 +import {
7 + GraphQL,
8 + GraphQLClient,
9 + GraphQLClientError,
10 + GraphQLGroup,
11 + GraphQLResolver,
12 +} from "effect/graphql";
13 import * as Option from "effect/Option";
8 -import * as Request from "effect/Request";
14 import * as RequestResolver from "effect/RequestResolver";
15 import * as Result from "effect/Result";
16 import * as Schema from "effect/Schema";
@@ -21,10 +26,12 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
26 import { decodeJsonResult } from "@t3tools/shared/schemaJson";
27 import { isSshRemoteUrl } from "@t3tools/shared/sourceControl";
28
24 -import * as GitHubApi from "./GitHubApi.ts";
29 +import * as GitHubRest from "./GitHubRest.ts";
30 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
31 import * as GitHubChangeRequestTemplate from "./gitHubChangeRequestTemplate.ts";
32 +import * as GitHubGraphQlClient from "./gitHubGraphQlClient.ts";
33 import {
27 - decodeGitHubPullRequestEntries,
34 + normalizeGitHubPullRequestRecord,
35 type NormalizedGitHubPullRequestRecord,
36 } from "./gitHubPullRequests.ts";
37 import {
@@ -56,6 +63,30 @@ import * as SourceControlHost from "@t3tools/source-control-core/server/SourceCo
63 import { readSourceControlHostSettings } from "@t3tools/source-control-core/client/definition";
64
65 import * as GitHubClient from "../client/definition.ts";
66 +import {
67 + PullRequestByNumber,
68 + PullRequestNode,
69 + PullRequestsByHead,
70 +} from "./sourceControlProvider.graphql.ts";
71 +
72 +/**
73 + * The generated head lookup with its rows left undecoded, so `listByHead` decodes them one at a
74 + * time: a row whose fields no longer decode is skipped rather than failing every lookup that
75 + * shared its document.
76 + */
77 +const LenientPullRequestsByHead = GraphQL.query(PullRequestsByHead.name, {
78 + // The template, not the joined text: `GraphQLResolver.aliased` repeats it per lookup.
79 + document: PullRequestsByHead.template!,
80 + variables: PullRequestsByHead.variables,
81 + result: Schema.Struct({
82 + repository: Schema.NullOr(
83 + Schema.Struct({
84 + pullRequests: Schema.Struct({ nodes: Schema.NullOr(Schema.Array(Schema.Unknown)) }),
85 + }),
86 + ),
87 + }),
88 +});
89 +const decodePullRequestNode = Schema.decodeUnknownOption(PullRequestNode);
90
91 const decodeLinkSubject = Schema.decodeUnknownEffect(
92 Schema.fromJsonString(
@@ -192,7 +223,7 @@ function environmentTokenVariable(environment: NodeJS.ProcessEnv): string | null
223 * token is checked against the API, since `gh auth status` may not know it.
224 */
225 export const makeDiscovery = Effect.gen(function* () {
195 - const api = yield* GitHubApi.GitHubApi;
226 + const api = yield* GitHubRest.GitHubRest;
227 const sourceControlHost = yield* SourceControlHost.SourceControlHost;
228 const process = sourceControlHost.process;
229 const environment = yield* HostProcess.Environment;
@@ -307,7 +338,7 @@ const REPOSITORY_NOT_FOUND = "Repository not found. Check the owner and name and
338
339 /** `notFound` names what was missing, which only the operation knows. */
340 function fromGitHubApiError(
310 - error: GitHubApi.GitHubApiError,
341 + error: GitHubRequestPolicy.GitHubApiError,
342 notFound = PULL_REQUEST_NOT_FOUND,
343 ): GitHubFailure {
344 switch (error._tag) {
@@ -361,10 +392,10 @@ const decodeViewerLogin = decodeJsonResult(Schema.Struct({ login: TrimmedNonEmpt
392
393 type PullRequestListState = "open" | "closed" | "merged" | "all";
394
364 -/** The pull request fields every read selects, in GraphQL. */
365 -const PULL_REQUEST_NODE_SELECTION =
366 - "number title url baseRefName headRefName headRefOid state isDraft mergedAt closedAt updatedAt isCrossRepository headRepository { name nameWithOwner } headRepositoryOwner { login }";
367 -const GRAPHQL_STATES: Record<PullRequestListState, ReadonlyArray<string>> = {
395 +const GRAPHQL_STATES: Record<
396 + PullRequestListState,
397 + NonNullable<PullRequestsByHead.Variables["states"]>
398 +> = {
399 open: ["OPEN"],
400 closed: ["CLOSED"],
401 merged: ["MERGED"],
@@ -398,69 +429,34 @@ const HEAD_LOOKUP_MAX_RESPONSE_BYTES = 16_000_000;
429 */
430 const OWNER_HEAD_SCAN_LIMIT = 100;
431
401 -class PullRequestsByHeadRead extends Request.Class<
402 - {
403 - readonly host: string;
404 - readonly owner: string;
405 - readonly name: string;
406 - readonly headRefName: string;
407 - readonly state: PullRequestListState;
408 - readonly limit: number;
409 - readonly allowReserve: boolean;
410 - },
411 - ReadonlyArray<NormalizedGitHubPullRequestRecord>,
412 - GitHubFailure
413 -> {}
414 -
415 -/** One aliased `pullRequests` connection per lookup, each head and state passed as a variable. */
416 -function buildPullRequestsByHeadQuery(
417 - lookups: ReadonlyArray<Pick<PullRequestsByHeadRead, "headRefName" | "state" | "limit">>,
418 -): { readonly document: string; readonly variables: Record<string, unknown> } {
419 - const variables: Record<string, unknown> = {};
420 - const declarations: string[] = ["$owner: String!", "$name: String!"];
421 - const selections: string[] = [];
422 - for (const [index, lookup] of lookups.entries()) {
423 - variables[`h${index}`] = lookup.headRefName;
424 - variables[`s${index}`] = GRAPHQL_STATES[lookup.state];
425 - declarations.push(`$h${index}: String!`, `$s${index}: [PullRequestState!]`);
426 - // `gh pr list` orders the same way, so a head with more matches than the limit keeps the
427 - // same rows.
428 - selections.push(
429 - ` h${index}: pullRequests(headRefName: $h${index}, states: $s${index}, first: ${lookup.limit}, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { ${PULL_REQUEST_NODE_SELECTION} } }`,
430 - );
431 - }
432 - return {
433 - document: `query PullRequestsByHead(${declarations.join(", ")}) {\n repository(owner: $owner, name: $name) {\n${selections.join("\n")}\n }\n}`,
434 - variables,
435 - };
432 +function trimmed(value: string): string | null {
433 + const text = value.trim();
434 + return text.length > 0 ? text : null;
435 }
436
438 -const PULL_REQUEST_BY_NUMBER_QUERY = `query PullRequestByNumber($owner: String!, $name: String!, $number: Int!) {
439 - repository(owner: $owner, name: $name) {
440 - pullRequest(number: $number) { ${PULL_REQUEST_NODE_SELECTION} }
441 - }
442 -}`;
443 -
444 -const decodePullRequestsByHead = decodeJsonResult(
445 - Schema.Struct({
446 - data: Schema.Struct({
447 - repository: Schema.NullOr(
448 - Schema.Record(
449 - Schema.String,
450 - Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.Unknown) })),
451 - ),
452 - ),
453 - }),
454 - }),
455 -);
456 -
457 -const decodePullRequestByNumber = decodeJsonResult(
458 - Schema.Struct({
459 - data: Schema.Struct({
460 - repository: Schema.NullOr(Schema.Struct({ pullRequest: Schema.NullOr(Schema.Unknown) })),
461 - }),
462 - }),
463 -);
437 +/**
438 + * A pull request as every read reports it, or null for a row this cannot use: a number below
439 + * one, a blank title, URL or branch name, or an `updatedAt` that is not a date. A list skips a
440 + * null, so one such row cannot hide the rest. The generated schema already holds every row to
441 + * GitHub's own types, with `state` as a lenient enum.
442 + */
443 +function toPullRequestRecord(node: PullRequestNode): NormalizedGitHubPullRequestRecord | null {
444 + const title = trimmed(node.title);
445 + const url = trimmed(node.url);
446 + const baseRefName = trimmed(node.baseRefName);
447 + const headRefName = trimmed(node.headRefName);
448 + const updatedAt = DateTime.make(node.updatedAt);
449 + if (node.number < 1 || !title || !url || !baseRefName || !headRefName) return null;
450 + if (Option.isNone(updatedAt)) return null;
451 + return normalizeGitHubPullRequestRecord({
452 + ...node,
453 + title,
454 + url,
455 + baseRefName,
456 + headRefName,
457 + updatedAt: Option.some(DateTime.toUtc(updatedAt.value)),
458 + });
459 +}
460
461 /** The local branch a pull request checks out into, the way `gh pr checkout` names it. */
462 export function pullRequestCheckoutBranchName(input: {
@@ -484,7 +480,7 @@ const contextHost = (context: SourceControlProvider.SourceControlProviderContext
480 context === undefined ? undefined : new URL(context.provider.baseUrl).host;
481
482 export const make = Effect.gen(function* () {
487 - const api = yield* GitHubApi.GitHubApi;
483 + const api = yield* GitHubRest.GitHubRest;
484 const sourceControlHost = yield* SourceControlHost.SourceControlHost;
485 const process = sourceControlHost.process;
486 const environment = yield* HostProcess.Environment;
@@ -543,73 +539,42 @@ export const make = Effect.gen(function* () {
539 },
540 );
541
546 - const graphqlJson = <A>(
547 - input: GitHubApi.GitHubGraphQlInput,
548 - decode: (raw: string) => Result.Result<A, unknown>,
542 + const client = yield* GraphQLClient.make(
543 + GraphQLGroup.make(LenientPullRequestsByHead, PullRequestByNumber).middleware(
544 + GitHubGraphQlClient.GitHubGraphQlAuth,
545 + ),
546 + ).pipe(Effect.provide(GitHubGraphQlClient.layer));
547 +
548 + /**
549 + * Runs a generated read against `target`. GitHub's refusals and `errors` fail the way REST
550 + * ones do; an answer that does not decode is a `decodeDetail` failure.
551 + */
552 + const graphqlRead = <A, E, R>(
553 + target: GitHubGraphQlClient.GitHubGraphQlTarget["Service"],
554 decodeDetail: string,
555 + effect: Effect.Effect<A, E, R>,
556 ) =>
551 - api.graphql(input).pipe(
552 - Effect.mapError(fromGitHubApiError),
553 - Effect.flatMap((raw) => {
554 - const decoded = decode(raw);
555 - return Result.isSuccess(decoded)
556 - ? Effect.succeed(decoded.success)
557 - : Effect.fail(failure(decodeDetail, decoded.failure));
558 - }),
557 + effect.pipe(
558 + GitHubGraphQlClient.call(target),
559 + Effect.mapError((error) =>
560 + GraphQLClientError.isGraphQLClientError(error)
561 + ? failure(decodeDetail, error)
562 + : fromGitHubApiError(error as GitHubRequestPolicy.GitHubApiError),
563 + ),
564 );
565
561 - const rest = (input: GitHubApi.GitHubRestInput, notFoundDetail?: string) =>
566 + const rest = (input: GitHubRest.GitHubRestInput, notFoundDetail?: string) =>
567 api.rest(input).pipe(Effect.mapError((error) => fromGitHubApiError(error, notFoundDetail)));
568
564 - const headResolver = RequestResolver.makeGrouped<PullRequestsByHeadRead, string>({
565 - key: ({ request, context }) =>
566 - [
567 - request.host,
568 - request.owner,
569 - request.name,
570 - String(request.allowReserve),
571 - Context.getOrElse(context, GitHubApi.PinnedGitHubCredential, () => null)
572 - ?.credentialFingerprint ?? "",
573 - Context.getOrElse(context, SourceControlRateLimit.CredentialScope, () => ""),
574 - ].join("\0"),
575 - resolver: (entries) => {
576 - const [first] = entries;
577 - const { host, owner, name, allowReserve } = first.request;
578 - const query = buildPullRequestsByHeadQuery(entries.map((entry) => entry.request));
579 - return graphqlJson(
580 - {
581 - host,
582 - operation: "listPullRequestsByHead",
583 - query: query.document,
584 - variables: { owner, name, ...query.variables },
585 - allowReserve,
586 - // Up to 50 heads of 100 rows each. A default branch such as `main` can match a hundred
587 - // fork pull requests, so the usual cap would cut the answer short.
588 - maxResponseBytes: HEAD_LOOKUP_MAX_RESPONSE_BYTES,
589 - },
590 - decodePullRequestsByHead,
591 - "GitHub returned an invalid change request list.",
592 - ).pipe(
593 - Effect.flatMap((decoded) =>
594 - decoded.data.repository === null
595 - ? Effect.fail(notFound("The repository could not be read."))
596 - : Effect.succeed(decoded.data.repository),
597 - ),
598 - Effect.map((aliases) => {
599 - for (const [index, entry] of entries.entries()) {
600 - const alias = aliases[`h${index}`];
601 - entry.completeUnsafe(
602 - Exit.succeed(alias == null ? [] : decodeGitHubPullRequestEntries(alias.nodes)),
603 - );
604 - }
605 - }),
606 - Effect.catchCause((cause) =>
607 - Effect.sync(() => {
608 - for (const entry of entries) entry.completeUnsafe(Exit.failCause(cause));
609 - }),
610 - ),
611 - );
612 - },
569 + /**
570 + * Head lookups to one host under one credential share aliased documents: the resolver batches by
571 + * the host's endpoint and `batchKey`. Each lookup has its own `repository` root, so lookups on
572 + * different repositories may share a document, and a repository GitHub cannot find fails only
573 + * its own. Interactive and background lookups never share one, since they use separate
574 + * resolvers, so a document is sent under one reserve setting.
575 + */
576 + const headResolver = GraphQLResolver.aliased(client.PullRequestsByHead, {
577 + batchKey: GitHubGraphQlClient.batchKey,
578 }).pipe(RequestResolver.batchN(HEAD_LOOKUPS_PER_DOCUMENT));
579 const interactiveHeadResolver = headResolver.pipe(
580 RequestResolver.setDelay(HEAD_LOOKUP_BATCH_WINDOW),
@@ -639,16 +604,33 @@ export const make = Effect.gen(function* () {
604 // owner is matched on the rows it returns.
605 const ownerMatch = /^([^:/\s]+):(.+)$/u.exec(input.headSelector.trim());
606 const headRefName = ownerMatch?.[2] ?? input.headSelector.trim();
642 - const rows = yield* Effect.request(
643 - new PullRequestsByHeadRead({
644 - ...locator,
645 - headRefName,
646 - state: input.state,
647 - limit: ownerMatch ? OWNER_HEAD_SCAN_LIMIT : limit,
607 + const result = yield* graphqlRead(
608 + {
609 + host: locator.host,
610 + operation: "listPullRequestsByHead",
611 allowReserve: input.allowReserve,
649 - }),
650 - input.allowReserve ? interactiveHeadResolver : backgroundHeadResolver,
612 + // Up to 50 heads of 100 rows each. A default branch such as `main` can match a hundred
613 + // fork pull requests, so the usual cap would cut the answer short.
614 + maxResponseBytes: HEAD_LOOKUP_MAX_RESPONSE_BYTES,
615 + },
616 + "GitHub returned an invalid change request list.",
617 + GraphQLResolver.request(
618 + {
619 + owner: locator.owner,
620 + name: locator.name,
621 + head: headRefName,
622 + states: GRAPHQL_STATES[input.state],
623 + first: ownerMatch ? OWNER_HEAD_SCAN_LIMIT : limit,
624 + },
625 + input.allowReserve ? interactiveHeadResolver : backgroundHeadResolver,
626 + ),
627 );
628 + if (result.repository === null) return yield* notFound("The repository could not be read.");
629 + const rows = (result.repository.pullRequests.nodes ?? []).flatMap((entry) => {
630 + const node = Option.getOrNull(decodePullRequestNode(entry));
631 + const record = node === null ? null : toPullRequestRecord(node);
632 + return record === null ? [] : [record];
633 + });
634 if (!ownerMatch) return rows;
635 const headOwner = ownerMatch[1]!.toLowerCase();
636 return rows
@@ -683,21 +665,19 @@ export const make = Effect.gen(function* () {
665 }
666 const locator = parsed.kind === "url" ? parsed.locator : yield* resolveRepository(input);
667 const decodeDetail = "GitHub returned an invalid pull request.";
686 - const decoded = yield* graphqlJson(
687 - {
688 - host: locator.host,
689 - operation: "getPullRequest",
690 - query: PULL_REQUEST_BY_NUMBER_QUERY,
691 - variables: { owner: locator.owner, name: locator.name, number: parsed.number },
692 - allowReserve: true,
693 - },
694 - decodePullRequestByNumber,
668 + const result = yield* graphqlRead(
669 + { host: locator.host, operation: "getPullRequest", allowReserve: true },
670 decodeDetail,
671 + client.PullRequestByNumber({
672 + owner: locator.owner,
673 + name: locator.name,
674 + number: parsed.number,
675 + }),
676 );
697 - const node = decoded.data.repository?.pullRequest;
677 + const node = result.repository?.pullRequest;
678 if (node == null) return yield* notFound("The pull request does not exist.");
699 - const [record] = decodeGitHubPullRequestEntries([node]);
700 - if (record === undefined)
679 + const record = toPullRequestRecord(node);
680 + if (record === null)
681 return yield* failure(decodeDetail, new Error("Malformed pull request."));
682 return record;
683 },
packages/source-control-github/src/server/gitHubConditionalChecks.test.ts
+11 -10
@@ -6,7 +6,8 @@ import * as Schema from "effect/Schema";
6 import * as Redacted from "effect/Redacted";
7 import type { PullRequestCheck } from "@t3tools/contracts";
8
9 -import * as GitHubApi from "./GitHubApi.ts";
9 +import * as GitHubRest from "./GitHubRest.ts";
10 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
11 import { KnownWorkflowRuns, makeChecksRevalidator } from "./gitHubConditionalChecks.ts";
12
13 const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
@@ -29,7 +30,7 @@ it.effect(
30 const known: Array<unknown> = [];
31 const revalidate = yield* makeChecksRevalidator.pipe(
32 Effect.provide(
32 - Layer.mock(GitHubApi.GitHubApi)({
33 + Layer.mock(GitHubRest.GitHubRest)({
34 rest: ({ path, ifNoneMatch }) =>
35 Effect.sync(() => {
36 requests.push(path);
@@ -78,7 +79,7 @@ it.effect(
79 });
80 const poll = (identity = credential) =>
81 revalidate(reference, read).pipe(
81 - Effect.provideService(GitHubApi.PinnedGitHubCredential, identity),
82 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, identity),
83 );
84 yield* poll();
85 expect(reads).toBe(1);
@@ -132,11 +133,11 @@ it.effect("does not retain failed or incomplete reads, and supports hosts withou
133 let reads = 0;
134 const revalidate = yield* makeChecksRevalidator.pipe(
135 Effect.provide(
135 - Layer.mock(GitHubApi.GitHubApi)({
136 + Layer.mock(GitHubRest.GitHubRest)({
137 rest: ({ path, ifNoneMatch }) =>
138 unavailable
139 ? Effect.fail(
139 - new GitHubApi.GitHubApiResponseError({
140 + new GitHubRequestPolicy.GitHubApiResponseError({
141 host: "github.com",
142 operation: "revalidateChecks",
143 status: 502,
@@ -165,7 +166,7 @@ it.effect("does not retain failed or incomplete reads, and supports hosts withou
166 reads++;
167 return fail
168 ? Effect.fail(
168 - new GitHubApi.GitHubApiResponseError({
169 + new GitHubRequestPolicy.GitHubApiResponseError({
170 host: "github.com",
171 operation: "read",
172 status: 500,
@@ -180,7 +181,7 @@ it.effect("does not retain failed or incomplete reads, and supports hosts withou
181 });
182 const poll = () =>
183 revalidate(reference, read).pipe(
183 - Effect.provideService(GitHubApi.PinnedGitHubCredential, credential),
184 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, credential),
185 );
186 yield* poll().pipe(Effect.flip);
187 fail = false;
@@ -218,11 +219,11 @@ it.effect("falls back when REST checks are unavailable without retrying unsuppor
219 let reads = 0;
220 const revalidate = yield* makeChecksRevalidator.pipe(
221 Effect.provide(
221 - Layer.mock(GitHubApi.GitHubApi)({
222 + Layer.mock(GitHubRest.GitHubRest)({
223 rest: () => {
224 probes++;
225 return Effect.fail(
225 - new GitHubApi.GitHubApiNotFoundError({
226 + new GitHubRequestPolicy.GitHubApiNotFoundError({
227 host: "github.com",
228 operation: "revalidateChecks",
229 }),
@@ -237,7 +238,7 @@ it.effect("falls back when REST checks are unavailable without retrying unsuppor
238 });
239 for (let tick = 0; tick < 2; tick++)
240 yield* revalidate(reference, read).pipe(
240 - Effect.provideService(GitHubApi.PinnedGitHubCredential, credential),
241 + Effect.provideService(GitHubRequestPolicy.PinnedGitHubCredential, credential),
242 );
243 expect(probes).toBe(1);
244 expect(reads).toBe(2);
packages/source-control-github/src/server/gitHubConditionalChecks.ts
+5 -4
@@ -7,7 +7,8 @@ import * as Schema from "effect/Schema";
7 import * as Semaphore from "effect/Semaphore";
8 import { PositiveInt, type PullRequestChecks } from "@t3tools/contracts";
9
10 -import * as GitHubApi from "./GitHubApi.ts";
10 +import * as GitHubRest from "./GitHubRest.ts";
11 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
12 import type { GitHubPullRequestDetail } from "./gitHubPullRequestJson.ts";
13 import type { GitHubPullRequestApiError } from "./GitHubPullRequestApi.ts";
14 import type { ProviderRepositoryRef } from "@t3tools/source-control-core/server/PullRequestProvider";
@@ -53,7 +54,7 @@ type Validator = { etag: string | undefined; next: boolean; body: string };
54 const UNSUPPORTED_STATUSES = new Set([404, 405, 501]);
55
56 export const makeChecksRevalidator = Effect.gen(function* () {
56 - const api = yield* GitHubApi.GitHubApi;
57 + const api = yield* GitHubRest.GitHubRest;
58 const entries = yield* Cache.makeWith(
59 (_key: string) =>
60 Effect.sync(() => ({
@@ -76,7 +77,7 @@ export const makeChecksRevalidator = Effect.gen(function* () {
77 >,
78 ) =>
79 Effect.gen(function* () {
79 - const credential = yield* GitHubApi.PinnedGitHubCredential;
80 + const credential = yield* GitHubRequestPolicy.PinnedGitHubCredential;
81 if (credential === null) return yield* read;
82 const key = `${credential.credentialFingerprint}\0${input.host}\0${input.repository}\0${input.number}`;
83 const entry = yield* Cache.get(entries, key);
@@ -84,7 +85,7 @@ export const makeChecksRevalidator = Effect.gen(function* () {
85 Effect.gen(function* () {
86 if (!entry.supported) return yield* read;
87 const fail = (status: number) =>
87 - new GitHubApi.GitHubApiResponseError({
88 + new GitHubRequestPolicy.GitHubApiResponseError({
89 host: input.host,
90 operation: "revalidateChecks",
91 status,
packages/source-control-github/src/server/gitHubGraphQlClient.test.ts new
+304
@@ -0,0 +1,304 @@
1 +import { describe, expect, it } from "@effect/vitest";
2 +import * as Effect from "effect/Effect";
3 +import * as Layer from "effect/Layer";
4 +import * as Redacted from "effect/Redacted";
5 +import * as TestClock from "effect/testing/TestClock";
6 +import * as Tracer from "effect/Tracer";
7 +import { HttpClient, HttpClientResponse, type HttpClientRequest } from "effect/http";
8 +import { GraphQLClient, GraphQLResolver } from "effect/graphql";
9 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
10 +
11 +import * as GitHubRest from "./GitHubRest.ts";
12 +import * as GitHubCredentials from "./GitHubCredentials.ts";
13 +import * as GitHubGraphQlClient from "./gitHubGraphQlClient.ts";
14 +import * as GitHubQuota from "./GitHubQuota.ts";
15 +import { PullRequestBatchesGraphQLGroup } from "./pullRequestBatches.graphql.ts";
16 +
17 +const NOW = Date.parse("2026-10-05T12:00:00.000Z");
18 +
19 +function harness(respond: (request: HttpClientRequest.HttpClientRequest) => Response) {
20 + const requests: Array<HttpClientRequest.HttpClientRequest> = [];
21 + let invalidations = 0;
22 + const services = Layer.mergeAll(
23 + Layer.succeed(GitHubCredentials.GitHubCredentials, {
24 + get: (host) =>
25 + Effect.succeed({
26 + host,
27 + token: Redacted.make("secret"),
28 + source: "gh" as const,
29 + fingerprint: `${host}:secret`,
30 + }),
31 + invalidate: () =>
32 + Effect.sync(() => {
33 + invalidations++;
34 + }),
35 + }),
36 + Layer.succeed(
37 + HttpClient.HttpClient,
38 + HttpClient.make((request) => {
39 + requests.push(request);
40 + return Effect.succeed(HttpClientResponse.fromWeb(request, respond(request)));
41 + }),
42 + ),
43 + GitHubQuota.layer,
44 + SourceControlRateLimit.layer,
45 + );
46 + const layer = GitHubRest.layer.pipe(Layer.provideMerge(services));
47 + return { layer, requests, invalidations: () => invalidations };
48 +}
49 +
50 +const json = (body: unknown, init?: ResponseInit) =>
51 + new Response(JSON.stringify(body), {
52 + ...init,
53 + headers: { "content-type": "application/json", ...init?.headers },
54 + });
55 +
56 +/** One stats lookup on `host`, through the client and middleware the pull request reads use. */
57 +const readStats = (host: string, number = 7) =>
58 + Effect.gen(function* () {
59 + const client = yield* GraphQLClient.make(
60 + PullRequestBatchesGraphQLGroup.middleware(GitHubGraphQlClient.GitHubGraphQlAuth),
61 + ).pipe(Effect.provide(GitHubGraphQlClient.layer));
62 + return yield* GraphQLResolver.request(
63 + { owner: "acme", name: "web", number },
64 + GraphQLResolver.aliased(client.PullRequestStats, {
65 + batchKey: GitHubGraphQlClient.batchKey,
66 + }),
67 + ).pipe(
68 + Effect.provideService(GitHubGraphQlClient.GitHubGraphQlTarget, {
69 + host,
70 + operation: "stats",
71 + }),
72 + );
73 + });
74 +
75 +const stats = { additions: 3, deletions: 1 };
76 +
77 +describe("GitHubGraphQlAuth", () => {
78 + it.effect(
79 + "sends each host's lookups to its own endpoint with its token, never in one batch",
80 + () => {
81 + const { layer, requests } = harness(() =>
82 + json({ data: { _0_repository: { pullRequest: stats } } }),
83 + );
84 + return Effect.gen(function* () {
85 + const client = yield* GraphQLClient.make(
86 + PullRequestBatchesGraphQLGroup.middleware(GitHubGraphQlClient.GitHubGraphQlAuth),
87 + ).pipe(Effect.provide(GitHubGraphQlClient.layer));
88 + const resolver = GraphQLResolver.aliased(client.PullRequestStats, {
89 + batchKey: GitHubGraphQlClient.batchKey,
90 + });
91 + const lookup = (host: string) =>
92 + GraphQLResolver.request({ owner: "acme", name: "web", number: 7 }, resolver).pipe(
93 + Effect.provideService(GitHubGraphQlClient.GitHubGraphQlTarget, {
94 + host,
95 + operation: "stats",
96 + }),
97 + );
98 + yield* Effect.all([lookup("github.com"), lookup("github.acme.test")], {
99 + concurrency: "unbounded",
100 + });
101 + expect(requests.map((request) => request.url).toSorted()).toEqual([
102 + "https://api.github.com/graphql",
103 + "https://github.acme.test/api/graphql",
104 + ]);
105 + expect(requests[0]?.headers["authorization"]).toBe("Bearer secret");
106 + expect(requests[0]?.headers["x-github-api-version"]).toBe("2022-11-28");
107 + }).pipe(Effect.provide(layer));
108 + },
109 + );
110 +
111 + it.effect("pauses the host on a RATE_LIMITED answer sent with HTTP 200", () => {
112 + const reset = Math.floor(NOW / 1000) + 600;
113 + const { layer, requests } = harness(() =>
114 + json(
115 + { data: null, errors: [{ type: "RATE_LIMITED", message: "API rate limit exceeded" }] },
116 + { headers: { "x-ratelimit-remaining": "0", "x-ratelimit-reset": String(reset) } },
117 + ),
118 + );
119 + return Effect.gen(function* () {
120 + yield* TestClock.setTime(NOW);
121 + const first = yield* Effect.flip(readStats("github.com"));
122 + expect(first).toMatchObject({ _tag: "GitHubApiRateLimitError", retryAt: reset * 1000 });
123 + // The pause is the one REST reads respect too.
124 + const api = yield* GitHubRest.GitHubRest;
125 + const rest = yield* Effect.flip(
126 + api.rest({ host: "github.com", operation: "stack", path: "repos/acme/web/stacks" }),
127 + );
128 + expect(rest).toMatchObject({ _tag: "SourceControlRateLimitPausedError" });
129 + expect(requests).toHaveLength(1);
130 + }).pipe(Effect.provide(layer));
131 + });
132 +
133 + it.effect("reads an untyped exhausted-quota error sent with HTTP 200 as a rate limit", () => {
134 + const reset = Math.floor(NOW / 1000) + 900;
135 + const { layer } = harness(() =>
136 + json(
137 + { data: null, errors: [{ message: "API rate limit already exceeded for user ID 1." }] },
138 + { headers: { "x-ratelimit-remaining": "0", "x-ratelimit-reset": String(reset) } },
139 + ),
140 + );
141 + return Effect.gen(function* () {
142 + yield* TestClock.setTime(NOW);
143 + const error = yield* Effect.flip(readStats("github.com"));
144 + expect(error).toMatchObject({ _tag: "GitHubApiRateLimitError", retryAt: reset * 1000 });
145 + }).pipe(Effect.provide(layer));
146 + });
147 +
148 + it.effect("traces the query hash and quota, never the variables, token or URL", () => {
149 + const spans: Array<Tracer.NativeSpan> = [];
150 + const tracer = Tracer.make({
151 + span: (options) => {
152 + const span = new Tracer.NativeSpan(options);
153 + spans.push(span);
154 + return span;
155 + },
156 + });
157 + const { layer } = harness(() =>
158 + json(
159 + { data: { _0_repository: { pullRequest: stats } } },
160 + { headers: { "x-ratelimit-remaining": "4990", "x-ratelimit-resource": "graphql" } },
161 + ),
162 + );
163 + return Effect.gen(function* () {
164 + yield* TestClock.setTime(NOW);
165 + yield* readStats("github.com", 4242);
166 + const execute = spans.find((span) => span.name === "GitHubGraphQlAuth.execute")!;
167 + const attributes = Object.fromEntries(execute.attributes);
168 + expect(attributes).toMatchObject({
169 + "github.kind": "graphql",
170 + "github.operation": "stats",
171 + "http.response.status_code": 200,
172 + "github.ratelimit.remaining": 4990,
173 + "github.ratelimit.resource": "graphql",
174 + });
175 + expect(String(attributes["github.graphql.query_hash"])).toMatch(/^[0-9a-f]{8}$/);
176 + const everything = spans
177 + .flatMap((span) => [...span.attributes].map(([key, value]) => `${key}=${String(value)}`))
178 + .join("\n");
179 + expect(everything).not.toContain("4242");
180 + expect(everything).not.toContain("secret");
181 + expect(spans.some((span) => span.attributes.has("url.full"))).toBe(false);
182 + }).pipe(Effect.provide(layer), Effect.withTracer(tracer));
183 + });
184 +
185 + it.effect("reads a 403 secondary limit as a rate limit, and a 401 as a refused token", () => {
186 + const answers = [
187 + json({ message: "You have exceeded a secondary rate limit." }, { status: 403 }),
188 + json({ message: "Bad credentials" }, { status: 401 }),
189 + ];
190 + const { layer, invalidations } = harness(() => answers.shift()!);
191 + return Effect.gen(function* () {
192 + yield* TestClock.setTime(NOW);
193 + expect((yield* Effect.flip(readStats("github.com")))._tag).toBe("GitHubApiRateLimitError");
194 + expect((yield* Effect.flip(readStats("github.example")))._tag).toBe(
195 + "GitHubApiAuthenticationError",
196 + );
197 + expect(invalidations()).toBe(1);
198 + }).pipe(Effect.provide(layer));
199 + });
200 +
201 + it.effect("keeps the quota reserve for interactive requests", () => {
202 + const reset = Math.floor(NOW / 1000) + 600;
203 + const { layer, requests } = harness(() =>
204 + json(
205 + { data: { _0_repository: { pullRequest: stats } } },
206 + {
207 + headers: {
208 + "x-ratelimit-resource": "graphql",
209 + "x-ratelimit-limit": "5000",
210 + "x-ratelimit-remaining": "100",
211 + "x-ratelimit-reset": String(reset),
212 + },
213 + },
214 + ),
215 + );
216 + return Effect.gen(function* () {
217 + yield* TestClock.setTime(NOW);
218 + yield* readStats("github.com", 1).pipe(
219 + Effect.provideService(SourceControlRateLimit.Interactive, true),
220 + );
221 + // 100 of 5,000 left is inside the reserve, which a background read may not spend.
222 + const background = yield* Effect.flip(readStats("github.com", 2));
223 + expect(background._tag).toBe("SourceControlRateLimitPausedError");
224 + expect(requests).toHaveLength(1);
225 + // REST spends a quota of its own, which the GraphQL reserve does not hold back.
226 + const api = yield* GitHubRest.GitHubRest;
227 + yield* api.rest({ host: "github.com", operation: "user", path: "user" });
228 + expect(requests).toHaveLength(2);
229 + }).pipe(Effect.provide(layer));
230 + });
231 +});
232 +
233 +/** One unbatched stats read on github.com, through `call`. */
234 +const callStats = (target: Partial<GitHubGraphQlClient.GitHubGraphQlTarget["Service"]> = {}) =>
235 + Effect.gen(function* () {
236 + const client = yield* GraphQLClient.make(
237 + PullRequestBatchesGraphQLGroup.middleware(GitHubGraphQlClient.GitHubGraphQlAuth),
238 + ).pipe(Effect.provide(GitHubGraphQlClient.layer));
239 + return yield* client
240 + .PullRequestStats({ owner: "acme", name: "web", number: 7 })
241 + .pipe(GitHubGraphQlClient.call({ host: "github.com", operation: "stats", ...target }));
242 + });
243 +
244 +describe("call", () => {
245 + it.effect("fails an answer whose errors all say NOT_FOUND as a missing resource", () => {
246 + const { layer } = harness(() =>
247 + json({
248 + data: { repository: null },
249 + errors: [{ type: "NOT_FOUND", message: "Could not resolve to a Repository" }],
250 + }),
251 + );
252 + return Effect.gen(function* () {
253 + const error = yield* Effect.flip(callStats());
254 + expect(error).toMatchObject({
255 + _tag: "GitHubApiNotFoundError",
256 + host: "github.com",
257 + operation: "stats",
258 + });
259 + }).pipe(Effect.provide(layer));
260 + });
261 +
262 + it.effect(
263 + "fails NOT_FOUND alongside another error as a failure carrying GitHub's reasons",
264 + () => {
265 + const { layer } = harness(() =>
266 + json({
267 + data: null,
268 + errors: [
269 + { type: "NOT_FOUND", message: "Could not resolve" },
270 + { type: "FORBIDDEN", message: "Resource not accessible" },
271 + ],
272 + }),
273 + );
274 + return Effect.gen(function* () {
275 + const error = yield* Effect.flip(callStats());
276 + expect(error).toMatchObject({
277 + _tag: "GitHubApiResponseError",
278 + status: 200,
279 + githubErrors: ["Could not resolve", "Resource not accessible"],
280 + });
281 + }).pipe(Effect.provide(layer));
282 + },
283 + );
284 +
285 + it.effect("leaves an answer that does not decode to the caller", () => {
286 + const { layer } = harness(() =>
287 + json({ data: { repository: { pullRequest: { additions: "many" } } } }),
288 + );
289 + return Effect.gen(function* () {
290 + const error = yield* Effect.flip(callStats());
291 + expect(error).toMatchObject({ _tag: "GraphQLClientError", reason: { _tag: "DecodeError" } });
292 + }).pipe(Effect.provide(layer));
293 + });
294 +
295 + it.effect("fails an answer past the byte cap with its status", () => {
296 + const { layer } = harness(() =>
297 + json({ data: { repository: { pullRequest: { ...stats, padding: "x".repeat(200) } } } }),
298 + );
299 + return Effect.gen(function* () {
300 + const error = yield* Effect.flip(callStats({ maxResponseBytes: 64 }));
301 + expect(error).toMatchObject({ _tag: "GitHubApiResponseError", status: 200 });
302 + }).pipe(Effect.provide(layer));
303 + });
304 +});
packages/source-control-github/src/server/gitHubGraphQlClient.ts new
+295
@@ -0,0 +1,295 @@
1 +import * as Context from "effect/Context";
2 +import * as Effect from "effect/Effect";
3 +import { dual } from "effect/Function";
4 +import * as Layer from "effect/Layer";
5 +import * as Option from "effect/Option";
6 +import * as Stream from "effect/Stream";
7 +import { HttpClient, HttpClientError, HttpClientResponse } from "effect/http";
8 +import * as Headers from "effect/http/Headers";
9 +import { GraphQLClientError, GraphQLMiddleware, GraphQLProtocol } from "effect/graphql";
10 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
11 +import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
12 +
13 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
14 +
15 +const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
16 +
17 +/**
18 + * The GitHub host and operation a generated GraphQL call is sent as. One client serves every host,
19 + * so each call names its own.
20 + */
21 +export class GitHubGraphQlTarget extends Context.Service<
22 + GitHubGraphQlTarget,
23 + {
24 + readonly host: string;
25 + readonly operation: string;
26 + /** Overrides `SourceControlRateLimit.Interactive` for this one call. */
27 + readonly allowReserve?: boolean | undefined;
28 + /** A longer answer fails as a `GitHubApiResponseError`. Defaults to 8 MB. */
29 + readonly maxResponseBytes?: number | undefined;
30 + }
31 +>()("@t3tools/source-control-github/server/gitHubGraphQlClient/GitHubGraphQlTarget") {}
32 +
33 +/** A stable short id for a GraphQL document, so traces group by query without its text. */
34 +function queryHash(query: string): string {
35 + let hash = 0x811c9dc5;
36 + for (let index = 0; index < query.length; index++) {
37 + hash ^= query.charCodeAt(index);
38 + hash = Math.imul(hash, 0x01000193);
39 + }
40 + return (hash >>> 0).toString(16).padStart(8, "0");
41 +}
42 +
43 +/**
44 + * Whether GitHub's `errors` all say the thing asked for does not exist, or that the credential
45 + * cannot see it. A batch reports that for one pull request alone.
46 + */
47 +export const isNotFoundOnly = (error: unknown): boolean =>
48 + GraphQLClientError.isGraphQLClientError(error) &&
49 + error.reason._tag === "ResponseError" &&
50 + error.reason.errors.every((graphQlError) => graphQlError["type"] === "NOT_FOUND");
51 +
52 +/**
53 + * GitHub's auth and rate limits around a generated GraphQL call, through `GitHubRequestPolicy`:
54 + * the same credential, request slots, quota and pause as REST. It fails with the policy's
55 + * errors, which every GitHub caller already maps. GraphQL `errors` that are not a rate limit are
56 + * the client's: a batch settles them per pull request, and `call` maps the rest.
57 + */
58 +export class GitHubGraphQlAuth extends GraphQLMiddleware.Service<
59 + GitHubGraphQlAuth,
60 + { requires: GitHubGraphQlTarget; error: GitHubRequestPolicy.GitHubApiError }
61 +>()("@t3tools/source-control-github/server/gitHubGraphQlClient/GitHubGraphQlAuth") {
62 + static readonly layer = Layer.effect(
63 + GitHubGraphQlAuth,
64 + Effect.gen(function* () {
65 + const policy = yield* GitHubRequestPolicy.GitHubRequestPolicy;
66 + return GitHubGraphQlAuth.of({
67 + execute: ({ request, next }) =>
68 + Effect.gen(function* () {
69 + const target = yield* GitHubGraphQlTarget;
70 + const host = GitHubRequestPolicy.normalizeHost(target.host);
71 + yield* Effect.annotateCurrentSpan({
72 + "github.kind": "graphql",
73 + "github.graphql.query_hash": queryHash(request.query),
74 + });
75 + return yield* policy.request(
76 + {
77 + host,
78 + operation: target.operation,
79 + resource: "graphql",
80 + allowReserve: target.allowReserve ?? (yield* SourceControlRateLimit.Interactive),
81 + },
82 + (headers) =>
83 + next({ ...request, headers: Headers.setAll(request.headers, headers) }).pipe(
84 + Effect.map((answer) => {
85 + const status = answer.status;
86 + const responseHeaders = answer.headers ?? Headers.empty;
87 + const rateLimited = GitHubRequestPolicy.isRateLimited({
88 + status: status ?? 200,
89 + headers: responseHeaders,
90 + ...(answer.errors === undefined ? {} : { graphqlErrors: answer.errors }),
91 + });
92 + return rateLimited
93 + ? { _tag: "RateLimited" as const, status, headers: responseHeaders }
94 + : { _tag: "Ok" as const, value: answer, status, headers: responseHeaders };
95 + }),
96 + Effect.catchIf(GraphQLClientError.isGraphQLClientError, (error) =>
97 + refused(error, { host, operation: target.operation }),
98 + ),
99 + ),
100 + );
101 + }).pipe(Effect.withSpan("GitHubGraphQlAuth.execute")),
102 + subscribe: () => Stream.die(new Error("GitHub GraphQL has no subscriptions.")),
103 + });
104 + }),
105 + );
106 +}
107 +
108 +/**
109 + * What a refusal GitHub sent as an HTTP status means, read the way REST reads one. A
110 + * failure that never reached GitHub is a request error; one that is not about the transport
111 + * (an answer that does not decode) is the client's own.
112 + */
113 +const refused = (
114 + error: GraphQLClientError.GraphQLClientError,
115 + context: { readonly host: string; readonly operation: string },
116 +) =>
117 + Effect.gen(function* () {
118 + const reason = error.reason;
119 + if (reason._tag !== "TransportError" && reason._tag !== "ResponseError") {
120 + return yield* Effect.fail(error);
121 + }
122 + const status = reason.status;
123 + if (reason._tag === "TransportError" && status === undefined) {
124 + return yield* new GitHubRequestPolicy.GitHubApiRequestError({ ...context, cause: error });
125 + }
126 + const headers = reason.headers ?? Headers.empty;
127 + // A secondary limit is a 403 that only its body names, which the transport read.
128 + const body =
129 + reason._tag === "TransportError" &&
130 + HttpClientError.isHttpClientError(reason.cause) &&
131 + reason.cause.response !== undefined
132 + ? yield* reason.cause.response.text.pipe(Effect.orElseSucceed(() => ""))
133 + : "";
134 + const tag = GitHubRequestPolicy.isRateLimited({
135 + status: status ?? 200,
136 + headers,
137 + body,
138 + ...(reason._tag === "ResponseError" ? { graphqlErrors: reason.errors } : {}),
139 + })
140 + ? "RateLimited"
141 + : status === 401
142 + ? "Unauthorized"
143 + : status === 404
144 + ? "NotFound"
145 + : "Failed";
146 + return { _tag: tag, status: status ?? 200, headers } as const;
147 + });
148 +
149 +/**
150 + * Reads each answer whole, up to the call's byte cap, before the protocol parses it. A body cut
151 + * at the cap hides any `errors` past the cut and cannot be decoded, so it fails, which the
152 + * middleware reports as a `GitHubApiResponseError` with the answer's status.
153 + */
154 +const capResponse = (
155 + effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError>,
156 +) =>
157 + Effect.gen(function* () {
158 + const response = yield* effect;
159 + const target = yield* Effect.serviceOption(GitHubGraphQlTarget);
160 + const maxBytes = Option.match(target, {
161 + onNone: () => DEFAULT_MAX_RESPONSE_BYTES,
162 + onSome: (target) => target.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES,
163 + });
164 + const collected = yield* collectUint8StreamText({ stream: response.stream, maxBytes }).pipe(
165 + Effect.catchIf(
166 + (error) => error.reason._tag === "EmptyBodyError",
167 + () => Effect.succeed({ text: "", truncated: false }),
168 + ),
169 + );
170 + if (collected.truncated) {
171 + return yield* new HttpClientError.HttpClientError({
172 + reason: new HttpClientError.DecodeError({
173 + request: response.request,
174 + response,
175 + description: `The answer is longer than ${maxBytes} bytes.`,
176 + }),
177 + });
178 + }
179 + return HttpClientResponse.fromWeb(
180 + response.request,
181 + new Response(collected.text === "" ? null : collected.text, {
182 + status: response.status,
183 + headers: response.headers,
184 + }),
185 + );
186 + });
187 +
188 +/**
189 + * The HTTP transport, sending each request to its target host's endpoint. Resolvers batch by this
190 + * URL, so lookups for different hosts never share a request. `GitHubGraphQlAuth` requires the
191 + * target, so every call has one. The middleware's span is the request's: the client's own would add
192 + * `url.full`, which can carry SHAs and branch names, so it is off, as for REST.
193 + */
194 +const layerProtocol = GraphQLProtocol.layerHttp({
195 + url: ({ context }) =>
196 + GitHubRequestPolicy.gitHubApiUrls(Context.getUnsafe(context, GitHubGraphQlTarget).host).graphql,
197 +}).pipe(
198 + Layer.provide(
199 + Layer.effect(
200 + HttpClient.HttpClient,
201 + Effect.gen(function* () {
202 + const client = yield* HttpClient.HttpClient;
203 + return HttpClient.transformResponse(client, (effect) =>
204 + capResponse(effect).pipe(
205 + Effect.provideService(HttpClient.TracerDisabledWhen, () => true),
206 + ),
207 + );
208 + }),
209 + ),
210 + ),
211 +);
212 +
213 +/**
214 + * What a client built over `.middleware(GitHubGraphQlAuth)` needs beyond `GitHubRequestPolicy`
215 + * and the HTTP client.
216 + */
217 +export const layer = Layer.merge(GitHubGraphQlAuth.layer, layerProtocol);
218 +
219 +/**
220 + * What decides which lookups to one host may share a batched request: the credential and
221 + * rate-limit scope it will be sent under. Read from the context the lookup was made in. Resolvers
222 + * already keep hosts apart, since they batch by the transport's URL too.
223 + */
224 +export const batchKey = (context: Context.Context<GitHubGraphQlTarget>) =>
225 + JSON.stringify([
226 + Context.getOrElse(context, GitHubRequestPolicy.PinnedGitHubCredential, () => null)
227 + ?.credentialFingerprint ?? null,
228 + Context.getOrElse(context, SourceControlRateLimit.CredentialScope, () => ""),
229 + ]);
230 +
231 +/**
232 + * GitHub's `errors` on an answer, as the policy's errors: not found when every error says so,
233 + * otherwise a response error carrying GitHub's messages. Any other client error (an answer that
234 + * does not decode) is returned as it is.
235 + */
236 +const fromClientError = (
237 + target: { readonly host: string; readonly operation: string },
238 + error: GraphQLClientError.GraphQLClientError,
239 +):
240 + | GitHubRequestPolicy.GitHubApiNotFoundError
241 + | GitHubRequestPolicy.GitHubApiResponseError
242 + | GraphQLClientError.GraphQLClientError => {
243 + const reason = error.reason;
244 + if (reason._tag !== "ResponseError") return error;
245 + const context = {
246 + host: GitHubRequestPolicy.normalizeHost(target.host),
247 + operation: target.operation,
248 + };
249 + return isNotFoundOnly(error)
250 + ? new GitHubRequestPolicy.GitHubApiNotFoundError(context)
251 + : new GitHubRequestPolicy.GitHubApiResponseError({
252 + ...context,
253 + status: reason.status ?? 200,
254 + githubErrors: reason.errors.map((graphQlError) => graphQlError.message),
255 + });
256 +};
257 +
258 +/**
259 + * Runs one generated GraphQL call (or several) against `target`, failing GitHub's `errors` as
260 + * `GitHubApiNotFoundError` or `GitHubApiResponseError`. What remains a `GraphQLClientError` is an
261 + * answer that did not decode, which the caller reports as its own read error. The middleware's
262 + * errors pass through.
263 + */
264 +export const call: {
265 + (
266 + target: GitHubGraphQlTarget["Service"],
267 + ): <A, E, R>(
268 + effect: Effect.Effect<A, E, R>,
269 + ) => Effect.Effect<
270 + A,
271 + E | GitHubRequestPolicy.GitHubApiNotFoundError | GitHubRequestPolicy.GitHubApiResponseError,
272 + Exclude<R, GitHubGraphQlTarget>
273 + >;
274 + <A, E, R>(
275 + effect: Effect.Effect<A, E, R>,
276 + target: GitHubGraphQlTarget["Service"],
277 + ): Effect.Effect<
278 + A,
279 + E | GitHubRequestPolicy.GitHubApiNotFoundError | GitHubRequestPolicy.GitHubApiResponseError,
280 + Exclude<R, GitHubGraphQlTarget>
281 + >;
282 +} = dual(2, <A, E, R>(effect: Effect.Effect<A, E, R>, target: GitHubGraphQlTarget["Service"]) =>
283 + effect.pipe(
284 + // A `GraphQLClientError` left unmapped is one `E` already holds.
285 + Effect.mapError((error) =>
286 + GraphQLClientError.isGraphQLClientError(error)
287 + ? (fromClientError(target, error) as
288 + | E
289 + | GitHubRequestPolicy.GitHubApiNotFoundError
290 + | GitHubRequestPolicy.GitHubApiResponseError)
291 + : error,
292 + ),
293 + Effect.provideService(GitHubGraphQlTarget, target),
294 + ),
295 +);
packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
+565 -369
@@ -1,35 +1,240 @@
1 import * as Result from "effect/Result";
2 +import * as Schema from "effect/Schema";
3 import { describe, expect, it } from "vite-plus/test";
4
5 import {
5 - buildPullRequestSummariesGraphQlQuery,
6 - buildPullRequestWatchFingerprintsGraphQlQuery,
7 - decodePullRequestSummariesJson,
8 - decodePullRequestWatchFingerprintsJson,
6 buildReviewSubmission,
10 - buildPullRequestStackMembershipsGraphQlQuery,
11 - decodePullRequestStackMembershipsJson,
7 buildReviewerRequest,
13 - buildSetFilesViewedGraphQlMutation,
14 - decodePullRequestActivityJson,
8 + pullRequestLookup,
9 + toPullRequestSummary,
10 + toPullRequestWatchFingerprint,
11 decodePullRequestDetailJson,
12 decodePullRequestFilesJson,
17 - decodePullRequestFilesViewedJson,
18 - decodePullRequestListJson,
19 - decodePullRequestNodeIdJson,
20 - decodePullRequestSearchJson,
13 decodePullRequestStacksJson,
22 - decodeLabelCandidatesJson,
23 - decodeReviewerCandidatesJson,
24 - decodeReviewThreadCommentsJson,
25 - decodeReviewThreadsJson,
26 - decodeViewerPermissionsJson,
14 decodeWorkflowRunsJson,
15 + LenientPullRequestList,
16 + LenientPullRequestSearch,
17 reviewThreadConversation,
29 - REVIEW_THREADS_GRAPHQL_QUERY,
30 - pullRequestCoreGraphQlQuery,
31 - pullRequestSearchGraphQlQuery,
18 + toLabelCandidates,
19 + toPullRequestActivityPage,
20 + toPullRequestCore,
21 + toPullRequestFilesViewedPage,
22 + toPullRequestNodeId,
23 + toPullRequestRows,
24 + toReviewerCandidates,
25 + toReviewThreadCommentsPage,
26 + toCanWrite,
27 + toReviewThreadPage,
28 + toViewerPermissions,
29 } from "./gitHubPullRequestJson.ts";
30 +import { PullRequestSummary, PullRequestWatchFingerprint } from "./pullRequestBatches.graphql.ts";
31 +import {
32 + LabelCandidates,
33 + PullRequestActivity,
34 + PullRequestCore,
35 + PullRequestFilesViewed,
36 + PullRequestNodeId,
37 + ReviewerCandidates,
38 + ViewerPermissions,
39 +} from "./pullRequestReads.graphql.ts";
40 +import { ReviewThreadComments, ReviewThreads } from "./pullRequestReviews.graphql.ts";
41 +
42 +/**
43 + * A GitHub answer (`{ data }` as JSON) through a generated operation's result schema and then its
44 + * mapping, the way the client decodes and the API maps. A mapping's null (nothing found) fails.
45 + */
46 +const through =
47 + <S extends Schema.Codec<unknown, unknown>, A>(schema: S, map: (result: S["Type"]) => A | null) =>
48 + (raw: string): Result.Result<A, unknown> => {
49 + const decoded = Schema.decodeUnknownResult(schema)(
50 + (JSON.parse(raw) as { readonly data: unknown }).data,
51 + );
52 + if (Result.isFailure(decoded)) return Result.fail(decoded.failure);
53 + const mapped = map(decoded.success);
54 + return mapped === null ? Result.fail("not found") : Result.succeed(mapped);
55 + };
56 +
57 +/** An account as a selection with `__typename` answers it: GitHub always sends the type. */
58 +const user = (login: string, fields: Record<string, unknown> = {}) => ({
59 + __typename: "User",
60 + login,
61 + ...fields,
62 +});
63 +
64 +/** A listing row with every field the row selection asks for, as GitHub always answers it. */
65 +const row = (fields: Record<string, unknown>) => ({
66 + number: 1,
67 + title: "Add the pull requests page",
68 + url: "https://github.com/pingdotgg/t3code/pull/1",
69 + author: null,
70 + headRefName: "feat/page",
71 + baseRefName: "main",
72 + state: "OPEN",
73 + isDraft: false,
74 + mergeable: "UNKNOWN",
75 + reviewDecision: null,
76 + latestReviews: { nodes: [] },
77 + createdAt: "2026-07-01T00:00:00Z",
78 + updatedAt: "2026-07-02T00:00:00Z",
79 + mergedAt: null,
80 + repository: { nameWithOwner: "pingdotgg/t3code" },
81 + reviewRequests: { nodes: [] },
82 + labels: { nodes: [] },
83 + commits: { nodes: [] },
84 + ...fields,
85 +});
86 +
87 +const listPage = (page: ReturnType<typeof toPullRequestRows>) => ({
88 + items: page.rows.map((row) => ({
89 + ...row.item,
90 + ...(row.repository === null ? {} : { repository: row.repository }),
91 + })),
92 + rawCount: page.rawCount,
93 +});
94 +const decodePullRequestListJson = through(LenientPullRequestList.result, (result) =>
95 + listPage(toPullRequestRows(result.repository?.pullRequests)),
96 +);
97 +const decodePullRequestSearchJson = through(LenientPullRequestSearch.result, (result) =>
98 + listPage(toPullRequestRows(result.search)),
99 +);
100 +const decodePullRequestActivityJson = through(
101 + PullRequestActivity.result,
102 + toPullRequestActivityPage,
103 +);
104 +const decodePullRequestCoreJson = through(PullRequestCore.result, toPullRequestCore);
105 +/**
106 + * Fills in what every review read answers with, so each fixture below says only what it is about:
107 + * a page with no more after it, an actor typed as a person, no reactions, no edits.
108 + */
109 +// Fixtures are loose JSON on purpose: each one writes only the fields its test is about.
110 +type Json = Record<string, any>;
111 +const LAST_PAGE = { hasNextPage: false, endCursor: null };
112 +const nodesIn = (connection: Json | null | undefined): ReadonlyArray<Json> =>
113 + connection?.["nodes"] ?? [];
114 +const actor = (raw: Json | null | undefined) =>
115 + raw === null || raw === undefined ? null : { __typename: "User", avatarUrl: "", ...raw };
116 +const reactionGroups = (groups: ReadonlyArray<Json> | undefined) =>
117 + (groups ?? []).map(({ reactors, ...group }) => ({
118 + viewerHasReacted: false,
119 + ...group,
120 + reactors: {
121 + totalCount: 0,
122 + ...reactors,
123 + nodes: nodesIn(reactors).map((node) => ({ __typename: "User", ...node })),
124 + },
125 + }));
126 +const remark = ({ author, reactionGroups: groups, ...raw }: Json) => ({
127 + body: "",
128 + lastEditedAt: null,
129 + url: "https://github.com/acme/web/pull/1#discussion",
130 + ...raw,
131 + author: actor(author),
132 + reactionGroups: reactionGroups(groups),
133 +});
134 +const threadCommentsOf = ({ nodes, ...connection }: Json) => ({
135 + totalCount: (nodes ?? []).length,
136 + pageInfo: LAST_PAGE,
137 + ...connection,
138 + nodes: (nodes ?? []).map(remark),
139 +});
140 +const requestedReviewer = (raw: Json | null) =>
141 + raw === null
142 + ? null
143 + : "login" in raw
144 + ? { name: null, ...actor(raw) }
145 + : { __typename: "Team", ...raw };
146 +const reviewCommit = ({ commit: { authors, ...commit } }: Json) => ({
147 + commit: {
148 + messageHeadline: "",
149 + committedDate: "",
150 + additions: 0,
151 + deletions: 0,
152 + parents: { totalCount: 1 },
153 + ...commit,
154 + authors: {
155 + nodes: nodesIn(authors).map((author) => ({
156 + name: null,
157 + avatarUrl: "",
158 + user: null,
159 + ...author,
160 + })),
161 + },
162 + },
163 +});
164 +const withReviewDefaults = (raw: string): string => {
165 + const { data } = JSON.parse(raw) as { data: Json };
166 + const pr = data["repository"]?.["pullRequest"];
167 + if (pr?.["reviewThreads"] !== undefined) {
168 + const {
169 + reviewThreads,
170 + author,
171 + reactionGroups: groups,
172 + comments,
173 + reviews,
174 + reviewRequests,
175 + latestReviews,
176 + commits,
177 + ...rest
178 + } = pr;
179 + data["repository"]["pullRequest"] = {
180 + viewerCanUpdate: true,
181 + viewerDidAuthor: false,
182 + reviewDismissals: { pageInfo: LAST_PAGE, nodes: [] },
183 + ...rest,
184 + author: actor(author),
185 + reactionGroups: reactionGroups(groups),
186 + comments: { nodes: nodesIn(comments).map(remark) },
187 + reviews: { nodes: nodesIn(reviews).map(remark) },
188 + reviewRequests: {
189 + nodes: nodesIn(reviewRequests).map((node) => ({
190 + requestedReviewer: requestedReviewer(node["requestedReviewer"]),
191 + })),
192 + },
193 + latestReviews: {
194 + nodes: nodesIn(latestReviews).map((node) => ({
195 + state: "COMMENTED",
196 + ...node,
197 + author: actor(node["author"]),
198 + })),
199 + },
200 + commits: { nodes: nodesIn(commits).map(reviewCommit) },
201 + reviewThreads: {
202 + totalCount: nodesIn(reviewThreads).length,
203 + pageInfo: LAST_PAGE,
204 + ...reviewThreads,
205 + nodes: nodesIn(reviewThreads).map((thread) => ({
206 + isResolved: false,
207 + isOutdated: false,
208 + line: null,
209 + diffSide: "RIGHT",
210 + ...thread,
211 + comments: threadCommentsOf(thread["comments"]),
212 + })),
213 + },
214 + };
215 + }
216 + if (data["node"] !== undefined && data["node"] !== null) {
217 + data["node"] = {
218 + __typename: "PullRequestReviewThread",
219 + ...data["node"],
220 + comments: threadCommentsOf(data["node"]["comments"]),
221 + };
222 + }
223 + data["viewer"] ??= { login: "viewer" };
224 + return JSON.stringify({ data });
225 +};
226 +const decodeReviewThreadsJson = (raw: string) =>
227 + through(ReviewThreads.result, toReviewThreadPage)(withReviewDefaults(raw));
228 +const decodeReviewThreadCommentsJson = (raw: string) =>
229 + through(ReviewThreadComments.result, toReviewThreadCommentsPage)(withReviewDefaults(raw));
230 +const decodeViewerPermissionsJson = through(ViewerPermissions.result, toViewerPermissions);
231 +const decodeLabelCandidatesJson = through(LabelCandidates.result, toLabelCandidates);
232 +const decodeReviewerCandidatesJson = through(ReviewerCandidates.result, toReviewerCandidates);
233 +const decodePullRequestNodeIdJson = through(PullRequestNodeId.result, toPullRequestNodeId);
234 +const decodePullRequestFilesViewedJson = through(
235 + PullRequestFilesViewed.result,
236 + toPullRequestFilesViewedPage,
237 +);
238
239 /**
240 * Rows as a repository's own GraphQL list answers them. Entries may use flat shapes for brevity:
@@ -40,30 +245,27 @@ function listJson(entries: ReadonlyArray<Record<string, unknown>>): string {
245 data: {
246 repository: {
247 pullRequests: {
43 - pageInfo: { hasNextPage: false },
44 - nodes: entries.map(({ reviewRequests, latestReviews, checks, ...entry }) => ({
45 - number: 1,
46 - title: "Add the pull requests page",
47 - url: "https://github.com/pingdotgg/t3code/pull/1",
48 - headRefName: "feat/page",
49 - baseRefName: "main",
50 - createdAt: "2026-07-01T00:00:00Z",
51 - updatedAt: "2026-07-02T00:00:00Z",
52 - ...(reviewRequests === undefined
53 - ? {}
54 - : {
55 - reviewRequests: {
56 - nodes: (reviewRequests as ReadonlyArray<unknown>).map((requestedReviewer) => ({
57 - requestedReviewer,
58 - })),
59 - },
60 - }),
61 - ...(latestReviews === undefined ? {} : { latestReviews: { nodes: latestReviews } }),
62 - ...(checks === undefined
63 - ? {}
64 - : { commits: { nodes: [{ commit: { statusCheckRollup: { state: checks } } }] } }),
65 - ...entry,
66 - })),
248 + pageInfo: { hasNextPage: false, endCursor: null },
249 + nodes: entries.map(({ reviewRequests, latestReviews, checks, ...entry }) =>
250 + row({
251 + ...(reviewRequests === undefined
252 + ? {}
253 + : {
254 + reviewRequests: {
255 + nodes: (reviewRequests as ReadonlyArray<unknown>).map(
256 + (requestedReviewer) => ({
257 + requestedReviewer,
258 + }),
259 + ),
260 + },
261 + }),
262 + ...(latestReviews === undefined ? {} : { latestReviews: { nodes: latestReviews } }),
263 + ...(checks === undefined
264 + ? {}
265 + : { commits: { nodes: [{ commit: { statusCheckRollup: { state: checks } } }] } }),
266 + ...entry,
267 + }),
268 + ),
269 },
270 },
271 },
@@ -100,7 +302,14 @@ describe("pull request list decoding", () => {
302 it("keeps user review requests and drops team ones, which are not logins", () => {
303 const [entry] = expectSuccess(
304 decodePullRequestListJson(
103 - listJson([{ reviewRequests: [{ login: "octocat" }, { slug: "web-platform" }] }]),
305 + listJson([
306 + {
307 + reviewRequests: [
308 + { __typename: "User", login: "octocat" },
309 + { __typename: "Team", slug: "web-platform" },
310 + ],
311 + },
312 + ]),
313 ),
314 ).items;
315 expect(entry?.reviewRequestLogins).toEqual(["octocat"]);
@@ -131,22 +340,22 @@ describe("pull request list decoding", () => {
340 listJson([
341 {
342 reviewDecision: null,
134 - latestReviews: [{ author: { login: "macroscopeapp" }, state: "APPROVED" }],
343 + latestReviews: [{ author: user("macroscopeapp"), state: "APPROVED" }],
344 },
345 {
346 reviewDecision: "REVIEW_REQUIRED",
347 latestReviews: [
139 - { author: { login: "octocat" }, state: "APPROVED" },
140 - { author: { login: "hubot" }, state: "CHANGES_REQUESTED" },
348 + { author: user("octocat"), state: "APPROVED" },
349 + { author: user("hubot"), state: "CHANGES_REQUESTED" },
350 ],
351 },
352 {
353 reviewDecision: "APPROVED",
145 - latestReviews: [{ author: { login: "hubot" }, state: "CHANGES_REQUESTED" }],
354 + latestReviews: [{ author: user("hubot"), state: "CHANGES_REQUESTED" }],
355 },
356 {
357 reviewDecision: null,
149 - latestReviews: [{ author: { login: "octocat" }, state: "COMMENTED" }],
358 + latestReviews: [{ author: user("octocat"), state: "COMMENTED" }],
359 },
360 ]),
361 ),
@@ -196,20 +405,16 @@ describe("pull request search decoding", () => {
405 return JSON.stringify({
406 data: {
407 search: {
199 - pageInfo: { hasNextPage: false },
200 - nodes: rollupStates.map((state, index) => ({
201 - number: index + 1,
202 - title: "Add the pull requests page",
203 - url: "https://github.com/pingdotgg/t3code/pull/1",
204 - headRefName: "feat/page",
205 - baseRefName: "main",
206 - createdAt: "2026-07-01T00:00:00Z",
207 - updatedAt: "2026-07-02T00:00:00Z",
208 - repository: { nameWithOwner: "pingdotgg/t3code" },
209 - commits: {
210 - nodes: [{ commit: { statusCheckRollup: state === null ? null : { state } } }],
211 - },
212 - })),
408 + pageInfo: { hasNextPage: false, endCursor: null },
409 + nodes: rollupStates.map((state, index) =>
410 + row({
411 + __typename: "PullRequest",
412 + number: index + 1,
413 + commits: {
414 + nodes: [{ commit: { statusCheckRollup: state === null ? null : { state } } }],
415 + },
416 + }),
417 + ),
418 },
419 },
420 });
@@ -222,8 +427,6 @@ describe("pull request search decoding", () => {
427 const batch = expectSuccess(decodePullRequestSearchJson(JSON.stringify(raw)));
428 expect(batch.items[0]?.stack).toEqual({ number: 3, size: 2, position: 1, base: "main" });
429 expect(batch.items[1]?.stack).toBeUndefined();
225 - expect(pullRequestSearchGraphQlQuery(20, true)).toContain("stackEntry");
226 - expect(pullRequestSearchGraphQlQuery(20)).not.toContain("stackEntry");
430 });
431
432 it("maps the rollup enum the search answers with onto the same three words", () => {
@@ -246,20 +449,101 @@ describe("pull request search decoding", () => {
449 });
450
451 describe("pull request detail decoding", () => {
452 + /** A check run or commit status as the core read's `CheckContext` fragment answers it. */
453 + const check = (fields: Record<string, unknown>) =>
454 + fields["__typename"] === "StatusContext"
455 + ? {
456 + context: "",
457 + state: "PENDING",
458 + targetUrl: null,
459 + createdAt: "2026-07-01T00:00:00Z",
460 + description: null,
461 + ...fields,
462 + }
463 + : {
464 + __typename: "CheckRun",
465 + name: "",
466 + status: "COMPLETED",
467 + conclusion: null,
468 + startedAt: null,
469 + completedAt: null,
470 + detailsUrl: null,
471 + checkSuite: { workflowRun: null },
472 + ...fields,
473 + };
474 + /** A check run owned by a workflow, which is how the core read names the workflow. */
475 + const inWorkflow = ({ workflowName, ...fields }: Record<string, unknown>) =>
476 + check({
477 + ...fields,
478 + checkSuite: { workflowRun: { workflow: { name: workflowName } } },
479 + });
480 +
481 + /** The core read's answer for pull request 7, with `rollup` as its head commit's checks. */
482 + const coreJson = (
483 + rollup: ReadonlyArray<Record<string, unknown>>,
484 + pullRequest: Record<string, unknown> = {},
485 + ) =>
486 + JSON.stringify({
487 + data: {
488 + repository: {
489 + mergeCommitAllowed: true,
490 + squashMergeAllowed: true,
491 + rebaseMergeAllowed: true,
492 + viewerPermission: "WRITE",
493 + pullRequest: {
494 + number: 7,
495 + title: "Detail",
496 + url: "https://github.com/pingdotgg/t3code/pull/7",
497 + body: "Body",
498 + state: "OPEN",
499 + isDraft: false,
500 + mergeable: "MERGEABLE",
501 + reviewDecision: null,
502 + additions: 0,
503 + deletions: 0,
504 + changedFiles: 0,
505 + createdAt: "2026-07-01T00:00:00Z",
506 + updatedAt: "2026-07-05T00:00:00Z",
507 + mergedAt: null,
508 + closedAt: null,
509 + headRefName: "feat/detail",
510 + baseRefName: "main",
511 + headRefOid: "abc123",
512 + isCrossRepository: false,
513 + headRepositoryOwner: null,
514 + headRepository: null,
515 + headRef: null,
516 + author: null,
517 + autoMergeRequest: null,
518 + viewerCanUpdate: true,
519 + viewerDidAuthor: false,
520 + viewerCanUpdateBranch: false,
521 + baseRef: null,
522 + reviewRequests: { nodes: [] },
523 + labels: { nodes: [] },
524 + commits: {
525 + nodes: [
526 + {
527 + commit: {
528 + statusCheckRollup: {
529 + contexts: { nodes: rollup, pageInfo: { hasNextPage: false } },
530 + },
531 + },
532 + },
533 + ],
534 + },
535 + ...pullRequest,
536 + },
537 + },
538 + },
539 + });
540 + const detailOf = (
541 + rollup: ReadonlyArray<Record<string, unknown>>,
542 + pullRequest?: Record<string, unknown>,
543 + ) => expectSuccess(decodePullRequestCoreJson(coreJson(rollup, pullRequest)));
544 +
545 + /** The conversation the activity read carries, in the flat shape the tests below write. */
546 const detailJson = JSON.stringify({
250 - number: 7,
251 - title: "Detail",
252 - url: "https://github.com/pingdotgg/t3code/pull/7",
253 - headRefName: "feat/detail",
254 - baseRefName: "main",
255 - createdAt: "2026-07-01T00:00:00Z",
256 - updatedAt: "2026-07-05T00:00:00Z",
257 - body: "Body",
258 - statusCheckRollup: [
259 - { __typename: "CheckRun", name: "build", status: "IN_PROGRESS" },
260 - { __typename: "CheckRun", name: "test", status: "COMPLETED", conclusion: "FAILURE" },
261 - { __typename: "StatusContext", context: "ci/legacy", state: "SUCCESS" },
262 - ],
547 comments: [{ id: "c1", body: "second", createdAt: "2026-07-04T00:00:00Z" }],
548 reviews: [
549 { id: "r1", body: "first", state: "CHANGES_REQUESTED", submittedAt: "2026-07-03T00:00:00Z" },
@@ -284,8 +568,30 @@ describe("pull request detail decoding", () => {
568 data: {
569 repository: {
570 pullRequest: {
287 - comments: { nodes: raw["comments"] ?? [] },
288 - reviews: { nodes: raw["reviews"] ?? [] },
571 + author: null,
572 + comments: {
573 + pageInfo: { hasNextPage: false, endCursor: null },
574 + nodes: ((raw["comments"] ?? []) as ReadonlyArray<Record<string, unknown>>).map(
575 + (comment) => ({
576 + lastEditedAt: null,
577 + url: "https://github.com/c",
578 + author: null,
579 + ...comment,
580 + }),
581 + ),
582 + },
583 + reviews: {
584 + pageInfo: { hasNextPage: false, endCursor: null },
585 + nodes: ((raw["reviews"] ?? []) as ReadonlyArray<Record<string, unknown>>).map(
586 + (review) => ({
587 + lastEditedAt: null,
588 + url: "https://github.com/r",
589 + author: null,
590 + submittedAt: null,
591 + ...review,
592 + }),
593 + ),
594 + },
595 commits: {
596 nodes: ((raw["commits"] ?? []) as ReadonlyArray<Record<string, unknown>>).map(
597 ({ authors, ...commit }) => ({
@@ -294,8 +600,10 @@ describe("pull request detail decoding", () => {
600 authors: {
601 nodes: ((authors ?? []) as ReadonlyArray<Record<string, unknown>>).map(
602 ({ login, ...author }) => ({
603 + name: null,
604 + email: null,
605 ...author,
298 - ...(login === undefined ? {} : { user: { login } }),
606 + user: login === undefined ? null : { login },
607 }),
608 ),
609 },
@@ -316,7 +624,11 @@ describe("pull request detail decoding", () => {
624 }));
625
626 it("maps check-run status and commit-status state onto one vocabulary", () => {
319 - const detail = expectSuccess(decodePullRequestDetailJson(detailJson));
627 + const detail = detailOf([
628 + check({ name: "build", status: "IN_PROGRESS" }),
629 + check({ name: "test", status: "COMPLETED", conclusion: "FAILURE" }),
630 + check({ __typename: "StatusContext", context: "ci/legacy", state: "SUCCESS" }),
631 + ]);
632 expect(detail.checks.map((check) => [check.name, check.status])).toEqual([
633 ["build", "pending"],
634 ["test", "failure"],
@@ -325,42 +637,23 @@ describe("pull request detail decoding", () => {
637 });
638
639 it("keeps what branch protection requires, and asks for it on github.com only", () => {
328 - const raw = JSON.parse(detailJson) as Record<string, unknown>;
329 - const detail = expectSuccess(
330 - decodePullRequestDetailJson(
331 - JSON.stringify({
332 - ...raw,
333 - statusCheckRollup: [
334 - { __typename: "CheckRun", name: "test", status: "IN_PROGRESS", isRequired: true },
335 - { __typename: "StatusContext", context: "bot", state: "PENDING", isRequired: false },
336 - { __typename: "StatusContext", context: "legacy", state: "SUCCESS" },
337 - ],
338 - }),
339 - ),
340 - );
640 + const detail = detailOf([
641 + check({ name: "test", status: "IN_PROGRESS", isRequired: true }),
642 + check({ __typename: "StatusContext", context: "bot", state: "PENDING", isRequired: false }),
643 + // Enterprise Server is not asked, so the field is absent rather than false.
644 + check({ __typename: "StatusContext", context: "legacy", state: "SUCCESS" }),
645 + ]);
646 expect(detail.checks.map((check) => check.required)).toEqual([true, false, undefined]);
342 - expect(pullRequestCoreGraphQlQuery("github.com")).toContain("isRequired");
343 - expect(pullRequestCoreGraphQlQuery("github.example.com")).not.toContain("isRequired");
647 + expect(PullRequestCore.document).toContain(
648 + "isRequired(pullRequestNumber:$number)@include(if:$required)",
649 + );
650 });
651
652 it("keeps a workflow waiting for approval out of the passing state", () => {
347 - const raw = JSON.parse(detailJson) as Record<string, unknown>;
348 - const detail = expectSuccess(
349 - decodePullRequestDetailJson(
350 - JSON.stringify({
351 - ...raw,
352 - statusCheckRollup: [
353 - { __typename: "CheckRun", name: "build", status: "COMPLETED", conclusion: "SUCCESS" },
354 - {
355 - __typename: "CheckRun",
356 - name: "contributor tests",
357 - status: "COMPLETED",
358 - conclusion: "ACTION_REQUIRED",
359 - },
360 - ],
361 - }),
362 - ),
363 - );
653 + const detail = detailOf([
654 + check({ name: "build", status: "COMPLETED", conclusion: "SUCCESS" }),
655 + check({ name: "contributor tests", status: "COMPLETED", conclusion: "ACTION_REQUIRED" }),
656 + ]);
657
658 expect(detail.checks.map((check) => check.status)).toEqual(["success", "action-required"]);
659 expect(detail.checksState).toBe("pending");
@@ -385,49 +678,50 @@ describe("pull request detail decoding", () => {
678 });
679
680 it("reads an auto-merge request and strategy, its null as off and its absence as neither", () => {
388 - const raw = JSON.parse(detailJson) as Record<string, unknown>;
389 - const armed = (entry: Record<string, unknown>) =>
390 - expectSuccess(decodePullRequestDetailJson(JSON.stringify({ ...raw, ...entry })));
391 -
681 + expect(detailOf([], { autoMergeRequest: { mergeMethod: "SQUASH" } })).toMatchObject({
682 + autoMergeEnabled: true,
683 + autoMergeMethod: "squash",
684 + });
685 + expect(detailOf([], { autoMergeRequest: null }).autoMergeEnabled).toBe(false);
686 + // A detail read that never asked about auto-merge does not claim it is unarmed.
687 expect(
393 - armed({ autoMergeRequest: { enabledBy: { login: "octocat" }, mergeMethod: "SQUASH" } }),
394 - ).toMatchObject({ autoMergeEnabled: true, autoMergeMethod: "squash" });
395 - expect(armed({ autoMergeRequest: null }).autoMergeEnabled).toBe(false);
396 - // `gh` not answering for the field at all is not GitHub saying the merge is unarmed.
397 - expect(armed({}).autoMergeEnabled).toBeUndefined();
688 + expectSuccess(
689 + decodePullRequestDetailJson(
690 + JSON.stringify({
691 + number: 7,
692 + title: "Detail",
693 + url: "https://github.com/pingdotgg/t3code/pull/7",
694 + headRefName: "feat/detail",
695 + baseRefName: "main",
696 + createdAt: "2026-07-01T00:00:00Z",
697 + updatedAt: "2026-07-05T00:00:00Z",
698 + }),
699 + ),
700 + ).autoMergeEnabled,
701 + ).toBeUndefined();
702 });
703
704 it("shows a re-running check once, as the run that is happening now", () => {
705 // What `statusCheckRollup` reports while a workflow is being re-run: the same check twice,
706 // the finished run and the one that replaced it, with no id to tell them apart.
403 - const raw = JSON.parse(detailJson) as Record<string, unknown>;
404 - const detail = expectSuccess(
405 - decodePullRequestDetailJson(
406 - JSON.stringify({
407 - ...raw,
408 - statusCheckRollup: [
409 - {
410 - __typename: "CheckRun",
411 - name: "Prepare PR size config",
412 - workflowName: "PR Size",
413 - status: "COMPLETED",
414 - conclusion: "SUCCESS",
415 - startedAt: "2026-08-11T16:06:20Z",
416 - completedAt: "2026-08-11T16:06:25Z",
417 - },
418 - {
419 - __typename: "CheckRun",
420 - name: "Prepare PR size config",
421 - workflowName: "PR Size",
422 - status: "IN_PROGRESS",
423 - conclusion: "",
424 - startedAt: "2026-08-11T17:01:04Z",
425 - completedAt: "0001-01-01T00:00:00Z",
426 - },
427 - ],
428 - }),
429 - ),
430 - );
707 + const detail = detailOf([
708 + inWorkflow({
709 + name: "Prepare PR size config",
710 + workflowName: "PR Size",
711 + status: "COMPLETED",
712 + conclusion: "SUCCESS",
713 + startedAt: "2026-08-11T16:06:20Z",
714 + completedAt: "2026-08-11T16:06:25Z",
715 + }),
716 + inWorkflow({
717 + name: "Prepare PR size config",
718 + workflowName: "PR Size",
719 + status: "IN_PROGRESS",
720 + conclusion: null,
721 + startedAt: "2026-08-11T17:01:04Z",
722 + completedAt: "0001-01-01T00:00:00Z",
723 + }),
724 + ]);
725
726 expect(detail.checks.map((check) => [check.name, check.status])).toEqual([
727 ["Prepare PR size config", "pending"],
@@ -439,7 +733,6 @@ describe("pull request detail decoding", () => {
733 // A workflow on both `push` and `pull_request` runs the same check twice on one commit. The
734 // `pull_request` run finished after the `push` run started, and the `push` run is still going.
735 const finished = {
442 - __typename: "CheckRun",
736 name: "check",
737 workflowName: "Checks",
738 status: "COMPLETED",
@@ -450,17 +743,14 @@ describe("pull request detail decoding", () => {
743 const running = {
744 ...finished,
745 status: "IN_PROGRESS",
453 - conclusion: "",
746 + conclusion: null,
747 startedAt: "2026-10-08T04:06:13Z",
748 completedAt: "0001-01-01T00:00:00Z",
749 };
750 // A run still queued has not started either, so it carries no time at all.
751 const queued = { ...running, status: "QUEUED", startedAt: "0001-01-01T00:00:00Z" };
459 - const raw = JSON.parse(detailJson) as Record<string, unknown>;
460 - const checksOf = (statusCheckRollup: ReadonlyArray<object>) => {
461 - const detail = expectSuccess(
462 - decodePullRequestDetailJson(JSON.stringify({ ...raw, statusCheckRollup })),
463 - );
752 + const checksOf = (rollup: ReadonlyArray<Record<string, unknown>>) => {
753 + const detail = detailOf(rollup.map(inWorkflow));
754 return [detail.checks.map((check) => [check.name, check.status]), detail.checksState];
755 };
756
@@ -527,12 +817,14 @@ describe("pull request detail decoding", () => {
817 },
818 );
819
530 - it("drops a review that carries neither a body nor a state", () => {
820 + it("drops a review that carries no body and no verdict", () => {
821 const raw = JSON.parse(detailJson) as Record<string, unknown>;
822 const detail = expectSuccess(
823 activity({
824 ...raw,
535 - reviews: [{ id: "r3", body: " ", submittedAt: "2026-07-07T00:00:00Z" }],
825 + reviews: [
826 + { id: "r3", body: " ", state: "COMMENTED", submittedAt: "2026-07-07T00:00:00Z" },
827 + ],
828 }),
829 );
830 expect(detail.comments.map((comment) => comment.id)).toEqual(["c1"]);
@@ -728,8 +1020,8 @@ describe("review thread decoding", () => {
1020 requested: [
1021 {
1022 combinedSlug: "pingdotgg/ping-devs",
731 - name: "Ping Devs",
732 - avatarUrl: "https://avatars.githubusercontent.com/t/6692390?s=400&v=4",
1023 + teamName: "Ping Devs",
1024 + teamAvatarUrl: "https://avatars.githubusercontent.com/t/6692390?s=400&v=4",
1025 },
1026 ],
1027 reviewed: [
@@ -760,7 +1052,12 @@ describe("review thread decoding", () => {
1052 // such as a mannequin. Failing on it would take the whole response down, comments included.
1053 const result = expectSuccess(
1054 decodeReviewThreadsJson(
763 - reviewJson({ requested: [{}, { login: "julius", avatarUrl: "https://avatars/j.png" }] }),
1055 + reviewJson({
1056 + requested: [
1057 + { __typename: "Mannequin" },
1058 + { login: "julius", avatarUrl: "https://avatars/j.png" },
1059 + ],
1060 + }),
1061 ),
1062 );
1063
@@ -982,7 +1279,7 @@ describe("repository access decoding", () => {
1279 mergeCommitAllowed: true,
1280 squashMergeAllowed: false,
1281 rebaseMergeAllowed: true,
985 - ...(viewerPermission === undefined ? {} : { viewerPermission }),
1282 + viewerPermission: viewerPermission ?? null,
1283 },
1284 },
1285 });
@@ -1016,7 +1313,7 @@ describe("repository access decoding", () => {
1313 it("withholds write where gh names no permission, which is not a standing it gave", () => {
1314 // The one place an unknown answer is not granted: a Merge button a reader cannot use wastes
1315 // the press, where a missing one still leaves the pull request open on its host.
1019 - expect(expectSuccess(decodeViewerPermissionsJson(repositoryJson())).canWrite).toBe(false);
1316 + expect(toCanWrite(undefined)).toBe(false);
1317 });
1318
1319 it("grants write and triage to a GitHub App, which GitHub answers with a null permission", () => {
@@ -1045,7 +1342,7 @@ describe("viewer permission decoding", () => {
1342 decodeViewerPermissionsJson(
1343 viewerJson({
1344 viewerPermission: "READ",
1048 - pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true },
1345 + pullRequest: { viewerCanUpdate: true, viewerDidAuthor: true, headRepository: null },
1346 }),
1347 ),
1348 ),
@@ -1065,7 +1362,7 @@ describe("viewer permission decoding", () => {
1362 decodeViewerPermissionsJson(
1363 viewerJson({
1364 viewerPermission: "READ",
1068 - pullRequest: { viewerCanUpdate: false, viewerDidAuthor: false },
1365 + pullRequest: { viewerCanUpdate: false, viewerDidAuthor: false, headRepository: null },
1366 }),
1367 ),
1368 ),
@@ -1083,7 +1380,11 @@ describe("viewer permission decoding", () => {
1380 // A node the viewer cannot see comes back null. Updating is a permission, so an unknown
1381 // answer grants it and lets the host refuse; authorship is a fact about who wrote the change,
1382 // and claiming it for someone who did not is how an author's own rules get handed out.
1086 - expect(expectSuccess(decodeViewerPermissionsJson(viewerJson({ pullRequest: null })))).toEqual({
1383 + expect(
1384 + expectSuccess(
1385 + decodeViewerPermissionsJson(viewerJson({ viewerPermission: "READ", pullRequest: null })),
1386 + ),
1387 + ).toEqual({
1388 mergeCapabilities: { merge: true, squash: false, rebase: true },
1389 canWrite: false,
1390 canTriage: false,
@@ -1098,7 +1399,7 @@ describe("viewer permission decoding", () => {
1399 decodeViewerPermissionsJson(
1400 viewerJson({
1401 viewerPermission: "TRIAGE",
1101 - pullRequest: { viewerCanUpdate: false, viewerDidAuthor: false },
1402 + pullRequest: { viewerCanUpdate: false, viewerDidAuthor: false, headRepository: null },
1403 }),
1404 ),
1405 );
@@ -1146,7 +1447,12 @@ describe("label candidate decoding", () => {
1447
1448 it("keeps a worn label the repository no longer defines, so it can be taken off", () => {
1449 const list = expectSuccess(
1149 - decodeLabelCandidatesJson(labelsJson({ defined: [{ name: "bug" }], applied: ["legacy"] })),
1450 + decodeLabelCandidatesJson(
1451 + labelsJson({
1452 + defined: [{ name: "bug", color: "d73a4a", description: null }],
1453 + applied: ["legacy"],
1454 + }),
1455 + ),
1456 );
1457 expect(list.candidates.map((label) => [label.name, label.isApplied])).toEqual([
1458 ["legacy", true],
@@ -1417,21 +1723,26 @@ describe("decodePullRequestNodeIdJson", () => {
1723 });
1724 });
1725
1420 -describe("REVIEW_THREADS_GRAPHQL_QUERY", () => {
1726 +describe("ReviewThreads", () => {
1727 it("caps the initial query after the 104-point rate-limit regression", () => {
1422 - const match = REVIEW_THREADS_GRAPHQL_QUERY.match(
1423 - /reviewThreads\(first: (\d+)[\s\S]*?comments\(first: (\d+)\)/u,
1728 + const match = ReviewThreads.document.match(
1729 + /reviewThreads\(first:(\d+)[\s\S]*?\.\.\.ThreadComment[\s\S]*$/u,
1730 );
1731 + const comments = ReviewThreads.document.match(/comments\(first:(\d+)\)\{totalCount/u);
1732
1733 expect(match).not.toBeNull();
1427 - if (match === null) throw new Error("expected review-thread connections");
1428 - expect(Number(match[1]) * Number(match[2])).toBeLessThanOrEqual(1_000);
1734 + expect(comments).not.toBeNull();
1735 + if (match === null || comments === null) throw new Error("expected review-thread connections");
1736 + expect(Number(match[1]) * Number(comments[1])).toBeLessThanOrEqual(1_000);
1737 });
1738
1739 it("asks for reactionGroups on the pull request itself, its comments, its reviews and each thread's comments", () => {
1432 - expect(REVIEW_THREADS_GRAPHQL_QUERY.match(/reactionGroups/g)).toHaveLength(4);
1740 + // The fragment is spread once per subject: the pull request, its comments, its reviews, and
1741 + // each thread's comments (through `ThreadComment`).
1742 + expect(ReviewThreads.document.match(/\.\.\.Reactions\b/g)).toHaveLength(4);
1743 + expect(ReviewThreads.document.match(/reactionGroups/g)).toHaveLength(1);
1744 // The reviews connection is new: only reactions were ever wanted off it.
1434 - expect(REVIEW_THREADS_GRAPHQL_QUERY).toContain("reviews(first:");
1745 + expect(ReviewThreads.document).toContain("reviews(first:");
1746 });
1747 });
1748
@@ -1447,12 +1758,25 @@ describe("reviewer candidate decoding", () => {
1758 repository: {
1759 assignableUsers: {
1760 pageInfo: { hasNextPage: input.hasNextPage ?? false },
1450 - nodes: input.assignable,
1761 + nodes: input.assignable.map((node) =>
1762 + node === null ? null : { name: null, avatarUrl: "", ...node },
1763 + ),
1764 },
1765 pullRequest: {
1453 - author: input.author === undefined ? null : { login: input.author },
1766 + author: input.author === undefined ? null : { __typename: "User", login: input.author },
1767 reviewRequests: {
1455 - nodes: (input.requested ?? []).map((requestedReviewer) => ({ requestedReviewer })),
1768 + nodes: (input.requested ?? []).map((requestedReviewer) => ({
1769 + requestedReviewer:
1770 + requestedReviewer === null
1771 + ? null
1772 + : "slug" in requestedReviewer
1773 + ? {
1774 + __typename: "Team",
1775 + teamAvatarUrl: null,
1776 + ...requestedReviewer,
1777 + }
1778 + : { __typename: "User", name: null, avatarUrl: "", ...requestedReviewer },
1779 + })),
1780 },
1781 },
1782 },
@@ -1503,7 +1827,7 @@ describe("reviewer candidate decoding", () => {
1827 decodeReviewerCandidatesJson(
1828 candidatesJson({
1829 assignable: [{ login: "octocat" }],
1506 - requested: [{ slug: "reviewers", combinedSlug: "acme/reviewers", name: "Reviewers" }],
1830 + requested: [{ slug: "reviewers", combinedSlug: "acme/reviewers", teamName: "Reviewers" }],
1831 }),
1832 ),
1833 );
@@ -1830,47 +2154,6 @@ describe("decodePullRequestFilesViewedJson", () => {
2154 });
2155 });
2156
1833 -describe("buildSetFilesViewedGraphQlMutation", () => {
1834 - it("asks for nothing when nothing was pressed", () => {
1835 - expect(buildSetFilesViewedGraphQlMutation("PR_1", [])).toBeNull();
1836 - });
1837 -
1838 - it("clears and restores in one document, each file under its own alias", () => {
1839 - const mutation = buildSetFilesViewedGraphQlMutation("PR_1", [
1840 - { path: "src/a.ts", viewed: true },
1841 - { path: "src/b.ts", viewed: false },
1842 - ]);
1843 - expect(mutation).not.toBeNull();
1844 - if (mutation === null) return;
1845 - expect(mutation.query).toContain(
1846 - "mutation($pullRequestId: ID!, $f0_path: String!, $f1_path: String!)",
1847 - );
1848 - expect(mutation.query).toContain(
1849 - "f0: markFileAsViewed(input: { pullRequestId: $pullRequestId, path: $f0_path })",
1850 - );
1851 - expect(mutation.query).toContain(
1852 - "f1: unmarkFileAsViewed(input: { pullRequestId: $pullRequestId, path: $f1_path })",
1853 - );
1854 - expect(mutation.variables).toEqual({
1855 - pullRequestId: "PR_1",
1856 - f0_path: "src/a.ts",
1857 - f1_path: "src/b.ts",
1858 - });
1859 - });
1860 -
1861 - it("keeps a path out of the document, so one cannot be read as part of it", () => {
1862 - const mutation = buildSetFilesViewedGraphQlMutation("PR_1", [
1863 - { path: '") { __typename } evil: markFileAsViewed(input: { path: "x', viewed: true },
1864 - ]);
1865 - expect(mutation).not.toBeNull();
1866 - if (mutation === null) return;
1867 - expect(mutation.query).not.toContain("evil");
1868 - expect(mutation.variables.f0_path).toBe(
1869 - '") { __typename } evil: markFileAsViewed(input: { path: "x',
1870 - );
1871 - });
1872 -});
1873 -
2157 describe("host-native stack decoding", () => {
2158 /** A stack as the preview lists it, bottom to top, with the fields it answers today. */
2159 function stack(overrides: Record<string, unknown> = {}) {
@@ -1975,86 +2258,54 @@ describe("host-native stack decoding", () => {
2258 });
2259 });
2260
1978 -describe("pull request stack membership batches", () => {
1979 - it("maps aliases while skipping missing pull requests and incomplete memberships", () => {
1980 - const memberships = expectSuccess(
1981 - decodePullRequestStackMembershipsJson(
1982 - JSON.stringify({
1983 - data: {
1984 - s0: {
1985 - pullRequest: {
1986 - stack: { number: 3, size: 2, baseRefName: "main" },
1987 - stackEntry: { position: 1 },
1988 - },
1989 - },
1990 - s1: null,
1991 - s2: { pullRequest: null },
1992 - s3: { pullRequest: { stack: null, stackEntry: null } },
1993 - s4: { pullRequest: { stack: { number: 3, size: 2, baseRefName: "main" } } },
1994 - },
1995 - }),
1996 - ),
1997 - );
1998 - expect([...memberships]).toEqual([[0, { number: 3, size: 2, base: "main", position: 1 }]]);
1999 - });
2000 -
2001 - it("refuses malformed responses and unsafe query selectors", () => {
2002 - expect(Result.isFailure(decodePullRequestStackMembershipsJson('{"errors":[]}'))).toBe(true);
2003 - expect(buildPullRequestStackMembershipsGraphQlQuery('acme/web") { x } #', [1])).toBeNull();
2004 - expect(buildPullRequestStackMembershipsGraphQlQuery("acme/web", [0])).toBeNull();
2005 - expect(buildPullRequestStackMembershipsGraphQlQuery("acme/web", [1.5])).toBeNull();
2006 - expect(buildPullRequestStackMembershipsGraphQlQuery("acme/web", [])).toBeNull();
2007 - expect(buildPullRequestStackMembershipsGraphQlQuery("acme/web", [7, 8])?.variables).toEqual({
2008 - s0_owner: "acme",
2009 - s0_name: "web",
2010 - s0_number: 7,
2011 - s1_owner: "acme",
2012 - s1_name: "web",
2013 - s1_number: 8,
2261 +/** A pull request as the generated batch operations decode it from GitHub's answer. */
2262 +const decodeSummaryResult = Schema.decodeUnknownSync(PullRequestSummary.result);
2263 +const decodeSummary = (pullRequest: object) =>
2264 + decodeSummaryResult({ repository: { pullRequest } }).repository!.pullRequest!;
2265 +const decodeWatchedResult = Schema.decodeUnknownSync(PullRequestWatchFingerprint.result);
2266 +const decodeWatched = (pullRequest: object) =>
2267 + decodeWatchedResult({ repository: { pullRequest } }).repository!.pullRequest!;
2268 +
2269 +describe("pull request lookups", () => {
2270 + it("refuses what GitHub cannot name, so one bad row cannot fail a whole batch", () => {
2271 + expect(pullRequestLookup({ repository: "acme/web", number: 7 })).toEqual({
2272 + owner: "acme",
2273 + name: "web",
2274 + number: 7,
2275 });
2276 + expect(pullRequestLookup({ repository: 'acme/web") { x } #', number: 1 })).toBeNull();
2277 + expect(pullRequestLookup({ repository: "acme/web", number: 0 })).toBeNull();
2278 + expect(pullRequestLookup({ repository: "acme/web", number: 1.5 })).toBeNull();
2279 + expect(pullRequestLookup({ repository: "acme/web", number: 2 ** 31 })).toBeNull();
2280 });
2281 });
2282
2283 describe("batched pull request summaries", () => {
2019 - it("refuses a repository GraphQL cannot address, rather than writing it into the document", () => {
2020 - expect(
2021 - buildPullRequestSummariesGraphQlQuery([{ repository: 'acme/web") { x } #', number: 1 }]),
2022 - ).toBeNull();
2023 - expect(
2024 - buildPullRequestSummariesGraphQlQuery([{ repository: "acme/web", number: 0 }]),
2025 - ).toBeNull();
2026 - expect(buildPullRequestSummariesGraphQlQuery([])).toBeNull();
2027 - });
2028 -
2029 - it("files each answer by its alias and skips what GitHub or the decoder could not give", () => {
2030 - const decoded = decodePullRequestSummariesJson(
2031 - JSON.stringify({
2032 - data: {
2033 - s0: {
2034 - pullRequest: {
2035 - number: 7,
2036 - title: "Merged",
2037 - url: "https://github.com/acme/web/pull/7",
2038 - author: { __typename: "Bot", login: "renovate", avatarUrl: "https://a/r.png" },
2039 - headRefName: "feat/seven",
2040 - baseRefName: "main",
2041 - state: "MERGED",
2042 - mergedAt: "2026-08-24T00:00:00Z",
2043 - closedAt: "2026-08-24T00:00:00Z",
2044 - updatedAt: "2026-08-24T00:00:00Z",
2045 - commits: { nodes: [{ commit: { statusCheckRollup: { state: "FAILURE" } } }] },
2046 - },
2047 - },
2048 - s1: { pullRequest: null },
2049 - s2: { pullRequest: { number: 9 } },
2050 - rateLimit: { cost: 1 },
2051 - },
2052 - }),
2053 - );
2054 - expect(Result.isSuccess(decoded)).toBe(true);
2055 - if (!Result.isSuccess(decoded)) return;
2056 - expect([...decoded.success.keys()]).toEqual([0]);
2057 - expect(decoded.success.get(0)).toMatchObject({
2284 + const summary = (fields: Record<string, unknown>) => ({
2285 + number: 7,
2286 + title: "Merged",
2287 + url: "https://github.com/acme/web/pull/7",
2288 + state: "MERGED",
2289 + isDraft: false,
2290 + mergeable: "UNKNOWN",
2291 + reviewDecision: null,
2292 + additions: 0,
2293 + deletions: 0,
2294 + changedFiles: 0,
2295 + updatedAt: "2026-08-24T00:00:00Z",
2296 + mergedAt: "2026-08-24T00:00:00Z",
2297 + closedAt: "2026-08-24T00:00:00Z",
2298 + headRefName: "feat/seven",
2299 + baseRefName: "main",
2300 + author: { __typename: "Bot", login: "renovate", avatarUrl: "https://a/r.png" },
2301 + latestReviews: { nodes: [] },
2302 + commits: { nodes: [{ commit: { statusCheckRollup: { state: "FAILURE" } } }] },
2303 + ...fields,
2304 + });
2305 +
2306 + it("maps GitHub's fields to the summary a linked thread keeps", () => {
2307 + const mapped = toPullRequestSummary(decodeSummary(summary({})));
2308 + expect(mapped).toMatchObject({
2309 number: 7,
2310 state: "merged",
2311 mergedAt: "2026-08-24T00:00:00Z",
@@ -2063,70 +2314,28 @@ describe("batched pull request summaries", () => {
2314 mergeability: "unknown",
2315 additions: 0,
2316 });
2066 - // The document did not ask about stacks, so the summary does not claim an answer.
2067 - expect(decoded.success.get(0)).not.toHaveProperty("stack");
2317 + // The read did not ask about stacks, so the summary does not claim an answer.
2318 + expect(mapped).not.toHaveProperty("stack");
2319 });
2320
2070 - it("reads stack membership only where the document asked for it", () => {
2321 + it("reads stack membership only where the read asked for it", () => {
2322 expect(
2072 - buildPullRequestSummariesGraphQlQuery([{ repository: "acme/web", number: 7 }], true)?.query,
2073 - ).toContain("stack { number size baseRefName } stackEntry { position }");
2323 + toPullRequestSummary(decodeSummary(summary({ stack: null, stackEntry: null }))).stack,
2324 + ).toBeNull();
2325 expect(
2075 - buildPullRequestSummariesGraphQlQuery([{ repository: "acme/web", number: 7 }])?.query,
2076 - ).not.toContain("stack {");
2077 - const pullRequest = (number: number, stack: Record<string, unknown>) => ({
2078 - pullRequest: {
2079 - number,
2080 - title: "Stacked",
2081 - url: `https://github.com/acme/web/pull/${number}`,
2082 - headRefName: `feat/${number}`,
2083 - baseRefName: "main",
2084 - state: "OPEN",
2085 - updatedAt: "2026-08-24T00:00:00Z",
2086 - ...stack,
2087 - },
2088 - });
2089 - const decoded = expectSuccess(
2090 - decodePullRequestSummariesJson(
2091 - JSON.stringify({
2092 - data: {
2093 - s0: pullRequest(7, { stack: null, stackEntry: null }),
2094 - s1: pullRequest(8, {
2095 - stack: { number: 3, size: 2, baseRefName: "main" },
2096 - stackEntry: { position: 2 },
2097 - }),
2098 - },
2099 - }),
2100 - ),
2101 - );
2102 - expect(decoded.get(0)?.stack).toBeNull();
2103 - expect(decoded.get(1)?.stack).toEqual({ number: 3, size: 2, base: "main", position: 2 });
2326 + toPullRequestSummary(
2327 + decodeSummary(
2328 + summary({
2329 + stack: { number: 3, size: 2, baseRefName: "main" },
2330 + stackEntry: { position: 2 },
2331 + }),
2332 + ),
2333 + ).stack,
2334 + ).toEqual({ number: 3, size: 2, base: "main", position: 2 });
2335 });
2336 });
2337
2338 describe("pull request watch fingerprints", () => {
2108 - it("asks for every pull request in one aliased read, and refuses an unsafe selector", () => {
2109 - const document = buildPullRequestWatchFingerprintsGraphQlQuery([
2110 - { repository: "pingdotgg/t3code", number: 7 },
2111 - { repository: "pingdotgg/lakebed", number: 8 },
2112 - ]);
2113 - expect(document?.query).toContain(
2114 - "w0: repository(owner: $w0_owner, name: $w0_name) { pullRequest(number: $w0_number)",
2115 - );
2116 - expect(document?.query).toContain("w1: repository(owner: $w1_owner, name: $w1_name)");
2117 - expect(document?.variables).toEqual({
2118 - w0_owner: "pingdotgg",
2119 - w0_name: "t3code",
2120 - w0_number: 7,
2121 - w1_owner: "pingdotgg",
2122 - w1_name: "lakebed",
2123 - w1_number: 8,
2124 - });
2125 - expect(
2126 - buildPullRequestWatchFingerprintsGraphQlQuery([{ repository: 'evil") { x', number: 1 }]),
2127 - ).toBeNull();
2128 - });
2129 -
2339 it("moves status with checks and remarks with comments, each without the other", () => {
2340 const pullRequest = (input: {
2341 readonly running: number;
@@ -2159,20 +2368,9 @@ describe("pull request watch fingerprints", () => {
2368 ],
2369 },
2370 });
2162 - const decode = (...pullRequests: ReadonlyArray<object | null>) => {
2163 - const decoded = decodePullRequestWatchFingerprintsJson(
2164 - JSON.stringify({
2165 - data: Object.fromEntries(
2166 - pullRequests.map((value, index) => [`w${index}`, { pullRequest: value }]),
2167 - ),
2168 - }),
2169 - );
2170 - if (!Result.isSuccess(decoded)) throw new Error("fingerprints did not decode");
2171 - return decoded.success;
2172 - };
2173 - const base = { running: 2, failed: 0, commentEditedAt: null, reviews: 1 };
2371 const fingerprint = (input: Parameters<typeof pullRequest>[0]) =>
2175 - decode(pullRequest(input)).get(0)!;
2372 + toPullRequestWatchFingerprint(decodeWatched(pullRequest(input)));
2373 + const base = { running: 2, failed: 0, commentEditedAt: null, reviews: 1 };
2374 const before = fingerprint(base);
2375 const checkFinished = fingerprint({ ...base, running: 1, failed: 1 });
2376 const summaryEdited = fingerprint({ ...base, commentEditedAt: "2026-10-05T23:47:43Z" });
@@ -2183,7 +2381,5 @@ describe("pull request watch fingerprints", () => {
2381 expect(summaryEdited.remarks).not.toBe(before.remarks);
2382 expect(summaryEdited.status).toBe(before.status);
2383 expect(replied.remarks).not.toBe(before.remarks);
2186 - // A pull request GitHub had no answer for is left for a full read.
2187 - expect(decode(null, pullRequest(base)).has(0)).toBe(false);
2384 });
2385 });
packages/source-control-github/src/server/gitHubPullRequestJson.ts
+612 -2138
@@ -2,6 +2,7 @@ import * as Cause from "effect/Cause";
2 import * as Exit from "effect/Exit";
3 import * as Result from "effect/Result";
4 import * as Schema from "effect/Schema";
5 +import { GraphQL } from "effect/graphql";
6 import type {
7 PullRequestStackMembership,
8 PullRequestActor,
@@ -34,284 +35,127 @@ import type {
35 } from "@t3tools/contracts";
36 import { quoteGitPatchPath } from "@t3tools/shared/gitPatchPath";
37 import { decodeJsonResult } from "@t3tools/shared/schemaJson";
37 -
38 -import { aliasedGraphQlDocument, type GraphQlDocument } from "./githubGraphQl.ts";
38 import { dedupeChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
39
41 -/**
42 - * Enum-ish GitHub CLI fields are decoded as plain strings and normalized here: a `gh`
43 - * release that adds a conclusion or a review state must not fail the whole payload.
44 - */
45 -const RawActorSchema = Schema.Struct({
46 - __typename: Schema.optional(Schema.String),
47 - is_bot: Schema.optional(Schema.Boolean),
48 - /**
49 - * Optional because a requested team goes by its slug instead, and a mannequin, which no query
50 - * has a fragment for, arrives as an empty object. A reviewer with neither names nobody to show,
51 - * and must not fail the response the conversation travels in.
52 - */
53 - login: Schema.optional(Schema.String),
54 - /** The node id, which is how a listing's authors are resolved to avatars in one request. */
55 - id: Schema.optional(Schema.NullOr(Schema.String)),
56 - name: Schema.optional(Schema.NullOr(Schema.String)),
57 - /** Only the GraphQL API reports one; `gh pr view --json` has no avatar to give. */
58 - avatarUrl: Schema.optional(Schema.NullOr(Schema.String)),
59 -});
40 +import type * as GitHubSchema from "../../schema/github.graphql.ts";
41 +import type {
42 + PullRequestSummaryRepositoryPullRequestPullRequest as SummarizedPullRequest,
43 + PullRequestWatchFingerprintRepositoryPullRequestPullRequest as WatchedPullRequest,
44 +} from "./pullRequestBatches.graphql.ts";
45 +import {
46 + PageInfo as ListingPageInfo,
47 + PullRequestList,
48 + PullRequestRow,
49 + PullRequestSearch,
50 +} from "./pullRequestListings.graphql.ts";
51 +import type {
52 + ActorAvatars,
53 + CheckContext,
54 + LabelCandidates,
55 + PullRequestActivity,
56 + PullRequestCheckContexts,
57 + PullRequestCore,
58 + PullRequestFilesViewed,
59 + PullRequestHeads,
60 + PullRequestPreview as PullRequestPreviewQuery,
61 + PullRequestSubject,
62 + ReviewerCandidates,
63 + ViewerPermissions,
64 +} from "./pullRequestReads.graphql.ts";
65 +import type {
66 + ReactionGroup,
67 + ReviewDismissals,
68 + ReviewThreadComments,
69 + ReviewThreads,
70 + ThreadComment,
71 +} from "./pullRequestReviews.graphql.ts";
72 +
73 +/** The parts of an actor the mappings below read, whichever selection it came from. */
74 +interface ActorFields {
75 + readonly __typename?: string | undefined;
76 + readonly login?: string | null | undefined;
77 + readonly name?: string | null | undefined;
78 + readonly avatarUrl?: string | null | undefined;
79 +}
80
81 /**
62 - * A team answers with a slug where a user answers with a login. `combinedSlug` is the team's
63 - * `org/slug`, which is what a reviewer row shows for it.
82 + * A listing row before mapping. Optional where a selection leaves a field out (the search's line
83 + * counts), and a check rollup reduced to the shape the detail's checks have.
84 */
65 -const RawRequestedReviewerSchema = Schema.Struct({
66 - ...RawActorSchema.fields,
67 - slug: Schema.optional(Schema.NullOr(Schema.String)),
68 - combinedSlug: Schema.optional(Schema.NullOr(Schema.String)),
69 -});
70 -
71 -const RawLabelSchema = Schema.Struct({
72 - name: Schema.String,
73 - color: Schema.optional(Schema.NullOr(Schema.String)),
74 -});
75 -
76 -const RawReviewRequestSchema = Schema.Struct({
77 - login: Schema.optional(Schema.NullOr(Schema.String)),
78 - slug: Schema.optional(Schema.NullOr(Schema.String)),
79 - combinedSlug: Schema.optional(Schema.NullOr(Schema.String)),
80 - name: Schema.optional(Schema.NullOr(Schema.String)),
81 - avatarUrl: Schema.optional(Schema.NullOr(Schema.String)),
82 -});
83 -
84 -/** One reviewer's most recent review: the state is all the verdict needs, the author is for who. */
85 -const RawLatestReviewSchema = Schema.Struct({
86 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
87 - state: Schema.optional(Schema.NullOr(Schema.String)),
88 -});
85 +interface ListItemFields {
86 + readonly number: number;
87 + readonly title: string;
88 + readonly url: string;
89 + readonly author?: (ActorFields & { readonly id?: string | null | undefined }) | null | undefined;
90 + readonly headRefName: string;
91 + readonly baseRefName: string;
92 + readonly state?: string | null | undefined;
93 + readonly isDraft?: boolean | undefined;
94 + readonly mergeable?: string | null | undefined;
95 + readonly reviewDecision?: string | null | undefined;
96 + readonly additions?: number | undefined;
97 + readonly deletions?: number | undefined;
98 + readonly createdAt: string;
99 + readonly updatedAt: string;
100 + readonly mergedAt?: string | null | undefined;
101 + readonly reviewRequests?: ReadonlyArray<ReviewRequestFields> | undefined;
102 + readonly latestReviews?: ReadonlyArray<LatestReviewFields> | undefined;
103 + readonly labels?: ReadonlyArray<LabelFields> | undefined;
104 + readonly statusCheckRollup?: ReadonlyArray<CheckFields> | null | undefined;
105 +}
106
90 -const RawCheckSchema = Schema.Struct({
91 - __typename: Schema.optional(Schema.String),
92 - name: Schema.optional(Schema.NullOr(Schema.String)),
93 - context: Schema.optional(Schema.NullOr(Schema.String)),
94 - status: Schema.optional(Schema.NullOr(Schema.String)),
95 - conclusion: Schema.optional(Schema.NullOr(Schema.String)),
96 - state: Schema.optional(Schema.NullOr(Schema.String)),
97 - description: Schema.optional(Schema.NullOr(Schema.String)),
98 - detailsUrl: Schema.optional(Schema.NullOr(Schema.String)),
99 - targetUrl: Schema.optional(Schema.NullOr(Schema.String)),
100 - /**
101 - * What tells two same-named checks apart, and which run of one is the newest. All three ride
102 - * along with `statusCheckRollup` already — it is asked for as a whole field — so reading them
103 - * costs no request. Empty for an app-provided check run, which belongs to no workflow, and
104 - * absent entirely on a commit status, which is not a run at all.
105 - */
106 - workflowName: Schema.optional(Schema.NullOr(Schema.String)),
107 - startedAt: Schema.optional(Schema.NullOr(Schema.String)),
108 - completedAt: Schema.optional(Schema.NullOr(Schema.String)),
109 - /** Branch protection requires this check; read by the detail query on github.com only. */
110 - isRequired: Schema.optional(Schema.NullOr(Schema.Boolean)),
111 -});
107 +interface LabelFields {
108 + readonly name: string;
109 + readonly color?: string | null | undefined;
110 +}
111
113 -const RawListItemSchema = Schema.Struct({
114 - number: Schema.Int,
115 - title: Schema.String,
116 - url: Schema.String,
117 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
118 - headRefName: Schema.String,
119 - baseRefName: Schema.String,
120 - state: Schema.optional(Schema.NullOr(Schema.String)),
121 - isDraft: Schema.optional(Schema.Boolean),
122 - mergeable: Schema.optional(Schema.NullOr(Schema.String)),
123 - reviewDecision: Schema.optional(Schema.NullOr(Schema.String)),
124 - additions: Schema.optional(Schema.Int),
125 - deletions: Schema.optional(Schema.Int),
126 - createdAt: Schema.String,
127 - updatedAt: Schema.String,
128 - mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
129 - reviewRequests: Schema.optional(Schema.Array(RawReviewRequestSchema)),
130 - latestReviews: Schema.optional(Schema.NullOr(Schema.Array(RawLatestReviewSchema))),
131 - labels: Schema.optional(Schema.Array(RawLabelSchema)),
132 - /**
133 - * Every check of the head commit, which is the only rollup `gh pr list --json` can give: there
134 - * is no field for the one-word verdict. Measured against `pingdotgg/t3code`, asking for it costs
135 - * 0.6s -> 7.9s at a hundred rows and 0.9s -> 2.1s at thirty, for 425 KB of checks a listing
136 - * reduces to one word. The listing pays it because the alternative is a request per row; the
137 - * cross-repository search below asks GitHub for the verdict itself instead.
138 - */
139 - statusCheckRollup: Schema.optional(Schema.NullOr(Schema.Array(RawCheckSchema))),
140 -});
112 +interface ReviewRequestFields {
113 + readonly login?: string | null | undefined;
114 + readonly slug?: string | null | undefined;
115 + readonly name?: string | null | undefined;
116 +}
117
142 -const RawStackMembershipSchema = Schema.Struct({
143 - stack: Schema.optional(
144 - Schema.NullOr(
145 - Schema.Struct({ number: Schema.Int, size: Schema.Int, baseRefName: Schema.String }),
146 - ),
147 - ),
148 - stackEntry: Schema.optional(Schema.NullOr(Schema.Struct({ position: Schema.Int }))),
149 -});
118 +/** One reviewer's most recent review: the state is all the verdict needs. */
119 +interface LatestReviewFields {
120 + readonly state?: string | null | undefined;
121 +}
122
123 /**
152 - * A search's own answer, which is the listing's row one connection deeper: `gh pr list --json`
153 - * flattens reviewers and labels, and GraphQL does not. Everything below the row is optional
154 - * because a node that is not a pull request decodes as an empty object, which is skipped.
124 + * A check as the rollup reports it, a check run and a commit status alike. A check run reports
125 + * `status` plus a `conclusion` once it has completed; a commit status a single `state`.
126 */
156 -const RawSearchItemSchema = Schema.Struct({
157 - ...RawStackMembershipSchema.fields,
158 - number: Schema.Int,
159 - title: Schema.String,
160 - url: Schema.String,
161 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
162 - headRefName: Schema.String,
163 - baseRefName: Schema.String,
164 - state: Schema.optional(Schema.NullOr(Schema.String)),
165 - isDraft: Schema.optional(Schema.Boolean),
166 - mergeable: Schema.optional(Schema.NullOr(Schema.String)),
167 - reviewDecision: Schema.optional(Schema.NullOr(Schema.String)),
168 - latestReviews: Schema.optional(
169 - Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.NullOr(RawLatestReviewSchema)) })),
170 - ),
171 - /** Asked for by the per-repository listing, and left out of the cross-repository search. */
172 - additions: Schema.optional(Schema.Int),
173 - deletions: Schema.optional(Schema.Int),
174 - createdAt: Schema.String,
175 - updatedAt: Schema.String,
176 - mergedAt: Schema.optional(Schema.NullOr(Schema.String)),
177 - repository: Schema.optional(Schema.NullOr(Schema.Struct({ nameWithOwner: Schema.String }))),
178 - reviewRequests: Schema.optional(
179 - Schema.NullOr(
180 - Schema.Struct({
181 - nodes: Schema.optional(
182 - Schema.NullOr(
183 - Schema.Array(
184 - Schema.NullOr(
185 - Schema.Struct({
186 - requestedReviewer: Schema.optional(
187 - Schema.NullOr(
188 - Schema.Struct({
189 - ...RawActorSchema.fields,
190 - slug: Schema.optional(Schema.NullOr(Schema.String)),
191 - }),
192 - ),
193 - ),
194 - }),
195 - ),
196 - ),
197 - ),
198 - ),
199 - }),
200 - ),
201 - ),
202 - labels: Schema.optional(
203 - Schema.NullOr(
204 - Schema.Struct({
205 - nodes: Schema.optional(Schema.NullOr(Schema.Array(Schema.NullOr(RawLabelSchema)))),
206 - }),
207 - ),
208 - ),
127 +interface CheckFields {
128 + readonly name?: string | null | undefined;
129 + readonly context?: string | null | undefined;
130 + readonly status?: string | null | undefined;
131 + readonly conclusion?: string | null | undefined;
132 + readonly state?: string | null | undefined;
133 + readonly description?: string | null | undefined;
134 + readonly detailsUrl?: string | null | undefined;
135 + readonly targetUrl?: string | null | undefined;
136 /**
210 - * GraphQL answers the rollup a listing actually wants — one enum for the head commit, rather
211 - * than the whole check array `gh pr list --json` insists on. Measured at a hundred rows across
212 - * this repository: 0.8s -> 3.0s and 15 KB, against 425 KB for the same verdict over `gh`.
137 + * What tells two same-named checks apart, and which run of one is the newest. Empty for an
138 + * app-provided check run, which belongs to no workflow, and absent on a commit status.
139 */
214 - commits: Schema.optional(
215 - Schema.NullOr(
216 - Schema.Struct({
217 - nodes: Schema.optional(
218 - Schema.NullOr(
219 - Schema.Array(
220 - Schema.NullOr(
221 - Schema.Struct({
222 - commit: Schema.optional(
223 - Schema.NullOr(
224 - Schema.Struct({
225 - statusCheckRollup: Schema.optional(
226 - Schema.NullOr(Schema.Struct({ state: Schema.String })),
227 - ),
228 - }),
229 - ),
230 - ),
231 - }),
232 - ),
233 - ),
234 - ),
235 - ),
236 - }),
237 - ),
238 - ),
239 -});
240 -
241 -const RawRowConnectionSchema = Schema.Struct({
242 - pageInfo: Schema.optional(
243 - Schema.NullOr(
244 - Schema.Struct({
245 - hasNextPage: Schema.Boolean,
246 - endCursor: Schema.optional(Schema.NullOr(Schema.String)),
247 - }),
248 - ),
249 - ),
250 - // Row by row: a node that is not a pull request — or one field GitHub changes — is skipped
251 - // rather than blanking every repository at once.
252 - nodes: Schema.optional(Schema.NullOr(Schema.Array(Schema.Unknown))),
253 -});
254 -
255 -const RawSearchSchema = Schema.Struct({
256 - data: Schema.Struct({ search: RawRowConnectionSchema }),
257 -});
258 -
259 -const RawRepositoryPullRequestsSchema = Schema.Struct({
260 - data: Schema.Struct({
261 - repository: Schema.NullOr(Schema.Struct({ pullRequests: RawRowConnectionSchema })),
262 - }),
263 -});
264 -
265 -/** One aliased lookup per row, so the response is keyed by the position it was asked in. */
266 -const RawStatsSchema = Schema.Struct({
267 - data: Schema.optional(
268 - Schema.NullOr(
269 - Schema.Record(
270 - Schema.String,
271 - Schema.NullOr(
272 - Schema.Struct({
273 - pullRequest: Schema.optional(
274 - Schema.NullOr(
275 - Schema.Struct({
276 - additions: Schema.optional(Schema.NullOr(Schema.Int)),
277 - deletions: Schema.optional(Schema.NullOr(Schema.Int)),
278 - }),
279 - ),
280 - ),
281 - }),
282 - ),
283 - ),
284 - ),
285 - ),
286 -});
287 -
288 -const RawStackMembershipsSchema = Schema.Struct({
289 - data: Schema.Record(
290 - Schema.String,
291 - Schema.NullOr(Schema.Struct({ pullRequest: Schema.NullOr(RawStackMembershipSchema) })),
292 - ),
293 -});
140 + readonly workflowName?: string | null | undefined;
141 + readonly startedAt?: string | null | undefined;
142 + readonly completedAt?: string | null | undefined;
143 + /** Branch protection requires this check; asked for on github.com only. */
144 + readonly isRequired?: boolean | null | undefined;
145 +}
146
295 -/** How many of a reaction's people the hover names before it counts the rest. */
296 -const REACTORS_PER_GROUP = 10;
147 +/** Where a connection carries on from, which is what every paged read follows. */
148 +interface PageInfoFields {
149 + readonly hasNextPage?: boolean | undefined;
150 + readonly endCursor?: string | null | undefined;
151 +}
152
298 -/**
299 - * A reaction group as every reactable node reports it. `reactors` is bounded rather than paged:
300 - * a hover says who reacted, and a hundred and forty names is a count, not a sentence.
301 - */
302 -const REACTION_GROUPS_FIELDS = `reactionGroups {
303 - content
304 - viewerHasReacted
305 - reactors(first: ${REACTORS_PER_GROUP}) {
306 - totalCount
307 - nodes {
308 - ... on User { login }
309 - ... on Bot { login }
310 - ... on Organization { login }
311 - ... on Mannequin { login }
312 - }
313 - }
314 -}`;
153 +/** The connection's nodes without the nulls GraphQL allows in a list. */
154 +function nodesOf<A>(
155 + connection: { readonly nodes?: ReadonlyArray<A | null> | null | undefined } | null | undefined,
156 +): ReadonlyArray<A> {
157 + return (connection?.nodes ?? []).flatMap((node) => (node === null ? [] : [node]));
158 +}
159
160 /** GitHub's reaction names, which are the same eight the contract carries under other spellings. */
161 const REACTION_CONTENT_BY_GITHUB: Readonly<Record<string, PullRequestReactionContent>> = {
@@ -325,7 +169,9 @@ const REACTION_CONTENT_BY_GITHUB: Readonly<Record<string, PullRequestReactionCon
169 EYES: "eyes",
170 };
171
328 -const GITHUB_REACTION_BY_CONTENT: Readonly<Record<PullRequestReactionContent, string>> = {
172 +const GITHUB_REACTION_BY_CONTENT: Readonly<
173 + Record<PullRequestReactionContent, GitHubSchema.ReactionContent>
174 +> = {
175 "thumbs-up": "THUMBS_UP",
176 "thumbs-down": "THUMBS_DOWN",
177 laugh: "LAUGH",
@@ -336,39 +182,12 @@ const GITHUB_REACTION_BY_CONTENT: Readonly<Record<PullRequestReactionContent, st
182 eyes: "EYES",
183 };
184
339 -export function gitHubReactionContent(content: PullRequestReactionContent): string {
185 +export function gitHubReactionContent(
186 + content: PullRequestReactionContent,
187 +): GitHubSchema.ReactionContent {
188 return GITHUB_REACTION_BY_CONTENT[content];
189 }
190
343 -const RawReactionGroupsSchema = Schema.optional(
344 - Schema.NullOr(
345 - Schema.Array(
346 - Schema.Struct({
347 - content: Schema.optional(Schema.NullOr(Schema.String)),
348 - viewerHasReacted: Schema.optional(Schema.Boolean),
349 - reactors: Schema.optional(
350 - Schema.NullOr(
351 - Schema.Struct({
352 - totalCount: Schema.optional(Schema.Int),
353 - nodes: Schema.optional(
354 - Schema.NullOr(
355 - Schema.Array(
356 - Schema.NullOr(
357 - Schema.Struct({ login: Schema.optional(Schema.NullOr(Schema.String)) }),
358 - ),
359 - ),
360 - ),
361 - ),
362 - }),
363 - ),
364 - ),
365 - }),
366 - ),
367 - ),
368 -);
369 -
370 -type RawReactionGroups = typeof RawReactionGroupsSchema.Type;
371 -
191 /**
192 * The groups GitHub answered with, as the contract carries them. A group with nobody behind it is
193 * dropped: GitHub answers with a group per content it knows, including the ones nobody chose. The
@@ -376,7 +195,7 @@ type RawReactionGroups = typeof RawReactionGroupsSchema.Type;
195 * in would name them twice — but `count` still counts them along with everyone else.
196 */
197 function toReactions(
379 - groups: RawReactionGroups,
198 + groups: ReadonlyArray<ReactionGroup> | null | undefined,
199 viewer: string | null,
200 ): ReadonlyArray<PullRequestReaction> {
201 const normalizedViewer = viewer?.toLowerCase() ?? null;
@@ -384,72 +203,20 @@ function toReactions(
203 for (const group of groups ?? []) {
204 const content = REACTION_CONTENT_BY_GITHUB[trimmed(group.content)?.toUpperCase() ?? ""];
205 if (content === undefined) continue;
387 - const logins = (group.reactors?.nodes ?? []).flatMap((node) => trimmed(node?.login) ?? []);
388 - const count = Math.max(group.reactors?.totalCount ?? logins.length, logins.length);
206 + const logins = nodesOf(group.reactors).flatMap((node) =>
207 + "login" in node ? (trimmed(node.login) ?? []) : [],
208 + );
209 + const count = Math.max(group.reactors.totalCount, logins.length);
210 if (count <= 0) continue;
211 const actors =
212 normalizedViewer === null
213 ? logins
214 : logins.filter((login) => login.toLowerCase() !== normalizedViewer);
394 - reactions.push({ content, count, actors, viewerHasReacted: group.viewerHasReacted === true });
215 + reactions.push({ content, count, actors, viewerHasReacted: group.viewerHasReacted });
216 }
217 return reactions;
218 }
219
399 -const RawCommentSchema = Schema.Struct({
400 - id: Schema.String,
401 - lastEditedAt: Schema.optional(Schema.NullOr(Schema.String)),
402 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
403 - body: Schema.optional(Schema.String),
404 - createdAt: Schema.String,
405 - url: Schema.optional(Schema.NullOr(Schema.String)),
406 - /** Only ever present on a GraphQL read; `gh pr view --json` reports no reaction at all. */
407 - reactionGroups: RawReactionGroupsSchema,
408 -});
409 -
410 -const RawReviewSchema = Schema.Struct({
411 - id: Schema.String,
412 - lastEditedAt: Schema.optional(Schema.NullOr(Schema.String)),
413 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
414 - body: Schema.optional(Schema.String),
415 - state: Schema.optional(Schema.NullOr(Schema.String)),
416 - submittedAt: Schema.optional(Schema.NullOr(Schema.String)),
417 - url: Schema.optional(Schema.NullOr(Schema.String)),
418 -});
419 -
420 -const RawCommitSchema = Schema.Struct({
421 - oid: Schema.String,
422 - messageHeadline: Schema.optional(Schema.String),
423 - committedDate: Schema.String,
424 - authors: Schema.optional(
425 - Schema.Array(
426 - Schema.Struct({
427 - email: Schema.optional(Schema.NullOr(Schema.String)),
428 - id: Schema.optional(Schema.NullOr(Schema.String)),
429 - login: Schema.optional(Schema.NullOr(Schema.String)),
430 - name: Schema.optional(Schema.NullOr(Schema.String)),
431 - }),
432 - ),
433 - ),
434 -});
435 -
436 -const RawDetailSchema = Schema.Struct({
437 - ...RawListItemSchema.fields,
438 - /** GitHub's explicit distinction between a fork head and a branch in the base repository. */
439 - isCrossRepository: Schema.optional(Schema.Boolean),
440 - /** Names the fork a pull request came from, which is what qualifies its head ref. */
441 - headRepositoryOwner: Schema.optional(Schema.NullOr(Schema.Struct({ login: Schema.String }))),
442 - /** The exact head revision, used to find workflow runs that GitHub has not started yet. */
443 - headRefOid: Schema.optional(Schema.NullOr(Schema.String)),
444 - body: Schema.optional(Schema.String),
445 - changedFiles: Schema.optional(Schema.Int),
446 - closedAt: Schema.optional(Schema.NullOr(Schema.String)),
447 - /** The standing instruction and strategy GitHub will use once its requirements are met. */
448 - autoMergeRequest: Schema.optional(
449 - Schema.NullOr(Schema.Struct({ mergeMethod: Schema.optional(Schema.NullOr(Schema.String)) })),
450 - ),
451 -});
452 -
220 /** `GET /repos/{owner}/{repo}/actions/runs`, one page of it. */
221 const RawWorkflowRunsSchema = Schema.Struct({
222 workflow_runs: Schema.Array(
@@ -461,329 +228,6 @@ const RawWorkflowRunsSchema = Schema.Struct({
228 ),
229 });
230
464 -const RawPullRequestHeadsSchema = Schema.Struct({
465 - data: Schema.Struct({
466 - repository: Schema.NullOr(
467 - Schema.Struct({
468 - pullRequests: Schema.Struct({
469 - pageInfo: Schema.optional(RawPageInfoSchemaFields()),
470 - nodes: Schema.Array(
471 - Schema.Struct({
472 - number: Schema.Int,
473 - headRefOid: Schema.String,
474 - isCrossRepository: Schema.optional(Schema.Boolean),
475 - headRepositoryOwner: Schema.optional(
476 - Schema.NullOr(Schema.Struct({ login: Schema.String })),
477 - ),
478 - }),
479 - ),
480 - }),
481 - }),
482 - ),
483 - }),
484 -});
485 -
486 -const RawActivityConnection = <S extends Schema.Top>(node: S) =>
487 - Schema.optional(
488 - Schema.NullOr(
489 - Schema.Struct({
490 - pageInfo: Schema.optional(RawPageInfoSchemaFields()),
491 - nodes: Schema.Array(node),
492 - }),
493 - ),
494 - );
495 -
496 -const RawActivitySchema = Schema.Struct({
497 - data: Schema.Struct({
498 - repository: Schema.Struct({
499 - pullRequest: Schema.Struct({
500 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
501 - comments: RawActivityConnection(RawCommentSchema),
502 - reviews: RawActivityConnection(RawReviewSchema),
503 - commits: Schema.optional(
504 - Schema.NullOr(
505 - Schema.Struct({
506 - nodes: Schema.Array(
507 - Schema.Struct({
508 - commit: Schema.Struct({
509 - oid: Schema.String,
510 - messageHeadline: Schema.optional(Schema.String),
511 - committedDate: Schema.String,
512 - authors: Schema.optional(
513 - Schema.NullOr(
514 - Schema.Struct({
515 - nodes: Schema.Array(
516 - Schema.Struct({
517 - email: Schema.optional(Schema.NullOr(Schema.String)),
518 - name: Schema.optional(Schema.NullOr(Schema.String)),
519 - user: Schema.optional(
520 - Schema.NullOr(
521 - Schema.Struct({
522 - login: Schema.optional(Schema.NullOr(Schema.String)),
523 - }),
524 - ),
525 - ),
526 - }),
527 - ),
528 - }),
529 - ),
530 - ),
531 - }),
532 - }),
533 - ),
534 - }),
535 - ),
536 - ),
537 - }),
538 - }),
539 - }),
540 -});
541 -
542 -/** Where a connection carries on from, which is what every paged read below follows. */
543 -function RawPageInfoSchemaFields() {
544 - return Schema.Struct({
545 - hasNextPage: Schema.optional(Schema.Boolean),
546 - endCursor: Schema.optional(Schema.NullOr(Schema.String)),
547 - });
548 -}
549 -const RawPageInfoSchema = RawPageInfoSchemaFields();
550 -
551 -/**
552 - * What GitHub says the viewer may do with a pull request. Both are optional so that an install
553 - * that answers without them still delivers the conversation they travel with; an absent field
554 - * reads as granted, which is what an unknown permission is.
555 - */
556 -const RawViewerFieldsSchema = Schema.Struct({
557 - viewerCanUpdate: Schema.optional(Schema.Boolean),
558 - viewerDidAuthor: Schema.optional(Schema.Boolean),
559 -});
560 -
561 -const RawHeadBranchAccessSchema = Schema.Struct({
562 - headRepository: Schema.optional(
563 - Schema.NullOr(
564 - Schema.Struct({
565 - nameWithOwner: Schema.optional(Schema.NullOr(Schema.String)),
566 - viewerPermission: Schema.optional(Schema.NullOr(Schema.String)),
567 - }),
568 - ),
569 - ),
570 - headRef: Schema.optional(Schema.NullOr(Schema.Struct({ id: Schema.String }))),
571 -});
572 -
573 -const RawThreadCommentsSchema = Schema.Struct({
574 - totalCount: Schema.optional(Schema.Int),
575 - pageInfo: Schema.optional(RawPageInfoSchema),
576 - nodes: Schema.Array(RawCommentSchema),
577 -});
578 -
579 -/** `gh pr view --json` cannot reach review threads, so they come from the GraphQL API. */
580 -const RawReviewThreadsSchema = Schema.Struct({
581 - data: Schema.Struct({
582 - // Rides along in the same request: GitHub names who reacted but never says whether that is
583 - // the reader, so the comparison is made here rather than paid for with a request of its own.
584 - viewer: Schema.optional(
585 - Schema.NullOr(Schema.Struct({ login: Schema.optional(Schema.NullOr(Schema.String)) })),
586 - ),
587 - repository: Schema.Struct({
588 - pullRequest: Schema.Struct({
589 - reviewThreads: Schema.Struct({
590 - totalCount: Schema.optional(Schema.Int),
591 - pageInfo: Schema.optional(RawPageInfoSchema),
592 - nodes: Schema.Array(
593 - Schema.Struct({
594 - id: Schema.optional(Schema.NullOr(Schema.String)),
595 - isResolved: Schema.optional(Schema.Boolean),
596 - isOutdated: Schema.optional(Schema.Boolean),
597 - path: Schema.optional(Schema.NullOr(Schema.String)),
598 - /** Null once the thread's line has left the diff, which `isOutdated` reports. */
599 - line: Schema.optional(Schema.NullOr(Schema.Int)),
600 - diffSide: Schema.optional(Schema.NullOr(Schema.String)),
601 - comments: RawThreadCommentsSchema,
602 - }),
603 - ),
604 - }),
605 - ...RawViewerFieldsSchema.fields,
606 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
607 - reactionGroups: RawReactionGroupsSchema,
608 - comments: Schema.optional(
609 - Schema.NullOr(
610 - Schema.Struct({
611 - nodes: Schema.Array(
612 - Schema.Struct({
613 - id: Schema.optional(Schema.NullOr(Schema.String)),
614 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
615 - lastEditedAt: Schema.optional(Schema.NullOr(Schema.String)),
616 - reactionGroups: RawReactionGroupsSchema,
617 - }),
618 - ),
619 - }),
620 - ),
621 - ),
622 - /**
623 - * Reviews for their reactions and actor identity: the words and the verdict arrive with
624 - * `gh pr view --json reviews`, which reports no reaction of any kind.
625 - */
626 - reviews: Schema.optional(
627 - Schema.NullOr(
628 - Schema.Struct({
629 - nodes: Schema.Array(
630 - Schema.Struct({
631 - id: Schema.optional(Schema.NullOr(Schema.String)),
632 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
633 - lastEditedAt: Schema.optional(Schema.NullOr(Schema.String)),
634 - reactionGroups: RawReactionGroupsSchema,
635 - }),
636 - ),
637 - }),
638 - ),
639 - ),
640 - reviewRequests: Schema.optional(
641 - Schema.NullOr(
642 - Schema.Struct({
643 - nodes: Schema.Array(
644 - Schema.Struct({
645 - // Null where GitHub does not name who was asked.
646 - requestedReviewer: Schema.optional(Schema.NullOr(RawRequestedReviewerSchema)),
647 - }),
648 - ),
649 - }),
650 - ),
651 - ),
652 - latestReviews: Schema.optional(
653 - Schema.NullOr(Schema.Struct({ nodes: Schema.Array(RawLatestReviewSchema) })),
654 - ),
655 - reviewDismissals: Schema.optional(
656 - Schema.NullOr(
657 - Schema.Struct({
658 - pageInfo: Schema.optional(RawPageInfoSchema),
659 - nodes: Schema.Array(
660 - Schema.Struct({
661 - dismissalMessage: Schema.optional(Schema.NullOr(Schema.String)),
662 - review: Schema.optional(
663 - Schema.NullOr(
664 - Schema.Struct({ id: Schema.optional(Schema.NullOr(Schema.String)) }),
665 - ),
666 - ),
667 - }),
668 - ),
669 - }),
670 - ),
671 - ),
672 - commits: Schema.optional(
673 - Schema.NullOr(
674 - Schema.Struct({
675 - nodes: Schema.Array(
676 - Schema.Struct({
677 - commit: Schema.Struct({
678 - oid: Schema.String,
679 - messageHeadline: Schema.optional(Schema.NullOr(Schema.String)),
680 - committedDate: Schema.optional(Schema.NullOr(Schema.String)),
681 - additions: Schema.optional(Schema.Int),
682 - deletions: Schema.optional(Schema.Int),
683 - parents: Schema.optional(
684 - Schema.NullOr(Schema.Struct({ totalCount: Schema.optional(Schema.Int) })),
685 - ),
686 - authors: Schema.optional(
687 - Schema.NullOr(
688 - Schema.Struct({
689 - nodes: Schema.Array(
690 - Schema.Struct({
691 - name: Schema.optional(Schema.NullOr(Schema.String)),
692 - avatarUrl: Schema.optional(Schema.NullOr(Schema.String)),
693 - user: Schema.optional(
694 - Schema.NullOr(
695 - Schema.Struct({
696 - login: Schema.optional(Schema.NullOr(Schema.String)),
697 - }),
698 - ),
699 - ),
700 - }),
701 - ),
702 - }),
703 - ),
704 - ),
705 - }),
706 - }),
707 - ),
708 - }),
709 - ),
710 - ),
711 - }),
712 - }),
713 - }),
714 -});
715 -
716 -/** Requested together, so a response missing any of them fails rather than defaulting open:
717 - * guessing `true` would offer a merge method the repository forbids. */
718 -const RawRepositoryAccessSchema = Schema.Struct({
719 - mergeCommitAllowed: Schema.Boolean,
720 - squashMergeAllowed: Schema.Boolean,
721 - rebaseMergeAllowed: Schema.Boolean,
722 - /**
723 - * ADMIN, MAINTAIN, WRITE, TRIAGE, READ or NONE, or null for a GitHub App. Optional rather than
724 - * required, unlike the three above: an install that does not report it still decodes rather
725 - * than failing the whole detail read, and `toCanWrite` decides what that standing allows.
726 - */
727 - viewerPermission: Schema.optional(Schema.NullOr(Schema.String)),
728 -});
729 -
730 -const RawCoreSchema = Schema.Struct({
731 - data: Schema.Struct({
732 - repository: Schema.Struct({
733 - ...RawRepositoryAccessSchema.fields,
734 - pullRequest: Schema.Struct({
735 - ...RawDetailSchema.fields,
736 - ...RawViewerFieldsSchema.fields,
737 - ...RawHeadBranchAccessSchema.fields,
738 - viewerCanUpdateBranch: Schema.Boolean,
739 - baseRef: Schema.NullOr(
740 - Schema.Struct({
741 - compare: Schema.NullOr(Schema.Struct({ behindBy: Schema.Int })),
742 - }),
743 - ),
744 - reviewRequests: Schema.Struct({
745 - nodes: Schema.Array(
746 - Schema.Struct({ requestedReviewer: Schema.NullOr(RawReviewRequestSchema) }),
747 - ),
748 - }),
749 - labels: Schema.Struct({ nodes: Schema.Array(RawLabelSchema) }),
750 - commits: Schema.Struct({
751 - nodes: Schema.Array(
752 - Schema.Struct({
753 - commit: Schema.Struct({
754 - statusCheckRollup: Schema.NullOr(
755 - Schema.Struct({
756 - contexts: Schema.Struct({
757 - nodes: Schema.Array(
758 - Schema.Struct({
759 - ...RawCheckSchema.fields,
760 - checkSuite: Schema.optional(
761 - Schema.NullOr(
762 - Schema.Struct({
763 - workflowRun: Schema.NullOr(
764 - Schema.Struct({
765 - workflow: Schema.NullOr(Schema.Struct({ name: Schema.String })),
766 - }),
767 - ),
768 - }),
769 - ),
770 - ),
771 - }),
772 - ),
773 - pageInfo: Schema.Struct({ hasNextPage: Schema.Boolean }),
774 - }),
775 - }),
776 - ),
777 - }),
778 - }),
779 - ),
780 - }),
781 - }),
782 - }),
783 - }),
784 -});
785 -const decodeCore = decodeJsonResult(RawCoreSchema);
786 -
231 const RawPullRequestFileSchema = Schema.Struct({
232 filename: Schema.String,
233 status: Schema.optional(Schema.NullOr(Schema.String)),
@@ -796,478 +240,69 @@ const RawPullRequestFileSchema = Schema.Struct({
240 deletions: Schema.optional(Schema.NullOr(Schema.Int)),
241 });
242
799 -/** Resolves a listing's authors to avatars, which no `gh` JSON field carries. */
800 -export const ACTOR_AVATARS_GRAPHQL_QUERY = `query($ids: [ID!]!) {
801 - nodes(ids: $ids) {
802 - ... on User { login avatarUrl }
803 - ... on Bot { login avatarUrl }
804 - }
805 -}`;
806 -
807 -const RawActorAvatarsSchema = Schema.Struct({
808 - data: Schema.Struct({
809 - nodes: Schema.Array(Schema.NullOr(RawActorSchema)),
810 - }),
811 -});
812 -
813 -const decodeActorAvatars = decodeJsonResult(RawActorAvatarsSchema);
814 -
815 -export function decodeActorAvatarsJson(
816 - raw: string,
817 -): Result.Result<ReadonlyMap<string, string>, DecodeFailure> {
818 - const decoded = decodeActorAvatars(raw);
819 - if (!Result.isSuccess(decoded)) {
820 - return Result.fail(decoded.failure);
821 - }
243 +/** A listing's authors' avatars by login, from their node ids. */
244 +export function toActorAvatars(result: ActorAvatars.Result): ReadonlyMap<string, string> {
245 const avatarsByLogin = new Map<string, string>();
823 - for (const node of decoded.success.data.nodes) {
824 - const login = trimmed(node?.login);
825 - const avatarUrl = trimmed(node?.avatarUrl);
246 + for (const node of result.nodes) {
247 + if (node === null || !("login" in node)) continue;
248 + const login = trimmed(node.login);
249 + const avatarUrl = trimmed(node.avatarUrl);
250 if (login !== null && avatarUrl !== null) avatarsByLogin.set(login, avatarUrl);
251 }
828 - return Result.succeed(avatarsByLogin);
252 + return avatarsByLogin;
253 }
254
831 -/**
832 - * Pull refs let the comparison share the detail read without first resolving a fork branch.
833 - * `isRequired` is asked for on github.com only: an older Enterprise server may not know it, and
834 - * an unknown field fails the whole read.
835 - */
836 -function checkContextNodesSelection(host: string): string {
837 - const required =
838 - host.toLowerCase() === "github.com" ? " isRequired(pullRequestNumber: $number)" : "";
839 - return `nodes {
840 - __typename
841 - ... on StatusContext { context state targetUrl createdAt description${required} }
842 - ... on CheckRun {
843 - name status conclusion startedAt completedAt detailsUrl${required}
844 - checkSuite { workflowRun { workflow { name } } }
845 - }
846 - }`;
847 -}
848 -
849 -export const pullRequestCoreGraphQlQuery = (host: string) => {
850 - return `query($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
851 - repository(owner: $owner, name: $name) {
852 - mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerPermission
853 - pullRequest(number: $number) {
854 - number title url body state isDraft mergeable reviewDecision
855 - additions deletions changedFiles createdAt updatedAt mergedAt closedAt
856 - headRefName baseRefName headRefOid isCrossRepository
857 - headRepositoryOwner { login }
858 - headRepository { nameWithOwner viewerPermission }
859 - headRef { id }
860 - author { login avatarUrl ... on User { id name } }
861 - autoMergeRequest { mergeMethod }
862 - viewerCanUpdate viewerDidAuthor viewerCanUpdateBranch
863 - baseRef { compare(headRef: $headRef) { behindBy } }
864 - reviewRequests(first: 100) {
865 - nodes { requestedReviewer { ... on User { login name } ... on Bot { login } ... on Team { slug combinedSlug name avatarUrl } } }
866 - }
867 - labels(first: 100) { nodes { name color } }
868 - commits(last: 1) {
869 - nodes { commit { statusCheckRollup { contexts(first: 100) {
870 - ${checkContextNodesSelection(host)}
871 - pageInfo { hasNextPage }
872 - } } } }
873 - }
874 - }
875 - }
876 -}`;
877 -};
878 -
879 -export const PULL_REQUEST_PREVIEW_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
880 - repository(owner: $owner, name: $name) {
881 - pullRequest(number: $number) {
882 - number title url state isDraft createdAt
883 - author { login avatarUrl ... on User { name } }
884 - }
885 - }
886 -}`;
887 -
888 -const decodePullRequestPreview = decodeJsonResult(
889 - Schema.Struct({
890 - data: Schema.Struct({
891 - repository: Schema.Struct({
892 - pullRequest: Schema.Struct({
893 - number: Schema.Int,
894 - title: Schema.String,
895 - url: Schema.String,
896 - state: Schema.String,
897 - isDraft: Schema.Boolean,
898 - createdAt: Schema.String,
899 - author: Schema.NullOr(RawActorSchema),
900 - }),
901 - }),
902 - }),
903 - }),
904 -);
905 -
906 -export function decodePullRequestPreviewJson(
907 - raw: string,
908 -): Result.Result<Omit<PullRequestPreview, "projectId" | "repository">, DecodeFailure> {
909 - return Result.map(decodePullRequestPreview(raw), ({ data }) => ({
910 - ...data.repository.pullRequest,
911 - author: toActor(data.repository.pullRequest.author),
912 - state: toState(data.repository.pullRequest),
913 - }));
255 +/** Null for a number that names no pull request the viewer can see. */
256 +export function toPullRequestPreview(
257 + result: PullRequestPreviewQuery.Result,
258 +): Omit<PullRequestPreview, "projectId" | "repository"> | null {
259 + const pullRequest = result.repository?.pullRequest;
260 + if (pullRequest == null) return null;
261 + return {
262 + ...pullRequest,
263 + author: toActor(pullRequest.author),
264 + state: toState(pullRequest),
265 + };
266 }
267
916 -/**
917 - * The conversation a pull request carries outside its review threads: who opened it, its issue
918 - * comments, its reviews and its newest commits. The two remark connections page independently, so
919 - * each is switched on only while it has more to give; the first read asks for everything.
920 - */
921 -export const PULL_REQUEST_ACTIVITY_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $head: Boolean!, $withComments: Boolean!, $commentsAfter: String, $withReviews: Boolean!, $reviewsAfter: String) {
922 - repository(owner: $owner, name: $name) {
923 - pullRequest(number: $number) {
924 - author @include(if: $head) { __typename login avatarUrl ... on User { name } }
925 - commits(last: 100) @include(if: $head) {
926 - nodes { commit { oid messageHeadline committedDate authors(first: 10) { nodes { name email user { login } } } } }
927 - }
928 - comments(first: 100, after: $commentsAfter) @include(if: $withComments) {
929 - pageInfo { hasNextPage endCursor }
930 - nodes { id body createdAt lastEditedAt url author { __typename login avatarUrl ... on User { name } } }
931 - }
932 - reviews(first: 100, after: $reviewsAfter) @include(if: $withReviews) {
933 - pageInfo { hasNextPage endCursor }
934 - nodes { id body state submittedAt lastEditedAt url author { __typename login avatarUrl ... on User { name } } }
935 - }
936 - }
937 - }
938 -}`;
939 -
940 -/** GitHub's own ceiling on a connection page, which is what both thread reads ask for. */
941 -const GRAPHQL_PAGE_SIZE = 100;
942 -
268 /**
269 * The ceiling on `search`, which refuses anything larger with EXCESSIVE_PAGINATION (measured:
270 * `first: 101` is an error, `first: 100` is not).
271 */
947 -export const PULL_REQUEST_SEARCH_MAX_ROWS = GRAPHQL_PAGE_SIZE;
948 -
949 -/**
950 - * Every repository of a host in one read, which is what makes a listing one request rather than
951 - * one process per repository.
952 - *
953 - * `additions` and `deletions` are deliberately absent: measured over twelve repositories at a
954 - * hundred rows, this query answers in ~4.0s with them left out and ~7.1s with them in, for two
955 - * numbers at the end of a row. They are read afterwards, by `buildPullRequestStatsGraphQlQuery`.
956 - *
957 - * The row count is written into the document rather than sent as a variable because every
958 - * variable here travels as a string — and it is this module's own number, clamped by the caller,
959 - * never a reader's.
960 - *
961 - * `first` on the two inner connections is a bound rather than a page: a pull request with more
962 - * than twenty labels shows twenty, and one that has asked more than twenty people for a review
963 - * is already past what a row can say.
964 - */
965 -export function pullRequestSearchGraphQlQuery(
966 - rows: number,
967 - includeStacks = false,
968 - includeStats = false,
969 -): string {
970 - return `query($q: String!, $after: String) {
971 - search(query: $q, type: ISSUE, first: ${pageRows(rows)}, after: $after) {
972 - pageInfo { hasNextPage endCursor }
973 - nodes {
974 - ... on PullRequest {
975 - ${pullRequestRowSelection(includeStacks, includeStats)}
976 - }
977 - }
978 - }
979 -}`;
980 -}
981 -
982 -/**
983 - * A repository's pull requests without search, newest created first: the order `gh pr list` lists
984 - * in when it does not search, for a repository GitHub's search index does not cover.
985 - */
986 -export function pullRequestListGraphQlQuery(rows: number, includeStacks = false): string {
987 - return `query($owner: String!, $name: String!, $states: [PullRequestState!], $after: String) {
988 - repository(owner: $owner, name: $name) {
989 - pullRequests(first: ${pageRows(rows)}, after: $after, states: $states, orderBy: { field: CREATED_AT, direction: DESC }) {
990 - pageInfo { hasNextPage endCursor }
991 - nodes { ${pullRequestRowSelection(includeStacks, true)} }
992 - }
993 - }
994 -}`;
995 -}
272 +export const PULL_REQUEST_SEARCH_MAX_ROWS = 100;
273
997 -function pageRows(rows: number): number {
274 +/** A row count a listing read may ask for. */
275 +export function pageRows(rows: number): number {
276 return Math.min(Math.max(Math.trunc(rows), 1), PULL_REQUEST_SEARCH_MAX_ROWS);
277 }
278
1001 -/** One listing row, the same whether it came from a search or from a repository's own list. */
1002 -function pullRequestRowSelection(includeStacks: boolean, includeStats: boolean): string {
1003 - return `${includeStacks ? "stack { number size baseRefName } stackEntry { position }" : ""}
1004 - number
1005 - title
1006 - url
1007 - author { __typename login avatarUrl ... on User { name } }
1008 - headRefName
1009 - baseRefName
1010 - state
1011 - isDraft
1012 - mergeable
1013 - reviewDecision
1014 - latestReviews(first: 20) { nodes { state author { login } } }
1015 - ${includeStats ? "additions deletions" : ""}
1016 - createdAt
1017 - updatedAt
1018 - mergedAt
1019 - repository { nameWithOwner }
1020 - reviewRequests(first: 20) { nodes { requestedReviewer { ... on User { login } ... on Team { slug } } } }
1021 - labels(first: 20) { nodes { name color } }
1022 - commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }`;
279 +/** The pull request's own node id, or null where GitHub found none. */
280 +export function toPullRequestNodeId(result: {
281 + readonly repository: { readonly pullRequest: { readonly id: string } | null } | null;
282 +}): string | null {
283 + return result.repository?.pullRequest?.id ?? null;
284 }
285
1025 -/**
1026 - * One page of review threads with their comments, and the people on the review. `$cursor` is
1027 - * null for the first page and the last page's `endCursor` after that, so a pull request with
1028 - * more threads than one page holds is walked rather than cut off at the first fifty.
1029 - *
1030 - * Only ten comments ride with each thread. A hundred threads times a hundred comments made
1031 - * GitHub reserve 10,000 nested rows and charge 104 points; unfinished threads are paged from
1032 - * their own cursor below.
1033 - *
1034 - * Reviewers come from here rather than from `gh pr view --json reviewRequests` for two reasons:
1035 - * that field holds only requests still outstanding, so anyone who has already reviewed drops off
1036 - * it, and neither it nor any other `gh` JSON field carries an avatar. A reviewer can be a person,
1037 - * an app, or a team, and each is asked for by name because they are different GraphQL types.
1038 - *
1039 - * `viewerCanUpdate` and `viewerDidAuthor` ride along here for the same reason: they belong to the
1040 - * pull request this query is already standing on, so what the reader may do with it arrives with
1041 - * the conversation rather than costing a request of its own.
1042 - *
1043 - * Commits are asked for with `last` rather than `first`: `gh pr view --json commits` pages from
1044 - * the start, so a pull request with more than a hundred commits loses the newest ones from its
1045 - * view entirely. This query gives back the newest hundred, which is what a reader scoping a diff
1046 - * wants, and stands in for the `gh` list wherever it came back non-empty.
1047 - */
1048 -export const REVIEW_THREADS_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $cursor: String) {
1049 - viewer { login }
1050 - repository(owner: $owner, name: $name) {
1051 - pullRequest(number: $number) {
1052 - reviewThreads(first: ${GRAPHQL_PAGE_SIZE}, after: $cursor) {
1053 - totalCount
1054 - pageInfo { hasNextPage endCursor }
1055 - nodes {
1056 - id
1057 - isResolved
1058 - isOutdated
1059 - path
1060 - line
1061 - diffSide
1062 - comments(first: 10) {
1063 - totalCount
1064 - pageInfo { hasNextPage endCursor }
1065 - nodes { id author { __typename login avatarUrl } body createdAt lastEditedAt url ${REACTION_GROUPS_FIELDS} }
1066 - }
1067 - }
1068 - }
1069 - viewerCanUpdate
1070 - viewerDidAuthor
1071 - author { __typename login avatarUrl }
1072 - ${REACTION_GROUPS_FIELDS}
1073 - comments(first: ${GRAPHQL_PAGE_SIZE}) {
1074 - nodes { id lastEditedAt author { __typename login avatarUrl } ${REACTION_GROUPS_FIELDS} }
1075 - }
1076 - reviews(first: ${GRAPHQL_PAGE_SIZE}) { nodes { id lastEditedAt author { __typename login avatarUrl } ${REACTION_GROUPS_FIELDS} } }
1077 - reviewRequests(first: 50) {
1078 - nodes {
1079 - requestedReviewer {
1080 - ... on User { login name avatarUrl }
1081 - ... on Bot { __typename login avatarUrl }
1082 - ... on Team { combinedSlug name avatarUrl }
1083 - }
1084 - }
1085 - }
1086 - latestReviews(first: 50) {
1087 - nodes { state author { __typename login avatarUrl } }
1088 - }
1089 - reviewDismissals: timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: ${GRAPHQL_PAGE_SIZE}) {
1090 - pageInfo { hasNextPage endCursor }
1091 - nodes { ... on ReviewDismissedEvent { dismissalMessage review { id } } }
1092 - }
1093 - commits(last: ${GRAPHQL_PAGE_SIZE}) {
1094 - nodes {
1095 - commit {
1096 - oid
1097 - messageHeadline
1098 - committedDate
1099 - additions
1100 - deletions
1101 - parents(first: 1) { totalCount }
1102 - authors(first: 3) { nodes { name avatarUrl user { login } } }
1103 - }
1104 - }
1105 - }
1106 - }
1107 - }
1108 -}`;
1109 -
1110 -/**
1111 - * The rest of one thread's conversation. GraphQL pages a connection nested inside another only
1112 - * from the inner node itself, so a thread longer than a page is followed on its own — a request
1113 - * GitHub makes necessary, and one no ordinary pull request ever provokes.
1114 - */
1115 -export const REVIEW_THREAD_COMMENTS_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $threadId: ID!, $cursor: String) {
1116 - viewer { login }
1117 - repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
1118 - node(id: $threadId) {
1119 - ... on PullRequestReviewThread {
1120 - pullRequest { id }
1121 - comments(first: ${GRAPHQL_PAGE_SIZE}, after: $cursor) {
1122 - pageInfo { hasNextPage endCursor }
1123 - nodes { id author { __typename login avatarUrl } body createdAt lastEditedAt url ${REACTION_GROUPS_FIELDS} }
1124 - }
1125 - }
1126 - }
1127 -}`;
1128 -
1129 -const RawReviewThreadCommentsSchema = Schema.Struct({
1130 - data: Schema.Struct({
1131 - viewer: Schema.optional(
1132 - Schema.NullOr(Schema.Struct({ login: Schema.optional(Schema.NullOr(Schema.String)) })),
1133 - ),
1134 - repository: Schema.NullOr(
1135 - Schema.Struct({ pullRequest: Schema.NullOr(Schema.Struct({ id: Schema.String })) }),
1136 - ),
1137 - /** Null for an id that names nothing the viewer can read, which is not a thread to page. */
1138 - node: Schema.NullOr(
1139 - Schema.Struct({
1140 - pullRequest: Schema.optional(Schema.Struct({ id: Schema.String })),
1141 - comments: Schema.optional(RawThreadCommentsSchema),
1142 - }),
1143 - ),
1144 - }),
1145 -});
1146 -
1147 -export const REVIEW_THREAD_REPLY_GRAPHQL_MUTATION = `mutation($threadId: ID!, $body: String!) {
1148 - addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) {
1149 - comment { id }
1150 - }
1151 -}`;
1152 -
1153 -/**
1154 - * The pull request's own node id, which is what a reaction on its description is addressed by.
1155 - * Read only when one is being written: the conversation carries an id for every remark in it, and
1156 - * the pull request is the one subject nothing in it names.
1157 - */
1158 -export const PULL_REQUEST_NODE_ID_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
1159 - repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
1160 -}`;
1161 -
1162 -const RawPullRequestNodeIdSchema = Schema.Struct({
1163 - data: Schema.Struct({
1164 - repository: Schema.Struct({
1165 - pullRequest: Schema.Struct({ id: Schema.String }),
1166 - }),
1167 - }),
1168 -});
1169 -
1170 -const decodePullRequestNodeId = decodeJsonResult(RawPullRequestNodeIdSchema);
1171 -
1172 -export function decodePullRequestNodeIdJson(raw: string): Result.Result<string, DecodeFailure> {
1173 - const decoded = decodePullRequestNodeId(raw);
1174 - return Result.isSuccess(decoded)
1175 - ? Result.succeed(decoded.success.data.repository.pullRequest.id)
1176 - : Result.fail(decoded.failure);
1177 -}
1178 -
1179 -/**
1180 - * Where a client-given reaction subject actually hangs: the pull request itself, or the pull
1181 - * request an issue comment, a review comment, or a review belongs to. Read before a mutation
1182 - * reaches it, so a subject named for one pull request cannot react on another's behalf.
1183 - */
1184 -export const REACTION_SUBJECT_PULL_REQUEST_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $subjectId: ID!) {
1185 - repository(owner: $owner, name: $name) { pullRequest(number: $number) { id } }
1186 - node(id: $subjectId) {
1187 - id
1188 - ... on IssueComment { pullRequest { id } }
1189 - ... on PullRequestReviewComment { pullRequest { id } }
1190 - ... on PullRequestReview { pullRequest { id } }
1191 - }
1192 -}`;
1193 -
1194 -const RawReactionSubjectScopeSchema = Schema.Struct({
1195 - data: Schema.Struct({
1196 - repository: Schema.NullOr(
1197 - Schema.Struct({ pullRequest: Schema.NullOr(Schema.Struct({ id: Schema.String })) }),
1198 - ),
1199 - node: Schema.NullOr(
1200 - Schema.Struct({
1201 - id: Schema.String,
1202 - pullRequest: Schema.optional(Schema.Struct({ id: Schema.String })),
1203 - }),
1204 - ),
1205 - }),
1206 -});
1207 -
1208 -const decodeReactionSubjectScope = decodeJsonResult(RawReactionSubjectScopeSchema);
1209 -
286 /**
287 * True when the subject named is the pull request itself, or hangs off it — false for anything
288 * else, including a subject or a pull request this host could not find.
289 */
1214 -export function decodeReactionSubjectScopeJson(raw: string): Result.Result<boolean, DecodeFailure> {
1215 - const decoded = decodeReactionSubjectScope(raw);
1216 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
1217 - const expected = decoded.success.data.repository?.pullRequest?.id ?? null;
1218 - const node = decoded.success.data.node;
1219 - const actual = node === null ? null : (node.pullRequest?.id ?? node.id);
1220 - return Result.succeed(expected !== null && actual !== null && expected === actual);
290 +export function isSubjectOfPullRequest(result: PullRequestSubject.Result): boolean {
291 + const expected = result.repository?.pullRequest?.id ?? null;
292 + const node = result.node;
293 + const actual =
294 + node === null
295 + ? null
296 + : node.__typename === "IssueComment"
297 + ? (node.pullRequest?.id ?? null)
298 + : node.__typename === "PullRequestReviewComment"
299 + ? node.reviewCommentPullRequest.id
300 + : node.__typename === "PullRequestReview"
301 + ? node.reviewPullRequest.id
302 + : node.id;
303 + return expected !== null && actual !== null && expected === actual;
304 }
305
1223 -export const ADD_REACTION_GRAPHQL_MUTATION = `mutation($subjectId: ID!, $content: ReactionContent!) {
1224 - addReaction(input: { subjectId: $subjectId, content: $content }) { reaction { content } }
1225 -}`;
1226 -
1227 -export const REMOVE_REACTION_GRAPHQL_MUTATION = `mutation($subjectId: ID!, $content: ReactionContent!) {
1228 - removeReaction(input: { subjectId: $subjectId, content: $content }) { reaction { content } }
1229 -}`;
1230 -
1231 -export const RESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION = `mutation($threadId: ID!) {
1232 - resolveReviewThread(input: { threadId: $threadId }) { thread { isResolved } }
1233 -}`;
1234 -
1235 -export const UNRESOLVE_REVIEW_THREAD_GRAPHQL_MUTATION = `mutation($threadId: ID!) {
1236 - unresolveReviewThread(input: { threadId: $threadId }) { thread { isResolved } }
1237 -}`;
1238 -
1239 -/**
1240 - * Rewrites the pull request's own words. Both are nullable so that one document serves a change
1241 - * to the title, to the description, or to the two together: a variable the request does not send
1242 - * puts no entry in the input at all, which leaves that field as it was rather than clearing it.
1243 - */
1244 -export const UPDATE_PULL_REQUEST_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!, $title: String, $body: String) {
1245 - updatePullRequest(input: { pullRequestId: $pullRequestId, title: $title, body: $body }) {
1246 - pullRequest { id }
1247 - }
1248 -}`;
1249 -
1250 -/** Creates a new pull request that reverses a merged pull request. */
1251 -export const REVERT_PULL_REQUEST_GRAPHQL_MUTATION = `mutation($pullRequestId: ID!) {
1252 - revertPullRequest(input: { pullRequestId: $pullRequestId }) {
1253 - revertPullRequest { id }
1254 - }
1255 -}`;
1256 -
1257 -/**
1258 - * The two comment mutations name their comment differently. The variable is spelled the same in
1259 - * both, so a rewrite sends one set of variables whichever kind of remark it is.
1260 - */
1261 -export const UPDATE_ISSUE_COMMENT_GRAPHQL_MUTATION = `mutation($commentId: ID!, $body: String!) {
1262 - updateIssueComment(input: { id: $commentId, body: $body }) { issueComment { id } }
1263 -}`;
1264 -
1265 -export const UPDATE_REVIEW_COMMENT_GRAPHQL_MUTATION = `mutation($commentId: ID!, $body: String!) {
1266 - updatePullRequestReviewComment(input: { pullRequestReviewCommentId: $commentId, body: $body }) {
1267 - pullRequestReviewComment { id }
1268 - }
1269 -}`;
1270 -
306 /** The body of `POST /repos/{owner}/{repo}/pulls/{number}/reviews`, which sends a review whole. */
307 const ReviewSubmissionSchema = Schema.Struct({
308 event: Schema.Literals(["COMMENT", "APPROVE", "REQUEST_CHANGES"]),
@@ -1288,21 +323,6 @@ const REVIEW_EVENTS: Record<PullRequestReviewVerdict, "COMMENT" | "APPROVE" | "R
323 "request-changes": "REQUEST_CHANGES",
324 };
325
1291 -/**
1292 - * The dismissal events past the page the thread read carries. A pull request rarely has any:
1293 - * this is followed only while the embedded page reports more.
1294 - */
1295 -export const REVIEW_DISMISSALS_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $cursor: String) {
1296 - repository(owner: $owner, name: $name) {
1297 - pullRequest(number: $number) {
1298 - timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: ${GRAPHQL_PAGE_SIZE}, after: $cursor) {
1299 - pageInfo { hasNextPage endCursor }
1300 - nodes { ... on ReviewDismissedEvent { dismissalMessage review { id } } }
1301 - }
1302 - }
1303 - }
1304 -}`;
1305 -
326 function gitHubReviewPosition(position: PullRequestReviewPosition): {
327 readonly line: number;
328 readonly side: "LEFT" | "RIGHT";
@@ -1410,12 +430,18 @@ function trimmed(value: string | null | undefined): string | null {
430 * an `endCursor` on a page that is also the last one, so the flag is what decides, not the
431 * cursor's presence.
432 */
1413 -function nextCursorOf(
1414 - pageInfo: Schema.Schema.Type<typeof RawPageInfoSchema> | undefined,
1415 -): string | null {
433 +function nextCursorOf(pageInfo: PageInfoFields | null | undefined): string | null {
434 return pageInfo?.hasNextPage === true ? trimmed(pageInfo.endCursor) : null;
435 }
436
437 +/**
438 + * The viewer's standing on one pull request. The two halves take opposite defaults on purpose.
439 + *
440 + * Updating is a permission, so an install that does not report it grants it and lets the host's
441 + * own refusal explain anything that fails. Authorship is not a permission but a fact about who
442 + * wrote the thing, and it is read to decide what an author may do to their own change — so an
443 + * unknown answer is "not the author", which grants nothing it should not.
444 + */
445 /**
446 * The viewer's standing on one pull request. The two halves take opposite defaults on purpose.
447 *
@@ -1425,12 +451,18 @@ function nextCursorOf(
451 * unknown answer is "not the author", which grants nothing it should not.
452 */
453 function toPullRequestViewerFields(
1428 - raw: Schema.Schema.Type<typeof RawViewerFieldsSchema> | null | undefined,
454 + raw:
455 + | {
456 + readonly viewerCanUpdate?: boolean | undefined;
457 + readonly viewerDidAuthor?: boolean | undefined;
458 + }
459 + | null
460 + | undefined,
461 ): { readonly canUpdate: boolean; readonly didAuthor: boolean } {
462 return { canUpdate: raw?.viewerCanUpdate !== false, didAuthor: raw?.viewerDidAuthor === true };
463 }
464
1433 -function toActor(raw: Schema.Schema.Type<typeof RawActorSchema> | null | undefined) {
465 +function toActor(raw: ActorFields | null | undefined): PullRequestActor | null {
466 const login = trimmed(raw?.login);
467 return login === null
468 ? null
@@ -1438,37 +470,42 @@ function toActor(raw: Schema.Schema.Type<typeof RawActorSchema> | null | undefin
470 login,
471 name: trimmed(raw?.name),
472 avatarUrl: trimmed(raw?.avatarUrl),
1441 - ...(raw?.__typename === "Bot" || raw?.is_bot === true ? { isBot: true } : {}),
473 + ...(raw?.__typename === "Bot" ? { isBot: true } : {}),
474 };
475 }
476
477 +/** A requested team as the reads select it: `org/slug`, with its name and avatar aliased apart. */
478 +interface RequestedTeamFields {
479 + readonly combinedSlug?: string | null | undefined;
480 + readonly teamName?: string | null | undefined;
481 + readonly teamAvatarUrl?: string | null | undefined;
482 +}
483 +
484 /**
485 * A requested team as a reviewer row. It goes by `org/slug`, the handle GitHub mentions it by.
486 * No GitHub login contains a slash, so a team never shares a row or a verdict with a user.
487 */
1449 -function toRequestedTeam(
1450 - raw:
1451 - | Pick<Schema.Schema.Type<typeof RawReviewRequestSchema>, "combinedSlug" | "name" | "avatarUrl">
1452 - | null
1453 - | undefined,
1454 -): PullRequestActor | null {
1455 - const login = trimmed(raw?.combinedSlug);
488 +function toRequestedTeam(raw: object | null | undefined): PullRequestActor | null {
489 + if (raw == null || !("combinedSlug" in raw)) return null;
490 + const team = raw as RequestedTeamFields;
491 + const login = trimmed(team.combinedSlug);
492 return login === null
493 ? null
1458 - : { login, name: trimmed(raw?.name), avatarUrl: trimmed(raw?.avatarUrl) };
494 + : { login, name: trimmed(team.teamName), avatarUrl: trimmed(team.teamAvatarUrl) };
495 }
496
1461 -function toCommitActor(
1462 - raw: NonNullable<Schema.Schema.Type<typeof RawCommitSchema>["authors"]>[number],
1463 -): PullRequestActor | null {
497 +function toCommitActor(raw: {
498 + readonly email?: string | null | undefined;
499 + readonly login?: string | null | undefined;
500 + readonly name?: string | null | undefined;
501 +}): PullRequestActor | null {
502 // An email-linked GitHub account has a login; an unlinked signature only has a name or email.
503 // Keep that signature visible instead of silently turning a co-authored commit into one author.
504 const login = trimmed(raw.login) ?? trimmed(raw.name) ?? trimmed(raw.email);
505 return login === null ? null : { login, name: trimmed(raw.name), avatarUrl: null };
506 }
507
1470 -/** An author off the GraphQL commits connection, which names an account by `user.login` where
1471 - * `gh pr view --json commits` names it by a flat `login` copied off the signature. */
508 +/** An author off the review read's commits, which names an account by `user.login`. */
509 function toGraphqlCommitActor(raw: {
510 readonly name?: string | null | undefined;
511 readonly avatarUrl?: string | null | undefined;
@@ -1523,22 +560,11 @@ function toMergeMethod(value: string | null | undefined): PullRequestMergeMethod
560 */
561 function toReviewDecisionWithReviews(
562 value: string | null | undefined,
1526 - // `gh pr list` hands the reviews as an array; the GraphQL reads hand a connection.
1527 - latestReviews:
1528 - | ReadonlyArray<Schema.Schema.Type<typeof RawLatestReviewSchema>>
1529 - | { readonly nodes: ReadonlyArray<Schema.Schema.Type<typeof RawLatestReviewSchema>> }
1530 - | null
1531 - | undefined,
563 + reviews: ReadonlyArray<LatestReviewFields> | undefined,
564 ): PullRequestReviewDecision | null {
565 const summarized = toReviewDecision(value);
566 if (summarized === "approved" || summarized === "changes-requested") return summarized;
1535 - const reviews =
1536 - latestReviews === null || latestReviews === undefined
1537 - ? []
1538 - : "nodes" in latestReviews
1539 - ? latestReviews.nodes
1540 - : latestReviews;
1541 - const states = new Set(reviews.map((review) => review.state?.trim().toUpperCase() ?? ""));
567 + const states = new Set((reviews ?? []).map((review) => review.state?.trim().toUpperCase() ?? ""));
568 if (states.has("CHANGES_REQUESTED")) return "changes-requested";
569 if (states.has("APPROVED")) return "approved";
570 return summarized;
@@ -1557,9 +583,7 @@ function toReviewDecision(value: string | null | undefined): PullRequestReviewDe
583 }
584 }
585
1560 -function toLabels(
1561 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawLabelSchema>> | undefined,
1562 -): ReadonlyArray<PullRequestLabel> {
586 +function toLabels(raw: ReadonlyArray<LabelFields> | undefined): ReadonlyArray<PullRequestLabel> {
587 return (raw ?? []).flatMap((label) => {
588 const name = trimmed(label.name);
589 return name === null ? [] : [{ name, color: trimmed(label.color) }];
@@ -1571,7 +595,7 @@ function toLabels(
595 * compared with the viewer's login.
596 */
597 function toReviewRequestLogins(
1574 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawReviewRequestSchema>> | undefined,
598 + raw: ReadonlyArray<ReviewRequestFields> | undefined,
599 ): ReadonlyArray<string> {
600 return (raw ?? []).flatMap((request) => {
601 const login = trimmed(request.login);
@@ -1579,9 +603,7 @@ function toReviewRequestLogins(
603 });
604 }
605
1582 -function hasTeamReviewRequest(
1583 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawReviewRequestSchema>> | undefined,
1584 -): boolean {
606 +function hasTeamReviewRequest(raw: ReadonlyArray<ReviewRequestFields> | undefined): boolean {
607 return (raw ?? []).some(
608 (request) =>
609 trimmed(request.login) === null &&
@@ -1589,7 +611,7 @@ function hasTeamReviewRequest(
611 );
612 }
613
1592 -function toCheckStatus(raw: Schema.Schema.Type<typeof RawCheckSchema>): PullRequestCheckStatus {
614 +function toCheckStatus(raw: CheckFields): PullRequestCheckStatus {
615 // Commit statuses report a single `state`; check runs report `status` plus a `conclusion`
616 // that only exists once the run has completed.
617 const status = raw.status?.trim().toUpperCase();
@@ -1630,7 +652,7 @@ function realTimestamp(value: string | null | undefined): string | null {
652 }
653
654 /** Only a row the rollup gives no name of any kind, which is not a check anyone can show. */
1633 -function isNamelessCheck(raw: Schema.Schema.Type<typeof RawCheckSchema>): boolean {
655 +function isNamelessCheck(raw: CheckFields): boolean {
656 return trimmed(raw.name) === null && trimmed(raw.context) === null;
657 }
658
@@ -1640,9 +662,7 @@ function isNamelessCheck(raw: Schema.Schema.Type<typeof RawCheckSchema>): boolea
662 * a workflow triggered by both `push` and `pull_request` runs the check twice on one commit, and
663 * the run that finished first must not hide the one still going.
664 */
1643 -function toCheckEntries(
1644 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawCheckSchema>> | null | undefined,
1645 -): ReadonlyArray<{
665 +function toCheckEntries(raw: ReadonlyArray<CheckFields> | null | undefined): ReadonlyArray<{
666 readonly check: PullRequestCheck;
667 readonly workflowName: string | null;
668 readonly at: string | null;
@@ -1685,7 +705,7 @@ function toCheckEntries(
705 * nameless row, and nothing nameless can collide with anything.
706 */
707 function rollupChecksState(
1688 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawCheckSchema>> | null | undefined,
708 + raw: ReadonlyArray<CheckFields> | null | undefined,
709 ): PullRequestChecksState | null {
710 const statuses = [
711 ...toChecks(raw).map((check) => check.status),
@@ -1698,7 +718,7 @@ function rollupChecksState(
718 }
719
720 function toChecks(
1701 - raw: ReadonlyArray<Schema.Schema.Type<typeof RawCheckSchema>> | null | undefined,
721 + raw: ReadonlyArray<CheckFields> | null | undefined,
722 ): ReadonlyArray<PullRequestCheck> {
723 return dedupeChecks(toCheckEntries(raw));
724 }
@@ -1715,11 +735,21 @@ function isReviewVerdict(reviewState: string | null): boolean {
735 }
736 }
737
738 +interface RemarkFields {
739 + readonly id: string;
740 + readonly lastEditedAt: string | null;
741 + readonly author: ActorFields | null;
742 + readonly body: string;
743 + readonly url: string | null;
744 +}
745 +
746 function toComments(raw: {
1719 - readonly comments?: ReadonlyArray<Schema.Schema.Type<typeof RawCommentSchema>> | undefined;
1720 - readonly reviews?: ReadonlyArray<Schema.Schema.Type<typeof RawReviewSchema>> | undefined;
747 + readonly comments: ReadonlyArray<RemarkFields & { readonly createdAt: string }>;
748 + readonly reviews: ReadonlyArray<
749 + RemarkFields & { readonly state: string; readonly submittedAt: string | null }
750 + >;
751 }): ReadonlyArray<PullRequestComment> {
1722 - const issueComments = (raw.comments ?? []).map((comment): PullRequestComment => ({
752 + const issueComments = raw.comments.map((comment): PullRequestComment => ({
753 id: comment.id,
754 kind: "issue-comment",
755 author: toActor(comment.author),
@@ -1734,7 +764,7 @@ function toComments(raw: {
764 // request for changes, a dismissal. GitHub also opens a bodiless `COMMENTED` review as the
765 // container for line comments, and those comments are read from the review threads, so
766 // keeping the container too would show a row with a name and nothing under it.
1737 - const reviews = (raw.reviews ?? []).flatMap((review): ReadonlyArray<PullRequestComment> => {
767 + const reviews = raw.reviews.flatMap((review): ReadonlyArray<PullRequestComment> => {
768 const submittedAt = trimmed(review.submittedAt);
769 const reviewState = trimmed(review.state);
770 if (
@@ -1763,20 +793,22 @@ function toComments(raw: {
793 }
794
795 function toCommits(
1766 - commits: ReadonlyArray<Schema.Schema.Type<typeof RawCommitSchema>> | undefined,
796 + commits: ReadonlyArray<{
797 + readonly oid: string;
798 + readonly messageHeadline: string;
799 + readonly committedDate: string;
800 + readonly authors: ReadonlyArray<Parameters<typeof toCommitActor>[0]>;
801 + }>,
802 ): ReadonlyArray<PullRequestCommit> {
1768 - return (commits ?? []).map((commit) => ({
803 + return commits.map((commit) => ({
804 oid: commit.oid,
1770 - messageHeadline: commit.messageHeadline ?? "",
805 + messageHeadline: commit.messageHeadline,
806 committedDate: commit.committedDate,
1772 - authors: (commit.authors ?? []).flatMap((author) => {
1773 - const actor = toCommitActor(author);
1774 - return actor === null ? [] : [actor];
1775 - }),
807 + authors: commit.authors.flatMap((author) => toCommitActor(author) ?? []),
808 }));
809 }
810
1779 -function toListItem(raw: Schema.Schema.Type<typeof RawListItemSchema>): GitHubPullRequestListItem {
811 +function toListItem(raw: ListItemFields): GitHubPullRequestListItem {
812 return {
813 authorId: trimmed(raw.author?.id),
814 number: raw.number,
@@ -1800,7 +832,21 @@ function toListItem(raw: Schema.Schema.Type<typeof RawListItemSchema>): GitHubPu
832 };
833 }
834
1803 -function toDetail(raw: Schema.Schema.Type<typeof RawDetailSchema>): GitHubPullRequestDetail {
835 +interface DetailFields extends ListItemFields {
836 + readonly isCrossRepository?: boolean | undefined;
837 + readonly headRepositoryOwner?: { readonly login: string } | null | undefined;
838 + readonly headRefOid?: string | null | undefined;
839 + readonly body?: string | undefined;
840 + readonly changedFiles?: number | undefined;
841 + readonly closedAt?: string | null | undefined;
842 + /** The standing instruction and strategy GitHub will use once its requirements are met. */
843 + readonly autoMergeRequest?:
844 + | { readonly mergeMethod?: string | null | undefined }
845 + | null
846 + | undefined;
847 +}
848 +
849 +function toDetail(raw: DetailFields): GitHubPullRequestDetail {
850 const autoMergeMethod = toMergeMethod(raw.autoMergeRequest?.mergeMethod);
851 return {
852 ...toListItem(raw),
@@ -1824,51 +870,76 @@ function toDetail(raw: Schema.Schema.Type<typeof RawDetailSchema>): GitHubPullRe
870 }
871
872 const decodeUnknownList = decodeJsonResult(Schema.Array(Schema.Unknown));
1827 -const decodeSearch = decodeJsonResult(RawSearchSchema);
1828 -const decodeSearchItem = Schema.decodeUnknownExit(RawSearchItemSchema);
1829 -const decodeStats = decodeJsonResult(RawStatsSchema);
1830 -const decodeDetail = decodeJsonResult(RawDetailSchema);
873 +const decodeDetail = decodeJsonResult(
874 + Schema.Struct({
875 + number: Schema.Int,
876 + title: Schema.String,
877 + url: Schema.String,
878 + headRefName: Schema.String,
879 + baseRefName: Schema.String,
880 + state: Schema.optional(Schema.String),
881 + createdAt: Schema.String,
882 + updatedAt: Schema.String,
883 + }),
884 +);
885 const decodeWorkflowRuns = decodeJsonResult(RawWorkflowRunsSchema);
1832 -const decodePullRequestHeads = decodeJsonResult(RawPullRequestHeadsSchema);
1833 -const decodeActivity = decodeJsonResult(RawActivitySchema);
1834 -const decodeRepositoryPullRequests = decodeJsonResult(RawRepositoryPullRequestsSchema);
886 const decodeFileEntry = Schema.decodeUnknownExit(RawPullRequestFileSchema);
1836 -const decodeReviewThreads = decodeJsonResult(RawReviewThreadsSchema);
1837 -const decodeReviewThreadComments = decodeJsonResult(RawReviewThreadCommentsSchema);
887 +const decodeRow = Schema.decodeUnknownExit(PullRequestRow);
888
1839 -type DecodeFailure = Cause.Cause<Schema.SchemaError>;
889 +/**
890 + * A listing page whose rows are left undecoded, so `toPullRequestRows` can decode them one at a
891 + * time: a node that is not a pull request, or one field GitHub changes, is skipped rather than
892 + * failing the page and blanking every repository at once.
893 + */
894 +const LenientRows = Schema.Struct({
895 + pageInfo: ListingPageInfo,
896 + nodes: Schema.NullOr(Schema.Array(Schema.Unknown)),
897 +});
898
1841 -export interface GitHubPullRequestListBatch {
1842 - readonly items: ReadonlyArray<GitHubPullRequestListItem>;
1843 - /** Rows GitHub returned, counted before decoding, so a skipped row cannot hide a next page. */
1844 - readonly rawCount: number;
1845 - /** Where the next page starts, or null once GitHub has handed over every row. */
1846 - readonly endCursor: string | null;
1847 -}
899 +/** The generated search, with its rows decoded by `toPullRequestRows` instead. */
900 +export const LenientPullRequestSearch = GraphQL.query(PullRequestSearch.name, {
901 + document: PullRequestSearch.document,
902 + variables: PullRequestSearch.variables,
903 + result: Schema.Struct({ search: LenientRows }),
904 +});
905 +
906 +/** The generated repository list, with its rows decoded by `toPullRequestRows` instead. */
907 +export const LenientPullRequestList = GraphQL.query(PullRequestList.name, {
908 + document: PullRequestList.document,
909 + variables: PullRequestList.variables,
910 + result: Schema.Struct({
911 + repository: Schema.NullOr(Schema.Struct({ pullRequests: LenientRows })),
912 + }),
913 +});
914 +
915 +type DecodeFailure = Cause.Cause<Schema.SchemaError>;
916
917 /**
1850 - * One page of a repository's own pull request list. Malformed rows are skipped rather than
1851 - * failing the page: one unexpected pull request must not blank the whole list. A repository the
1852 - * viewer cannot see answers as an empty page, which is what `gh pr list` printed for it too.
918 + * A listing page's rows, decoded one at a time against the generated row: a node that is not a pull
919 + * request, or one whose fields no longer decode, is skipped rather than blanking the whole page.
920 + * `rawCount` counts them all, so a skipped row cannot hide a next page.
921 */
1854 -export function decodePullRequestListJson(
1855 - raw: string,
1856 -): Result.Result<GitHubPullRequestListBatch, DecodeFailure> {
1857 - const decoded = decodeRepositoryPullRequests(raw);
1858 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
1859 - const connection = decoded.success.data.repository?.pullRequests;
922 +export function toPullRequestRows(
923 + connection:
924 + | { readonly pageInfo: PageInfoFields; readonly nodes: ReadonlyArray<unknown> | null }
925 + | null
926 + | undefined,
927 +): {
928 + readonly rows: ReadonlyArray<{
929 + readonly item: GitHubPullRequestListItem;
930 + readonly repository: string | null;
931 + }>;
932 + readonly rawCount: number;
933 + readonly hasNextPage: boolean;
934 + readonly endCursor: string | null;
935 +} {
936 const nodes = connection?.nodes ?? [];
1861 - const items: GitHubPullRequestListItem[] = [];
1862 - for (const entry of nodes) {
1863 - const row = toRow(entry);
1864 - if (row !== null) items.push(row.item);
1865 - }
1866 - return Result.succeed({
1867 - items,
937 + return {
938 + rows: nodes.flatMap((entry) => toRow(entry) ?? []),
939 rawCount: nodes.length,
1869 - endCursor:
1870 - connection?.pageInfo?.hasNextPage === true ? trimmed(connection.pageInfo.endCursor) : null,
1871 - });
940 + hasNextPage: connection?.pageInfo.hasNextPage === true,
941 + endCursor: nextCursorOf(connection?.pageInfo),
942 + };
943 }
944
945 /**
@@ -1879,16 +950,17 @@ export function decodePullRequestListJson(
950 function toRow(
951 entry: unknown,
952 ): { readonly item: GitHubPullRequestListItem; readonly repository: string | null } | null {
1882 - const decodedNode = decodeSearchItem(entry);
953 + const decodedNode = decodeRow(entry);
954 if (!Exit.isSuccess(decodedNode)) return null;
955 const node = decodedNode.value;
956 const stack = toStackMembership(node);
1886 - const reviewRequests = (node.reviewRequests?.nodes ?? []).flatMap(
1887 - (request): ReadonlyArray<{ readonly login?: string; readonly slug?: string }> => {
1888 - const reviewer = request?.requestedReviewer;
1889 - const login = trimmed(reviewer?.login);
957 + const reviewRequests = nodesOf(node.reviewRequests).flatMap(
958 + (request): ReadonlyArray<ReviewRequestFields> => {
959 + const reviewer = request.requestedReviewer;
960 + if (reviewer === null) return [];
961 + const login = "login" in reviewer ? trimmed(reviewer.login) : null;
962 if (login !== null) return [{ login }];
1891 - const slug = trimmed(reviewer?.slug);
963 + const slug = "slug" in reviewer ? trimmed(reviewer.slug) : null;
964 return slug === null ? [] : [{ slug }];
965 },
966 );
@@ -1896,71 +968,44 @@ function toRow(
968 item: {
969 ...toListItem({
970 ...node,
1899 - latestReviews: (node.latestReviews?.nodes ?? []).flatMap((review) =>
1900 - review === null ? [] : [review],
1901 - ),
971 + latestReviews: nodesOf(node.latestReviews),
972 reviewRequests,
1903 - labels: (node.labels?.nodes ?? []).flatMap((label) => (label === null ? [] : [label])),
973 + labels: nodesOf(node.labels),
974 // The rollup arrives as one enum. Dressed as a single check here so it is read the same
975 // way the detail's checks are.
1906 - statusCheckRollup: (node.commits?.nodes ?? []).flatMap((commitNode) => {
1907 - const state = trimmed(commitNode?.commit?.statusCheckRollup?.state);
1908 - return state === null ? [] : [{ state }];
1909 - }),
976 + statusCheckRollup: rollupStates(node.commits),
977 }),
978 ...(stack === undefined ? {} : { stack }),
979 },
1913 - repository: trimmed(node.repository?.nameWithOwner),
980 + repository: trimmed(node.repository.nameWithOwner),
981 };
1915 -}
1916 -
1917 -export interface GitHubPullRequestSearchItem extends GitHubPullRequestListItem {
1918 - /** `owner/name` as GitHub spells it, which is how a row from a search finds its repository. */
1919 - readonly repository: string;
1920 -}
1921 -
1922 -export interface GitHubPullRequestSearchBatch {
1923 - readonly items: ReadonlyArray<GitHubPullRequestSearchItem>;
1924 - /** Rows the search returned, counted before decoding, so a skipped row cannot hide a next page. */
1925 - readonly rawCount: number;
1926 - /** More rows than this slice asked for, which is truncation for every repository in it. */
1927 - readonly hasNextPage: boolean;
1928 - /** Where the next page of the same search starts. */
1929 - readonly endCursor: string | null;
1930 -}
1931 -
1932 -/**
1933 - * A search answers with the same row a repository's list does, each naming its repository.
1934 - *
1935 - * Rows that are not pull requests decode as empty and are skipped, the way a malformed listing
1936 - * row is — `is:pr` already excludes them, and one surprise must not blank a whole host.
1937 - */
1938 -export function decodePullRequestSearchJson(
1939 - raw: string,
1940 -): Result.Result<GitHubPullRequestSearchBatch, DecodeFailure> {
1941 - const decoded = decodeSearch(raw);
1942 - if (!Result.isSuccess(decoded)) {
1943 - return Result.fail(decoded.failure);
1944 - }
1945 - const search = decoded.success.data.search;
1946 - const nodes = search.nodes ?? [];
1947 - const items: GitHubPullRequestSearchItem[] = [];
1948 - for (const entry of nodes) {
1949 - const row = toRow(entry);
1950 - if (row === null || row.repository === null) continue;
1951 - items.push({ ...row.item, repository: row.repository });
1952 - }
1953 - return Result.succeed({
1954 - items,
1955 - rawCount: nodes.length,
1956 - hasNextPage: search.pageInfo?.hasNextPage ?? false,
1957 - endCursor: search.pageInfo?.hasNextPage === true ? trimmed(search.pageInfo.endCursor) : null,
982 +}
983 +
984 +/** The head commit's one-word rollup as a nameless check, which `rollupChecksState` reads. */
985 +function rollupStates(commits: {
986 + readonly nodes: ReadonlyArray<{
987 + readonly commit: { readonly statusCheckRollup: { readonly state: string } | null };
988 + } | null> | null;
989 +}): ReadonlyArray<CheckFields> {
990 + return nodesOf(commits).flatMap((commitNode) => {
991 + const state = trimmed(commitNode.commit.statusCheckRollup?.state);
992 + return state === null ? [] : [{ state }];
993 });
994 }
995
1961 -function toStackMembership(
1962 - raw: Schema.Schema.Type<typeof RawStackMembershipSchema>,
1963 -): PullRequestStackMembership | undefined {
996 +export interface GitHubPullRequestSearchItem extends GitHubPullRequestListItem {
997 + /** `owner/name` as GitHub spells it, which is how a row from a search finds its repository. */
998 + readonly repository: string;
999 +}
1000 +
1001 +export function toStackMembership(raw: {
1002 + readonly stack?: {
1003 + readonly number: number;
1004 + readonly size: number;
1005 + readonly baseRefName: string;
1006 + } | null;
1007 + readonly stackEntry?: { readonly position: number } | null;
1008 +}): PullRequestStackMembership | undefined {
1009 return raw.stack && raw.stackEntry
1010 ? {
1011 number: raw.stack.number,
@@ -1975,179 +1020,22 @@ function toStackMembership(
1020 const REPOSITORY_PART = /^[A-Za-z0-9._-]+$/;
1021
1022 /**
1978 - * The owner and name of an `owner/name` selector, or null for one GitHub cannot name. A batch is
1979 - * one document, and a single unanswerable alias fails all of it, so these are refused up front.
1023 + * The variables of one pull request lookup, or null for a selector or number GitHub cannot
1024 + * name: a batch would send it, and GitHub would refuse the whole request rather than its part.
1025 */
1981 -function repositoryParts(
1982 - repository: string,
1983 -): { readonly owner: string; readonly name: string } | null {
1984 - const [owner, name, ...rest] = repository.trim().split("/");
1026 +export function pullRequestLookup(changeRequest: {
1027 + readonly repository: string;
1028 + readonly number: number;
1029 +}): { readonly owner: string; readonly name: string; readonly number: number } | null {
1030 + const [owner, name, ...rest] = changeRequest.repository.trim().split("/");
1031 if (rest.length > 0 || owner === undefined || name === undefined) return null;
1986 - return REPOSITORY_PART.test(owner) && REPOSITORY_PART.test(name) ? { owner, name } : null;
1987 -}
1988 -
1989 -const isPullRequestNumber = (number: number) => Number.isSafeInteger(number) && number > 0;
1990 -
1991 -/** One aliased `repository { pullRequest { selection } }` per change request, on one host. */
1992 -function aliasedPullRequestsDocument(
1993 - name: string,
1994 - alias: string,
1995 - changeRequests: ReadonlyArray<{ readonly repository: string; readonly number: number }>,
1996 - selection: string,
1997 -): GraphQlDocument | null {
1998 - const addressed = changeRequests.map((changeRequest) => ({
1999 - parts: repositoryParts(changeRequest.repository),
2000 - number: changeRequest.number,
2001 - }));
2002 - if (addressed.some(({ parts, number }) => parts === null || !isPullRequestNumber(number))) {
2003 - return null;
2004 - }
2005 - return aliasedGraphQlDocument({
2006 - operation: "query",
2007 - name,
2008 - alias,
2009 - items: addressed,
2010 - variables: ({ parts, number }) => ({
2011 - owner: ["String!", parts!.owner],
2012 - name: ["String!", parts!.name],
2013 - number: ["Int!", number],
2014 - }),
2015 - field: ({ owner, name, number }) =>
2016 - `repository(owner: ${owner}, name: ${name}) { pullRequest(number: ${number}) { ${selection} } }`,
2017 - });
2018 -}
2019 -
2020 -/**
2021 - * The line counts for rows a listing already handed over, as one aliased lookup each.
2022 - *
2023 - * Aliases rather than `nodes(ids:)` because the caller asks in the terms the page holds — a
2024 - * repository and a number — and never sees a node id. Null for a selector GitHub cannot name,
2025 - * which the caller reports rather than sends, and for an empty request.
2026 - */
2027 -export function buildPullRequestStatsGraphQlQuery(
2028 - changeRequests: ReadonlyArray<{ readonly repository: string; readonly number: number }>,
2029 -): GraphQlDocument | null {
2030 - return aliasedPullRequestsDocument(
2031 - "PullRequestStats",
2032 - "s",
2033 - changeRequests,
2034 - "additions deletions",
2035 - );
2036 -}
2037 -
2038 -/** Stack membership for the visible rows of a per-repository listing. */
2039 -export function buildPullRequestStackMembershipsGraphQlQuery(
2040 - repository: string,
2041 - numbers: ReadonlyArray<number>,
2042 -): GraphQlDocument | null {
2043 - return aliasedPullRequestsDocument(
2044 - "PullRequestStackMemberships",
2045 - "s",
2046 - numbers.map((number) => ({ repository, number })),
2047 - STACK_MEMBERSHIP_SELECTION,
2048 - );
2049 -}
2050 -
2051 -const decodeStackMemberships = decodeJsonResult(RawStackMembershipsSchema);
2052 -
2053 -export function decodePullRequestStackMembershipsJson(
2054 - raw: string,
2055 -): Result.Result<ReadonlyMap<number, PullRequestStackMembership>, DecodeFailure> {
2056 - const decoded = decodeStackMemberships(raw);
2057 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2058 - const memberships = new Map<number, PullRequestStackMembership>();
2059 - for (const [alias, value] of Object.entries(decoded.success.data)) {
2060 - const index = /^s(\d+)$/.exec(alias)?.[1];
2061 - if (index === undefined || value?.pullRequest == null) continue;
2062 - const stack = toStackMembership(value.pullRequest);
2063 - if (stack !== undefined) memberships.set(Number(index), stack);
2064 - }
2065 - return Result.succeed(memberships);
2066 -}
2067 -
2068 -/**
2069 - * The counts by the position they were asked in. A repository or a pull request GitHub answered
2070 - * nothing for is simply absent, which leaves the row with whatever it already had.
2071 - */
2072 -export function decodePullRequestStatsJson(
2073 - raw: string,
2074 -): Result.Result<
2075 - ReadonlyMap<number, { readonly additions: number; readonly deletions: number }>,
2076 - DecodeFailure
2077 -> {
2078 - const decoded = decodeStats(raw);
2079 - if (!Result.isSuccess(decoded)) {
2080 - return Result.fail(decoded.failure);
2081 - }
2082 - const stats = new Map<number, { readonly additions: number; readonly deletions: number }>();
2083 - for (const [alias, value] of Object.entries(decoded.success.data ?? {})) {
2084 - const index = /^s(\d+)$/.exec(alias)?.[1];
2085 - const pullRequest = value?.pullRequest;
2086 - if (index === undefined || pullRequest == null) continue;
2087 - stats.set(Number(index), {
2088 - additions: pullRequest.additions ?? 0,
2089 - deletions: pullRequest.deletions ?? 0,
2090 - });
2091 - }
2092 - return Result.succeed(stats);
2093 -}
2094 -
2095 -/**
2096 - * The fields a linked thread keeps current, for many pull requests in one aliased read. Same
2097 - * shape as the search row where the two overlap: the checks arrive as GitHub's one-word rollup
2098 - * rather than the whole check list `gh pr view` hands back, which is what keeps a batch cheap.
2099 - */
2100 -const STACK_MEMBERSHIP_SELECTION = "stack { number size baseRefName } stackEntry { position }";
2101 -
2102 -const PULL_REQUEST_SUMMARY_SELECTION =
2103 - "number title url state isDraft mergeable reviewDecision additions deletions changedFiles " +
2104 - "updatedAt mergedAt closedAt headRefName baseRefName " +
2105 - "author { __typename login avatarUrl ... on User { name } } " +
2106 - "latestReviews(first: 20) { nodes { state author { login } } } " +
2107 - "commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }";
2108 -
2109 -/** Summaries for pull requests anywhere on one host, one aliased lookup each; null when unsafe. */
2110 -export function buildPullRequestSummariesGraphQlQuery(
2111 - changeRequests: ReadonlyArray<{ readonly repository: string; readonly number: number }>,
2112 - includeStacks = false,
2113 -): GraphQlDocument | null {
2114 - return aliasedPullRequestsDocument(
2115 - "PullRequestSummaries",
2116 - "s",
2117 - changeRequests,
2118 - `${PULL_REQUEST_SUMMARY_SELECTION}${includeStacks ? ` ${STACK_MEMBERSHIP_SELECTION}` : ""}`,
2119 - );
1032 + if (!REPOSITORY_PART.test(owner) || !REPOSITORY_PART.test(name)) return null;
1033 + const { number } = changeRequest;
1034 + return Number.isSafeInteger(number) && number > 0 && number <= 2_147_483_647
1035 + ? { owner, name, number }
1036 + : null;
1037 }
1038
2122 -/** One pull request's summary, aliased the way the batch is so the same decoder reads it. */
2123 -export function pullRequestSummaryGraphQlQuery(includeStacks = false): string {
2124 - return `query($owner: String!, $name: String!, $number: Int!) {
2125 - s0: repository(owner: $owner, name: $name) { pullRequest(number: $number) { ${PULL_REQUEST_SUMMARY_SELECTION}${includeStacks ? ` ${STACK_MEMBERSHIP_SELECTION}` : ""} } }
2126 -}`;
2127 -}
2128 -
2129 -const RawSummarySchema = Schema.Struct({
2130 - ...RawSearchItemSchema.fields,
2131 - changedFiles: Schema.optional(Schema.NullOr(Schema.Int)),
2132 - additions: Schema.optional(Schema.NullOr(Schema.Int)),
2133 - deletions: Schema.optional(Schema.NullOr(Schema.Int)),
2134 - closedAt: Schema.optional(Schema.NullOr(Schema.String)),
2135 - createdAt: Schema.optional(Schema.String),
2136 -});
2137 -const decodeSummaries = decodeJsonResult(
2138 - Schema.Struct({
2139 - data: Schema.optional(
2140 - Schema.NullOr(
2141 - Schema.Record(
2142 - Schema.String,
2143 - Schema.NullOr(Schema.Struct({ pullRequest: Schema.optional(Schema.Unknown) })),
2144 - ),
2145 - ),
2146 - ),
2147 - }),
2148 -);
2149 -const decodeSummaryEntry = Schema.decodeUnknownExit(RawSummarySchema);
2150 -
1039 export interface GitHubPullRequestSummary {
1040 readonly number: number;
1041 readonly title: string;
@@ -2170,86 +1058,29 @@ export interface GitHubPullRequestSummary {
1058 readonly stack?: PullRequestStackMembership | null;
1059 }
1060
2173 -/**
2174 - * Summaries by the position they were asked in. A pull request GitHub answered nothing for, or
2175 - * one whose fields no longer decode, is absent rather than failing the rest of the batch.
2176 - */
2177 -export function decodePullRequestSummariesJson(
2178 - raw: string,
2179 -): Result.Result<ReadonlyMap<number, GitHubPullRequestSummary>, DecodeFailure> {
2180 - const decoded = decodeSummaries(raw);
2181 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2182 - const summaries = new Map<number, GitHubPullRequestSummary>();
2183 - for (const [alias, value] of Object.entries(decoded.success.data ?? {})) {
2184 - const index = /^s(\d+)$/.exec(alias)?.[1];
2185 - if (index === undefined || value?.pullRequest == null) continue;
2186 - const entry = decodeSummaryEntry(value.pullRequest);
2187 - if (!Exit.isSuccess(entry)) continue;
2188 - const pr = entry.value;
2189 - summaries.set(Number(index), {
2190 - number: pr.number,
2191 - title: pr.title,
2192 - url: pr.url,
2193 - headBranch: pr.headRefName,
2194 - baseBranch: pr.baseRefName,
2195 - state: toState(pr),
2196 - isDraft: pr.isDraft ?? false,
2197 - closedAt: trimmed(pr.closedAt),
2198 - mergedAt: trimmed(pr.mergedAt),
2199 - updatedAt: pr.updatedAt,
2200 - author: toActor(pr.author),
2201 - additions: pr.additions ?? 0,
2202 - deletions: pr.deletions ?? 0,
2203 - changedFiles: pr.changedFiles ?? 0,
2204 - reviewDecision: toReviewDecisionWithReviews(
2205 - pr.reviewDecision,
2206 - (pr.latestReviews?.nodes ?? []).flatMap((review) => (review === null ? [] : [review])),
2207 - ),
2208 - // One enum for the head commit, dressed as a single check like the search row's.
2209 - checksState: rollupChecksState(
2210 - (pr.commits?.nodes ?? []).flatMap((commitNode) => {
2211 - const state = trimmed(commitNode?.commit?.statusCheckRollup?.state);
2212 - return state === null ? [] : [{ state }];
2213 - }),
2214 - ),
2215 - mergeability: toMergeability(pr.mergeable),
2216 - ...(pr.stack === undefined ? {} : { stack: toStackMembership(pr) ?? null }),
2217 - });
2218 - }
2219 - return Result.succeed(summaries);
2220 -}
2221 -
2222 -const WATCH_FINGERPRINT_EDITS = "totalCount nodes { lastEditedAt }";
2223 -const WATCH_FINGERPRINT_CHECK_COUNTS =
2224 - "checkRunCountsByState { state count } statusContextCountsByState { state count }";
2225 -
2226 -/**
2227 - * What a pull request watch needs to notice, priced by GitHub at one point for twenty-five pull
2228 - * requests, where the detail and activity reads it gates cost sixteen for one. Counts and the
2229 - * newest edit cover new comments, reviews (a reply in a review thread is a review), threads, and
2230 - * a bot rewriting its summary; check counts by state move whenever a check starts or finishes.
2231 - * Comments come most recently updated first, since an edit moves `updatedAt`, so an edit to an
2232 - * old comment on a long pull request is still in the page. Reviews have no such order: an edit
2233 - * to a review older than the last hundred waits for the watch's periodic full read, as do edits
2234 - * to comments inside review threads, which cost a point per pull request to ask for.
2235 - */
2236 -const PULL_REQUEST_WATCH_FINGERPRINT_SELECTION =
2237 - "state mergeable headRefOid " +
2238 - `comments(first: 100, orderBy: { field: UPDATED_AT, direction: DESC }) { ${WATCH_FINGERPRINT_EDITS} } ` +
2239 - `reviews(last: 100) { ${WATCH_FINGERPRINT_EDITS} } ` +
2240 - "reviewThreads { totalCount } " +
2241 - `commits(last: 1) { nodes { commit { statusCheckRollup { contexts { ${WATCH_FINGERPRINT_CHECK_COUNTS} } } } } }`;
2242 -
2243 -/** Watch fingerprints for pull requests on one host, one aliased lookup each; null when unsafe. */
2244 -export function buildPullRequestWatchFingerprintsGraphQlQuery(
2245 - changeRequests: ReadonlyArray<{ readonly repository: string; readonly number: number }>,
2246 -): GraphQlDocument | null {
2247 - return aliasedPullRequestsDocument(
2248 - "PullRequestWatchFingerprints",
2249 - "w",
2250 - changeRequests,
2251 - PULL_REQUEST_WATCH_FINGERPRINT_SELECTION,
2252 - );
1061 +/** The summary a linked thread keeps current, from one slice of the batched read. */
1062 +export function toPullRequestSummary(pr: SummarizedPullRequest): GitHubPullRequestSummary {
1063 + return {
1064 + number: pr.number,
1065 + title: pr.title,
1066 + url: pr.url,
1067 + headBranch: pr.headRefName,
1068 + baseBranch: pr.baseRefName,
1069 + state: toState(pr),
1070 + isDraft: pr.isDraft,
1071 + closedAt: trimmed(pr.closedAt),
1072 + mergedAt: trimmed(pr.mergedAt),
1073 + updatedAt: pr.updatedAt,
1074 + author: toActor(pr.author),
1075 + additions: pr.additions,
1076 + deletions: pr.deletions,
1077 + changedFiles: pr.changedFiles,
1078 + reviewDecision: toReviewDecisionWithReviews(pr.reviewDecision, nodesOf(pr.latestReviews)),
1079 + // One enum for the head commit, dressed as a single check like the search row's.
1080 + checksState: rollupChecksState(rollupStates(pr.commits)),
1081 + mergeability: toMergeability(pr.mergeable),
1082 + ...(pr.stack === undefined ? {} : { stack: toStackMembership(pr) ?? null }),
1083 + };
1084 }
1085
1086 /**
@@ -2261,89 +1092,44 @@ export interface GitHubPullRequestWatchFingerprint {
1092 readonly remarks: string;
1093 }
1094
2264 -const RawEditedSchema = Schema.Struct({
2265 - totalCount: Schema.Int,
2266 - nodes: Schema.Array(Schema.NullOr(Schema.Struct({ lastEditedAt: Schema.NullOr(Schema.String) }))),
2267 -});
2268 -const RawStateCountsSchema = Schema.NullOr(
2269 - Schema.Array(Schema.Struct({ state: Schema.String, count: Schema.Int })),
2270 -);
2271 -const decodeWatchFingerprintEntry = Schema.decodeUnknownExit(
2272 - Schema.Struct({
2273 - state: Schema.String,
2274 - mergeable: Schema.NullOr(Schema.String),
2275 - headRefOid: Schema.String,
2276 - comments: RawEditedSchema,
2277 - reviews: RawEditedSchema,
2278 - reviewThreads: Schema.Struct({ totalCount: Schema.Int }),
2279 - commits: Schema.Struct({
2280 - nodes: Schema.Array(
2281 - Schema.NullOr(
2282 - Schema.Struct({
2283 - commit: Schema.Struct({
2284 - statusCheckRollup: Schema.NullOr(
2285 - Schema.Struct({
2286 - contexts: Schema.Struct({
2287 - checkRunCountsByState: RawStateCountsSchema,
2288 - statusContextCountsByState: RawStateCountsSchema,
2289 - }),
2290 - }),
2291 - ),
2292 - }),
2293 - }),
2294 - ),
2295 - ),
2296 - }),
2297 - }),
2298 -);
1095 +type EditedConnection = WatchedPullRequest["comments"] | WatchedPullRequest["reviews"];
1096 +type StateCounts = ReadonlyArray<{ readonly state: string; readonly count: number }> | null;
1097
1098 // An edit only ever moves `lastEditedAt` forward, so the newest one stands for them all.
2301 -const newestEdit = (connection: typeof RawEditedSchema.Type) =>
2302 - connection.nodes.reduce(
1099 +const newestEdit = (connection: EditedConnection) =>
1100 + (connection?.nodes ?? []).reduce(
1101 (newest, node) =>
1102 node?.lastEditedAt != null && node.lastEditedAt > newest ? node.lastEditedAt : newest,
1103 "",
1104 );
1105
2308 -const stateCounts = (counts: typeof RawStateCountsSchema.Type) =>
1106 +const stateCounts = (counts: StateCounts) =>
1107 (counts ?? [])
1108 .filter(({ count }) => count > 0)
1109 .map(({ state, count }) => `${state}:${count}`)
1110 .toSorted()
1111 .join(",");
1112
2315 -/** Fingerprints by alias index; a pull request GitHub returned nothing for is left out. */
2316 -export function decodePullRequestWatchFingerprintsJson(
2317 - raw: string,
2318 -): Result.Result<ReadonlyMap<number, GitHubPullRequestWatchFingerprint>, DecodeFailure> {
2319 - const decoded = decodeSummaries(raw);
2320 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2321 - const fingerprints = new Map<number, GitHubPullRequestWatchFingerprint>();
2322 - for (const [alias, value] of Object.entries(decoded.success.data ?? {})) {
2323 - const index = /^w(\d+)$/.exec(alias)?.[1];
2324 - if (index === undefined || value?.pullRequest == null) continue;
2325 - const entry = decodeWatchFingerprintEntry(value.pullRequest);
2326 - if (!Exit.isSuccess(entry)) continue;
2327 - const pr = entry.value;
2328 - const contexts = pr.commits.nodes[0]?.commit.statusCheckRollup?.contexts;
2329 - fingerprints.set(Number(index), {
2330 - status: [
2331 - pr.state,
2332 - pr.mergeable ?? "",
2333 - pr.headRefOid,
2334 - stateCounts(contexts?.checkRunCountsByState ?? null),
2335 - stateCounts(contexts?.statusContextCountsByState ?? null),
2336 - ].join(" "),
2337 - remarks: [
2338 - pr.comments.totalCount,
2339 - newestEdit(pr.comments),
2340 - pr.reviews.totalCount,
2341 - newestEdit(pr.reviews),
2342 - pr.reviewThreads.totalCount,
2343 - ].join(" "),
2344 - });
2345 - }
2346 - return Result.succeed(fingerprints);
1113 +export function toPullRequestWatchFingerprint(
1114 + pr: WatchedPullRequest,
1115 +): GitHubPullRequestWatchFingerprint {
1116 + const contexts = pr.commits.nodes?.[0]?.commit.statusCheckRollup?.contexts;
1117 + return {
1118 + status: [
1119 + pr.state,
1120 + pr.mergeable,
1121 + pr.headRefOid,
1122 + stateCounts(contexts?.checkRunCountsByState ?? null),
1123 + stateCounts(contexts?.statusContextCountsByState ?? null),
1124 + ].join(" "),
1125 + remarks: [
1126 + pr.comments.totalCount,
1127 + newestEdit(pr.comments),
1128 + pr.reviews?.totalCount ?? 0,
1129 + newestEdit(pr.reviews),
1130 + pr.reviewThreads.totalCount,
1131 + ].join(" "),
1132 + };
1133 }
1134
1135 export interface GitHubPullRequestCore extends GitHubPullRequestDetail {
@@ -2354,25 +1140,46 @@ export interface GitHubPullRequestCore extends GitHubPullRequestDetail {
1140 readonly checksTruncated: boolean;
1141 }
1142
2357 -export function decodePullRequestCoreJson(
2358 - raw: string,
2359 -): Result.Result<GitHubPullRequestCore, DecodeFailure> {
2360 - const decoded = decodeCore(raw);
2361 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2362 - const repository = decoded.success.data.repository;
2363 - const pr = repository.pullRequest;
2364 - const contexts = pr.commits.nodes[0]?.commit.statusCheckRollup?.contexts;
2365 - return Result.succeed({
2366 - reviewRequestTeams: pr.reviewRequests.nodes.flatMap(
1143 +type CoreRequestedReviewer = NonNullable<
1144 + NonNullable<
1145 + NonNullable<NonNullable<PullRequestCore.Result["repository"]>["pullRequest"]>["reviewRequests"]
1146 + >["nodes"]
1147 +>[number];
1148 +
1149 +/** Null for a repository or number that names no pull request the viewer can see. */
1150 +export function toPullRequestCore(result: PullRequestCore.Result): GitHubPullRequestCore | null {
1151 + const repository = result.repository;
1152 + const pr = repository?.pullRequest;
1153 + if (repository == null || pr == null) return null;
1154 + const contexts = nodesOf(pr.commits)[0]?.commit.statusCheckRollup?.contexts;
1155 + return {
1156 + reviewRequestTeams: nodesOf(pr.reviewRequests).flatMap(
1157 ({ requestedReviewer }) => toRequestedTeam(requestedReviewer) ?? [],
1158 ),
1159 ...toDetail({
1160 ...pr,
2371 - reviewRequests: pr.reviewRequests.nodes.flatMap(({ requestedReviewer }) =>
2372 - requestedReviewer === null ? [] : [requestedReviewer],
1161 + author:
1162 + pr.author === null ? null : { ...pr.author, id: "id" in pr.author ? pr.author.id : null },
1163 + latestReviews: [],
1164 + reviewRequests: nodesOf(pr.reviewRequests).flatMap(
1165 + ({ requestedReviewer }: NonNullable<CoreRequestedReviewer>) =>
1166 + requestedReviewer === null
1167 + ? []
1168 + : [
1169 + {
1170 + login: "login" in requestedReviewer ? requestedReviewer.login : null,
1171 + slug: "slug" in requestedReviewer ? requestedReviewer.slug : null,
1172 + name:
1173 + "teamName" in requestedReviewer
1174 + ? requestedReviewer.teamName
1175 + : "name" in requestedReviewer
1176 + ? requestedReviewer.name
1177 + : null,
1178 + },
1179 + ],
1180 ),
2374 - labels: pr.labels.nodes,
2375 - statusCheckRollup: toCheckContexts(contexts?.nodes ?? []),
1181 + labels: nodesOf(pr.labels),
1182 + statusCheckRollup: toCheckContexts(nodesOf(contexts)),
1183 }),
1184 headRepositoryNameWithOwner: trimmed(pr.headRepository?.nameWithOwner),
1185 viewerAccess: {
@@ -2394,9 +1201,10 @@ export function decodePullRequestCoreJson(
1201 viewerCanUpdate: pr.viewerCanUpdateBranch,
1202 },
1203 checksTruncated: contexts?.pageInfo.hasNextPage === true,
2397 - });
1204 + };
1205 }
1206
1207 +/** A detail as a REST pull request names it, for the provider's tests and fixtures. */
1208 export function decodePullRequestDetailJson(
1209 raw: string,
1210 ): Result.Result<GitHubPullRequestDetail, DecodeFailure> {
@@ -2428,37 +1236,21 @@ export function decodeWorkflowRunsJson(
1236 });
1237 }
1238
2431 -/** Open pull requests whose head branch has one name, from whichever repository it lives in. */
2432 -export const PULL_REQUEST_HEADS_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $head: String!, $after: String) {
2433 - repository(owner: $owner, name: $name) {
2434 - pullRequests(first: 100, after: $after, states: [OPEN], headRefName: $head) {
2435 - pageInfo { hasNextPage endCursor }
2436 - nodes { number headRefOid isCrossRepository headRepositoryOwner { login } }
2437 - }
2438 - }
2439 -}`;
2440 -
2441 -export function decodePullRequestHeadsJson(raw: string): Result.Result<
2442 - {
2443 - readonly heads: ReadonlyArray<GitHubPullRequestHead>;
2444 - readonly nextCursor: string | null;
2445 - },
2446 - DecodeFailure
2447 -> {
2448 - const decoded = decodePullRequestHeads(raw);
2449 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2450 - const connection = decoded.success.data.repository?.pullRequests;
2451 - return Result.succeed({
2452 - heads: (connection?.nodes ?? []).map((pullRequest) => ({
1239 +/** One page of open pull requests on one head branch; an unseen repository is an empty page. */
1240 +export function toPullRequestHeads(result: PullRequestHeads.Result): {
1241 + readonly heads: ReadonlyArray<GitHubPullRequestHead>;
1242 + readonly nextCursor: string | null;
1243 +} {
1244 + const connection = result.repository?.pullRequests;
1245 + return {
1246 + heads: nodesOf(connection).map((pullRequest) => ({
1247 number: pullRequest.number,
1248 headSha: pullRequest.headRefOid,
2455 - ...(typeof pullRequest.isCrossRepository === "boolean"
2456 - ? { isCrossRepository: pullRequest.isCrossRepository }
2457 - : {}),
1249 + isCrossRepository: pullRequest.isCrossRepository,
1250 headRepositoryOwner: trimmed(pullRequest.headRepositoryOwner?.login),
1251 })),
1252 nextCursor: nextCursorOf(connection?.pageInfo),
2461 - });
1253 + };
1254 }
1255
1256 export interface GitHubPullRequestActivityPage {
@@ -2471,123 +1263,58 @@ export interface GitHubPullRequestActivityPage {
1263 readonly nextReviewsCursor: string | null;
1264 }
1265
2474 -/** One page of `PULL_REQUEST_ACTIVITY_GRAPHQL_QUERY`. */
2475 -export function decodePullRequestActivityJson(
2476 - raw: string,
2477 -): Result.Result<GitHubPullRequestActivityPage, DecodeFailure> {
2478 - const decoded = decodeActivity(raw);
2479 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2480 - const pr = decoded.success.data.repository.pullRequest;
2481 - return Result.succeed({
1266 +/** One page of the activity read; null for a pull request the viewer cannot see. */
1267 +export function toPullRequestActivityPage(
1268 + result: PullRequestActivity.Result,
1269 +): GitHubPullRequestActivityPage | null {
1270 + const pr = result.repository?.pullRequest;
1271 + if (pr == null) return null;
1272 + return {
1273 ...(pr.author === undefined ? {} : { author: toActor(pr.author) }),
1274 ...(pr.commits === undefined
1275 ? {}
1276 : {
1277 commits: toCommits(
2487 - (pr.commits?.nodes ?? []).map(({ commit }) => ({
1278 + nodesOf(pr.commits).map(({ commit }) => ({
1279 ...commit,
2489 - authors: (commit.authors?.nodes ?? []).map((author) => ({
1280 + authors: nodesOf(commit.authors).map((author) => ({
1281 ...author,
1282 login: author.user?.login ?? null,
1283 })),
1284 })),
1285 ),
1286 }),
2496 - remarks: toComments({
2497 - comments: pr.comments?.nodes ?? [],
2498 - reviews: pr.reviews?.nodes ?? [],
2499 - }),
1287 + remarks: toComments({ comments: nodesOf(pr.comments), reviews: nodesOf(pr.reviews) }),
1288 nextCommentsCursor: nextCursorOf(pr.comments?.pageInfo),
1289 nextReviewsCursor: nextCursorOf(pr.reviews?.pageInfo),
2502 - });
1290 + };
1291 }
1292
2505 -/** Every check context of the head commit, a page at a time, for a rollup past one page. */
2506 -export const pullRequestCheckContextsGraphQlQuery = (host: string) =>
2507 - `query($owner: String!, $name: String!, $number: Int!, $after: String) {
2508 - repository(owner: $owner, name: $name) {
2509 - pullRequest(number: $number) {
2510 - headRefOid
2511 - commits(last: 1) {
2512 - nodes { commit { statusCheckRollup { contexts(first: 100, after: $after) {
2513 - ${checkContextNodesSelection(host)}
2514 - pageInfo { hasNextPage endCursor }
2515 - } } } }
2516 - }
2517 - }
2518 - }
2519 -}`;
2520 -
2521 -const RawCheckContextNodeSchema = Schema.Struct({
2522 - ...RawCheckSchema.fields,
2523 - checkSuite: Schema.optional(
2524 - Schema.NullOr(
2525 - Schema.Struct({
2526 - workflowRun: Schema.NullOr(
2527 - Schema.Struct({ workflow: Schema.NullOr(Schema.Struct({ name: Schema.String })) }),
2528 - ),
2529 - }),
2530 - ),
2531 - ),
2532 -});
2533 -
2534 -const decodeCheckContexts = decodeJsonResult(
2535 - Schema.Struct({
2536 - data: Schema.Struct({
2537 - repository: Schema.Struct({
2538 - pullRequest: Schema.Struct({
2539 - headRefOid: Schema.String,
2540 - commits: Schema.Struct({
2541 - nodes: Schema.Array(
2542 - Schema.Struct({
2543 - commit: Schema.Struct({
2544 - statusCheckRollup: Schema.NullOr(
2545 - Schema.Struct({
2546 - contexts: Schema.Struct({
2547 - nodes: Schema.Array(RawCheckContextNodeSchema),
2548 - pageInfo: RawPageInfoSchema,
2549 - }),
2550 - }),
2551 - ),
2552 - }),
2553 - }),
2554 - ),
2555 - }),
2556 - }),
2557 - }),
2558 - }),
2559 - }),
2560 -);
2561 -
1293 /** A check context as the rollup reports it; opaque outside this module. */
2563 -export type GitHubCheckContext = Schema.Schema.Type<typeof RawCheckSchema>;
2564 -
2565 -function toCheckContexts(
2566 - nodes: ReadonlyArray<Schema.Schema.Type<typeof RawCheckContextNodeSchema>>,
2567 -): ReadonlyArray<GitHubCheckContext> {
2568 - return nodes.map((check) => ({
2569 - ...check,
2570 - workflowName: check.checkSuite?.workflowRun?.workflow?.name ?? null,
2571 - }));
1294 +export type GitHubCheckContext = CheckFields;
1295 +
1296 +function toCheckContexts(nodes: ReadonlyArray<CheckContext>): ReadonlyArray<GitHubCheckContext> {
1297 + return nodes.map((check) =>
1298 + check.__typename === "CheckRun"
1299 + ? { ...check, workflowName: check.checkSuite.workflowRun?.workflow.name ?? null }
1300 + : check,
1301 + );
1302 }
1303
2574 -export function decodePullRequestCheckContextsJson(raw: string): Result.Result<
2575 - {
2576 - readonly headSha: string;
2577 - readonly contexts: ReadonlyArray<GitHubCheckContext>;
2578 - readonly nextCursor: string | null;
2579 - },
2580 - DecodeFailure
2581 -> {
2582 - const decoded = decodeCheckContexts(raw);
2583 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
2584 - const pr = decoded.success.data.repository.pullRequest;
2585 - const contexts = pr.commits.nodes[0]?.commit.statusCheckRollup?.contexts;
2586 - return Result.succeed({
1304 +/** One page of the head commit's check contexts; null for a pull request GitHub did not find. */
1305 +export function toPullRequestCheckContextsPage(result: PullRequestCheckContexts.Result): {
1306 + readonly headSha: string;
1307 + readonly contexts: ReadonlyArray<GitHubCheckContext>;
1308 + readonly nextCursor: string | null;
1309 +} | null {
1310 + const pr = result.repository?.pullRequest;
1311 + if (pr == null) return null;
1312 + const contexts = nodesOf(pr.commits)[0]?.commit.statusCheckRollup?.contexts;
1313 + return {
1314 headSha: pr.headRefOid,
2588 - contexts: toCheckContexts(contexts?.nodes ?? []),
1315 + contexts: toCheckContexts(nodesOf(contexts)),
1316 nextCursor: nextCursorOf(contexts?.pageInfo),
2590 - });
1317 + };
1318 }
1319
1320 /** The checks and their one-word verdict, from every context of the head commit. */
@@ -2702,17 +1429,13 @@ export function reviewThreadConversation(
1429 );
1430 }
1431
2705 -/** One page of review threads. Following the cursors it hands back is the caller's job. */
1432 +/** Dismissal reasons by the dismissed review's node id. */
1433 function toDismissalEntries(
2707 - nodes:
2708 - | ReadonlyArray<{
2709 - readonly dismissalMessage?: string | null | undefined;
2710 - readonly review?: { readonly id?: string | null | undefined } | null | undefined;
2711 - }>
2712 - | undefined,
1434 + connection: ReviewThreadsPullRequest["reviewDismissals"],
1435 ): Map<string, string> {
1436 const entries = new Map<string, string>();
2715 - for (const node of nodes ?? []) {
1437 + for (const node of nodesOf(connection)) {
1438 + if (!("dismissalMessage" in node)) continue;
1439 const reviewId = trimmed(node.review?.id);
1440 const message = trimmed(node.dismissalMessage);
1441 if (reviewId !== null && message !== null) entries.set(reviewId, message);
@@ -2720,60 +1443,47 @@ function toDismissalEntries(
1443 return entries;
1444 }
1445
2723 -const RawReviewDismissalsSchema = Schema.Struct({
2724 - data: Schema.Struct({
2725 - repository: Schema.Struct({
2726 - pullRequest: Schema.Struct({
2727 - timelineItems: Schema.Struct({
2728 - pageInfo: Schema.optional(RawPageInfoSchema),
2729 - nodes: Schema.Array(
2730 - Schema.Struct({
2731 - dismissalMessage: Schema.optional(Schema.NullOr(Schema.String)),
2732 - review: Schema.optional(
2733 - Schema.NullOr(Schema.Struct({ id: Schema.optional(Schema.NullOr(Schema.String)) })),
2734 - ),
2735 - }),
2736 - ),
2737 - }),
2738 - }),
2739 - }),
2740 - }),
2741 -});
2742 -
2743 -const decodeReviewDismissals = decodeJsonResult(RawReviewDismissalsSchema);
2744 -
1446 /** One further page of dismissal events, in the shape the thread read's own page carries. */
2746 -export function decodeReviewDismissalsJson(raw: string): Result.Result<
2747 - {
2748 - readonly dismissalsByReviewId: ReadonlyMap<string, string>;
2749 - readonly nextCursor: string | null;
2750 - },
2751 - DecodeFailure
2752 -> {
2753 - const decoded = decodeReviewDismissals(raw);
2754 - if (!Result.isSuccess(decoded)) {
2755 - return Result.fail(decoded.failure);
2756 - }
2757 - const items = decoded.success.data.repository.pullRequest.timelineItems;
2758 - return Result.succeed({
2759 - dismissalsByReviewId: toDismissalEntries(items.nodes),
1447 +export function toReviewDismissalsPage(result: ReviewDismissals.Result): {
1448 + readonly dismissalsByReviewId: ReadonlyMap<string, string>;
1449 + readonly nextCursor: string | null;
1450 +} | null {
1451 + const items = result.repository?.pullRequest?.timelineItems;
1452 + if (items === undefined) return null;
1453 + return {
1454 + dismissalsByReviewId: toDismissalEntries(items),
1455 nextCursor: nextCursorOf(items.pageInfo),
2761 - });
1456 + };
1457 }
1458
2764 -export function decodeReviewThreadsJson(
2765 - raw: string,
2766 -): Result.Result<GitHubReviewThreadPage, DecodeFailure> {
2767 - const decoded = decodeReviewThreads(raw);
2768 - if (!Result.isSuccess(decoded)) {
2769 - return Result.fail(decoded.failure);
2770 - }
2771 - const viewer = trimmed(decoded.success.data.viewer?.login);
2772 - const threads = decoded.success.data.repository.pullRequest.reviewThreads;
2773 - const entries = threads.nodes.flatMap((thread): ReadonlyArray<GitHubReviewThreadEntry> => {
1459 +function toThreadComment(comment: ThreadComment, viewer: string | null): PullRequestThreadComment {
1460 + return {
1461 + id: comment.id,
1462 + author: toActor(comment.author),
1463 + body: comment.body,
1464 + createdAt: comment.createdAt,
1465 + editedAt: comment.lastEditedAt,
1466 + url: trimmed(comment.url),
1467 + reactions: toReactions(comment.reactionGroups, viewer),
1468 + };
1469 +}
1470 +
1471 +type ReviewThreadsPullRequest = NonNullable<
1472 + NonNullable<ReviewThreads.Result["repository"]>["pullRequest"]
1473 +>;
1474 +
1475 +/** One page of review threads; null for a pull request the viewer cannot see. */
1476 +export function toReviewThreadPage(result: ReviewThreads.Result): GitHubReviewThreadPage | null {
1477 + const pullRequest = result.repository?.pullRequest;
1478 + if (pullRequest == null) return null;
1479 + const viewer = trimmed(result.viewer.login);
1480 + const threads = pullRequest.reviewThreads;
1481 + const threadNodes = nodesOf(threads);
1482 + const entries = threadNodes.flatMap((thread): ReadonlyArray<GitHubReviewThreadEntry> => {
1483 const path = trimmed(thread.path);
1484 const id = trimmed(thread.id);
2776 - if (path === null || id === null || thread.comments.nodes.length === 0) return [];
1485 + const comments = nodesOf(thread.comments);
1486 + if (path === null || id === null || comments.length === 0) return [];
1487 return [
1488 {
1489 thread: {
@@ -2781,38 +1491,32 @@ export function decodeReviewThreadsJson(
1491 path,
1492 // Null once the thread's line has left the diff, which is exactly when GitHub reports
1493 // it outdated. Such a thread is listed rather than pinned to a line it no longer has.
2784 - line:
2785 - thread.line !== null && thread.line !== undefined && thread.line > 0
2786 - ? thread.line
2787 - : null,
2788 - side: thread.diffSide?.toUpperCase() === "LEFT" ? "left" : "right",
2789 - isResolved: thread.isResolved === true,
2790 - isOutdated: thread.isOutdated === true,
2791 - comments: thread.comments.nodes.map((comment) => ({
2792 - id: comment.id,
2793 - author: toActor(comment.author),
2794 - body: comment.body ?? "",
2795 - createdAt: comment.createdAt,
2796 - editedAt: comment.lastEditedAt ?? null,
2797 - url: trimmed(comment.url),
2798 - reactions: toReactions(comment.reactionGroups, viewer),
2799 - })),
1494 + line: thread.line !== null && thread.line > 0 ? thread.line : null,
1495 + side: thread.diffSide.toUpperCase() === "LEFT" ? "left" : "right",
1496 + isResolved: thread.isResolved,
1497 + isOutdated: thread.isOutdated,
1498 + comments: comments.map((comment) => toThreadComment(comment, viewer)),
1499 },
2801 - commentCount: thread.comments.totalCount ?? thread.comments.nodes.length,
1500 + commentCount: thread.comments.totalCount,
1501 nextCommentCursor: nextCursorOf(thread.comments.pageInfo),
1502 },
1503 ];
1504 });
2806 - const pullRequest = decoded.success.data.repository.pullRequest;
1505 + const requestedReviewers = nodesOf(pullRequest.reviewRequests).map(
1506 + (node): ActorFields | null => node.requestedReviewer,
1507 + );
1508 + const latestReviews = nodesOf(pullRequest.latestReviews);
1509 + const comments = nodesOf(pullRequest.comments);
1510 + const reviews = nodesOf(pullRequest.reviews);
1511 const avatarsByLogin = new Map<string, string>();
1512 const botLogins = new Set<string>();
1513 for (const raw of [
1514 pullRequest.author,
2811 - ...(pullRequest.comments?.nodes ?? []).map((node) => node.author),
2812 - ...(pullRequest.reviews?.nodes ?? []).map((node) => node.author),
2813 - ...(pullRequest.reviewRequests?.nodes ?? []).map((node) => node.requestedReviewer),
2814 - ...(pullRequest.latestReviews?.nodes ?? []).map((node) => node.author),
2815 - ...threads.nodes.flatMap((thread) => thread.comments.nodes.map((comment) => comment.author)),
1515 + ...comments.map((node) => node.author),
1516 + ...reviews.map((node) => node.author),
1517 + ...requestedReviewers,
1518 + ...latestReviews.map((node) => node.author),
1519 + ...threadNodes.flatMap((thread) => nodesOf(thread.comments).map((comment) => comment.author)),
1520 ]) {
1521 const login = trimmed(raw?.login);
1522 const avatarUrl = trimmed(raw?.avatarUrl);
@@ -2820,28 +1524,20 @@ export function decodeReviewThreadsJson(
1524 if (login !== null && toActor(raw)?.isBot) botLogins.add(login);
1525 }
1526 const reviewers = new Map<string, PullRequestActor>();
2823 - for (const raw of [
2824 - ...(pullRequest.reviewRequests?.nodes ?? []).map((node) => node.requestedReviewer),
2825 - ...(pullRequest.latestReviews?.nodes ?? []).map((node) => node.author),
2826 - ]) {
1527 + for (const raw of [...requestedReviewers, ...latestReviews.map((node) => node.author)]) {
1528 const actor = toActor(raw) ?? toRequestedTeam(raw);
1529 // Keyed by login, so someone who was asked and then answered appears once.
1530 if (actor !== null && !reviewers.has(actor.login)) reviewers.set(actor.login, actor);
1531 }
1532 const commitStats = new Map<string, { readonly additions: number; readonly deletions: number }>();
1533 const commits: PullRequestCommit[] = [];
2833 - for (const node of pullRequest.commits?.nodes ?? []) {
2834 - const commit = node.commit;
1534 + for (const { commit } of nodesOf(pullRequest.commits)) {
1535 const oid = trimmed(commit.oid);
1536 if (oid === null) continue;
1537 // GitHub measures a merge commit against its first parent, so merging the base into the head
1538 // reports every upstream change as if it belonged to the pull request. There is no useful
1539 // per-commit stat to show for that integration commit without another comparison request.
2840 - if (
2841 - (commit.parents?.totalCount ?? 1) <= 1 &&
2842 - commit.additions !== undefined &&
2843 - commit.deletions !== undefined
2844 - ) {
1540 + if (commit.parents.totalCount <= 1) {
1541 commitStats.set(oid, {
1542 additions: Math.max(0, commit.additions),
1543 deletions: Math.max(0, commit.deletions),
@@ -2851,20 +1547,14 @@ export function decodeReviewThreadsJson(
1547 if (committedDate === null) continue;
1548 commits.push({
1549 oid,
2854 - messageHeadline: commit.messageHeadline ?? "",
1550 + messageHeadline: commit.messageHeadline,
1551 committedDate,
2856 - authors: (commit.authors?.nodes ?? []).flatMap((author) => {
2857 - const actor = toGraphqlCommitActor(author);
2858 - return actor === null ? [] : [actor];
2859 - }),
1552 + authors: nodesOf(commit.authors).flatMap((author) => toGraphqlCommitActor(author) ?? []),
1553 });
1554 }
1555 const reactionsById = new Map<string, ReadonlyArray<PullRequestReaction>>();
1556 const editedAtById = new Map<string, string>();
2864 - for (const node of [
2865 - ...(pullRequest.comments?.nodes ?? []),
2866 - ...(pullRequest.reviews?.nodes ?? []),
2867 - ]) {
1557 + for (const node of [...comments, ...reviews]) {
1558 const id = trimmed(node.id);
1559 if (id === null) continue;
1560 const editedAt = trimmed(node.lastEditedAt);
@@ -2872,7 +1562,7 @@ export function decodeReviewThreadsJson(
1562 const reactions = toReactions(node.reactionGroups, viewer);
1563 if (reactions.length > 0) reactionsById.set(id, reactions);
1564 }
2875 - return Result.succeed({
1565 + return {
1566 threads: entries,
1567 nextCursor: nextCursorOf(threads.pageInfo),
1568 reactions: toReactions(pullRequest.reactionGroups, viewer),
@@ -2884,42 +1574,25 @@ export function decodeReviewThreadsJson(
1574 commitStats,
1575 commits,
1576 viewer: toPullRequestViewerFields(pullRequest),
2887 - dismissalsByReviewId: toDismissalEntries(pullRequest.reviewDismissals?.nodes),
2888 - nextDismissalCursor: nextCursorOf(pullRequest.reviewDismissals?.pageInfo),
2889 - });
1577 + dismissalsByReviewId: toDismissalEntries(pullRequest.reviewDismissals),
1578 + nextDismissalCursor: nextCursorOf(pullRequest.reviewDismissals.pageInfo),
1579 + };
1580 }
1581
1582 /** The rest of one thread's comments, in the shape the first page already delivered them. */
2893 -export function decodeReviewThreadCommentsJson(raw: string): Result.Result<
2894 - {
2895 - readonly belongsToPullRequest: boolean;
2896 - readonly comments: ReadonlyArray<PullRequestThreadComment>;
2897 - readonly nextCursor: string | null;
2898 - },
2899 - DecodeFailure
2900 -> {
2901 - const decoded = decodeReviewThreadComments(raw);
2902 - if (!Result.isSuccess(decoded)) {
2903 - return Result.fail(decoded.failure);
2904 - }
2905 - const viewer = trimmed(decoded.success.data.viewer?.login);
2906 - const comments = decoded.success.data.node?.comments;
2907 - return Result.succeed({
2908 - belongsToPullRequest:
2909 - decoded.success.data.repository?.pullRequest?.id !== undefined &&
2910 - decoded.success.data.repository?.pullRequest?.id ===
2911 - decoded.success.data.node?.pullRequest?.id,
2912 - comments: (comments?.nodes ?? []).map((comment) => ({
2913 - id: comment.id,
2914 - author: toActor(comment.author),
2915 - body: comment.body ?? "",
2916 - createdAt: comment.createdAt,
2917 - editedAt: comment.lastEditedAt ?? null,
2918 - url: trimmed(comment.url),
2919 - reactions: toReactions(comment.reactionGroups, viewer),
2920 - })),
2921 - nextCursor: nextCursorOf(comments?.pageInfo),
2922 - });
1583 +export function toReviewThreadCommentsPage(result: ReviewThreadComments.Result): {
1584 + readonly belongsToPullRequest: boolean;
1585 + readonly comments: ReadonlyArray<PullRequestThreadComment>;
1586 + readonly nextCursor: string | null;
1587 +} {
1588 + const viewer = trimmed(result.viewer.login);
1589 + const thread = result.node?.__typename === "PullRequestReviewThread" ? result.node : null;
1590 + const pullRequestId = result.repository?.pullRequest?.id;
1591 + return {
1592 + belongsToPullRequest: pullRequestId !== undefined && pullRequestId === thread?.pullRequest.id,
1593 + comments: nodesOf(thread?.comments).map((comment) => toThreadComment(comment, viewer)),
1594 + nextCursor: nextCursorOf(thread?.comments.pageInfo),
1595 + };
1596 }
1597
1598 /** Repository settings returned alongside the pull request viewer permissions. */
@@ -2977,57 +1650,6 @@ export interface GitHubBaseComparison {
1650 readonly viewerCanUpdate: boolean;
1651 }
1652
2980 -export const REVIEWER_CANDIDATES_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
2981 - repository(owner: $owner, name: $name) {
2982 - assignableUsers(first: ${GRAPHQL_PAGE_SIZE}) {
2983 - pageInfo { hasNextPage }
2984 - nodes { login name avatarUrl }
2985 - }
2986 - pullRequest(number: $number) {
2987 - author { login }
2988 - reviewRequests(first: ${GRAPHQL_PAGE_SIZE}) {
2989 - nodes {
2990 - requestedReviewer {
2991 - ... on User { login name avatarUrl }
2992 - ... on Team { slug combinedSlug name avatarUrl }
2993 - ... on Bot { login avatarUrl }
2994 - }
2995 - }
2996 - }
2997 - }
2998 - }
2999 -}`;
3000 -
3001 -const RawReviewerCandidatesSchema = Schema.Struct({
3002 - data: Schema.Struct({
3003 - repository: Schema.Struct({
3004 - assignableUsers: Schema.Struct({
3005 - pageInfo: Schema.optional(RawPageInfoSchema),
3006 - nodes: Schema.Array(Schema.NullOr(RawActorSchema)),
3007 - }),
3008 - /** Null for a number that names no pull request the viewer can see. */
3009 - pullRequest: Schema.NullOr(
3010 - Schema.Struct({
3011 - author: Schema.optional(Schema.NullOr(RawActorSchema)),
3012 - reviewRequests: Schema.optional(
3013 - Schema.NullOr(
3014 - Schema.Struct({
3015 - nodes: Schema.Array(
3016 - Schema.Struct({
3017 - requestedReviewer: Schema.optional(Schema.NullOr(RawRequestedReviewerSchema)),
3018 - }),
3019 - ),
3020 - }),
3021 - ),
3022 - ),
3023 - }),
3024 - ),
3025 - }),
3026 - }),
3027 -});
3028 -
3029 -const decodeReviewerCandidates = decodeJsonResult(RawReviewerCandidatesSchema);
3030 -
1653 /**
1654 * The people this pull request may be sent to, with whoever is already on it marked. The author is
1655 * dropped rather than shown as an unusable row: GitHub refuses a review request from the person
@@ -3035,49 +1657,49 @@ const decodeReviewerCandidates = decodeJsonResult(RawReviewerCandidatesSchema);
1657 *
1658 * Whoever has been asked leads the list even where GitHub does not count them assignable — an
1659 * outside collaborator, an app — because a request that cannot be seen cannot be taken back.
1660 + * Null for a repository the viewer cannot see.
1661 */
3039 -export function decodeReviewerCandidatesJson(
3040 - raw: string,
3041 -): Result.Result<PullRequestReviewerCandidateList, DecodeFailure> {
3042 - const decoded = decodeReviewerCandidates(raw);
3043 - if (!Result.isSuccess(decoded)) {
3044 - return Result.fail(decoded.failure);
3045 - }
3046 - const repository = decoded.success.data.repository;
1662 +export function toReviewerCandidates(
1663 + result: ReviewerCandidates.Result,
1664 +): PullRequestReviewerCandidateList | null {
1665 + const repository = result.repository;
1666 + if (repository == null) return null;
1667 const pullRequest = repository.pullRequest;
1668 const author = trimmed(pullRequest?.author?.login);
1669 const candidates = new Map<string, PullRequestReviewerCandidate>();
3050 - for (const node of pullRequest?.reviewRequests?.nodes ?? []) {
3051 - const raw = node.requestedReviewer;
3052 - const slug = trimmed(raw?.slug);
3053 - const id = slug ?? trimmed(raw?.login);
1670 + for (const { requestedReviewer: raw } of nodesOf(pullRequest?.reviewRequests)) {
1671 + if (raw === null) continue;
1672 + const slug = "slug" in raw ? trimmed(raw.slug) : null;
1673 + const id = slug ?? ("login" in raw ? trimmed(raw.login) : null);
1674 if (id === null) continue;
1675 candidates.set(`${slug === null ? "user" : "team"} ${id}`, {
1676 id,
1677 kind: slug === null ? "user" : "team",
1678 // The same `org/slug` the reviewer row shows, so taking the request back finds that row.
3059 - login: slug === null ? id : (trimmed(raw?.combinedSlug) ?? id),
3060 - name: trimmed(raw?.name),
3061 - avatarUrl: trimmed(raw?.avatarUrl),
1679 + login: slug === null ? id : (trimmed("combinedSlug" in raw ? raw.combinedSlug : null) ?? id),
1680 + name: trimmed("teamName" in raw ? raw.teamName : "name" in raw ? raw.name : null),
1681 + avatarUrl: trimmed(
1682 + "teamAvatarUrl" in raw ? raw.teamAvatarUrl : "avatarUrl" in raw ? raw.avatarUrl : null,
1683 + ),
1684 isRequested: true,
1685 });
1686 }
3065 - for (const node of repository.assignableUsers.nodes) {
3066 - const login = trimmed(node?.login);
1687 + for (const node of nodesOf(repository.assignableUsers)) {
1688 + const login = trimmed(node.login);
1689 if (login === null || login === author || candidates.has(`user ${login}`)) continue;
1690 candidates.set(`user ${login}`, {
1691 id: login,
1692 kind: "user",
1693 login,
3072 - name: trimmed(node?.name),
3073 - avatarUrl: trimmed(node?.avatarUrl),
1694 + name: trimmed(node.name),
1695 + avatarUrl: trimmed(node.avatarUrl),
1696 isRequested: false,
1697 });
1698 }
3077 - return Result.succeed({
1699 + return {
1700 candidates: [...candidates.values()],
3079 - truncated: repository.assignableUsers.pageInfo?.hasNextPage === true,
3080 - });
1701 + truncated: repository.assignableUsers.pageInfo.hasNextPage,
1702 + };
1703 }
1704
1705 /**
@@ -3101,88 +1723,39 @@ export function buildReviewerRequest(
1723 };
1724 }
1725
3104 -export const LABEL_CANDIDATES_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
3105 - repository(owner: $owner, name: $name) {
3106 - labels(first: ${GRAPHQL_PAGE_SIZE}, orderBy: { field: NAME, direction: ASC }) {
3107 - pageInfo { hasNextPage }
3108 - nodes { name color description }
3109 - }
3110 - pullRequest(number: $number) {
3111 - labels(first: ${GRAPHQL_PAGE_SIZE}) { nodes { name } }
3112 - }
3113 - }
3114 -}`;
3115 -
3116 -const RawLabelCandidatesSchema = Schema.Struct({
3117 - data: Schema.Struct({
3118 - repository: Schema.Struct({
3119 - labels: Schema.optional(
3120 - Schema.NullOr(
3121 - Schema.Struct({
3122 - pageInfo: Schema.optional(RawPageInfoSchema),
3123 - nodes: Schema.Array(
3124 - Schema.NullOr(
3125 - Schema.Struct({
3126 - ...RawLabelSchema.fields,
3127 - description: Schema.optional(Schema.NullOr(Schema.String)),
3128 - }),
3129 - ),
3130 - ),
3131 - }),
3132 - ),
3133 - ),
3134 - /** Null for a number that names no pull request the viewer can see. */
3135 - pullRequest: Schema.NullOr(
3136 - Schema.Struct({
3137 - labels: Schema.optional(
3138 - Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.NullOr(RawLabelSchema)) })),
3139 - ),
3140 - }),
3141 - ),
3142 - }),
3143 - }),
3144 -});
3145 -
3146 -const decodeLabelCandidates = decodeJsonResult(RawLabelCandidatesSchema);
3147 -
1726 /**
1727 * The repository's labels, with the ones already on this pull request marked. A label the pull
1728 * request wears that the repository no longer defines — deleted since, or past the page — leads
3151 - * the list anyway, because a label that cannot be seen cannot be taken off.
1729 + * the list anyway, because a label that cannot be seen cannot be taken off. Null for a repository
1730 + * the viewer cannot see.
1731 */
3153 -export function decodeLabelCandidatesJson(
3154 - raw: string,
3155 -): Result.Result<PullRequestLabelCandidateList, DecodeFailure> {
3156 - const decoded = decodeLabelCandidates(raw);
3157 - if (!Result.isSuccess(decoded)) {
3158 - return Result.fail(decoded.failure);
3159 - }
3160 - const repository = decoded.success.data.repository;
1732 +export function toLabelCandidates(
1733 + result: LabelCandidates.Result,
1734 +): PullRequestLabelCandidateList | null {
1735 + const repository = result.repository;
1736 + if (repository == null) return null;
1737 const applied = new Set(
3162 - (repository.pullRequest?.labels?.nodes ?? []).flatMap((label) => {
3163 - const name = trimmed(label?.name);
3164 - return name === null ? [] : [name];
3165 - }),
1738 + nodesOf(repository.pullRequest?.labels).flatMap((label) => trimmed(label.name) ?? []),
1739 );
1740 const candidates = new Map<string, PullRequestLabelCandidate>();
3168 - for (const node of repository.labels?.nodes ?? []) {
3169 - const name = trimmed(node?.name);
1741 + for (const node of nodesOf(repository.labels)) {
1742 + const name = trimmed(node.name);
1743 if (name === null) continue;
1744 candidates.set(name, {
1745 name,
3173 - color: trimmed(node?.color),
3174 - description: trimmed(node?.description),
1746 + color: trimmed(node.color),
1747 + description: trimmed(node.description),
1748 isApplied: applied.has(name),
1749 });
1750 }
1751 const missing = [...applied].filter((name) => !candidates.has(name));
3179 - return Result.succeed({
1752 + return {
1753 candidates: [
1754 ...missing.map((name) => ({ name, color: null, description: null, isApplied: true })),
1755 ...candidates.values(),
1756 ],
3184 - truncated: repository.labels?.pageInfo?.hasNextPage === true,
3185 - });
1757 + truncated: repository.labels?.pageInfo.hasNextPage === true,
1758 + };
1759 }
1760
1761 /** The body of `POST /repos/{owner}/{repo}/issues/{number}/labels`, which adds to what is there. */
@@ -3216,40 +1789,13 @@ export interface GitHubViewerAccess {
1789 readonly canUpdateBranch?: boolean;
1790 }
1791
3219 -/** Core detail and write checks share one read of permissions and merge settings. */
3220 -export const VIEWER_PERMISSIONS_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
3221 - repository(owner: $owner, name: $name) {
3222 - mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerPermission
3223 - pullRequest(number: $number) {
3224 - viewerCanUpdate viewerDidAuthor
3225 - headRepository { viewerPermission }
3226 - }
3227 - }
3228 -}`;
3229 -
3230 -const RawViewerPermissionsSchema = Schema.Struct({
3231 - data: Schema.Struct({
3232 - repository: Schema.Struct({
3233 - ...RawRepositoryAccessSchema.fields,
3234 - /** Null for a number that names no pull request the viewer can see. */
3235 - pullRequest: Schema.NullOr(
3236 - Schema.Struct({ ...RawViewerFieldsSchema.fields, ...RawHeadBranchAccessSchema.fields }),
3237 - ),
3238 - }),
3239 - }),
3240 -});
3241 -
3242 -const decodeViewerPermissions = decodeJsonResult(RawViewerPermissionsSchema);
3243 -
3244 -export function decodeViewerPermissionsJson(
3245 - raw: string,
3246 -): Result.Result<GitHubViewerAccess & GitHubRepositoryAccess, DecodeFailure> {
3247 - const decoded = decodeViewerPermissions(raw);
3248 - if (!Result.isSuccess(decoded)) {
3249 - return Result.fail(decoded.failure);
3250 - }
3251 - const repository = decoded.success.data.repository;
3252 - return Result.succeed({
1792 +/** Null for a repository the viewer cannot see. */
1793 +export function toViewerPermissions(
1794 + result: ViewerPermissions.Result,
1795 +): (GitHubViewerAccess & GitHubRepositoryAccess) | null {
1796 + const repository = result.repository;
1797 + if (repository == null) return null;
1798 + return {
1799 mergeCapabilities: {
1800 merge: repository.mergeCommitAllowed,
1801 squash: repository.squashMergeAllowed,
@@ -3259,7 +1805,7 @@ export function decodeViewerPermissionsJson(
1805 canDeleteBranch: toCanWrite(repository.pullRequest?.headRepository?.viewerPermission),
1806 canTriage: toCanTriage(repository.viewerPermission),
1807 ...toPullRequestViewerFields(repository.pullRequest),
3262 - });
1808 + };
1809 }
1810
1811 export interface GitHubPullRequestFilesPatch {
@@ -3346,55 +1892,6 @@ function toFilesPatch(entries: ReadonlyArray<unknown>): GitHubPullRequestFilesPa
1892 };
1893 }
1894
3349 -/**
3350 - * Which files of a pull request the signed-in account has cleared. GraphQL only, since the REST
3351 - * files endpoint the patch is read from carries no viewed state, so this is a second read rather
3352 - * than a wider version of the first.
3353 - */
3354 -export const PULL_REQUEST_FILES_VIEWED_GRAPHQL_QUERY = `query($owner: String!, $name: String!, $number: Int!, $after: String) {
3355 - repository(owner: $owner, name: $name) {
3356 - pullRequest(number: $number) {
3357 - files(first: 100, after: $after) {
3358 - pageInfo { hasNextPage endCursor }
3359 - nodes { path viewerViewedState }
3360 - }
3361 - }
3362 - }
3363 -}`;
3364 -
3365 -const RawPullRequestFilesViewedSchema = Schema.Struct({
3366 - data: Schema.Struct({
3367 - repository: Schema.NullOr(
3368 - Schema.Struct({
3369 - pullRequest: Schema.NullOr(
3370 - Schema.Struct({
3371 - files: Schema.Struct({
3372 - pageInfo: Schema.Struct({
3373 - hasNextPage: Schema.Boolean,
3374 - endCursor: Schema.NullOr(Schema.String),
3375 - }),
3376 - nodes: Schema.NullOr(
3377 - Schema.Array(
3378 - Schema.NullOr(
3379 - Schema.Struct({
3380 - path: Schema.String,
3381 - // Decoded as a plain string and narrowed below: a GitHub release that adds
3382 - // a fourth state must not fail the whole page.
3383 - viewerViewedState: Schema.String,
3384 - }),
3385 - ),
3386 - ),
3387 - ),
3388 - }),
3389 - }),
3390 - ),
3391 - }),
3392 - ),
3393 - }),
3394 -});
3395 -
3396 -const decodePullRequestFilesViewed = decodeJsonResult(RawPullRequestFilesViewedSchema);
3397 -
1895 export interface GitHubPullRequestFilesViewedPage {
1896 readonly files: ReadonlyArray<{
1897 readonly path: string;
@@ -3416,42 +1913,19 @@ function toFileViewedState(raw: string): PullRequestFileViewedState {
1913 }
1914 }
1915
3419 -export function decodePullRequestFilesViewedJson(
3420 - raw: string,
3421 -): Result.Result<GitHubPullRequestFilesViewedPage, DecodeFailure> {
3422 - const decoded = decodePullRequestFilesViewed(raw);
3423 - if (!Result.isSuccess(decoded)) return Result.fail(decoded.failure);
3424 - const files = decoded.success.data.repository?.pullRequest?.files;
3425 - if (files === undefined) return Result.succeed({ files: [], nextCursor: null });
3426 - return Result.succeed({
3427 - files: (files.nodes ?? []).flatMap((node) =>
3428 - node === null || node.path.length === 0
1916 +/** One page of viewed state; empty for a pull request the host has nothing to say about. */
1917 +export function toPullRequestFilesViewedPage(
1918 + result: PullRequestFilesViewed.Result,
1919 +): GitHubPullRequestFilesViewedPage {
1920 + const files = result.repository?.pullRequest?.files;
1921 + return {
1922 + files: nodesOf(files).flatMap((node) =>
1923 + node.path.length === 0
1924 ? []
1925 : [{ path: node.path, state: toFileViewedState(node.viewerViewedState) }],
1926 ),
3432 - nextCursor: files.pageInfo.hasNextPage ? files.pageInfo.endCursor : null,
3433 - });
3434 -}
3435 -
3436 -/**
3437 - * One document that clears and restores as many files as the reader ticked, rather than one
3438 - * request each. GitHub has no bulk form of `markFileAsViewed`/`unmarkFileAsViewed`, which each
3439 - * take a single path, so the batching is done with aliases; top-level mutation fields run in
3440 - * write order, so the last word about a path is the one that sticks.
3441 - */
3442 -export function buildSetFilesViewedGraphQlMutation(
3443 - pullRequestId: string,
3444 - files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>,
3445 -): GraphQlDocument | null {
3446 - return aliasedGraphQlDocument({
3447 - operation: "mutation",
3448 - alias: "f",
3449 - items: files,
3450 - shared: { pullRequestId: ["ID!", pullRequestId] },
3451 - variables: (file) => ({ path: ["String!", file.path] }),
3452 - field: ({ path }, file) =>
3453 - `${file.viewed ? "markFileAsViewed" : "unmarkFileAsViewed"}(input: { pullRequestId: $pullRequestId, path: ${path} }) { clientMutationId }`,
3454 - });
1927 + nextCursor: nextCursorOf(files?.pageInfo),
1928 + };
1929 }
1930
1931 /** One pull request as the stacks API lists it: a number, a head, and whether it is done. */
packages/source-control-github/src/server/gitHubPullRequests.ts
+3 -2
@@ -80,7 +80,8 @@ function normalizeGitHubPullRequestState(input: {
80 return "open";
81 }
82
83 -function normalizeGitHubPullRequestRecord(
83 +/** A pull request row, in `gh --json` or GraphQL node shape, as every read reports it. */
84 +export function normalizeGitHubPullRequestRecord(
85 raw: Schema.Schema.Type<typeof GitHubPullRequestSchema>,
86 ): NormalizedGitHubPullRequestRecord {
87 const explicitNameWithOwner = trimOptionalString(raw.headRepository?.nameWithOwner);
@@ -122,7 +123,7 @@ const decodeGitHubPullRequestEntry = Schema.decodeUnknownExit(GitHubPullRequestS
123 * Pull request rows in `gh --json` or GraphQL node shape. A row that does not decode is
124 * skipped, so one malformed pull request cannot hide the rest.
125 */
125 -export function decodeGitHubPullRequestEntries(
126 +function decodeGitHubPullRequestEntries(
127 entries: ReadonlyArray<unknown>,
128 ): ReadonlyArray<NormalizedGitHubPullRequestRecord> {
129 const pullRequests: NormalizedGitHubPullRequestRecord[] = [];
packages/source-control-github/src/server/githubGraphQl.test.ts deleted
-105
@@ -1,105 +0,0 @@
1 -import { assert, describe, expect, it } from "@effect/vitest";
2 -import * as Effect from "effect/Effect";
3 -
4 -import { aliasedGraphQlDocument, readGraphQlPages } from "./githubGraphQl.ts";
5 -
6 -describe("aliasedGraphQlDocument", () => {
7 - it("keeps every value out of the document, each under its alias's own variable", () => {
8 - const document = aliasedGraphQlDocument({
9 - operation: "query",
10 - name: "Lookups",
11 - alias: "s",
12 - items: ['acme") { x } #', "web"],
13 - shared: { owner: ["String!", "acme"] },
14 - variables: (repo) => ({ name: ["String!", repo] }),
15 - field: ({ name }) => `repository(owner: $owner, name: ${name}) { id }`,
16 - });
17 - assert.isNotNull(document);
18 - expect(document!.query).toBe(
19 - "query Lookups($owner: String!, $s0_name: String!, $s1_name: String!) {\n" +
20 - " s0: repository(owner: $owner, name: $s0_name) { id }\n" +
21 - " s1: repository(owner: $owner, name: $s1_name) { id }\n}",
22 - );
23 - expect(document!.variables).toEqual({
24 - owner: "acme",
25 - s0_name: 'acme") { x } #',
26 - s1_name: "web",
27 - });
28 - });
29 -
30 - it("aliases by key and nests inside a shared parent when asked", () => {
31 - const document = aliasedGraphQlDocument({
32 - operation: "query",
33 - alias: "pr",
34 - key: (number) => number,
35 - items: [2, 3],
36 - variables: (number) => ({ number: ["Int!", number] }),
37 - field: ({ number }) => `pullRequest(number: ${number}) { id }`,
38 - within: (fields) => `repository(owner: "a", name: "b") {\n${fields}\n}`,
39 - });
40 - expect(document?.query).toContain(" pr2: pullRequest(number: $pr2_number) { id }");
41 - expect(document?.query).toContain(" pr3: pullRequest(number: $pr3_number) { id }");
42 - expect(document?.variables).toEqual({ pr2_number: 2, pr3_number: 3 });
43 - });
44 -
45 - it("asks for nothing when there is nothing to ask", () => {
46 - expect(
47 - aliasedGraphQlDocument({
48 - operation: "mutation",
49 - alias: "f",
50 - items: [],
51 - variables: () => ({}),
52 - field: () => "x",
53 - }),
54 - ).toBeNull();
55 - });
56 -});
57 -
58 -describe("readGraphQlPages", () => {
59 - const pages = (cursors: ReadonlyArray<string | null>) => {
60 - const asked: Array<string | null> = [];
61 - const read = (after: string | null) =>
62 - Effect.sync(() => {
63 - asked.push(after);
64 - return { next: cursors[asked.length - 1] ?? null };
65 - });
66 - return { asked, read };
67 - };
68 -
69 - it.effect("follows the cursor until GitHub has no more", () =>
70 - Effect.gen(function* () {
71 - const { asked, read } = pages(["a", "b", null]);
72 - const result = yield* readGraphQlPages(read, { nextCursor: (page) => page.next });
73 - expect(asked).toEqual([null, "a", "b"]);
74 - expect(result.truncated).toBe(false);
75 - }),
76 - );
77 -
78 - it.effect("stops as truncated at the page limit, at `until`, or on a repeated cursor", () =>
79 - Effect.gen(function* () {
80 - const limited = pages(["a", "b", "c"]);
81 - const atLimit = yield* readGraphQlPages(limited.read, {
82 - nextCursor: (page) => page.next,
83 - maxPages: 2,
84 - });
85 - expect(limited.asked).toEqual([null, "a"]);
86 - expect(atLimit.truncated).toBe(true);
87 -
88 - const enough = pages(["a", "b", "c"]);
89 - const satisfied = yield* readGraphQlPages(enough.read, {
90 - nextCursor: (page) => page.next,
91 - until: (read) => read.length === 1,
92 - });
93 - expect(enough.asked).toEqual([null]);
94 - expect(satisfied.truncated).toBe(true);
95 -
96 - const stuck = pages(["a", "a", "a"]);
97 - const repeated = yield* readGraphQlPages(stuck.read, {
98 - nextCursor: (page) => page.next,
99 - from: "start",
100 - });
101 - expect(stuck.asked).toEqual(["start", "a"]);
102 - expect(repeated.truncated).toBe(true);
103 - }),
104 - );
105 -});
packages/source-control-github/src/server/githubGraphQl.ts deleted
-100
@@ -1,100 +0,0 @@
1 -import * as Effect from "effect/Effect";
2 -
3 -/** GraphQL variables by name, each with the type it is declared as and the value it carries. */
4 -export type GraphQlVariables = Readonly<Record<string, readonly [type: string, value: unknown]>>;
5 -
6 -export interface GraphQlDocument {
7 - readonly query: string;
8 - readonly variables: Readonly<Record<string, unknown>>;
9 -}
10 -
11 -/**
12 - * One document asking the same field for many items, each under its own alias: the prefix and
13 - * the item's position (`s0`, `s1`, …), or its `key` when the answer is easier read by one. GitHub
14 - * has no bulk form of most lookups, so aliases are how a batch travels in one request.
15 - *
16 - * Every value travels as a variable renamed per alias (`$s0_owner`), and `field` is handed those
17 - * placeholders rather than the values: nothing an item holds is written into the document.
18 - * `shared` variables are declared once and referenced by their own name; `within` nests the aliased
19 - * fields inside one parent selection, such as a single repository.
20 - *
21 - * Null for no items, since a document with no selection is not a document.
22 - */
23 -export function aliasedGraphQlDocument<Item, Variables extends GraphQlVariables>(input: {
24 - readonly operation: "query" | "mutation";
25 - /** The operation's name, which tells one batch from another in logs and recorded traffic. */
26 - readonly name?: string;
27 - readonly alias: string;
28 - readonly key?: (item: Item, index: number) => number;
29 - readonly items: ReadonlyArray<Item>;
30 - readonly variables: (item: Item) => Variables;
31 - readonly field: (
32 - placeholders: { readonly [Name in keyof Variables]: string },
33 - item: Item,
34 - ) => string;
35 - readonly shared?: GraphQlVariables;
36 - readonly within?: (fields: string) => string;
37 -}): GraphQlDocument | null {
38 - if (input.items.length === 0) return null;
39 - const declarations: string[] = [];
40 - const variables: Record<string, unknown> = {};
41 - for (const [name, [type, value]] of Object.entries(input.shared ?? {})) {
42 - declarations.push(`$${name}: ${type}`);
43 - variables[name] = value;
44 - }
45 - const fields = input.items.map((item, index) => {
46 - const alias = `${input.alias}${input.key?.(item, index) ?? index}`;
47 - const placeholders: Record<string, string> = {};
48 - for (const [name, [type, value]] of Object.entries(input.variables(item))) {
49 - const variable = `${alias}_${name}`;
50 - declarations.push(`$${variable}: ${type}`);
51 - variables[variable] = value;
52 - placeholders[name] = `$${variable}`;
53 - }
54 - return ` ${alias}: ${input.field(placeholders as { readonly [Name in keyof Variables]: string }, item)}`;
55 - });
56 - const selection = fields.join("\n");
57 - const parameters = declarations.length === 0 ? "" : `(${declarations.join(", ")})`;
58 - return {
59 - query: `${input.operation}${input.name === undefined ? "" : ` ${input.name}`}${parameters} {\n${input.within?.(selection) ?? selection}\n}`,
60 - variables,
61 - };
62 -}
63 -
64 -/**
65 - * The pages of a GraphQL connection, read one after another from `from` (the first page by
66 - * default) until GitHub has no more, `until` is satisfied, or `maxPages` have been read. `read` is
67 - * handed the pages so far, for reads that size or check the next page by what has already arrived.
68 - *
69 - * `truncated` says pages remained when reading stopped. A cursor GitHub hands back a second time
70 - * would page forever, so it stops the read as truncated too.
71 - */
72 -export const readGraphQlPages = <Page, E, R>(
73 - read: (after: string | null, pages: ReadonlyArray<Page>) => Effect.Effect<Page, E, R>,
74 - options: {
75 - readonly nextCursor: (page: NoInfer<Page>) => string | null;
76 - readonly from?: string | null;
77 - readonly maxPages?: number;
78 - readonly until?: (pages: ReadonlyArray<NoInfer<Page>>) => boolean;
79 - },
80 -): Effect.Effect<{ readonly pages: ReadonlyArray<Page>; readonly truncated: boolean }, E, R> =>
81 - Effect.gen(function* () {
82 - const pages: Page[] = [];
83 - const seen = new Set<string>();
84 - let after = options.from ?? null;
85 - while (true) {
86 - const page: Page = yield* read(after, pages);
87 - pages.push(page);
88 - const next = options.nextCursor(page);
89 - if (next === null) return { pages, truncated: false };
90 - if (
91 - seen.has(next) ||
92 - pages.length >= (options.maxPages ?? Infinity) ||
93 - options.until?.(pages) === true
94 - ) {
95 - return { pages, truncated: true };
96 - }
97 - seen.add(next);
98 - after = next;
99 - }
100 - });
packages/source-control-github/src/server/githubStackActions.test.ts
+77 -59
@@ -6,20 +6,24 @@ import * as Schema from "effect/Schema";
6 import * as TestClock from "effect/testing/TestClock";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Redacted from "effect/Redacted";
9 +import { HttpClient, HttpClientResponse } from "effect/http";
10 import { ChildProcessSpawner } from "effect/process";
10 -import * as GitHubApi from "./GitHubApi.ts";
11 +import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
12 +import * as GitHubRest from "./GitHubRest.ts";
13 +import * as GitHubCredentials from "./GitHubCredentials.ts";
14 +import * as GitHubQuota from "./GitHubQuota.ts";
15 +import * as GitHubRequestPolicy from "./GitHubRequestPolicy.ts";
16 import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
17 import { runGitHubStackAction as runStackAction } from "./githubStackActions.ts";
18
19 /**
20 * One request as the fake saw it, flattened to words: the path or document, then each variable
21 * or body field as `name=value`, so an assertion reads as "this request carried that value".
22 + * A batched GraphQL request is one call, its variables carrying their alias prefixes.
23 */
24 type Call = ReadonlyArray<string>;
19 -type Send = (
20 - call: Call,
21 - kind: "graphql" | "rest",
22 -) => Effect.Effect<string, GitHubApi.GitHubApiError>;
25 +/** The next answer in the script: a REST body, or for GraphQL the `data` to answer with. */
26 +type Send = (call: Call, kind: "graphql" | "rest") => Effect.Effect<unknown>;
27
28 /** Every git command the cascade ran, in order; none actually runs. */
29 let gitCalls: Array<ReadonlyArray<string>> = [];
@@ -44,35 +48,62 @@ const fakeGit = Layer.mergeAll(
48 FileSystem.layerNoop({ makeTempDirectoryScoped: () => Effect.succeed("/tmp/scratch") }),
49 );
50
51 +/** GitHub's GraphQL endpoint, answering each request with the next scripted `data`. */
52 +const graphQlHttp = (send: Send) =>
53 + HttpClient.make((request) =>
54 + Effect.gen(function* () {
55 + const sent =
56 + request.body._tag === "Uint8Array"
57 + ? (JSON.parse(new TextDecoder().decode(request.body.body)) as {
58 + readonly query: string;
59 + readonly variables: Readonly<Record<string, unknown>>;
60 + })
61 + : { query: "", variables: {} };
62 + const data = yield* send(words(sent.query, sent.variables), "graphql");
63 + return HttpClientResponse.fromWeb(
64 + request,
65 + new Response(encodeJson({ data }), { headers: { "content-type": "application/json" } }),
66 + );
67 + }),
68 + );
69 +
70 const runGitHubStackAction = (send: Send, input: Parameters<typeof runStackAction>[0]) =>
71 runStackAction(input).pipe(
72 Effect.provide(
73 Layer.mergeAll(
74 fakeGit,
52 - Layer.mock(GitHubApi.GitHubApi)({
75 + Layer.mock(GitHubRest.GitHubRest)({
76 credential: () => Effect.succeed({ token: Redacted.make("token"), fingerprint: "fp" }),
54 - graphql: (request) => {
55 - // GitHub refuses a document that declares a variable it never uses.
56 - const declared = [...request.query.matchAll(/\$(\w+)\s*:/g)].map((match) => match[1]!);
57 - const unused = declared.filter(
58 - (name) => !new RegExp(`\\$${name}(?!\\w)(?!\\s*:)`).test(request.query),
59 - );
60 - if (unused.length > 0) {
61 - return Effect.die(new Error(`Variables declared but not used: ${unused.join(", ")}`));
62 - }
63 - return send(words(request.query, request.variables), "graphql");
64 - },
77 rest: (request) =>
78 send(words(request.path, request.body), "rest").pipe(
79 Effect.map((body) => ({
80 status: 200,
81 headers: {},
70 - body,
82 + body: encodeJson(body),
83 truncated: false,
84 invalidUtf8: false,
85 })),
86 ),
87 }),
88 + GitHubRequestPolicy.layer.pipe(
89 + Layer.provide(
90 + Layer.mergeAll(
91 + Layer.succeed(GitHubCredentials.GitHubCredentials, {
92 + get: (host) =>
93 + Effect.succeed({
94 + host,
95 + token: Redacted.make("token"),
96 + source: "gh" as const,
97 + fingerprint: "fp",
98 + }),
99 + invalidate: () => Effect.void,
100 + }),
101 + GitHubQuota.layer,
102 + SourceControlRateLimit.layer,
103 + ),
104 + ),
105 + ),
106 + Layer.succeed(HttpClient.HttpClient, graphQlHttp(send)),
107 ),
108 ),
109 );
@@ -126,14 +157,13 @@ const input = {
157 ],
158 action: "merge" as const,
159 };
129 -const access = {
130 - data: {
131 - repository: {
132 - pr2: { headRepository: { viewerPermission: "WRITE" }, maintainerCanModify: false },
133 - pr3: { headRepository: { viewerPermission: "WRITE" }, maintainerCanModify: false },
134 - },
135 - },
136 -};
160 +const writable = { headRepository: { viewerPermission: "WRITE" }, maintainerCanModify: false };
161 +/** One batched branch-access answer: each open layer's pull request, in stack order. */
162 +const accessOf = (...pullRequests: ReadonlyArray<unknown>) =>
163 + Object.fromEntries(
164 + pullRequests.map((pullRequest, index) => [`_${index}_repository`, { pullRequest }]),
165 + );
166 +const access = accessOf(writable, writable);
167
168 const branch = (number: number, headRefOid: string, behindBy = 1, processed: string[] = []) => ({
169 data: {
@@ -155,7 +185,7 @@ function fake(responses: readonly unknown[]) {
185 calls.push(call);
186 const value = responses[calls.length - 1];
187 if (value === undefined) throw new Error("Unexpected GitHub request");
158 - return encodeJson(value);
188 + return value;
189 });
190 return { execute, calls };
191 }
@@ -285,14 +315,10 @@ it.effect("refuses the entire rebase before mutation when a later fork denies wr
315 Effect.gen(function* () {
316 const api = fake([
317 stack,
288 - {
289 - data: {
290 - repository: {
291 - ...access.data.repository,
292 - pr3: { headRepository: { viewerPermission: "READ" }, maintainerCanModify: false },
293 - },
294 - },
295 - },
318 + accessOf(writable, {
319 + headRepository: { viewerPermission: "READ" },
320 + maintainerCanModify: false,
321 + }),
322 ]);
323 const result = yield* runGitHubStackAction(api.execute, {
324 ...input,
@@ -310,14 +336,10 @@ it.effect("allows a fork that explicitly permits maintainer updates", () =>
336 Effect.gen(function* () {
337 const api = fake([
338 stack,
313 - {
314 - data: {
315 - repository: {
316 - ...access.data.repository,
317 - pr3: { headRepository: { viewerPermission: "READ" }, maintainerCanModify: true },
318 - },
319 - },
320 - },
339 + accessOf(writable, {
340 + headRepository: { viewerPermission: "READ" },
341 + maintainerCanModify: true,
342 + }),
343 ...rebaseResponses,
344 ]);
345 yield* runGitHubStackAction(api.execute, { ...input, action: "update-branch" });
@@ -330,14 +352,10 @@ it.effect("rebases for a GitHub App, which GitHub gives no permission to read",
352 gitCalls = [];
353 const api = fake([
354 stack,
333 - {
334 - data: {
335 - repository: {
336 - pr2: { headRepository: { viewerPermission: null }, maintainerCanModify: false },
337 - pr3: { headRepository: { viewerPermission: null }, maintainerCanModify: false },
338 - },
339 - },
340 - },
355 + accessOf(
356 + { headRepository: { viewerPermission: null }, maintainerCanModify: false },
357 + { headRepository: { viewerPermission: null }, maintainerCanModify: false },
358 + ),
359 ...rebaseResponses,
360 ]);
361 yield* runGitHubStackAction(api.execute, { ...input, action: "update-branch" });
@@ -369,6 +387,10 @@ it.effect("rebases the open layers bottom to top in a scratch clone, each onto t
387 gitCalls = [];
388 const api = fake([stack, access]);
389 yield* runGitHubStackAction(api.execute, { ...input, action: "update-branch" });
390 + // Both layers' access is one aliased read, layer by layer in stack order.
391 + expect(api.calls[1]).toEqual(
392 + expect.arrayContaining(["_0_number=2", "_1_number=3", "_0_owner=acme", "_0_name=web"]),
393 + );
394 // GitHub is only read; every change is a git push with a lease on the reviewed head.
395 expect(api.calls.some(isMutation)).toBe(false);
396 const rebases = gitCalls.filter((args) => args[0] === "rebase");
@@ -400,14 +422,10 @@ it.effect("checks every layer's write access before any git runs", () =>
422 gitCalls = [];
423 const api = fake([
424 stack,
403 - {
404 - data: {
405 - repository: {
406 - ...access.data.repository,
407 - pr3: { headRepository: { viewerPermission: "READ" }, maintainerCanModify: false },
408 - },
409 - },
410 - },
425 + accessOf(writable, {
426 + headRepository: { viewerPermission: "READ" },
427 + maintainerCanModify: false,
428 + }),
429 ]);
430 yield* Effect.flip(runGitHubStackAction(api.execute, { ...input, action: "update-branch" }));
431 expect(gitCalls).toEqual([]);
packages/source-control-github/src/server/githubStackActions.ts
+30 -46
@@ -5,13 +5,16 @@ import type {
5 } from "@t3tools/contracts";
6 import * as Effect from "effect/Effect";
7 import * as Clock from "effect/Clock";
8 +import { GraphQLClient, GraphQLClientError, GraphQLResolver } from "effect/graphql";
9 +import * as RequestResolver from "effect/RequestResolver";
10 import * as Result from "effect/Result";
11 import * as Schema from "effect/Schema";
12
11 -import * as GitHubApi from "./GitHubApi.ts";
12 -import { aliasedGraphQlDocument } from "./githubGraphQl.ts";
13 +import * as GitHubRest from "./GitHubRest.ts";
14 +import * as GitHubGraphQlClient from "./gitHubGraphQlClient.ts";
15 import { decodePullRequestStacksJson, toCanWrite } from "./gitHubPullRequestJson.ts";
16 import { cascadeRebaseStack } from "./githubStackRebase.ts";
17 +import { StackActionsGraphQLGroup } from "./stackActions.graphql.ts";
18
19 const stackErrorIdentity = {
20 repository: Schema.String,
@@ -104,28 +107,6 @@ const MergeResponse = Schema.Struct({
107 }),
108 });
109
107 -const decodeBranchAccess = Schema.decodeEffect(
108 - Schema.fromJsonString(
109 - Schema.Struct({
110 - data: Schema.Struct({
111 - repository: Schema.NullOr(
112 - Schema.Record(
113 - Schema.String,
114 - Schema.NullOr(
115 - Schema.Struct({
116 - headRepository: Schema.NullOr(
117 - Schema.Struct({ viewerPermission: Schema.NullOr(Schema.String) }),
118 - ),
119 - maintainerCanModify: Schema.Boolean,
120 - }),
121 - ),
122 - ),
123 - ),
124 - }),
125 - }),
126 - ),
127 -);
128 -
110 const decodeMergeResponse = Schema.decodeEffect(Schema.fromJsonString(MergeResponse));
111
112 /** Remote-only updates: a stack rebase works in a scratch clone, never the environment's checkout. */
@@ -139,7 +120,7 @@ export const runGitHubStackAction = Effect.fn("runGitHubStackAction")(function*
120 action: PullRequestAction;
121 mergeMethod?: PullRequestMergeMethod;
122 }) {
142 - const api = yield* GitHubApi.GitHubApi;
123 + const api = yield* GitHubRest.GitHubRest;
124 const identity = {
125 repository: input.repository,
126 number: input.number,
@@ -189,31 +170,34 @@ export const runGitHubStackAction = Effect.fn("runGitHubStackAction")(function*
170 return yield* new GitHubStackUnsupportedError({ ...identity });
171 if (input.action === "update-branch") {
172 const [owner, name] = input.repository.split("/");
192 - const permissions = yield* api.graphql({
193 - host: input.host,
194 - operation: "runGitHubStackAction",
195 - allowReserve: true,
196 - // `open` is non-empty here, so there is always a document.
197 - ...aliasedGraphQlDocument({
198 - operation: "query",
199 - alias: "pr",
200 - key: (layer) => layer.number,
201 - items: open,
202 - shared: { owner: ["String!", owner], name: ["String!", name] },
203 - variables: (layer) => ({ number: ["Int!", layer.number] }),
204 - field: ({ number }) =>
205 - `pullRequest(number: ${number}) { headRepository { viewerPermission } maintainerCanModify }`,
206 - within: (fields) => `repository(owner: $owner, name: $name) {\n${fields}\n}`,
207 - })!,
208 - });
209 - const access = yield* decodeBranchAccess(permissions).pipe(
210 - Effect.mapError((cause) => new GitHubStackResponseInvalidError({ ...identity, cause })),
173 + const client = yield* GraphQLClient.make(
174 + StackActionsGraphQLGroup.middleware(GitHubGraphQlClient.GitHubGraphQlAuth),
175 + ).pipe(Effect.provide(GitHubGraphQlClient.layer));
176 + // One aliased request checks every layer; `open` is non-empty here.
177 + const resolver = GraphQLResolver.aliased(client.PullRequestBranchAccess, {
178 + batchKey: GitHubGraphQlClient.batchKey,
179 + }).pipe(RequestResolver.batchN(open.length));
180 + const access = yield* Effect.forEach(
181 + open,
182 + (layer) =>
183 + GraphQLResolver.request({ owner: owner!, name: name!, number: layer.number }, resolver),
184 + { concurrency: "unbounded" },
185 + ).pipe(
186 + GitHubGraphQlClient.call({
187 + host: input.host,
188 + operation: "runGitHubStackAction",
189 + allowReserve: true,
190 + }),
191 + Effect.catchIf(
192 + GraphQLClientError.isGraphQLClientError,
193 + (cause) => new GitHubStackResponseInvalidError({ ...identity, cause }),
194 + ),
195 );
196 // viewerCanUpdateBranch is false for an already-current layer, even if rebasing its parent
197 // will make it stale. Check branch write access separately before touching any layer.
198 if (
215 - open.some((layer) => {
216 - const pr = access.data.repository?.[`pr${layer.number}`];
199 + access.some(({ repository }) => {
200 + const pr = repository?.pullRequest;
201 return (
202 !pr?.headRepository ||
203 (!pr.maintainerCanModify && !toCanWrite(pr.headRepository.viewerPermission))
packages/source-control-github/src/server/githubStackRebase.ts
+2 -2
@@ -4,7 +4,7 @@ import * as Redacted from "effect/Redacted";
4 import * as Schema from "effect/Schema";
5 import * as Base64 from "effect/encoding/Base64";
6
7 -import * as GitHubApi from "./GitHubApi.ts";
7 +import * as GitHubRest from "./GitHubRest.ts";
8 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
9
10 /** One open layer of a stack, bottom to top, with the head the reader reviewed. */
@@ -57,7 +57,7 @@ export const cascadeRebaseStack = Effect.fn("cascadeRebaseStack")(function* (inp
57 /** Where to fetch and push; the repository's own URL on its host unless a test points elsewhere. */
58 readonly remote?: string;
59 }) {
60 - const api = yield* GitHubApi.GitHubApi;
60 + const api = yield* GitHubRest.GitHubRest;
61 const { process } = yield* SourceControlHost.SourceControlHost;
62 const fileSystem = yield* FileSystem.FileSystem;
63 const { token } = yield* api.credential(input.host);
packages/source-control-github/src/server/pullRequestBatches.graphql new
+128
@@ -0,0 +1,128 @@
1 +# One pull request per operation. `GraphQLResolver.aliased` repeats each under an alias per
2 +# pull request, so a batch is one request and a missing pull request fails only its own slice.
3 +# `stacks` is false off github.com: Enterprise Server has no pull request stacks.
4 +
5 +query PullRequestSummary($owner: String!, $name: String!, $number: Int!, $stacks: Boolean!) {
6 + repository(owner: $owner, name: $name) {
7 + pullRequest(number: $number) {
8 + number
9 + title
10 + url
11 + state
12 + isDraft
13 + mergeable
14 + reviewDecision
15 + additions
16 + deletions
17 + changedFiles
18 + updatedAt
19 + mergedAt
20 + closedAt
21 + headRefName
22 + baseRefName
23 + author {
24 + login
25 + avatarUrl
26 + ... on User {
27 + name
28 + }
29 + }
30 + latestReviews(first: 20) {
31 + nodes {
32 + state
33 + author {
34 + login
35 + }
36 + }
37 + }
38 + commits(last: 1) {
39 + nodes {
40 + commit {
41 + statusCheckRollup {
42 + state
43 + }
44 + }
45 + }
46 + }
47 + stack @include(if: $stacks) {
48 + number
49 + size
50 + baseRefName
51 + }
52 + stackEntry @include(if: $stacks) {
53 + position
54 + }
55 + }
56 + }
57 +}
58 +
59 +query PullRequestStats($owner: String!, $name: String!, $number: Int!) {
60 + repository(owner: $owner, name: $name) {
61 + pullRequest(number: $number) {
62 + additions
63 + deletions
64 + }
65 + }
66 +}
67 +
68 +query PullRequestStackMembership($owner: String!, $name: String!, $number: Int!) {
69 + repository(owner: $owner, name: $name) {
70 + pullRequest(number: $number) {
71 + stack {
72 + number
73 + size
74 + baseRefName
75 + }
76 + stackEntry {
77 + position
78 + }
79 + }
80 + }
81 +}
82 +
83 +# What a pull request watch needs to notice. Comments come most recently updated first, since an
84 +# edit moves `updatedAt`, so an edit to an old comment on a long pull request is still in the page.
85 +# Reviews have no such order: an edit to a review older than the last hundred waits for the
86 +# watch's periodic full read, as do edits to comments inside review threads.
87 +query PullRequestWatchFingerprint($owner: String!, $name: String!, $number: Int!) {
88 + repository(owner: $owner, name: $name) {
89 + pullRequest(number: $number) {
90 + state
91 + mergeable
92 + headRefOid
93 + comments(first: 100, orderBy: { field: UPDATED_AT, direction: DESC }) {
94 + totalCount
95 + nodes {
96 + lastEditedAt
97 + }
98 + }
99 + reviews(last: 100) {
100 + totalCount
101 + nodes {
102 + lastEditedAt
103 + }
104 + }
105 + reviewThreads {
106 + totalCount
107 + }
108 + commits(last: 1) {
109 + nodes {
110 + commit {
111 + statusCheckRollup {
112 + contexts {
113 + checkRunCountsByState {
114 + state
115 + count
116 + }
117 + statusContextCountsByState {
118 + state
119 + count
120 + }
121 + }
122 + }
123 + }
124 + }
125 + }
126 + }
127 + }
128 +}
packages/source-control-github/src/server/pullRequestBatches.graphql.ts new
+420
@@ -0,0 +1,420 @@
1 +// Generated by @effect/graphql-generator from pullRequestBatches.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
7 +export const User = Schema.Struct({
8 + __typename: Schema.Literal("User"),
9 + /** The username used to login. */
10 + login: Schema.String,
11 + /** A URL pointing to the user's public avatar. */
12 + avatarUrl: Shared.URI,
13 + /** The user's public profile name. */
14 + name: Schema.NullOr(Schema.String)
15 +})
16 +export interface User extends Schema.Struct.Type<typeof User.fields> {}
17 +
18 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
19 +export const ActorOther = Schema.Struct({
20 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()(["User"]),
21 + /** The username of the actor. */
22 + login: Schema.String,
23 + /** A URL pointing to the actor's public avatar. */
24 + avatarUrl: Shared.URI
25 +})
26 +export interface ActorOther extends Schema.Struct.Type<typeof ActorOther.fields> {}
27 +
28 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
29 +export const Actor = Schema.Struct({
30 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()([]),
31 + /** The username of the actor. */
32 + login: Schema.String
33 +})
34 +export interface Actor extends Schema.Struct.Type<typeof Actor.fields> {}
35 +
36 +/** A review object for a given pull request. */
37 +export const LatestReviewsNodesPullRequestReview = Schema.Struct({
38 + /** Identifies the current state of the pull request review. */
39 + state: GraphQL.enumLiterals(Shared.PullRequestReviewState.literals),
40 + /** The actor who authored the comment. */
41 + author: Schema.NullOr(Actor)
42 +})
43 +export interface LatestReviewsNodesPullRequestReview extends Schema.Struct.Type<typeof LatestReviewsNodesPullRequestReview.fields> {}
44 +
45 +/** The connection type for PullRequestReview. */
46 +export const LatestReviewsPullRequestReviewConnection = Schema.Struct({
47 + /** A list of nodes. */
48 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(LatestReviewsNodesPullRequestReview)))
49 +})
50 +export interface LatestReviewsPullRequestReviewConnection extends Schema.Struct.Type<typeof LatestReviewsPullRequestReviewConnection.fields> {}
51 +
52 +/** Represents the rollup for both the check runs and status for a commit. */
53 +export const PullRequestSummaryRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup = Schema.Struct({
54 + /** The combined status for the commit. */
55 + state: GraphQL.enumLiterals(Shared.StatusState.literals)
56 +})
57 +export interface PullRequestSummaryRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup.fields> {}
58 +
59 +/** Represents a Git commit. */
60 +export const PullRequestSummaryRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
61 + /** Check and Status rollup information for this commit. */
62 + statusCheckRollup: Schema.NullOr(PullRequestSummaryRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup)
63 +})
64 +export interface PullRequestSummaryRepositoryPullRequestCommitsNodesCommitCommit extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryPullRequestCommitsNodesCommitCommit.fields> {}
65 +
66 +/** Represents a Git commit part of a pull request. */
67 +export const PullRequestSummaryRepositoryPullRequestCommitsNodesPullRequestCommit = Schema.Struct({
68 + /** The Git commit object */
69 + commit: PullRequestSummaryRepositoryPullRequestCommitsNodesCommitCommit
70 +})
71 +export interface PullRequestSummaryRepositoryPullRequestCommitsNodesPullRequestCommit extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryPullRequestCommitsNodesPullRequestCommit.fields> {}
72 +
73 +/** The connection type for PullRequestCommit. */
74 +export const PullRequestSummaryRepositoryPullRequestCommitsPullRequestCommitConnection = Schema.Struct({
75 + /** A list of nodes. */
76 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestSummaryRepositoryPullRequestCommitsNodesPullRequestCommit)))
77 +})
78 +export interface PullRequestSummaryRepositoryPullRequestCommitsPullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryPullRequestCommitsPullRequestCommitConnection.fields> {}
79 +
80 +/** A stack of PullRequests */
81 +export const PullRequestStack = Schema.Struct({
82 + /** A number uniquely identifying the stack within its repository */
83 + number: Shared.Int,
84 + /** The total number of pull requests in the stack */
85 + size: Shared.Int,
86 + /** The branch that the stack's pull requests target */
87 + baseRefName: Schema.String
88 +})
89 +export interface PullRequestStack extends Schema.Struct.Type<typeof PullRequestStack.fields> {}
90 +
91 +/** A member of a PullRequestStack */
92 +export const PullRequestStackEntry = Schema.Struct({
93 + /** This entry's position in the stack, where 1 is the closest to the base branch, 2 is stacked on top of 1, etc. */
94 + position: Shared.Int
95 +})
96 +export interface PullRequestStackEntry extends Schema.Struct.Type<typeof PullRequestStackEntry.fields> {}
97 +
98 +/** A repository pull request. */
99 +export const PullRequestSummaryRepositoryPullRequestPullRequest = Schema.Struct({
100 + /** Identifies the pull request number. */
101 + number: Shared.Int,
102 + /** Identifies the pull request title. */
103 + title: Schema.String,
104 + /** The HTTP URL for this pull request. */
105 + url: Shared.URI,
106 + /** Identifies the state of the pull request. */
107 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
108 + /** Identifies if the pull request is a draft. */
109 + isDraft: Schema.Boolean,
110 + /** Whether or not the pull request can be merged based on the existence of merge conflicts. */
111 + mergeable: GraphQL.enumLiterals(Shared.MergeableState.literals),
112 + /** The current status of this pull request with respect to code review. */
113 + reviewDecision: Schema.NullOr(GraphQL.enumLiterals(Shared.PullRequestReviewDecision.literals)),
114 + /** The number of additions in this pull request. */
115 + additions: Shared.Int,
116 + /** The number of deletions in this pull request. */
117 + deletions: Shared.Int,
118 + /** The number of changed files in this pull request. */
119 + changedFiles: Shared.Int,
120 + /** Identifies the date and time when the object was last updated. */
121 + updatedAt: Shared.DateTime,
122 + /** The date and time that the pull request was merged. */
123 + mergedAt: Schema.NullOr(Shared.DateTime),
124 + /** Identifies the date and time when the object was closed. */
125 + closedAt: Schema.NullOr(Shared.DateTime),
126 + /** Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. */
127 + headRefName: Schema.String,
128 + /** Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. */
129 + baseRefName: Schema.String,
130 + /** The actor who authored the comment. */
131 + author: Schema.NullOr(Schema.Union([
132 + User,
133 + ActorOther
134 + ])),
135 + /** A list of latest reviews per user associated with the pull request that are not also pending review. */
136 + latestReviews: Schema.NullOr(LatestReviewsPullRequestReviewConnection),
137 + /** A list of commits present in this pull request's head branch not present in the base branch. */
138 + commits: PullRequestSummaryRepositoryPullRequestCommitsPullRequestCommitConnection,
139 + /** The stack this Pull Request belongs to, or null if it is not part of a stack */
140 + stack: Schema.optionalKey(Schema.NullOr(PullRequestStack)),
141 + /** The stack entry for this Pull Request, or null if it is not part of a stack */
142 + stackEntry: Schema.optionalKey(Schema.NullOr(PullRequestStackEntry))
143 +})
144 +export interface PullRequestSummaryRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryPullRequestPullRequest.fields> {}
145 +
146 +/** A repository contains the content for a project. */
147 +export const PullRequestSummaryRepositoryRepository = Schema.Struct({
148 + /** Returns a single pull request from the current repository by number. */
149 + pullRequest: Schema.NullOr(PullRequestSummaryRepositoryPullRequestPullRequest)
150 +})
151 +export interface PullRequestSummaryRepositoryRepository extends Schema.Struct.Type<typeof PullRequestSummaryRepositoryRepository.fields> {}
152 +
153 +/** `query PullRequestSummary` */
154 +export const PullRequestSummary = GraphQL.query("PullRequestSummary", {
155 + document: {
156 + variables: [
157 + { name: "owner", body: "String!" },
158 + { name: "name", body: "String!" },
159 + { name: "number", body: "Int!" },
160 + { name: "stacks", body: "Boolean!" }
161 + ],
162 + selections: [
163 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){number title url state isDraft mergeable reviewDecision additions deletions changedFiles updatedAt mergedAt closedAt headRefName baseRefName author{__typename login avatarUrl...on User{name}}latestReviews(first:20){nodes{state author{__typename login}}}commits(last:1){nodes{commit{statusCheckRollup{state}}}}stack@include(if:$", "stacks", "){number size baseRefName}stackEntry@include(if:$", "stacks", "){position}}}"] }
164 + ],
165 + fragments: []
166 + },
167 + variables: {
168 + owner: Schema.String,
169 + name: Schema.String,
170 + number: Shared.Int,
171 + stacks: Schema.Boolean
172 + },
173 + result: Schema.Struct({
174 + /** Lookup a given repository by the owner and repository name. */
175 + repository: Schema.NullOr(PullRequestSummaryRepositoryRepository)
176 + })
177 +})
178 +export declare namespace PullRequestSummary {
179 + export type Variables = typeof PullRequestSummary.variables.Type
180 + export type Result = typeof PullRequestSummary.result.Type
181 +}
182 +
183 +/** A repository pull request. */
184 +export const PullRequestStatsRepositoryPullRequestPullRequest = Schema.Struct({
185 + /** The number of additions in this pull request. */
186 + additions: Shared.Int,
187 + /** The number of deletions in this pull request. */
188 + deletions: Shared.Int
189 +})
190 +export interface PullRequestStatsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestStatsRepositoryPullRequestPullRequest.fields> {}
191 +
192 +/** A repository contains the content for a project. */
193 +export const PullRequestStatsRepositoryRepository = Schema.Struct({
194 + /** Returns a single pull request from the current repository by number. */
195 + pullRequest: Schema.NullOr(PullRequestStatsRepositoryPullRequestPullRequest)
196 +})
197 +export interface PullRequestStatsRepositoryRepository extends Schema.Struct.Type<typeof PullRequestStatsRepositoryRepository.fields> {}
198 +
199 +/** `query PullRequestStats` */
200 +export const PullRequestStats = GraphQL.query("PullRequestStats", {
201 + document: {
202 + variables: [
203 + { name: "owner", body: "String!" },
204 + { name: "name", body: "String!" },
205 + { name: "number", body: "Int!" }
206 + ],
207 + selections: [
208 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){additions deletions}}"] }
209 + ],
210 + fragments: []
211 + },
212 + variables: {
213 + owner: Schema.String,
214 + name: Schema.String,
215 + number: Shared.Int
216 + },
217 + result: Schema.Struct({
218 + /** Lookup a given repository by the owner and repository name. */
219 + repository: Schema.NullOr(PullRequestStatsRepositoryRepository)
220 + })
221 +})
222 +export declare namespace PullRequestStats {
223 + export type Variables = typeof PullRequestStats.variables.Type
224 + export type Result = typeof PullRequestStats.result.Type
225 +}
226 +
227 +/** A repository pull request. */
228 +export const PullRequestStackMembershipRepositoryPullRequestPullRequest = Schema.Struct({
229 + /** The stack this Pull Request belongs to, or null if it is not part of a stack */
230 + stack: Schema.NullOr(PullRequestStack),
231 + /** The stack entry for this Pull Request, or null if it is not part of a stack */
232 + stackEntry: Schema.NullOr(PullRequestStackEntry)
233 +})
234 +export interface PullRequestStackMembershipRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestStackMembershipRepositoryPullRequestPullRequest.fields> {}
235 +
236 +/** A repository contains the content for a project. */
237 +export const PullRequestStackMembershipRepositoryRepository = Schema.Struct({
238 + /** Returns a single pull request from the current repository by number. */
239 + pullRequest: Schema.NullOr(PullRequestStackMembershipRepositoryPullRequestPullRequest)
240 +})
241 +export interface PullRequestStackMembershipRepositoryRepository extends Schema.Struct.Type<typeof PullRequestStackMembershipRepositoryRepository.fields> {}
242 +
243 +/** `query PullRequestStackMembership` */
244 +export const PullRequestStackMembership = GraphQL.query("PullRequestStackMembership", {
245 + document: {
246 + variables: [
247 + { name: "owner", body: "String!" },
248 + { name: "name", body: "String!" },
249 + { name: "number", body: "Int!" }
250 + ],
251 + selections: [
252 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){stack{number size baseRefName}stackEntry{position}}}"] }
253 + ],
254 + fragments: []
255 + },
256 + variables: {
257 + owner: Schema.String,
258 + name: Schema.String,
259 + number: Shared.Int
260 + },
261 + result: Schema.Struct({
262 + /** Lookup a given repository by the owner and repository name. */
263 + repository: Schema.NullOr(PullRequestStackMembershipRepositoryRepository)
264 + })
265 +})
266 +export declare namespace PullRequestStackMembership {
267 + export type Variables = typeof PullRequestStackMembership.variables.Type
268 + export type Result = typeof PullRequestStackMembership.result.Type
269 +}
270 +
271 +/** Represents a comment on an Issue. */
272 +export const IssueComment = Schema.Struct({
273 + /** The moment the editor made the last edit */
274 + lastEditedAt: Schema.NullOr(Shared.DateTime)
275 +})
276 +export interface IssueComment extends Schema.Struct.Type<typeof IssueComment.fields> {}
277 +
278 +/** The connection type for IssueComment. */
279 +export const IssueCommentConnection = Schema.Struct({
280 + /** Identifies the total count of items in the connection. */
281 + totalCount: Shared.Int,
282 + /** A list of nodes. */
283 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(IssueComment)))
284 +})
285 +export interface IssueCommentConnection extends Schema.Struct.Type<typeof IssueCommentConnection.fields> {}
286 +
287 +/** A review object for a given pull request. */
288 +export const ReviewsNodesPullRequestReview = Schema.Struct({
289 + /** The moment the editor made the last edit */
290 + lastEditedAt: Schema.NullOr(Shared.DateTime)
291 +})
292 +export interface ReviewsNodesPullRequestReview extends Schema.Struct.Type<typeof ReviewsNodesPullRequestReview.fields> {}
293 +
294 +/** The connection type for PullRequestReview. */
295 +export const ReviewsPullRequestReviewConnection = Schema.Struct({
296 + /** Identifies the total count of items in the connection. */
297 + totalCount: Shared.Int,
298 + /** A list of nodes. */
299 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ReviewsNodesPullRequestReview)))
300 +})
301 +export interface ReviewsPullRequestReviewConnection extends Schema.Struct.Type<typeof ReviewsPullRequestReviewConnection.fields> {}
302 +
303 +/** Review comment threads for a pull request review. */
304 +export const PullRequestReviewThreadConnection = Schema.Struct({
305 + /** Identifies the total count of items in the connection. */
306 + totalCount: Shared.Int
307 +})
308 +export interface PullRequestReviewThreadConnection extends Schema.Struct.Type<typeof PullRequestReviewThreadConnection.fields> {}
309 +
310 +/** Represents a count of the state of a check run. */
311 +export const CheckRunStateCount = Schema.Struct({
312 + /** The state of a check run. */
313 + state: GraphQL.enumLiterals(Shared.CheckRunState.literals),
314 + /** The number of check runs with this state. */
315 + count: Shared.Int
316 +})
317 +export interface CheckRunStateCount extends Schema.Struct.Type<typeof CheckRunStateCount.fields> {}
318 +
319 +/** Represents a count of the state of a status context. */
320 +export const StatusContextStateCount = Schema.Struct({
321 + /** The state of a status context. */
322 + state: GraphQL.enumLiterals(Shared.StatusState.literals),
323 + /** The number of statuses with this state. */
324 + count: Shared.Int
325 +})
326 +export interface StatusContextStateCount extends Schema.Struct.Type<typeof StatusContextStateCount.fields> {}
327 +
328 +/** The connection type for StatusCheckRollupContext. */
329 +export const StatusCheckRollupContextConnection = Schema.Struct({
330 + /** Counts of check runs by state. */
331 + checkRunCountsByState: Schema.NullOr(Schema.Array(CheckRunStateCount)),
332 + /** Counts of status contexts by state. */
333 + statusContextCountsByState: Schema.NullOr(Schema.Array(StatusContextStateCount))
334 +})
335 +export interface StatusCheckRollupContextConnection extends Schema.Struct.Type<typeof StatusCheckRollupContextConnection.fields> {}
336 +
337 +/** Represents the rollup for both the check runs and status for a commit. */
338 +export const PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup = Schema.Struct({
339 + /** A list of status contexts and check runs for this commit. */
340 + contexts: StatusCheckRollupContextConnection
341 +})
342 +export interface PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup.fields> {}
343 +
344 +/** Represents a Git commit. */
345 +export const PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
346 + /** Check and Status rollup information for this commit. */
347 + statusCheckRollup: Schema.NullOr(PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup)
348 +})
349 +export interface PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitCommit extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitCommit.fields> {}
350 +
351 +/** Represents a Git commit part of a pull request. */
352 +export const PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesPullRequestCommit = Schema.Struct({
353 + /** The Git commit object */
354 + commit: PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesCommitCommit
355 +})
356 +export interface PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesPullRequestCommit extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesPullRequestCommit.fields> {}
357 +
358 +/** The connection type for PullRequestCommit. */
359 +export const PullRequestWatchFingerprintRepositoryPullRequestCommitsPullRequestCommitConnection = Schema.Struct({
360 + /** A list of nodes. */
361 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestWatchFingerprintRepositoryPullRequestCommitsNodesPullRequestCommit)))
362 +})
363 +export interface PullRequestWatchFingerprintRepositoryPullRequestCommitsPullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryPullRequestCommitsPullRequestCommitConnection.fields> {}
364 +
365 +/** A repository pull request. */
366 +export const PullRequestWatchFingerprintRepositoryPullRequestPullRequest = Schema.Struct({
367 + /** Identifies the state of the pull request. */
368 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
369 + /** Whether or not the pull request can be merged based on the existence of merge conflicts. */
370 + mergeable: GraphQL.enumLiterals(Shared.MergeableState.literals),
371 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
372 + headRefOid: Shared.GitObjectID,
373 + /** A list of comments associated with the pull request. */
374 + comments: IssueCommentConnection,
375 + /** A list of reviews associated with the pull request. */
376 + reviews: Schema.NullOr(ReviewsPullRequestReviewConnection),
377 + /** The list of all review threads for this pull request. */
378 + reviewThreads: PullRequestReviewThreadConnection,
379 + /** A list of commits present in this pull request's head branch not present in the base branch. */
380 + commits: PullRequestWatchFingerprintRepositoryPullRequestCommitsPullRequestCommitConnection
381 +})
382 +export interface PullRequestWatchFingerprintRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryPullRequestPullRequest.fields> {}
383 +
384 +/** A repository contains the content for a project. */
385 +export const PullRequestWatchFingerprintRepositoryRepository = Schema.Struct({
386 + /** Returns a single pull request from the current repository by number. */
387 + pullRequest: Schema.NullOr(PullRequestWatchFingerprintRepositoryPullRequestPullRequest)
388 +})
389 +export interface PullRequestWatchFingerprintRepositoryRepository extends Schema.Struct.Type<typeof PullRequestWatchFingerprintRepositoryRepository.fields> {}
390 +
391 +/** `query PullRequestWatchFingerprint` */
392 +export const PullRequestWatchFingerprint = GraphQL.query("PullRequestWatchFingerprint", {
393 + document: {
394 + variables: [
395 + { name: "owner", body: "String!" },
396 + { name: "name", body: "String!" },
397 + { name: "number", body: "Int!" }
398 + ],
399 + selections: [
400 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){state mergeable headRefOid comments(first:100 orderBy:{field:UPDATED_AT direction:DESC}){totalCount nodes{lastEditedAt}}reviews(last:100){totalCount nodes{lastEditedAt}}reviewThreads{totalCount}commits(last:1){nodes{commit{statusCheckRollup{contexts{checkRunCountsByState{state count}statusContextCountsByState{state count}}}}}}}}"] }
401 + ],
402 + fragments: []
403 + },
404 + variables: {
405 + owner: Schema.String,
406 + name: Schema.String,
407 + number: Shared.Int
408 + },
409 + result: Schema.Struct({
410 + /** Lookup a given repository by the owner and repository name. */
411 + repository: Schema.NullOr(PullRequestWatchFingerprintRepositoryRepository)
412 + })
413 +})
414 +export declare namespace PullRequestWatchFingerprint {
415 + export type Variables = typeof PullRequestWatchFingerprint.variables.Type
416 + export type Result = typeof PullRequestWatchFingerprint.result.Type
417 +}
418 +
419 +/** Every operation in pullRequestBatches.graphql. */
420 +export const PullRequestBatchesGraphQLGroup = GraphQLGroup.make(PullRequestSummary, PullRequestStats, PullRequestStackMembership, PullRequestWatchFingerprint)
packages/source-control-github/src/server/pullRequestListings.graphql new
+132
@@ -0,0 +1,132 @@
1 +# Listings: a search across one or more repositories, and a repository's own list for one GitHub's
2 +# search index does not cover. Both answer with the same row.
3 +
4 +# One listing row. `first` on the inner connections is a bound rather than a page: a pull request
5 +# with more than twenty labels shows twenty, and one that has asked more than twenty people for a
6 +# review is already past what a row can say.
7 +#
8 +# `additions` and `deletions` are asked for only with `$stats`: measured over twelve repositories
9 +# at a hundred rows, a search answers in ~4.0s without them and ~7.1s with them, for two numbers at
10 +# the end of a row. The cross-repository search reads them afterwards, in `PullRequestStats`.
11 +# `stack` and `stackEntry` exist on github.com only (`$stacks`).
12 +fragment PullRequestRow on PullRequest {
13 + stack @include(if: $stacks) {
14 + number
15 + size
16 + baseRefName
17 + }
18 + stackEntry @include(if: $stacks) {
19 + position
20 + }
21 + number
22 + title
23 + url
24 + author {
25 + login
26 + avatarUrl
27 + ... on User {
28 + name
29 + }
30 + }
31 + headRefName
32 + baseRefName
33 + state
34 + isDraft
35 + mergeable
36 + reviewDecision
37 + latestReviews(first: 20) {
38 + nodes {
39 + state
40 + author {
41 + login
42 + }
43 + }
44 + }
45 + additions @include(if: $stats)
46 + deletions @include(if: $stats)
47 + createdAt
48 + updatedAt
49 + mergedAt
50 + repository {
51 + nameWithOwner
52 + }
53 + reviewRequests(first: 20) {
54 + nodes {
55 + requestedReviewer {
56 + ... on User {
57 + login
58 + }
59 + ... on Team {
60 + slug
61 + }
62 + }
63 + }
64 + }
65 + labels(first: 20) {
66 + nodes {
67 + name
68 + color
69 + }
70 + }
71 + # GitHub's rollup for the head commit, one enum, rather than the whole check list: measured at a
72 + # hundred rows, 0.8s -> 3.0s and 15 KB, against 425 KB for the same verdict as a check array.
73 + commits(last: 1) {
74 + nodes {
75 + commit {
76 + statusCheckRollup {
77 + state
78 + }
79 + }
80 + }
81 + }
82 +}
83 +
84 +# Every repository of a host in one read, which is what makes a listing one request rather than
85 +# one per repository. `$first` is at most 100: `search` refuses anything larger with
86 +# EXCESSIVE_PAGINATION.
87 +query PullRequestSearch(
88 + $q: String!
89 + $first: Int!
90 + $after: String
91 + $stacks: Boolean!
92 + $stats: Boolean!
93 +) {
94 + search(query: $q, type: ISSUE, first: $first, after: $after) {
95 + pageInfo {
96 + hasNextPage
97 + endCursor
98 + }
99 + nodes {
100 + ...PullRequestRow
101 + }
102 + }
103 +}
104 +
105 +# A repository's pull requests without search, newest created first: the order `gh pr list` lists
106 +# in when it does not search, for a repository GitHub's search index does not cover.
107 +query PullRequestList(
108 + $owner: String!
109 + $name: String!
110 + $states: [PullRequestState!]
111 + $first: Int!
112 + $after: String
113 + $stacks: Boolean!
114 + $stats: Boolean!
115 +) {
116 + repository(owner: $owner, name: $name) {
117 + pullRequests(
118 + first: $first
119 + after: $after
120 + states: $states
121 + orderBy: { field: CREATED_AT, direction: DESC }
122 + ) {
123 + pageInfo {
124 + hasNextPage
125 + endCursor
126 + }
127 + nodes {
128 + ...PullRequestRow
129 + }
130 + }
131 + }
132 +}
packages/source-control-github/src/server/pullRequestListings.graphql.ts new
+344
@@ -0,0 +1,344 @@
1 +// Generated by @effect/graphql-generator from pullRequestListings.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A stack of PullRequests */
7 +export const PullRequestStack = Schema.Struct({
8 + /** A number uniquely identifying the stack within its repository */
9 + number: Shared.Int,
10 + /** The total number of pull requests in the stack */
11 + size: Shared.Int,
12 + /** The branch that the stack's pull requests target */
13 + baseRefName: Schema.String
14 +})
15 +export interface PullRequestStack extends Schema.Struct.Type<typeof PullRequestStack.fields> {}
16 +
17 +/** A member of a PullRequestStack */
18 +export const PullRequestStackEntry = Schema.Struct({
19 + /** This entry's position in the stack, where 1 is the closest to the base branch, 2 is stacked on top of 1, etc. */
20 + position: Shared.Int
21 +})
22 +export interface PullRequestStackEntry extends Schema.Struct.Type<typeof PullRequestStackEntry.fields> {}
23 +
24 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
25 +export const AuthorUser = Schema.Struct({
26 + __typename: Schema.Literal("User"),
27 + /** The username used to login. */
28 + login: Schema.String,
29 + /** A URL pointing to the user's public avatar. */
30 + avatarUrl: Shared.URI,
31 + /** The user's public profile name. */
32 + name: Schema.NullOr(Schema.String)
33 +})
34 +export interface AuthorUser extends Schema.Struct.Type<typeof AuthorUser.fields> {}
35 +
36 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
37 +export const ActorOther = Schema.Struct({
38 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()(["User"]),
39 + /** The username of the actor. */
40 + login: Schema.String,
41 + /** A URL pointing to the actor's public avatar. */
42 + avatarUrl: Shared.URI
43 +})
44 +export interface ActorOther extends Schema.Struct.Type<typeof ActorOther.fields> {}
45 +
46 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
47 +export const Actor = Schema.Struct({
48 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()([]),
49 + /** The username of the actor. */
50 + login: Schema.String
51 +})
52 +export interface Actor extends Schema.Struct.Type<typeof Actor.fields> {}
53 +
54 +/** A review object for a given pull request. */
55 +export const PullRequestReview = Schema.Struct({
56 + /** Identifies the current state of the pull request review. */
57 + state: GraphQL.enumLiterals(Shared.PullRequestReviewState.literals),
58 + /** The actor who authored the comment. */
59 + author: Schema.NullOr(Actor)
60 +})
61 +export interface PullRequestReview extends Schema.Struct.Type<typeof PullRequestReview.fields> {}
62 +
63 +/** The connection type for PullRequestReview. */
64 +export const PullRequestReviewConnection = Schema.Struct({
65 + /** A list of nodes. */
66 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestReview)))
67 +})
68 +export interface PullRequestReviewConnection extends Schema.Struct.Type<typeof PullRequestReviewConnection.fields> {}
69 +
70 +/** A repository contains the content for a project. */
71 +export const PullRequestRowRepositoryRepository = Schema.Struct({
72 + /** The repository's name with owner. */
73 + nameWithOwner: Schema.String
74 +})
75 +export interface PullRequestRowRepositoryRepository extends Schema.Struct.Type<typeof PullRequestRowRepositoryRepository.fields> {}
76 +
77 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
78 +export const RequestedReviewerUser = Schema.Struct({
79 + __typename: Schema.Literal("User"),
80 + /** The username used to login. */
81 + login: Schema.String
82 +})
83 +export interface RequestedReviewerUser extends Schema.Struct.Type<typeof RequestedReviewerUser.fields> {}
84 +
85 +/** A team of users in an organization. */
86 +export const Team = Schema.Struct({
87 + __typename: Schema.Literal("Team"),
88 + /** The slug corresponding to the team. */
89 + slug: Schema.String
90 +})
91 +export interface Team extends Schema.Struct.Type<typeof Team.fields> {}
92 +
93 +/** Types that can be requested reviewers. */
94 +export const RequestedReviewerOther = Schema.Struct({
95 + __typename: GraphQL.otherTypename<Shared.Typename.RequestedReviewer>()(["User", "Team"])
96 +})
97 +export interface RequestedReviewerOther extends Schema.Struct.Type<typeof RequestedReviewerOther.fields> {}
98 +
99 +/** A request for a user to review a pull request. */
100 +export const ReviewRequest = Schema.Struct({
101 + /** The reviewer that is requested. */
102 + requestedReviewer: Schema.NullOr(Schema.Union([
103 + RequestedReviewerUser,
104 + Team,
105 + RequestedReviewerOther
106 + ]))
107 +})
108 +export interface ReviewRequest extends Schema.Struct.Type<typeof ReviewRequest.fields> {}
109 +
110 +/** The connection type for ReviewRequest. */
111 +export const ReviewRequestConnection = Schema.Struct({
112 + /** A list of nodes. */
113 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ReviewRequest)))
114 +})
115 +export interface ReviewRequestConnection extends Schema.Struct.Type<typeof ReviewRequestConnection.fields> {}
116 +
117 +/** A label for categorizing Issues, Pull Requests, Milestones, or Discussions with a given Repository. */
118 +export const Label = Schema.Struct({
119 + /** Identifies the label name. */
120 + name: Schema.String,
121 + /** Identifies the label color. */
122 + color: Schema.String
123 +})
124 +export interface Label extends Schema.Struct.Type<typeof Label.fields> {}
125 +
126 +/** The connection type for Label. */
127 +export const LabelConnection = Schema.Struct({
128 + /** A list of nodes. */
129 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Label)))
130 +})
131 +export interface LabelConnection extends Schema.Struct.Type<typeof LabelConnection.fields> {}
132 +
133 +/** Represents the rollup for both the check runs and status for a commit. */
134 +export const StatusCheckRollup = Schema.Struct({
135 + /** The combined status for the commit. */
136 + state: GraphQL.enumLiterals(Shared.StatusState.literals)
137 +})
138 +export interface StatusCheckRollup extends Schema.Struct.Type<typeof StatusCheckRollup.fields> {}
139 +
140 +/** Represents a Git commit. */
141 +export const Commit = Schema.Struct({
142 + /** Check and Status rollup information for this commit. */
143 + statusCheckRollup: Schema.NullOr(StatusCheckRollup)
144 +})
145 +export interface Commit extends Schema.Struct.Type<typeof Commit.fields> {}
146 +
147 +/** Represents a Git commit part of a pull request. */
148 +export const PullRequestCommit = Schema.Struct({
149 + /** The Git commit object */
150 + commit: Commit
151 +})
152 +export interface PullRequestCommit extends Schema.Struct.Type<typeof PullRequestCommit.fields> {}
153 +
154 +/** The connection type for PullRequestCommit. */
155 +export const PullRequestCommitConnection = Schema.Struct({
156 + /** A list of nodes. */
157 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCommit)))
158 +})
159 +export interface PullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestCommitConnection.fields> {}
160 +
161 +/**
162 + * `fragment PullRequestRow on PullRequest`
163 + *
164 + * A repository pull request.
165 + */
166 +export const PullRequestRow = Schema.Struct({
167 + /** The stack this Pull Request belongs to, or null if it is not part of a stack */
168 + stack: Schema.optionalKey(Schema.NullOr(PullRequestStack)),
169 + /** The stack entry for this Pull Request, or null if it is not part of a stack */
170 + stackEntry: Schema.optionalKey(Schema.NullOr(PullRequestStackEntry)),
171 + /** Identifies the pull request number. */
172 + number: Shared.Int,
173 + /** Identifies the pull request title. */
174 + title: Schema.String,
175 + /** The HTTP URL for this pull request. */
176 + url: Shared.URI,
177 + /** The actor who authored the comment. */
178 + author: Schema.NullOr(Schema.Union([
179 + AuthorUser,
180 + ActorOther
181 + ])),
182 + /** Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. */
183 + headRefName: Schema.String,
184 + /** Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. */
185 + baseRefName: Schema.String,
186 + /** Identifies the state of the pull request. */
187 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
188 + /** Identifies if the pull request is a draft. */
189 + isDraft: Schema.Boolean,
190 + /** Whether or not the pull request can be merged based on the existence of merge conflicts. */
191 + mergeable: GraphQL.enumLiterals(Shared.MergeableState.literals),
192 + /** The current status of this pull request with respect to code review. */
193 + reviewDecision: Schema.NullOr(GraphQL.enumLiterals(Shared.PullRequestReviewDecision.literals)),
194 + /** A list of latest reviews per user associated with the pull request that are not also pending review. */
195 + latestReviews: Schema.NullOr(PullRequestReviewConnection),
196 + /** The number of additions in this pull request. */
197 + additions: Schema.optionalKey(Shared.Int),
198 + /** The number of deletions in this pull request. */
199 + deletions: Schema.optionalKey(Shared.Int),
200 + /** Identifies the date and time when the object was created. */
201 + createdAt: Shared.DateTime,
202 + /** Identifies the date and time when the object was last updated. */
203 + updatedAt: Shared.DateTime,
204 + /** The date and time that the pull request was merged. */
205 + mergedAt: Schema.NullOr(Shared.DateTime),
206 + /** The repository associated with this node. */
207 + repository: PullRequestRowRepositoryRepository,
208 + /** A list of review requests associated with the pull request. */
209 + reviewRequests: Schema.NullOr(ReviewRequestConnection),
210 + /** A list of labels associated with the object. */
211 + labels: Schema.NullOr(LabelConnection),
212 + /** A list of commits present in this pull request's head branch not present in the base branch. */
213 + commits: PullRequestCommitConnection
214 +})
215 +export interface PullRequestRow extends Schema.Struct.Type<typeof PullRequestRow.fields> {}
216 +
217 +/** Information about pagination in a connection. */
218 +export const PageInfo = Schema.Struct({
219 + /** When paginating forwards, are there more items? */
220 + hasNextPage: Schema.Boolean,
221 + /** When paginating forwards, the cursor to continue. */
222 + endCursor: Schema.NullOr(Schema.String)
223 +})
224 +export interface PageInfo extends Schema.Struct.Type<typeof PageInfo.fields> {}
225 +
226 +/** A repository pull request. */
227 +export const PullRequest = Schema.Struct({
228 + __typename: Schema.Literal("PullRequest"),
229 + ...PullRequestRow.fields
230 +})
231 +export interface PullRequest extends Schema.Struct.Type<typeof PullRequest.fields> {}
232 +
233 +/** The results of a search. */
234 +export const SearchResultItemOther = Schema.Struct({
235 + __typename: GraphQL.otherTypename<Shared.Typename.SearchResultItem>()(["PullRequest"])
236 +})
237 +export interface SearchResultItemOther extends Schema.Struct.Type<typeof SearchResultItemOther.fields> {}
238 +
239 +/**
240 + * A list of results that matched against a search query. Regardless of the number
241 + * of matches, a maximum of 1,000 results will be available across all types,
242 + * potentially split across many pages.
243 + */
244 +export const SearchResultItemConnection = Schema.Struct({
245 + /** Information to aid in pagination. */
246 + pageInfo: PageInfo,
247 + /** A list of nodes. */
248 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Union([
249 + PullRequest,
250 + SearchResultItemOther
251 + ]))))
252 +})
253 +export interface SearchResultItemConnection extends Schema.Struct.Type<typeof SearchResultItemConnection.fields> {}
254 +
255 +/** `query PullRequestSearch` */
256 +export const PullRequestSearch = GraphQL.query("PullRequestSearch", {
257 + document: {
258 + variables: [
259 + { name: "q", body: "String!" },
260 + { name: "first", body: "Int!" },
261 + { name: "after", body: "String" },
262 + { name: "stacks", body: "Boolean!" },
263 + { name: "stats", body: "Boolean!" }
264 + ],
265 + selections: [
266 + { name: "search", body: ["(query:$", "q", " type:ISSUE first:$", "first", " after:$", "after", "){pageInfo{hasNextPage endCursor}nodes{__typename...", "PullRequestRow", "}}"] }
267 + ],
268 + fragments: [
269 + { name: "PullRequestRow", body: ["on PullRequest{stack@include(if:$", "stacks", "){number size baseRefName}stackEntry@include(if:$", "stacks", "){position}number title url author{__typename login avatarUrl...on User{name}}headRefName baseRefName state isDraft mergeable reviewDecision latestReviews(first:20){nodes{state author{__typename login}}}additions@include(if:$", "stats", ")deletions@include(if:$", "stats", ")createdAt updatedAt mergedAt repository{nameWithOwner}reviewRequests(first:20){nodes{requestedReviewer{__typename...on User{login}...on Team{slug}}}}labels(first:20){nodes{name color}}commits(last:1){nodes{commit{statusCheckRollup{state}}}}}"] }
270 + ]
271 + },
272 + variables: {
273 + q: Schema.String,
274 + first: Shared.Int,
275 + after: Schema.optional(Schema.NullOr(Schema.String)),
276 + stacks: Schema.Boolean,
277 + stats: Schema.Boolean
278 + },
279 + result: Schema.Struct({
280 + /** Perform a search across resources, returning a maximum of 1,000 results. */
281 + search: SearchResultItemConnection
282 + })
283 +})
284 +export declare namespace PullRequestSearch {
285 + export type Variables = typeof PullRequestSearch.variables.Type
286 + export type Result = typeof PullRequestSearch.result.Type
287 +}
288 +
289 +/** The connection type for PullRequest. */
290 +export const PullRequestConnection = Schema.Struct({
291 + /** Information to aid in pagination. */
292 + pageInfo: PageInfo,
293 + /** A list of nodes. */
294 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestRow)))
295 +})
296 +export interface PullRequestConnection extends Schema.Struct.Type<typeof PullRequestConnection.fields> {}
297 +
298 +/** A repository contains the content for a project. */
299 +export const PullRequestListRepositoryRepository = Schema.Struct({
300 + /** A list of pull requests that have been opened in the repository. */
301 + pullRequests: PullRequestConnection
302 +})
303 +export interface PullRequestListRepositoryRepository extends Schema.Struct.Type<typeof PullRequestListRepositoryRepository.fields> {}
304 +
305 +/** `query PullRequestList` */
306 +export const PullRequestList = GraphQL.query("PullRequestList", {
307 + document: {
308 + variables: [
309 + { name: "owner", body: "String!" },
310 + { name: "name", body: "String!" },
311 + { name: "states", body: "[PullRequestState!]" },
312 + { name: "first", body: "Int!" },
313 + { name: "after", body: "String" },
314 + { name: "stacks", body: "Boolean!" },
315 + { name: "stats", body: "Boolean!" }
316 + ],
317 + selections: [
318 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequests(first:$", "first", " after:$", "after", " states:$", "states", " orderBy:{field:CREATED_AT direction:DESC}){pageInfo{hasNextPage endCursor}nodes{...", "PullRequestRow", "}}}"] }
319 + ],
320 + fragments: [
321 + { name: "PullRequestRow", body: ["on PullRequest{stack@include(if:$", "stacks", "){number size baseRefName}stackEntry@include(if:$", "stacks", "){position}number title url author{__typename login avatarUrl...on User{name}}headRefName baseRefName state isDraft mergeable reviewDecision latestReviews(first:20){nodes{state author{__typename login}}}additions@include(if:$", "stats", ")deletions@include(if:$", "stats", ")createdAt updatedAt mergedAt repository{nameWithOwner}reviewRequests(first:20){nodes{requestedReviewer{__typename...on User{login}...on Team{slug}}}}labels(first:20){nodes{name color}}commits(last:1){nodes{commit{statusCheckRollup{state}}}}}"] }
322 + ]
323 + },
324 + variables: {
325 + owner: Schema.String,
326 + name: Schema.String,
327 + states: Schema.optional(Schema.NullOr(Schema.Array(Shared.PullRequestState))),
328 + first: Shared.Int,
329 + after: Schema.optional(Schema.NullOr(Schema.String)),
330 + stacks: Schema.Boolean,
331 + stats: Schema.Boolean
332 + },
333 + result: Schema.Struct({
334 + /** Lookup a given repository by the owner and repository name. */
335 + repository: Schema.NullOr(PullRequestListRepositoryRepository)
336 + })
337 +})
338 +export declare namespace PullRequestList {
339 + export type Variables = typeof PullRequestList.variables.Type
340 + export type Result = typeof PullRequestList.result.Type
341 +}
342 +
343 +/** Every operation in pullRequestListings.graphql. */
344 +export const PullRequestListingsGraphQLGroup = GraphQLGroup.make(PullRequestSearch, PullRequestList)
packages/source-control-github/src/server/pullRequestMutations.graphql new
+163
@@ -0,0 +1,163 @@
1 +# Writes to a pull request and the remarks on it. None reads its answer back beyond what GitHub
2 +# requires a mutation to select.
3 +
4 +mutation AddReviewThreadReply($threadId: ID!, $body: String!) {
5 + addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) {
6 + comment {
7 + id
8 + }
9 + }
10 +}
11 +
12 +mutation AddReaction($subjectId: ID!, $content: ReactionContent!) {
13 + addReaction(input: { subjectId: $subjectId, content: $content }) {
14 + reaction {
15 + content
16 + }
17 + }
18 +}
19 +
20 +mutation RemoveReaction($subjectId: ID!, $content: ReactionContent!) {
21 + removeReaction(input: { subjectId: $subjectId, content: $content }) {
22 + reaction {
23 + content
24 + }
25 + }
26 +}
27 +
28 +mutation ResolveReviewThread($threadId: ID!) {
29 + resolveReviewThread(input: { threadId: $threadId }) {
30 + thread {
31 + isResolved
32 + }
33 + }
34 +}
35 +
36 +mutation UnresolveReviewThread($threadId: ID!) {
37 + unresolveReviewThread(input: { threadId: $threadId }) {
38 + thread {
39 + isResolved
40 + }
41 + }
42 +}
43 +
44 +# Rewrites the pull request's own words. Both are nullable so that one document serves a change to
45 +# the title, to the description, or to the two together: a variable the request does not send puts
46 +# no entry in the input at all, which leaves that field as it was rather than clearing it.
47 +mutation UpdatePullRequest($pullRequestId: ID!, $title: String, $body: String) {
48 + updatePullRequest(input: { pullRequestId: $pullRequestId, title: $title, body: $body }) {
49 + pullRequest {
50 + id
51 + }
52 + }
53 +}
54 +
55 +# Creates a new pull request that reverses a merged pull request.
56 +mutation RevertPullRequest($pullRequestId: ID!) {
57 + revertPullRequest(input: { pullRequestId: $pullRequestId }) {
58 + revertPullRequest {
59 + id
60 + }
61 + }
62 +}
63 +
64 +# The two comment mutations name their comment differently; the variable is spelled the same in
65 +# both, so a rewrite sends one set of variables whichever kind of remark it is.
66 +mutation UpdateIssueComment($commentId: ID!, $body: String!) {
67 + updateIssueComment(input: { id: $commentId, body: $body }) {
68 + issueComment {
69 + id
70 + }
71 + }
72 +}
73 +
74 +mutation UpdateReviewComment($commentId: ID!, $body: String!) {
75 + updatePullRequestReviewComment(input: { pullRequestReviewCommentId: $commentId, body: $body }) {
76 + pullRequestReviewComment {
77 + id
78 + }
79 + }
80 +}
81 +
82 +# Clears one file, or puts it back. GitHub has no bulk form of either mutation, so
83 +# `GraphQLResolver.aliased` repeats this under an alias per file and a burst of ticks is one
84 +# request; `$viewed` picks which of the two each alias runs.
85 +mutation SetFileViewed($pullRequestId: ID!, $path: String!, $viewed: Boolean!) {
86 + markFileAsViewed(input: { pullRequestId: $pullRequestId, path: $path }) @include(if: $viewed) {
87 + clientMutationId
88 + }
89 + unmarkFileAsViewed(input: { pullRequestId: $pullRequestId, path: $path }) @skip(if: $viewed) {
90 + clientMutationId
91 + }
92 +}
93 +
94 +mutation MergePullRequest($input: MergePullRequestInput!) {
95 + mergePullRequest(input: $input) {
96 + clientMutationId
97 + }
98 +}
99 +
100 +mutation EnablePullRequestAutoMerge($input: EnablePullRequestAutoMergeInput!) {
101 + enablePullRequestAutoMerge(input: $input) {
102 + clientMutationId
103 + }
104 +}
105 +
106 +mutation DisablePullRequestAutoMerge($pullRequestId: ID!) {
107 + disablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId }) {
108 + clientMutationId
109 + }
110 +}
111 +
112 +mutation UpdatePullRequestBranch(
113 + $pullRequestId: ID!
114 + $expectedHeadOid: GitObjectID!
115 + $updateMethod: PullRequestBranchUpdateMethod!
116 +) {
117 + updatePullRequestBranch(
118 + input: {
119 + pullRequestId: $pullRequestId
120 + expectedHeadOid: $expectedHeadOid
121 + updateMethod: $updateMethod
122 + }
123 + ) {
124 + clientMutationId
125 + }
126 +}
127 +
128 +mutation MarkPullRequestReadyForReview($pullRequestId: ID!) {
129 + markPullRequestReadyForReview(input: { pullRequestId: $pullRequestId }) {
130 + clientMutationId
131 + }
132 +}
133 +
134 +mutation ConvertPullRequestToDraft($pullRequestId: ID!) {
135 + convertPullRequestToDraft(input: { pullRequestId: $pullRequestId }) {
136 + clientMutationId
137 + }
138 +}
139 +
140 +mutation ClosePullRequest($pullRequestId: ID!) {
141 + closePullRequest(input: { pullRequestId: $pullRequestId }) {
142 + clientMutationId
143 + }
144 +}
145 +
146 +mutation ReopenPullRequest($pullRequestId: ID!) {
147 + reopenPullRequest(input: { pullRequestId: $pullRequestId }) {
148 + clientMutationId
149 + }
150 +}
151 +
152 +mutation AddComment($subjectId: ID!, $body: String!) {
153 + addComment(input: { subjectId: $subjectId, body: $body }) {
154 + clientMutationId
155 + }
156 +}
157 +
158 +# Deletes a branch only while it still points at `beforeOid`, which `refUpdates` carries.
159 +mutation DeletePullRequestBranch($input: UpdateRefsInput!) {
160 + updateRefs(input: $input) {
161 + clientMutationId
162 + }
163 +}
packages/source-control-github/src/server/pullRequestMutations.graphql.ts new
+722
@@ -0,0 +1,722 @@
1 +// Generated by @effect/graphql-generator from pullRequestMutations.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A review comment associated with a given repository pull request. */
7 +export const PullRequestReviewComment = Schema.Struct({
8 + /** The Node ID of the PullRequestReviewComment object */
9 + id: Shared.ID
10 +})
11 +export interface PullRequestReviewComment extends Schema.Struct.Type<typeof PullRequestReviewComment.fields> {}
12 +
13 +/** Autogenerated return type of AddPullRequestReviewThreadReply. */
14 +export const AddPullRequestReviewThreadReplyPayload = Schema.Struct({
15 + /** The newly created reply. */
16 + comment: Schema.NullOr(PullRequestReviewComment)
17 +})
18 +export interface AddPullRequestReviewThreadReplyPayload extends Schema.Struct.Type<typeof AddPullRequestReviewThreadReplyPayload.fields> {}
19 +
20 +/** `mutation AddReviewThreadReply` */
21 +export const AddReviewThreadReply = GraphQL.mutation("AddReviewThreadReply", {
22 + document: {
23 + variables: [
24 + { name: "threadId", body: "ID!" },
25 + { name: "body", body: "String!" }
26 + ],
27 + selections: [
28 + { name: "addPullRequestReviewThreadReply", body: ["(input:{pullRequestReviewThreadId:$", "threadId", " body:$", "body", "}){comment{id}}"] }
29 + ],
30 + fragments: []
31 + },
32 + variables: {
33 + threadId: Shared.ID,
34 + body: Schema.String
35 + },
36 + result: Schema.Struct({
37 + /** Adds a reply to an existing Pull Request Review Thread. */
38 + addPullRequestReviewThreadReply: Schema.NullOr(AddPullRequestReviewThreadReplyPayload)
39 + })
40 +})
41 +export declare namespace AddReviewThreadReply {
42 + export type Variables = typeof AddReviewThreadReply.variables.Type
43 + export type Result = typeof AddReviewThreadReply.result.Type
44 +}
45 +
46 +/** An emoji reaction to a particular piece of content. */
47 +export const Reaction = Schema.Struct({
48 + /** Identifies the emoji reaction. */
49 + content: GraphQL.enumLiterals(Shared.ReactionContent.literals)
50 +})
51 +export interface Reaction extends Schema.Struct.Type<typeof Reaction.fields> {}
52 +
53 +/** Autogenerated return type of AddReaction. */
54 +export const AddReactionPayload = Schema.Struct({
55 + /** The reaction object. */
56 + reaction: Schema.NullOr(Reaction)
57 +})
58 +export interface AddReactionPayload extends Schema.Struct.Type<typeof AddReactionPayload.fields> {}
59 +
60 +/** `mutation AddReaction` */
61 +export const AddReaction = GraphQL.mutation("AddReaction", {
62 + document: {
63 + variables: [
64 + { name: "subjectId", body: "ID!" },
65 + { name: "content", body: "ReactionContent!" }
66 + ],
67 + selections: [
68 + { name: "addReaction", body: ["(input:{subjectId:$", "subjectId", " content:$", "content", "}){reaction{content}}"] }
69 + ],
70 + fragments: []
71 + },
72 + variables: {
73 + subjectId: Shared.ID,
74 + content: Shared.ReactionContent
75 + },
76 + result: Schema.Struct({
77 + /** Adds a reaction to a subject. */
78 + addReaction: Schema.NullOr(AddReactionPayload)
79 + })
80 +})
81 +export declare namespace AddReaction {
82 + export type Variables = typeof AddReaction.variables.Type
83 + export type Result = typeof AddReaction.result.Type
84 +}
85 +
86 +/** Autogenerated return type of RemoveReaction. */
87 +export const RemoveReactionPayload = Schema.Struct({
88 + /** The reaction object. */
89 + reaction: Schema.NullOr(Reaction)
90 +})
91 +export interface RemoveReactionPayload extends Schema.Struct.Type<typeof RemoveReactionPayload.fields> {}
92 +
93 +/** `mutation RemoveReaction` */
94 +export const RemoveReaction = GraphQL.mutation("RemoveReaction", {
95 + document: {
96 + variables: [
97 + { name: "subjectId", body: "ID!" },
98 + { name: "content", body: "ReactionContent!" }
99 + ],
100 + selections: [
101 + { name: "removeReaction", body: ["(input:{subjectId:$", "subjectId", " content:$", "content", "}){reaction{content}}"] }
102 + ],
103 + fragments: []
104 + },
105 + variables: {
106 + subjectId: Shared.ID,
107 + content: Shared.ReactionContent
108 + },
109 + result: Schema.Struct({
110 + /** Removes a reaction from a subject. */
111 + removeReaction: Schema.NullOr(RemoveReactionPayload)
112 + })
113 +})
114 +export declare namespace RemoveReaction {
115 + export type Variables = typeof RemoveReaction.variables.Type
116 + export type Result = typeof RemoveReaction.result.Type
117 +}
118 +
119 +/** A threaded list of comments for a given pull request. */
120 +export const PullRequestReviewThread = Schema.Struct({
121 + /** Whether this thread has been resolved */
122 + isResolved: Schema.Boolean
123 +})
124 +export interface PullRequestReviewThread extends Schema.Struct.Type<typeof PullRequestReviewThread.fields> {}
125 +
126 +/** Autogenerated return type of ResolveReviewThread. */
127 +export const ResolveReviewThreadPayload = Schema.Struct({
128 + /** The thread to resolve. */
129 + thread: Schema.NullOr(PullRequestReviewThread)
130 +})
131 +export interface ResolveReviewThreadPayload extends Schema.Struct.Type<typeof ResolveReviewThreadPayload.fields> {}
132 +
133 +/** `mutation ResolveReviewThread` */
134 +export const ResolveReviewThread = GraphQL.mutation("ResolveReviewThread", {
135 + document: {
136 + variables: [
137 + { name: "threadId", body: "ID!" }
138 + ],
139 + selections: [
140 + { name: "resolveReviewThread", body: ["(input:{threadId:$", "threadId", "}){thread{isResolved}}"] }
141 + ],
142 + fragments: []
143 + },
144 + variables: {
145 + threadId: Shared.ID
146 + },
147 + result: Schema.Struct({
148 + /** Marks a review thread as resolved. */
149 + resolveReviewThread: Schema.NullOr(ResolveReviewThreadPayload)
150 + })
151 +})
152 +export declare namespace ResolveReviewThread {
153 + export type Variables = typeof ResolveReviewThread.variables.Type
154 + export type Result = typeof ResolveReviewThread.result.Type
155 +}
156 +
157 +/** Autogenerated return type of UnresolveReviewThread. */
158 +export const UnresolveReviewThreadPayload = Schema.Struct({
159 + /** The thread to resolve. */
160 + thread: Schema.NullOr(PullRequestReviewThread)
161 +})
162 +export interface UnresolveReviewThreadPayload extends Schema.Struct.Type<typeof UnresolveReviewThreadPayload.fields> {}
163 +
164 +/** `mutation UnresolveReviewThread` */
165 +export const UnresolveReviewThread = GraphQL.mutation("UnresolveReviewThread", {
166 + document: {
167 + variables: [
168 + { name: "threadId", body: "ID!" }
169 + ],
170 + selections: [
171 + { name: "unresolveReviewThread", body: ["(input:{threadId:$", "threadId", "}){thread{isResolved}}"] }
172 + ],
173 + fragments: []
174 + },
175 + variables: {
176 + threadId: Shared.ID
177 + },
178 + result: Schema.Struct({
179 + /** Marks a review thread as unresolved. */
180 + unresolveReviewThread: Schema.NullOr(UnresolveReviewThreadPayload)
181 + })
182 +})
183 +export declare namespace UnresolveReviewThread {
184 + export type Variables = typeof UnresolveReviewThread.variables.Type
185 + export type Result = typeof UnresolveReviewThread.result.Type
186 +}
187 +
188 +/** A repository pull request. */
189 +export const PullRequest = Schema.Struct({
190 + /** The Node ID of the PullRequest object */
191 + id: Shared.ID
192 +})
193 +export interface PullRequest extends Schema.Struct.Type<typeof PullRequest.fields> {}
194 +
195 +/** Autogenerated return type of UpdatePullRequest. */
196 +export const UpdatePullRequestPayload = Schema.Struct({
197 + /** The updated pull request. */
198 + pullRequest: Schema.NullOr(PullRequest)
199 +})
200 +export interface UpdatePullRequestPayload extends Schema.Struct.Type<typeof UpdatePullRequestPayload.fields> {}
201 +
202 +/** `mutation UpdatePullRequest` */
203 +export const UpdatePullRequest = GraphQL.mutation("UpdatePullRequest", {
204 + document: {
205 + variables: [
206 + { name: "pullRequestId", body: "ID!" },
207 + { name: "title", body: "String" },
208 + { name: "body", body: "String" }
209 + ],
210 + selections: [
211 + { name: "updatePullRequest", body: ["(input:{pullRequestId:$", "pullRequestId", " title:$", "title", " body:$", "body", "}){pullRequest{id}}"] }
212 + ],
213 + fragments: []
214 + },
215 + variables: {
216 + pullRequestId: Shared.ID,
217 + title: Schema.optional(Schema.NullOr(Schema.String)),
218 + body: Schema.optional(Schema.NullOr(Schema.String))
219 + },
220 + result: Schema.Struct({
221 + /** Update a pull request */
222 + updatePullRequest: Schema.NullOr(UpdatePullRequestPayload)
223 + })
224 +})
225 +export declare namespace UpdatePullRequest {
226 + export type Variables = typeof UpdatePullRequest.variables.Type
227 + export type Result = typeof UpdatePullRequest.result.Type
228 +}
229 +
230 +/** Autogenerated return type of RevertPullRequest. */
231 +export const RevertPullRequestPayload = Schema.Struct({
232 + /** The new pull request that reverts the input pull request. */
233 + revertPullRequest: Schema.NullOr(PullRequest)
234 +})
235 +export interface RevertPullRequestPayload extends Schema.Struct.Type<typeof RevertPullRequestPayload.fields> {}
236 +
237 +/** `mutation RevertPullRequest` */
238 +export const RevertPullRequest = GraphQL.mutation("RevertPullRequest", {
239 + document: {
240 + variables: [
241 + { name: "pullRequestId", body: "ID!" }
242 + ],
243 + selections: [
244 + { name: "revertPullRequest", body: ["(input:{pullRequestId:$", "pullRequestId", "}){revertPullRequest{id}}"] }
245 + ],
246 + fragments: []
247 + },
248 + variables: {
249 + pullRequestId: Shared.ID
250 + },
251 + result: Schema.Struct({
252 + /** Create a pull request that reverts the changes from a merged pull request. */
253 + revertPullRequest: Schema.NullOr(RevertPullRequestPayload)
254 + })
255 +})
256 +export declare namespace RevertPullRequest {
257 + export type Variables = typeof RevertPullRequest.variables.Type
258 + export type Result = typeof RevertPullRequest.result.Type
259 +}
260 +
261 +/** Represents a comment on an Issue. */
262 +export const IssueComment = Schema.Struct({
263 + /** The Node ID of the IssueComment object */
264 + id: Shared.ID
265 +})
266 +export interface IssueComment extends Schema.Struct.Type<typeof IssueComment.fields> {}
267 +
268 +/** Autogenerated return type of UpdateIssueComment. */
269 +export const UpdateIssueCommentPayload = Schema.Struct({
270 + /** The updated comment. */
271 + issueComment: Schema.NullOr(IssueComment)
272 +})
273 +export interface UpdateIssueCommentPayload extends Schema.Struct.Type<typeof UpdateIssueCommentPayload.fields> {}
274 +
275 +/** `mutation UpdateIssueComment` */
276 +export const UpdateIssueComment = GraphQL.mutation("UpdateIssueComment", {
277 + document: {
278 + variables: [
279 + { name: "commentId", body: "ID!" },
280 + { name: "body", body: "String!" }
281 + ],
282 + selections: [
283 + { name: "updateIssueComment", body: ["(input:{id:$", "commentId", " body:$", "body", "}){issueComment{id}}"] }
284 + ],
285 + fragments: []
286 + },
287 + variables: {
288 + commentId: Shared.ID,
289 + body: Schema.String
290 + },
291 + result: Schema.Struct({
292 + /** Updates an IssueComment object. */
293 + updateIssueComment: Schema.NullOr(UpdateIssueCommentPayload)
294 + })
295 +})
296 +export declare namespace UpdateIssueComment {
297 + export type Variables = typeof UpdateIssueComment.variables.Type
298 + export type Result = typeof UpdateIssueComment.result.Type
299 +}
300 +
301 +/** Autogenerated return type of UpdatePullRequestReviewComment. */
302 +export const UpdatePullRequestReviewCommentPayload = Schema.Struct({
303 + /** The updated comment. */
304 + pullRequestReviewComment: Schema.NullOr(PullRequestReviewComment)
305 +})
306 +export interface UpdatePullRequestReviewCommentPayload extends Schema.Struct.Type<typeof UpdatePullRequestReviewCommentPayload.fields> {}
307 +
308 +/** `mutation UpdateReviewComment` */
309 +export const UpdateReviewComment = GraphQL.mutation("UpdateReviewComment", {
310 + document: {
311 + variables: [
312 + { name: "commentId", body: "ID!" },
313 + { name: "body", body: "String!" }
314 + ],
315 + selections: [
316 + { name: "updatePullRequestReviewComment", body: ["(input:{pullRequestReviewCommentId:$", "commentId", " body:$", "body", "}){pullRequestReviewComment{id}}"] }
317 + ],
318 + fragments: []
319 + },
320 + variables: {
321 + commentId: Shared.ID,
322 + body: Schema.String
323 + },
324 + result: Schema.Struct({
325 + /** Updates a pull request review comment. */
326 + updatePullRequestReviewComment: Schema.NullOr(UpdatePullRequestReviewCommentPayload)
327 + })
328 +})
329 +export declare namespace UpdateReviewComment {
330 + export type Variables = typeof UpdateReviewComment.variables.Type
331 + export type Result = typeof UpdateReviewComment.result.Type
332 +}
333 +
334 +/** Autogenerated return type of MarkFileAsViewed. */
335 +export const MarkFileAsViewedPayload = Schema.Struct({
336 + /** A unique identifier for the client performing the mutation. */
337 + clientMutationId: Schema.NullOr(Schema.String)
338 +})
339 +export interface MarkFileAsViewedPayload extends Schema.Struct.Type<typeof MarkFileAsViewedPayload.fields> {}
340 +
341 +/** Autogenerated return type of UnmarkFileAsViewed. */
342 +export const UnmarkFileAsViewedPayload = Schema.Struct({
343 + /** A unique identifier for the client performing the mutation. */
344 + clientMutationId: Schema.NullOr(Schema.String)
345 +})
346 +export interface UnmarkFileAsViewedPayload extends Schema.Struct.Type<typeof UnmarkFileAsViewedPayload.fields> {}
347 +
348 +/** `mutation SetFileViewed` */
349 +export const SetFileViewed = GraphQL.mutation("SetFileViewed", {
350 + document: {
351 + variables: [
352 + { name: "pullRequestId", body: "ID!" },
353 + { name: "path", body: "String!" },
354 + { name: "viewed", body: "Boolean!" }
355 + ],
356 + selections: [
357 + { name: "markFileAsViewed", body: ["(input:{pullRequestId:$", "pullRequestId", " path:$", "path", "})@include(if:$", "viewed", "){clientMutationId}"] },
358 + { name: "unmarkFileAsViewed", body: ["(input:{pullRequestId:$", "pullRequestId", " path:$", "path", "})@skip(if:$", "viewed", "){clientMutationId}"] }
359 + ],
360 + fragments: []
361 + },
362 + variables: {
363 + pullRequestId: Shared.ID,
364 + path: Schema.String,
365 + viewed: Schema.Boolean
366 + },
367 + result: Schema.Struct({
368 + /** Mark a pull request file as viewed */
369 + markFileAsViewed: Schema.optionalKey(Schema.NullOr(MarkFileAsViewedPayload)),
370 + /** Unmark a pull request file as viewed */
371 + unmarkFileAsViewed: Schema.optionalKey(Schema.NullOr(UnmarkFileAsViewedPayload))
372 + })
373 +})
374 +export declare namespace SetFileViewed {
375 + export type Variables = typeof SetFileViewed.variables.Type
376 + export type Result = typeof SetFileViewed.result.Type
377 +}
378 +
379 +/** Autogenerated return type of MergePullRequest. */
380 +export const MergePullRequestPayload = Schema.Struct({
381 + /** A unique identifier for the client performing the mutation. */
382 + clientMutationId: Schema.NullOr(Schema.String)
383 +})
384 +export interface MergePullRequestPayload extends Schema.Struct.Type<typeof MergePullRequestPayload.fields> {}
385 +
386 +/** `mutation MergePullRequest` */
387 +export const MergePullRequest = GraphQL.mutation("MergePullRequest", {
388 + document: {
389 + variables: [
390 + { name: "input", body: "MergePullRequestInput!" }
391 + ],
392 + selections: [
393 + { name: "mergePullRequest", body: ["(input:$", "input", "){clientMutationId}"] }
394 + ],
395 + fragments: []
396 + },
397 + variables: {
398 + input: Shared.MergePullRequestInput
399 + },
400 + result: Schema.Struct({
401 + /**
402 + * Merge a pull request.
403 + *
404 + * > [!NOTE]
405 + * > We recommend using the [asynchronous merge REST
406 + * API](${externalDocsUrl}/rest/pulls/pulls#merge-a-pull-request-asynchronously) instead.
407 + * > This mutation does not support stacked pull requests.
408 + */
409 + mergePullRequest: Schema.NullOr(MergePullRequestPayload)
410 + })
411 +})
412 +export declare namespace MergePullRequest {
413 + export type Variables = typeof MergePullRequest.variables.Type
414 + export type Result = typeof MergePullRequest.result.Type
415 +}
416 +
417 +/** Autogenerated return type of EnablePullRequestAutoMerge. */
418 +export const EnablePullRequestAutoMergePayload = Schema.Struct({
419 + /** A unique identifier for the client performing the mutation. */
420 + clientMutationId: Schema.NullOr(Schema.String)
421 +})
422 +export interface EnablePullRequestAutoMergePayload extends Schema.Struct.Type<typeof EnablePullRequestAutoMergePayload.fields> {}
423 +
424 +/** `mutation EnablePullRequestAutoMerge` */
425 +export const EnablePullRequestAutoMerge = GraphQL.mutation("EnablePullRequestAutoMerge", {
426 + document: {
427 + variables: [
428 + { name: "input", body: "EnablePullRequestAutoMergeInput!" }
429 + ],
430 + selections: [
431 + { name: "enablePullRequestAutoMerge", body: ["(input:$", "input", "){clientMutationId}"] }
432 + ],
433 + fragments: []
434 + },
435 + variables: {
436 + input: Shared.EnablePullRequestAutoMergeInput
437 + },
438 + result: Schema.Struct({
439 + /** Enable the default auto-merge on a pull request. */
440 + enablePullRequestAutoMerge: Schema.NullOr(EnablePullRequestAutoMergePayload)
441 + })
442 +})
443 +export declare namespace EnablePullRequestAutoMerge {
444 + export type Variables = typeof EnablePullRequestAutoMerge.variables.Type
445 + export type Result = typeof EnablePullRequestAutoMerge.result.Type
446 +}
447 +
448 +/** Autogenerated return type of DisablePullRequestAutoMerge. */
449 +export const DisablePullRequestAutoMergePayload = Schema.Struct({
450 + /** A unique identifier for the client performing the mutation. */
451 + clientMutationId: Schema.NullOr(Schema.String)
452 +})
453 +export interface DisablePullRequestAutoMergePayload extends Schema.Struct.Type<typeof DisablePullRequestAutoMergePayload.fields> {}
454 +
455 +/** `mutation DisablePullRequestAutoMerge` */
456 +export const DisablePullRequestAutoMerge = GraphQL.mutation("DisablePullRequestAutoMerge", {
457 + document: {
458 + variables: [
459 + { name: "pullRequestId", body: "ID!" }
460 + ],
461 + selections: [
462 + { name: "disablePullRequestAutoMerge", body: ["(input:{pullRequestId:$", "pullRequestId", "}){clientMutationId}"] }
463 + ],
464 + fragments: []
465 + },
466 + variables: {
467 + pullRequestId: Shared.ID
468 + },
469 + result: Schema.Struct({
470 + /** Disable auto merge on the given pull request */
471 + disablePullRequestAutoMerge: Schema.NullOr(DisablePullRequestAutoMergePayload)
472 + })
473 +})
474 +export declare namespace DisablePullRequestAutoMerge {
475 + export type Variables = typeof DisablePullRequestAutoMerge.variables.Type
476 + export type Result = typeof DisablePullRequestAutoMerge.result.Type
477 +}
478 +
479 +/** Autogenerated return type of UpdatePullRequestBranch. */
480 +export const UpdatePullRequestBranchPayload = Schema.Struct({
481 + /** A unique identifier for the client performing the mutation. */
482 + clientMutationId: Schema.NullOr(Schema.String)
483 +})
484 +export interface UpdatePullRequestBranchPayload extends Schema.Struct.Type<typeof UpdatePullRequestBranchPayload.fields> {}
485 +
486 +/** `mutation UpdatePullRequestBranch` */
487 +export const UpdatePullRequestBranch = GraphQL.mutation("UpdatePullRequestBranch", {
488 + document: {
489 + variables: [
490 + { name: "pullRequestId", body: "ID!" },
491 + { name: "expectedHeadOid", body: "GitObjectID!" },
492 + { name: "updateMethod", body: "PullRequestBranchUpdateMethod!" }
493 + ],
494 + selections: [
495 + { name: "updatePullRequestBranch", body: ["(input:{pullRequestId:$", "pullRequestId", " expectedHeadOid:$", "expectedHeadOid", " updateMethod:$", "updateMethod", "}){clientMutationId}"] }
496 + ],
497 + fragments: []
498 + },
499 + variables: {
500 + pullRequestId: Shared.ID,
501 + expectedHeadOid: Shared.GitObjectID,
502 + updateMethod: Shared.PullRequestBranchUpdateMethod
503 + },
504 + result: Schema.Struct({
505 + /** Merge or Rebase HEAD from upstream branch into pull request branch */
506 + updatePullRequestBranch: Schema.NullOr(UpdatePullRequestBranchPayload)
507 + })
508 +})
509 +export declare namespace UpdatePullRequestBranch {
510 + export type Variables = typeof UpdatePullRequestBranch.variables.Type
511 + export type Result = typeof UpdatePullRequestBranch.result.Type
512 +}
513 +
514 +/** Autogenerated return type of MarkPullRequestReadyForReview. */
515 +export const MarkPullRequestReadyForReviewPayload = Schema.Struct({
516 + /** A unique identifier for the client performing the mutation. */
517 + clientMutationId: Schema.NullOr(Schema.String)
518 +})
519 +export interface MarkPullRequestReadyForReviewPayload extends Schema.Struct.Type<typeof MarkPullRequestReadyForReviewPayload.fields> {}
520 +
521 +/** `mutation MarkPullRequestReadyForReview` */
522 +export const MarkPullRequestReadyForReview = GraphQL.mutation("MarkPullRequestReadyForReview", {
523 + document: {
524 + variables: [
525 + { name: "pullRequestId", body: "ID!" }
526 + ],
527 + selections: [
528 + { name: "markPullRequestReadyForReview", body: ["(input:{pullRequestId:$", "pullRequestId", "}){clientMutationId}"] }
529 + ],
530 + fragments: []
531 + },
532 + variables: {
533 + pullRequestId: Shared.ID
534 + },
535 + result: Schema.Struct({
536 + /** Marks a pull request ready for review. */
537 + markPullRequestReadyForReview: Schema.NullOr(MarkPullRequestReadyForReviewPayload)
538 + })
539 +})
540 +export declare namespace MarkPullRequestReadyForReview {
541 + export type Variables = typeof MarkPullRequestReadyForReview.variables.Type
542 + export type Result = typeof MarkPullRequestReadyForReview.result.Type
543 +}
544 +
545 +/** Autogenerated return type of ConvertPullRequestToDraft. */
546 +export const ConvertPullRequestToDraftPayload = Schema.Struct({
547 + /** A unique identifier for the client performing the mutation. */
548 + clientMutationId: Schema.NullOr(Schema.String)
549 +})
550 +export interface ConvertPullRequestToDraftPayload extends Schema.Struct.Type<typeof ConvertPullRequestToDraftPayload.fields> {}
551 +
552 +/** `mutation ConvertPullRequestToDraft` */
553 +export const ConvertPullRequestToDraft = GraphQL.mutation("ConvertPullRequestToDraft", {
554 + document: {
555 + variables: [
556 + { name: "pullRequestId", body: "ID!" }
557 + ],
558 + selections: [
559 + { name: "convertPullRequestToDraft", body: ["(input:{pullRequestId:$", "pullRequestId", "}){clientMutationId}"] }
560 + ],
561 + fragments: []
562 + },
563 + variables: {
564 + pullRequestId: Shared.ID
565 + },
566 + result: Schema.Struct({
567 + /** Converts a pull request to draft */
568 + convertPullRequestToDraft: Schema.NullOr(ConvertPullRequestToDraftPayload)
569 + })
570 +})
571 +export declare namespace ConvertPullRequestToDraft {
572 + export type Variables = typeof ConvertPullRequestToDraft.variables.Type
573 + export type Result = typeof ConvertPullRequestToDraft.result.Type
574 +}
575 +
576 +/** Autogenerated return type of ClosePullRequest. */
577 +export const ClosePullRequestPayload = Schema.Struct({
578 + /** A unique identifier for the client performing the mutation. */
579 + clientMutationId: Schema.NullOr(Schema.String)
580 +})
581 +export interface ClosePullRequestPayload extends Schema.Struct.Type<typeof ClosePullRequestPayload.fields> {}
582 +
583 +/** `mutation ClosePullRequest` */
584 +export const ClosePullRequest = GraphQL.mutation("ClosePullRequest", {
585 + document: {
586 + variables: [
587 + { name: "pullRequestId", body: "ID!" }
588 + ],
589 + selections: [
590 + { name: "closePullRequest", body: ["(input:{pullRequestId:$", "pullRequestId", "}){clientMutationId}"] }
591 + ],
592 + fragments: []
593 + },
594 + variables: {
595 + pullRequestId: Shared.ID
596 + },
597 + result: Schema.Struct({
598 + /** Close a pull request. */
599 + closePullRequest: Schema.NullOr(ClosePullRequestPayload)
600 + })
601 +})
602 +export declare namespace ClosePullRequest {
603 + export type Variables = typeof ClosePullRequest.variables.Type
604 + export type Result = typeof ClosePullRequest.result.Type
605 +}
606 +
607 +/** Autogenerated return type of ReopenPullRequest. */
608 +export const ReopenPullRequestPayload = Schema.Struct({
609 + /** A unique identifier for the client performing the mutation. */
610 + clientMutationId: Schema.NullOr(Schema.String)
611 +})
612 +export interface ReopenPullRequestPayload extends Schema.Struct.Type<typeof ReopenPullRequestPayload.fields> {}
613 +
614 +/** `mutation ReopenPullRequest` */
615 +export const ReopenPullRequest = GraphQL.mutation("ReopenPullRequest", {
616 + document: {
617 + variables: [
618 + { name: "pullRequestId", body: "ID!" }
619 + ],
620 + selections: [
621 + { name: "reopenPullRequest", body: ["(input:{pullRequestId:$", "pullRequestId", "}){clientMutationId}"] }
622 + ],
623 + fragments: []
624 + },
625 + variables: {
626 + pullRequestId: Shared.ID
627 + },
628 + result: Schema.Struct({
629 + /** Reopen a pull request. */
630 + reopenPullRequest: Schema.NullOr(ReopenPullRequestPayload)
631 + })
632 +})
633 +export declare namespace ReopenPullRequest {
634 + export type Variables = typeof ReopenPullRequest.variables.Type
635 + export type Result = typeof ReopenPullRequest.result.Type
636 +}
637 +
638 +/** Autogenerated return type of AddComment. */
639 +export const AddCommentPayload = Schema.Struct({
640 + /** A unique identifier for the client performing the mutation. */
641 + clientMutationId: Schema.NullOr(Schema.String)
642 +})
643 +export interface AddCommentPayload extends Schema.Struct.Type<typeof AddCommentPayload.fields> {}
644 +
645 +/** `mutation AddComment` */
646 +export const AddComment = GraphQL.mutation("AddComment", {
647 + document: {
648 + variables: [
649 + { name: "subjectId", body: "ID!" },
650 + { name: "body", body: "String!" }
651 + ],
652 + selections: [
653 + { name: "addComment", body: ["(input:{subjectId:$", "subjectId", " body:$", "body", "}){clientMutationId}"] }
654 + ],
655 + fragments: []
656 + },
657 + variables: {
658 + subjectId: Shared.ID,
659 + body: Schema.String
660 + },
661 + result: Schema.Struct({
662 + /** Adds a comment to an Issue or Pull Request. */
663 + addComment: Schema.NullOr(AddCommentPayload)
664 + })
665 +})
666 +export declare namespace AddComment {
667 + export type Variables = typeof AddComment.variables.Type
668 + export type Result = typeof AddComment.result.Type
669 +}
670 +
671 +/** Autogenerated return type of UpdateRefs. */
672 +export const UpdateRefsPayload = Schema.Struct({
673 + /** A unique identifier for the client performing the mutation. */
674 + clientMutationId: Schema.NullOr(Schema.String)
675 +})
676 +export interface UpdateRefsPayload extends Schema.Struct.Type<typeof UpdateRefsPayload.fields> {}
677 +
678 +/** `mutation DeletePullRequestBranch` */
679 +export const DeletePullRequestBranch = GraphQL.mutation("DeletePullRequestBranch", {
680 + document: {
681 + variables: [
682 + { name: "input", body: "UpdateRefsInput!" }
683 + ],
684 + selections: [
685 + { name: "updateRefs", body: ["(input:$", "input", "){clientMutationId}"] }
686 + ],
687 + fragments: []
688 + },
689 + variables: {
690 + input: Shared.UpdateRefsInput
691 + },
692 + result: Schema.Struct({
693 + /**
694 + * Creates, updates and/or deletes multiple refs in a repository.
695 + *
696 + * This mutation takes a list of `RefUpdate`s and performs these updates
697 + * on the repository. All updates are performed atomically, meaning that
698 + * if one of them is rejected, no other ref will be modified.
699 + *
700 + * `RefUpdate.beforeOid` specifies that the given reference needs to point
701 + * to the given value before performing any updates. A value of
702 + * `0000000000000000000000000000000000000000` can be used to verify that
703 + * the references should not exist.
704 + *
705 + * `RefUpdate.afterOid` specifies the value that the given reference
706 + * will point to after performing all updates. A value of
707 + * `0000000000000000000000000000000000000000` can be used to delete a
708 + * reference.
709 + *
710 + * If `RefUpdate.force` is set to `true`, a non-fast-forward updates
711 + * for the given reference will be allowed.
712 + */
713 + updateRefs: Schema.NullOr(UpdateRefsPayload)
714 + })
715 +})
716 +export declare namespace DeletePullRequestBranch {
717 + export type Variables = typeof DeletePullRequestBranch.variables.Type
718 + export type Result = typeof DeletePullRequestBranch.result.Type
719 +}
720 +
721 +/** Every operation in pullRequestMutations.graphql. */
722 +export const PullRequestMutationsGraphQLGroup = GraphQLGroup.make(AddReviewThreadReply, AddReaction, RemoveReaction, ResolveReviewThread, UnresolveReviewThread, UpdatePullRequest, RevertPullRequest, UpdateIssueComment, UpdateReviewComment, SetFileViewed, MergePullRequest, EnablePullRequestAutoMerge, DisablePullRequestAutoMerge, UpdatePullRequestBranch, MarkPullRequestReadyForReview, ConvertPullRequestToDraft, ClosePullRequest, ReopenPullRequest, AddComment, DeletePullRequestBranch)
packages/source-control-github/src/server/pullRequestReads.graphql new
+532
@@ -0,0 +1,532 @@
1 +# Reads of one pull request, or of the repository it belongs to.
2 +
3 +# Resolves a listing's authors to avatars, which no listing field carries.
4 +query ActorAvatars($ids: [ID!]!) {
5 + nodes(ids: $ids) {
6 + ... on User {
7 + login
8 + avatarUrl
9 + }
10 + ... on Bot {
11 + login
12 + avatarUrl
13 + }
14 + }
15 +}
16 +
17 +# A check context of the head commit. `isRequired` is asked for on github.com only (`$required`):
18 +# an older Enterprise server may not know it, and an unknown field fails the whole read.
19 +fragment CheckContext on StatusCheckRollupContext {
20 + ... on StatusContext {
21 + context
22 + state
23 + targetUrl
24 + createdAt
25 + description
26 + isRequired(pullRequestNumber: $number) @include(if: $required)
27 + }
28 + ... on CheckRun {
29 + name
30 + status
31 + conclusion
32 + startedAt
33 + completedAt
34 + detailsUrl
35 + isRequired(pullRequestNumber: $number) @include(if: $required)
36 + checkSuite {
37 + workflowRun {
38 + workflow {
39 + name
40 + }
41 + }
42 + }
43 + }
44 +}
45 +
46 +# The detail of a pull request with the viewer's standing on it. Pull refs let the comparison
47 +# (`$headRef` is `refs/pull/<number>/head`) share this read without first resolving a fork branch.
48 +query PullRequestCore(
49 + $owner: String!
50 + $name: String!
51 + $number: Int!
52 + $headRef: String!
53 + $required: Boolean!
54 +) {
55 + repository(owner: $owner, name: $name) {
56 + mergeCommitAllowed
57 + squashMergeAllowed
58 + rebaseMergeAllowed
59 + viewerPermission
60 + pullRequest(number: $number) {
61 + number
62 + title
63 + url
64 + body
65 + state
66 + isDraft
67 + mergeable
68 + reviewDecision
69 + additions
70 + deletions
71 + changedFiles
72 + createdAt
73 + updatedAt
74 + mergedAt
75 + closedAt
76 + headRefName
77 + baseRefName
78 + headRefOid
79 + isCrossRepository
80 + headRepositoryOwner {
81 + login
82 + }
83 + # The source branch's own repository and ref, which is what deleting the branch needs: write
84 + # there, and a branch still to delete.
85 + headRepository {
86 + nameWithOwner
87 + viewerPermission
88 + }
89 + headRef {
90 + id
91 + }
92 + author {
93 + login
94 + avatarUrl
95 + ... on User {
96 + id
97 + name
98 + }
99 + }
100 + autoMergeRequest {
101 + mergeMethod
102 + }
103 + viewerCanUpdate
104 + viewerDidAuthor
105 + viewerCanUpdateBranch
106 + baseRef {
107 + compare(headRef: $headRef) {
108 + behindBy
109 + }
110 + }
111 + reviewRequests(first: 100) {
112 + nodes {
113 + requestedReviewer {
114 + ... on User {
115 + login
116 + name
117 + }
118 + ... on Bot {
119 + login
120 + }
121 + # A team's name and avatar are nullable differently from a person's, so they travel
122 + # under their own aliases. `combinedSlug` is the `org/slug` a reviewer row shows.
123 + ... on Team {
124 + slug
125 + combinedSlug
126 + teamName: name
127 + teamAvatarUrl: avatarUrl
128 + }
129 + }
130 + }
131 + }
132 + labels(first: 100) {
133 + nodes {
134 + name
135 + color
136 + }
137 + }
138 + commits(last: 1) {
139 + nodes {
140 + commit {
141 + statusCheckRollup {
142 + contexts(first: 100) {
143 + nodes {
144 + ...CheckContext
145 + }
146 + pageInfo {
147 + hasNextPage
148 + }
149 + }
150 + }
151 + }
152 + }
153 + }
154 + }
155 + }
156 +}
157 +
158 +# Every check context of the head commit, a page at a time, for a rollup past one page.
159 +query PullRequestCheckContexts(
160 + $owner: String!
161 + $name: String!
162 + $number: Int!
163 + $required: Boolean!
164 + $after: String
165 +) {
166 + repository(owner: $owner, name: $name) {
167 + pullRequest(number: $number) {
168 + headRefOid
169 + commits(last: 1) {
170 + nodes {
171 + commit {
172 + statusCheckRollup {
173 + contexts(first: 100, after: $after) {
174 + nodes {
175 + ...CheckContext
176 + }
177 + pageInfo {
178 + hasNextPage
179 + endCursor
180 + }
181 + }
182 + }
183 + }
184 + }
185 + }
186 + }
187 + }
188 +}
189 +
190 +query PullRequestPreview($owner: String!, $name: String!, $number: Int!) {
191 + repository(owner: $owner, name: $name) {
192 + pullRequest(number: $number) {
193 + number
194 + title
195 + url
196 + state
197 + isDraft
198 + createdAt
199 + author {
200 + login
201 + avatarUrl
202 + ... on User {
203 + name
204 + }
205 + }
206 + }
207 + }
208 +}
209 +
210 +# The conversation a pull request carries outside its review threads: who opened it, its issue
211 +# comments, its reviews and its newest commits. The two remark connections page independently, so
212 +# each is switched on only while it has more to give; the first read (`$head`) asks for everything.
213 +query PullRequestActivity(
214 + $owner: String!
215 + $name: String!
216 + $number: Int!
217 + $head: Boolean!
218 + $withComments: Boolean!
219 + $commentsAfter: String
220 + $withReviews: Boolean!
221 + $reviewsAfter: String
222 +) {
223 + repository(owner: $owner, name: $name) {
224 + pullRequest(number: $number) {
225 + author @include(if: $head) {
226 + login
227 + avatarUrl
228 + ... on User {
229 + name
230 + }
231 + }
232 + commits(last: 100) @include(if: $head) {
233 + nodes {
234 + commit {
235 + oid
236 + messageHeadline
237 + committedDate
238 + authors(first: 10) {
239 + nodes {
240 + name
241 + email
242 + user {
243 + login
244 + }
245 + }
246 + }
247 + }
248 + }
249 + }
250 + comments(first: 100, after: $commentsAfter) @include(if: $withComments) {
251 + pageInfo {
252 + hasNextPage
253 + endCursor
254 + }
255 + nodes {
256 + id
257 + body
258 + createdAt
259 + lastEditedAt
260 + url
261 + author {
262 + login
263 + avatarUrl
264 + ... on User {
265 + name
266 + }
267 + }
268 + }
269 + }
270 + reviews(first: 100, after: $reviewsAfter) @include(if: $withReviews) {
271 + pageInfo {
272 + hasNextPage
273 + endCursor
274 + }
275 + nodes {
276 + id
277 + body
278 + state
279 + submittedAt
280 + lastEditedAt
281 + url
282 + author {
283 + login
284 + avatarUrl
285 + ... on User {
286 + name
287 + }
288 + }
289 + }
290 + }
291 + }
292 + }
293 +}
294 +
295 +# Open pull requests whose head branch has one name, from whichever repository it lives in.
296 +query PullRequestHeads($owner: String!, $name: String!, $head: String!, $after: String) {
297 + repository(owner: $owner, name: $name) {
298 + pullRequests(first: 100, after: $after, states: [OPEN], headRefName: $head) {
299 + pageInfo {
300 + hasNextPage
301 + endCursor
302 + }
303 + nodes {
304 + number
305 + headRefOid
306 + isCrossRepository
307 + headRepositoryOwner {
308 + login
309 + }
310 + }
311 + }
312 + }
313 +}
314 +
315 +# The pull request's own node id, which is what a mutation against the pull request itself is
316 +# addressed by. Read only when one is being written: the conversation carries an id for every
317 +# remark in it, and the pull request is the one subject nothing in it names.
318 +query PullRequestNodeId($owner: String!, $name: String!, $number: Int!) {
319 + repository(owner: $owner, name: $name) {
320 + pullRequest(number: $number) {
321 + id
322 + }
323 + }
324 +}
325 +
326 +# Where a client-given subject actually hangs: the pull request itself, or the pull request an
327 +# issue comment, a review comment, or a review belongs to. Read before a mutation reaches it, so a
328 +# subject named for one pull request cannot write on another's behalf.
329 +query PullRequestSubject($owner: String!, $name: String!, $number: Int!, $subjectId: ID!) {
330 + repository(owner: $owner, name: $name) {
331 + pullRequest(number: $number) {
332 + id
333 + }
334 + }
335 + node(id: $subjectId) {
336 + id
337 + ... on IssueComment {
338 + pullRequest {
339 + id
340 + }
341 + }
342 + # Aliased apart: an issue comment's pull request is nullable, the other two are not.
343 + ... on PullRequestReviewComment {
344 + reviewCommentPullRequest: pullRequest {
345 + id
346 + }
347 + }
348 + ... on PullRequestReview {
349 + reviewPullRequest: pullRequest {
350 + id
351 + }
352 + }
353 + }
354 +}
355 +
356 +# Core detail and write checks share one read of permissions and merge settings.
357 +query ViewerPermissions($owner: String!, $name: String!, $number: Int!) {
358 + repository(owner: $owner, name: $name) {
359 + mergeCommitAllowed
360 + squashMergeAllowed
361 + rebaseMergeAllowed
362 + viewerPermission
363 + pullRequest(number: $number) {
364 + viewerCanUpdate
365 + viewerDidAuthor
366 + headRepository {
367 + viewerPermission
368 + }
369 + }
370 + }
371 +}
372 +
373 +# Who a review may be asked of, and who it has already been asked of, in one read.
374 +#
375 +# `assignableUsers` is the list GitHub's own reviewer picker is built from (everyone with access to
376 +# the repository) rather than `collaborators`, which the REST API refuses to anyone without push
377 +# access and which would therefore be empty for exactly the reader most likely to be looking.
378 +#
379 +# Teams are asked for only where one has already been requested, so a request to a team can be
380 +# taken back. The teams a repository could newly be sent to live on the owning organization and
381 +# need `read:org`, which a repository-scoped token need not carry, and a query GitHub refuses
382 +# fails whole, taking the people down with the teams.
383 +query ReviewerCandidates($owner: String!, $name: String!, $number: Int!) {
384 + repository(owner: $owner, name: $name) {
385 + assignableUsers(first: 100) {
386 + pageInfo {
387 + hasNextPage
388 + }
389 + nodes {
390 + login
391 + name
392 + avatarUrl
393 + }
394 + }
395 + pullRequest(number: $number) {
396 + author {
397 + login
398 + }
399 + reviewRequests(first: 100) {
400 + nodes {
401 + requestedReviewer {
402 + ... on User {
403 + login
404 + name
405 + avatarUrl
406 + }
407 + # Aliased apart from a person's: their nullability differs.
408 + ... on Team {
409 + slug
410 + combinedSlug
411 + teamName: name
412 + teamAvatarUrl: avatarUrl
413 + }
414 + ... on Bot {
415 + login
416 + avatarUrl
417 + }
418 + }
419 + }
420 + }
421 + }
422 + }
423 +}
424 +
425 +query LabelCandidates($owner: String!, $name: String!, $number: Int!) {
426 + repository(owner: $owner, name: $name) {
427 + labels(first: 100, orderBy: { field: NAME, direction: ASC }) {
428 + pageInfo {
429 + hasNextPage
430 + }
431 + nodes {
432 + name
433 + color
434 + description
435 + }
436 + }
437 + pullRequest(number: $number) {
438 + labels(first: 100) {
439 + nodes {
440 + name
441 + }
442 + }
443 + }
444 + }
445 +}
446 +
447 +# Which files of a pull request the signed-in account has cleared. GraphQL only, since the REST
448 +# files endpoint the patch is read from carries no viewed state, so this is a second read rather
449 +# than a wider version of the first.
450 +query PullRequestFilesViewed($owner: String!, $name: String!, $number: Int!, $after: String) {
451 + repository(owner: $owner, name: $name) {
452 + pullRequest(number: $number) {
453 + files(first: 100, after: $after) {
454 + pageInfo {
455 + hasNextPage
456 + endCursor
457 + }
458 + nodes {
459 + path
460 + viewerViewedState
461 + }
462 + }
463 + }
464 + }
465 +}
466 +
467 +# What a merge that rewrites its message reads first: GitHub's own message for the method, and
468 +# whether a merge queue will choose its own instead.
469 +query PullRequestMergeMessage(
470 + $owner: String!
471 + $name: String!
472 + $number: Int!
473 + $method: PullRequestMergeMethod!
474 +) {
475 + repository(owner: $owner, name: $name) {
476 + pullRequest(number: $number) {
477 + isMergeQueueEnabled
478 + headRefOid
479 + viewerMergeBodyText(mergeType: $method)
480 + }
481 + }
482 +}
483 +
484 +# What `gh pr merge` and `gh pr update-branch` read before they act.
485 +query PullRequestActionState($owner: String!, $name: String!, $number: Int!, $headRef: String!) {
486 + repository(owner: $owner, name: $name) {
487 + pullRequest(number: $number) {
488 + id
489 + headRefOid
490 + isMergeQueueEnabled
491 + mergeStateStatus
492 + baseRef {
493 + compare(headRef: $headRef) {
494 + behindBy
495 + }
496 + }
497 + }
498 + }
499 +}
500 +
501 +# What deleting a closed or merged pull request's source branch reads first: the branch, the
502 +# commit it should still point at, and the repository it lives in.
503 +query PullRequestBranchToDelete($owner: String!, $name: String!, $number: Int!) {
504 + repository(owner: $owner, name: $name) {
505 + pullRequest(number: $number) {
506 + state
507 + headRefName
508 + baseRefName
509 + headRefOid
510 + headRepository {
511 + id
512 + }
513 + }
514 + }
515 +}
516 +
517 +# The source branch as its own repository holds it now, beside that repository's default branch,
518 +# so a branch that moved on or is the default is never deleted.
519 +query PullRequestSourceBranch($repositoryId: ID!, $ref: String!) {
520 + node(id: $repositoryId) {
521 + ... on Repository {
522 + defaultBranchRef {
523 + name
524 + }
525 + ref(qualifiedName: $ref) {
526 + target {
527 + oid
528 + }
529 + }
530 + }
531 + }
532 +}
packages/source-control-github/src/server/pullRequestReads.graphql.ts new
+1490
@@ -0,0 +1,1490 @@
1 +// Generated by @effect/graphql-generator from pullRequestReads.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** Represents an individual commit status context */
7 +export const StatusContext = Schema.Struct({
8 + __typename: Schema.Literal("StatusContext"),
9 + /** The name of this status context. */
10 + context: Schema.String,
11 + /** The state of this status context. */
12 + state: GraphQL.enumLiterals(Shared.StatusState.literals),
13 + /** The URL for this status context. */
14 + targetUrl: Schema.NullOr(Shared.URI),
15 + /** Identifies the date and time when the object was created. */
16 + createdAt: Shared.DateTime,
17 + /** The description for this status context. */
18 + description: Schema.NullOr(Schema.String),
19 + /** Whether this is required to pass before merging for a specific pull request. */
20 + isRequired: Schema.optionalKey(Schema.Boolean)
21 +})
22 +export interface StatusContext extends Schema.Struct.Type<typeof StatusContext.fields> {}
23 +
24 +/** A workflow contains meta information about an Actions workflow file. */
25 +export const Workflow = Schema.Struct({
26 + /** The name of the workflow. */
27 + name: Schema.String
28 +})
29 +export interface Workflow extends Schema.Struct.Type<typeof Workflow.fields> {}
30 +
31 +/** A workflow run. */
32 +export const WorkflowRun = Schema.Struct({
33 + /** The workflow executed in this workflow run. */
34 + workflow: Workflow
35 +})
36 +export interface WorkflowRun extends Schema.Struct.Type<typeof WorkflowRun.fields> {}
37 +
38 +/** A check suite. */
39 +export const CheckSuite = Schema.Struct({
40 + /** The workflow run associated with this check suite. */
41 + workflowRun: Schema.NullOr(WorkflowRun)
42 +})
43 +export interface CheckSuite extends Schema.Struct.Type<typeof CheckSuite.fields> {}
44 +
45 +/** A check run. */
46 +export const CheckRun = Schema.Struct({
47 + __typename: Schema.Literal("CheckRun"),
48 + /** The name of the check for this check run. */
49 + name: Schema.String,
50 + /** The current status of the check run. */
51 + status: GraphQL.enumLiterals(Shared.CheckStatusState.literals),
52 + /** The conclusion of the check run. */
53 + conclusion: Schema.NullOr(GraphQL.enumLiterals(Shared.CheckConclusionState.literals)),
54 + /** Identifies the date and time when the check run was started. */
55 + startedAt: Schema.NullOr(Shared.DateTime),
56 + /** Identifies the date and time when the check run was completed. */
57 + completedAt: Schema.NullOr(Shared.DateTime),
58 + /** The URL from which to find full details of the check run on the integrator's site. */
59 + detailsUrl: Schema.NullOr(Shared.URI),
60 + /** Whether this is required to pass before merging for a specific pull request. */
61 + isRequired: Schema.optionalKey(Schema.Boolean),
62 + /** The check suite that this run is a part of. */
63 + checkSuite: CheckSuite
64 +})
65 +export interface CheckRun extends Schema.Struct.Type<typeof CheckRun.fields> {}
66 +
67 +/** Types that can be inside a StatusCheckRollup context. */
68 +export const StatusCheckRollupContextOther = Schema.Struct({
69 + __typename: GraphQL.otherTypename<Shared.Typename.StatusCheckRollupContext>()(["StatusContext", "CheckRun"])
70 +})
71 +export interface StatusCheckRollupContextOther extends Schema.Struct.Type<typeof StatusCheckRollupContextOther.fields> {}
72 +
73 +/**
74 + * `fragment CheckContext on StatusCheckRollupContext`
75 + *
76 + * Types that can be inside a StatusCheckRollup context.
77 + */
78 +export const CheckContext = Schema.Union([
79 + StatusContext,
80 + CheckRun,
81 + StatusCheckRollupContextOther
82 +])
83 +export type CheckContext = typeof CheckContext.Type
84 +
85 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
86 +export const ActorAvatarsNodesUser = Schema.Struct({
87 + __typename: Schema.Literal("User"),
88 + /** The username used to login. */
89 + login: Schema.String,
90 + /** A URL pointing to the user's public avatar. */
91 + avatarUrl: Shared.URI
92 +})
93 +export interface ActorAvatarsNodesUser extends Schema.Struct.Type<typeof ActorAvatarsNodesUser.fields> {}
94 +
95 +/** A special type of user which takes actions on behalf of GitHub Apps. */
96 +export const NodesBot = Schema.Struct({
97 + __typename: Schema.Literal("Bot"),
98 + /** The username of the actor. */
99 + login: Schema.String,
100 + /** A URL pointing to the GitHub App's public avatar. */
101 + avatarUrl: Shared.URI
102 +})
103 +export interface NodesBot extends Schema.Struct.Type<typeof NodesBot.fields> {}
104 +
105 +/** An object with an ID. */
106 +export const NodesNodeOther = Schema.Struct({
107 + __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["User", "Bot"])
108 +})
109 +export interface NodesNodeOther extends Schema.Struct.Type<typeof NodesNodeOther.fields> {}
110 +
111 +/** `query ActorAvatars` */
112 +export const ActorAvatars = GraphQL.query("ActorAvatars", {
113 + document: {
114 + variables: [
115 + { name: "ids", body: "[ID!]!" }
116 + ],
117 + selections: [
118 + { name: "nodes", body: ["(ids:$", "ids", "){__typename...on User{login avatarUrl}...on Bot{login avatarUrl}}"] }
119 + ],
120 + fragments: []
121 + },
122 + variables: {
123 + ids: Schema.Array(Shared.ID)
124 + },
125 + result: Schema.Struct({
126 + /** Lookup nodes by a list of IDs. */
127 + nodes: Schema.Array(Schema.NullOr(Schema.Union([
128 + ActorAvatarsNodesUser,
129 + NodesBot,
130 + NodesNodeOther
131 + ])))
132 + })
133 +})
134 +export declare namespace ActorAvatars {
135 + export type Variables = typeof ActorAvatars.variables.Type
136 + export type Result = typeof ActorAvatars.result.Type
137 +}
138 +
139 +/** Represents an owner of a Repository. */
140 +export const RepositoryOwner = Schema.Struct({
141 + __typename: GraphQL.otherTypename<Shared.Typename.RepositoryOwner>()([]),
142 + /** The username used to login. */
143 + login: Schema.String
144 +})
145 +export interface RepositoryOwner extends Schema.Struct.Type<typeof RepositoryOwner.fields> {}
146 +
147 +/** A repository contains the content for a project. */
148 +export const PullRequestCoreRepositoryPullRequestHeadRepositoryRepository = Schema.Struct({
149 + /** The repository's name with owner. */
150 + nameWithOwner: Schema.String,
151 + /** The users permission level on the repository. Will return null if authenticated as an GitHub App. */
152 + viewerPermission: Schema.NullOr(GraphQL.enumLiterals(Shared.RepositoryPermission.literals))
153 +})
154 +export interface PullRequestCoreRepositoryPullRequestHeadRepositoryRepository extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestHeadRepositoryRepository.fields> {}
155 +
156 +/** Represents a Git reference. */
157 +export const HeadRefRef = Schema.Struct({
158 + /** The Node ID of the Ref object */
159 + id: Shared.ID
160 +})
161 +export interface HeadRefRef extends Schema.Struct.Type<typeof HeadRefRef.fields> {}
162 +
163 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
164 +export const PullRequestCoreRepositoryPullRequestAuthorUser = Schema.Struct({
165 + __typename: Schema.Literal("User"),
166 + /** The username used to login. */
167 + login: Schema.String,
168 + /** A URL pointing to the user's public avatar. */
169 + avatarUrl: Shared.URI,
170 + /** The Node ID of the User object */
171 + id: Shared.ID,
172 + /** The user's public profile name. */
173 + name: Schema.NullOr(Schema.String)
174 +})
175 +export interface PullRequestCoreRepositoryPullRequestAuthorUser extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestAuthorUser.fields> {}
176 +
177 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
178 +export const ActorOther = Schema.Struct({
179 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()(["User"]),
180 + /** The username of the actor. */
181 + login: Schema.String,
182 + /** A URL pointing to the actor's public avatar. */
183 + avatarUrl: Shared.URI
184 +})
185 +export interface ActorOther extends Schema.Struct.Type<typeof ActorOther.fields> {}
186 +
187 +/** Represents an auto-merge request for a pull request */
188 +export const AutoMergeRequest = Schema.Struct({
189 + /**
190 + * The merge method of the auto-merge request. If a merge queue is required by
191 + * the base branch, this value will be set by the merge queue when merging.
192 + */
193 + mergeMethod: GraphQL.enumLiterals(Shared.PullRequestMergeMethod.literals)
194 +})
195 +export interface AutoMergeRequest extends Schema.Struct.Type<typeof AutoMergeRequest.fields> {}
196 +
197 +/** Represents a comparison between two commit revisions. */
198 +export const Comparison = Schema.Struct({
199 + /** The number of commits behind the base branch. */
200 + behindBy: Shared.Int
201 +})
202 +export interface Comparison extends Schema.Struct.Type<typeof Comparison.fields> {}
203 +
204 +/** Represents a Git reference. */
205 +export const BaseRefRef = Schema.Struct({
206 + /** Compares the current ref as a base ref to another head ref, if the comparison can be made. */
207 + compare: Schema.NullOr(Comparison)
208 +})
209 +export interface BaseRefRef extends Schema.Struct.Type<typeof BaseRefRef.fields> {}
210 +
211 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
212 +export const RequestedReviewerUser = Schema.Struct({
213 + __typename: Schema.Literal("User"),
214 + /** The username used to login. */
215 + login: Schema.String,
216 + /** The user's public profile name. */
217 + name: Schema.NullOr(Schema.String)
218 +})
219 +export interface RequestedReviewerUser extends Schema.Struct.Type<typeof RequestedReviewerUser.fields> {}
220 +
221 +/** A special type of user which takes actions on behalf of GitHub Apps. */
222 +export const RequestedReviewerBot = Schema.Struct({
223 + __typename: Schema.Literal("Bot"),
224 + /** The username of the actor. */
225 + login: Schema.String
226 +})
227 +export interface RequestedReviewerBot extends Schema.Struct.Type<typeof RequestedReviewerBot.fields> {}
228 +
229 +/** A team of users in an organization. */
230 +export const Team = Schema.Struct({
231 + __typename: Schema.Literal("Team"),
232 + /** The slug corresponding to the team. */
233 + slug: Schema.String,
234 + /** The slug corresponding to the organization and team. */
235 + combinedSlug: Schema.String,
236 + /** The name of the team. */
237 + teamName: Schema.String,
238 + /** A URL pointing to the team's avatar. */
239 + teamAvatarUrl: Schema.NullOr(Shared.URI)
240 +})
241 +export interface Team extends Schema.Struct.Type<typeof Team.fields> {}
242 +
243 +/** Types that can be requested reviewers. */
244 +export const RequestedReviewerOther = Schema.Struct({
245 + __typename: GraphQL.otherTypename<Shared.Typename.RequestedReviewer>()(["User", "Bot", "Team"])
246 +})
247 +export interface RequestedReviewerOther extends Schema.Struct.Type<typeof RequestedReviewerOther.fields> {}
248 +
249 +/** A request for a user to review a pull request. */
250 +export const PullRequestCoreRepositoryPullRequestReviewRequestsNodesReviewRequest = Schema.Struct({
251 + /** The reviewer that is requested. */
252 + requestedReviewer: Schema.NullOr(Schema.Union([
253 + RequestedReviewerUser,
254 + RequestedReviewerBot,
255 + Team,
256 + RequestedReviewerOther
257 + ]))
258 +})
259 +export interface PullRequestCoreRepositoryPullRequestReviewRequestsNodesReviewRequest extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestReviewRequestsNodesReviewRequest.fields> {}
260 +
261 +/** The connection type for ReviewRequest. */
262 +export const PullRequestCoreRepositoryPullRequestReviewRequestsReviewRequestConnection = Schema.Struct({
263 + /** A list of nodes. */
264 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCoreRepositoryPullRequestReviewRequestsNodesReviewRequest)))
265 +})
266 +export interface PullRequestCoreRepositoryPullRequestReviewRequestsReviewRequestConnection extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestReviewRequestsReviewRequestConnection.fields> {}
267 +
268 +/** A label for categorizing Issues, Pull Requests, Milestones, or Discussions with a given Repository. */
269 +export const PullRequestCoreRepositoryPullRequestLabelsNodesLabel = Schema.Struct({
270 + /** Identifies the label name. */
271 + name: Schema.String,
272 + /** Identifies the label color. */
273 + color: Schema.String
274 +})
275 +export interface PullRequestCoreRepositoryPullRequestLabelsNodesLabel extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestLabelsNodesLabel.fields> {}
276 +
277 +/** The connection type for Label. */
278 +export const PullRequestCoreRepositoryPullRequestLabelsLabelConnection = Schema.Struct({
279 + /** A list of nodes. */
280 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCoreRepositoryPullRequestLabelsNodesLabel)))
281 +})
282 +export interface PullRequestCoreRepositoryPullRequestLabelsLabelConnection extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestLabelsLabelConnection.fields> {}
283 +
284 +/** Information about pagination in a connection. */
285 +export const PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo = Schema.Struct({
286 + /** When paginating forwards, are there more items? */
287 + hasNextPage: Schema.Boolean
288 +})
289 +export interface PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo.fields> {}
290 +
291 +/** The connection type for StatusCheckRollupContext. */
292 +export const PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection = Schema.Struct({
293 + /** A list of nodes. */
294 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(CheckContext))),
295 + /** Information to aid in pagination. */
296 + pageInfo: PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo
297 +})
298 +export interface PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection.fields> {}
299 +
300 +/** Represents the rollup for both the check runs and status for a commit. */
301 +export const PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup = Schema.Struct({
302 + /** A list of status contexts and check runs for this commit. */
303 + contexts: PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection
304 +})
305 +export interface PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup.fields> {}
306 +
307 +/** Represents a Git commit. */
308 +export const PullRequestCoreRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
309 + /** Check and Status rollup information for this commit. */
310 + statusCheckRollup: Schema.NullOr(PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup)
311 +})
312 +export interface PullRequestCoreRepositoryPullRequestCommitsNodesCommitCommit extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsNodesCommitCommit.fields> {}
313 +
314 +/** Represents a Git commit part of a pull request. */
315 +export const PullRequestCoreRepositoryPullRequestCommitsNodesPullRequestCommit = Schema.Struct({
316 + /** The Git commit object */
317 + commit: PullRequestCoreRepositoryPullRequestCommitsNodesCommitCommit
318 +})
319 +export interface PullRequestCoreRepositoryPullRequestCommitsNodesPullRequestCommit extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsNodesPullRequestCommit.fields> {}
320 +
321 +/** The connection type for PullRequestCommit. */
322 +export const PullRequestCoreRepositoryPullRequestCommitsPullRequestCommitConnection = Schema.Struct({
323 + /** A list of nodes. */
324 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCoreRepositoryPullRequestCommitsNodesPullRequestCommit)))
325 +})
326 +export interface PullRequestCoreRepositoryPullRequestCommitsPullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestCommitsPullRequestCommitConnection.fields> {}
327 +
328 +/** A repository pull request. */
329 +export const PullRequestCoreRepositoryPullRequestPullRequest = Schema.Struct({
330 + /** Identifies the pull request number. */
331 + number: Shared.Int,
332 + /** Identifies the pull request title. */
333 + title: Schema.String,
334 + /** The HTTP URL for this pull request. */
335 + url: Shared.URI,
336 + /** The body as Markdown. */
337 + body: Schema.String,
338 + /** Identifies the state of the pull request. */
339 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
340 + /** Identifies if the pull request is a draft. */
341 + isDraft: Schema.Boolean,
342 + /** Whether or not the pull request can be merged based on the existence of merge conflicts. */
343 + mergeable: GraphQL.enumLiterals(Shared.MergeableState.literals),
344 + /** The current status of this pull request with respect to code review. */
345 + reviewDecision: Schema.NullOr(GraphQL.enumLiterals(Shared.PullRequestReviewDecision.literals)),
346 + /** The number of additions in this pull request. */
347 + additions: Shared.Int,
348 + /** The number of deletions in this pull request. */
349 + deletions: Shared.Int,
350 + /** The number of changed files in this pull request. */
351 + changedFiles: Shared.Int,
352 + /** Identifies the date and time when the object was created. */
353 + createdAt: Shared.DateTime,
354 + /** Identifies the date and time when the object was last updated. */
355 + updatedAt: Shared.DateTime,
356 + /** The date and time that the pull request was merged. */
357 + mergedAt: Schema.NullOr(Shared.DateTime),
358 + /** Identifies the date and time when the object was closed. */
359 + closedAt: Schema.NullOr(Shared.DateTime),
360 + /** Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. */
361 + headRefName: Schema.String,
362 + /** Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. */
363 + baseRefName: Schema.String,
364 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
365 + headRefOid: Shared.GitObjectID,
366 + /** The head and base repositories are different. */
367 + isCrossRepository: Schema.Boolean,
368 + /** The owner of the repository associated with this pull request's head Ref. */
369 + headRepositoryOwner: Schema.NullOr(RepositoryOwner),
370 + /** The repository associated with this pull request's head Ref. */
371 + headRepository: Schema.NullOr(PullRequestCoreRepositoryPullRequestHeadRepositoryRepository),
372 + /** Identifies the head Ref associated with the pull request. */
373 + headRef: Schema.NullOr(HeadRefRef),
374 + /** The actor who authored the comment. */
375 + author: Schema.NullOr(Schema.Union([
376 + PullRequestCoreRepositoryPullRequestAuthorUser,
377 + ActorOther
378 + ])),
379 + /** Returns the auto-merge request object if one exists for this pull request. */
380 + autoMergeRequest: Schema.NullOr(AutoMergeRequest),
381 + /** Check if the current viewer can update this object. */
382 + viewerCanUpdate: Schema.Boolean,
383 + /** Did the viewer author this comment. */
384 + viewerDidAuthor: Schema.Boolean,
385 + /**
386 + * Whether or not the viewer can update the head ref of this PR, by merging or rebasing the base ref.
387 + * If the head ref is up to date or unable to be updated by this user, this will return false.
388 + */
389 + viewerCanUpdateBranch: Schema.Boolean,
390 + /** Identifies the base Ref associated with the pull request. */
391 + baseRef: Schema.NullOr(BaseRefRef),
392 + /** A list of review requests associated with the pull request. */
393 + reviewRequests: Schema.NullOr(PullRequestCoreRepositoryPullRequestReviewRequestsReviewRequestConnection),
394 + /** A list of labels associated with the object. */
395 + labels: Schema.NullOr(PullRequestCoreRepositoryPullRequestLabelsLabelConnection),
396 + /** A list of commits present in this pull request's head branch not present in the base branch. */
397 + commits: PullRequestCoreRepositoryPullRequestCommitsPullRequestCommitConnection
398 +})
399 +export interface PullRequestCoreRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestCoreRepositoryPullRequestPullRequest.fields> {}
400 +
401 +/** A repository contains the content for a project. */
402 +export const PullRequestCoreRepositoryRepository = Schema.Struct({
403 + /** Whether or not PRs are merged with a merge commit on this repository. */
404 + mergeCommitAllowed: Schema.Boolean,
405 + /** Whether or not squash-merging is enabled on this repository. */
406 + squashMergeAllowed: Schema.Boolean,
407 + /** Whether or not rebase-merging is enabled on this repository. */
408 + rebaseMergeAllowed: Schema.Boolean,
409 + /** The users permission level on the repository. Will return null if authenticated as an GitHub App. */
410 + viewerPermission: Schema.NullOr(GraphQL.enumLiterals(Shared.RepositoryPermission.literals)),
411 + /** Returns a single pull request from the current repository by number. */
412 + pullRequest: Schema.NullOr(PullRequestCoreRepositoryPullRequestPullRequest)
413 +})
414 +export interface PullRequestCoreRepositoryRepository extends Schema.Struct.Type<typeof PullRequestCoreRepositoryRepository.fields> {}
415 +
416 +/** `query PullRequestCore` */
417 +export const PullRequestCore = GraphQL.query("PullRequestCore", {
418 + document: {
419 + variables: [
420 + { name: "owner", body: "String!" },
421 + { name: "name", body: "String!" },
422 + { name: "number", body: "Int!" },
423 + { name: "headRef", body: "String!" },
424 + { name: "required", body: "Boolean!" }
425 + ],
426 + selections: [
427 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerPermission pullRequest(number:$", "number", "){number title url body state isDraft mergeable reviewDecision additions deletions changedFiles createdAt updatedAt mergedAt closedAt headRefName baseRefName headRefOid isCrossRepository headRepositoryOwner{__typename login}headRepository{nameWithOwner viewerPermission}headRef{id}author{__typename login avatarUrl...on User{id name}}autoMergeRequest{mergeMethod}viewerCanUpdate viewerDidAuthor viewerCanUpdateBranch baseRef{compare(headRef:$", "headRef", "){behindBy}}reviewRequests(first:100){nodes{requestedReviewer{__typename...on User{login name}...on Bot{login}...on Team{slug combinedSlug teamName:name teamAvatarUrl:avatarUrl}}}}labels(first:100){nodes{name color}}commits(last:1){nodes{commit{statusCheckRollup{contexts(first:100){nodes{__typename...", "CheckContext", "}pageInfo{hasNextPage}}}}}}}}"] }
428 + ],
429 + fragments: [
430 + { name: "CheckContext", body: ["on StatusCheckRollupContext{__typename...on StatusContext{context state targetUrl createdAt description isRequired(pullRequestNumber:$", "number", ")@include(if:$", "required", ")}...on CheckRun{name status conclusion startedAt completedAt detailsUrl isRequired(pullRequestNumber:$", "number", ")@include(if:$", "required", ")checkSuite{workflowRun{workflow{name}}}}}"] }
431 + ]
432 + },
433 + variables: {
434 + owner: Schema.String,
435 + name: Schema.String,
436 + number: Shared.Int,
437 + headRef: Schema.String,
438 + required: Schema.Boolean
439 + },
440 + result: Schema.Struct({
441 + /** Lookup a given repository by the owner and repository name. */
442 + repository: Schema.NullOr(PullRequestCoreRepositoryRepository)
443 + })
444 +})
445 +export declare namespace PullRequestCore {
446 + export type Variables = typeof PullRequestCore.variables.Type
447 + export type Result = typeof PullRequestCore.result.Type
448 +}
449 +
450 +/** Information about pagination in a connection. */
451 +export const PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo = Schema.Struct({
452 + /** When paginating forwards, are there more items? */
453 + hasNextPage: Schema.Boolean,
454 + /** When paginating forwards, the cursor to continue. */
455 + endCursor: Schema.NullOr(Schema.String)
456 +})
457 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo.fields> {}
458 +
459 +/** The connection type for StatusCheckRollupContext. */
460 +export const PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection = Schema.Struct({
461 + /** A list of nodes. */
462 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(CheckContext))),
463 + /** Information to aid in pagination. */
464 + pageInfo: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo
465 +})
466 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection.fields> {}
467 +
468 +/** Represents the rollup for both the check runs and status for a commit. */
469 +export const PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup = Schema.Struct({
470 + /** A list of status contexts and check runs for this commit. */
471 + contexts: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsStatusCheckRollupContextConnection
472 +})
473 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup.fields> {}
474 +
475 +/** Represents a Git commit. */
476 +export const PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
477 + /** Check and Status rollup information for this commit. */
478 + statusCheckRollup: Schema.NullOr(PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupStatusCheckRollup)
479 +})
480 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitCommit extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitCommit.fields> {}
481 +
482 +/** Represents a Git commit part of a pull request. */
483 +export const PullRequestCheckContextsRepositoryPullRequestCommitsNodesPullRequestCommit = Schema.Struct({
484 + /** The Git commit object */
485 + commit: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitCommit
486 +})
487 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsNodesPullRequestCommit extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsNodesPullRequestCommit.fields> {}
488 +
489 +/** The connection type for PullRequestCommit. */
490 +export const PullRequestCheckContextsRepositoryPullRequestCommitsPullRequestCommitConnection = Schema.Struct({
491 + /** A list of nodes. */
492 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCheckContextsRepositoryPullRequestCommitsNodesPullRequestCommit)))
493 +})
494 +export interface PullRequestCheckContextsRepositoryPullRequestCommitsPullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestCommitsPullRequestCommitConnection.fields> {}
495 +
496 +/** A repository pull request. */
497 +export const PullRequestCheckContextsRepositoryPullRequestPullRequest = Schema.Struct({
498 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
499 + headRefOid: Shared.GitObjectID,
500 + /** A list of commits present in this pull request's head branch not present in the base branch. */
501 + commits: PullRequestCheckContextsRepositoryPullRequestCommitsPullRequestCommitConnection
502 +})
503 +export interface PullRequestCheckContextsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryPullRequestPullRequest.fields> {}
504 +
505 +/** A repository contains the content for a project. */
506 +export const PullRequestCheckContextsRepositoryRepository = Schema.Struct({
507 + /** Returns a single pull request from the current repository by number. */
508 + pullRequest: Schema.NullOr(PullRequestCheckContextsRepositoryPullRequestPullRequest)
509 +})
510 +export interface PullRequestCheckContextsRepositoryRepository extends Schema.Struct.Type<typeof PullRequestCheckContextsRepositoryRepository.fields> {}
511 +
512 +/** `query PullRequestCheckContexts` */
513 +export const PullRequestCheckContexts = GraphQL.query("PullRequestCheckContexts", {
514 + document: {
515 + variables: [
516 + { name: "owner", body: "String!" },
517 + { name: "name", body: "String!" },
518 + { name: "number", body: "Int!" },
519 + { name: "required", body: "Boolean!" },
520 + { name: "after", body: "String" }
521 + ],
522 + selections: [
523 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){headRefOid commits(last:1){nodes{commit{statusCheckRollup{contexts(first:100 after:$", "after", "){nodes{__typename...", "CheckContext", "}pageInfo{hasNextPage endCursor}}}}}}}}"] }
524 + ],
525 + fragments: [
526 + { name: "CheckContext", body: ["on StatusCheckRollupContext{__typename...on StatusContext{context state targetUrl createdAt description isRequired(pullRequestNumber:$", "number", ")@include(if:$", "required", ")}...on CheckRun{name status conclusion startedAt completedAt detailsUrl isRequired(pullRequestNumber:$", "number", ")@include(if:$", "required", ")checkSuite{workflowRun{workflow{name}}}}}"] }
527 + ]
528 + },
529 + variables: {
530 + owner: Schema.String,
531 + name: Schema.String,
532 + number: Shared.Int,
533 + required: Schema.Boolean,
534 + after: Schema.optional(Schema.NullOr(Schema.String))
535 + },
536 + result: Schema.Struct({
537 + /** Lookup a given repository by the owner and repository name. */
538 + repository: Schema.NullOr(PullRequestCheckContextsRepositoryRepository)
539 + })
540 +})
541 +export declare namespace PullRequestCheckContexts {
542 + export type Variables = typeof PullRequestCheckContexts.variables.Type
543 + export type Result = typeof PullRequestCheckContexts.result.Type
544 +}
545 +
546 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
547 +export const PullRequestPreviewRepositoryPullRequestAuthorUser = Schema.Struct({
548 + __typename: Schema.Literal("User"),
549 + /** The username used to login. */
550 + login: Schema.String,
551 + /** A URL pointing to the user's public avatar. */
552 + avatarUrl: Shared.URI,
553 + /** The user's public profile name. */
554 + name: Schema.NullOr(Schema.String)
555 +})
556 +export interface PullRequestPreviewRepositoryPullRequestAuthorUser extends Schema.Struct.Type<typeof PullRequestPreviewRepositoryPullRequestAuthorUser.fields> {}
557 +
558 +/** A repository pull request. */
559 +export const PullRequestPreviewRepositoryPullRequestPullRequest = Schema.Struct({
560 + /** Identifies the pull request number. */
561 + number: Shared.Int,
562 + /** Identifies the pull request title. */
563 + title: Schema.String,
564 + /** The HTTP URL for this pull request. */
565 + url: Shared.URI,
566 + /** Identifies the state of the pull request. */
567 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
568 + /** Identifies if the pull request is a draft. */
569 + isDraft: Schema.Boolean,
570 + /** Identifies the date and time when the object was created. */
571 + createdAt: Shared.DateTime,
572 + /** The actor who authored the comment. */
573 + author: Schema.NullOr(Schema.Union([
574 + PullRequestPreviewRepositoryPullRequestAuthorUser,
575 + ActorOther
576 + ]))
577 +})
578 +export interface PullRequestPreviewRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestPreviewRepositoryPullRequestPullRequest.fields> {}
579 +
580 +/** A repository contains the content for a project. */
581 +export const PullRequestPreviewRepositoryRepository = Schema.Struct({
582 + /** Returns a single pull request from the current repository by number. */
583 + pullRequest: Schema.NullOr(PullRequestPreviewRepositoryPullRequestPullRequest)
584 +})
585 +export interface PullRequestPreviewRepositoryRepository extends Schema.Struct.Type<typeof PullRequestPreviewRepositoryRepository.fields> {}
586 +
587 +/** `query PullRequestPreview` */
588 +export const PullRequestPreview = GraphQL.query("PullRequestPreview", {
589 + document: {
590 + variables: [
591 + { name: "owner", body: "String!" },
592 + { name: "name", body: "String!" },
593 + { name: "number", body: "Int!" }
594 + ],
595 + selections: [
596 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){number title url state isDraft createdAt author{__typename login avatarUrl...on User{name}}}}"] }
597 + ],
598 + fragments: []
599 + },
600 + variables: {
601 + owner: Schema.String,
602 + name: Schema.String,
603 + number: Shared.Int
604 + },
605 + result: Schema.Struct({
606 + /** Lookup a given repository by the owner and repository name. */
607 + repository: Schema.NullOr(PullRequestPreviewRepositoryRepository)
608 + })
609 +})
610 +export declare namespace PullRequestPreview {
611 + export type Variables = typeof PullRequestPreview.variables.Type
612 + export type Result = typeof PullRequestPreview.result.Type
613 +}
614 +
615 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
616 +export const UserUser = Schema.Struct({
617 + /** The username used to login. */
618 + login: Schema.String
619 +})
620 +export interface UserUser extends Schema.Struct.Type<typeof UserUser.fields> {}
621 +
622 +/** Represents an actor in a Git commit (ie. an author or committer). */
623 +export const GitActor = Schema.Struct({
624 + /** The name in the Git commit. */
625 + name: Schema.NullOr(Schema.String),
626 + /** The email in the Git commit. */
627 + email: Schema.NullOr(Schema.String),
628 + /** The GitHub user corresponding to the email field. Null if no such user exists. */
629 + user: Schema.NullOr(UserUser)
630 +})
631 +export interface GitActor extends Schema.Struct.Type<typeof GitActor.fields> {}
632 +
633 +/** The connection type for GitActor. */
634 +export const GitActorConnection = Schema.Struct({
635 + /** A list of nodes. */
636 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(GitActor)))
637 +})
638 +export interface GitActorConnection extends Schema.Struct.Type<typeof GitActorConnection.fields> {}
639 +
640 +/** Represents a Git commit. */
641 +export const PullRequestActivityRepositoryPullRequestCommitsNodesCommitCommit = Schema.Struct({
642 + /** The Git object ID */
643 + oid: Shared.GitObjectID,
644 + /** The Git commit message headline */
645 + messageHeadline: Schema.String,
646 + /** The datetime when this commit was committed. */
647 + committedDate: Shared.DateTime,
648 + /**
649 + * The list of authors for this commit based on the git author and the Co-authored-by
650 + * message trailer. The git author will always be first.
651 + */
652 + authors: GitActorConnection
653 +})
654 +export interface PullRequestActivityRepositoryPullRequestCommitsNodesCommitCommit extends Schema.Struct.Type<typeof PullRequestActivityRepositoryPullRequestCommitsNodesCommitCommit.fields> {}
655 +
656 +/** Represents a Git commit part of a pull request. */
657 +export const PullRequestActivityRepositoryPullRequestCommitsNodesPullRequestCommit = Schema.Struct({
658 + /** The Git commit object */
659 + commit: PullRequestActivityRepositoryPullRequestCommitsNodesCommitCommit
660 +})
661 +export interface PullRequestActivityRepositoryPullRequestCommitsNodesPullRequestCommit extends Schema.Struct.Type<typeof PullRequestActivityRepositoryPullRequestCommitsNodesPullRequestCommit.fields> {}
662 +
663 +/** The connection type for PullRequestCommit. */
664 +export const PullRequestActivityRepositoryPullRequestCommitsPullRequestCommitConnection = Schema.Struct({
665 + /** A list of nodes. */
666 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestActivityRepositoryPullRequestCommitsNodesPullRequestCommit)))
667 +})
668 +export interface PullRequestActivityRepositoryPullRequestCommitsPullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestActivityRepositoryPullRequestCommitsPullRequestCommitConnection.fields> {}
669 +
670 +/** Represents a comment on an Issue. */
671 +export const NodesIssueComment = Schema.Struct({
672 + /** The Node ID of the IssueComment object */
673 + id: Shared.ID,
674 + /** The body as Markdown. */
675 + body: Schema.String,
676 + /** Identifies the date and time when the object was created. */
677 + createdAt: Shared.DateTime,
678 + /** The moment the editor made the last edit */
679 + lastEditedAt: Schema.NullOr(Shared.DateTime),
680 + /** The HTTP URL for this issue comment */
681 + url: Shared.URI,
682 + /** The actor who authored the comment. */
683 + author: Schema.NullOr(Schema.Union([
684 + PullRequestPreviewRepositoryPullRequestAuthorUser,
685 + ActorOther
686 + ]))
687 +})
688 +export interface NodesIssueComment extends Schema.Struct.Type<typeof NodesIssueComment.fields> {}
689 +
690 +/** The connection type for IssueComment. */
691 +export const IssueCommentConnection = Schema.Struct({
692 + /** Information to aid in pagination. */
693 + pageInfo: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
694 + /** A list of nodes. */
695 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(NodesIssueComment)))
696 +})
697 +export interface IssueCommentConnection extends Schema.Struct.Type<typeof IssueCommentConnection.fields> {}
698 +
699 +/** A review object for a given pull request. */
700 +export const NodesPullRequestReview = Schema.Struct({
701 + /** The Node ID of the PullRequestReview object */
702 + id: Shared.ID,
703 + /** Identifies the pull request review body. */
704 + body: Schema.String,
705 + /** Identifies the current state of the pull request review. */
706 + state: GraphQL.enumLiterals(Shared.PullRequestReviewState.literals),
707 + /** Identifies when the Pull Request Review was submitted */
708 + submittedAt: Schema.NullOr(Shared.DateTime),
709 + /** The moment the editor made the last edit */
710 + lastEditedAt: Schema.NullOr(Shared.DateTime),
711 + /** The HTTP URL permalink for this PullRequestReview. */
712 + url: Shared.URI,
713 + /** The actor who authored the comment. */
714 + author: Schema.NullOr(Schema.Union([
715 + PullRequestPreviewRepositoryPullRequestAuthorUser,
716 + ActorOther
717 + ]))
718 +})
719 +export interface NodesPullRequestReview extends Schema.Struct.Type<typeof NodesPullRequestReview.fields> {}
720 +
721 +/** The connection type for PullRequestReview. */
722 +export const PullRequestReviewConnection = Schema.Struct({
723 + /** Information to aid in pagination. */
724 + pageInfo: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
725 + /** A list of nodes. */
726 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(NodesPullRequestReview)))
727 +})
728 +export interface PullRequestReviewConnection extends Schema.Struct.Type<typeof PullRequestReviewConnection.fields> {}
729 +
730 +/** A repository pull request. */
731 +export const PullRequestActivityRepositoryPullRequestPullRequest = Schema.Struct({
732 + /** The actor who authored the comment. */
733 + author: Schema.optionalKey(Schema.NullOr(Schema.Union([
734 + PullRequestPreviewRepositoryPullRequestAuthorUser,
735 + ActorOther
736 + ]))),
737 + /** A list of commits present in this pull request's head branch not present in the base branch. */
738 + commits: Schema.optionalKey(PullRequestActivityRepositoryPullRequestCommitsPullRequestCommitConnection),
739 + /** A list of comments associated with the pull request. */
740 + comments: Schema.optionalKey(IssueCommentConnection),
741 + /** A list of reviews associated with the pull request. */
742 + reviews: Schema.optionalKey(Schema.NullOr(PullRequestReviewConnection))
743 +})
744 +export interface PullRequestActivityRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestActivityRepositoryPullRequestPullRequest.fields> {}
745 +
746 +/** A repository contains the content for a project. */
747 +export const PullRequestActivityRepositoryRepository = Schema.Struct({
748 + /** Returns a single pull request from the current repository by number. */
749 + pullRequest: Schema.NullOr(PullRequestActivityRepositoryPullRequestPullRequest)
750 +})
751 +export interface PullRequestActivityRepositoryRepository extends Schema.Struct.Type<typeof PullRequestActivityRepositoryRepository.fields> {}
752 +
753 +/** `query PullRequestActivity` */
754 +export const PullRequestActivity = GraphQL.query("PullRequestActivity", {
755 + document: {
756 + variables: [
757 + { name: "owner", body: "String!" },
758 + { name: "name", body: "String!" },
759 + { name: "number", body: "Int!" },
760 + { name: "head", body: "Boolean!" },
761 + { name: "withComments", body: "Boolean!" },
762 + { name: "commentsAfter", body: "String" },
763 + { name: "withReviews", body: "Boolean!" },
764 + { name: "reviewsAfter", body: "String" }
765 + ],
766 + selections: [
767 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){author@include(if:$", "head", "){__typename login avatarUrl...on User{name}}commits(last:100)@include(if:$", "head", "){nodes{commit{oid messageHeadline committedDate authors(first:10){nodes{name email user{login}}}}}}comments(first:100 after:$", "commentsAfter", ")@include(if:$", "withComments", "){pageInfo{hasNextPage endCursor}nodes{id body createdAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}reviews(first:100 after:$", "reviewsAfter", ")@include(if:$", "withReviews", "){pageInfo{hasNextPage endCursor}nodes{id body state submittedAt lastEditedAt url author{__typename login avatarUrl...on User{name}}}}}}"] }
768 + ],
769 + fragments: []
770 + },
771 + variables: {
772 + owner: Schema.String,
773 + name: Schema.String,
774 + number: Shared.Int,
775 + head: Schema.Boolean,
776 + withComments: Schema.Boolean,
777 + commentsAfter: Schema.optional(Schema.NullOr(Schema.String)),
778 + withReviews: Schema.Boolean,
779 + reviewsAfter: Schema.optional(Schema.NullOr(Schema.String))
780 + },
781 + result: Schema.Struct({
782 + /** Lookup a given repository by the owner and repository name. */
783 + repository: Schema.NullOr(PullRequestActivityRepositoryRepository)
784 + })
785 +})
786 +export declare namespace PullRequestActivity {
787 + export type Variables = typeof PullRequestActivity.variables.Type
788 + export type Result = typeof PullRequestActivity.result.Type
789 +}
790 +
791 +/** A repository pull request. */
792 +export const NodesPullRequest = Schema.Struct({
793 + /** Identifies the pull request number. */
794 + number: Shared.Int,
795 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
796 + headRefOid: Shared.GitObjectID,
797 + /** The head and base repositories are different. */
798 + isCrossRepository: Schema.Boolean,
799 + /** The owner of the repository associated with this pull request's head Ref. */
800 + headRepositoryOwner: Schema.NullOr(RepositoryOwner)
801 +})
802 +export interface NodesPullRequest extends Schema.Struct.Type<typeof NodesPullRequest.fields> {}
803 +
804 +/** The connection type for PullRequest. */
805 +export const PullRequestConnection = Schema.Struct({
806 + /** Information to aid in pagination. */
807 + pageInfo: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
808 + /** A list of nodes. */
809 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(NodesPullRequest)))
810 +})
811 +export interface PullRequestConnection extends Schema.Struct.Type<typeof PullRequestConnection.fields> {}
812 +
813 +/** A repository contains the content for a project. */
814 +export const PullRequestHeadsRepositoryRepository = Schema.Struct({
815 + /** A list of pull requests that have been opened in the repository. */
816 + pullRequests: PullRequestConnection
817 +})
818 +export interface PullRequestHeadsRepositoryRepository extends Schema.Struct.Type<typeof PullRequestHeadsRepositoryRepository.fields> {}
819 +
820 +/** `query PullRequestHeads` */
821 +export const PullRequestHeads = GraphQL.query("PullRequestHeads", {
822 + document: {
823 + variables: [
824 + { name: "owner", body: "String!" },
825 + { name: "name", body: "String!" },
826 + { name: "head", body: "String!" },
827 + { name: "after", body: "String" }
828 + ],
829 + selections: [
830 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequests(first:100 after:$", "after", " states:[OPEN]headRefName:$", "head", "){pageInfo{hasNextPage endCursor}nodes{number headRefOid isCrossRepository headRepositoryOwner{__typename login}}}}"] }
831 + ],
832 + fragments: []
833 + },
834 + variables: {
835 + owner: Schema.String,
836 + name: Schema.String,
837 + head: Schema.String,
838 + after: Schema.optional(Schema.NullOr(Schema.String))
839 + },
840 + result: Schema.Struct({
841 + /** Lookup a given repository by the owner and repository name. */
842 + repository: Schema.NullOr(PullRequestHeadsRepositoryRepository)
843 + })
844 +})
845 +export declare namespace PullRequestHeads {
846 + export type Variables = typeof PullRequestHeads.variables.Type
847 + export type Result = typeof PullRequestHeads.result.Type
848 +}
849 +
850 +/** A repository pull request. */
851 +export const PullRequestNodeIdRepositoryPullRequestPullRequest = Schema.Struct({
852 + /** The Node ID of the PullRequest object */
853 + id: Shared.ID
854 +})
855 +export interface PullRequestNodeIdRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestNodeIdRepositoryPullRequestPullRequest.fields> {}
856 +
857 +/** A repository contains the content for a project. */
858 +export const PullRequestNodeIdRepositoryRepository = Schema.Struct({
859 + /** Returns a single pull request from the current repository by number. */
860 + pullRequest: Schema.NullOr(PullRequestNodeIdRepositoryPullRequestPullRequest)
861 +})
862 +export interface PullRequestNodeIdRepositoryRepository extends Schema.Struct.Type<typeof PullRequestNodeIdRepositoryRepository.fields> {}
863 +
864 +/** `query PullRequestNodeId` */
865 +export const PullRequestNodeId = GraphQL.query("PullRequestNodeId", {
866 + document: {
867 + variables: [
868 + { name: "owner", body: "String!" },
869 + { name: "name", body: "String!" },
870 + { name: "number", body: "Int!" }
871 + ],
872 + selections: [
873 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){id}}"] }
874 + ],
875 + fragments: []
876 + },
877 + variables: {
878 + owner: Schema.String,
879 + name: Schema.String,
880 + number: Shared.Int
881 + },
882 + result: Schema.Struct({
883 + /** Lookup a given repository by the owner and repository name. */
884 + repository: Schema.NullOr(PullRequestNodeIdRepositoryRepository)
885 + })
886 +})
887 +export declare namespace PullRequestNodeId {
888 + export type Variables = typeof PullRequestNodeId.variables.Type
889 + export type Result = typeof PullRequestNodeId.result.Type
890 +}
891 +
892 +/** Represents a comment on an Issue. */
893 +export const NodeIssueComment = Schema.Struct({
894 + __typename: Schema.Literal("IssueComment"),
895 + /** The Node ID of the IssueComment object */
896 + id: Shared.ID,
897 + /**
898 + * Returns the pull request associated with the comment, if this comment was made on a
899 + * pull request.
900 + */
901 + pullRequest: Schema.NullOr(PullRequestNodeIdRepositoryPullRequestPullRequest)
902 +})
903 +export interface NodeIssueComment extends Schema.Struct.Type<typeof NodeIssueComment.fields> {}
904 +
905 +/** A review comment associated with a given repository pull request. */
906 +export const PullRequestReviewComment = Schema.Struct({
907 + __typename: Schema.Literal("PullRequestReviewComment"),
908 + /** The Node ID of the PullRequestReviewComment object */
909 + id: Shared.ID,
910 + /** The pull request associated with this review comment. */
911 + reviewCommentPullRequest: PullRequestNodeIdRepositoryPullRequestPullRequest
912 +})
913 +export interface PullRequestReviewComment extends Schema.Struct.Type<typeof PullRequestReviewComment.fields> {}
914 +
915 +/** A review object for a given pull request. */
916 +export const NodePullRequestReview = Schema.Struct({
917 + __typename: Schema.Literal("PullRequestReview"),
918 + /** The Node ID of the PullRequestReview object */
919 + id: Shared.ID,
920 + /** Identifies the pull request associated with this pull request review. */
921 + reviewPullRequest: PullRequestNodeIdRepositoryPullRequestPullRequest
922 +})
923 +export interface NodePullRequestReview extends Schema.Struct.Type<typeof NodePullRequestReview.fields> {}
924 +
925 +/** An object with an ID. */
926 +export const PullRequestSubjectNodeNodeOther = Schema.Struct({
927 + __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["IssueComment", "PullRequestReviewComment", "PullRequestReview"]),
928 + /** ID of the object. */
929 + id: Shared.ID
930 +})
931 +export interface PullRequestSubjectNodeNodeOther extends Schema.Struct.Type<typeof PullRequestSubjectNodeNodeOther.fields> {}
932 +
933 +/** `query PullRequestSubject` */
934 +export const PullRequestSubject = GraphQL.query("PullRequestSubject", {
935 + document: {
936 + variables: [
937 + { name: "owner", body: "String!" },
938 + { name: "name", body: "String!" },
939 + { name: "number", body: "Int!" },
940 + { name: "subjectId", body: "ID!" }
941 + ],
942 + selections: [
943 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){id}}"] },
944 + { name: "node", body: ["(id:$", "subjectId", "){__typename id...on IssueComment{pullRequest{id}}...on PullRequestReviewComment{reviewCommentPullRequest:pullRequest{id}}...on PullRequestReview{reviewPullRequest:pullRequest{id}}}"] }
945 + ],
946 + fragments: []
947 + },
948 + variables: {
949 + owner: Schema.String,
950 + name: Schema.String,
951 + number: Shared.Int,
952 + subjectId: Shared.ID
953 + },
954 + result: Schema.Struct({
955 + /** Lookup a given repository by the owner and repository name. */
956 + repository: Schema.NullOr(PullRequestNodeIdRepositoryRepository),
957 + /** Fetches an object given its ID. */
958 + node: Schema.NullOr(Schema.Union([
959 + NodeIssueComment,
960 + PullRequestReviewComment,
961 + NodePullRequestReview,
962 + PullRequestSubjectNodeNodeOther
963 + ]))
964 + })
965 +})
966 +export declare namespace PullRequestSubject {
967 + export type Variables = typeof PullRequestSubject.variables.Type
968 + export type Result = typeof PullRequestSubject.result.Type
969 +}
970 +
971 +/** A repository contains the content for a project. */
972 +export const ViewerPermissionsRepositoryPullRequestHeadRepositoryRepository = Schema.Struct({
973 + /** The users permission level on the repository. Will return null if authenticated as an GitHub App. */
974 + viewerPermission: Schema.NullOr(GraphQL.enumLiterals(Shared.RepositoryPermission.literals))
975 +})
976 +export interface ViewerPermissionsRepositoryPullRequestHeadRepositoryRepository extends Schema.Struct.Type<typeof ViewerPermissionsRepositoryPullRequestHeadRepositoryRepository.fields> {}
977 +
978 +/** A repository pull request. */
979 +export const ViewerPermissionsRepositoryPullRequestPullRequest = Schema.Struct({
980 + /** Check if the current viewer can update this object. */
981 + viewerCanUpdate: Schema.Boolean,
982 + /** Did the viewer author this comment. */
983 + viewerDidAuthor: Schema.Boolean,
984 + /** The repository associated with this pull request's head Ref. */
985 + headRepository: Schema.NullOr(ViewerPermissionsRepositoryPullRequestHeadRepositoryRepository)
986 +})
987 +export interface ViewerPermissionsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof ViewerPermissionsRepositoryPullRequestPullRequest.fields> {}
988 +
989 +/** A repository contains the content for a project. */
990 +export const ViewerPermissionsRepositoryRepository = Schema.Struct({
991 + /** Whether or not PRs are merged with a merge commit on this repository. */
992 + mergeCommitAllowed: Schema.Boolean,
993 + /** Whether or not squash-merging is enabled on this repository. */
994 + squashMergeAllowed: Schema.Boolean,
995 + /** Whether or not rebase-merging is enabled on this repository. */
996 + rebaseMergeAllowed: Schema.Boolean,
997 + /** The users permission level on the repository. Will return null if authenticated as an GitHub App. */
998 + viewerPermission: Schema.NullOr(GraphQL.enumLiterals(Shared.RepositoryPermission.literals)),
999 + /** Returns a single pull request from the current repository by number. */
1000 + pullRequest: Schema.NullOr(ViewerPermissionsRepositoryPullRequestPullRequest)
1001 +})
1002 +export interface ViewerPermissionsRepositoryRepository extends Schema.Struct.Type<typeof ViewerPermissionsRepositoryRepository.fields> {}
1003 +
1004 +/** `query ViewerPermissions` */
1005 +export const ViewerPermissions = GraphQL.query("ViewerPermissions", {
1006 + document: {
1007 + variables: [
1008 + { name: "owner", body: "String!" },
1009 + { name: "name", body: "String!" },
1010 + { name: "number", body: "Int!" }
1011 + ],
1012 + selections: [
1013 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed viewerPermission pullRequest(number:$", "number", "){viewerCanUpdate viewerDidAuthor headRepository{viewerPermission}}}"] }
1014 + ],
1015 + fragments: []
1016 + },
1017 + variables: {
1018 + owner: Schema.String,
1019 + name: Schema.String,
1020 + number: Shared.Int
1021 + },
1022 + result: Schema.Struct({
1023 + /** Lookup a given repository by the owner and repository name. */
1024 + repository: Schema.NullOr(ViewerPermissionsRepositoryRepository)
1025 + })
1026 +})
1027 +export declare namespace ViewerPermissions {
1028 + export type Variables = typeof ViewerPermissions.variables.Type
1029 + export type Result = typeof ViewerPermissions.result.Type
1030 +}
1031 +
1032 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
1033 +export const AssignableUsersNodesUser = Schema.Struct({
1034 + /** The username used to login. */
1035 + login: Schema.String,
1036 + /** The user's public profile name. */
1037 + name: Schema.NullOr(Schema.String),
1038 + /** A URL pointing to the user's public avatar. */
1039 + avatarUrl: Shared.URI
1040 +})
1041 +export interface AssignableUsersNodesUser extends Schema.Struct.Type<typeof AssignableUsersNodesUser.fields> {}
1042 +
1043 +/** A list of users. */
1044 +export const UserConnection = Schema.Struct({
1045 + /** Information to aid in pagination. */
1046 + pageInfo: PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
1047 + /** A list of nodes. */
1048 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(AssignableUsersNodesUser)))
1049 +})
1050 +export interface UserConnection extends Schema.Struct.Type<typeof UserConnection.fields> {}
1051 +
1052 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
1053 +export const Actor = Schema.Struct({
1054 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()([]),
1055 + /** The username of the actor. */
1056 + login: Schema.String
1057 +})
1058 +export interface Actor extends Schema.Struct.Type<typeof Actor.fields> {}
1059 +
1060 +/** A request for a user to review a pull request. */
1061 +export const ReviewerCandidatesRepositoryPullRequestReviewRequestsNodesReviewRequest = Schema.Struct({
1062 + /** The reviewer that is requested. */
1063 + requestedReviewer: Schema.NullOr(Schema.Union([
1064 + PullRequestPreviewRepositoryPullRequestAuthorUser,
1065 + Team,
1066 + NodesBot,
1067 + RequestedReviewerOther
1068 + ]))
1069 +})
1070 +export interface ReviewerCandidatesRepositoryPullRequestReviewRequestsNodesReviewRequest extends Schema.Struct.Type<typeof ReviewerCandidatesRepositoryPullRequestReviewRequestsNodesReviewRequest.fields> {}
1071 +
1072 +/** The connection type for ReviewRequest. */
1073 +export const ReviewerCandidatesRepositoryPullRequestReviewRequestsReviewRequestConnection = Schema.Struct({
1074 + /** A list of nodes. */
1075 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ReviewerCandidatesRepositoryPullRequestReviewRequestsNodesReviewRequest)))
1076 +})
1077 +export interface ReviewerCandidatesRepositoryPullRequestReviewRequestsReviewRequestConnection extends Schema.Struct.Type<typeof ReviewerCandidatesRepositoryPullRequestReviewRequestsReviewRequestConnection.fields> {}
1078 +
1079 +/** A repository pull request. */
1080 +export const ReviewerCandidatesRepositoryPullRequestPullRequest = Schema.Struct({
1081 + /** The actor who authored the comment. */
1082 + author: Schema.NullOr(Actor),
1083 + /** A list of review requests associated with the pull request. */
1084 + reviewRequests: Schema.NullOr(ReviewerCandidatesRepositoryPullRequestReviewRequestsReviewRequestConnection)
1085 +})
1086 +export interface ReviewerCandidatesRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof ReviewerCandidatesRepositoryPullRequestPullRequest.fields> {}
1087 +
1088 +/** A repository contains the content for a project. */
1089 +export const ReviewerCandidatesRepositoryRepository = Schema.Struct({
1090 + /** A list of users that can be assigned to issues in this repository. */
1091 + assignableUsers: UserConnection,
1092 + /** Returns a single pull request from the current repository by number. */
1093 + pullRequest: Schema.NullOr(ReviewerCandidatesRepositoryPullRequestPullRequest)
1094 +})
1095 +export interface ReviewerCandidatesRepositoryRepository extends Schema.Struct.Type<typeof ReviewerCandidatesRepositoryRepository.fields> {}
1096 +
1097 +/** `query ReviewerCandidates` */
1098 +export const ReviewerCandidates = GraphQL.query("ReviewerCandidates", {
1099 + document: {
1100 + variables: [
1101 + { name: "owner", body: "String!" },
1102 + { name: "name", body: "String!" },
1103 + { name: "number", body: "Int!" }
1104 + ],
1105 + selections: [
1106 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){assignableUsers(first:100){pageInfo{hasNextPage}nodes{login name avatarUrl}}pullRequest(number:$", "number", "){author{__typename login}reviewRequests(first:100){nodes{requestedReviewer{__typename...on User{login name avatarUrl}...on Team{slug combinedSlug teamName:name teamAvatarUrl:avatarUrl}...on Bot{login avatarUrl}}}}}}"] }
1107 + ],
1108 + fragments: []
1109 + },
1110 + variables: {
1111 + owner: Schema.String,
1112 + name: Schema.String,
1113 + number: Shared.Int
1114 + },
1115 + result: Schema.Struct({
1116 + /** Lookup a given repository by the owner and repository name. */
1117 + repository: Schema.NullOr(ReviewerCandidatesRepositoryRepository)
1118 + })
1119 +})
1120 +export declare namespace ReviewerCandidates {
1121 + export type Variables = typeof ReviewerCandidates.variables.Type
1122 + export type Result = typeof ReviewerCandidates.result.Type
1123 +}
1124 +
1125 +/** A label for categorizing Issues, Pull Requests, Milestones, or Discussions with a given Repository. */
1126 +export const RepositoryLabelsNodesLabel = Schema.Struct({
1127 + /** Identifies the label name. */
1128 + name: Schema.String,
1129 + /** Identifies the label color. */
1130 + color: Schema.String,
1131 + /** A brief description of this label. */
1132 + description: Schema.NullOr(Schema.String)
1133 +})
1134 +export interface RepositoryLabelsNodesLabel extends Schema.Struct.Type<typeof RepositoryLabelsNodesLabel.fields> {}
1135 +
1136 +/** The connection type for Label. */
1137 +export const RepositoryLabelsLabelConnection = Schema.Struct({
1138 + /** Information to aid in pagination. */
1139 + pageInfo: PullRequestCoreRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
1140 + /** A list of nodes. */
1141 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(RepositoryLabelsNodesLabel)))
1142 +})
1143 +export interface RepositoryLabelsLabelConnection extends Schema.Struct.Type<typeof RepositoryLabelsLabelConnection.fields> {}
1144 +
1145 +/** A label for categorizing Issues, Pull Requests, Milestones, or Discussions with a given Repository. */
1146 +export const LabelCandidatesRepositoryPullRequestLabelsNodesLabel = Schema.Struct({
1147 + /** Identifies the label name. */
1148 + name: Schema.String
1149 +})
1150 +export interface LabelCandidatesRepositoryPullRequestLabelsNodesLabel extends Schema.Struct.Type<typeof LabelCandidatesRepositoryPullRequestLabelsNodesLabel.fields> {}
1151 +
1152 +/** The connection type for Label. */
1153 +export const LabelCandidatesRepositoryPullRequestLabelsLabelConnection = Schema.Struct({
1154 + /** A list of nodes. */
1155 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(LabelCandidatesRepositoryPullRequestLabelsNodesLabel)))
1156 +})
1157 +export interface LabelCandidatesRepositoryPullRequestLabelsLabelConnection extends Schema.Struct.Type<typeof LabelCandidatesRepositoryPullRequestLabelsLabelConnection.fields> {}
1158 +
1159 +/** A repository pull request. */
1160 +export const LabelCandidatesRepositoryPullRequestPullRequest = Schema.Struct({
1161 + /** A list of labels associated with the object. */
1162 + labels: Schema.NullOr(LabelCandidatesRepositoryPullRequestLabelsLabelConnection)
1163 +})
1164 +export interface LabelCandidatesRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof LabelCandidatesRepositoryPullRequestPullRequest.fields> {}
1165 +
1166 +/** A repository contains the content for a project. */
1167 +export const LabelCandidatesRepositoryRepository = Schema.Struct({
1168 + /** A list of labels associated with the repository. */
1169 + labels: Schema.NullOr(RepositoryLabelsLabelConnection),
1170 + /** Returns a single pull request from the current repository by number. */
1171 + pullRequest: Schema.NullOr(LabelCandidatesRepositoryPullRequestPullRequest)
1172 +})
1173 +export interface LabelCandidatesRepositoryRepository extends Schema.Struct.Type<typeof LabelCandidatesRepositoryRepository.fields> {}
1174 +
1175 +/** `query LabelCandidates` */
1176 +export const LabelCandidates = GraphQL.query("LabelCandidates", {
1177 + document: {
1178 + variables: [
1179 + { name: "owner", body: "String!" },
1180 + { name: "name", body: "String!" },
1181 + { name: "number", body: "Int!" }
1182 + ],
1183 + selections: [
1184 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){labels(first:100 orderBy:{field:NAME direction:ASC}){pageInfo{hasNextPage}nodes{name color description}}pullRequest(number:$", "number", "){labels(first:100){nodes{name}}}}"] }
1185 + ],
1186 + fragments: []
1187 + },
1188 + variables: {
1189 + owner: Schema.String,
1190 + name: Schema.String,
1191 + number: Shared.Int
1192 + },
1193 + result: Schema.Struct({
1194 + /** Lookup a given repository by the owner and repository name. */
1195 + repository: Schema.NullOr(LabelCandidatesRepositoryRepository)
1196 + })
1197 +})
1198 +export declare namespace LabelCandidates {
1199 + export type Variables = typeof LabelCandidates.variables.Type
1200 + export type Result = typeof LabelCandidates.result.Type
1201 +}
1202 +
1203 +/** A file changed in a pull request. */
1204 +export const PullRequestChangedFile = Schema.Struct({
1205 + /** The path of the file. */
1206 + path: Schema.String,
1207 + /** The state of the file for the viewer. */
1208 + viewerViewedState: GraphQL.enumLiterals(Shared.FileViewedState.literals)
1209 +})
1210 +export interface PullRequestChangedFile extends Schema.Struct.Type<typeof PullRequestChangedFile.fields> {}
1211 +
1212 +/** The connection type for PullRequestChangedFile. */
1213 +export const PullRequestChangedFileConnection = Schema.Struct({
1214 + /** Information to aid in pagination. */
1215 + pageInfo: PullRequestCheckContextsRepositoryPullRequestCommitsNodesCommitStatusCheckRollupContextsPageInfoPageInfo,
1216 + /** A list of nodes. */
1217 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestChangedFile)))
1218 +})
1219 +export interface PullRequestChangedFileConnection extends Schema.Struct.Type<typeof PullRequestChangedFileConnection.fields> {}
1220 +
1221 +/** A repository pull request. */
1222 +export const PullRequestFilesViewedRepositoryPullRequestPullRequest = Schema.Struct({
1223 + /** Lists the files changed within this pull request. */
1224 + files: Schema.NullOr(PullRequestChangedFileConnection)
1225 +})
1226 +export interface PullRequestFilesViewedRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestFilesViewedRepositoryPullRequestPullRequest.fields> {}
1227 +
1228 +/** A repository contains the content for a project. */
1229 +export const PullRequestFilesViewedRepositoryRepository = Schema.Struct({
1230 + /** Returns a single pull request from the current repository by number. */
1231 + pullRequest: Schema.NullOr(PullRequestFilesViewedRepositoryPullRequestPullRequest)
1232 +})
1233 +export interface PullRequestFilesViewedRepositoryRepository extends Schema.Struct.Type<typeof PullRequestFilesViewedRepositoryRepository.fields> {}
1234 +
1235 +/** `query PullRequestFilesViewed` */
1236 +export const PullRequestFilesViewed = GraphQL.query("PullRequestFilesViewed", {
1237 + document: {
1238 + variables: [
1239 + { name: "owner", body: "String!" },
1240 + { name: "name", body: "String!" },
1241 + { name: "number", body: "Int!" },
1242 + { name: "after", body: "String" }
1243 + ],
1244 + selections: [
1245 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){files(first:100 after:$", "after", "){pageInfo{hasNextPage endCursor}nodes{path viewerViewedState}}}}"] }
1246 + ],
1247 + fragments: []
1248 + },
1249 + variables: {
1250 + owner: Schema.String,
1251 + name: Schema.String,
1252 + number: Shared.Int,
1253 + after: Schema.optional(Schema.NullOr(Schema.String))
1254 + },
1255 + result: Schema.Struct({
1256 + /** Lookup a given repository by the owner and repository name. */
1257 + repository: Schema.NullOr(PullRequestFilesViewedRepositoryRepository)
1258 + })
1259 +})
1260 +export declare namespace PullRequestFilesViewed {
1261 + export type Variables = typeof PullRequestFilesViewed.variables.Type
1262 + export type Result = typeof PullRequestFilesViewed.result.Type
1263 +}
1264 +
1265 +/** A repository pull request. */
1266 +export const PullRequestMergeMessageRepositoryPullRequestPullRequest = Schema.Struct({
1267 + /** Indicates whether the pull request's base ref has a merge queue enabled. */
1268 + isMergeQueueEnabled: Schema.Boolean,
1269 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
1270 + headRefOid: Shared.GitObjectID,
1271 + /** The merge body text for the viewer and method. */
1272 + viewerMergeBodyText: Schema.String
1273 +})
1274 +export interface PullRequestMergeMessageRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestMergeMessageRepositoryPullRequestPullRequest.fields> {}
1275 +
1276 +/** A repository contains the content for a project. */
1277 +export const PullRequestMergeMessageRepositoryRepository = Schema.Struct({
1278 + /** Returns a single pull request from the current repository by number. */
1279 + pullRequest: Schema.NullOr(PullRequestMergeMessageRepositoryPullRequestPullRequest)
1280 +})
1281 +export interface PullRequestMergeMessageRepositoryRepository extends Schema.Struct.Type<typeof PullRequestMergeMessageRepositoryRepository.fields> {}
1282 +
1283 +/** `query PullRequestMergeMessage` */
1284 +export const PullRequestMergeMessage = GraphQL.query("PullRequestMergeMessage", {
1285 + document: {
1286 + variables: [
1287 + { name: "owner", body: "String!" },
1288 + { name: "name", body: "String!" },
1289 + { name: "number", body: "Int!" },
1290 + { name: "method", body: "PullRequestMergeMethod!" }
1291 + ],
1292 + selections: [
1293 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){isMergeQueueEnabled headRefOid viewerMergeBodyText(mergeType:$", "method", ")}}"] }
1294 + ],
1295 + fragments: []
1296 + },
1297 + variables: {
1298 + owner: Schema.String,
1299 + name: Schema.String,
1300 + number: Shared.Int,
1301 + method: Shared.PullRequestMergeMethod
1302 + },
1303 + result: Schema.Struct({
1304 + /** Lookup a given repository by the owner and repository name. */
1305 + repository: Schema.NullOr(PullRequestMergeMessageRepositoryRepository)
1306 + })
1307 +})
1308 +export declare namespace PullRequestMergeMessage {
1309 + export type Variables = typeof PullRequestMergeMessage.variables.Type
1310 + export type Result = typeof PullRequestMergeMessage.result.Type
1311 +}
1312 +
1313 +/** A repository pull request. */
1314 +export const PullRequestActionStateRepositoryPullRequestPullRequest = Schema.Struct({
1315 + /** The Node ID of the PullRequest object */
1316 + id: Shared.ID,
1317 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
1318 + headRefOid: Shared.GitObjectID,
1319 + /** Indicates whether the pull request's base ref has a merge queue enabled. */
1320 + isMergeQueueEnabled: Schema.Boolean,
1321 + /** Detailed information about the current pull request merge state status. */
1322 + mergeStateStatus: GraphQL.enumLiterals(Shared.MergeStateStatus.literals),
1323 + /** Identifies the base Ref associated with the pull request. */
1324 + baseRef: Schema.NullOr(BaseRefRef)
1325 +})
1326 +export interface PullRequestActionStateRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestActionStateRepositoryPullRequestPullRequest.fields> {}
1327 +
1328 +/** A repository contains the content for a project. */
1329 +export const PullRequestActionStateRepositoryRepository = Schema.Struct({
1330 + /** Returns a single pull request from the current repository by number. */
1331 + pullRequest: Schema.NullOr(PullRequestActionStateRepositoryPullRequestPullRequest)
1332 +})
1333 +export interface PullRequestActionStateRepositoryRepository extends Schema.Struct.Type<typeof PullRequestActionStateRepositoryRepository.fields> {}
1334 +
1335 +/** `query PullRequestActionState` */
1336 +export const PullRequestActionState = GraphQL.query("PullRequestActionState", {
1337 + document: {
1338 + variables: [
1339 + { name: "owner", body: "String!" },
1340 + { name: "name", body: "String!" },
1341 + { name: "number", body: "Int!" },
1342 + { name: "headRef", body: "String!" }
1343 + ],
1344 + selections: [
1345 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){id headRefOid isMergeQueueEnabled mergeStateStatus baseRef{compare(headRef:$", "headRef", "){behindBy}}}}"] }
1346 + ],
1347 + fragments: []
1348 + },
1349 + variables: {
1350 + owner: Schema.String,
1351 + name: Schema.String,
1352 + number: Shared.Int,
1353 + headRef: Schema.String
1354 + },
1355 + result: Schema.Struct({
1356 + /** Lookup a given repository by the owner and repository name. */
1357 + repository: Schema.NullOr(PullRequestActionStateRepositoryRepository)
1358 + })
1359 +})
1360 +export declare namespace PullRequestActionState {
1361 + export type Variables = typeof PullRequestActionState.variables.Type
1362 + export type Result = typeof PullRequestActionState.result.Type
1363 +}
1364 +
1365 +/** A repository contains the content for a project. */
1366 +export const PullRequestBranchToDeleteRepositoryPullRequestHeadRepositoryRepository = Schema.Struct({
1367 + /** The Node ID of the Repository object */
1368 + id: Shared.ID
1369 +})
1370 +export interface PullRequestBranchToDeleteRepositoryPullRequestHeadRepositoryRepository extends Schema.Struct.Type<typeof PullRequestBranchToDeleteRepositoryPullRequestHeadRepositoryRepository.fields> {}
1371 +
1372 +/** A repository pull request. */
1373 +export const PullRequestBranchToDeleteRepositoryPullRequestPullRequest = Schema.Struct({
1374 + /** Identifies the state of the pull request. */
1375 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
1376 + /** Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. */
1377 + headRefName: Schema.String,
1378 + /** Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. */
1379 + baseRefName: Schema.String,
1380 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
1381 + headRefOid: Shared.GitObjectID,
1382 + /** The repository associated with this pull request's head Ref. */
1383 + headRepository: Schema.NullOr(PullRequestBranchToDeleteRepositoryPullRequestHeadRepositoryRepository)
1384 +})
1385 +export interface PullRequestBranchToDeleteRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof PullRequestBranchToDeleteRepositoryPullRequestPullRequest.fields> {}
1386 +
1387 +/** A repository contains the content for a project. */
1388 +export const PullRequestBranchToDeleteRepositoryRepository = Schema.Struct({
1389 + /** Returns a single pull request from the current repository by number. */
1390 + pullRequest: Schema.NullOr(PullRequestBranchToDeleteRepositoryPullRequestPullRequest)
1391 +})
1392 +export interface PullRequestBranchToDeleteRepositoryRepository extends Schema.Struct.Type<typeof PullRequestBranchToDeleteRepositoryRepository.fields> {}
1393 +
1394 +/** `query PullRequestBranchToDelete` */
1395 +export const PullRequestBranchToDelete = GraphQL.query("PullRequestBranchToDelete", {
1396 + document: {
1397 + variables: [
1398 + { name: "owner", body: "String!" },
1399 + { name: "name", body: "String!" },
1400 + { name: "number", body: "Int!" }
1401 + ],
1402 + selections: [
1403 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){state headRefName baseRefName headRefOid headRepository{id}}}"] }
1404 + ],
1405 + fragments: []
1406 + },
1407 + variables: {
1408 + owner: Schema.String,
1409 + name: Schema.String,
1410 + number: Shared.Int
1411 + },
1412 + result: Schema.Struct({
1413 + /** Lookup a given repository by the owner and repository name. */
1414 + repository: Schema.NullOr(PullRequestBranchToDeleteRepositoryRepository)
1415 + })
1416 +})
1417 +export declare namespace PullRequestBranchToDelete {
1418 + export type Variables = typeof PullRequestBranchToDelete.variables.Type
1419 + export type Result = typeof PullRequestBranchToDelete.result.Type
1420 +}
1421 +
1422 +/** Represents a Git reference. */
1423 +export const DefaultBranchRefRef = Schema.Struct({
1424 + /** The ref name. */
1425 + name: Schema.String
1426 +})
1427 +export interface DefaultBranchRefRef extends Schema.Struct.Type<typeof DefaultBranchRefRef.fields> {}
1428 +
1429 +/** Represents a Git object. */
1430 +export const GitObject = Schema.Struct({
1431 + __typename: GraphQL.otherTypename<Shared.Typename.GitObject>()([]),
1432 + /** The Git object ID */
1433 + oid: Shared.GitObjectID
1434 +})
1435 +export interface GitObject extends Schema.Struct.Type<typeof GitObject.fields> {}
1436 +
1437 +/** Represents a Git reference. */
1438 +export const RefRef = Schema.Struct({
1439 + /** The object the ref points to. Returns null when object does not exist. */
1440 + target: Schema.NullOr(GitObject)
1441 +})
1442 +export interface RefRef extends Schema.Struct.Type<typeof RefRef.fields> {}
1443 +
1444 +/** A repository contains the content for a project. */
1445 +export const NodeRepository = Schema.Struct({
1446 + __typename: Schema.Literal("Repository"),
1447 + /** The Ref associated with the repository's default branch. */
1448 + defaultBranchRef: Schema.NullOr(DefaultBranchRefRef),
1449 + /** Fetch a given ref from the repository */
1450 + ref: Schema.NullOr(RefRef)
1451 +})
1452 +export interface NodeRepository extends Schema.Struct.Type<typeof NodeRepository.fields> {}
1453 +
1454 +/** An object with an ID. */
1455 +export const PullRequestSourceBranchNodeNodeOther = Schema.Struct({
1456 + __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["Repository"])
1457 +})
1458 +export interface PullRequestSourceBranchNodeNodeOther extends Schema.Struct.Type<typeof PullRequestSourceBranchNodeNodeOther.fields> {}
1459 +
1460 +/** `query PullRequestSourceBranch` */
1461 +export const PullRequestSourceBranch = GraphQL.query("PullRequestSourceBranch", {
1462 + document: {
1463 + variables: [
1464 + { name: "repositoryId", body: "ID!" },
1465 + { name: "ref", body: "String!" }
1466 + ],
1467 + selections: [
1468 + { name: "node", body: ["(id:$", "repositoryId", "){__typename...on Repository{defaultBranchRef{name}ref(qualifiedName:$", "ref", "){target{__typename oid}}}}"] }
1469 + ],
1470 + fragments: []
1471 + },
1472 + variables: {
1473 + repositoryId: Shared.ID,
1474 + ref: Schema.String
1475 + },
1476 + result: Schema.Struct({
1477 + /** Fetches an object given its ID. */
1478 + node: Schema.NullOr(Schema.Union([
1479 + NodeRepository,
1480 + PullRequestSourceBranchNodeNodeOther
1481 + ]))
1482 + })
1483 +})
1484 +export declare namespace PullRequestSourceBranch {
1485 + export type Variables = typeof PullRequestSourceBranch.variables.Type
1486 + export type Result = typeof PullRequestSourceBranch.result.Type
1487 +}
1488 +
1489 +/** Every operation in pullRequestReads.graphql. */
1490 +export const PullRequestReadsGraphQLGroup = GraphQLGroup.make(ActorAvatars, PullRequestCore, PullRequestCheckContexts, PullRequestPreview, PullRequestActivity, PullRequestHeads, PullRequestNodeId, PullRequestSubject, ViewerPermissions, ReviewerCandidates, LabelCandidates, PullRequestFilesViewed, PullRequestMergeMessage, PullRequestActionState, PullRequestBranchToDelete, PullRequestSourceBranch)
packages/source-control-github/src/server/pullRequestReviews.graphql new
+257
@@ -0,0 +1,257 @@
1 +# The review conversation: threads, their comments, and what the people on the review said.
2 +
3 +# A reaction group as every reactable node reports it. `reactors` is bounded rather than paged: a
4 +# hover says who reacted, and a hundred and forty names is a count, not a sentence.
5 +fragment Reactions on Reactable {
6 + reactionGroups {
7 + content
8 + viewerHasReacted
9 + reactors(first: 10) {
10 + totalCount
11 + nodes {
12 + ... on User {
13 + login
14 + }
15 + ... on Bot {
16 + login
17 + }
18 + ... on Organization {
19 + login
20 + }
21 + ... on Mannequin {
22 + login
23 + }
24 + }
25 + }
26 + }
27 +}
28 +
29 +fragment ThreadComment on PullRequestReviewComment {
30 + id
31 + author {
32 + __typename
33 + login
34 + avatarUrl
35 + }
36 + body
37 + createdAt
38 + lastEditedAt
39 + url
40 + ...Reactions
41 +}
42 +
43 +# One page of review threads with their comments, and the people on the review. `$after` is null
44 +# for the first page and the last page's `endCursor` after that, so a pull request with more
45 +# threads than one page holds is walked rather than cut off.
46 +#
47 +# `viewer` rides along: GitHub names who reacted but never says whether that is the reader, so the
48 +# comparison is made locally rather than paid for with a request of its own.
49 +#
50 +# Reviewers come from here because `reviewRequests` holds only requests still outstanding, so
51 +# anyone who has already reviewed drops off it; `latestReviews` adds them back. A reviewer can be a
52 +# person or an app, and both are asked for by name because they are different GraphQL types.
53 +#
54 +# `viewerCanUpdate` and `viewerDidAuthor` belong to the pull request this query is already
55 +# standing on, so what the reader may do with it arrives with the conversation.
56 +query ReviewThreads($owner: String!, $name: String!, $number: Int!, $after: String) {
57 + viewer {
58 + login
59 + }
60 + repository(owner: $owner, name: $name) {
61 + pullRequest(number: $number) {
62 + reviewThreads(first: 100, after: $after) {
63 + totalCount
64 + pageInfo {
65 + hasNextPage
66 + endCursor
67 + }
68 + nodes {
69 + id
70 + isResolved
71 + isOutdated
72 + path
73 + # Null once the thread's line has left the diff, which `isOutdated` reports.
74 + line
75 + diffSide
76 + # Only ten comments ride with each thread. A hundred threads times a hundred comments
77 + # made GitHub reserve 10,000 nested rows and charge 104 points; unfinished threads are
78 + # paged from their own cursor by `ReviewThreadComments`.
79 + comments(first: 10) {
80 + totalCount
81 + pageInfo {
82 + hasNextPage
83 + endCursor
84 + }
85 + nodes {
86 + ...ThreadComment
87 + }
88 + }
89 + }
90 + }
91 + viewerCanUpdate
92 + viewerDidAuthor
93 + author {
94 + __typename
95 + login
96 + avatarUrl
97 + }
98 + ...Reactions
99 + comments(first: 100) {
100 + nodes {
101 + id
102 + lastEditedAt
103 + author {
104 + __typename
105 + login
106 + avatarUrl
107 + }
108 + ...Reactions
109 + }
110 + }
111 + # For their reactions and edit times: the words and the verdict arrive with the activity read.
112 + reviews(first: 100) {
113 + nodes {
114 + id
115 + lastEditedAt
116 + author {
117 + __typename
118 + login
119 + avatarUrl
120 + }
121 + ...Reactions
122 + }
123 + }
124 + reviewRequests(first: 50) {
125 + nodes {
126 + # Null for nobody. A team goes by its `org/slug`; a mannequin answers with neither and
127 + # names nobody to show. A team's name and avatar are aliased apart from a person's,
128 + # since their nullability differs.
129 + requestedReviewer {
130 + ... on User {
131 + login
132 + name
133 + avatarUrl
134 + }
135 + ... on Bot {
136 + login
137 + avatarUrl
138 + }
139 + ... on Team {
140 + combinedSlug
141 + teamName: name
142 + teamAvatarUrl: avatarUrl
143 + }
144 + }
145 + }
146 + }
147 + latestReviews(first: 50) {
148 + nodes {
149 + state
150 + author {
151 + __typename
152 + login
153 + avatarUrl
154 + }
155 + }
156 + }
157 + reviewDismissals: timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100) {
158 + pageInfo {
159 + hasNextPage
160 + endCursor
161 + }
162 + nodes {
163 + ... on ReviewDismissedEvent {
164 + dismissalMessage
165 + review {
166 + id
167 + }
168 + }
169 + }
170 + }
171 + # `last` rather than `first`: a pull request with more than a hundred commits keeps the
172 + # newest ones, which is what a reader scoping a diff wants.
173 + commits(last: 100) {
174 + nodes {
175 + commit {
176 + oid
177 + messageHeadline
178 + committedDate
179 + additions
180 + deletions
181 + parents(first: 1) {
182 + totalCount
183 + }
184 + authors(first: 3) {
185 + nodes {
186 + name
187 + avatarUrl
188 + user {
189 + login
190 + }
191 + }
192 + }
193 + }
194 + }
195 + }
196 + }
197 + }
198 +}
199 +
200 +# The rest of one thread's conversation. GraphQL pages a connection nested inside another only
201 +# from the inner node itself, so a thread longer than a page is followed on its own: a request
202 +# GitHub makes necessary, and one no ordinary pull request ever provokes.
203 +query ReviewThreadComments(
204 + $owner: String!
205 + $name: String!
206 + $number: Int!
207 + $threadId: ID!
208 + $after: String
209 +) {
210 + viewer {
211 + login
212 + }
213 + repository(owner: $owner, name: $name) {
214 + pullRequest(number: $number) {
215 + id
216 + }
217 + }
218 + node(id: $threadId) {
219 + ... on PullRequestReviewThread {
220 + pullRequest {
221 + id
222 + }
223 + comments(first: 100, after: $after) {
224 + pageInfo {
225 + hasNextPage
226 + endCursor
227 + }
228 + nodes {
229 + ...ThreadComment
230 + }
231 + }
232 + }
233 + }
234 +}
235 +
236 +# The dismissal events past the page the thread read carries. A pull request rarely has any: this
237 +# is followed only while the embedded page reports more.
238 +query ReviewDismissals($owner: String!, $name: String!, $number: Int!, $after: String) {
239 + repository(owner: $owner, name: $name) {
240 + pullRequest(number: $number) {
241 + timelineItems(itemTypes: [REVIEW_DISMISSED_EVENT], first: 100, after: $after) {
242 + pageInfo {
243 + hasNextPage
244 + endCursor
245 + }
246 + nodes {
247 + ... on ReviewDismissedEvent {
248 + dismissalMessage
249 + review {
250 + id
251 + }
252 + }
253 + }
254 + }
255 + }
256 + }
257 +}
packages/source-control-github/src/server/pullRequestReviews.graphql.ts new
+581
@@ -0,0 +1,581 @@
1 +// Generated by @effect/graphql-generator from pullRequestReviews.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
7 +export const NodesUser = Schema.Struct({
8 + __typename: Schema.Literal("User"),
9 + /** The username used to login. */
10 + login: Schema.String
11 +})
12 +export interface NodesUser extends Schema.Struct.Type<typeof NodesUser.fields> {}
13 +
14 +/** A special type of user which takes actions on behalf of GitHub Apps. */
15 +export const NodesBot = Schema.Struct({
16 + __typename: Schema.Literal("Bot"),
17 + /** The username of the actor. */
18 + login: Schema.String
19 +})
20 +export interface NodesBot extends Schema.Struct.Type<typeof NodesBot.fields> {}
21 +
22 +/** An account on GitHub, with one or more owners, that has repositories, members and teams. */
23 +export const Organization = Schema.Struct({
24 + __typename: Schema.Literal("Organization"),
25 + /** The organization's login name. */
26 + login: Schema.String
27 +})
28 +export interface Organization extends Schema.Struct.Type<typeof Organization.fields> {}
29 +
30 +/** A placeholder user for attribution of imported data on GitHub. */
31 +export const Mannequin = Schema.Struct({
32 + __typename: Schema.Literal("Mannequin"),
33 + /** The username of the actor. */
34 + login: Schema.String
35 +})
36 +export interface Mannequin extends Schema.Struct.Type<typeof Mannequin.fields> {}
37 +
38 +/** Types that can be assigned to reactions. */
39 +export const ReactorOther = Schema.Struct({
40 + __typename: GraphQL.otherTypename<Shared.Typename.Reactor>()(["User", "Bot", "Organization", "Mannequin"])
41 +})
42 +export interface ReactorOther extends Schema.Struct.Type<typeof ReactorOther.fields> {}
43 +
44 +/** The connection type for Reactor. */
45 +export const ReactorConnection = Schema.Struct({
46 + /** Identifies the total count of items in the connection. */
47 + totalCount: Shared.Int,
48 + /** A list of nodes. */
49 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Union([
50 + NodesUser,
51 + NodesBot,
52 + Organization,
53 + Mannequin,
54 + ReactorOther
55 + ]))))
56 +})
57 +export interface ReactorConnection extends Schema.Struct.Type<typeof ReactorConnection.fields> {}
58 +
59 +/** A group of emoji reactions to a particular piece of content. */
60 +export const ReactionGroup = Schema.Struct({
61 + /** Identifies the emoji reaction. */
62 + content: GraphQL.enumLiterals(Shared.ReactionContent.literals),
63 + /** Whether or not the authenticated user has left a reaction on the subject. */
64 + viewerHasReacted: Schema.Boolean,
65 + /** Reactors to the reaction subject with the emotion represented by this reaction group. */
66 + reactors: ReactorConnection
67 +})
68 +export interface ReactionGroup extends Schema.Struct.Type<typeof ReactionGroup.fields> {}
69 +
70 +/**
71 + * `fragment Reactions on Reactable`
72 + *
73 + * Represents a subject that can be reacted on.
74 + */
75 +export const Reactions = Schema.Struct({
76 + __typename: GraphQL.otherTypename<Shared.Typename.Reactable>()([]),
77 + /** A list of reactions grouped by content left on the subject. */
78 + reactionGroups: Schema.NullOr(Schema.Array(ReactionGroup))
79 +})
80 +export type Reactions = typeof Reactions.Type
81 +
82 +/** Represents an object which can take actions on GitHub. Typically a User or Bot. */
83 +export const Actor = Schema.Struct({
84 + __typename: GraphQL.otherTypename<Shared.Typename.Actor>()([]),
85 + /** The username of the actor. */
86 + login: Schema.String,
87 + /** A URL pointing to the actor's public avatar. */
88 + avatarUrl: Shared.URI
89 +})
90 +export interface Actor extends Schema.Struct.Type<typeof Actor.fields> {}
91 +
92 +/**
93 + * `fragment ThreadComment on PullRequestReviewComment`
94 + *
95 + * A review comment associated with a given repository pull request.
96 + */
97 +export const ThreadComment = Schema.Struct({
98 + /** The Node ID of the PullRequestReviewComment object */
99 + id: Shared.ID,
100 + /** The actor who authored the comment. */
101 + author: Schema.NullOr(Actor),
102 + /** The comment body of this review comment. */
103 + body: Schema.String,
104 + /** Identifies when the comment was created. */
105 + createdAt: Shared.DateTime,
106 + /** The moment the editor made the last edit */
107 + lastEditedAt: Schema.NullOr(Shared.DateTime),
108 + /** The HTTP URL permalink for this review comment. */
109 + url: Shared.URI,
110 + /** A list of reactions grouped by content left on the subject. */
111 + reactionGroups: Schema.NullOr(Schema.Array(ReactionGroup))
112 +})
113 +export interface ThreadComment extends Schema.Struct.Type<typeof ThreadComment.fields> {}
114 +
115 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
116 +export const ViewerUser = Schema.Struct({
117 + /** The username used to login. */
118 + login: Schema.String
119 +})
120 +export interface ViewerUser extends Schema.Struct.Type<typeof ViewerUser.fields> {}
121 +
122 +/** Information about pagination in a connection. */
123 +export const PageInfo = Schema.Struct({
124 + /** When paginating forwards, are there more items? */
125 + hasNextPage: Schema.Boolean,
126 + /** When paginating forwards, the cursor to continue. */
127 + endCursor: Schema.NullOr(Schema.String)
128 +})
129 +export interface PageInfo extends Schema.Struct.Type<typeof PageInfo.fields> {}
130 +
131 +/** The connection type for PullRequestReviewComment. */
132 +export const NodesCommentsPullRequestReviewCommentConnection = Schema.Struct({
133 + /** Identifies the total count of items in the connection. */
134 + totalCount: Shared.Int,
135 + /** Information to aid in pagination. */
136 + pageInfo: PageInfo,
137 + /** A list of nodes. */
138 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ThreadComment)))
139 +})
140 +export interface NodesCommentsPullRequestReviewCommentConnection extends Schema.Struct.Type<typeof NodesCommentsPullRequestReviewCommentConnection.fields> {}
141 +
142 +/** A threaded list of comments for a given pull request. */
143 +export const NodesPullRequestReviewThread = Schema.Struct({
144 + /** The Node ID of the PullRequestReviewThread object */
145 + id: Shared.ID,
146 + /** Whether this thread has been resolved */
147 + isResolved: Schema.Boolean,
148 + /** Indicates whether this thread was outdated by newer changes. */
149 + isOutdated: Schema.Boolean,
150 + /** Identifies the file path of this thread. */
151 + path: Schema.String,
152 + /** The line in the file to which this thread refers */
153 + line: Schema.NullOr(Shared.Int),
154 + /** The side of the diff on which this thread was placed. */
155 + diffSide: GraphQL.enumLiterals(Shared.DiffSide.literals),
156 + /** A list of pull request comments associated with the thread. */
157 + comments: NodesCommentsPullRequestReviewCommentConnection
158 +})
159 +export interface NodesPullRequestReviewThread extends Schema.Struct.Type<typeof NodesPullRequestReviewThread.fields> {}
160 +
161 +/** Review comment threads for a pull request review. */
162 +export const PullRequestReviewThreadConnection = Schema.Struct({
163 + /** Identifies the total count of items in the connection. */
164 + totalCount: Shared.Int,
165 + /** Information to aid in pagination. */
166 + pageInfo: PageInfo,
167 + /** A list of nodes. */
168 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(NodesPullRequestReviewThread)))
169 +})
170 +export interface PullRequestReviewThreadConnection extends Schema.Struct.Type<typeof PullRequestReviewThreadConnection.fields> {}
171 +
172 +/** Represents a comment on an Issue. */
173 +export const IssueComment = Schema.Struct({
174 + /** The Node ID of the IssueComment object */
175 + id: Shared.ID,
176 + /** The moment the editor made the last edit */
177 + lastEditedAt: Schema.NullOr(Shared.DateTime),
178 + /** The actor who authored the comment. */
179 + author: Schema.NullOr(Actor),
180 + /** A list of reactions grouped by content left on the subject. */
181 + reactionGroups: Schema.NullOr(Schema.Array(ReactionGroup))
182 +})
183 +export interface IssueComment extends Schema.Struct.Type<typeof IssueComment.fields> {}
184 +
185 +/** The connection type for IssueComment. */
186 +export const IssueCommentConnection = Schema.Struct({
187 + /** A list of nodes. */
188 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(IssueComment)))
189 +})
190 +export interface IssueCommentConnection extends Schema.Struct.Type<typeof IssueCommentConnection.fields> {}
191 +
192 +/** A review object for a given pull request. */
193 +export const ReviewsNodesPullRequestReview = Schema.Struct({
194 + /** The Node ID of the PullRequestReview object */
195 + id: Shared.ID,
196 + /** The moment the editor made the last edit */
197 + lastEditedAt: Schema.NullOr(Shared.DateTime),
198 + /** The actor who authored the comment. */
199 + author: Schema.NullOr(Actor),
200 + /** A list of reactions grouped by content left on the subject. */
201 + reactionGroups: Schema.NullOr(Schema.Array(ReactionGroup))
202 +})
203 +export interface ReviewsNodesPullRequestReview extends Schema.Struct.Type<typeof ReviewsNodesPullRequestReview.fields> {}
204 +
205 +/** The connection type for PullRequestReview. */
206 +export const ReviewsPullRequestReviewConnection = Schema.Struct({
207 + /** A list of nodes. */
208 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ReviewsNodesPullRequestReview)))
209 +})
210 +export interface ReviewsPullRequestReviewConnection extends Schema.Struct.Type<typeof ReviewsPullRequestReviewConnection.fields> {}
211 +
212 +/** A user is an individual's account on GitHub that owns repositories and can make new content. */
213 +export const RequestedReviewerUser = Schema.Struct({
214 + __typename: Schema.Literal("User"),
215 + /** The username used to login. */
216 + login: Schema.String,
217 + /** The user's public profile name. */
218 + name: Schema.NullOr(Schema.String),
219 + /** A URL pointing to the user's public avatar. */
220 + avatarUrl: Shared.URI
221 +})
222 +export interface RequestedReviewerUser extends Schema.Struct.Type<typeof RequestedReviewerUser.fields> {}
223 +
224 +/** A special type of user which takes actions on behalf of GitHub Apps. */
225 +export const RequestedReviewerBot = Schema.Struct({
226 + __typename: Schema.Literal("Bot"),
227 + /** The username of the actor. */
228 + login: Schema.String,
229 + /** A URL pointing to the GitHub App's public avatar. */
230 + avatarUrl: Shared.URI
231 +})
232 +export interface RequestedReviewerBot extends Schema.Struct.Type<typeof RequestedReviewerBot.fields> {}
233 +
234 +/** A team of users in an organization. */
235 +export const Team = Schema.Struct({
236 + __typename: Schema.Literal("Team"),
237 + /** The slug corresponding to the organization and team. */
238 + combinedSlug: Schema.String,
239 + /** The name of the team. */
240 + teamName: Schema.String,
241 + /** A URL pointing to the team's avatar. */
242 + teamAvatarUrl: Schema.NullOr(Shared.URI)
243 +})
244 +export interface Team extends Schema.Struct.Type<typeof Team.fields> {}
245 +
246 +/** Types that can be requested reviewers. */
247 +export const RequestedReviewerOther = Schema.Struct({
248 + __typename: GraphQL.otherTypename<Shared.Typename.RequestedReviewer>()(["User", "Bot", "Team"])
249 +})
250 +export interface RequestedReviewerOther extends Schema.Struct.Type<typeof RequestedReviewerOther.fields> {}
251 +
252 +/** A request for a user to review a pull request. */
253 +export const ReviewRequest = Schema.Struct({
254 + /** The reviewer that is requested. */
255 + requestedReviewer: Schema.NullOr(Schema.Union([
256 + RequestedReviewerUser,
257 + RequestedReviewerBot,
258 + Team,
259 + RequestedReviewerOther
260 + ]))
261 +})
262 +export interface ReviewRequest extends Schema.Struct.Type<typeof ReviewRequest.fields> {}
263 +
264 +/** The connection type for ReviewRequest. */
265 +export const ReviewRequestConnection = Schema.Struct({
266 + /** A list of nodes. */
267 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ReviewRequest)))
268 +})
269 +export interface ReviewRequestConnection extends Schema.Struct.Type<typeof ReviewRequestConnection.fields> {}
270 +
271 +/** A review object for a given pull request. */
272 +export const LatestReviewsNodesPullRequestReview = Schema.Struct({
273 + /** Identifies the current state of the pull request review. */
274 + state: GraphQL.enumLiterals(Shared.PullRequestReviewState.literals),
275 + /** The actor who authored the comment. */
276 + author: Schema.NullOr(Actor)
277 +})
278 +export interface LatestReviewsNodesPullRequestReview extends Schema.Struct.Type<typeof LatestReviewsNodesPullRequestReview.fields> {}
279 +
280 +/** The connection type for PullRequestReview. */
281 +export const LatestReviewsPullRequestReviewConnection = Schema.Struct({
282 + /** A list of nodes. */
283 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(LatestReviewsNodesPullRequestReview)))
284 +})
285 +export interface LatestReviewsPullRequestReviewConnection extends Schema.Struct.Type<typeof LatestReviewsPullRequestReviewConnection.fields> {}
286 +
287 +/** A review object for a given pull request. */
288 +export const ReviewPullRequestReview = Schema.Struct({
289 + /** The Node ID of the PullRequestReview object */
290 + id: Shared.ID
291 +})
292 +export interface ReviewPullRequestReview extends Schema.Struct.Type<typeof ReviewPullRequestReview.fields> {}
293 +
294 +/** Represents a 'review_dismissed' event on a given issue or pull request. */
295 +export const ReviewDismissedEvent = Schema.Struct({
296 + __typename: Schema.Literal("ReviewDismissedEvent"),
297 + /** Identifies the optional message associated with the 'review_dismissed' event. */
298 + dismissalMessage: Schema.NullOr(Schema.String),
299 + /** Identifies the review associated with the 'review_dismissed' event. */
300 + review: Schema.NullOr(ReviewPullRequestReview)
301 +})
302 +export interface ReviewDismissedEvent extends Schema.Struct.Type<typeof ReviewDismissedEvent.fields> {}
303 +
304 +/** An item in a pull request timeline */
305 +export const PullRequestTimelineItemsOther = Schema.Struct({
306 + __typename: GraphQL.otherTypename<Shared.Typename.PullRequestTimelineItems>()(["ReviewDismissedEvent"])
307 +})
308 +export interface PullRequestTimelineItemsOther extends Schema.Struct.Type<typeof PullRequestTimelineItemsOther.fields> {}
309 +
310 +/** The connection type for PullRequestTimelineItems. */
311 +export const PullRequestTimelineItemsConnection = Schema.Struct({
312 + /** Information to aid in pagination. */
313 + pageInfo: PageInfo,
314 + /** A list of nodes. */
315 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(Schema.Union([
316 + ReviewDismissedEvent,
317 + PullRequestTimelineItemsOther
318 + ]))))
319 +})
320 +export interface PullRequestTimelineItemsConnection extends Schema.Struct.Type<typeof PullRequestTimelineItemsConnection.fields> {}
321 +
322 +/** The connection type for Commit. */
323 +export const CommitConnection = Schema.Struct({
324 + /** Identifies the total count of items in the connection. */
325 + totalCount: Shared.Int
326 +})
327 +export interface CommitConnection extends Schema.Struct.Type<typeof CommitConnection.fields> {}
328 +
329 +/** Represents an actor in a Git commit (ie. an author or committer). */
330 +export const GitActor = Schema.Struct({
331 + /** The name in the Git commit. */
332 + name: Schema.NullOr(Schema.String),
333 + /** A URL pointing to the author's public avatar. */
334 + avatarUrl: Shared.URI,
335 + /** The GitHub user corresponding to the email field. Null if no such user exists. */
336 + user: Schema.NullOr(ViewerUser)
337 +})
338 +export interface GitActor extends Schema.Struct.Type<typeof GitActor.fields> {}
339 +
340 +/** The connection type for GitActor. */
341 +export const GitActorConnection = Schema.Struct({
342 + /** A list of nodes. */
343 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(GitActor)))
344 +})
345 +export interface GitActorConnection extends Schema.Struct.Type<typeof GitActorConnection.fields> {}
346 +
347 +/** Represents a Git commit. */
348 +export const Commit = Schema.Struct({
349 + /** The Git object ID */
350 + oid: Shared.GitObjectID,
351 + /** The Git commit message headline */
352 + messageHeadline: Schema.String,
353 + /** The datetime when this commit was committed. */
354 + committedDate: Shared.DateTime,
355 + /** The number of additions in this commit. */
356 + additions: Shared.Int,
357 + /** The number of deletions in this commit. */
358 + deletions: Shared.Int,
359 + /** The parents of a commit. */
360 + parents: CommitConnection,
361 + /**
362 + * The list of authors for this commit based on the git author and the Co-authored-by
363 + * message trailer. The git author will always be first.
364 + */
365 + authors: GitActorConnection
366 +})
367 +export interface Commit extends Schema.Struct.Type<typeof Commit.fields> {}
368 +
369 +/** Represents a Git commit part of a pull request. */
370 +export const PullRequestCommit = Schema.Struct({
371 + /** The Git commit object */
372 + commit: Commit
373 +})
374 +export interface PullRequestCommit extends Schema.Struct.Type<typeof PullRequestCommit.fields> {}
375 +
376 +/** The connection type for PullRequestCommit. */
377 +export const PullRequestCommitConnection = Schema.Struct({
378 + /** A list of nodes. */
379 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestCommit)))
380 +})
381 +export interface PullRequestCommitConnection extends Schema.Struct.Type<typeof PullRequestCommitConnection.fields> {}
382 +
383 +/** A repository pull request. */
384 +export const ReviewThreadsRepositoryPullRequestPullRequest = Schema.Struct({
385 + /** The list of all review threads for this pull request. */
386 + reviewThreads: PullRequestReviewThreadConnection,
387 + /** Check if the current viewer can update this object. */
388 + viewerCanUpdate: Schema.Boolean,
389 + /** Did the viewer author this comment. */
390 + viewerDidAuthor: Schema.Boolean,
391 + /** The actor who authored the comment. */
392 + author: Schema.NullOr(Actor),
393 + /** A list of reactions grouped by content left on the subject. */
394 + reactionGroups: Schema.NullOr(Schema.Array(ReactionGroup)),
395 + /** A list of comments associated with the pull request. */
396 + comments: IssueCommentConnection,
397 + /** A list of reviews associated with the pull request. */
398 + reviews: Schema.NullOr(ReviewsPullRequestReviewConnection),
399 + /** A list of review requests associated with the pull request. */
400 + reviewRequests: Schema.NullOr(ReviewRequestConnection),
401 + /** A list of latest reviews per user associated with the pull request that are not also pending review. */
402 + latestReviews: Schema.NullOr(LatestReviewsPullRequestReviewConnection),
403 + /** A list of events, comments, commits, etc. associated with the pull request. */
404 + reviewDismissals: PullRequestTimelineItemsConnection,
405 + /** A list of commits present in this pull request's head branch not present in the base branch. */
406 + commits: PullRequestCommitConnection
407 +})
408 +export interface ReviewThreadsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof ReviewThreadsRepositoryPullRequestPullRequest.fields> {}
409 +
410 +/** A repository contains the content for a project. */
411 +export const ReviewThreadsRepositoryRepository = Schema.Struct({
412 + /** Returns a single pull request from the current repository by number. */
413 + pullRequest: Schema.NullOr(ReviewThreadsRepositoryPullRequestPullRequest)
414 +})
415 +export interface ReviewThreadsRepositoryRepository extends Schema.Struct.Type<typeof ReviewThreadsRepositoryRepository.fields> {}
416 +
417 +/** `query ReviewThreads` */
418 +export const ReviewThreads = GraphQL.query("ReviewThreads", {
419 + document: {
420 + variables: [
421 + { name: "owner", body: "String!" },
422 + { name: "name", body: "String!" },
423 + { name: "number", body: "Int!" },
424 + { name: "after", body: "String" }
425 + ],
426 + selections: [
427 + { name: "viewer", body: ["{login}"] },
428 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){reviewThreads(first:100 after:$", "after", "){totalCount pageInfo{hasNextPage endCursor}nodes{id isResolved isOutdated path line diffSide comments(first:10){totalCount pageInfo{hasNextPage endCursor}nodes{...ThreadComment}}}}viewerCanUpdate viewerDidAuthor author{__typename login avatarUrl}...Reactions comments(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviews(first:100){nodes{id lastEditedAt author{__typename login avatarUrl}...Reactions}}reviewRequests(first:50){nodes{requestedReviewer{__typename...on User{login name avatarUrl}...on Bot{login avatarUrl}...on Team{combinedSlug teamName:name teamAvatarUrl:avatarUrl}}}}latestReviews(first:50){nodes{state author{__typename login avatarUrl}}}reviewDismissals:timelineItems(itemTypes:[REVIEW_DISMISSED_EVENT]first:100){pageInfo{hasNextPage endCursor}nodes{__typename...on ReviewDismissedEvent{dismissalMessage review{id}}}}commits(last:100){nodes{commit{oid messageHeadline committedDate additions deletions parents(first:1){totalCount}authors(first:3){nodes{name avatarUrl user{login}}}}}}}}"] }
429 + ],
430 + fragments: [
431 + { name: "ThreadComment", body: ["on PullRequestReviewComment{id author{__typename login avatarUrl}body createdAt lastEditedAt url...Reactions}"] },
432 + { name: "Reactions", body: ["on Reactable{__typename reactionGroups{content viewerHasReacted reactors(first:10){totalCount nodes{__typename...on User{login}...on Bot{login}...on Organization{login}...on Mannequin{login}}}}}"] }
433 + ]
434 + },
435 + variables: {
436 + owner: Schema.String,
437 + name: Schema.String,
438 + number: Shared.Int,
439 + after: Schema.optional(Schema.NullOr(Schema.String))
440 + },
441 + result: Schema.Struct({
442 + /** The currently authenticated user. */
443 + viewer: ViewerUser,
444 + /** Lookup a given repository by the owner and repository name. */
445 + repository: Schema.NullOr(ReviewThreadsRepositoryRepository)
446 + })
447 +})
448 +export declare namespace ReviewThreads {
449 + export type Variables = typeof ReviewThreads.variables.Type
450 + export type Result = typeof ReviewThreads.result.Type
451 +}
452 +
453 +/** A repository pull request. */
454 +export const ReviewThreadCommentsRepositoryPullRequestPullRequest = Schema.Struct({
455 + /** The Node ID of the PullRequest object */
456 + id: Shared.ID
457 +})
458 +export interface ReviewThreadCommentsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof ReviewThreadCommentsRepositoryPullRequestPullRequest.fields> {}
459 +
460 +/** A repository contains the content for a project. */
461 +export const ReviewThreadCommentsRepositoryRepository = Schema.Struct({
462 + /** Returns a single pull request from the current repository by number. */
463 + pullRequest: Schema.NullOr(ReviewThreadCommentsRepositoryPullRequestPullRequest)
464 +})
465 +export interface ReviewThreadCommentsRepositoryRepository extends Schema.Struct.Type<typeof ReviewThreadCommentsRepositoryRepository.fields> {}
466 +
467 +/** The connection type for PullRequestReviewComment. */
468 +export const NodeCommentsPullRequestReviewCommentConnection = Schema.Struct({
469 + /** Information to aid in pagination. */
470 + pageInfo: PageInfo,
471 + /** A list of nodes. */
472 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(ThreadComment)))
473 +})
474 +export interface NodeCommentsPullRequestReviewCommentConnection extends Schema.Struct.Type<typeof NodeCommentsPullRequestReviewCommentConnection.fields> {}
475 +
476 +/** A threaded list of comments for a given pull request. */
477 +export const NodePullRequestReviewThread = Schema.Struct({
478 + __typename: Schema.Literal("PullRequestReviewThread"),
479 + /** Identifies the pull request associated with this thread. */
480 + pullRequest: ReviewThreadCommentsRepositoryPullRequestPullRequest,
481 + /** A list of pull request comments associated with the thread. */
482 + comments: NodeCommentsPullRequestReviewCommentConnection
483 +})
484 +export interface NodePullRequestReviewThread extends Schema.Struct.Type<typeof NodePullRequestReviewThread.fields> {}
485 +
486 +/** An object with an ID. */
487 +export const NodeOther = Schema.Struct({
488 + __typename: GraphQL.otherTypename<Shared.Typename.Node>()(["PullRequestReviewThread"])
489 +})
490 +export interface NodeOther extends Schema.Struct.Type<typeof NodeOther.fields> {}
491 +
492 +/** `query ReviewThreadComments` */
493 +export const ReviewThreadComments = GraphQL.query("ReviewThreadComments", {
494 + document: {
495 + variables: [
496 + { name: "owner", body: "String!" },
497 + { name: "name", body: "String!" },
498 + { name: "number", body: "Int!" },
499 + { name: "threadId", body: "ID!" },
500 + { name: "after", body: "String" }
501 + ],
502 + selections: [
503 + { name: "viewer", body: ["{login}"] },
504 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){id}}"] },
505 + { name: "node", body: ["(id:$", "threadId", "){__typename...on PullRequestReviewThread{pullRequest{id}comments(first:100 after:$", "after", "){pageInfo{hasNextPage endCursor}nodes{...ThreadComment}}}}"] }
506 + ],
507 + fragments: [
508 + { name: "ThreadComment", body: ["on PullRequestReviewComment{id author{__typename login avatarUrl}body createdAt lastEditedAt url...Reactions}"] },
509 + { name: "Reactions", body: ["on Reactable{__typename reactionGroups{content viewerHasReacted reactors(first:10){totalCount nodes{__typename...on User{login}...on Bot{login}...on Organization{login}...on Mannequin{login}}}}}"] }
510 + ]
511 + },
512 + variables: {
513 + owner: Schema.String,
514 + name: Schema.String,
515 + number: Shared.Int,
516 + threadId: Shared.ID,
517 + after: Schema.optional(Schema.NullOr(Schema.String))
518 + },
519 + result: Schema.Struct({
520 + /** The currently authenticated user. */
521 + viewer: ViewerUser,
522 + /** Lookup a given repository by the owner and repository name. */
523 + repository: Schema.NullOr(ReviewThreadCommentsRepositoryRepository),
524 + /** Fetches an object given its ID. */
525 + node: Schema.NullOr(Schema.Union([
526 + NodePullRequestReviewThread,
527 + NodeOther
528 + ]))
529 + })
530 +})
531 +export declare namespace ReviewThreadComments {
532 + export type Variables = typeof ReviewThreadComments.variables.Type
533 + export type Result = typeof ReviewThreadComments.result.Type
534 +}
535 +
536 +/** A repository pull request. */
537 +export const ReviewDismissalsRepositoryPullRequestPullRequest = Schema.Struct({
538 + /** A list of events, comments, commits, etc. associated with the pull request. */
539 + timelineItems: PullRequestTimelineItemsConnection
540 +})
541 +export interface ReviewDismissalsRepositoryPullRequestPullRequest extends Schema.Struct.Type<typeof ReviewDismissalsRepositoryPullRequestPullRequest.fields> {}
542 +
543 +/** A repository contains the content for a project. */
544 +export const ReviewDismissalsRepositoryRepository = Schema.Struct({
545 + /** Returns a single pull request from the current repository by number. */
546 + pullRequest: Schema.NullOr(ReviewDismissalsRepositoryPullRequestPullRequest)
547 +})
548 +export interface ReviewDismissalsRepositoryRepository extends Schema.Struct.Type<typeof ReviewDismissalsRepositoryRepository.fields> {}
549 +
550 +/** `query ReviewDismissals` */
551 +export const ReviewDismissals = GraphQL.query("ReviewDismissals", {
552 + document: {
553 + variables: [
554 + { name: "owner", body: "String!" },
555 + { name: "name", body: "String!" },
556 + { name: "number", body: "Int!" },
557 + { name: "after", body: "String" }
558 + ],
559 + selections: [
560 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){timelineItems(itemTypes:[REVIEW_DISMISSED_EVENT]first:100 after:$", "after", "){pageInfo{hasNextPage endCursor}nodes{__typename...on ReviewDismissedEvent{dismissalMessage review{id}}}}}}"] }
561 + ],
562 + fragments: []
563 + },
564 + variables: {
565 + owner: Schema.String,
566 + name: Schema.String,
567 + number: Shared.Int,
568 + after: Schema.optional(Schema.NullOr(Schema.String))
569 + },
570 + result: Schema.Struct({
571 + /** Lookup a given repository by the owner and repository name. */
572 + repository: Schema.NullOr(ReviewDismissalsRepositoryRepository)
573 + })
574 +})
575 +export declare namespace ReviewDismissals {
576 + export type Variables = typeof ReviewDismissals.variables.Type
577 + export type Result = typeof ReviewDismissals.result.Type
578 +}
579 +
580 +/** Every operation in pullRequestReviews.graphql. */
581 +export const PullRequestReviewsGraphQLGroup = GraphQLGroup.make(ReviewThreads, ReviewThreadComments, ReviewDismissals)
packages/source-control-github/src/server/sourceControlProvider.graphql new
+57
@@ -0,0 +1,57 @@
1 +# The pull request reads behind `GitHubSourceControlProvider`. `PullRequestsByHead` is batched
2 +# with `GraphQLResolver.aliased`, which repeats it under an alias per lookup, so the lookups a
3 +# branch sweep makes together share one request and a missing repository fails only its own.
4 +
5 +# The pull request fields every read selects.
6 +fragment PullRequestNode on PullRequest {
7 + number
8 + title
9 + url
10 + baseRefName
11 + headRefName
12 + headRefOid
13 + state
14 + isDraft
15 + mergedAt
16 + closedAt
17 + updatedAt
18 + isCrossRepository
19 + headRepository {
20 + name
21 + nameWithOwner
22 + }
23 + headRepositoryOwner {
24 + login
25 + }
26 +}
27 +
28 +query PullRequestsByHead(
29 + $owner: String!
30 + $name: String!
31 + $head: String!
32 + $states: [PullRequestState!]
33 + $first: Int!
34 +) {
35 + repository(owner: $owner, name: $name) {
36 + # `gh pr list` orders the same way, so a head with more matches than the limit keeps the
37 + # same rows.
38 + pullRequests(
39 + headRefName: $head
40 + states: $states
41 + first: $first
42 + orderBy: { field: CREATED_AT, direction: DESC }
43 + ) {
44 + nodes {
45 + ...PullRequestNode
46 + }
47 + }
48 + }
49 +}
50 +
51 +query PullRequestByNumber($owner: String!, $name: String!, $number: Int!) {
52 + repository(owner: $owner, name: $name) {
53 + pullRequest(number: $number) {
54 + ...PullRequestNode
55 + }
56 + }
57 +}
packages/source-control-github/src/server/sourceControlProvider.graphql.ts new
+146
@@ -0,0 +1,146 @@
1 +// Generated by @effect/graphql-generator from sourceControlProvider.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A repository contains the content for a project. */
7 +export const HeadRepositoryRepository = Schema.Struct({
8 + /** The name of the repository. */
9 + name: Schema.String,
10 + /** The repository's name with owner. */
11 + nameWithOwner: Schema.String
12 +})
13 +export interface HeadRepositoryRepository extends Schema.Struct.Type<typeof HeadRepositoryRepository.fields> {}
14 +
15 +/** Represents an owner of a Repository. */
16 +export const RepositoryOwner = Schema.Struct({
17 + __typename: GraphQL.otherTypename<Shared.Typename.RepositoryOwner>()([]),
18 + /** The username used to login. */
19 + login: Schema.String
20 +})
21 +export interface RepositoryOwner extends Schema.Struct.Type<typeof RepositoryOwner.fields> {}
22 +
23 +/**
24 + * `fragment PullRequestNode on PullRequest`
25 + *
26 + * A repository pull request.
27 + */
28 +export const PullRequestNode = Schema.Struct({
29 + /** Identifies the pull request number. */
30 + number: Shared.Int,
31 + /** Identifies the pull request title. */
32 + title: Schema.String,
33 + /** The HTTP URL for this pull request. */
34 + url: Shared.URI,
35 + /** Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. */
36 + baseRefName: Schema.String,
37 + /** Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. */
38 + headRefName: Schema.String,
39 + /** Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. */
40 + headRefOid: Shared.GitObjectID,
41 + /** Identifies the state of the pull request. */
42 + state: GraphQL.enumLiterals(Shared.PullRequestState.literals),
43 + /** Identifies if the pull request is a draft. */
44 + isDraft: Schema.Boolean,
45 + /** The date and time that the pull request was merged. */
46 + mergedAt: Schema.NullOr(Shared.DateTime),
47 + /** Identifies the date and time when the object was closed. */
48 + closedAt: Schema.NullOr(Shared.DateTime),
49 + /** Identifies the date and time when the object was last updated. */
50 + updatedAt: Shared.DateTime,
51 + /** The head and base repositories are different. */
52 + isCrossRepository: Schema.Boolean,
53 + /** The repository associated with this pull request's head Ref. */
54 + headRepository: Schema.NullOr(HeadRepositoryRepository),
55 + /** The owner of the repository associated with this pull request's head Ref. */
56 + headRepositoryOwner: Schema.NullOr(RepositoryOwner)
57 +})
58 +export interface PullRequestNode extends Schema.Struct.Type<typeof PullRequestNode.fields> {}
59 +
60 +/** The connection type for PullRequest. */
61 +export const PullRequestConnection = Schema.Struct({
62 + /** A list of nodes. */
63 + nodes: Schema.NullOr(Schema.Array(Schema.NullOr(PullRequestNode)))
64 +})
65 +export interface PullRequestConnection extends Schema.Struct.Type<typeof PullRequestConnection.fields> {}
66 +
67 +/** A repository contains the content for a project. */
68 +export const PullRequestsByHeadRepositoryRepository = Schema.Struct({
69 + /** A list of pull requests that have been opened in the repository. */
70 + pullRequests: PullRequestConnection
71 +})
72 +export interface PullRequestsByHeadRepositoryRepository extends Schema.Struct.Type<typeof PullRequestsByHeadRepositoryRepository.fields> {}
73 +
74 +/** `query PullRequestsByHead` */
75 +export const PullRequestsByHead = GraphQL.query("PullRequestsByHead", {
76 + document: {
77 + variables: [
78 + { name: "owner", body: "String!" },
79 + { name: "name", body: "String!" },
80 + { name: "head", body: "String!" },
81 + { name: "states", body: "[PullRequestState!]" },
82 + { name: "first", body: "Int!" }
83 + ],
84 + selections: [
85 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequests(headRefName:$", "head", " states:$", "states", " first:$", "first", " orderBy:{field:CREATED_AT direction:DESC}){nodes{...PullRequestNode}}}"] }
86 + ],
87 + fragments: [
88 + { name: "PullRequestNode", body: ["on PullRequest{number title url baseRefName headRefName headRefOid state isDraft mergedAt closedAt updatedAt isCrossRepository headRepository{name nameWithOwner}headRepositoryOwner{__typename login}}"] }
89 + ]
90 + },
91 + variables: {
92 + owner: Schema.String,
93 + name: Schema.String,
94 + head: Schema.String,
95 + states: Schema.optional(Schema.NullOr(Schema.Array(Shared.PullRequestState))),
96 + first: Shared.Int
97 + },
98 + result: Schema.Struct({
99 + /** Lookup a given repository by the owner and repository name. */
100 + repository: Schema.NullOr(PullRequestsByHeadRepositoryRepository)
101 + })
102 +})
103 +export declare namespace PullRequestsByHead {
104 + export type Variables = typeof PullRequestsByHead.variables.Type
105 + export type Result = typeof PullRequestsByHead.result.Type
106 +}
107 +
108 +/** A repository contains the content for a project. */
109 +export const PullRequestByNumberRepositoryRepository = Schema.Struct({
110 + /** Returns a single pull request from the current repository by number. */
111 + pullRequest: Schema.NullOr(PullRequestNode)
112 +})
113 +export interface PullRequestByNumberRepositoryRepository extends Schema.Struct.Type<typeof PullRequestByNumberRepositoryRepository.fields> {}
114 +
115 +/** `query PullRequestByNumber` */
116 +export const PullRequestByNumber = GraphQL.query("PullRequestByNumber", {
117 + document: {
118 + variables: [
119 + { name: "owner", body: "String!" },
120 + { name: "name", body: "String!" },
121 + { name: "number", body: "Int!" }
122 + ],
123 + selections: [
124 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){...PullRequestNode}}"] }
125 + ],
126 + fragments: [
127 + { name: "PullRequestNode", body: ["on PullRequest{number title url baseRefName headRefName headRefOid state isDraft mergedAt closedAt updatedAt isCrossRepository headRepository{name nameWithOwner}headRepositoryOwner{__typename login}}"] }
128 + ]
129 + },
130 + variables: {
131 + owner: Schema.String,
132 + name: Schema.String,
133 + number: Shared.Int
134 + },
135 + result: Schema.Struct({
136 + /** Lookup a given repository by the owner and repository name. */
137 + repository: Schema.NullOr(PullRequestByNumberRepositoryRepository)
138 + })
139 +})
140 +export declare namespace PullRequestByNumber {
141 + export type Variables = typeof PullRequestByNumber.variables.Type
142 + export type Result = typeof PullRequestByNumber.result.Type
143 +}
144 +
145 +/** Every operation in sourceControlProvider.graphql. */
146 +export const SourceControlProviderGraphQLGroup = GraphQLGroup.make(PullRequestsByHead, PullRequestByNumber)
packages/source-control-github/src/server/stackActions.graphql new
+13
@@ -0,0 +1,13 @@
1 +# Whether the viewer can push to one stack layer's head branch. `GraphQLResolver.aliased` repeats
2 +# it under an alias per layer, so a stack's layers are checked in one request.
3 +query PullRequestBranchAccess($owner: String!, $name: String!, $number: Int!) {
4 + repository(owner: $owner, name: $name) {
5 + pullRequest(number: $number) {
6 + headRepository {
7 + viewerPermission
8 + }
9 + # A fork's branch is writable without repository access when its owner allows it.
10 + maintainerCanModify
11 + }
12 + }
13 +}
packages/source-control-github/src/server/stackActions.graphql.ts new
+58
@@ -0,0 +1,58 @@
1 +// Generated by @effect/graphql-generator from stackActions.graphql. Do not edit.
2 +import { GraphQL, GraphQLGroup } from "effect/graphql"
3 +import * as Schema from "effect/Schema"
4 +import * as Shared from "../../schema/github.graphql.ts"
5 +
6 +/** A repository contains the content for a project. */
7 +export const HeadRepositoryRepository = Schema.Struct({
8 + /** The users permission level on the repository. Will return null if authenticated as an GitHub App. */
9 + viewerPermission: Schema.NullOr(GraphQL.enumLiterals(Shared.RepositoryPermission.literals))
10 +})
11 +export interface HeadRepositoryRepository extends Schema.Struct.Type<typeof HeadRepositoryRepository.fields> {}
12 +
13 +/** A repository pull request. */
14 +export const PullRequest = Schema.Struct({
15 + /** The repository associated with this pull request's head Ref. */
16 + headRepository: Schema.NullOr(HeadRepositoryRepository),
17 + /** Indicates whether maintainers can modify the pull request. */
18 + maintainerCanModify: Schema.Boolean
19 +})
20 +export interface PullRequest extends Schema.Struct.Type<typeof PullRequest.fields> {}
21 +
22 +/** A repository contains the content for a project. */
23 +export const RepositoryRepository = Schema.Struct({
24 + /** Returns a single pull request from the current repository by number. */
25 + pullRequest: Schema.NullOr(PullRequest)
26 +})
27 +export interface RepositoryRepository extends Schema.Struct.Type<typeof RepositoryRepository.fields> {}
28 +
29 +/** `query PullRequestBranchAccess` */
30 +export const PullRequestBranchAccess = GraphQL.query("PullRequestBranchAccess", {
31 + document: {
32 + variables: [
33 + { name: "owner", body: "String!" },
34 + { name: "name", body: "String!" },
35 + { name: "number", body: "Int!" }
36 + ],
37 + selections: [
38 + { name: "repository", body: ["(owner:$", "owner", " name:$", "name", "){pullRequest(number:$", "number", "){headRepository{viewerPermission}maintainerCanModify}}"] }
39 + ],
40 + fragments: []
41 + },
42 + variables: {
43 + owner: Schema.String,
44 + name: Schema.String,
45 + number: Shared.Int
46 + },
47 + result: Schema.Struct({
48 + /** Lookup a given repository by the owner and repository name. */
49 + repository: Schema.NullOr(RepositoryRepository)
50 + })
51 +})
52 +export declare namespace PullRequestBranchAccess {
53 + export type Variables = typeof PullRequestBranchAccess.variables.Type
54 + export type Result = typeof PullRequestBranchAccess.result.Type
55 +}
56 +
57 +/** Every operation in stackActions.graphql. */
58 +export const StackActionsGraphQLGroup = GraphQLGroup.make(PullRequestBranchAccess)
patches/@effect__vitest@4.0.5.patch renamed
+1 -1
@@ -67,7 +67,7 @@ index b78f4d6..8c43672 100644
67 },
68 "peerDependencies": {
69 - "vitest": ">=5.0.0 <6.0.0",
70 - "effect": "^4.0.4"
70 + "effect": "^4.0.5"
71 },
72 "devDependencies": {
73 diff --git a/src/index.ts b/src/index.ts
pnpm-lock.yaml
+373 -355
@@ -6,12 +6,15 @@ settings:
6
7 catalogs:
8 default:
9 + '@effect/graphql-generator':
10 + specifier: 4.0.5
11 + version: 4.0.5
12 '@effect/openapi-generator':
10 - specifier: 4.0.4
11 - version: 4.0.4
13 + specifier: 4.0.5
14 + version: 4.0.5
15 '@effect/sql-sqlite-do':
13 - specifier: 4.0.4
14 - version: 4.0.4
16 + specifier: 4.0.5
17 + version: 4.0.5
18 '@effect/tsgo':
19 specifier: 0.51.1
20 version: 0.51.1
@@ -111,11 +114,11 @@ overrides:
114 '@clerk/expo': 4.6.8
115 '@clerk/react': 6.16.1
116 '@clerk/shared': 4.33.0
114 - '@effect/atom-react': 4.0.4
115 - '@effect/platform-node': 4.0.4
116 - '@effect/platform-node-shared': 4.0.4
117 - '@effect/sql-pg': 4.0.4
118 - '@effect/vitest': 4.0.4
117 + '@effect/atom-react': 4.0.5
118 + '@effect/platform-node': 4.0.5
119 + '@effect/platform-node-shared': 4.0.5
120 + '@effect/sql-pg': 4.0.5
121 + '@effect/vitest': 4.0.5
122 '@effect/vitest>vitest': '-'
123 '@expo/dom-webview': 58.0.2
124 '@expo/metro-config': 58.0.6
@@ -128,9 +131,9 @@ overrides:
131 '@tailwindcss/oxide': 4.3.3
132 '@tailwindcss/vite': 4.3.3
133 '@types/node': 24.12.4
131 - effect: 4.0.4
132 - '@opencode/protocol>effect': 4.0.4
133 - '@opencode/schema>effect': 4.0.4
134 + effect: 4.0.5
135 + '@opencode/protocol>effect': 4.0.5
136 + '@opencode/schema>effect': 4.0.5
137 node-abi: 4.33.0
138 electron-webauthn>@electron-webauthn/macos: 1.3.1
139 '@electron-webauthn/macos>objc-js': 1.5.0
@@ -147,7 +150,7 @@ packageExtensionsChecksum: sha256-FYDaKefjFcda1+vgiq8yMpZC4ehE5CyLi/bsCGLgTtY=
150
151 patchedDependencies:
152 '@clerk/expo@4.6.8': b8b22ab733de5bea846ad9e88046c10582352fe9ad86f314f368b2a823f0f281
150 - '@effect/vitest@4.0.4': ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad
153 + '@effect/vitest@4.0.5': 2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02
154 '@expo/metro-config@58.0.6': 90fa980e8b6480631fb2fbb04559834e3c612db40c550cd828f11be297d8d760
155 '@ff-labs/fff-node@0.11.0': cc71fcec015f4d39bc96ae2e2bf6b0ca678124c722c66a7841efce9d34b5983c
156 '@legendapp/list@3.3.5': 680cc6a5c5b4a4032e467e7b3fde22f89a84c0ee2e6eac6fda737d6277cc0806
@@ -208,8 +211,8 @@ importers:
211 specifier: 0.13.0
212 version: 0.13.0
213 '@effect/platform-node':
211 - specifier: 4.0.4
212 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
214 + specifier: 4.0.5
215 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
216 '@napi-rs/keyring':
217 specifier: ^1.3.0
218 version: 1.3.0
@@ -232,8 +235,8 @@ importers:
235 specifier: 0.10.2
236 version: 0.10.2(patch_hash=cfff57561b0ee59b5addb3b2e6c6f20906e967507a530ab67e8db8108e520ba4)
237 effect:
235 - specifier: 4.0.4
236 - version: 4.0.4
238 + specifier: 4.0.5
239 + version: 4.0.5
240 electron:
241 specifier: 44.4.5
242 version: 44.4.5
@@ -260,8 +263,8 @@ importers:
263 version: 7.4.2
264 devDependencies:
265 '@effect/vitest':
263 - specifier: 4.0.4
264 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
266 + specifier: 4.0.5
267 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
268 '@types/node':
269 specifier: 24.12.4
270 version: 24.12.4
@@ -309,8 +312,8 @@ importers:
312 specifier: 4.6.8
313 version: 4.6.8(patch_hash=b8b22ab733de5bea846ad9e88046c10582352fe9ad86f314f368b2a823f0f281)(9fda653cb5598772915b4a39a7aee91d)
314 '@effect/atom-react':
312 - specifier: 4.0.4
313 - version: 4.0.4(effect@4.0.4)(react@19.3.0)(scheduler@0.28.0)
315 + specifier: 4.0.5
316 + version: 4.0.5(effect@4.0.5)(react@19.3.0)(scheduler@0.28.0)
317 '@expo-google-fonts/dm-sans':
318 specifier: ^0.4.2
319 version: 0.4.2
@@ -408,8 +411,8 @@ importers:
411 specifier: 8.0.3
412 version: 8.0.3
413 effect:
411 - specifier: 4.0.4
412 - version: 4.0.4
414 + specifier: 4.0.5
415 + version: 4.0.5
416 expo:
417 specifier: 58.0.2
418 version: 58.0.2(bd4444e61fed72e958d45f73733b7f54)
@@ -580,8 +583,8 @@ importers:
583 version: 1.12.1(@expo/metro-config@58.0.6(patch_hash=90fa980e8b6480631fb2fbb04559834e3c612db40c550cd828f11be297d8d760)(bufferutil@4.1.0)(expo@58.0.2)(typescript@7.0.2)(utf-8-validate@6.0.6))(metro-cache@0.87.1)(metro-transform-worker@0.87.1(bufferutil@4.1.0)(utf-8-validate@6.0.6))(metro@0.87.1(bufferutil@4.1.0)(utf-8-validate@6.0.6))(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)(tailwindcss@4.3.3)
584 devDependencies:
585 '@effect/vitest':
583 - specifier: 4.0.4
584 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
586 + specifier: 4.0.5
587 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
588 '@pierre/trees':
589 specifier: 1.0.0-beta.6
590 version: 1.0.0-beta.6(@pierre/theme@2.0.0)(@shikijs/themes@4.2.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(shiki@4.2.0)
@@ -616,11 +619,11 @@ importers:
619 specifier: 1.0.35
620 version: 1.0.35
621 '@effect/platform-node':
619 - specifier: 4.0.4
620 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
622 + specifier: 4.0.5
623 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
624 '@effect/platform-node-shared':
622 - specifier: 4.0.4
623 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(utf-8-validate@6.0.6)
625 + specifier: 4.0.5
626 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(utf-8-validate@6.0.6)
627 '@ff-labs/fff-node':
628 specifier: 0.11.0
629 version: 0.11.0(patch_hash=cc71fcec015f4d39bc96ae2e2bf6b0ca678124c722c66a7841efce9d34b5983c)
@@ -679,8 +682,8 @@ importers:
682 specifier: workspace:*
683 version: link:../../packages/source-control-gitlab
684 effect:
682 - specifier: 4.0.4
683 - version: 4.0.4
685 + specifier: 4.0.5
686 + version: 4.0.5
687 jose:
688 specifier: 'catalog:'
689 version: 6.2.2
@@ -710,8 +713,8 @@ importers:
713 version: 3.4.0
714 devDependencies:
715 '@effect/vitest':
713 - specifier: 4.0.4
714 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
716 + specifier: 4.0.5
717 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
718 '@modelcontextprotocol/sdk':
719 specifier: 1.29.0
720 version: 1.29.0(zod@4.6.5)
@@ -782,8 +785,8 @@ importers:
785 specifier: ^3.2.2
786 version: 3.2.2(react@19.2.6)
787 '@effect/atom-react':
785 - specifier: 4.0.4
786 - version: 4.0.4(effect@4.0.4)(react@19.2.6)(scheduler@0.28.0)
788 + specifier: 4.0.5
789 + version: 4.0.5(effect@4.0.5)(react@19.2.6)(scheduler@0.28.0)
790 '@formkit/auto-animate':
791 specifier: ^0.9.0
792 version: 0.9.0
@@ -881,8 +884,8 @@ importers:
884 specifier: ^3.4.16
885 version: 3.4.16
886 effect:
884 - specifier: 4.0.4
885 - version: 4.0.4
887 + specifier: 4.0.5
888 + version: 4.0.5
889 hast-util-to-html:
890 specifier: ^9.0.5
891 version: 9.0.5
@@ -936,11 +939,11 @@ importers:
939 version: 5.0.14(@types/react@19.3.0)(react@19.2.6)(use-sync-external-store@1.6.0(react@19.2.6))
940 devDependencies:
941 '@effect/platform-node':
939 - specifier: 4.0.4
940 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
942 + specifier: 4.0.5
943 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
944 '@effect/vitest':
942 - specifier: 4.0.4
943 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
945 + specifier: 4.0.5
946 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
947 '@rolldown/plugin-babel':
948 specifier: ^0.2.0
949 version: 0.2.3(@babel/core@7.29.7)(@babel/plugin-transform-runtime@7.29.7(@babel/core@7.29.7))(@babel/runtime@7.29.7)(@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0))(rolldown@1.2.5)
@@ -1008,11 +1011,11 @@ importers:
1011 specifier: 3.18.1
1012 version: 3.18.1(react-dom@19.3.0(react@19.3.0))(react@19.2.6)
1013 '@effect/sql-pg':
1011 - specifier: 4.0.4
1012 - version: 4.0.4(effect@4.0.4)
1014 + specifier: 4.0.5
1015 + version: 4.0.5(effect@4.0.5)
1016 '@effect/sql-sqlite-do':
1017 specifier: 'catalog:'
1015 - version: 4.0.4(effect@4.0.4)
1018 + version: 4.0.5(effect@4.0.5)
1019 '@noble/curves':
1020 specifier: 'catalog:'
1021 version: 1.9.1
@@ -1030,23 +1033,23 @@ importers:
1033 version: link:../../packages/shared
1034 alchemy:
1035 specifier: 2.0.0-beta.80
1033 - version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(65456df005cbbd653b96024b9ea83b1c)
1036 + version: 2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(e32ed987c684265dc2dfa72f5ab4da0d)
1037 drizzle-orm:
1038 specifier: 1.0.0-rc.5-ab785fc
1036 - version: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.4))(@effect/sql-pg@4.0.4(effect@4.0.4))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.4))(@effect/sql-sqlite-do@4.0.4(effect@4.0.4))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.4)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3)
1039 + version: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3)
1040 effect:
1038 - specifier: 4.0.4
1039 - version: 4.0.4
1041 + specifier: 4.0.5
1042 + version: 4.0.5
1043 devDependencies:
1044 '@cloudflare/workers-types':
1045 specifier: ^4.20260601.1
1046 version: 4.20260604.1
1047 '@effect/platform-node':
1045 - specifier: 4.0.4
1046 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1048 + specifier: 4.0.5
1049 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1050 '@effect/vitest':
1048 - specifier: 4.0.4
1049 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1051 + specifier: 4.0.5
1052 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1053 '@types/node':
1054 specifier: 24.12.4
1055 version: 24.12.4
@@ -1066,18 +1069,18 @@ importers:
1069 oxlint-plugin-t3code:
1070 dependencies:
1071 '@effect/platform-node':
1069 - specifier: 4.0.4
1070 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1072 + specifier: 4.0.5
1073 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1074 '@oxlint/plugins':
1075 specifier: ^1.63.0
1076 version: 1.68.0
1077 effect:
1075 - specifier: 4.0.4
1076 - version: 4.0.4
1078 + specifier: 4.0.5
1079 + version: 4.0.5
1080 devDependencies:
1081 '@effect/vitest':
1079 - specifier: 4.0.4
1080 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1082 + specifier: 4.0.5
1083 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1084 vite-plus:
1085 specifier: 1.0.0
1086 version: 1.0.0(@types/node@24.12.4)(@vitest/ui@5.0.1(vitest@5.0.1))(bufferutil@4.1.0)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
@@ -1115,15 +1118,15 @@ importers:
1118 specifier: workspace:*
1119 version: link:../source-control-gitlab
1120 effect:
1118 - specifier: 4.0.4
1119 - version: 4.0.4
1121 + specifier: 4.0.5
1122 + version: 4.0.5
1123 three:
1124 specifier: 0.180.0
1125 version: 0.180.0
1126 devDependencies:
1127 '@effect/vitest':
1125 - specifier: 4.0.4
1126 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1128 + specifier: 4.0.5
1129 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1130 '@types/three':
1131 specifier: 0.180.0
1132 version: 0.180.0
@@ -1134,12 +1137,12 @@ importers:
1137 packages/contracts:
1138 dependencies:
1139 effect:
1137 - specifier: 4.0.4
1138 - version: 4.0.4
1140 + specifier: 4.0.5
1141 + version: 4.0.5
1142 devDependencies:
1143 '@effect/vitest':
1141 - specifier: 4.0.4
1142 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1144 + specifier: 4.0.5
1145 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1146 vite-plus:
1147 specifier: 1.0.0
1148 version: 1.0.0(@types/node@24.12.4)(@vitest/ui@5.0.1(vitest@5.0.1))(bufferutil@4.1.0)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
@@ -1147,18 +1150,18 @@ importers:
1150 packages/effect-acp:
1151 dependencies:
1152 effect:
1150 - specifier: 4.0.4
1151 - version: 4.0.4
1153 + specifier: 4.0.5
1154 + version: 4.0.5
1155 devDependencies:
1156 '@effect/openapi-generator':
1157 specifier: 'catalog:'
1155 - version: 4.0.4(@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.4)(encoding@0.1.13)
1158 + version: 4.0.5(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.5)(encoding@0.1.13)
1159 '@effect/platform-node':
1157 - specifier: 4.0.4
1158 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1160 + specifier: 4.0.5
1161 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1162 '@effect/vitest':
1160 - specifier: 4.0.4
1161 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1163 + specifier: 4.0.5
1164 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1165 '@types/node':
1166 specifier: 24.12.4
1167 version: 24.12.4
@@ -1169,18 +1172,18 @@ importers:
1172 packages/effect-codex-app-server:
1173 dependencies:
1174 effect:
1172 - specifier: 4.0.4
1173 - version: 4.0.4
1175 + specifier: 4.0.5
1176 + version: 4.0.5
1177 devDependencies:
1178 '@effect/openapi-generator':
1179 specifier: 'catalog:'
1177 - version: 4.0.4(@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.4)(encoding@0.1.13)
1180 + version: 4.0.5(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.5)(encoding@0.1.13)
1181 '@effect/platform-node':
1179 - specifier: 4.0.4
1180 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1182 + specifier: 4.0.5
1183 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1184 '@effect/vitest':
1182 - specifier: 4.0.4
1183 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1185 + specifier: 4.0.5
1186 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1187 '@types/node':
1188 specifier: 24.12.4
1189 version: 24.12.4
@@ -1203,15 +1206,15 @@ importers:
1206 specifier: 8.0.3
1207 version: 8.0.3
1208 effect:
1206 - specifier: 4.0.4
1207 - version: 4.0.4
1209 + specifier: 4.0.5
1210 + version: 4.0.5
1211 devDependencies:
1212 '@effect/platform-node':
1210 - specifier: 4.0.4
1211 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1213 + specifier: 4.0.5
1214 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1215 '@effect/vitest':
1213 - specifier: 4.0.4
1214 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1216 + specifier: 4.0.5
1217 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1218 '@types/node':
1219 specifier: 24.12.4
1220 version: 24.12.4
@@ -1240,15 +1243,15 @@ importers:
1243 specifier: workspace:*
1244 version: link:../shared
1245 effect:
1243 - specifier: 4.0.4
1244 - version: 4.0.4
1246 + specifier: 4.0.5
1247 + version: 4.0.5
1248 devDependencies:
1249 '@effect/platform-node':
1247 - specifier: 4.0.4
1248 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1250 + specifier: 4.0.5
1251 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1252 '@effect/vitest':
1250 - specifier: 4.0.4
1251 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1253 + specifier: 4.0.5
1254 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1255 '@t3tools/provider-testing':
1256 specifier: workspace:*
1257 version: link:../provider-testing
@@ -1271,15 +1274,15 @@ importers:
1274 specifier: workspace:*
1275 version: link:../shared
1276 effect:
1274 - specifier: 4.0.4
1275 - version: 4.0.4
1277 + specifier: 4.0.5
1278 + version: 4.0.5
1279 devDependencies:
1280 '@effect/platform-node':
1278 - specifier: 4.0.4
1279 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1281 + specifier: 4.0.5
1282 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1283 '@effect/vitest':
1281 - specifier: 4.0.4
1282 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1284 + specifier: 4.0.5
1285 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1286 '@types/node':
1287 specifier: 24.12.4
1288 version: 24.12.4
@@ -1305,18 +1308,18 @@ importers:
1308 specifier: workspace:*
1309 version: link:../shared
1310 effect:
1308 - specifier: 4.0.4
1309 - version: 4.0.4
1311 + specifier: 4.0.5
1312 + version: 4.0.5
1313 yaml:
1314 specifier: ^2.9.0
1315 version: 2.9.0
1316 devDependencies:
1317 '@effect/platform-node':
1315 - specifier: 4.0.4
1316 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1318 + specifier: 4.0.5
1319 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1320 '@effect/vitest':
1318 - specifier: 4.0.4
1319 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1321 + specifier: 4.0.5
1322 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1323 '@t3tools/provider-testing':
1324 specifier: workspace:*
1325 version: link:../provider-testing
@@ -1342,15 +1345,15 @@ importers:
1345 specifier: workspace:*
1346 version: link:../shared
1347 effect:
1345 - specifier: 4.0.4
1346 - version: 4.0.4
1348 + specifier: 4.0.5
1349 + version: 4.0.5
1350 devDependencies:
1351 '@effect/platform-node':
1349 - specifier: 4.0.4
1350 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1352 + specifier: 4.0.5
1353 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1354 '@effect/vitest':
1352 - specifier: 4.0.4
1353 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1355 + specifier: 4.0.5
1356 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1357 '@t3tools/provider-testing':
1358 specifier: workspace:*
1359 version: link:../provider-testing
@@ -1379,15 +1382,15 @@ importers:
1382 specifier: workspace:*
1383 version: link:../shared
1384 effect:
1382 - specifier: 4.0.4
1383 - version: 4.0.4
1385 + specifier: 4.0.5
1386 + version: 4.0.5
1387 devDependencies:
1388 '@effect/platform-node':
1386 - specifier: 4.0.4
1387 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1389 + specifier: 4.0.5
1390 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1391 '@effect/vitest':
1389 - specifier: 4.0.4
1390 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1392 + specifier: 4.0.5
1393 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1394 '@t3tools/provider-testing':
1395 specifier: workspace:*
1396 version: link:../provider-testing
@@ -1405,7 +1408,7 @@ importers:
1408 version: 1.15.13
1409 '@opencode/client':
1410 specifier: 2.0.28
1408 - version: 2.0.28(effect@4.0.4)
1411 + version: 2.0.28(effect@4.0.5)
1412 '@opencode/protocol':
1413 specifier: 2.0.28
1414 version: 2.0.28
@@ -1422,15 +1425,15 @@ importers:
1425 specifier: workspace:*
1426 version: link:../shared
1427 effect:
1425 - specifier: 4.0.4
1426 - version: 4.0.4
1428 + specifier: 4.0.5
1429 + version: 4.0.5
1430 devDependencies:
1431 '@effect/platform-node':
1429 - specifier: 4.0.4
1430 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1432 + specifier: 4.0.5
1433 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1434 '@effect/vitest':
1432 - specifier: 4.0.4
1433 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1435 + specifier: 4.0.5
1436 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1437 '@t3tools/provider-testing':
1438 specifier: workspace:*
1439 version: link:../provider-testing
@@ -1453,15 +1456,15 @@ importers:
1456 specifier: workspace:*
1457 version: link:../shared
1458 effect:
1456 - specifier: 4.0.4
1457 - version: 4.0.4
1459 + specifier: 4.0.5
1460 + version: 4.0.5
1461 devDependencies:
1462 '@effect/platform-node':
1460 - specifier: 4.0.4
1461 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1463 + specifier: 4.0.5
1464 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1465 '@effect/vitest':
1463 - specifier: 4.0.4
1464 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1466 + specifier: 4.0.5
1467 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1468 '@t3tools/provider-testing':
1469 specifier: workspace:*
1470 version: link:../provider-testing
@@ -1475,8 +1478,8 @@ importers:
1478 packages/provider-testing:
1479 dependencies:
1480 '@effect/platform-node':
1478 - specifier: 4.0.4
1479 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1481 + specifier: 4.0.5
1482 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1483 '@t3tools/contracts':
1484 specifier: workspace:*
1485 version: link:../contracts
@@ -1487,12 +1490,12 @@ importers:
1490 specifier: workspace:*
1491 version: link:../shared
1492 effect:
1490 - specifier: 4.0.4
1491 - version: 4.0.4
1493 + specifier: 4.0.5
1494 + version: 4.0.5
1495 devDependencies:
1496 '@effect/vitest':
1494 - specifier: 4.0.4
1495 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1497 + specifier: 4.0.5
1498 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1499 '@types/node':
1500 specifier: 24.12.4
1501 version: 24.12.4
@@ -1512,8 +1515,8 @@ importers:
1515 specifier: workspace:*
1516 version: link:../contracts
1517 effect:
1515 - specifier: 4.0.4
1516 - version: 4.0.4
1518 + specifier: 4.0.5
1519 + version: 4.0.5
1520 jose:
1521 specifier: 'catalog:'
1522 version: 6.2.2
@@ -1552,11 +1555,11 @@ importers:
1555 version: 2.9.0
1556 devDependencies:
1557 '@effect/platform-node':
1555 - specifier: 4.0.4
1556 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1558 + specifier: 4.0.5
1559 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1560 '@effect/vitest':
1558 - specifier: 4.0.4
1559 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1561 + specifier: 4.0.5
1562 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1563 '@types/node':
1564 specifier: 24.12.4
1565 version: 24.12.4
@@ -1582,15 +1585,15 @@ importers:
1585 specifier: 8.0.3
1586 version: 8.0.3
1587 effect:
1585 - specifier: 4.0.4
1586 - version: 4.0.4
1588 + specifier: 4.0.5
1589 + version: 4.0.5
1590 devDependencies:
1591 '@effect/platform-node':
1589 - specifier: 4.0.4
1590 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1592 + specifier: 4.0.5
1593 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1594 '@effect/vitest':
1592 - specifier: 4.0.4
1593 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1595 + specifier: 4.0.5
1596 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1597 '@t3tools/source-control-testing':
1598 specifier: workspace:*
1599 version: link:../source-control-testing
@@ -1616,12 +1619,12 @@ importers:
1619 specifier: workspace:*
1620 version: link:../source-control-core
1621 effect:
1619 - specifier: 4.0.4
1620 - version: 4.0.4
1622 + specifier: 4.0.5
1623 + version: 4.0.5
1624 devDependencies:
1625 '@effect/vitest':
1623 - specifier: 4.0.4
1624 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1626 + specifier: 4.0.5
1627 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1628 '@types/node':
1629 specifier: 24.12.4
1630 version: 24.12.4
@@ -1638,12 +1641,12 @@ importers:
1641 specifier: workspace:*
1642 version: link:../shared
1643 effect:
1641 - specifier: 4.0.4
1642 - version: 4.0.4
1644 + specifier: 4.0.5
1645 + version: 4.0.5
1646 devDependencies:
1647 '@effect/vitest':
1645 - specifier: 4.0.4
1646 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1648 + specifier: 4.0.5
1649 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1650 '@types/node':
1651 specifier: 24.12.4
1652 version: 24.12.4
@@ -1666,12 +1669,12 @@ importers:
1669 specifier: workspace:*
1670 version: link:../source-control-core
1671 effect:
1669 - specifier: 4.0.4
1670 - version: 4.0.4
1672 + specifier: 4.0.5
1673 + version: 4.0.5
1674 devDependencies:
1675 '@effect/vitest':
1673 - specifier: 4.0.4
1674 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1676 + specifier: 4.0.5
1677 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1678 '@t3tools/source-control-testing':
1679 specifier: workspace:*
1680 version: link:../source-control-testing
@@ -1697,12 +1700,12 @@ importers:
1700 specifier: workspace:*
1701 version: link:../source-control-core
1702 effect:
1700 - specifier: 4.0.4
1701 - version: 4.0.4
1703 + specifier: 4.0.5
1704 + version: 4.0.5
1705 devDependencies:
1706 '@effect/vitest':
1704 - specifier: 4.0.4
1705 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1707 + specifier: 4.0.5
1708 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1709 '@t3tools/source-control-testing':
1710 specifier: workspace:*
1711 version: link:../source-control-testing
@@ -1728,15 +1731,18 @@ importers:
1731 specifier: workspace:*
1732 version: link:../source-control-core
1733 effect:
1731 - specifier: 4.0.4
1732 - version: 4.0.4
1734 + specifier: 4.0.5
1735 + version: 4.0.5
1736 devDependencies:
1737 + '@effect/graphql-generator':
1738 + specifier: 'catalog:'
1739 + version: 4.0.5(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.5)
1740 '@effect/platform-node':
1735 - specifier: 4.0.4
1736 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1741 + specifier: 4.0.5
1742 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1743 '@effect/vitest':
1738 - specifier: 4.0.4
1739 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1744 + specifier: 4.0.5
1745 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1746 '@t3tools/source-control-testing':
1747 specifier: workspace:*
1748 version: link:../source-control-testing
@@ -1759,12 +1765,12 @@ importers:
1765 specifier: workspace:*
1766 version: link:../source-control-core
1767 effect:
1762 - specifier: 4.0.4
1763 - version: 4.0.4
1768 + specifier: 4.0.5
1769 + version: 4.0.5
1770 devDependencies:
1771 '@effect/vitest':
1766 - specifier: 4.0.4
1767 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1772 + specifier: 4.0.5
1773 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1774 '@t3tools/source-control-testing':
1775 specifier: workspace:*
1776 version: link:../source-control-testing
@@ -1787,8 +1793,8 @@ importers:
1793 specifier: workspace:*
1794 version: link:../source-control-core
1795 effect:
1790 - specifier: 4.0.4
1791 - version: 4.0.4
1796 + specifier: 4.0.5
1797 + version: 4.0.5
1798 devDependencies:
1799 '@types/node':
1800 specifier: 24.12.4
@@ -1803,15 +1809,15 @@ importers:
1809 specifier: workspace:*
1810 version: link:../shared
1811 effect:
1806 - specifier: 4.0.4
1807 - version: 4.0.4
1812 + specifier: 4.0.5
1813 + version: 4.0.5
1814 devDependencies:
1815 '@effect/platform-node':
1810 - specifier: 4.0.4
1811 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1816 + specifier: 4.0.5
1817 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1818 '@effect/vitest':
1813 - specifier: 4.0.4
1814 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1819 + specifier: 4.0.5
1820 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1821 '@types/node':
1822 specifier: 24.12.4
1823 version: 24.12.4
@@ -1825,12 +1831,12 @@ importers:
1831 specifier: workspace:*
1832 version: link:../shared
1833 effect:
1828 - specifier: 4.0.4
1829 - version: 4.0.4
1834 + specifier: 4.0.5
1835 + version: 4.0.5
1836 devDependencies:
1837 '@effect/vitest':
1832 - specifier: 4.0.4
1833 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1838 + specifier: 4.0.5
1839 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1840 '@types/node':
1841 specifier: 24.12.4
1842 version: 24.12.4
@@ -1841,8 +1847,8 @@ importers:
1847 scripts:
1848 dependencies:
1849 '@effect/platform-node':
1844 - specifier: 4.0.4
1845 - version: 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
1850 + specifier: 4.0.5
1851 + version: 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
1852 '@electron/asar':
1853 specifier: ^4.3.0
1854 version: 4.3.0
@@ -1856,8 +1862,8 @@ importers:
1862 specifier: workspace:*
1863 version: link:../packages/tailscale
1864 effect:
1859 - specifier: 4.0.4
1860 - version: 4.0.4
1865 + specifier: 4.0.5
1866 + version: 4.0.5
1867 plist:
1868 specifier: 'catalog:'
1869 version: 3.1.1
@@ -1869,8 +1875,8 @@ importers:
1875 version: 0.35.4(@types/node@24.12.4)
1876 devDependencies:
1877 '@effect/vitest':
1872 - specifier: 4.0.4
1873 - version: 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1878 + specifier: 4.0.5
1879 + version: 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1880 '@types/plist':
1881 specifier: 'catalog:'
1882 version: 3.0.5
@@ -1917,8 +1923,8 @@ packages:
1923 peerDependencies:
1924 '@distilled.cloud/cloudflare': 1.0.0-rc.13
1925 '@effect/platform-bun': ^4.0.0
1920 - '@effect/platform-node': 4.0.4
1921 - effect: 4.0.4
1926 + '@effect/platform-node': 4.0.5
1927 + effect: 4.0.5
1928 rolldown: 1.2.5
1929 vite: ^7.0.0 || ^8.0.0
1930 peerDependenciesMeta:
@@ -1934,7 +1940,7 @@ packages:
1940 '@alchemy.run/floci@2.0.0-beta.80':
1941 resolution: {integrity: sha512-gtUXFitVY9pSQQYCDtSVyjfd5YOKY3Wleg3WCG5yWno7/l7xBo4kfOMbM63tzWnmka9LewVSITbMfwnC4D/73A==}
1942 peerDependencies:
1937 - effect: 4.0.4
1943 + effect: 4.0.5
1944
1945 '@alchemy.run/node-utils@2.0.0-beta.80':
1946 resolution: {integrity: sha512-uOhVDQZTjwh1AU4mrk0wB5rQaziTwSrVMfqwFP8wALfU//nveu4goOWZimHtqytXiybENh+iEbALH25EFAkc7A==}
@@ -2972,82 +2978,82 @@ packages:
2978 '@distilled.cloud/acme@1.0.0-rc.13':
2979 resolution: {integrity: sha512-3rmzH125jQxk0zpCvXGNEybSaqpAolyCX+8LWDDrXf+wIKs67GflkJyQLjOOh0lKARe29hdUZGgqEbbvpp0LNA==}
2980 peerDependencies:
2975 - effect: 4.0.4
2981 + effect: 4.0.5
2982
2983 '@distilled.cloud/aws@1.0.0-rc.13':
2984 resolution: {integrity: sha512-6ZGcp0LkniB0I2l8Gr7vKRQgTZTch0/07iuvuMZv9Nu+rWwNuZG9VHTUdlIoarWgCHFUNN8yvSYBGOjaeN99tQ==}
2985 peerDependencies:
2980 - effect: 4.0.4
2986 + effect: 4.0.5
2987
2988 '@distilled.cloud/axiom@1.0.0-rc.13':
2989 resolution: {integrity: sha512-aRoJtvfXgWi5dtfjuJvDwnArRKvv2MPYHCxYeZcxZbqe62IaQA5yu/khft7TJvxeDyJoSDnVXZu3RyJjNmBA4g==}
2990 peerDependencies:
2985 - effect: 4.0.4
2991 + effect: 4.0.5
2992
2993 '@distilled.cloud/cloudflare@1.0.0-rc.13':
2994 resolution: {integrity: sha512-Py5FoA6azyYExDb91VaeC+9x+ravOBSRhXeUmpcQjCtgqmOdiXgc2YZGMMPI68DF+kMuHRVIrR+2uRZNDOhYjw==}
2995 peerDependencies:
2990 - effect: 4.0.4
2996 + effect: 4.0.5
2997
2998 '@distilled.cloud/core@1.0.0-rc.13':
2999 resolution: {integrity: sha512-RYyrxW+F5zrTuu1UWV/JoycholBCIkXIusYJdDniDwCdmbjdKGl07KlkkeeY774uBawNGf+pt1ESNGeLVnNHsg==}
3000 peerDependencies:
2995 - effect: 4.0.4
3001 + effect: 4.0.5
3002
3003 '@distilled.cloud/doppler@1.0.0-rc.13':
3004 resolution: {integrity: sha512-GgOEUCc4Bx0C+lYNfZ4OqaA3ULvqDUQTJC8gobSh1L0jfrWclv/kRcSr43v4IXyStld+saUvDfDZgeGzlE74OA==}
3005 peerDependencies:
3000 - effect: 4.0.4
3006 + effect: 4.0.5
3007
3008 '@distilled.cloud/fly-io@1.0.0-rc.13':
3009 resolution: {integrity: sha512-Ipp+9nvs+PzqwDPhZq2/BEHNUeWzXKhrvjfT/eBLFHo/QpH0HgdMH8MSQe6/LGszZoormwA6ZrTv2wxaFO7ZiQ==}
3010 peerDependencies:
3005 - effect: 4.0.4
3011 + effect: 4.0.5
3012
3013 '@distilled.cloud/gcp@1.0.0-rc.13':
3014 resolution: {integrity: sha512-un8jqil9ejt96oN+OfEDUsbrEOpC6Ut4B/73DqKDttvt0Btal1OeBNTTQsftVCpeEzXAvkYKGRIT2AeEu1J5jA==}
3015 peerDependencies:
3010 - effect: 4.0.4
3016 + effect: 4.0.5
3017
3018 '@distilled.cloud/hetzner@1.0.0-rc.13':
3019 resolution: {integrity: sha512-FvqofgMypNkeZbnjGjWMZqvqGd9GxcMzdbi/6JrbcPaHMJG+CCBGt/mAa7mLlEovzwVaGCsBnOXJ6rP5pZjB4Q==}
3020 peerDependencies:
3015 - effect: 4.0.4
3021 + effect: 4.0.5
3022
3023 '@distilled.cloud/infisical@1.0.0-rc.13':
3024 resolution: {integrity: sha512-Zz8ksA/Y8UUUnWag2UBxB5WYA6wLqOS78ugWJ3cOr9Ot+4bC0NJYWanq35uFInozLXWhun84USU2wOI+mdwQUQ==}
3025 peerDependencies:
3020 - effect: 4.0.4
3026 + effect: 4.0.5
3027
3028 '@distilled.cloud/neon@1.0.0-rc.13':
3029 resolution: {integrity: sha512-2JvbBFj1kBfkDVPnWcJZ7TJ1cJwWBtScAY7SNJ2qNBUuAK1Wf2kjJXU0/j16eCJ48BQigPArQFWL51wVu/EUQQ==}
3030 peerDependencies:
3025 - effect: 4.0.4
3031 + effect: 4.0.5
3032
3033 '@distilled.cloud/planetscale@1.0.0-rc.13':
3034 resolution: {integrity: sha512-AM97YGRnDfZdqsxFgQMQ83p7ZlRqxS6/foTTJA5P590UMbbOyrQyFyd33BD0agul8a3ngZde3Oej6v7BN55aWw==}
3035 peerDependencies:
3030 - effect: 4.0.4
3036 + effect: 4.0.5
3037
3038 '@distilled.cloud/prisma@1.0.0-rc.13':
3039 resolution: {integrity: sha512-+UmHSp9JV8XQl5t5tTdQBY+dWZ9abrEoc7leYEctA0Ar1TrKZEl2EaeQDoumrg4RyGaacRlirEbxaDFI4SOPtQ==}
3040 peerDependencies:
3035 - effect: 4.0.4
3041 + effect: 4.0.5
3042
3043 '@distilled.cloud/railway@1.0.0-rc.13':
3044 resolution: {integrity: sha512-yXalRS3GFLo3hWM0HXptqudi23NVCM4FRD20db2/Ob9FFcNrMJik1fopv+74HOiV+BuxfkCP609KsEK6LVdB/g==}
3045 peerDependencies:
3040 - effect: 4.0.4
3046 + effect: 4.0.5
3047
3048 '@distilled.cloud/stripe@1.0.0-rc.13':
3049 resolution: {integrity: sha512-jLTJ1mg4U39lHZb9EGYBJLR91yB3LSG6fVxix+r1BbqaTovWzE+NuJ7fu9fRSeax9jRAqsGLLxe9IxJbOtwQnQ==}
3050 peerDependencies:
3045 - effect: 4.0.4
3051 + effect: 4.0.5
3052
3053 '@distilled.cloud/zerossl@1.0.0-rc.13':
3054 resolution: {integrity: sha512-dnxhg39lZjpTdZbHCVYPoUC9E2r8eSHbqiYDhSq2EurVPJcc9YRXlxZR1bP1nniSp078XV8GA+aUECt/Z56aQg==}
3055 peerDependencies:
3050 - effect: 4.0.4
3056 + effect: 4.0.5
3057
3058 '@dnd-kit/accessibility@3.1.1':
3059 resolution: {integrity: sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw==}
@@ -3080,52 +3086,59 @@ packages:
3086 '@drizzle-team/brocli@0.12.0':
3087 resolution: {integrity: sha512-mlUE+rZ8CatQekLhnaiN91Iemdd+e2gFKooGlnRB3oPTL3VghLfX24dx7HrzMNeC1JrIB/0kpsfyty3f5HNfxQ==}
3088
3083 - '@effect/atom-react@4.0.4':
3084 - resolution: {integrity: sha512-/cd4zHAS/j4QEAJahvIuvCjASI9iKPsKoYDJF1WdqBH6ol+7PIzV5jfIxyd5K0hTlLlavZnzEfi849pcS84apg==}
3089 + '@effect/atom-react@4.0.5':
3090 + resolution: {integrity: sha512-tqTSiy0rWBitej7kPfvTSw29q4ipof52+txDg6bIBJx0ksHVzVXaFTsssDa+AZBeImafK0xmjm9m1XzPfE6k2A==}
3091 peerDependencies:
3086 - effect: 4.0.4
3092 + effect: 4.0.5
3093 react: '>=19.0.0 <20.0.0'
3094 scheduler: '>=0.25.0 <0.29.0'
3095
3090 - '@effect/openapi-generator@4.0.4':
3091 - resolution: {integrity: sha512-5TcA4HP2Eml1Y3DCP1JCojYVeioGrtr9MxDDWCKYrfUQx2U/JRcnCzH0rJ+sD5obUAn9QKw2QIvb+/A3mxP35w==}
3096 + '@effect/graphql-generator@4.0.5':
3097 + resolution: {integrity: sha512-2QtEQxP4RRANWVJVe/wQBmG6SGePDfhgqpOeyfa7JlTsbnJbf3J25lmTz/faO3fGgicTVTTMruHTY6CR16KILg==}
3098 hasBin: true
3099 peerDependencies:
3094 - '@effect/platform-node': 4.0.4
3095 - effect: 4.0.4
3100 + '@effect/platform-node': 4.0.5
3101 + effect: 4.0.5
3102
3097 - '@effect/platform-node-shared@4.0.4':
3098 - resolution: {integrity: sha512-gh2KRmqGWrJ0FVL8GqnI1GpB+fCfCUI7sGiUZkxxBHyHj1t94rm6VDJffCfuVZWe6GpvYXtizifVczUrgOce8A==}
3103 + '@effect/openapi-generator@4.0.5':
3104 + resolution: {integrity: sha512-pksR5BhRKQQfDcpA8AbxCiAFLAbdnZseiRmgr1UtVi1x/IyEuS8WmXoFD1C424TEyS+n2Q6lPpR0ue/WQ743aw==}
3105 + hasBin: true
3106 + peerDependencies:
3107 + '@effect/platform-node': 4.0.5
3108 + effect: 4.0.5
3109 +
3110 + '@effect/platform-node-shared@4.0.5':
3111 + resolution: {integrity: sha512-a8rCdEkfZBGe9C6bsIjxVZuRp73svIyK5IHwHdDAVsvZXjrbkxusfI+rZ8WlX31RP1mKizwI/E72GQTNfdMWHw==}
3112 engines: {node: '>=18.0.0'}
3113 peerDependencies:
3101 - effect: 4.0.4
3114 + effect: 4.0.5
3115
3103 - '@effect/platform-node@4.0.4':
3104 - resolution: {integrity: sha512-SdoyQMrO5zmqBebb2fxDk0sHYyJjBiw4QmLdV2ZcWf3ATpQPge3B5sTLijZg49PadekOwNeO83o5TfdtiiFEig==}
3116 + '@effect/platform-node@4.0.5':
3117 + resolution: {integrity: sha512-v4KD5fWvEUa4QmWFpZFbBsRhmfnTP6ETCME2r9ifyXVDPjhfpxpTZl41prjgQFMqZBHdWWCl7YC5ImbXv5ui5g==}
3118 engines: {node: '>=18.0.0'}
3119 peerDependencies:
3107 - effect: 4.0.4
3120 + effect: 4.0.5
3121 redis: '>=5.0.0 <7.0.0'
3122
3123 '@effect/sql-d1@4.0.0':
3124 resolution: {integrity: sha512-pmkzncZCGD6CLyvc89keEBU85h+gHVCu/LKQnThd+ruYSUbG0R9jYA+lnk3R8Djp0wQW6SbsbmHQuhopIYyo3Q==}
3125 peerDependencies:
3113 - effect: 4.0.4
3126 + effect: 4.0.5
3127
3115 - '@effect/sql-pg@4.0.4':
3116 - resolution: {integrity: sha512-41x5O2C+gRF3A/Sf+IkV+OOzo5BexsIubH1cib3m4NwhZcjQUQUrq5YbOw7fIuWmBODtAyHNXFjaeEtiXoPL9Q==}
3128 + '@effect/sql-pg@4.0.5':
3129 + resolution: {integrity: sha512-F9tG76H+aryhYcp5pvgd+MwWrNltv3XAuLcZSBsOOX6q+PEl+IM4zkQKzx0TF9OsEMH/SQ+3gZRdYWOsDF+vJQ==}
3130 peerDependencies:
3118 - effect: 4.0.4
3131 + effect: 4.0.5
3132
3133 '@effect/sql-sqlite-bun@4.0.0-rc.112':
3134 resolution: {integrity: sha512-EqR8pWZo3VzedRvP6qo5HcfqNmFvSa+sQLWQl3oBMx2KY1FCc8NYjep79wYjNkW0qABnffrPUXCMTOncd1A+5g==}
3135 peerDependencies:
3123 - effect: 4.0.4
3136 + effect: 4.0.5
3137
3125 - '@effect/sql-sqlite-do@4.0.4':
3126 - resolution: {integrity: sha512-6Uqa6zbm5GPTWjoIVVty8msQ5C+8coPQDzj8qZM9Mk4NXUWa/RVlaziW335mXZ/8tCnQsFj2iJ/CJdv54JXuew==}
3138 + '@effect/sql-sqlite-do@4.0.5':
3139 + resolution: {integrity: sha512-TGlU65ZJJMa81I7EoicQXxhRsJDxDPz6A/PNOPzMYRgmCdLs6EsTTXIkKZ+8apb7pl2o0OKVcrT6i6mGlluyLg==}
3140 peerDependencies:
3128 - effect: 4.0.4
3141 + effect: 4.0.5
3142
3143 '@effect/tsgo-darwin-arm64@0.51.1':
3144 resolution: {integrity: sha512-Jx+1RB3pz1B2zYs1EmxybwDOq9KRpfdu/rn1XTULNMZmqUJZuvTQU9CRqB0g/ZgIa6MeNBZEYvmAu4Dq2/QVWA==}
@@ -3166,10 +3179,10 @@ packages:
3179 resolution: {integrity: sha512-i6mA6cNah+0mkPdu8qZILCO3Pnd9kWo03/s82Ju+1DFhdL28HFagi+1PRGxqgq1uMaHziWQ+ciKvOmIoks2RdA==}
3180 hasBin: true
3181
3169 - '@effect/vitest@4.0.4':
3170 - resolution: {integrity: sha512-l5KN46RbDVpqZxWzwXZtX6FVQiyzd+/hTYqL543uSDRo7hC0m19IeICh6O9U/nqCtfersqsNZnBjgHFfkuHsBw==}
3182 + '@effect/vitest@4.0.5':
3183 + resolution: {integrity: sha512-q64paZ/i4V2NiRhTyqCmT2KiDbFjlxc2EZrZca8GGt+Nf8844946HyJM5bPk/q+YeRkFSxIrlCs+J+LSfky/wA==}
3184 peerDependencies:
3172 - effect: 4.0.4
3185 + effect: 4.0.5
3186
3187 '@electric-sql/pglite@0.3.15':
3188 resolution: {integrity: sha512-Cj++n1Mekf9ETfdc16TlDi+cDDQF0W7EcbyRHYOAeZdsAe8M/FJg18itDTSwyHfar2WIezawM9o0EKaRGVKygQ==}
@@ -4525,7 +4538,7 @@ packages:
4538 '@opencode/client@2.0.28':
4539 resolution: {integrity: sha512-YV0Yxk93/K2h4Xy/sEW/4ZYGMwn7ltxG2Y/Vdy2VCIZ2z0/r9MI6x5/XawSNfCvImBxuHkQNbYtu9Rgp3ArJ4g==}
4540 peerDependencies:
4528 - effect: 4.0.4
4541 + effect: 4.0.5
4542 solid-js: '>=1.9.0'
4543 peerDependenciesMeta:
4544 effect:
@@ -7145,15 +7158,15 @@ packages:
7158 '@alchemy.run/frontend-frameworks': 2.0.0-beta.80
7159 '@aws/durable-execution-sdk-js': ^2.1.0
7160 '@effect/platform-bun': ^4.0.0
7148 - '@effect/platform-node': 4.0.4
7161 + '@effect/platform-node': 4.0.5
7162 '@effect/sql-mysql2': ^4.0.0
7150 - '@effect/sql-pg': 4.0.4
7151 - '@effect/vitest': 4.0.4
7163 + '@effect/sql-pg': 4.0.5
7164 + '@effect/vitest': 4.0.5
7165 '@prisma/orm-postgres': 8.0.0-rc.11
7166 '@vercel/nft': ^1.10.2
7167 drizzle-kit: 1.0.0-rc.5-ab785fc
7168 drizzle-orm: 1.0.0-rc.5-ab785fc
7156 - effect: 4.0.4
7169 + effect: 4.0.5
7170 mongodb: ^6.10.0
7171 mysql2: ^3.24.2
7172 pg: ^8.22.0
@@ -8183,7 +8196,7 @@ packages:
8196 '@effect/sql-d1': '>=4.0.0-beta.105 || >=4.0.0'
8197 '@effect/sql-libsql': '>=4.0.0-beta.105 || >=4.0.0'
8198 '@effect/sql-mysql2': '>=4.0.0-beta.105 || >=4.0.0'
8186 - '@effect/sql-pg': 4.0.4
8199 + '@effect/sql-pg': 4.0.5
8200 '@effect/sql-pglite': '>=4.0.0-beta.105 || >=4.0.0'
8201 '@effect/sql-sqlite-bun': '>=4.0.0-beta.105 || >=4.0.0'
8202 '@effect/sql-sqlite-do': '>=4.0.0-beta.105 || >=4.0.0'
@@ -8214,7 +8227,7 @@ packages:
8227 arktype: '>=2.0.0'
8228 better-sqlite3: '>=9.3.0'
8229 bun-types: '*'
8217 - effect: 4.0.4
8230 + effect: 4.0.5
8231 expo-sqlite: '>=14.0.0'
8232 minipg: '>=0.2.0'
8233 mssql: ^11.0.1
@@ -8341,8 +8354,8 @@ packages:
8354 ee-first@1.1.1:
8355 resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
8356
8344 - effect@4.0.4:
8345 - resolution: {integrity: sha512-Sr50OeVSC3M5UkoUYUhFf3EULryhGaZZUf6OzDHTvaznOw7HRlxOKdF3/4nvQXHL22StOyMG3Cvo8Bt7xUp+Ng==}
8357 + effect@4.0.5:
8358 + resolution: {integrity: sha512-BY4/28NlpOd99yzmV741xbVGmp+1U7tks4oB7F/Png64bTa5tm5eCA6W0RiXsnuLDDoJpjfVSo4Dnq4BZb/89Q==}
8359
8360 ejs@3.1.10:
8361 resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==}
@@ -12435,14 +12448,14 @@ snapshots:
12448 dependencies:
12449 json-schema: 0.4.0
12450
12438 - '@alchemy.run/cloudflare-runtime@2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.4))(@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6))(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.4)(rolldown@1.2.5)(typescript@7.0.2)':
12451 + '@alchemy.run/cloudflare-runtime@2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.5))(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.5)(rolldown@1.2.5)(typescript@7.0.2)':
12452 dependencies:
12453 '@alchemy.run/node-utils': 2.0.0-beta.80
12454 '@cloudflare/unenv-preset': 2.16.1(unenv@2.0.0-rc.24)(workerd@1.20260918.1)
12442 - '@distilled.cloud/cloudflare': 1.0.0-rc.13(effect@4.0.4)
12455 + '@distilled.cloud/cloudflare': 1.0.0-rc.13(effect@4.0.5)
12456 '@puppeteer/browsers': 3.2.2(yauzl@3.4.0)
12457 capnp-es: 0.0.16(typescript@7.0.2)
12445 - effect: 4.0.4
12458 + effect: 4.0.5
12459 magic-string: 0.30.21
12460 mime: 4.1.0
12461 sharp: 0.35.4(@types/node@24.12.4)
@@ -12450,7 +12463,7 @@ snapshots:
12463 workerd: 1.20260918.1
12464 yauzl: 3.4.0
12465 optionalDependencies:
12453 - '@effect/platform-node': 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
12466 + '@effect/platform-node': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
12467 rolldown: 1.2.5
12468 vite: '@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0)'
12469 transitivePeerDependencies:
@@ -12458,9 +12471,9 @@ snapshots:
12471 - proxy-agent
12472 - typescript
12473
12461 - '@alchemy.run/floci@2.0.0-beta.80(effect@4.0.4)':
12474 + '@alchemy.run/floci@2.0.0-beta.80(effect@4.0.5)':
12475 dependencies:
12463 - effect: 4.0.4
12476 + effect: 4.0.5
12477
12478 '@alchemy.run/node-utils@2.0.0-beta.80':
12479 dependencies:
@@ -13742,86 +13755,86 @@ snapshots:
13755
13756 '@dimforge/rapier3d-compat@0.12.0': {}
13757
13745 - '@distilled.cloud/acme@1.0.0-rc.13(effect@4.0.4)':
13758 + '@distilled.cloud/acme@1.0.0-rc.13(effect@4.0.5)':
13759 dependencies:
13747 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13748 - effect: 4.0.4
13760 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13761 + effect: 4.0.5
13762
13750 - '@distilled.cloud/aws@1.0.0-rc.13(effect@4.0.4)':
13763 + '@distilled.cloud/aws@1.0.0-rc.13(effect@4.0.5)':
13764 dependencies:
13752 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13765 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13766 '@smithy/types': 4.18.0
13754 - effect: 4.0.4
13767 + effect: 4.0.5
13768
13756 - '@distilled.cloud/axiom@1.0.0-rc.13(effect@4.0.4)':
13769 + '@distilled.cloud/axiom@1.0.0-rc.13(effect@4.0.5)':
13770 dependencies:
13758 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13759 - effect: 4.0.4
13771 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13772 + effect: 4.0.5
13773
13761 - '@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.4)':
13774 + '@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.5)':
13775 dependencies:
13763 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13764 - effect: 4.0.4
13776 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13777 + effect: 4.0.5
13778
13766 - '@distilled.cloud/core@1.0.0-rc.13(effect@4.0.4)':
13779 + '@distilled.cloud/core@1.0.0-rc.13(effect@4.0.5)':
13780 dependencies:
13768 - effect: 4.0.4
13781 + effect: 4.0.5
13782 graphql: 16.11.0
13783
13771 - '@distilled.cloud/doppler@1.0.0-rc.13(effect@4.0.4)':
13784 + '@distilled.cloud/doppler@1.0.0-rc.13(effect@4.0.5)':
13785 dependencies:
13773 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13774 - effect: 4.0.4
13786 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13787 + effect: 4.0.5
13788
13776 - '@distilled.cloud/fly-io@1.0.0-rc.13(effect@4.0.4)':
13789 + '@distilled.cloud/fly-io@1.0.0-rc.13(effect@4.0.5)':
13790 dependencies:
13778 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13779 - effect: 4.0.4
13791 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13792 + effect: 4.0.5
13793
13781 - '@distilled.cloud/gcp@1.0.0-rc.13(effect@4.0.4)':
13794 + '@distilled.cloud/gcp@1.0.0-rc.13(effect@4.0.5)':
13795 dependencies:
13783 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13784 - effect: 4.0.4
13796 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13797 + effect: 4.0.5
13798
13786 - '@distilled.cloud/hetzner@1.0.0-rc.13(effect@4.0.4)':
13799 + '@distilled.cloud/hetzner@1.0.0-rc.13(effect@4.0.5)':
13800 dependencies:
13788 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13789 - effect: 4.0.4
13801 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13802 + effect: 4.0.5
13803
13791 - '@distilled.cloud/infisical@1.0.0-rc.13(effect@4.0.4)':
13804 + '@distilled.cloud/infisical@1.0.0-rc.13(effect@4.0.5)':
13805 dependencies:
13793 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13794 - effect: 4.0.4
13806 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13807 + effect: 4.0.5
13808
13796 - '@distilled.cloud/neon@1.0.0-rc.13(effect@4.0.4)':
13809 + '@distilled.cloud/neon@1.0.0-rc.13(effect@4.0.5)':
13810 dependencies:
13798 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13799 - effect: 4.0.4
13811 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13812 + effect: 4.0.5
13813
13801 - '@distilled.cloud/planetscale@1.0.0-rc.13(effect@4.0.4)':
13814 + '@distilled.cloud/planetscale@1.0.0-rc.13(effect@4.0.5)':
13815 dependencies:
13803 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13804 - effect: 4.0.4
13816 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13817 + effect: 4.0.5
13818
13806 - '@distilled.cloud/prisma@1.0.0-rc.13(effect@4.0.4)':
13819 + '@distilled.cloud/prisma@1.0.0-rc.13(effect@4.0.5)':
13820 dependencies:
13808 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13809 - effect: 4.0.4
13821 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13822 + effect: 4.0.5
13823
13811 - '@distilled.cloud/railway@1.0.0-rc.13(effect@4.0.4)':
13824 + '@distilled.cloud/railway@1.0.0-rc.13(effect@4.0.5)':
13825 dependencies:
13813 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13814 - effect: 4.0.4
13826 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13827 + effect: 4.0.5
13828
13816 - '@distilled.cloud/stripe@1.0.0-rc.13(effect@4.0.4)':
13829 + '@distilled.cloud/stripe@1.0.0-rc.13(effect@4.0.5)':
13830 dependencies:
13818 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13819 - effect: 4.0.4
13831 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13832 + effect: 4.0.5
13833
13821 - '@distilled.cloud/zerossl@1.0.0-rc.13(effect@4.0.4)':
13834 + '@distilled.cloud/zerossl@1.0.0-rc.13(effect@4.0.5)':
13835 dependencies:
13823 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
13824 - effect: 4.0.4
13836 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
13837 + effect: 4.0.5
13838
13839 '@dnd-kit/accessibility@3.1.1(react@19.2.6)':
13840 dependencies:
@@ -13857,62 +13870,67 @@ snapshots:
13870
13871 '@drizzle-team/brocli@0.12.0': {}
13872
13860 - '@effect/atom-react@4.0.4(effect@4.0.4)(react@19.2.6)(scheduler@0.28.0)':
13873 + '@effect/atom-react@4.0.5(effect@4.0.5)(react@19.2.6)(scheduler@0.28.0)':
13874 dependencies:
13862 - effect: 4.0.4
13875 + effect: 4.0.5
13876 react: 19.2.6
13877 scheduler: 0.28.0
13878
13866 - '@effect/atom-react@4.0.4(effect@4.0.4)(react@19.3.0)(scheduler@0.28.0)':
13879 + '@effect/atom-react@4.0.5(effect@4.0.5)(react@19.3.0)(scheduler@0.28.0)':
13880 dependencies:
13868 - effect: 4.0.4
13881 + effect: 4.0.5
13882 react: 19.3.0
13883 scheduler: 0.28.0
13884
13872 - '@effect/openapi-generator@4.0.4(@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.4)(encoding@0.1.13)':
13885 + '@effect/graphql-generator@4.0.5(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.5)':
13886 + dependencies:
13887 + '@effect/platform-node': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
13888 + effect: 4.0.5
13889 +
13890 + '@effect/openapi-generator@4.0.5(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(effect@4.0.5)(encoding@0.1.13)':
13891 dependencies:
13874 - '@effect/platform-node': 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
13875 - effect: 4.0.4
13892 + '@effect/platform-node': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
13893 + effect: 4.0.5
13894 swagger2openapi: 7.0.8(encoding@0.1.13)
13895 transitivePeerDependencies:
13896 - encoding
13897
13880 - '@effect/platform-node-shared@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(utf-8-validate@6.0.6)':
13898 + '@effect/platform-node-shared@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(utf-8-validate@6.0.6)':
13899 dependencies:
13900 '@types/ws': 8.18.2
13883 - effect: 4.0.4
13901 + effect: 4.0.5
13902 ws: 8.22.0(bufferutil@4.1.0)(utf-8-validate@6.0.6)
13903 transitivePeerDependencies:
13904 - bufferutil
13905 - utf-8-validate
13906
13889 - '@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)':
13907 + '@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)':
13908 dependencies:
13891 - '@effect/platform-node-shared': 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(utf-8-validate@6.0.6)
13892 - effect: 4.0.4
13909 + '@effect/platform-node-shared': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(utf-8-validate@6.0.6)
13910 + effect: 4.0.5
13911 redis: 6.2.1
13912 undici: 8.11.2
13913 transitivePeerDependencies:
13914 - bufferutil
13915 - utf-8-validate
13916
13899 - '@effect/sql-d1@4.0.0(effect@4.0.4)':
13917 + '@effect/sql-d1@4.0.0(effect@4.0.5)':
13918 dependencies:
13919 '@cloudflare/workers-types': 5.20261004.1
13902 - effect: 4.0.4
13920 + effect: 4.0.5
13921
13904 - '@effect/sql-pg@4.0.4(effect@4.0.4)':
13922 + '@effect/sql-pg@4.0.5(effect@4.0.5)':
13923 dependencies:
13906 - effect: 4.0.4
13924 + effect: 4.0.5
13925
13908 - '@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.4)':
13926 + '@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5)':
13927 dependencies:
13910 - effect: 4.0.4
13928 + effect: 4.0.5
13929 optional: true
13930
13913 - '@effect/sql-sqlite-do@4.0.4(effect@4.0.4)':
13931 + '@effect/sql-sqlite-do@4.0.5(effect@4.0.5)':
13932 dependencies:
13915 - effect: 4.0.4
13933 + effect: 4.0.5
13934
13935 '@effect/tsgo-darwin-arm64@0.51.1':
13936 optional: true
@@ -13945,9 +13963,9 @@ snapshots:
13963 '@effect/tsgo-win32-arm64': 0.51.1
13964 '@effect/tsgo-win32-x64': 0.51.1
13965
13948 - '@effect/vitest@4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)':
13966 + '@effect/vitest@4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)':
13967 dependencies:
13950 - effect: 4.0.4
13968 + effect: 4.0.5
13969 vite-plus: 1.0.0(@types/node@24.12.4)(@vitest/ui@5.0.1(vitest@5.0.1))(bufferutil@4.1.0)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
13970 transitivePeerDependencies:
13971 - '@arethetypeswrong/core'
@@ -15375,22 +15393,22 @@ snapshots:
15393 dependencies:
15394 cross-spawn: 7.0.6
15395
15378 - '@opencode/client@2.0.28(effect@4.0.4)':
15396 + '@opencode/client@2.0.28(effect@4.0.5)':
15397 dependencies:
15398 '@opencode/protocol': 2.0.28
15399 '@opencode/schema': 2.0.28
15400 optionalDependencies:
15383 - effect: 4.0.4
15401 + effect: 4.0.5
15402
15403 '@opencode/protocol@2.0.28':
15404 dependencies:
15405 '@opencode/schema': 2.0.28
15388 - effect: 4.0.4
15406 + effect: 4.0.5
15407
15408 '@opencode/schema@2.0.28':
15409 dependencies:
15410 '@standard-schema/spec': 1.1.0
15393 - effect: 4.0.4
15411 + effect: 4.0.5
15412
15413 '@oslojs/asn1@1.0.0':
15414 dependencies:
@@ -17611,37 +17629,37 @@ snapshots:
17629 json-schema-traverse: 1.0.0
17630 require-from-string: 2.0.2
17631
17614 - alchemy@2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(65456df005cbbd653b96024b9ea83b1c):
17632 + alchemy@2.0.0-beta.80(patch_hash=bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd)(e32ed987c684265dc2dfa72f5ab4da0d):
17633 dependencies:
17616 - '@alchemy.run/cloudflare-runtime': 2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.4))(@effect/platform-node@4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6))(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.4)(rolldown@1.2.5)(typescript@7.0.2)
17617 - '@alchemy.run/floci': 2.0.0-beta.80(effect@4.0.4)
17634 + '@alchemy.run/cloudflare-runtime': 2.0.0-beta.80(@distilled.cloud/cloudflare@1.0.0-rc.13(effect@4.0.5))(@effect/platform-node@4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6))(@types/node@24.12.4)(@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0))(effect@4.0.5)(rolldown@1.2.5)(typescript@7.0.2)
17635 + '@alchemy.run/floci': 2.0.0-beta.80(effect@4.0.5)
17636 '@alchemy.run/node-utils': 2.0.0-beta.80
17637 '@alchemy.run/sigil': 0.1.0-alpha.1(@types/react@19.3.0)(react-devtools-core@6.1.5(bufferutil@4.1.0)(utf-8-validate@6.0.6))
17620 - '@distilled.cloud/acme': 1.0.0-rc.13(effect@4.0.4)
17621 - '@distilled.cloud/aws': 1.0.0-rc.13(effect@4.0.4)
17622 - '@distilled.cloud/axiom': 1.0.0-rc.13(effect@4.0.4)
17623 - '@distilled.cloud/cloudflare': 1.0.0-rc.13(effect@4.0.4)
17624 - '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.4)
17625 - '@distilled.cloud/doppler': 1.0.0-rc.13(effect@4.0.4)
17626 - '@distilled.cloud/fly-io': 1.0.0-rc.13(effect@4.0.4)
17627 - '@distilled.cloud/gcp': 1.0.0-rc.13(effect@4.0.4)
17628 - '@distilled.cloud/hetzner': 1.0.0-rc.13(effect@4.0.4)
17629 - '@distilled.cloud/infisical': 1.0.0-rc.13(effect@4.0.4)
17630 - '@distilled.cloud/neon': 1.0.0-rc.13(effect@4.0.4)
17631 - '@distilled.cloud/planetscale': 1.0.0-rc.13(effect@4.0.4)
17632 - '@distilled.cloud/prisma': 1.0.0-rc.13(effect@4.0.4)
17633 - '@distilled.cloud/railway': 1.0.0-rc.13(effect@4.0.4)
17634 - '@distilled.cloud/stripe': 1.0.0-rc.13(effect@4.0.4)
17635 - '@distilled.cloud/zerossl': 1.0.0-rc.13(effect@4.0.4)
17636 - '@effect/sql-d1': 4.0.0(effect@4.0.4)
17637 - '@effect/sql-sqlite-do': 4.0.4(effect@4.0.4)
17638 + '@distilled.cloud/acme': 1.0.0-rc.13(effect@4.0.5)
17639 + '@distilled.cloud/aws': 1.0.0-rc.13(effect@4.0.5)
17640 + '@distilled.cloud/axiom': 1.0.0-rc.13(effect@4.0.5)
17641 + '@distilled.cloud/cloudflare': 1.0.0-rc.13(effect@4.0.5)
17642 + '@distilled.cloud/core': 1.0.0-rc.13(effect@4.0.5)
17643 + '@distilled.cloud/doppler': 1.0.0-rc.13(effect@4.0.5)
17644 + '@distilled.cloud/fly-io': 1.0.0-rc.13(effect@4.0.5)
17645 + '@distilled.cloud/gcp': 1.0.0-rc.13(effect@4.0.5)
17646 + '@distilled.cloud/hetzner': 1.0.0-rc.13(effect@4.0.5)
17647 + '@distilled.cloud/infisical': 1.0.0-rc.13(effect@4.0.5)
17648 + '@distilled.cloud/neon': 1.0.0-rc.13(effect@4.0.5)
17649 + '@distilled.cloud/planetscale': 1.0.0-rc.13(effect@4.0.5)
17650 + '@distilled.cloud/prisma': 1.0.0-rc.13(effect@4.0.5)
17651 + '@distilled.cloud/railway': 1.0.0-rc.13(effect@4.0.5)
17652 + '@distilled.cloud/stripe': 1.0.0-rc.13(effect@4.0.5)
17653 + '@distilled.cloud/zerossl': 1.0.0-rc.13(effect@4.0.5)
17654 + '@effect/sql-d1': 4.0.0(effect@4.0.5)
17655 + '@effect/sql-sqlite-do': 4.0.5(effect@4.0.5)
17656 '@libsql/client': 0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6)
17657 '@neon/functions': 0.11.0(hono@4.13.7)
17658 '@octokit/rest': 22.0.1
17659 '@octokit/webhooks': 14.2.0
17660 '@types/aws-lambda': 8.10.161
17661 capnweb: 0.12.0
17644 - effect: 4.0.4
17662 + effect: 4.0.5
17663 fflate: 0.8.3
17664 libsodium-wrappers: 0.8.4
17665 pathe: 2.0.3
@@ -17650,11 +17668,11 @@ snapshots:
17668 tinyglobby: 0.2.17
17669 yaml: 2.9.0
17670 optionalDependencies:
17653 - '@effect/platform-node': 4.0.4(bufferutil@4.1.0)(effect@4.0.4)(redis@6.2.1)(utf-8-validate@6.0.6)
17654 - '@effect/sql-pg': 4.0.4(effect@4.0.4)
17655 - '@effect/vitest': 4.0.4(patch_hash=ebaec66c6bdd25e1b8d5bfd4a14f25ab959bdcca6e22ed8871d061e50e2db0ad)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.4)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
17671 + '@effect/platform-node': 4.0.5(bufferutil@4.1.0)(effect@4.0.5)(redis@6.2.1)(utf-8-validate@6.0.6)
17672 + '@effect/sql-pg': 4.0.5(effect@4.0.5)
17673 + '@effect/vitest': 4.0.5(patch_hash=2731c9c3761c595f25ddc625a7d61ca376b389d5b3049ecb837c8940f21cfa02)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.5)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
17674 drizzle-kit: 1.0.0-rc.5-ab785fc
17657 - drizzle-orm: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.4))(@effect/sql-pg@4.0.4(effect@4.0.4))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.4))(@effect/sql-sqlite-do@4.0.4(effect@4.0.4))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.4)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3)
17675 + drizzle-orm: 1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3)
17676 mongodb: 6.21.0(@aws-sdk/credential-providers@3.1062.0)(socks@2.8.9)
17677 pg: 8.23.0
17678 vite: '@voidzero-dev/vite-plus-core@1.0.0(@types/node@24.12.4)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(yaml@2.9.0)'
@@ -18810,17 +18828,17 @@ snapshots:
18828 get-tsconfig: 4.14.3
18829 jiti: 2.7.0
18830
18813 - drizzle-orm@1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.4))(@effect/sql-pg@4.0.4(effect@4.0.4))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.4))(@effect/sql-sqlite-do@4.0.4(effect@4.0.4))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.4)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3):
18831 + drizzle-orm@1.0.0-rc.5-ab785fc(@cloudflare/workers-types@4.20260604.1)(@effect/sql-d1@4.0.0(effect@4.0.5))(@effect/sql-pg@4.0.5(effect@4.0.5))(@effect/sql-sqlite-bun@4.0.0-rc.112(effect@4.0.5))(@effect/sql-sqlite-do@4.0.5(effect@4.0.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6))(bun-types@1.3.14)(effect@4.0.5)(expo-sqlite@58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0))(pg@8.23.0)(valibot@1.2.0(typescript@7.0.2))(zod@4.4.3):
18832 optionalDependencies:
18833 '@cloudflare/workers-types': 4.20260604.1
18816 - '@effect/sql-d1': 4.0.0(effect@4.0.4)
18817 - '@effect/sql-pg': 4.0.4(effect@4.0.4)
18818 - '@effect/sql-sqlite-bun': 4.0.0-rc.112(effect@4.0.4)
18819 - '@effect/sql-sqlite-do': 4.0.4(effect@4.0.4)
18834 + '@effect/sql-d1': 4.0.0(effect@4.0.5)
18835 + '@effect/sql-pg': 4.0.5(effect@4.0.5)
18836 + '@effect/sql-sqlite-bun': 4.0.0-rc.112(effect@4.0.5)
18837 + '@effect/sql-sqlite-do': 4.0.5(effect@4.0.5)
18838 '@electric-sql/pglite': 0.3.15
18839 '@libsql/client': 0.17.3(bufferutil@4.1.0)(utf-8-validate@6.0.6)
18840 bun-types: 1.3.14
18823 - effect: 4.0.4
18841 + effect: 4.0.5
18842 expo-sqlite: 58.0.8(expo@58.0.2)(react-native@0.88.0-rc.3(@babel/core@7.29.7)(@react-native/metro-config@0.88.0-rc.3(@babel/core@7.29.7)(bufferutil@4.1.0)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(utf-8-validate@6.0.6))(react@19.3.0)
18843 pg: 8.23.0
18844 valibot: 1.2.0(typescript@7.0.2)
@@ -18842,7 +18860,7 @@ snapshots:
18860
18861 ee-first@1.1.1: {}
18862
18845 - effect@4.0.4: {}
18863 + effect@4.0.5: {}
18864
18865 ejs@3.1.10:
18866 dependencies:
pnpm-workspace.yaml
+19 -17
@@ -34,14 +34,15 @@ catalog:
34 "@clerk/expo": 4.6.8
35 "@clerk/react": 6.16.1
36 "@clerk/shared": 4.33.0
37 - "@effect/atom-react": 4.0.4
38 - "@effect/openapi-generator": 4.0.4
39 - "@effect/platform-node": 4.0.4
40 - "@effect/platform-node-shared": 4.0.4
41 - "@effect/sql-pg": 4.0.4
42 - "@effect/sql-sqlite-do": 4.0.4
37 + "@effect/atom-react": 4.0.5
38 + "@effect/graphql-generator": 4.0.5
39 + "@effect/openapi-generator": 4.0.5
40 + "@effect/platform-node": 4.0.5
41 + "@effect/platform-node-shared": 4.0.5
42 + "@effect/sql-pg": 4.0.5
43 + "@effect/sql-sqlite-do": 4.0.5
44 "@effect/tsgo": 0.51.1
44 - "@effect/vitest": 4.0.4
45 + "@effect/vitest": 4.0.5
46 "@electron-webauthn/macos": 1.3.1
47 "@legendapp/list": 3.3.5
48 "@noble/curves": 1.9.1
@@ -53,7 +54,7 @@ catalog:
54 "@types/node": 24.12.4
55 "@types/plist": 3.0.5
56 "@types/ws": 8.18.2
56 - effect: 4.0.4
57 + effect: 4.0.5
58 electron-webauthn: 1.3.1
59 jose: 6.2.2
60 lightningcss: 1.33.0
@@ -99,15 +100,16 @@ minimumReleaseAgeExclude:
100 - "@distilled.cloud/core@1.0.0-rc.13"
101 - "@distilled.cloud/neon@1.0.0-rc.13"
102 - "@distilled.cloud/planetscale@1.0.0-rc.13"
102 - - "@effect/atom-react@4.0.4"
103 - - "@effect/openapi-generator@4.0.4"
104 - - "@effect/platform-node-shared@4.0.4"
105 - - "@effect/platform-node@4.0.4"
106 - - "@effect/sql-pg@4.0.4"
107 - - "@effect/sql-sqlite-do@4.0.4"
108 - - "@effect/vitest@4.0.4"
103 + - "@effect/atom-react@4.0.5"
104 + - "@effect/graphql-generator@4.0.5"
105 + - "@effect/openapi-generator@4.0.5"
106 + - "@effect/platform-node-shared@4.0.5"
107 + - "@effect/platform-node@4.0.5"
108 + - "@effect/sql-pg@4.0.5"
109 + - "@effect/sql-sqlite-do@4.0.5"
110 + - "@effect/vitest@4.0.5"
111 - alchemy@2.0.0-beta.80
110 - - effect@4.0.4
112 + - effect@4.0.5
113 - "@legendapp/list@3.3.5"
114 - "@expo/cli@58.1.1"
115 - "@expo/env@2.5.1"
@@ -290,7 +292,7 @@ patchedDependencies:
292 expo-blur@58.0.3: patches/expo-blur@58.0.3.patch
293 expo-audio@58.0.4: patches/expo-audio@58.0.4.patch
294 "@clerk/expo@4.6.8": patches/@clerk__expo@4.6.8.patch
293 - "@effect/vitest@4.0.4": patches/@effect__vitest@4.0.4.patch
295 + "@effect/vitest@4.0.5": patches/@effect__vitest@4.0.5.patch
296 "@expo/metro-config@58.0.6": patches/@expo__metro-config@58.0.6.patch
297 expo-sharing@58.0.13: patches/expo-sharing@58.0.13.patch
298 expo-widgets@58.0.11: patches/expo-widgets@58.0.11.patch
vite.config.ts
+4
@@ -94,6 +94,8 @@ export default defineConfig({
94 "pnpm-lock.yaml",
95 "*.tsbuildinfo",
96 "**/routeTree.gen.ts",
97 + "**/*.graphql.ts",
98 + "packages/source-control-github/schema/**",
99 "apps/mobile/android/**",
100 "apps/mobile/ios/**",
101 "apps/mobile/uniwind-types.d.ts",
@@ -119,6 +121,8 @@ export default defineConfig({
121 "pnpm-lock.yaml",
122 "*.tsbuildinfo",
123 "**/routeTree.gen.ts",
124 + "**/*.graphql.ts",
125 + "packages/source-control-github/schema/**",
126 "apps/mobile/android/**",
127 "apps/mobile/ios/**",
128 "apps/mobile/uniwind-types.d.ts",