@theholocron/github-client 1.58.0-alpha.11 → 1.58.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +50 -0
- package/dist/index.mjs +16 -0
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,10 @@ import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
|
15
15
|
* which transport they're talking to.
|
|
16
16
|
*/
|
|
17
17
|
interface GraphQLClient {
|
|
18
|
+
/**
|
|
19
|
+
* Sends one query or mutation to `POST /graphql` and returns its `data`. Throws a `ProviderApiError` (status `200`, with the
|
|
20
|
+
* response's `errors` array) when GitHub answers with errors, and the transport's own `ProviderApiError` for a network or HTTP failure.
|
|
21
|
+
*/
|
|
18
22
|
query<T>(document: string, variables?: Record<string, unknown>): Promise<T>;
|
|
19
23
|
}
|
|
20
24
|
/** Options for creating a GitHub client. */
|
|
@@ -115,6 +119,8 @@ interface GitHubCheckRun {
|
|
|
115
119
|
conclusion: CheckRunConclusion | null;
|
|
116
120
|
/** The URL of the check run's page on GitHub. */
|
|
117
121
|
html_url: string;
|
|
122
|
+
/** The check's own "Details" link, when it set one. */
|
|
123
|
+
details_url?: string | null;
|
|
118
124
|
}
|
|
119
125
|
/** The body of an `updateCheckRun()` request; every field is optional. */
|
|
120
126
|
interface UpdateCheckRunInput {
|
|
@@ -433,6 +439,40 @@ interface GitHubPullRequest {
|
|
|
433
439
|
/** The head commit. */
|
|
434
440
|
sha: string;
|
|
435
441
|
};
|
|
442
|
+
/** Whether the pull request is a draft. */
|
|
443
|
+
draft?: boolean;
|
|
444
|
+
/** When the pull request was opened, as an ISO 8601 timestamp. */
|
|
445
|
+
created_at?: string;
|
|
446
|
+
/** The author. */
|
|
447
|
+
user?: {
|
|
448
|
+
/** The author's login. */
|
|
449
|
+
login: string;
|
|
450
|
+
/** The account type: `User` or `Bot` (Dependabot is a `Bot`). */
|
|
451
|
+
type: string;
|
|
452
|
+
};
|
|
453
|
+
/** Who merged it; `null` for a pull request that is not merged. */
|
|
454
|
+
merged_by?: {
|
|
455
|
+
login: string;
|
|
456
|
+
} | null;
|
|
457
|
+
/** The base branch. */
|
|
458
|
+
base?: {
|
|
459
|
+
/** The base branch's name, e.g. `alpha`. */
|
|
460
|
+
ref: string;
|
|
461
|
+
};
|
|
462
|
+
/** The people whose review is still asked for. */
|
|
463
|
+
requested_reviewers?: {
|
|
464
|
+
login: string;
|
|
465
|
+
}[];
|
|
466
|
+
/** Lines added, as the single-pull-request endpoint returns it (the list endpoint omits it). */
|
|
467
|
+
additions?: number;
|
|
468
|
+
/** Lines removed; see `additions`. */
|
|
469
|
+
deletions?: number;
|
|
470
|
+
/** Files changed; see `additions`. */
|
|
471
|
+
changed_files?: number;
|
|
472
|
+
/** Whether it merges cleanly; `null` while GitHub is still working it out. */
|
|
473
|
+
mergeable?: boolean | null;
|
|
474
|
+
/** `dirty` means it conflicts with its base; see `mergeable`. */
|
|
475
|
+
mergeable_state?: string;
|
|
436
476
|
}
|
|
437
477
|
/** A commit's name/email as git itself recorded it — `commit.author`/`commit.committer`, distinct from the GitHub-account `author` below (a commit can carry any email, linked to a GitHub account or not). */
|
|
438
478
|
interface GitHubCommitIdentity {
|
|
@@ -511,6 +551,12 @@ interface GitHubPullRequestReview {
|
|
|
511
551
|
id: number;
|
|
512
552
|
/** The URL of the review on GitHub. */
|
|
513
553
|
html_url: string;
|
|
554
|
+
/** `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, `DISMISSED` or `PENDING`; set on a review read back. */
|
|
555
|
+
state?: string;
|
|
556
|
+
/** The reviewer; set on a review read back. */
|
|
557
|
+
user?: {
|
|
558
|
+
login: string;
|
|
559
|
+
} | null;
|
|
514
560
|
}
|
|
515
561
|
/**
|
|
516
562
|
* One review thread — GraphQL-only (`resolveReviewThread`, the mutation
|
|
@@ -546,6 +592,8 @@ interface GitHubRepo {
|
|
|
546
592
|
default_branch: string;
|
|
547
593
|
/** The repository's `owner/name`. */
|
|
548
594
|
full_name: string;
|
|
595
|
+
/** Whether the repository is archived (read-only). */
|
|
596
|
+
archived?: boolean;
|
|
549
597
|
/** The repository description. */
|
|
550
598
|
description?: string | null;
|
|
551
599
|
/** The repository homepage URL. */
|
|
@@ -855,6 +903,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
855
903
|
removeBranch: (repo: string, branch: string) => Promise<void>;
|
|
856
904
|
};
|
|
857
905
|
checks: {
|
|
906
|
+
listCheckRunsForRef: (repo: string, ref: string) => Promise<GitHubCheckRun[]>;
|
|
858
907
|
createCheckRun: (repo: string, input: CreateCheckRunInput) => Promise<GitHubCheckRun>;
|
|
859
908
|
updateCheckRun: (repo: string, checkRunId: number, input: UpdateCheckRunInput) => Promise<GitHubCheckRun>;
|
|
860
909
|
};
|
|
@@ -924,6 +973,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
924
973
|
listPullRequests: (repo: string, state: "open" | "closed") => Promise<GitHubPullRequest[]>;
|
|
925
974
|
listCommits: (repo: string, number: number) => Promise<GitHubPullRequestCommit[]>;
|
|
926
975
|
listFiles: (repo: string, number: number) => Promise<GitHubPullRequestFile[]>;
|
|
976
|
+
listReviews: (repo: string, number: number) => Promise<GitHubPullRequestReview[]>;
|
|
927
977
|
createReview: (repo: string, number: number, input: CreateReviewInput) => Promise<GitHubPullRequestReview>;
|
|
928
978
|
listReviewThreads: (repo: string, number: number) => Promise<ReviewThread[]>;
|
|
929
979
|
resolveReviewThread: (threadId: string) => Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProviderApiError, createRestClient } from "@theholocron/http-client";
|
|
2
2
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
3
|
// src/graphql/graphql.ts
|
|
4
|
+
/** A {@link GraphQLClient} for GitHub's GraphQL API, built on the shared REST transport. */
|
|
4
5
|
function createGitHubGraphQLClient(config) {
|
|
5
6
|
const rest = createRestClient({
|
|
6
7
|
baseUrl: config.baseUrl ?? "https://api.github.com",
|
|
@@ -107,8 +108,21 @@ function branches(rest) {
|
|
|
107
108
|
* do for you; slice with it rather than hardcoding the number.
|
|
108
109
|
*/
|
|
109
110
|
const MAX_CHECK_RUN_ANNOTATIONS = 50;
|
|
111
|
+
/** Page size and the most pages {@link checks}`.listCheckRunsForRef` reads: 100 a page over 10 pages, so 1,000 check runs. */
|
|
112
|
+
const CHECK_RUN_PAGE_SIZE = 100;
|
|
113
|
+
const CHECK_RUN_MAX_PAGES = 10;
|
|
110
114
|
function checks(rest) {
|
|
111
115
|
return {
|
|
116
|
+
/** Every check run on a commit, read a page at a time until a page comes back short. */
|
|
117
|
+
listCheckRunsForRef: async (repo, ref) => {
|
|
118
|
+
const all = [];
|
|
119
|
+
for (let page = 1; page <= CHECK_RUN_MAX_PAGES; page++) {
|
|
120
|
+
const batch = await rest.request(`${repoBase(repo)}/commits/${ref}/check-runs?per_page=${CHECK_RUN_PAGE_SIZE}&page=${page}`);
|
|
121
|
+
all.push(...batch.check_runs);
|
|
122
|
+
if (batch.check_runs.length < CHECK_RUN_PAGE_SIZE) break;
|
|
123
|
+
}
|
|
124
|
+
return all;
|
|
125
|
+
},
|
|
112
126
|
createCheckRun: (repo, input) => rest.request(`${repoBase(repo)}/check-runs`, {
|
|
113
127
|
method: "POST",
|
|
114
128
|
body: input
|
|
@@ -413,6 +427,8 @@ function pulls(rest, graphql) {
|
|
|
413
427
|
* is an edge case no consumer here needs to paginate for today.
|
|
414
428
|
*/
|
|
415
429
|
listFiles: (repo, number) => rest.request(`${repoBase(repo)}/pulls/${number}/files?per_page=100`),
|
|
430
|
+
/** A PR's reviews, oldest first. `per_page=100` covers every real PR in this org. */
|
|
431
|
+
listReviews: (repo, number) => rest.request(`${repoBase(repo)}/pulls/${number}/reviews?per_page=100`),
|
|
416
432
|
/**
|
|
417
433
|
* Submits a review in one call — GitHub has no separate "create draft,
|
|
418
434
|
* then submit" step when `event` is provided directly (the multi-step
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/github-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.13",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@theholocron/observability": "^0.7.0-alpha.1",
|
|
36
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
36
|
+
"@theholocron/http-client": "^1.58.0-alpha.13"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"tsdown": "^0.23.4",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.0.5",
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
48
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.9",
|
|
49
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.9",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.9",
|
|
51
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.9"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|