gh-api-client 1.0.0
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/LICENSE +21 -0
- package/README.md +371 -0
- package/dist/index.d.mts +1726 -0
- package/dist/index.d.ts +1726 -0
- package/dist/index.js +971 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +948 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1726 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common pagination parameters accepted by GitHub REST API list endpoints.
|
|
3
|
+
*
|
|
4
|
+
* GitHub uses page-based pagination. Pass `page` and `per_page` to control results.
|
|
5
|
+
*/
|
|
6
|
+
interface PaginationParams {
|
|
7
|
+
/**
|
|
8
|
+
* Maximum number of results per page.
|
|
9
|
+
* GitHub default is `30`, maximum is `100`.
|
|
10
|
+
*/
|
|
11
|
+
per_page?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Page number to retrieve (1-based).
|
|
14
|
+
* Use `nextPage` from the previous response to paginate forward.
|
|
15
|
+
*/
|
|
16
|
+
page?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Wrapper returned by GitHub paginated list endpoints.
|
|
20
|
+
*
|
|
21
|
+
* Use `values` for the items, `hasNextPage` and `nextPage` for pagination.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* let page = 1;
|
|
26
|
+
* let hasMore = true;
|
|
27
|
+
* while (hasMore) {
|
|
28
|
+
* const res = await gh.user('octocat').repos({ per_page: 100, page });
|
|
29
|
+
* process(res.values);
|
|
30
|
+
* hasMore = res.hasNextPage;
|
|
31
|
+
* page = res.nextPage ?? page + 1;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
interface GitHubPagedResponse<T> {
|
|
36
|
+
/** The items on the current page */
|
|
37
|
+
values: T[];
|
|
38
|
+
/** Whether there are more pages available */
|
|
39
|
+
hasNextPage: boolean;
|
|
40
|
+
/** The next page number, if `hasNextPage` is true */
|
|
41
|
+
nextPage?: number;
|
|
42
|
+
/** Total number of results (only available for search endpoints) */
|
|
43
|
+
totalCount?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Represents a GitHub organization.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://docs.github.com/en/rest/orgs/orgs#get-an-organization}
|
|
50
|
+
*/
|
|
51
|
+
interface GitHubOrganization {
|
|
52
|
+
/** Unique numeric organization ID */
|
|
53
|
+
id: number;
|
|
54
|
+
/** The organization's login name (e.g., `'github'`) */
|
|
55
|
+
login: string;
|
|
56
|
+
/** Display name */
|
|
57
|
+
name: string | null;
|
|
58
|
+
/** Organization description */
|
|
59
|
+
description: string | null;
|
|
60
|
+
/** URL to the organization's avatar image */
|
|
61
|
+
avatar_url: string;
|
|
62
|
+
/** URL to the organization's GitHub page */
|
|
63
|
+
html_url: string;
|
|
64
|
+
/** API URL for the organization's repositories */
|
|
65
|
+
repos_url: string;
|
|
66
|
+
/** Number of public repositories */
|
|
67
|
+
public_repos: number;
|
|
68
|
+
/** Number of public gists */
|
|
69
|
+
public_gists: number;
|
|
70
|
+
/** Number of followers */
|
|
71
|
+
followers: number;
|
|
72
|
+
/** Number of accounts the org follows */
|
|
73
|
+
following: number;
|
|
74
|
+
/** ISO 8601 timestamp of organization creation */
|
|
75
|
+
created_at: string;
|
|
76
|
+
/** ISO 8601 timestamp of last update */
|
|
77
|
+
updated_at: string;
|
|
78
|
+
/** Account type — always `'Organization'` */
|
|
79
|
+
type: 'Organization';
|
|
80
|
+
/** Whether this is a verified organization */
|
|
81
|
+
is_verified?: boolean;
|
|
82
|
+
/** Number of private repositories (requires admin scope) */
|
|
83
|
+
total_private_repos?: number;
|
|
84
|
+
/** Total number of members */
|
|
85
|
+
members_count?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Query parameters for listing organization members.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link https://docs.github.com/en/rest/orgs/members#list-organization-members}
|
|
91
|
+
*/
|
|
92
|
+
interface OrgMembersParams extends PaginationParams {
|
|
93
|
+
/** Filter members by role */
|
|
94
|
+
role?: 'all' | 'admin' | 'member';
|
|
95
|
+
/** Filter members by public visibility */
|
|
96
|
+
filter?: 'all' | '2fa_disabled';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Represents a GitHub user or bot.
|
|
101
|
+
* This is the minimal user object embedded in other responses (e.g., repository owner, PR author).
|
|
102
|
+
*/
|
|
103
|
+
interface GitHubUser {
|
|
104
|
+
/** Unique numeric user ID */
|
|
105
|
+
id: number;
|
|
106
|
+
/** The user's login name (e.g., `'octocat'`) */
|
|
107
|
+
login: string;
|
|
108
|
+
/** Display name, may be null for users who have not set one */
|
|
109
|
+
name: string | null;
|
|
110
|
+
/** Public email address, may be null */
|
|
111
|
+
email: string | null;
|
|
112
|
+
/** URL to the user's avatar image */
|
|
113
|
+
avatar_url: string;
|
|
114
|
+
/** URL to the user's GitHub profile page */
|
|
115
|
+
html_url: string;
|
|
116
|
+
/** Account type */
|
|
117
|
+
type: 'User' | 'Organization' | 'Bot';
|
|
118
|
+
/** Whether the user is a GitHub site administrator */
|
|
119
|
+
site_admin: boolean;
|
|
120
|
+
/** The user's company affiliation */
|
|
121
|
+
company?: string | null;
|
|
122
|
+
/** The user's biography */
|
|
123
|
+
bio?: string | null;
|
|
124
|
+
/** The user's location */
|
|
125
|
+
location?: string | null;
|
|
126
|
+
/** Number of public repositories */
|
|
127
|
+
public_repos?: number;
|
|
128
|
+
/** Number of public gists */
|
|
129
|
+
public_gists?: number;
|
|
130
|
+
/** Number of followers */
|
|
131
|
+
followers?: number;
|
|
132
|
+
/** Number of accounts the user follows */
|
|
133
|
+
following?: number;
|
|
134
|
+
/** ISO 8601 timestamp of account creation */
|
|
135
|
+
created_at?: string;
|
|
136
|
+
/** ISO 8601 timestamp of last profile update */
|
|
137
|
+
updated_at?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Query parameters accepted by `GET /users` (list all users).
|
|
141
|
+
*
|
|
142
|
+
* @see {@link https://docs.github.com/en/rest/users/users#list-users}
|
|
143
|
+
*/
|
|
144
|
+
interface UsersParams {
|
|
145
|
+
/** The integer ID of the last user seen */
|
|
146
|
+
since?: number;
|
|
147
|
+
/** Results per page (max 100) */
|
|
148
|
+
per_page?: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Query parameters accepted by `GET /search/users`.
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://docs.github.com/en/rest/search/search#search-users}
|
|
154
|
+
*/
|
|
155
|
+
interface SearchUsersParams extends PaginationParams {
|
|
156
|
+
/** Search query (required) */
|
|
157
|
+
q: string;
|
|
158
|
+
/** Sort field */
|
|
159
|
+
sort?: 'followers' | 'repositories' | 'joined';
|
|
160
|
+
/** Sort direction */
|
|
161
|
+
order?: 'asc' | 'desc';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Represents a GitHub repository.
|
|
166
|
+
*
|
|
167
|
+
* @see {@link https://docs.github.com/en/rest/repos/repos#get-a-repository}
|
|
168
|
+
*/
|
|
169
|
+
interface GitHubRepository {
|
|
170
|
+
/** Unique numeric repository ID */
|
|
171
|
+
id: number;
|
|
172
|
+
/** Repository name (e.g., `'Hello-World'`) */
|
|
173
|
+
name: string;
|
|
174
|
+
/** Full name including owner (e.g., `'octocat/Hello-World'`) */
|
|
175
|
+
full_name: string;
|
|
176
|
+
/** Repository owner (user or organization) */
|
|
177
|
+
owner: GitHubUser;
|
|
178
|
+
/** Whether the repository is private */
|
|
179
|
+
private: boolean;
|
|
180
|
+
/** Repository description */
|
|
181
|
+
description: string | null;
|
|
182
|
+
/** Whether the repository is a fork */
|
|
183
|
+
fork: boolean;
|
|
184
|
+
/** URL to the repository on GitHub */
|
|
185
|
+
html_url: string;
|
|
186
|
+
/** HTTPS clone URL */
|
|
187
|
+
clone_url: string;
|
|
188
|
+
/** SSH clone URL */
|
|
189
|
+
ssh_url: string;
|
|
190
|
+
/** Default branch name (e.g., `'main'`) */
|
|
191
|
+
default_branch: string;
|
|
192
|
+
/** Primary language */
|
|
193
|
+
language: string | null;
|
|
194
|
+
/** Number of forks */
|
|
195
|
+
forks_count: number;
|
|
196
|
+
/** Number of stargazers */
|
|
197
|
+
stargazers_count: number;
|
|
198
|
+
/** Number of watchers */
|
|
199
|
+
watchers_count: number;
|
|
200
|
+
/** Number of open issues and pull requests */
|
|
201
|
+
open_issues_count: number;
|
|
202
|
+
/** Repository topics */
|
|
203
|
+
topics: string[];
|
|
204
|
+
/** Whether the repository is archived */
|
|
205
|
+
archived: boolean;
|
|
206
|
+
/** Whether the repository is disabled */
|
|
207
|
+
disabled: boolean;
|
|
208
|
+
/** Repository visibility */
|
|
209
|
+
visibility: 'public' | 'private' | 'internal';
|
|
210
|
+
/** ISO 8601 timestamp of the last push */
|
|
211
|
+
pushed_at: string | null;
|
|
212
|
+
/** ISO 8601 timestamp of repository creation */
|
|
213
|
+
created_at: string;
|
|
214
|
+
/** ISO 8601 timestamp of last update */
|
|
215
|
+
updated_at: string;
|
|
216
|
+
/** Repository size in kilobytes */
|
|
217
|
+
size?: number;
|
|
218
|
+
/** Whether the repository has issues enabled */
|
|
219
|
+
has_issues?: boolean;
|
|
220
|
+
/** Whether the repository has wiki enabled */
|
|
221
|
+
has_wiki?: boolean;
|
|
222
|
+
/** Whether the repository has projects enabled */
|
|
223
|
+
has_projects?: boolean;
|
|
224
|
+
/** Whether the repository has discussions enabled */
|
|
225
|
+
has_discussions?: boolean;
|
|
226
|
+
/** Parent repository, if this is a fork */
|
|
227
|
+
parent?: GitHubRepository;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Query parameters for listing user or organization repositories.
|
|
231
|
+
*
|
|
232
|
+
* @see {@link https://docs.github.com/en/rest/repos/repos#list-repositories-for-a-user}
|
|
233
|
+
*/
|
|
234
|
+
interface ReposParams extends PaginationParams {
|
|
235
|
+
/** Filter by repository type */
|
|
236
|
+
type?: 'all' | 'public' | 'private' | 'forks' | 'sources' | 'member';
|
|
237
|
+
/** Sort field */
|
|
238
|
+
sort?: 'created' | 'updated' | 'pushed' | 'full_name';
|
|
239
|
+
/** Sort direction */
|
|
240
|
+
direction?: 'asc' | 'desc';
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Query parameters for listing forks of a repository.
|
|
244
|
+
*
|
|
245
|
+
* @see {@link https://docs.github.com/en/rest/repos/forks#list-forks}
|
|
246
|
+
*/
|
|
247
|
+
interface ForksParams extends PaginationParams {
|
|
248
|
+
/** Sort field */
|
|
249
|
+
sort?: 'newest' | 'oldest' | 'stargazers' | 'watchers';
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Query parameters accepted by `GET /search/repositories`.
|
|
253
|
+
*
|
|
254
|
+
* @see {@link https://docs.github.com/en/rest/search/search#search-repositories}
|
|
255
|
+
*/
|
|
256
|
+
interface SearchReposParams extends PaginationParams {
|
|
257
|
+
/** Search query (required). Supports qualifiers like `user:octocat`, `language:typescript` */
|
|
258
|
+
q: string;
|
|
259
|
+
/** Sort field */
|
|
260
|
+
sort?: 'stars' | 'forks' | 'help-wanted-issues' | 'updated';
|
|
261
|
+
/** Sort direction */
|
|
262
|
+
order?: 'asc' | 'desc';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Represents a git reference in a pull request (head or base).
|
|
267
|
+
*/
|
|
268
|
+
interface GitHubRef {
|
|
269
|
+
/** Branch name (e.g., `'main'`, `'feature/my-feature'`) */
|
|
270
|
+
ref: string;
|
|
271
|
+
/** Commit SHA at the tip of this ref */
|
|
272
|
+
sha: string;
|
|
273
|
+
/** `owner:branch` label */
|
|
274
|
+
label: string;
|
|
275
|
+
/** The repository this ref belongs to */
|
|
276
|
+
repo: GitHubRepository;
|
|
277
|
+
/** The user who owns the ref's repository */
|
|
278
|
+
user: GitHubUser;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Represents a GitHub label on a pull request or issue.
|
|
282
|
+
*/
|
|
283
|
+
interface GitHubLabel {
|
|
284
|
+
/** Unique numeric label ID */
|
|
285
|
+
id: number;
|
|
286
|
+
/** Label name */
|
|
287
|
+
name: string;
|
|
288
|
+
/** Hex color code (without `#`) */
|
|
289
|
+
color: string;
|
|
290
|
+
/** Label description */
|
|
291
|
+
description: string | null;
|
|
292
|
+
/** Whether this is a default label */
|
|
293
|
+
default: boolean;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Represents a GitHub milestone.
|
|
297
|
+
*/
|
|
298
|
+
interface GitHubMilestone {
|
|
299
|
+
/** Unique numeric milestone ID */
|
|
300
|
+
id: number;
|
|
301
|
+
/** Milestone number within the repository */
|
|
302
|
+
number: number;
|
|
303
|
+
/** Milestone title */
|
|
304
|
+
title: string;
|
|
305
|
+
/** Milestone description */
|
|
306
|
+
description: string | null;
|
|
307
|
+
/** Milestone state */
|
|
308
|
+
state: 'open' | 'closed';
|
|
309
|
+
/** ISO 8601 due date, if set */
|
|
310
|
+
due_on: string | null;
|
|
311
|
+
/** ISO 8601 timestamp of creation */
|
|
312
|
+
created_at: string;
|
|
313
|
+
/** ISO 8601 timestamp of last update */
|
|
314
|
+
updated_at: string;
|
|
315
|
+
/** ISO 8601 timestamp of closing */
|
|
316
|
+
closed_at: string | null;
|
|
317
|
+
/** Number of open issues in this milestone */
|
|
318
|
+
open_issues: number;
|
|
319
|
+
/** Number of closed issues in this milestone */
|
|
320
|
+
closed_issues: number;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Represents a GitHub pull request.
|
|
324
|
+
*
|
|
325
|
+
* @see {@link https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request}
|
|
326
|
+
*/
|
|
327
|
+
interface GitHubPullRequest {
|
|
328
|
+
/** Unique numeric pull request ID (global across GitHub) */
|
|
329
|
+
id: number;
|
|
330
|
+
/** Pull request number within the repository */
|
|
331
|
+
number: number;
|
|
332
|
+
/** Pull request title */
|
|
333
|
+
title: string;
|
|
334
|
+
/** Pull request body / description */
|
|
335
|
+
body: string | null;
|
|
336
|
+
/** Current state */
|
|
337
|
+
state: 'open' | 'closed';
|
|
338
|
+
/** Whether the pull request is locked */
|
|
339
|
+
locked: boolean;
|
|
340
|
+
/** Whether the pull request has been merged */
|
|
341
|
+
merged: boolean;
|
|
342
|
+
/** Whether the pull request can be merged (null while GitHub computes it) */
|
|
343
|
+
mergeable: boolean | null;
|
|
344
|
+
/** Merge strategy used (only set when merged) */
|
|
345
|
+
merge_commit_sha: string | null;
|
|
346
|
+
/** ISO 8601 timestamp of merging */
|
|
347
|
+
merged_at: string | null;
|
|
348
|
+
/** ISO 8601 timestamp of closing */
|
|
349
|
+
closed_at: string | null;
|
|
350
|
+
/** ISO 8601 timestamp of creation */
|
|
351
|
+
created_at: string;
|
|
352
|
+
/** ISO 8601 timestamp of last update */
|
|
353
|
+
updated_at: string;
|
|
354
|
+
/** Pull request author */
|
|
355
|
+
user: GitHubUser;
|
|
356
|
+
/** Users assigned to this pull request */
|
|
357
|
+
assignees: GitHubUser[];
|
|
358
|
+
/** Requested reviewers */
|
|
359
|
+
requested_reviewers: GitHubUser[];
|
|
360
|
+
/** Labels applied to this pull request */
|
|
361
|
+
labels: GitHubLabel[];
|
|
362
|
+
/** Milestone, if any */
|
|
363
|
+
milestone: GitHubMilestone | null;
|
|
364
|
+
/** Source branch reference */
|
|
365
|
+
head: GitHubRef;
|
|
366
|
+
/** Target branch reference */
|
|
367
|
+
base: GitHubRef;
|
|
368
|
+
/** Whether this is a draft pull request */
|
|
369
|
+
draft: boolean;
|
|
370
|
+
/** URL to the pull request on GitHub */
|
|
371
|
+
html_url: string;
|
|
372
|
+
/** Number of commits in this pull request */
|
|
373
|
+
commits: number;
|
|
374
|
+
/** Number of line additions */
|
|
375
|
+
additions: number;
|
|
376
|
+
/** Number of line deletions */
|
|
377
|
+
deletions: number;
|
|
378
|
+
/** Number of changed files */
|
|
379
|
+
changed_files: number;
|
|
380
|
+
/** User who merged this pull request */
|
|
381
|
+
merged_by: GitHubUser | null;
|
|
382
|
+
/** Number of review comments */
|
|
383
|
+
review_comments: number;
|
|
384
|
+
/** Number of comments */
|
|
385
|
+
comments: number;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Query parameters for listing pull requests.
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://docs.github.com/en/rest/pulls/pulls#list-pull-requests}
|
|
391
|
+
*/
|
|
392
|
+
interface PullRequestsParams extends PaginationParams {
|
|
393
|
+
/** Filter by state */
|
|
394
|
+
state?: 'open' | 'closed' | 'all';
|
|
395
|
+
/** Filter by head branch (format: `user:branch-name`) */
|
|
396
|
+
head?: string;
|
|
397
|
+
/** Filter by base branch name */
|
|
398
|
+
base?: string;
|
|
399
|
+
/** Sort field */
|
|
400
|
+
sort?: 'created' | 'updated' | 'popularity' | 'long-running';
|
|
401
|
+
/** Sort direction */
|
|
402
|
+
direction?: 'asc' | 'desc';
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Represents a file changed in a commit.
|
|
407
|
+
*/
|
|
408
|
+
interface GitHubCommitFile {
|
|
409
|
+
/** File SHA */
|
|
410
|
+
sha: string;
|
|
411
|
+
/** File path */
|
|
412
|
+
filename: string;
|
|
413
|
+
/** Change status */
|
|
414
|
+
status: 'added' | 'removed' | 'modified' | 'renamed' | 'copied' | 'changed' | 'unchanged';
|
|
415
|
+
/** Number of line additions */
|
|
416
|
+
additions: number;
|
|
417
|
+
/** Number of line deletions */
|
|
418
|
+
deletions: number;
|
|
419
|
+
/** Total number of changes */
|
|
420
|
+
changes: number;
|
|
421
|
+
/** URL to the blob on GitHub */
|
|
422
|
+
blob_url: string;
|
|
423
|
+
/** URL to the raw file */
|
|
424
|
+
raw_url: string;
|
|
425
|
+
/** API URL to file contents */
|
|
426
|
+
contents_url: string;
|
|
427
|
+
/** The unified diff patch */
|
|
428
|
+
patch?: string;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Represents a GitHub commit.
|
|
432
|
+
*
|
|
433
|
+
* @see {@link https://docs.github.com/en/rest/commits/commits#get-a-commit}
|
|
434
|
+
*/
|
|
435
|
+
interface GitHubCommit {
|
|
436
|
+
/** Full commit SHA */
|
|
437
|
+
sha: string;
|
|
438
|
+
/** Git commit data */
|
|
439
|
+
commit: {
|
|
440
|
+
/** Commit message */
|
|
441
|
+
message: string;
|
|
442
|
+
/** Git author */
|
|
443
|
+
author: {
|
|
444
|
+
/** Author name */
|
|
445
|
+
name: string;
|
|
446
|
+
/** Author email */
|
|
447
|
+
email: string;
|
|
448
|
+
/** ISO 8601 timestamp of authoring */
|
|
449
|
+
date: string;
|
|
450
|
+
};
|
|
451
|
+
/** Git committer */
|
|
452
|
+
committer: {
|
|
453
|
+
/** Committer name */
|
|
454
|
+
name: string;
|
|
455
|
+
/** Committer email */
|
|
456
|
+
email: string;
|
|
457
|
+
/** ISO 8601 timestamp of committing */
|
|
458
|
+
date: string;
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
/** GitHub user associated with the author (null if no matching account) */
|
|
462
|
+
author: GitHubUser | null;
|
|
463
|
+
/** GitHub user associated with the committer (null if no matching account) */
|
|
464
|
+
committer: GitHubUser | null;
|
|
465
|
+
/** Parent commits */
|
|
466
|
+
parents: {
|
|
467
|
+
sha: string;
|
|
468
|
+
url: string;
|
|
469
|
+
}[];
|
|
470
|
+
/** URL to the commit on GitHub */
|
|
471
|
+
html_url: string;
|
|
472
|
+
/** Commit stats (only present on single commit GET) */
|
|
473
|
+
stats?: {
|
|
474
|
+
/** Number of line additions */
|
|
475
|
+
additions: number;
|
|
476
|
+
/** Number of line deletions */
|
|
477
|
+
deletions: number;
|
|
478
|
+
/** Total number of changes */
|
|
479
|
+
total: number;
|
|
480
|
+
};
|
|
481
|
+
/** Changed files (only present on single commit GET) */
|
|
482
|
+
files?: GitHubCommitFile[];
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Query parameters for listing repository commits.
|
|
486
|
+
*
|
|
487
|
+
* @see {@link https://docs.github.com/en/rest/commits/commits#list-commits}
|
|
488
|
+
*/
|
|
489
|
+
interface CommitsParams extends PaginationParams {
|
|
490
|
+
/** SHA or branch to start listing commits from */
|
|
491
|
+
sha?: string;
|
|
492
|
+
/** Only commits containing this file path */
|
|
493
|
+
path?: string;
|
|
494
|
+
/** Filter by author login or email */
|
|
495
|
+
author?: string;
|
|
496
|
+
/** Filter by committer login or email */
|
|
497
|
+
committer?: string;
|
|
498
|
+
/** Only commits after this ISO 8601 date */
|
|
499
|
+
since?: string;
|
|
500
|
+
/** Only commits before this ISO 8601 date */
|
|
501
|
+
until?: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Represents a GitHub branch.
|
|
506
|
+
*
|
|
507
|
+
* @see {@link https://docs.github.com/en/rest/branches/branches#get-a-branch}
|
|
508
|
+
*/
|
|
509
|
+
interface GitHubBranch {
|
|
510
|
+
/** Branch name (e.g., `'main'`, `'feature/my-feature'`) */
|
|
511
|
+
name: string;
|
|
512
|
+
/** Whether this branch is protected */
|
|
513
|
+
protected: boolean;
|
|
514
|
+
/** The latest commit on this branch */
|
|
515
|
+
commit: {
|
|
516
|
+
/** Commit SHA */
|
|
517
|
+
sha: string;
|
|
518
|
+
/** API URL to the commit */
|
|
519
|
+
url: string;
|
|
520
|
+
};
|
|
521
|
+
/** Branch protection details (only present when using authenticated requests) */
|
|
522
|
+
protection?: {
|
|
523
|
+
/** Whether protection is enabled */
|
|
524
|
+
enabled: boolean;
|
|
525
|
+
/** Required status checks */
|
|
526
|
+
required_status_checks: {
|
|
527
|
+
/** Enforcement level */
|
|
528
|
+
enforcement_level: string;
|
|
529
|
+
/** Required context names */
|
|
530
|
+
contexts: string[];
|
|
531
|
+
} | null;
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Query parameters for listing repository branches.
|
|
536
|
+
*
|
|
537
|
+
* @see {@link https://docs.github.com/en/rest/branches/branches#list-branches}
|
|
538
|
+
*/
|
|
539
|
+
interface BranchesParams extends PaginationParams {
|
|
540
|
+
/** When `true`, only protected branches are returned */
|
|
541
|
+
protected?: boolean;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Represents a GitHub lightweight tag (list endpoint).
|
|
546
|
+
*
|
|
547
|
+
* @see {@link https://docs.github.com/en/rest/repos/repos#list-repository-tags}
|
|
548
|
+
*/
|
|
549
|
+
interface GitHubTag {
|
|
550
|
+
/** Tag name (e.g., `'v1.0.0'`) */
|
|
551
|
+
name: string;
|
|
552
|
+
/** Commit this tag points to */
|
|
553
|
+
commit: {
|
|
554
|
+
/** Commit SHA */
|
|
555
|
+
sha: string;
|
|
556
|
+
/** API URL to the commit */
|
|
557
|
+
url: string;
|
|
558
|
+
};
|
|
559
|
+
/** URL to download the repository at this tag as a zip archive */
|
|
560
|
+
zipball_url: string;
|
|
561
|
+
/** URL to download the repository at this tag as a tar.gz archive */
|
|
562
|
+
tarball_url: string;
|
|
563
|
+
/** Node ID */
|
|
564
|
+
node_id: string;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Query parameters for listing repository tags.
|
|
568
|
+
*
|
|
569
|
+
* @see {@link https://docs.github.com/en/rest/repos/repos#list-repository-tags}
|
|
570
|
+
*/
|
|
571
|
+
interface TagsParams extends PaginationParams {
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Represents a release asset (a file attached to a GitHub release).
|
|
576
|
+
*/
|
|
577
|
+
interface GitHubReleaseAsset {
|
|
578
|
+
/** Unique numeric asset ID */
|
|
579
|
+
id: number;
|
|
580
|
+
/** Asset filename */
|
|
581
|
+
name: string;
|
|
582
|
+
/** Asset label */
|
|
583
|
+
label: string | null;
|
|
584
|
+
/** MIME content type */
|
|
585
|
+
content_type: string;
|
|
586
|
+
/** File size in bytes */
|
|
587
|
+
size: number;
|
|
588
|
+
/** Total number of downloads */
|
|
589
|
+
download_count: number;
|
|
590
|
+
/** ISO 8601 timestamp of creation */
|
|
591
|
+
created_at: string;
|
|
592
|
+
/** ISO 8601 timestamp of last update */
|
|
593
|
+
updated_at: string;
|
|
594
|
+
/** Browser download URL */
|
|
595
|
+
browser_download_url: string;
|
|
596
|
+
/** User who uploaded the asset */
|
|
597
|
+
uploader: GitHubUser;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Represents a GitHub release.
|
|
601
|
+
*
|
|
602
|
+
* @see {@link https://docs.github.com/en/rest/releases/releases#get-a-release}
|
|
603
|
+
*/
|
|
604
|
+
interface GitHubRelease {
|
|
605
|
+
/** Unique numeric release ID */
|
|
606
|
+
id: number;
|
|
607
|
+
/** The tag this release is associated with (e.g., `'v1.0.0'`) */
|
|
608
|
+
tag_name: string;
|
|
609
|
+
/** Release title */
|
|
610
|
+
name: string | null;
|
|
611
|
+
/** Release description / changelog */
|
|
612
|
+
body: string | null;
|
|
613
|
+
/** Whether this is a draft release */
|
|
614
|
+
draft: boolean;
|
|
615
|
+
/** Whether this is a pre-release */
|
|
616
|
+
prerelease: boolean;
|
|
617
|
+
/** ISO 8601 timestamp of creation */
|
|
618
|
+
created_at: string;
|
|
619
|
+
/** ISO 8601 timestamp of publishing (null for drafts) */
|
|
620
|
+
published_at: string | null;
|
|
621
|
+
/** User who created the release */
|
|
622
|
+
author: GitHubUser;
|
|
623
|
+
/** URL to the release on GitHub */
|
|
624
|
+
html_url: string;
|
|
625
|
+
/** URL to download the source as a tar archive */
|
|
626
|
+
tarball_url: string;
|
|
627
|
+
/** URL to download the source as a zip archive */
|
|
628
|
+
zipball_url: string;
|
|
629
|
+
/** Files attached to this release */
|
|
630
|
+
assets: GitHubReleaseAsset[];
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Query parameters for listing releases.
|
|
634
|
+
*
|
|
635
|
+
* @see {@link https://docs.github.com/en/rest/releases/releases#list-releases}
|
|
636
|
+
*/
|
|
637
|
+
interface ReleasesParams extends PaginationParams {
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Represents a GitHub repository webhook.
|
|
642
|
+
*
|
|
643
|
+
* @see {@link https://docs.github.com/en/rest/webhooks/repos#get-a-repository-webhook}
|
|
644
|
+
*/
|
|
645
|
+
interface GitHubWebhook {
|
|
646
|
+
/** Unique numeric webhook ID */
|
|
647
|
+
id: number;
|
|
648
|
+
/** Webhook name — always `'web'` for repository webhooks */
|
|
649
|
+
name: string;
|
|
650
|
+
/** Whether the webhook is active */
|
|
651
|
+
active: boolean;
|
|
652
|
+
/** List of events that trigger this webhook */
|
|
653
|
+
events: string[];
|
|
654
|
+
/** Webhook configuration */
|
|
655
|
+
config: {
|
|
656
|
+
/** Payload delivery URL */
|
|
657
|
+
url: string;
|
|
658
|
+
/** Payload format (`'json'` or `'form'`) */
|
|
659
|
+
content_type?: string;
|
|
660
|
+
/** Whether SSL verification is disabled (`'0'` = disabled, `'1'` = enabled) */
|
|
661
|
+
insecure_ssl?: string;
|
|
662
|
+
/** HMAC secret for payload verification */
|
|
663
|
+
secret?: string;
|
|
664
|
+
};
|
|
665
|
+
/** ISO 8601 timestamp of creation */
|
|
666
|
+
created_at: string;
|
|
667
|
+
/** ISO 8601 timestamp of last update */
|
|
668
|
+
updated_at: string;
|
|
669
|
+
/** URL to ping this webhook */
|
|
670
|
+
ping_url: string;
|
|
671
|
+
/** URL to list webhook deliveries */
|
|
672
|
+
deliveries_url: string;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Query parameters for listing webhooks.
|
|
676
|
+
*
|
|
677
|
+
* @see {@link https://docs.github.com/en/rest/webhooks/repos#list-repository-webhooks}
|
|
678
|
+
*/
|
|
679
|
+
interface WebhooksParams extends PaginationParams {
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Represents a file or directory entry in a GitHub repository.
|
|
684
|
+
*
|
|
685
|
+
* @see {@link https://docs.github.com/en/rest/repos/contents#get-repository-content}
|
|
686
|
+
*/
|
|
687
|
+
interface GitHubContent {
|
|
688
|
+
/** Entry type */
|
|
689
|
+
type: 'file' | 'dir' | 'symlink' | 'submodule';
|
|
690
|
+
/** Content encoding (only for files — always `'base64'`) */
|
|
691
|
+
encoding?: string;
|
|
692
|
+
/** File size in bytes */
|
|
693
|
+
size: number;
|
|
694
|
+
/** Entry name (filename or directory name) */
|
|
695
|
+
name: string;
|
|
696
|
+
/** Path from repository root */
|
|
697
|
+
path: string;
|
|
698
|
+
/**
|
|
699
|
+
* Base64-encoded file content.
|
|
700
|
+
* Only present for files when type is `'file'`.
|
|
701
|
+
* Decode with `Buffer.from(content, 'base64').toString()` or `atob(content)`.
|
|
702
|
+
*/
|
|
703
|
+
content?: string;
|
|
704
|
+
/** Blob SHA */
|
|
705
|
+
sha: string;
|
|
706
|
+
/** API URL to this content entry */
|
|
707
|
+
url: string;
|
|
708
|
+
/** URL to this file on GitHub */
|
|
709
|
+
html_url: string;
|
|
710
|
+
/** URL to the raw file content */
|
|
711
|
+
download_url: string | null;
|
|
712
|
+
/** HAL links */
|
|
713
|
+
_links: Record<string, string>;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Query parameters for fetching repository content.
|
|
717
|
+
*
|
|
718
|
+
* @see {@link https://docs.github.com/en/rest/repos/contents#get-repository-content}
|
|
719
|
+
*/
|
|
720
|
+
interface ContentParams {
|
|
721
|
+
/** Branch name, tag name, or commit SHA. Defaults to the repository's default branch. */
|
|
722
|
+
ref?: string;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Represents a pull request review submitted by a reviewer.
|
|
727
|
+
*
|
|
728
|
+
* @see {@link https://docs.github.com/en/rest/pulls/reviews#get-a-review-for-a-pull-request}
|
|
729
|
+
*/
|
|
730
|
+
interface GitHubReview {
|
|
731
|
+
/** Unique numeric review ID */
|
|
732
|
+
id: number;
|
|
733
|
+
/** User who submitted the review */
|
|
734
|
+
user: GitHubUser;
|
|
735
|
+
/** Review body text */
|
|
736
|
+
body: string;
|
|
737
|
+
/** Review state */
|
|
738
|
+
state: 'APPROVED' | 'CHANGES_REQUESTED' | 'COMMENTED' | 'DISMISSED' | 'PENDING';
|
|
739
|
+
/** URL to the review on GitHub */
|
|
740
|
+
html_url: string;
|
|
741
|
+
/** ISO 8601 timestamp of submission */
|
|
742
|
+
submitted_at: string;
|
|
743
|
+
/** The commit SHA this review was submitted against */
|
|
744
|
+
commit_id: string;
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Represents a review comment on a specific line of a pull request diff.
|
|
748
|
+
*
|
|
749
|
+
* @see {@link https://docs.github.com/en/rest/pulls/comments#get-a-review-comment-for-a-pull-request}
|
|
750
|
+
*/
|
|
751
|
+
interface GitHubReviewComment {
|
|
752
|
+
/** Unique numeric comment ID */
|
|
753
|
+
id: number;
|
|
754
|
+
/** User who wrote the comment */
|
|
755
|
+
user: GitHubUser;
|
|
756
|
+
/** Comment body text */
|
|
757
|
+
body: string;
|
|
758
|
+
/** ISO 8601 timestamp of creation */
|
|
759
|
+
created_at: string;
|
|
760
|
+
/** ISO 8601 timestamp of last update */
|
|
761
|
+
updated_at: string;
|
|
762
|
+
/** URL to the comment on GitHub */
|
|
763
|
+
html_url: string;
|
|
764
|
+
/** Path to the file this comment is on */
|
|
765
|
+
path: string;
|
|
766
|
+
/** Line position in the diff */
|
|
767
|
+
position: number | null;
|
|
768
|
+
/** The diff hunk this comment refers to */
|
|
769
|
+
diff_hunk: string;
|
|
770
|
+
/** The commit SHA this comment was placed on */
|
|
771
|
+
commit_id: string;
|
|
772
|
+
/** ID of the parent comment if this is a reply */
|
|
773
|
+
in_reply_to_id?: number;
|
|
774
|
+
/** ID of the review this comment belongs to */
|
|
775
|
+
pull_request_review_id: number;
|
|
776
|
+
/** Line number in the file */
|
|
777
|
+
line?: number;
|
|
778
|
+
/** Side of the diff (`LEFT` for old file, `RIGHT` for new file) */
|
|
779
|
+
side?: 'LEFT' | 'RIGHT';
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Query parameters for listing pull request reviews.
|
|
783
|
+
*
|
|
784
|
+
* @see {@link https://docs.github.com/en/rest/pulls/reviews#list-reviews-for-a-pull-request}
|
|
785
|
+
*/
|
|
786
|
+
interface ReviewsParams extends PaginationParams {
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Query parameters for listing review comments.
|
|
790
|
+
*
|
|
791
|
+
* @see {@link https://docs.github.com/en/rest/pulls/comments#list-review-comments-on-a-pull-request}
|
|
792
|
+
*/
|
|
793
|
+
interface ReviewCommentsParams extends PaginationParams {
|
|
794
|
+
/** Sort field */
|
|
795
|
+
sort?: 'created' | 'updated';
|
|
796
|
+
/** Sort direction */
|
|
797
|
+
direction?: 'asc' | 'desc';
|
|
798
|
+
/** Only return comments after this ISO 8601 date */
|
|
799
|
+
since?: string;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Represents a file changed in a pull request.
|
|
804
|
+
*
|
|
805
|
+
* @see {@link https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files}
|
|
806
|
+
*/
|
|
807
|
+
interface GitHubPullRequestFile {
|
|
808
|
+
/** File SHA */
|
|
809
|
+
sha: string;
|
|
810
|
+
/** File path */
|
|
811
|
+
filename: string;
|
|
812
|
+
/** Change status */
|
|
813
|
+
status: 'added' | 'removed' | 'modified' | 'renamed' | 'copied' | 'changed' | 'unchanged';
|
|
814
|
+
/** Number of line additions */
|
|
815
|
+
additions: number;
|
|
816
|
+
/** Number of line deletions */
|
|
817
|
+
deletions: number;
|
|
818
|
+
/** Total number of changes */
|
|
819
|
+
changes: number;
|
|
820
|
+
/** URL to the blob on GitHub */
|
|
821
|
+
blob_url: string;
|
|
822
|
+
/** URL to the raw file */
|
|
823
|
+
raw_url: string;
|
|
824
|
+
/** API URL to file contents */
|
|
825
|
+
contents_url: string;
|
|
826
|
+
/** The unified diff patch for this file */
|
|
827
|
+
patch?: string;
|
|
828
|
+
/** Previous file path (for renamed or copied files) */
|
|
829
|
+
previous_filename?: string;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Query parameters for listing pull request files.
|
|
833
|
+
*
|
|
834
|
+
* @see {@link https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files}
|
|
835
|
+
*/
|
|
836
|
+
interface PullRequestFilesParams extends PaginationParams {
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Represents a GitHub pull request resource with chainable async methods.
|
|
841
|
+
*
|
|
842
|
+
* Implements `PromiseLike<GitHubPullRequest>` so it can be awaited directly
|
|
843
|
+
* to fetch the pull request info, while also exposing sub-resource methods.
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```typescript
|
|
847
|
+
* // Await directly to get pull request info
|
|
848
|
+
* const pr = await gh.org('github').repo('linguist').pullRequest(42);
|
|
849
|
+
*
|
|
850
|
+
* // Get commits in this pull request
|
|
851
|
+
* const commits = await gh.org('github').repo('linguist').pullRequest(42).commits();
|
|
852
|
+
*
|
|
853
|
+
* // Get changed files
|
|
854
|
+
* const files = await gh.org('github').repo('linguist').pullRequest(42).files();
|
|
855
|
+
*
|
|
856
|
+
* // Get reviews
|
|
857
|
+
* const reviews = await gh.org('github').repo('linguist').pullRequest(42).reviews();
|
|
858
|
+
*
|
|
859
|
+
* // Get review comments (inline diff comments)
|
|
860
|
+
* const comments = await gh.org('github').repo('linguist').pullRequest(42).reviewComments();
|
|
861
|
+
* ```
|
|
862
|
+
*/
|
|
863
|
+
declare class PullRequestResource implements PromiseLike<GitHubPullRequest> {
|
|
864
|
+
private readonly request;
|
|
865
|
+
private readonly requestList;
|
|
866
|
+
private readonly basePath;
|
|
867
|
+
/** @internal */
|
|
868
|
+
constructor(request: RequestFn, requestList: RequestListFn, owner: string, repo: string, pullNumber: number);
|
|
869
|
+
/**
|
|
870
|
+
* Allows the resource to be awaited directly, resolving with the pull request info.
|
|
871
|
+
* Delegates to {@link PullRequestResource.get}.
|
|
872
|
+
*/
|
|
873
|
+
then<TResult1 = GitHubPullRequest, TResult2 = never>(onfulfilled?: ((value: GitHubPullRequest) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
874
|
+
/**
|
|
875
|
+
* Fetches the pull request details.
|
|
876
|
+
*
|
|
877
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}`
|
|
878
|
+
*
|
|
879
|
+
* @returns The pull request object
|
|
880
|
+
*/
|
|
881
|
+
get(): Promise<GitHubPullRequest>;
|
|
882
|
+
/**
|
|
883
|
+
* Fetches the commits included in this pull request.
|
|
884
|
+
*
|
|
885
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}/commits`
|
|
886
|
+
*
|
|
887
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
888
|
+
* @returns A paged response of commits
|
|
889
|
+
*/
|
|
890
|
+
commits(params?: PaginationParams): Promise<GitHubPagedResponse<GitHubCommit>>;
|
|
891
|
+
/**
|
|
892
|
+
* Fetches the files changed by this pull request.
|
|
893
|
+
*
|
|
894
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}/files`
|
|
895
|
+
*
|
|
896
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
897
|
+
* @returns A paged response of changed files
|
|
898
|
+
*/
|
|
899
|
+
files(params?: PullRequestFilesParams): Promise<GitHubPagedResponse<GitHubPullRequestFile>>;
|
|
900
|
+
/**
|
|
901
|
+
* Fetches the reviews submitted on this pull request.
|
|
902
|
+
*
|
|
903
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews`
|
|
904
|
+
*
|
|
905
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
906
|
+
* @returns A paged response of reviews
|
|
907
|
+
*/
|
|
908
|
+
reviews(params?: ReviewsParams): Promise<GitHubPagedResponse<GitHubReview>>;
|
|
909
|
+
/**
|
|
910
|
+
* Fetches the inline review comments on this pull request's diff.
|
|
911
|
+
*
|
|
912
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}/comments`
|
|
913
|
+
*
|
|
914
|
+
* @param params - Optional filters: `sort`, `direction`, `since`, `per_page`, `page`
|
|
915
|
+
* @returns A paged response of review comments
|
|
916
|
+
*/
|
|
917
|
+
reviewComments(params?: ReviewCommentsParams): Promise<GitHubPagedResponse<GitHubReviewComment>>;
|
|
918
|
+
/**
|
|
919
|
+
* Checks whether the pull request has been merged.
|
|
920
|
+
*
|
|
921
|
+
* `GET /repos/{owner}/{repo}/pulls/{pull_number}/merge`
|
|
922
|
+
*
|
|
923
|
+
* @returns `true` if merged (HTTP 204), `false` if not merged (HTTP 404)
|
|
924
|
+
*/
|
|
925
|
+
isMerged(): Promise<boolean>;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Represents an individual commit status set by a CI/CD system or external service.
|
|
930
|
+
*
|
|
931
|
+
* @see {@link https://docs.github.com/en/rest/commits/statuses#list-commit-statuses-for-a-reference}
|
|
932
|
+
*/
|
|
933
|
+
interface GitHubCommitStatus {
|
|
934
|
+
/** Unique numeric status ID */
|
|
935
|
+
id: number;
|
|
936
|
+
/** Status state */
|
|
937
|
+
state: 'error' | 'failure' | 'pending' | 'success';
|
|
938
|
+
/** Human-readable description */
|
|
939
|
+
description: string | null;
|
|
940
|
+
/** URL to the full details of the status */
|
|
941
|
+
target_url: string | null;
|
|
942
|
+
/** Context label identifying the source (e.g., `'ci/circleci'`) */
|
|
943
|
+
context: string;
|
|
944
|
+
/** ISO 8601 timestamp of creation */
|
|
945
|
+
created_at: string;
|
|
946
|
+
/** ISO 8601 timestamp of last update */
|
|
947
|
+
updated_at: string;
|
|
948
|
+
/** User who created the status */
|
|
949
|
+
creator: GitHubUser;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Represents the combined commit status — an aggregation of all statuses for a ref.
|
|
953
|
+
*
|
|
954
|
+
* @see {@link https://docs.github.com/en/rest/commits/statuses#get-the-combined-status-for-a-specific-reference}
|
|
955
|
+
*/
|
|
956
|
+
interface GitHubCombinedStatus {
|
|
957
|
+
/** Overall combined state */
|
|
958
|
+
state: 'error' | 'failure' | 'pending' | 'success';
|
|
959
|
+
/** Individual statuses that make up the combined status */
|
|
960
|
+
statuses: GitHubCommitStatus[];
|
|
961
|
+
/** The commit SHA this status refers to */
|
|
962
|
+
sha: string;
|
|
963
|
+
/** Total number of statuses */
|
|
964
|
+
total_count: number;
|
|
965
|
+
/** The repository this status belongs to */
|
|
966
|
+
repository: GitHubRepository;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Represents a GitHub Actions check run.
|
|
970
|
+
*
|
|
971
|
+
* @see {@link https://docs.github.com/en/rest/checks/runs#get-a-check-run}
|
|
972
|
+
*/
|
|
973
|
+
interface GitHubCheckRun {
|
|
974
|
+
/** Unique numeric check run ID */
|
|
975
|
+
id: number;
|
|
976
|
+
/** Check run name */
|
|
977
|
+
name: string;
|
|
978
|
+
/** Current status */
|
|
979
|
+
status: 'queued' | 'in_progress' | 'completed';
|
|
980
|
+
/** Conclusion (only set when `status` is `'completed'`) */
|
|
981
|
+
conclusion: 'action_required' | 'cancelled' | 'failure' | 'neutral' | 'success' | 'skipped' | 'stale' | 'timed_out' | null;
|
|
982
|
+
/** ISO 8601 timestamp of when the check started */
|
|
983
|
+
started_at: string | null;
|
|
984
|
+
/** ISO 8601 timestamp of when the check completed */
|
|
985
|
+
completed_at: string | null;
|
|
986
|
+
/** URL to the check run details on GitHub */
|
|
987
|
+
html_url: string;
|
|
988
|
+
/** The commit SHA this check run is for */
|
|
989
|
+
head_sha: string;
|
|
990
|
+
/** GitHub App that created the check run */
|
|
991
|
+
app: {
|
|
992
|
+
id: number;
|
|
993
|
+
name: string;
|
|
994
|
+
slug: string;
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Query parameters for listing commit statuses.
|
|
999
|
+
*
|
|
1000
|
+
* @see {@link https://docs.github.com/en/rest/commits/statuses#list-commit-statuses-for-a-reference}
|
|
1001
|
+
*/
|
|
1002
|
+
interface CommitStatusesParams extends PaginationParams {
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Query parameters for listing check runs.
|
|
1006
|
+
*
|
|
1007
|
+
* @see {@link https://docs.github.com/en/rest/checks/runs#list-check-runs-for-a-git-reference}
|
|
1008
|
+
*/
|
|
1009
|
+
interface CheckRunsParams extends PaginationParams {
|
|
1010
|
+
/** Filter by check name */
|
|
1011
|
+
check_name?: string;
|
|
1012
|
+
/** Filter by status */
|
|
1013
|
+
status?: 'queued' | 'in_progress' | 'completed';
|
|
1014
|
+
/** Filter by app slug */
|
|
1015
|
+
app_id?: number;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Represents a GitHub commit resource with chainable async methods.
|
|
1020
|
+
*
|
|
1021
|
+
* Implements `PromiseLike<GitHubCommit>` so it can be awaited directly
|
|
1022
|
+
* to fetch the commit info, while also exposing sub-resource methods.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```typescript
|
|
1026
|
+
* // Await directly to get commit info (includes stats and files)
|
|
1027
|
+
* const commit = await gh.org('github').repo('linguist').commit('abc123');
|
|
1028
|
+
*
|
|
1029
|
+
* // Get CI/CD statuses for this commit
|
|
1030
|
+
* const statuses = await gh.org('github').repo('linguist').commit('abc123').statuses();
|
|
1031
|
+
*
|
|
1032
|
+
* // Get the combined (aggregated) status
|
|
1033
|
+
* const combined = await gh.org('github').repo('linguist').commit('abc123').combinedStatus();
|
|
1034
|
+
*
|
|
1035
|
+
* // Get GitHub Actions check runs
|
|
1036
|
+
* const checks = await gh.org('github').repo('linguist').commit('abc123').checkRuns();
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1039
|
+
declare class CommitResource implements PromiseLike<GitHubCommit> {
|
|
1040
|
+
private readonly request;
|
|
1041
|
+
private readonly requestList;
|
|
1042
|
+
private readonly basePath;
|
|
1043
|
+
private readonly ref;
|
|
1044
|
+
/** @internal */
|
|
1045
|
+
constructor(request: RequestFn, requestList: RequestListFn, owner: string, repo: string, ref: string);
|
|
1046
|
+
/**
|
|
1047
|
+
* Allows the resource to be awaited directly, resolving with the commit info.
|
|
1048
|
+
* Delegates to {@link CommitResource.get}.
|
|
1049
|
+
*/
|
|
1050
|
+
then<TResult1 = GitHubCommit, TResult2 = never>(onfulfilled?: ((value: GitHubCommit) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Fetches the commit details, including stats and changed files.
|
|
1053
|
+
*
|
|
1054
|
+
* `GET /repos/{owner}/{repo}/commits/{ref}`
|
|
1055
|
+
*
|
|
1056
|
+
* @returns The commit object with stats and files
|
|
1057
|
+
*/
|
|
1058
|
+
get(): Promise<GitHubCommit>;
|
|
1059
|
+
/**
|
|
1060
|
+
* Fetches the individual commit statuses (from CI/CD systems via the Statuses API).
|
|
1061
|
+
*
|
|
1062
|
+
* `GET /repos/{owner}/{repo}/statuses/{sha}`
|
|
1063
|
+
*
|
|
1064
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
1065
|
+
* @returns A paged response of commit statuses
|
|
1066
|
+
*/
|
|
1067
|
+
statuses(params?: CommitStatusesParams): Promise<GitHubPagedResponse<GitHubCommitStatus>>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Fetches the combined commit status — an aggregation of all statuses for this ref.
|
|
1070
|
+
*
|
|
1071
|
+
* `GET /repos/{owner}/{repo}/commits/{ref}/status`
|
|
1072
|
+
*
|
|
1073
|
+
* @returns The combined status object
|
|
1074
|
+
*/
|
|
1075
|
+
combinedStatus(): Promise<GitHubCombinedStatus>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Fetches GitHub Actions check runs for this commit.
|
|
1078
|
+
*
|
|
1079
|
+
* `GET /repos/{owner}/{repo}/commits/{ref}/check-runs`
|
|
1080
|
+
*
|
|
1081
|
+
* @param params - Optional filters: `check_name`, `status`, `app_id`, `per_page`, `page`
|
|
1082
|
+
* @returns A paged response of check runs
|
|
1083
|
+
*/
|
|
1084
|
+
checkRuns(params?: CheckRunsParams): Promise<GitHubPagedResponse<GitHubCheckRun>>;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* Represents a GitHub repository resource with chainable async methods.
|
|
1089
|
+
*
|
|
1090
|
+
* Implements `PromiseLike<GitHubRepository>` so it can be awaited directly
|
|
1091
|
+
* to fetch repository info, while also exposing sub-resource methods.
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```typescript
|
|
1095
|
+
* // Await directly to get repository info
|
|
1096
|
+
* const repo = await gh.org('github').repo('linguist');
|
|
1097
|
+
*
|
|
1098
|
+
* // Get pull requests
|
|
1099
|
+
* const prs = await gh.org('github').repo('linguist').pullRequests({ state: 'open' });
|
|
1100
|
+
*
|
|
1101
|
+
* // Navigate into a specific pull request
|
|
1102
|
+
* const files = await gh.org('github').repo('linguist').pullRequest(42).files();
|
|
1103
|
+
*
|
|
1104
|
+
* // Get commits
|
|
1105
|
+
* const commits = await gh.org('github').repo('linguist').commits({ per_page: 10 });
|
|
1106
|
+
*
|
|
1107
|
+
* // Get raw file content
|
|
1108
|
+
* const content = await gh.org('github').repo('linguist').raw('README.md');
|
|
1109
|
+
* ```
|
|
1110
|
+
*/
|
|
1111
|
+
declare class RepositoryResource implements PromiseLike<GitHubRepository> {
|
|
1112
|
+
private readonly request;
|
|
1113
|
+
private readonly requestList;
|
|
1114
|
+
private readonly requestText;
|
|
1115
|
+
private readonly owner;
|
|
1116
|
+
private readonly repo;
|
|
1117
|
+
private readonly basePath;
|
|
1118
|
+
/** @internal */
|
|
1119
|
+
constructor(request: RequestFn, requestList: RequestListFn, requestText: RequestTextFn, owner: string, repo: string);
|
|
1120
|
+
/**
|
|
1121
|
+
* Allows the resource to be awaited directly, resolving with the repository info.
|
|
1122
|
+
* Delegates to {@link RepositoryResource.get}.
|
|
1123
|
+
*/
|
|
1124
|
+
then<TResult1 = GitHubRepository, TResult2 = never>(onfulfilled?: ((value: GitHubRepository) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Fetches the repository details.
|
|
1127
|
+
*
|
|
1128
|
+
* `GET /repos/{owner}/{repo}`
|
|
1129
|
+
*
|
|
1130
|
+
* @returns The repository object
|
|
1131
|
+
*/
|
|
1132
|
+
get(): Promise<GitHubRepository>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Fetches pull requests for this repository.
|
|
1135
|
+
*
|
|
1136
|
+
* `GET /repos/{owner}/{repo}/pulls`
|
|
1137
|
+
*
|
|
1138
|
+
* @param params - Optional filters: `state`, `head`, `base`, `sort`, `direction`, `per_page`, `page`
|
|
1139
|
+
* @returns A paged response of pull requests
|
|
1140
|
+
*/
|
|
1141
|
+
pullRequests(params?: PullRequestsParams): Promise<GitHubPagedResponse<GitHubPullRequest>>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Returns a {@link PullRequestResource} for a given pull request number.
|
|
1144
|
+
*
|
|
1145
|
+
* The returned resource can be awaited directly to fetch pull request info,
|
|
1146
|
+
* or chained to access nested resources.
|
|
1147
|
+
*
|
|
1148
|
+
* @param pullNumber - The pull request number (not the ID)
|
|
1149
|
+
* @returns A chainable pull request resource
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* ```typescript
|
|
1153
|
+
* const pr = await gh.org('github').repo('linguist').pullRequest(42);
|
|
1154
|
+
* const files = await gh.org('github').repo('linguist').pullRequest(42).files();
|
|
1155
|
+
* const reviews = await gh.org('github').repo('linguist').pullRequest(42).reviews();
|
|
1156
|
+
* ```
|
|
1157
|
+
*/
|
|
1158
|
+
pullRequest(pullNumber: number): PullRequestResource;
|
|
1159
|
+
/**
|
|
1160
|
+
* Fetches commits for this repository.
|
|
1161
|
+
*
|
|
1162
|
+
* `GET /repos/{owner}/{repo}/commits`
|
|
1163
|
+
*
|
|
1164
|
+
* @param params - Optional filters: `sha`, `path`, `author`, `since`, `until`, `per_page`, `page`
|
|
1165
|
+
* @returns A paged response of commits
|
|
1166
|
+
*/
|
|
1167
|
+
commits(params?: CommitsParams): Promise<GitHubPagedResponse<GitHubCommit>>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Returns a {@link CommitResource} for a given commit ref (SHA, branch, or tag).
|
|
1170
|
+
*
|
|
1171
|
+
* The returned resource can be awaited directly to fetch commit info,
|
|
1172
|
+
* or chained to access nested resources.
|
|
1173
|
+
*
|
|
1174
|
+
* @param ref - Commit SHA, branch name, or tag name
|
|
1175
|
+
* @returns A chainable commit resource
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```typescript
|
|
1179
|
+
* const commit = await gh.org('github').repo('linguist').commit('abc123');
|
|
1180
|
+
* const statuses = await gh.org('github').repo('linguist').commit('abc123').statuses();
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
commit(ref: string): CommitResource;
|
|
1184
|
+
/**
|
|
1185
|
+
* Fetches branches for this repository.
|
|
1186
|
+
*
|
|
1187
|
+
* `GET /repos/{owner}/{repo}/branches`
|
|
1188
|
+
*
|
|
1189
|
+
* @param params - Optional filters: `protected`, `per_page`, `page`
|
|
1190
|
+
* @returns A paged response of branches
|
|
1191
|
+
*/
|
|
1192
|
+
branches(params?: BranchesParams): Promise<GitHubPagedResponse<GitHubBranch>>;
|
|
1193
|
+
/**
|
|
1194
|
+
* Fetches a specific branch by name.
|
|
1195
|
+
*
|
|
1196
|
+
* `GET /repos/{owner}/{repo}/branches/{branch}`
|
|
1197
|
+
*
|
|
1198
|
+
* @param name - The branch name (e.g., `'main'`)
|
|
1199
|
+
* @returns The branch object
|
|
1200
|
+
*/
|
|
1201
|
+
branch(name: string): Promise<GitHubBranch>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Fetches tags for this repository.
|
|
1204
|
+
*
|
|
1205
|
+
* `GET /repos/{owner}/{repo}/tags`
|
|
1206
|
+
*
|
|
1207
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
1208
|
+
* @returns A paged response of tags
|
|
1209
|
+
*/
|
|
1210
|
+
tags(params?: TagsParams): Promise<GitHubPagedResponse<GitHubTag>>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Fetches releases for this repository.
|
|
1213
|
+
*
|
|
1214
|
+
* `GET /repos/{owner}/{repo}/releases`
|
|
1215
|
+
*
|
|
1216
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
1217
|
+
* @returns A paged response of releases
|
|
1218
|
+
*/
|
|
1219
|
+
releases(params?: ReleasesParams): Promise<GitHubPagedResponse<GitHubRelease>>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Fetches the latest published release for this repository.
|
|
1222
|
+
*
|
|
1223
|
+
* `GET /repos/{owner}/{repo}/releases/latest`
|
|
1224
|
+
*
|
|
1225
|
+
* @returns The latest release object
|
|
1226
|
+
*/
|
|
1227
|
+
latestRelease(): Promise<GitHubRelease>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Fetches the forks of this repository.
|
|
1230
|
+
*
|
|
1231
|
+
* `GET /repos/{owner}/{repo}/forks`
|
|
1232
|
+
*
|
|
1233
|
+
* @param params - Optional filters: `sort`, `per_page`, `page`
|
|
1234
|
+
* @returns A paged response of forked repositories
|
|
1235
|
+
*/
|
|
1236
|
+
forks(params?: ForksParams): Promise<GitHubPagedResponse<GitHubRepository>>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Fetches webhooks configured on this repository.
|
|
1239
|
+
*
|
|
1240
|
+
* `GET /repos/{owner}/{repo}/hooks`
|
|
1241
|
+
*
|
|
1242
|
+
* @param params - Optional pagination: `per_page`, `page`
|
|
1243
|
+
* @returns A paged response of webhooks
|
|
1244
|
+
*/
|
|
1245
|
+
webhooks(params?: WebhooksParams): Promise<GitHubPagedResponse<GitHubWebhook>>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Fetches the contents of a file or directory in this repository.
|
|
1248
|
+
*
|
|
1249
|
+
* `GET /repos/{owner}/{repo}/contents/{path}`
|
|
1250
|
+
*
|
|
1251
|
+
* Returns a single {@link GitHubContent} for files, or an array for directories.
|
|
1252
|
+
*
|
|
1253
|
+
* @param path - Path to the file or directory (e.g., `'src/index.ts'` or `'src'`). Omit for root.
|
|
1254
|
+
* @param params - Optional: `ref` (branch, tag, or commit SHA)
|
|
1255
|
+
* @returns File content object or array of directory entries
|
|
1256
|
+
*/
|
|
1257
|
+
contents(path?: string, params?: ContentParams): Promise<GitHubContent | GitHubContent[]>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Fetches the raw text content of a file in this repository.
|
|
1260
|
+
*
|
|
1261
|
+
* Uses `Accept: application/vnd.github.raw+json` to retrieve the file directly
|
|
1262
|
+
* without base64 encoding.
|
|
1263
|
+
*
|
|
1264
|
+
* `GET /repos/{owner}/{repo}/contents/{filePath}`
|
|
1265
|
+
*
|
|
1266
|
+
* @param filePath - Path to the file (e.g., `'src/index.ts'`)
|
|
1267
|
+
* @param params - Optional: `ref` (branch, tag, or commit SHA)
|
|
1268
|
+
* @returns The raw file content as a string
|
|
1269
|
+
*/
|
|
1270
|
+
raw(filePath: string, params?: ContentParams): Promise<string>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Fetches the repository topics.
|
|
1273
|
+
*
|
|
1274
|
+
* `GET /repos/{owner}/{repo}/topics`
|
|
1275
|
+
*
|
|
1276
|
+
* @returns An array of topic strings
|
|
1277
|
+
*/
|
|
1278
|
+
topics(): Promise<string[]>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Fetches contributors to this repository.
|
|
1281
|
+
*
|
|
1282
|
+
* `GET /repos/{owner}/{repo}/contributors`
|
|
1283
|
+
*
|
|
1284
|
+
* @param params - Optional filters: `anon` (include anonymous contributors), `per_page`, `page`
|
|
1285
|
+
* @returns A paged response of contributors
|
|
1286
|
+
*/
|
|
1287
|
+
contributors(params?: PaginationParams & {
|
|
1288
|
+
anon?: boolean;
|
|
1289
|
+
}): Promise<GitHubPagedResponse<{
|
|
1290
|
+
login?: string;
|
|
1291
|
+
id?: number;
|
|
1292
|
+
contributions: number;
|
|
1293
|
+
avatar_url?: string;
|
|
1294
|
+
html_url?: string;
|
|
1295
|
+
}>>;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/** @internal */
|
|
1299
|
+
type RequestFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<T>;
|
|
1300
|
+
/** @internal */
|
|
1301
|
+
type RequestListFn = <T>(path: string, params?: Record<string, string | number | boolean>) => Promise<GitHubPagedResponse<T>>;
|
|
1302
|
+
/** @internal */
|
|
1303
|
+
type RequestTextFn = (path: string, params?: Record<string, string | number | boolean>) => Promise<string>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Represents a GitHub organization resource with chainable async methods.
|
|
1306
|
+
*
|
|
1307
|
+
* Implements `PromiseLike<GitHubOrganization>` so it can be awaited directly
|
|
1308
|
+
* to fetch the organization info, while also exposing sub-resource methods.
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* // Await directly to get organization info
|
|
1313
|
+
* const org = await gh.org('github');
|
|
1314
|
+
*
|
|
1315
|
+
* // Get repositories
|
|
1316
|
+
* const repos = await gh.org('github').repos({ type: 'public', per_page: 50 });
|
|
1317
|
+
*
|
|
1318
|
+
* // Navigate into a specific repository
|
|
1319
|
+
* const prs = await gh.org('github').repo('linguist').pullRequests({ state: 'open' });
|
|
1320
|
+
*
|
|
1321
|
+
* // Get members
|
|
1322
|
+
* const members = await gh.org('github').members({ role: 'admin' });
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
declare class OrganizationResource implements PromiseLike<GitHubOrganization> {
|
|
1326
|
+
private readonly request;
|
|
1327
|
+
private readonly requestList;
|
|
1328
|
+
private readonly requestText;
|
|
1329
|
+
private readonly org;
|
|
1330
|
+
/** @internal */
|
|
1331
|
+
constructor(request: RequestFn, requestList: RequestListFn, requestText: RequestTextFn, org: string);
|
|
1332
|
+
/**
|
|
1333
|
+
* Allows the resource to be awaited directly, resolving with the organization info.
|
|
1334
|
+
* Delegates to {@link OrganizationResource.get}.
|
|
1335
|
+
*/
|
|
1336
|
+
then<TResult1 = GitHubOrganization, TResult2 = never>(onfulfilled?: ((value: GitHubOrganization) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Fetches the organization details.
|
|
1339
|
+
*
|
|
1340
|
+
* `GET /orgs/{org}`
|
|
1341
|
+
*
|
|
1342
|
+
* @returns The organization object
|
|
1343
|
+
*/
|
|
1344
|
+
get(): Promise<GitHubOrganization>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Fetches repositories belonging to this organization.
|
|
1347
|
+
*
|
|
1348
|
+
* `GET /orgs/{org}/repos`
|
|
1349
|
+
*
|
|
1350
|
+
* @param params - Optional filters: `type`, `sort`, `direction`, `per_page`, `page`
|
|
1351
|
+
* @returns A paged response of repositories
|
|
1352
|
+
*/
|
|
1353
|
+
repos(params?: ReposParams): Promise<GitHubPagedResponse<GitHubRepository>>;
|
|
1354
|
+
/**
|
|
1355
|
+
* Returns a {@link RepositoryResource} for a given repository name within this organization.
|
|
1356
|
+
*
|
|
1357
|
+
* The returned resource can be awaited directly to fetch repository info,
|
|
1358
|
+
* or chained to access nested resources.
|
|
1359
|
+
*
|
|
1360
|
+
* @param name - The repository name (e.g., `'linguist'`)
|
|
1361
|
+
* @returns A chainable repository resource
|
|
1362
|
+
*
|
|
1363
|
+
* @example
|
|
1364
|
+
* ```typescript
|
|
1365
|
+
* const repo = await gh.org('github').repo('linguist');
|
|
1366
|
+
* const prs = await gh.org('github').repo('linguist').pullRequests({ state: 'open' });
|
|
1367
|
+
* const commits = await gh.org('github').repo('linguist').commits({ per_page: 10 });
|
|
1368
|
+
* ```
|
|
1369
|
+
*/
|
|
1370
|
+
repo(name: string): RepositoryResource;
|
|
1371
|
+
/**
|
|
1372
|
+
* Fetches members of this organization.
|
|
1373
|
+
*
|
|
1374
|
+
* `GET /orgs/{org}/members`
|
|
1375
|
+
*
|
|
1376
|
+
* @param params - Optional filters: `role`, `filter`, `per_page`, `page`
|
|
1377
|
+
* @returns A paged response of users
|
|
1378
|
+
*/
|
|
1379
|
+
members(params?: OrgMembersParams): Promise<GitHubPagedResponse<GitHubUser>>;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Represents a GitHub user resource with chainable async methods.
|
|
1384
|
+
*
|
|
1385
|
+
* Implements `PromiseLike<GitHubUser>` so it can be awaited directly
|
|
1386
|
+
* to fetch user info, while also exposing sub-resource methods.
|
|
1387
|
+
*
|
|
1388
|
+
* @example
|
|
1389
|
+
* ```typescript
|
|
1390
|
+
* // Await directly to get user info
|
|
1391
|
+
* const user = await gh.user('octocat');
|
|
1392
|
+
*
|
|
1393
|
+
* // Get the user's public repositories
|
|
1394
|
+
* const repos = await gh.user('octocat').repos({ sort: 'updated' });
|
|
1395
|
+
*
|
|
1396
|
+
* // Navigate into a specific repository
|
|
1397
|
+
* const prs = await gh.user('octocat').repo('Hello-World').pullRequests();
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
declare class UserResource implements PromiseLike<GitHubUser> {
|
|
1401
|
+
private readonly request;
|
|
1402
|
+
private readonly requestList;
|
|
1403
|
+
private readonly requestText;
|
|
1404
|
+
private readonly login;
|
|
1405
|
+
private readonly basePath;
|
|
1406
|
+
/** @internal */
|
|
1407
|
+
constructor(request: RequestFn, requestList: RequestListFn, requestText: RequestTextFn, login: string);
|
|
1408
|
+
/**
|
|
1409
|
+
* Allows the resource to be awaited directly, resolving with the user info.
|
|
1410
|
+
* Delegates to {@link UserResource.get}.
|
|
1411
|
+
*/
|
|
1412
|
+
then<TResult1 = GitHubUser, TResult2 = never>(onfulfilled?: ((value: GitHubUser) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1413
|
+
/**
|
|
1414
|
+
* Fetches the user details.
|
|
1415
|
+
*
|
|
1416
|
+
* `GET /users/{username}`
|
|
1417
|
+
*
|
|
1418
|
+
* @returns The user object
|
|
1419
|
+
*/
|
|
1420
|
+
get(): Promise<GitHubUser>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Fetches public repositories for this user.
|
|
1423
|
+
*
|
|
1424
|
+
* `GET /users/{username}/repos`
|
|
1425
|
+
*
|
|
1426
|
+
* @param params - Optional filters: `type`, `sort`, `direction`, `per_page`, `page`
|
|
1427
|
+
* @returns A paged response of repositories
|
|
1428
|
+
*/
|
|
1429
|
+
repos(params?: ReposParams): Promise<GitHubPagedResponse<GitHubRepository>>;
|
|
1430
|
+
/**
|
|
1431
|
+
* Returns a {@link RepositoryResource} for a given repository under this user,
|
|
1432
|
+
* providing access to all repository sub-resources.
|
|
1433
|
+
*
|
|
1434
|
+
* @param name - The repository name
|
|
1435
|
+
* @returns A chainable repository resource
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
* ```typescript
|
|
1439
|
+
* const repo = await gh.user('octocat').repo('Hello-World');
|
|
1440
|
+
* const content = await gh.user('octocat').repo('Hello-World').raw('README.md');
|
|
1441
|
+
* ```
|
|
1442
|
+
*/
|
|
1443
|
+
repo(name: string): RepositoryResource;
|
|
1444
|
+
/**
|
|
1445
|
+
* Fetches the users this user is following.
|
|
1446
|
+
*
|
|
1447
|
+
* `GET /users/{username}/following`
|
|
1448
|
+
*
|
|
1449
|
+
* @returns A paged response of users
|
|
1450
|
+
*/
|
|
1451
|
+
following(params?: {
|
|
1452
|
+
per_page?: number;
|
|
1453
|
+
page?: number;
|
|
1454
|
+
}): Promise<GitHubPagedResponse<GitHubUser>>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Fetches the users following this user.
|
|
1457
|
+
*
|
|
1458
|
+
* `GET /users/{username}/followers`
|
|
1459
|
+
*
|
|
1460
|
+
* @returns A paged response of users
|
|
1461
|
+
*/
|
|
1462
|
+
followers(params?: {
|
|
1463
|
+
per_page?: number;
|
|
1464
|
+
page?: number;
|
|
1465
|
+
}): Promise<GitHubPagedResponse<GitHubUser>>;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* Payload emitted on every HTTP request made by {@link GitHubClient}.
|
|
1470
|
+
*/
|
|
1471
|
+
interface RequestEvent {
|
|
1472
|
+
/** Full URL that was requested */
|
|
1473
|
+
url: string;
|
|
1474
|
+
/** HTTP method used */
|
|
1475
|
+
method: 'GET';
|
|
1476
|
+
/** Timestamp when the request started */
|
|
1477
|
+
startedAt: Date;
|
|
1478
|
+
/** Timestamp when the request finished (success or error) */
|
|
1479
|
+
finishedAt: Date;
|
|
1480
|
+
/** Total duration in milliseconds */
|
|
1481
|
+
durationMs: number;
|
|
1482
|
+
/** HTTP status code returned by the server, if a response was received */
|
|
1483
|
+
statusCode?: number;
|
|
1484
|
+
/** Error thrown, if the request failed */
|
|
1485
|
+
error?: Error;
|
|
1486
|
+
}
|
|
1487
|
+
/** Map of supported client events to their callback signatures */
|
|
1488
|
+
interface GitHubClientEvents {
|
|
1489
|
+
request: (event: RequestEvent) => void;
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Constructor options for {@link GitHubClient}.
|
|
1493
|
+
*/
|
|
1494
|
+
interface GitHubClientOptions {
|
|
1495
|
+
/** A GitHub personal access token (`ghp_...`), OAuth token, or GitHub App installation token */
|
|
1496
|
+
token: string;
|
|
1497
|
+
/**
|
|
1498
|
+
* The base URL of the GitHub API.
|
|
1499
|
+
* Defaults to `'https://api.github.com'`.
|
|
1500
|
+
* Override for GitHub Enterprise Server (e.g., `'https://github.mycompany.com/api/v3'`).
|
|
1501
|
+
*/
|
|
1502
|
+
apiUrl?: string;
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Main entry point for the GitHub REST API client.
|
|
1506
|
+
*
|
|
1507
|
+
* @example
|
|
1508
|
+
* ```typescript
|
|
1509
|
+
* const gh = new GitHubClient({ token: 'ghp_myPersonalAccessToken' });
|
|
1510
|
+
*
|
|
1511
|
+
* const me = await gh.currentUser();
|
|
1512
|
+
* const user = await gh.user('octocat');
|
|
1513
|
+
* const repos = await gh.user('octocat').repos({ sort: 'updated' });
|
|
1514
|
+
* const org = await gh.org('github');
|
|
1515
|
+
* const repo = await gh.repo('octocat', 'Hello-World');
|
|
1516
|
+
* const prs = await gh.repo('octocat', 'Hello-World').pullRequests({ state: 'open' });
|
|
1517
|
+
* const commits = await gh.repo('octocat', 'Hello-World').commits({ per_page: 10 });
|
|
1518
|
+
* const results = await gh.searchRepos({ q: 'language:typescript stars:>1000' });
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
declare class GitHubClient {
|
|
1522
|
+
private readonly security;
|
|
1523
|
+
private readonly listeners;
|
|
1524
|
+
/**
|
|
1525
|
+
* @param options - Authentication and connection options
|
|
1526
|
+
* @throws {TypeError} If `apiUrl` is not a valid URL
|
|
1527
|
+
*/
|
|
1528
|
+
constructor({ token, apiUrl }: GitHubClientOptions);
|
|
1529
|
+
/**
|
|
1530
|
+
* Subscribes to a client event.
|
|
1531
|
+
*
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```typescript
|
|
1534
|
+
* gh.on('request', (event) => {
|
|
1535
|
+
* console.log(`${event.method} ${event.url} — ${event.durationMs}ms`);
|
|
1536
|
+
* if (event.error) console.error('Request failed:', event.error);
|
|
1537
|
+
* });
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
on<K extends keyof GitHubClientEvents>(event: K, callback: GitHubClientEvents[K]): this;
|
|
1541
|
+
private emit;
|
|
1542
|
+
/**
|
|
1543
|
+
* Performs an authenticated GET request returning a single JSON object.
|
|
1544
|
+
* @internal
|
|
1545
|
+
*/
|
|
1546
|
+
private request;
|
|
1547
|
+
/**
|
|
1548
|
+
* Performs an authenticated GET request returning a paginated list.
|
|
1549
|
+
* Parses the `Link` response header to determine if more pages exist.
|
|
1550
|
+
* @internal
|
|
1551
|
+
*/
|
|
1552
|
+
private requestList;
|
|
1553
|
+
/**
|
|
1554
|
+
* Performs a GET request returning raw text content.
|
|
1555
|
+
* Uses `Accept: application/vnd.github.raw+json` to retrieve file content directly.
|
|
1556
|
+
* @internal
|
|
1557
|
+
*/
|
|
1558
|
+
private requestText;
|
|
1559
|
+
private makeRequestFn;
|
|
1560
|
+
private makeRequestListFn;
|
|
1561
|
+
private makeRequestTextFn;
|
|
1562
|
+
/**
|
|
1563
|
+
* Fetches the authenticated user's profile.
|
|
1564
|
+
*
|
|
1565
|
+
* `GET /user`
|
|
1566
|
+
*
|
|
1567
|
+
* @returns The authenticated user object
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```typescript
|
|
1571
|
+
* const me = await gh.currentUser();
|
|
1572
|
+
* console.log(me.login); // 'octocat'
|
|
1573
|
+
* ```
|
|
1574
|
+
*/
|
|
1575
|
+
currentUser(): Promise<GitHubUser>;
|
|
1576
|
+
/**
|
|
1577
|
+
* Returns a {@link UserResource} for a given GitHub login, providing access
|
|
1578
|
+
* to user data and their repositories.
|
|
1579
|
+
*
|
|
1580
|
+
* The returned resource can be awaited directly to fetch user info,
|
|
1581
|
+
* or chained to access nested resources.
|
|
1582
|
+
*
|
|
1583
|
+
* @param login - The user's login name (e.g., `'octocat'`)
|
|
1584
|
+
* @returns A chainable user resource
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* ```typescript
|
|
1588
|
+
* const user = await gh.user('octocat');
|
|
1589
|
+
* const repos = await gh.user('octocat').repos({ sort: 'updated' });
|
|
1590
|
+
* const pr = await gh.user('octocat').repo('Hello-World').pullRequest(1).files();
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
user(login: string): UserResource;
|
|
1594
|
+
/**
|
|
1595
|
+
* Returns an {@link OrganizationResource} for a given GitHub organization, providing
|
|
1596
|
+
* access to organization data and its repositories.
|
|
1597
|
+
*
|
|
1598
|
+
* The returned resource can be awaited directly to fetch organization info,
|
|
1599
|
+
* or chained to access nested resources.
|
|
1600
|
+
*
|
|
1601
|
+
* @param name - The organization's login name (e.g., `'github'`)
|
|
1602
|
+
* @returns A chainable organization resource
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* ```typescript
|
|
1606
|
+
* const org = await gh.org('github');
|
|
1607
|
+
* const repos = await gh.org('github').repos({ type: 'public' });
|
|
1608
|
+
* const prs = await gh.org('github').repo('linguist').pullRequests({ state: 'open' });
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
org(name: string): OrganizationResource;
|
|
1612
|
+
/**
|
|
1613
|
+
* Returns a {@link RepositoryResource} for a given owner and repository name.
|
|
1614
|
+
*
|
|
1615
|
+
* Shortcut that works for both user repositories and organization repositories.
|
|
1616
|
+
*
|
|
1617
|
+
* @param owner - The owner login (user or organization)
|
|
1618
|
+
* @param name - The repository name
|
|
1619
|
+
* @returns A chainable repository resource
|
|
1620
|
+
*
|
|
1621
|
+
* @example
|
|
1622
|
+
* ```typescript
|
|
1623
|
+
* const repo = await gh.repo('octocat', 'Hello-World');
|
|
1624
|
+
* const prs = await gh.repo('octocat', 'Hello-World').pullRequests();
|
|
1625
|
+
* ```
|
|
1626
|
+
*/
|
|
1627
|
+
repo(owner: string, name: string): RepositoryResource;
|
|
1628
|
+
/**
|
|
1629
|
+
* Searches for repositories using GitHub's search syntax.
|
|
1630
|
+
*
|
|
1631
|
+
* `GET /search/repositories`
|
|
1632
|
+
*
|
|
1633
|
+
* @param params - Search query and optional filters. `q` is required.
|
|
1634
|
+
* @returns A paged response of repositories with `totalCount`
|
|
1635
|
+
*
|
|
1636
|
+
* @example
|
|
1637
|
+
* ```typescript
|
|
1638
|
+
* const results = await gh.searchRepos({ q: 'language:typescript stars:>1000', sort: 'stars' });
|
|
1639
|
+
* console.log(`Found ${results.totalCount} repositories`);
|
|
1640
|
+
* ```
|
|
1641
|
+
*/
|
|
1642
|
+
searchRepos(params: SearchReposParams): Promise<GitHubPagedResponse<GitHubRepository>>;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* Thrown when the GitHub REST API returns a non-2xx response.
|
|
1647
|
+
*
|
|
1648
|
+
* @example
|
|
1649
|
+
* ```typescript
|
|
1650
|
+
* import { GitHubApiError } from 'github-api-client';
|
|
1651
|
+
*
|
|
1652
|
+
* try {
|
|
1653
|
+
* await gh.user('nonexistent-user-xyz');
|
|
1654
|
+
* } catch (err) {
|
|
1655
|
+
* if (err instanceof GitHubApiError) {
|
|
1656
|
+
* console.log(err.status); // 404
|
|
1657
|
+
* console.log(err.statusText); // 'Not Found'
|
|
1658
|
+
* console.log(err.message); // 'GitHub API error: 404 Not Found'
|
|
1659
|
+
* }
|
|
1660
|
+
* }
|
|
1661
|
+
* ```
|
|
1662
|
+
*/
|
|
1663
|
+
declare class GitHubApiError extends Error {
|
|
1664
|
+
/** HTTP status code (e.g. `404`, `401`, `403`, `422`) */
|
|
1665
|
+
readonly status: number;
|
|
1666
|
+
/** HTTP status text (e.g. `'Not Found'`, `'Unauthorized'`) */
|
|
1667
|
+
readonly statusText: string;
|
|
1668
|
+
constructor(status: number, statusText: string);
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* Handles Bearer token authentication for GitHub REST API requests.
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```typescript
|
|
1676
|
+
* const security = new Security('ghp_myPersonalAccessToken');
|
|
1677
|
+
*
|
|
1678
|
+
* const headers = security.getHeaders();
|
|
1679
|
+
* // {
|
|
1680
|
+
* // Authorization: 'Bearer ghp_myPersonalAccessToken',
|
|
1681
|
+
* // Accept: 'application/vnd.github+json',
|
|
1682
|
+
* // 'Content-Type': 'application/json',
|
|
1683
|
+
* // 'X-GitHub-Api-Version': '2022-11-28',
|
|
1684
|
+
* // }
|
|
1685
|
+
* ```
|
|
1686
|
+
*/
|
|
1687
|
+
declare class Security {
|
|
1688
|
+
private readonly apiUrl;
|
|
1689
|
+
private readonly token;
|
|
1690
|
+
/**
|
|
1691
|
+
* Creates a new Security instance with a GitHub personal access token.
|
|
1692
|
+
*
|
|
1693
|
+
* @param token - A GitHub personal access token (e.g., `ghp_...`) or OAuth token
|
|
1694
|
+
* @param apiUrl - The base URL of the GitHub API. Defaults to `'https://api.github.com'`.
|
|
1695
|
+
* Must be a valid URL; throws if it cannot be parsed.
|
|
1696
|
+
*
|
|
1697
|
+
* @throws {TypeError} If `apiUrl` is not a valid URL
|
|
1698
|
+
*/
|
|
1699
|
+
constructor(token: string, apiUrl?: string);
|
|
1700
|
+
/**
|
|
1701
|
+
* Returns the base URL of the GitHub API, without a trailing slash.
|
|
1702
|
+
*
|
|
1703
|
+
* @returns The API base URL
|
|
1704
|
+
*/
|
|
1705
|
+
getApiUrl(): string;
|
|
1706
|
+
/**
|
|
1707
|
+
* Returns the value of the `Authorization` header for Bearer authentication.
|
|
1708
|
+
*
|
|
1709
|
+
* @returns The Authorization header value in the format `Bearer <token>`
|
|
1710
|
+
*/
|
|
1711
|
+
getAuthorizationHeader(): string;
|
|
1712
|
+
/**
|
|
1713
|
+
* Returns the full set of HTTP headers required for authenticated GitHub API requests.
|
|
1714
|
+
*
|
|
1715
|
+
* @returns An object containing `Authorization`, `Accept`, `Content-Type`, and `X-GitHub-Api-Version` headers
|
|
1716
|
+
*/
|
|
1717
|
+
getHeaders(): Record<string, string>;
|
|
1718
|
+
/**
|
|
1719
|
+
* Returns headers for raw file content requests.
|
|
1720
|
+
*
|
|
1721
|
+
* @returns Headers with `Accept: application/vnd.github.raw+json`
|
|
1722
|
+
*/
|
|
1723
|
+
getRawHeaders(): Record<string, string>;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
export { type BranchesParams, type CheckRunsParams, CommitResource, type CommitStatusesParams, type CommitsParams, type ContentParams, type ForksParams, GitHubApiError, type GitHubBranch, type GitHubCheckRun, GitHubClient, type GitHubClientEvents, type GitHubClientOptions, type GitHubCombinedStatus, type GitHubCommit, type GitHubCommitFile, type GitHubCommitStatus, type GitHubContent, type GitHubLabel, type GitHubMilestone, type GitHubOrganization, type GitHubPagedResponse, type GitHubPullRequest, type GitHubPullRequestFile, type GitHubRef, type GitHubRelease, type GitHubReleaseAsset, type GitHubRepository, type GitHubReview, type GitHubReviewComment, type GitHubTag, type GitHubUser, type GitHubWebhook, type OrgMembersParams, OrganizationResource, type PaginationParams, type PullRequestFilesParams, PullRequestResource, type PullRequestsParams, type ReleasesParams, type ReposParams, RepositoryResource, type RequestEvent, type ReviewCommentsParams, type ReviewsParams, type SearchReposParams, type SearchUsersParams, Security, type TagsParams, UserResource, type UsersParams, type WebhooksParams };
|