@theholocron/github-client 1.58.0-alpha.3 → 1.58.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +227 -0
- package/dist/index.mjs +1 -0
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import "@theholocron/http-client";
|
|
2
2
|
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
/** Options for creating a GitHub client. */
|
|
3
4
|
interface GitHubClientOptions {
|
|
5
|
+
/** The token sent as the bearer credential. */
|
|
4
6
|
token: string;
|
|
7
|
+
/** The GitHub API base URL; defaults to `https://api.github.com`. */
|
|
5
8
|
baseUrl?: string;
|
|
9
|
+
/** The `fetch` implementation to use; defaults to the global `fetch`. */
|
|
6
10
|
fetch?: typeof fetch;
|
|
7
11
|
/** Structured logger for request/response diagnostics. Defaults to a no-op. */
|
|
8
12
|
logger?: Logger;
|
|
@@ -16,8 +20,11 @@ interface GitHubBranch {
|
|
|
16
20
|
sha: string;
|
|
17
21
|
};
|
|
18
22
|
}
|
|
23
|
+
/** The lifecycle state of a check run. */
|
|
19
24
|
type CheckRunStatus = "queued" | "in_progress" | "completed";
|
|
25
|
+
/** The final result of a completed check run. */
|
|
20
26
|
type CheckRunConclusion = "success" | "failure" | "neutral" | "cancelled" | "timed_out" | "action_required" | "skipped";
|
|
27
|
+
/** The severity of a check run annotation. */
|
|
21
28
|
type CheckRunAnnotationLevel = "notice" | "warning" | "failure";
|
|
22
29
|
/**
|
|
23
30
|
* GitHub's cap on `output.annotations` per `createCheckRun()` /
|
|
@@ -26,15 +33,19 @@ type CheckRunAnnotationLevel = "notice" | "warning" | "failure";
|
|
|
26
33
|
* do for you; slice with it rather than hardcoding the number.
|
|
27
34
|
*/
|
|
28
35
|
export declare const MAX_CHECK_RUN_ANNOTATIONS = 50;
|
|
36
|
+
/** One inline annotation attached to a check run's output, anchored to a file and line range. */
|
|
29
37
|
interface CheckRunAnnotation {
|
|
30
38
|
/** File path relative to the repo root. */
|
|
31
39
|
path: string;
|
|
32
40
|
/** 1-indexed. */
|
|
33
41
|
start_line: number;
|
|
42
|
+
/** 1-indexed last line of the annotated range. */
|
|
34
43
|
end_line: number;
|
|
35
44
|
/** Only valid when `start_line === end_line`. */
|
|
36
45
|
start_column?: number;
|
|
46
|
+
/** Column of the end of the range; only valid when `start_line === end_line`. */
|
|
37
47
|
end_column?: number;
|
|
48
|
+
/** Severity of the annotation. */
|
|
38
49
|
annotation_level: CheckRunAnnotationLevel;
|
|
39
50
|
/** Max 64KB. */
|
|
40
51
|
message: string;
|
|
@@ -43,9 +54,13 @@ interface CheckRunAnnotation {
|
|
|
43
54
|
/** Max 64KB. */
|
|
44
55
|
raw_details?: string;
|
|
45
56
|
}
|
|
57
|
+
/** The title, summary and optional annotations shown on a check run. */
|
|
46
58
|
interface CheckRunOutput {
|
|
59
|
+
/** The output's title. */
|
|
47
60
|
title: string;
|
|
61
|
+
/** The output's summary, rendered as Markdown. */
|
|
48
62
|
summary: string;
|
|
63
|
+
/** Longer details text, rendered as Markdown. */
|
|
49
64
|
text?: string;
|
|
50
65
|
/**
|
|
51
66
|
* Inline PR annotations — up to {@link MAX_CHECK_RUN_ANNOTATIONS} per
|
|
@@ -54,7 +69,9 @@ interface CheckRunOutput {
|
|
|
54
69
|
*/
|
|
55
70
|
annotations?: CheckRunAnnotation[];
|
|
56
71
|
}
|
|
72
|
+
/** The body of a `createCheckRun()` request. */
|
|
57
73
|
interface CreateCheckRunInput {
|
|
74
|
+
/** The check run's name, as shown in the checks list. */
|
|
58
75
|
name: string;
|
|
59
76
|
/** The commit SHA the check run attaches to. */
|
|
60
77
|
head_sha: string;
|
|
@@ -62,30 +79,46 @@ interface CreateCheckRunInput {
|
|
|
62
79
|
status?: CheckRunStatus;
|
|
63
80
|
/** Required when `status` is `"completed"`. */
|
|
64
81
|
conclusion?: CheckRunConclusion;
|
|
82
|
+
/** The title, summary and annotations to show on the check run. */
|
|
65
83
|
output?: CheckRunOutput;
|
|
66
84
|
/** URL for the "Details" link on the check run. GitHub defaults to the check suite's own summary page when omitted. */
|
|
67
85
|
details_url?: string;
|
|
68
86
|
}
|
|
87
|
+
/** A check run as GitHub returns it, with only the fields this client reads. */
|
|
69
88
|
interface GitHubCheckRun {
|
|
89
|
+
/** The check run's numeric id. */
|
|
70
90
|
id: number;
|
|
91
|
+
/** The check run's name. */
|
|
71
92
|
name: string;
|
|
93
|
+
/** The commit SHA the check run is attached to. */
|
|
72
94
|
head_sha: string;
|
|
95
|
+
/** The check run's current lifecycle state. */
|
|
73
96
|
status: CheckRunStatus;
|
|
97
|
+
/** The check run's result, or `null` until it is completed. */
|
|
74
98
|
conclusion: CheckRunConclusion | null;
|
|
99
|
+
/** The URL of the check run's page on GitHub. */
|
|
75
100
|
html_url: string;
|
|
76
101
|
}
|
|
102
|
+
/** The body of an `updateCheckRun()` request; every field is optional. */
|
|
77
103
|
interface UpdateCheckRunInput {
|
|
104
|
+
/** The lifecycle state to move the check run to. */
|
|
78
105
|
status?: CheckRunStatus;
|
|
79
106
|
/** Required when `status` is `"completed"`. */
|
|
80
107
|
conclusion?: CheckRunConclusion;
|
|
108
|
+
/** The title, summary and annotations to set on the check run. */
|
|
81
109
|
output?: CheckRunOutput;
|
|
82
110
|
/** URL for the "Details" link on the check run. */
|
|
83
111
|
details_url?: string;
|
|
84
112
|
}
|
|
113
|
+
/** A deployment environment of a repository and its protection settings. */
|
|
85
114
|
interface GitHubEnvironment {
|
|
115
|
+
/** The environment's name. */
|
|
86
116
|
name: string;
|
|
117
|
+
/** Minutes to wait before a job that targets the environment may proceed. */
|
|
87
118
|
wait_timer?: number;
|
|
119
|
+
/** Whether the user who triggered a deployment may also approve it. */
|
|
88
120
|
prevent_self_review?: boolean;
|
|
121
|
+
/** The protection rules on the environment; each has a `type` and, for required reviewers, the reviewers. */
|
|
89
122
|
protection_rules?: Array<{
|
|
90
123
|
type: string;
|
|
91
124
|
reviewers?: Array<{
|
|
@@ -96,52 +129,87 @@ interface GitHubEnvironment {
|
|
|
96
129
|
}>;
|
|
97
130
|
}>;
|
|
98
131
|
}
|
|
132
|
+
/** A git reference (such as a branch) and the object it points at. */
|
|
99
133
|
interface GitRef {
|
|
134
|
+
/** The object the reference points at. */
|
|
100
135
|
object: {
|
|
136
|
+
/** The object's SHA. */
|
|
101
137
|
sha: string;
|
|
138
|
+
/** The object's type, e.g. `commit`. */
|
|
102
139
|
type: string;
|
|
140
|
+
/** The API URL of the object. */
|
|
103
141
|
url: string;
|
|
104
142
|
};
|
|
143
|
+
/** The full reference name, e.g. `refs/heads/main`. */
|
|
105
144
|
ref: string;
|
|
145
|
+
/** The API URL of the reference. */
|
|
106
146
|
url: string;
|
|
107
147
|
}
|
|
148
|
+
/** A git commit, with only the fields this client reads. */
|
|
108
149
|
interface GitCommit {
|
|
150
|
+
/** The commit's SHA. */
|
|
109
151
|
sha: string;
|
|
152
|
+
/** The tree the commit points at. */
|
|
110
153
|
tree: {
|
|
154
|
+
/** The tree's SHA. */
|
|
111
155
|
sha: string;
|
|
156
|
+
/** The API URL of the tree. */
|
|
112
157
|
url: string;
|
|
113
158
|
};
|
|
114
159
|
}
|
|
160
|
+
/** One entry of a git tree. */
|
|
115
161
|
interface GitTreeItem {
|
|
162
|
+
/** The entry's path within the tree. */
|
|
116
163
|
path: string;
|
|
164
|
+
/** The entry's object SHA. */
|
|
117
165
|
sha: string;
|
|
166
|
+
/** The kind of object the entry points at, e.g. `blob` or `tree`. */
|
|
118
167
|
type: string;
|
|
168
|
+
/** The entry's file mode, e.g. `100644`. */
|
|
119
169
|
mode?: string;
|
|
170
|
+
/** The blob's size in bytes; absent for trees. */
|
|
120
171
|
size?: number;
|
|
121
172
|
}
|
|
173
|
+
/** A git tree as GitHub returns it. */
|
|
122
174
|
interface GitTree {
|
|
175
|
+
/** The tree's SHA. */
|
|
123
176
|
sha: string;
|
|
177
|
+
/** The entries of the tree. */
|
|
124
178
|
tree: GitTreeItem[];
|
|
179
|
+
/** Whether GitHub cut the entry list short because the tree was too large. */
|
|
125
180
|
truncated: boolean;
|
|
126
181
|
}
|
|
182
|
+
/** A file's contents as the contents API returns them. */
|
|
127
183
|
interface GitContents {
|
|
184
|
+
/** The file content, encoded as named by `encoding`. */
|
|
128
185
|
content: string;
|
|
186
|
+
/** The encoding of `content`, normally `base64`. */
|
|
129
187
|
encoding: string;
|
|
188
|
+
/** The file's blob SHA. */
|
|
130
189
|
sha: string;
|
|
190
|
+
/** The file's name. */
|
|
131
191
|
name: string;
|
|
192
|
+
/** The file's path in the repository. */
|
|
132
193
|
path: string;
|
|
133
194
|
}
|
|
134
195
|
/** What `git.putContents` returns: the file's new blob sha (the `sha` to pass next time) and the commit it made. */
|
|
135
196
|
interface PutContentsResult {
|
|
197
|
+
/** The file written: its path and its new blob SHA. */
|
|
136
198
|
content: {
|
|
199
|
+
/** The file's new blob SHA. */
|
|
137
200
|
sha: string;
|
|
201
|
+
/** The file's path. */
|
|
138
202
|
path: string;
|
|
139
203
|
};
|
|
204
|
+
/** The commit that was made. */
|
|
140
205
|
commit: {
|
|
206
|
+
/** The new commit's SHA. */
|
|
141
207
|
sha: string;
|
|
142
208
|
};
|
|
143
209
|
}
|
|
210
|
+
/** The body of a `putContents()` request. */
|
|
144
211
|
interface PutContentsInput {
|
|
212
|
+
/** The commit message. */
|
|
145
213
|
message: string;
|
|
146
214
|
/** The new file text (UTF-8); the client encodes it. */
|
|
147
215
|
content: string;
|
|
@@ -154,90 +222,150 @@ interface PutContentsInput {
|
|
|
154
222
|
/** Defaults to the repo's default branch. */
|
|
155
223
|
branch?: string;
|
|
156
224
|
}
|
|
225
|
+
/** A git blob created in the repository. */
|
|
157
226
|
interface GitBlob {
|
|
227
|
+
/** The blob's SHA. */
|
|
158
228
|
sha: string;
|
|
229
|
+
/** The API URL of the blob. */
|
|
159
230
|
url: string;
|
|
160
231
|
}
|
|
232
|
+
/** A pull request as returned when one is created, with only the fields this client reads. */
|
|
161
233
|
interface GitPull {
|
|
234
|
+
/** The pull request's number. */
|
|
162
235
|
number: number;
|
|
236
|
+
/** The URL of the pull request's page on GitHub. */
|
|
163
237
|
html_url: string;
|
|
238
|
+
/** The pull request's title. */
|
|
164
239
|
title: string;
|
|
165
240
|
}
|
|
241
|
+
/** The body of a `createPull()` request. */
|
|
166
242
|
interface CreatePullInput {
|
|
243
|
+
/** The pull request's title. */
|
|
167
244
|
title: string;
|
|
245
|
+
/** The branch the changes come from. */
|
|
168
246
|
head: string;
|
|
247
|
+
/** The branch the changes are to be merged into. */
|
|
169
248
|
base: string;
|
|
249
|
+
/** The pull request's description. */
|
|
170
250
|
body?: string;
|
|
171
251
|
}
|
|
252
|
+
/** An issue as GitHub returns it, with only the fields this client reads. */
|
|
172
253
|
interface GitHubIssue {
|
|
254
|
+
/** The issue's numeric id. */
|
|
173
255
|
id: number;
|
|
256
|
+
/** The issue's number within its repository. */
|
|
174
257
|
number: number;
|
|
258
|
+
/** The issue's title. */
|
|
175
259
|
title: string;
|
|
260
|
+
/** The issue's description; `null` or absent when empty. */
|
|
176
261
|
body?: string | null;
|
|
262
|
+
/** Whether the issue is open or closed. */
|
|
177
263
|
state: "open" | "closed";
|
|
264
|
+
/** The labels on the issue. */
|
|
178
265
|
labels: Array<{
|
|
179
266
|
name: string;
|
|
180
267
|
}>;
|
|
268
|
+
/** The user the issue is assigned to, or `null` when unassigned. */
|
|
181
269
|
assignee: {
|
|
182
270
|
login: string;
|
|
183
271
|
name?: string | null;
|
|
184
272
|
email?: string | null;
|
|
185
273
|
} | null;
|
|
274
|
+
/** When the issue was last updated, as an ISO 8601 timestamp. */
|
|
186
275
|
updated_at: string;
|
|
276
|
+
/** The URL of the issue's page on GitHub. */
|
|
187
277
|
html_url: string;
|
|
278
|
+
/** Set when the item is a pull request; GitHub's issues API returns pull requests too. */
|
|
188
279
|
pull_request?: unknown;
|
|
189
280
|
}
|
|
281
|
+
/** A milestone, with only the fields this client reads. */
|
|
190
282
|
interface GitHubMilestone {
|
|
283
|
+
/** The milestone's number. */
|
|
191
284
|
number: number;
|
|
285
|
+
/** The milestone's title. */
|
|
192
286
|
title: string;
|
|
193
287
|
}
|
|
288
|
+
/** Filters for listing issues. */
|
|
194
289
|
interface IssueSearchParams {
|
|
290
|
+
/** Which issues to list by state; GitHub defaults to `open`. */
|
|
195
291
|
state?: "open" | "closed" | "all";
|
|
292
|
+
/** The field to sort by, passed through to GitHub. */
|
|
196
293
|
sort?: string;
|
|
294
|
+
/** The sort direction, passed through to GitHub. */
|
|
197
295
|
direction?: string;
|
|
296
|
+
/** The number of issues per page. */
|
|
198
297
|
per_page?: number;
|
|
298
|
+
/** Which issues to list by relation to the user, passed through to GitHub. */
|
|
199
299
|
filter?: string;
|
|
300
|
+
/** Limit to issues assigned to this login. */
|
|
200
301
|
assignee?: string;
|
|
201
302
|
}
|
|
303
|
+
/** A repository label. */
|
|
202
304
|
interface GitHubLabel {
|
|
305
|
+
/** The label's name. */
|
|
203
306
|
name: string;
|
|
307
|
+
/** The label's color as a hex code without the leading `#`. */
|
|
204
308
|
color: string;
|
|
309
|
+
/** The label's description, or `null` when it has none. */
|
|
205
310
|
description: string | null;
|
|
206
311
|
}
|
|
312
|
+
/** How a Pages site is built: by a workflow or from a branch. */
|
|
207
313
|
type PagesBuildType = "workflow" | "legacy";
|
|
314
|
+
/** The status of a Pages build. */
|
|
208
315
|
type PagesBuildStatus = "built" | "building" | "errored" | "unknown";
|
|
316
|
+
/** A repository's GitHub Pages site configuration. */
|
|
209
317
|
interface GitHubPages {
|
|
318
|
+
/** The latest build's status, or `null` when there is none. */
|
|
210
319
|
status: PagesBuildStatus | null;
|
|
320
|
+
/** How the site is built, or `null` when unknown. */
|
|
211
321
|
build_type: PagesBuildType | null;
|
|
322
|
+
/** The branch and folder the site is published from, for a legacy build. */
|
|
212
323
|
source?: {
|
|
324
|
+
/** The branch the site is published from. */
|
|
213
325
|
branch: string;
|
|
326
|
+
/** The folder on the branch, `/` or `/docs`. */
|
|
214
327
|
path: string;
|
|
215
328
|
};
|
|
329
|
+
/** Whether HTTPS is enforced for the site. */
|
|
216
330
|
https_enforced: boolean;
|
|
331
|
+
/** The site's custom domain, or `null` when it has none. */
|
|
217
332
|
custom_domain: string | null;
|
|
218
333
|
}
|
|
334
|
+
/** The body of a Pages creation request. */
|
|
219
335
|
interface CreatePagesPayload {
|
|
336
|
+
/** How the site is built. */
|
|
220
337
|
build_type: PagesBuildType;
|
|
221
338
|
/** Required when build_type is "legacy". */
|
|
222
339
|
source?: {
|
|
340
|
+
/** The branch the site is published from. */
|
|
223
341
|
branch: string;
|
|
342
|
+
/** The folder on the branch, `/` or `/docs`. */
|
|
224
343
|
path: string;
|
|
225
344
|
};
|
|
226
345
|
}
|
|
346
|
+
/** The body of a Pages update request; every field is optional. */
|
|
227
347
|
interface UpdatePagesPayload {
|
|
348
|
+
/** How the site is built. */
|
|
228
349
|
build_type?: PagesBuildType;
|
|
350
|
+
/** The branch and folder to publish from. */
|
|
229
351
|
source?: {
|
|
352
|
+
/** The branch the site is published from. */
|
|
230
353
|
branch: string;
|
|
354
|
+
/** The folder on the branch, `/` or `/docs`. */
|
|
231
355
|
path: string;
|
|
232
356
|
};
|
|
357
|
+
/** The custom domain, or `null` to remove it. */
|
|
233
358
|
cname?: string | null;
|
|
359
|
+
/** Whether to enforce HTTPS. */
|
|
234
360
|
https_enforced?: boolean;
|
|
235
361
|
}
|
|
236
362
|
/** One custom property of an organization, as its schema defines it. */
|
|
237
363
|
interface OrgProperty {
|
|
364
|
+
/** The property's name. */
|
|
238
365
|
property_name: string;
|
|
239
366
|
/** `string`, `single_select`, `multi_select`, `true_false` or `url`. */
|
|
240
367
|
value_type: string;
|
|
368
|
+
/** Whether a repository must set the property. */
|
|
241
369
|
required?: boolean;
|
|
242
370
|
/** The values a `single_select` or `multi_select` property accepts; `null` for any other type. */
|
|
243
371
|
allowed_values?: string[] | null;
|
|
@@ -249,11 +377,17 @@ interface RepoPropertyValue {
|
|
|
249
377
|
/** A string, a string array for `multi_select`, or `null` when unset. */
|
|
250
378
|
value: string | string[] | null;
|
|
251
379
|
}
|
|
380
|
+
/** A pull request as GitHub returns it, with only the fields this client reads. */
|
|
252
381
|
interface GitHubPullRequest {
|
|
382
|
+
/** The pull request's number. */
|
|
253
383
|
number: number;
|
|
384
|
+
/** The pull request's title. */
|
|
254
385
|
title: string;
|
|
386
|
+
/** Whether the pull request is open or closed. */
|
|
255
387
|
state: "open" | "closed";
|
|
388
|
+
/** When the pull request was merged as an ISO 8601 timestamp, or `null` if it was not merged. */
|
|
256
389
|
merged_at: string | null;
|
|
390
|
+
/** The URL of the pull request's page on GitHub. */
|
|
257
391
|
html_url: string;
|
|
258
392
|
/** The head branch: its name and the commit it pointed at when the PR was read. */
|
|
259
393
|
head: {
|
|
@@ -270,10 +404,15 @@ interface GitHubCommitIdentity {
|
|
|
270
404
|
}
|
|
271
405
|
/** One commit as returned by `GET /pulls/{pull_number}/commits` — only the fields any known consumer needs. */
|
|
272
406
|
interface GitHubPullRequestCommit {
|
|
407
|
+
/** The commit's SHA. */
|
|
273
408
|
sha: string;
|
|
409
|
+
/** The commit's message and git identities. */
|
|
274
410
|
commit: {
|
|
411
|
+
/** The commit message. */
|
|
275
412
|
message: string;
|
|
413
|
+
/** The commit's author, as git recorded it. */
|
|
276
414
|
author: GitHubCommitIdentity;
|
|
415
|
+
/** The commit's committer, as git recorded it. */
|
|
277
416
|
committer: GitHubCommitIdentity;
|
|
278
417
|
};
|
|
279
418
|
/** The commit's linked GitHub account, when GitHub can associate one — `null` for a commit email with no linked account. `type: "Bot"` identifies an app-authored commit (e.g. Dependabot, a prior Sentinel auto-fix-commit). */
|
|
@@ -288,7 +427,9 @@ interface GitHubPullRequestCommit {
|
|
|
288
427
|
}
|
|
289
428
|
/** One file as returned by `GET /pulls/{pull_number}/files` — only the fields any known consumer needs. */
|
|
290
429
|
interface GitHubPullRequestFile {
|
|
430
|
+
/** The file's path in the repository. */
|
|
291
431
|
filename: string;
|
|
432
|
+
/** How the pull request changes the file. */
|
|
292
433
|
status: "added" | "removed" | "modified" | "renamed" | "copied" | "changed" | "unchanged";
|
|
293
434
|
/** Set only when `status === "renamed"`. */
|
|
294
435
|
previous_filename?: string;
|
|
@@ -308,8 +449,10 @@ interface CreateReviewComment {
|
|
|
308
449
|
line: number;
|
|
309
450
|
/** Almost always `"RIGHT"` (the PR's own new content) — `"LEFT"` targets the base/pre-PR version instead. */
|
|
310
451
|
side: "LEFT" | "RIGHT";
|
|
452
|
+
/** The comment text. */
|
|
311
453
|
body: string;
|
|
312
454
|
}
|
|
455
|
+
/** The body of a review creation request. */
|
|
313
456
|
interface CreateReviewInput {
|
|
314
457
|
/** The PR's head SHA the review attaches to. */
|
|
315
458
|
commit_id: string;
|
|
@@ -322,11 +465,14 @@ interface CreateReviewInput {
|
|
|
322
465
|
* required-approval counts and dismissal.
|
|
323
466
|
*/
|
|
324
467
|
event: "COMMENT" | "REQUEST_CHANGES" | "APPROVE";
|
|
468
|
+
/** Inline comments to post with the review. */
|
|
325
469
|
comments?: CreateReviewComment[];
|
|
326
470
|
}
|
|
327
471
|
/** `POST /pulls/{pull_number}/reviews`'s response — only the fields any known consumer needs. */
|
|
328
472
|
interface GitHubPullRequestReview {
|
|
473
|
+
/** The review's numeric id. */
|
|
329
474
|
id: number;
|
|
475
|
+
/** The URL of the review on GitHub. */
|
|
330
476
|
html_url: string;
|
|
331
477
|
}
|
|
332
478
|
/**
|
|
@@ -337,7 +483,9 @@ interface GitHubPullRequestReview {
|
|
|
337
483
|
* never compare it against a REST-sourced ID.
|
|
338
484
|
*/
|
|
339
485
|
interface ReviewThread {
|
|
486
|
+
/** The thread's GraphQL node id. */
|
|
340
487
|
id: string;
|
|
488
|
+
/** Whether the thread is resolved. */
|
|
341
489
|
isResolved: boolean;
|
|
342
490
|
/** The thread's first comment's author login (e.g. `"the-holocron-sentinel[bot]"`) — `undefined` if GitHub ever returns a thread with no comments, which shouldn't happen in practice. Callers filter on this before resolving anything, so a bot never touches a human reviewer's own thread. */
|
|
343
491
|
authorLogin: string | undefined;
|
|
@@ -355,8 +503,11 @@ interface ReviewThread {
|
|
|
355
503
|
*/
|
|
356
504
|
body: string | undefined;
|
|
357
505
|
}
|
|
506
|
+
/** A repository as GitHub returns it, with only the fields this client reads. */
|
|
358
507
|
interface GitHubRepo {
|
|
508
|
+
/** The name of the repository's default branch. */
|
|
359
509
|
default_branch: string;
|
|
510
|
+
/** The repository's `owner/name`. */
|
|
360
511
|
full_name: string;
|
|
361
512
|
/** The repository description. */
|
|
362
513
|
description?: string | null;
|
|
@@ -389,13 +540,20 @@ interface GitHubRepo {
|
|
|
389
540
|
status: string;
|
|
390
541
|
} | undefined> | null;
|
|
391
542
|
}
|
|
543
|
+
/** A file's contents as the contents API returns them. */
|
|
392
544
|
interface GitHubContents {
|
|
545
|
+
/** The file content, encoded as named by `encoding`. */
|
|
393
546
|
content: string;
|
|
547
|
+
/** The encoding of `content`, normally `base64`. */
|
|
394
548
|
encoding: string;
|
|
395
549
|
}
|
|
550
|
+
/** A repository ruleset in summary form. */
|
|
396
551
|
interface GitHubRuleset {
|
|
552
|
+
/** The ruleset's numeric id. */
|
|
397
553
|
id: number;
|
|
554
|
+
/** The ruleset's name. */
|
|
398
555
|
name: string;
|
|
556
|
+
/** How the ruleset is enforced, e.g. `active`, `evaluate` or `disabled`. */
|
|
399
557
|
enforcement: string;
|
|
400
558
|
}
|
|
401
559
|
/** One ruleset in full, as `GET /repos/{repo}/rulesets/{id}` returns it. */
|
|
@@ -408,6 +566,7 @@ interface GitHubRulesetDetail extends GitHubRuleset {
|
|
|
408
566
|
parameters?: Record<string, unknown>;
|
|
409
567
|
}>;
|
|
410
568
|
}
|
|
569
|
+
/** Where a secret lives: the repository, one of its environments, or an organization. */
|
|
411
570
|
type SecretScope = {
|
|
412
571
|
kind: "repo";
|
|
413
572
|
} | {
|
|
@@ -417,14 +576,21 @@ type SecretScope = {
|
|
|
417
576
|
kind: "organization";
|
|
418
577
|
org: string;
|
|
419
578
|
};
|
|
579
|
+
/** A public key used to encrypt a secret before it is sent. */
|
|
420
580
|
interface GitHubPublicKey {
|
|
581
|
+
/** The key's id, sent back with the encrypted secret. */
|
|
421
582
|
key_id: string;
|
|
583
|
+
/** The Base64-encoded public key. */
|
|
422
584
|
key: string;
|
|
423
585
|
}
|
|
586
|
+
/** The workflow run that a code scanning setup started. */
|
|
424
587
|
interface CodeScanningSetupResult {
|
|
588
|
+
/** The id of the workflow run. */
|
|
425
589
|
run_id: number;
|
|
590
|
+
/** The URL of the workflow run. */
|
|
426
591
|
run_url: string;
|
|
427
592
|
}
|
|
593
|
+
/** A permission level a team can hold on a repository. */
|
|
428
594
|
type TeamPermission = "pull" | "triage" | "push" | "maintain" | "admin";
|
|
429
595
|
/** A team with access to a repository, and the permission it has there. */
|
|
430
596
|
interface RepoTeam {
|
|
@@ -435,10 +601,14 @@ interface RepoTeam {
|
|
|
435
601
|
}
|
|
436
602
|
/** A member of a team, as GitHub lists it. `id` is the numeric user id, which survives a rename; `login` does not. */
|
|
437
603
|
interface TeamMember {
|
|
604
|
+
/** The member's numeric user id. */
|
|
438
605
|
id: number;
|
|
606
|
+
/** The member's login. */
|
|
439
607
|
login: string;
|
|
608
|
+
/** The kind of account, e.g. `User`. */
|
|
440
609
|
type?: string;
|
|
441
610
|
}
|
|
611
|
+
/** Where a variable lives: the repository, one of its environments, or an organization. */
|
|
442
612
|
type VariableScope = {
|
|
443
613
|
kind: "repo";
|
|
444
614
|
} | {
|
|
@@ -455,14 +625,20 @@ type VariableScope = {
|
|
|
455
625
|
type VariableVisibility = "all" | "private" | "selected";
|
|
456
626
|
/** A GitHub Actions variable. Unlike a secret its value is readable, so a reconcile can tell whether it differs. */
|
|
457
627
|
interface GitHubVariable {
|
|
628
|
+
/** The variable's name. */
|
|
458
629
|
name: string;
|
|
630
|
+
/** The variable's value. */
|
|
459
631
|
value: string;
|
|
460
632
|
/** Present on organization variables only. */
|
|
461
633
|
visibility?: VariableVisibility;
|
|
462
634
|
}
|
|
635
|
+
/** The authenticated user, with only the fields this client reads. */
|
|
463
636
|
interface GitHubUser {
|
|
637
|
+
/** The user's login. */
|
|
464
638
|
login: string;
|
|
639
|
+
/** The user's display name, or `null` when not set. */
|
|
465
640
|
name: string | null;
|
|
641
|
+
/** The user's public email, or `null` when not set. */
|
|
466
642
|
email: string | null;
|
|
467
643
|
}
|
|
468
644
|
/** The authenticated user and, for a token that expires, when. */
|
|
@@ -477,30 +653,48 @@ interface GitHubUserWithExpiry {
|
|
|
477
653
|
* ISO 8601, or `undefined` when the header is missing or is not a date.
|
|
478
654
|
*/
|
|
479
655
|
export declare function parseTokenExpiration(header: string | null): string | undefined;
|
|
656
|
+
/** A workflow run as GitHub returns it, with only the fields this client reads. */
|
|
480
657
|
interface GitHubWorkflowRun {
|
|
658
|
+
/** The run's numeric id. */
|
|
481
659
|
id: number;
|
|
660
|
+
/** The workflow's name, or `null` when unnamed. */
|
|
482
661
|
name: string | null;
|
|
662
|
+
/** The run's display title. */
|
|
483
663
|
display_title: string;
|
|
664
|
+
/** The branch the run was triggered on. */
|
|
484
665
|
head_branch: string;
|
|
666
|
+
/** The commit SHA the run was triggered on. */
|
|
485
667
|
head_sha: string;
|
|
668
|
+
/** The run's status, e.g. `queued`, `in_progress` or `completed`. */
|
|
486
669
|
status: string;
|
|
670
|
+
/** The run's result once completed, or `null` before. */
|
|
487
671
|
conclusion: string | null;
|
|
672
|
+
/** The URL of the run's page on GitHub. */
|
|
488
673
|
html_url: string;
|
|
674
|
+
/** When the run was created, as an ISO 8601 timestamp. */
|
|
489
675
|
created_at: string;
|
|
676
|
+
/** When the run was last updated, as an ISO 8601 timestamp. */
|
|
490
677
|
updated_at: string;
|
|
491
678
|
}
|
|
679
|
+
/** Filters for listing workflow runs. */
|
|
492
680
|
interface WorkflowRunFilter {
|
|
681
|
+
/** Only runs on this branch. */
|
|
493
682
|
branch?: string;
|
|
683
|
+
/** The maximum number of runs to return. */
|
|
494
684
|
limit?: number;
|
|
685
|
+
/** Only runs with this status. */
|
|
495
686
|
status?: string;
|
|
496
687
|
}
|
|
688
|
+
/** The credentials identifying a GitHub App: its id and private key. */
|
|
497
689
|
interface GitHubAppCredentials {
|
|
498
690
|
/** The App's numeric id (not the client id). */
|
|
499
691
|
appId: string;
|
|
500
692
|
/** PEM-encoded RSA private key — PKCS#1 (GitHub's default download format) or PKCS#8, either works. */
|
|
501
693
|
privateKey: string;
|
|
502
694
|
}
|
|
695
|
+
/** A short-lived installation access token and when it expires. */
|
|
503
696
|
interface InstallationAccessToken {
|
|
697
|
+
/** The installation access token, used as a bearer token for the REST API. */
|
|
504
698
|
token: string;
|
|
505
699
|
/** ISO 8601 — installation tokens are short-lived, about an hour. */
|
|
506
700
|
expiresAt: string;
|
|
@@ -550,6 +744,7 @@ export declare function verifyGitHubWebhookSignature(input: {
|
|
|
550
744
|
signature: string | undefined;
|
|
551
745
|
secret: string;
|
|
552
746
|
}): boolean;
|
|
747
|
+
/** The three GitHub webhook headers a consumer needs. */
|
|
553
748
|
interface GitHubWebhookHeaders {
|
|
554
749
|
/** `X-GitHub-Event` — the event category, e.g. `"push"`, `"pull_request"`. */
|
|
555
750
|
event: string | undefined;
|
|
@@ -560,31 +755,62 @@ interface GitHubWebhookHeaders {
|
|
|
560
755
|
}
|
|
561
756
|
/** Extracts GitHub's three webhook headers, case-insensitively (Node's raw headers may arrive lower-cased, or as an array when a header repeats). */
|
|
562
757
|
export declare function parseGitHubWebhookHeaders(headers: Record<string, string | string[] | undefined>): GitHubWebhookHeaders;
|
|
758
|
+
/** The payload of an `installation` webhook delivery. */
|
|
563
759
|
interface GitHubInstallationWebhookPayload {
|
|
760
|
+
/** What happened to the installation, e.g. `created` or `deleted`. */
|
|
564
761
|
action: string;
|
|
762
|
+
/** The installation the delivery is about. */
|
|
565
763
|
installation: {
|
|
764
|
+
/** The installation id. */
|
|
566
765
|
id: number;
|
|
567
766
|
};
|
|
568
767
|
}
|
|
768
|
+
/** The payload of a `push` webhook delivery. */
|
|
569
769
|
interface GitHubPushWebhookPayload {
|
|
770
|
+
/** The full name of the pushed ref, e.g. `refs/heads/main`. */
|
|
570
771
|
ref: string;
|
|
772
|
+
/** The installation the delivery is about, when sent. */
|
|
571
773
|
installation?: {
|
|
774
|
+
/** The installation id. */
|
|
572
775
|
id: number;
|
|
573
776
|
};
|
|
777
|
+
/** The repository that was pushed to. */
|
|
574
778
|
repository: {
|
|
779
|
+
/** The repository's owner/name. */
|
|
575
780
|
full_name: string;
|
|
781
|
+
/** The name of the default branch. */
|
|
576
782
|
default_branch: string;
|
|
577
783
|
};
|
|
578
784
|
}
|
|
785
|
+
/** The payload of a `pull_request` webhook delivery. */
|
|
579
786
|
interface GitHubPullRequestWebhookPayload {
|
|
787
|
+
/** What happened to the pull request, e.g. `opened` or `closed`. */
|
|
580
788
|
action: string;
|
|
789
|
+
/** For an `edited` action, the fields that changed (each holds the previous value); absent for other actions. */
|
|
790
|
+
changes?: {
|
|
791
|
+
/** Present when the title was edited. */
|
|
792
|
+
title?: {
|
|
793
|
+
/** The title before the edit. */
|
|
794
|
+
from: string;
|
|
795
|
+
};
|
|
796
|
+
/** Present when the description was edited. */
|
|
797
|
+
body?: {
|
|
798
|
+
/** The description before the edit; `null` when it was empty. */
|
|
799
|
+
from: string | null;
|
|
800
|
+
};
|
|
801
|
+
};
|
|
802
|
+
/** The installation the delivery is about, when sent. */
|
|
581
803
|
installation?: {
|
|
804
|
+
/** The installation id. */
|
|
582
805
|
id: number;
|
|
583
806
|
};
|
|
807
|
+
/** The repository the pull request belongs to. */
|
|
584
808
|
repository: {
|
|
809
|
+
/** The repository's owner/name. */
|
|
585
810
|
full_name: string;
|
|
586
811
|
};
|
|
587
812
|
}
|
|
813
|
+
/** Creates a GitHub client with a group of methods per API area (branches, pulls, issues, secrets and so on), backed by one REST client and one GraphQL client built from the same options. */
|
|
588
814
|
export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
589
815
|
branches: {
|
|
590
816
|
protectBranch: (repo: string, branch: string, payload: Record<string, unknown>) => Promise<void>;
|
|
@@ -717,5 +943,6 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
717
943
|
createWorkflowDispatch: (repo: string, workflowFile: string, ref: string, inputs?: Record<string, string>) => Promise<void>;
|
|
718
944
|
};
|
|
719
945
|
};
|
|
946
|
+
/** The client returned by `createGitHubClient()`: one group of methods per GitHub API area. */
|
|
720
947
|
export type GitHubClient = ReturnType<typeof createGitHubClient>;
|
|
721
948
|
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitHubAppCredentials, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubRulesetDetail, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, RepoPropertyValue, RepoTeam, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -891,6 +891,7 @@ function parseGitHubWebhookHeaders(headers) {
|
|
|
891
891
|
};
|
|
892
892
|
}
|
|
893
893
|
// src/index.ts
|
|
894
|
+
/** Creates a GitHub client with a group of methods per API area (branches, pulls, issues, secrets and so on), backed by one REST client and one GraphQL client built from the same options. */
|
|
894
895
|
function createGitHubClient(opts) {
|
|
895
896
|
const rest = createGitHubRestClient(opts);
|
|
896
897
|
const graphql = createGitHubGraphQLApiClient(opts);
|
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.4",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.4",
|
|
36
36
|
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"tsdown": "^0.23.3",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.0.5",
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.5",
|
|
49
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.5",
|
|
51
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|