@theholocron/github-client 1.58.0-alpha.2 → 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 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,99 +222,172 @@ 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;
244
372
  }
373
+ /** One custom property value set on a repository. */
374
+ interface RepoPropertyValue {
375
+ /** The property's name. */
376
+ property_name: string;
377
+ /** A string, a string array for `multi_select`, or `null` when unset. */
378
+ value: string | string[] | null;
379
+ }
380
+ /** A pull request as GitHub returns it, with only the fields this client reads. */
245
381
  interface GitHubPullRequest {
382
+ /** The pull request's number. */
246
383
  number: number;
384
+ /** The pull request's title. */
247
385
  title: string;
386
+ /** Whether the pull request is open or closed. */
248
387
  state: "open" | "closed";
388
+ /** When the pull request was merged as an ISO 8601 timestamp, or `null` if it was not merged. */
249
389
  merged_at: string | null;
390
+ /** The URL of the pull request's page on GitHub. */
250
391
  html_url: string;
251
392
  /** The head branch: its name and the commit it pointed at when the PR was read. */
252
393
  head: {
@@ -263,10 +404,15 @@ interface GitHubCommitIdentity {
263
404
  }
264
405
  /** One commit as returned by `GET /pulls/{pull_number}/commits` — only the fields any known consumer needs. */
265
406
  interface GitHubPullRequestCommit {
407
+ /** The commit's SHA. */
266
408
  sha: string;
409
+ /** The commit's message and git identities. */
267
410
  commit: {
411
+ /** The commit message. */
268
412
  message: string;
413
+ /** The commit's author, as git recorded it. */
269
414
  author: GitHubCommitIdentity;
415
+ /** The commit's committer, as git recorded it. */
270
416
  committer: GitHubCommitIdentity;
271
417
  };
272
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). */
@@ -281,7 +427,9 @@ interface GitHubPullRequestCommit {
281
427
  }
282
428
  /** One file as returned by `GET /pulls/{pull_number}/files` — only the fields any known consumer needs. */
283
429
  interface GitHubPullRequestFile {
430
+ /** The file's path in the repository. */
284
431
  filename: string;
432
+ /** How the pull request changes the file. */
285
433
  status: "added" | "removed" | "modified" | "renamed" | "copied" | "changed" | "unchanged";
286
434
  /** Set only when `status === "renamed"`. */
287
435
  previous_filename?: string;
@@ -301,8 +449,10 @@ interface CreateReviewComment {
301
449
  line: number;
302
450
  /** Almost always `"RIGHT"` (the PR's own new content) — `"LEFT"` targets the base/pre-PR version instead. */
303
451
  side: "LEFT" | "RIGHT";
452
+ /** The comment text. */
304
453
  body: string;
305
454
  }
455
+ /** The body of a review creation request. */
306
456
  interface CreateReviewInput {
307
457
  /** The PR's head SHA the review attaches to. */
308
458
  commit_id: string;
@@ -315,11 +465,14 @@ interface CreateReviewInput {
315
465
  * required-approval counts and dismissal.
316
466
  */
317
467
  event: "COMMENT" | "REQUEST_CHANGES" | "APPROVE";
468
+ /** Inline comments to post with the review. */
318
469
  comments?: CreateReviewComment[];
319
470
  }
320
471
  /** `POST /pulls/{pull_number}/reviews`'s response — only the fields any known consumer needs. */
321
472
  interface GitHubPullRequestReview {
473
+ /** The review's numeric id. */
322
474
  id: number;
475
+ /** The URL of the review on GitHub. */
323
476
  html_url: string;
324
477
  }
325
478
  /**
@@ -330,7 +483,9 @@ interface GitHubPullRequestReview {
330
483
  * never compare it against a REST-sourced ID.
331
484
  */
332
485
  interface ReviewThread {
486
+ /** The thread's GraphQL node id. */
333
487
  id: string;
488
+ /** Whether the thread is resolved. */
334
489
  isResolved: boolean;
335
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. */
336
491
  authorLogin: string | undefined;
@@ -348,19 +503,70 @@ interface ReviewThread {
348
503
  */
349
504
  body: string | undefined;
350
505
  }
506
+ /** A repository as GitHub returns it, with only the fields this client reads. */
351
507
  interface GitHubRepo {
508
+ /** The name of the repository's default branch. */
352
509
  default_branch: string;
510
+ /** The repository's `owner/name`. */
353
511
  full_name: string;
354
- }
512
+ /** The repository description. */
513
+ description?: string | null;
514
+ /** The repository homepage URL. */
515
+ homepage?: string | null;
516
+ /** The topics set on the repository. */
517
+ topics?: string[];
518
+ /** Whether squash merging is allowed. */
519
+ allow_squash_merge?: boolean;
520
+ /** Whether merge commits are allowed. */
521
+ allow_merge_commit?: boolean;
522
+ /** Whether rebase merging is allowed. */
523
+ allow_rebase_merge?: boolean;
524
+ /** Whether auto-merge is allowed. */
525
+ allow_auto_merge?: boolean;
526
+ /** Whether a pull request branch can be updated from its base. */
527
+ allow_update_branch?: boolean;
528
+ /** Whether a merged pull request's branch is deleted. */
529
+ delete_branch_on_merge?: boolean;
530
+ /** Whether issues are enabled. */
531
+ has_issues?: boolean;
532
+ /** Whether discussions are enabled. */
533
+ has_discussions?: boolean;
534
+ /** Whether projects are enabled. */
535
+ has_projects?: boolean;
536
+ /** Whether the wiki is enabled. */
537
+ has_wiki?: boolean;
538
+ /** Each feature's `status` (`enabled` / `disabled`). Only an admin token sees it; absent for the rest. */
539
+ security_and_analysis?: Record<string, {
540
+ status: string;
541
+ } | undefined> | null;
542
+ }
543
+ /** A file's contents as the contents API returns them. */
355
544
  interface GitHubContents {
545
+ /** The file content, encoded as named by `encoding`. */
356
546
  content: string;
547
+ /** The encoding of `content`, normally `base64`. */
357
548
  encoding: string;
358
549
  }
550
+ /** A repository ruleset in summary form. */
359
551
  interface GitHubRuleset {
552
+ /** The ruleset's numeric id. */
360
553
  id: number;
554
+ /** The ruleset's name. */
361
555
  name: string;
556
+ /** How the ruleset is enforced, e.g. `active`, `evaluate` or `disabled`. */
362
557
  enforcement: string;
363
558
  }
559
+ /** One ruleset in full, as `GET /repos/{repo}/rulesets/{id}` returns it. */
560
+ interface GitHubRulesetDetail extends GitHubRuleset {
561
+ /** What the ruleset applies to, e.g. `branch`. */
562
+ target?: string;
563
+ /** Each rule has a `type`; some carry `parameters`. */
564
+ rules?: Array<{
565
+ type: string;
566
+ parameters?: Record<string, unknown>;
567
+ }>;
568
+ }
569
+ /** Where a secret lives: the repository, one of its environments, or an organization. */
364
570
  type SecretScope = {
365
571
  kind: "repo";
366
572
  } | {
@@ -370,21 +576,39 @@ type SecretScope = {
370
576
  kind: "organization";
371
577
  org: string;
372
578
  };
579
+ /** A public key used to encrypt a secret before it is sent. */
373
580
  interface GitHubPublicKey {
581
+ /** The key's id, sent back with the encrypted secret. */
374
582
  key_id: string;
583
+ /** The Base64-encoded public key. */
375
584
  key: string;
376
585
  }
586
+ /** The workflow run that a code scanning setup started. */
377
587
  interface CodeScanningSetupResult {
588
+ /** The id of the workflow run. */
378
589
  run_id: number;
590
+ /** The URL of the workflow run. */
379
591
  run_url: string;
380
592
  }
593
+ /** A permission level a team can hold on a repository. */
381
594
  type TeamPermission = "pull" | "triage" | "push" | "maintain" | "admin";
595
+ /** A team with access to a repository, and the permission it has there. */
596
+ interface RepoTeam {
597
+ /** The team's slug. */
598
+ slug: string;
599
+ /** The team's permission on the repository. */
600
+ permission: TeamPermission;
601
+ }
382
602
  /** A member of a team, as GitHub lists it. `id` is the numeric user id, which survives a rename; `login` does not. */
383
603
  interface TeamMember {
604
+ /** The member's numeric user id. */
384
605
  id: number;
606
+ /** The member's login. */
385
607
  login: string;
608
+ /** The kind of account, e.g. `User`. */
386
609
  type?: string;
387
610
  }
611
+ /** Where a variable lives: the repository, one of its environments, or an organization. */
388
612
  type VariableScope = {
389
613
  kind: "repo";
390
614
  } | {
@@ -401,14 +625,20 @@ type VariableScope = {
401
625
  type VariableVisibility = "all" | "private" | "selected";
402
626
  /** A GitHub Actions variable. Unlike a secret its value is readable, so a reconcile can tell whether it differs. */
403
627
  interface GitHubVariable {
628
+ /** The variable's name. */
404
629
  name: string;
630
+ /** The variable's value. */
405
631
  value: string;
406
632
  /** Present on organization variables only. */
407
633
  visibility?: VariableVisibility;
408
634
  }
635
+ /** The authenticated user, with only the fields this client reads. */
409
636
  interface GitHubUser {
637
+ /** The user's login. */
410
638
  login: string;
639
+ /** The user's display name, or `null` when not set. */
411
640
  name: string | null;
641
+ /** The user's public email, or `null` when not set. */
412
642
  email: string | null;
413
643
  }
414
644
  /** The authenticated user and, for a token that expires, when. */
@@ -423,30 +653,48 @@ interface GitHubUserWithExpiry {
423
653
  * ISO 8601, or `undefined` when the header is missing or is not a date.
424
654
  */
425
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. */
426
657
  interface GitHubWorkflowRun {
658
+ /** The run's numeric id. */
427
659
  id: number;
660
+ /** The workflow's name, or `null` when unnamed. */
428
661
  name: string | null;
662
+ /** The run's display title. */
429
663
  display_title: string;
664
+ /** The branch the run was triggered on. */
430
665
  head_branch: string;
666
+ /** The commit SHA the run was triggered on. */
431
667
  head_sha: string;
668
+ /** The run's status, e.g. `queued`, `in_progress` or `completed`. */
432
669
  status: string;
670
+ /** The run's result once completed, or `null` before. */
433
671
  conclusion: string | null;
672
+ /** The URL of the run's page on GitHub. */
434
673
  html_url: string;
674
+ /** When the run was created, as an ISO 8601 timestamp. */
435
675
  created_at: string;
676
+ /** When the run was last updated, as an ISO 8601 timestamp. */
436
677
  updated_at: string;
437
678
  }
679
+ /** Filters for listing workflow runs. */
438
680
  interface WorkflowRunFilter {
681
+ /** Only runs on this branch. */
439
682
  branch?: string;
683
+ /** The maximum number of runs to return. */
440
684
  limit?: number;
685
+ /** Only runs with this status. */
441
686
  status?: string;
442
687
  }
688
+ /** The credentials identifying a GitHub App: its id and private key. */
443
689
  interface GitHubAppCredentials {
444
690
  /** The App's numeric id (not the client id). */
445
691
  appId: string;
446
692
  /** PEM-encoded RSA private key — PKCS#1 (GitHub's default download format) or PKCS#8, either works. */
447
693
  privateKey: string;
448
694
  }
695
+ /** A short-lived installation access token and when it expires. */
449
696
  interface InstallationAccessToken {
697
+ /** The installation access token, used as a bearer token for the REST API. */
450
698
  token: string;
451
699
  /** ISO 8601 — installation tokens are short-lived, about an hour. */
452
700
  expiresAt: string;
@@ -496,6 +744,7 @@ export declare function verifyGitHubWebhookSignature(input: {
496
744
  signature: string | undefined;
497
745
  secret: string;
498
746
  }): boolean;
747
+ /** The three GitHub webhook headers a consumer needs. */
499
748
  interface GitHubWebhookHeaders {
500
749
  /** `X-GitHub-Event` — the event category, e.g. `"push"`, `"pull_request"`. */
501
750
  event: string | undefined;
@@ -506,31 +755,62 @@ interface GitHubWebhookHeaders {
506
755
  }
507
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). */
508
757
  export declare function parseGitHubWebhookHeaders(headers: Record<string, string | string[] | undefined>): GitHubWebhookHeaders;
758
+ /** The payload of an `installation` webhook delivery. */
509
759
  interface GitHubInstallationWebhookPayload {
760
+ /** What happened to the installation, e.g. `created` or `deleted`. */
510
761
  action: string;
762
+ /** The installation the delivery is about. */
511
763
  installation: {
764
+ /** The installation id. */
512
765
  id: number;
513
766
  };
514
767
  }
768
+ /** The payload of a `push` webhook delivery. */
515
769
  interface GitHubPushWebhookPayload {
770
+ /** The full name of the pushed ref, e.g. `refs/heads/main`. */
516
771
  ref: string;
772
+ /** The installation the delivery is about, when sent. */
517
773
  installation?: {
774
+ /** The installation id. */
518
775
  id: number;
519
776
  };
777
+ /** The repository that was pushed to. */
520
778
  repository: {
779
+ /** The repository's owner/name. */
521
780
  full_name: string;
781
+ /** The name of the default branch. */
522
782
  default_branch: string;
523
783
  };
524
784
  }
785
+ /** The payload of a `pull_request` webhook delivery. */
525
786
  interface GitHubPullRequestWebhookPayload {
787
+ /** What happened to the pull request, e.g. `opened` or `closed`. */
526
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. */
527
803
  installation?: {
804
+ /** The installation id. */
528
805
  id: number;
529
806
  };
807
+ /** The repository the pull request belongs to. */
530
808
  repository: {
809
+ /** The repository's owner/name. */
531
810
  full_name: string;
532
811
  };
533
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. */
534
814
  export declare function createGitHubClient(opts: GitHubClientOptions): {
535
815
  branches: {
536
816
  protectBranch: (repo: string, branch: string, payload: Record<string, unknown>) => Promise<void>;
@@ -595,6 +875,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
595
875
  updatePages: (repo: string, payload: UpdatePagesPayload) => Promise<void>;
596
876
  };
597
877
  properties: {
878
+ getValues: (repo: string) => Promise<RepoPropertyValue[]>;
598
879
  orgSchema: (org: string) => Promise<OrgProperty[]>;
599
880
  setProperties: (repo: string, values: Record<string, string | string[]>) => Promise<void>;
600
881
  };
@@ -613,6 +894,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
613
894
  getContents: (repo: string, path: string) => Promise<GitHubContents>;
614
895
  };
615
896
  rulesets: {
897
+ getRuleset: (repo: string, id: number) => Promise<GitHubRulesetDetail>;
616
898
  listRulesets: (repo: string) => Promise<GitHubRuleset[]>;
617
899
  createRuleset: (repo: string, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
618
900
  updateRuleset: (repo: string, id: number, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
@@ -624,6 +906,10 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
624
906
  deleteSecret: (repo: string, scope: SecretScope, name: string) => Promise<void>;
625
907
  };
626
908
  security: {
909
+ vulnerabilityAlertsEnabled: (repo: string) => Promise<boolean>;
910
+ automatedSecurityFixesEnabled: (repo: string) => Promise<boolean>;
911
+ privateVulnerabilityReportingEnabled: (repo: string) => Promise<boolean>;
912
+ codeScanningDefaultSetupState: (repo: string) => Promise<string>;
627
913
  enableVulnerabilityAlerts: (repo: string) => Promise<void>;
628
914
  enableAutomatedSecurityFixes: (repo: string) => Promise<void>;
629
915
  enableSecretScanning: (repo: string) => Promise<void>;
@@ -634,6 +920,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
634
920
  };
635
921
  teams: {
636
922
  members: (org: string, teamSlug: string) => Promise<TeamMember[]>;
923
+ listForRepo: (repo: string) => Promise<RepoTeam[]>;
637
924
  addRepo: (org: string, teamSlug: string, owner: string, repo: string, permission: TeamPermission) => Promise<void>;
638
925
  };
639
926
  topics: {
@@ -656,5 +943,6 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
656
943
  createWorkflowDispatch: (repo: string, workflowFile: string, ref: string, inputs?: Record<string, string>) => Promise<void>;
657
944
  };
658
945
  };
946
+ /** The client returned by `createGitHubClient()`: one group of methods per GitHub API area. */
659
947
  export type GitHubClient = ReturnType<typeof createGitHubClient>;
660
- 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, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
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
@@ -293,6 +293,8 @@ function pages(rest) {
293
293
  // src/properties/properties.ts
294
294
  function properties(rest) {
295
295
  return {
296
+ /** The custom property values set on a repository (read-only). */
297
+ getValues: (repo) => rest.request(`${repoBase(repo)}/properties/values`),
296
298
  /**
297
299
  * The custom properties an organization defines, with their types and allowed values (read-only).
298
300
  * The token needs read access to the organization's custom properties.
@@ -431,6 +433,7 @@ function repos(rest) {
431
433
  // src/rulesets/rulesets.ts
432
434
  function rulesets(rest) {
433
435
  return {
436
+ getRuleset: (repo, id) => rest.request(`${repoBase(repo)}/rulesets/${id}`),
434
437
  listRulesets: (repo) => rest.request(`${repoBase(repo)}/rulesets`),
435
438
  createRuleset: (repo, payload) => rest.request(`${repoBase(repo)}/rulesets`, {
436
439
  method: "POST",
@@ -468,6 +471,22 @@ function secrets(rest) {
468
471
  // src/security/security.ts
469
472
  function security(rest) {
470
473
  return {
474
+ /** Whether vulnerability alerts are on: GitHub answers 204 when they are and 404 when they are not. */
475
+ vulnerabilityAlertsEnabled: async (repo) => {
476
+ try {
477
+ await rest.request(`${repoBase(repo)}/vulnerability-alerts`, { expectNoContent: true });
478
+ return true;
479
+ } catch (err) {
480
+ if (err instanceof ProviderApiError && err.status === 404) return false;
481
+ throw err;
482
+ }
483
+ },
484
+ /** Whether Dependabot security updates are on. */
485
+ automatedSecurityFixesEnabled: async (repo) => (await rest.request(`${repoBase(repo)}/automated-security-fixes`)).enabled,
486
+ /** Whether private vulnerability reporting is on. */
487
+ privateVulnerabilityReportingEnabled: async (repo) => (await rest.request(`${repoBase(repo)}/private-vulnerability-reporting`)).enabled,
488
+ /** The state of CodeQL default setup: `configured` or `not-configured`. */
489
+ codeScanningDefaultSetupState: async (repo) => (await rest.request(`${repoBase(repo)}/code-scanning/default-setup`)).state,
471
490
  enableVulnerabilityAlerts: (repo) => rest.request(`${repoBase(repo)}/vulnerability-alerts`, {
472
491
  method: "PUT",
473
492
  expectNoContent: true
@@ -535,6 +554,8 @@ function teams(rest) {
535
554
  if ((await read(51)).length > 0) throw new Error(`team ${org}/${teamSlug} has more than 5000 members; refusing to read them all`);
536
555
  return all;
537
556
  },
557
+ /** The teams that have access to a repository, with each team's permission there (read-only). */
558
+ listForRepo: (repo) => rest.request(`${repoBase(repo)}/teams`, { query: { per_page: String(PAGE$1) } }),
538
559
  addRepo: (org, teamSlug, owner, repo, permission) => rest.request(`/orgs/${org}/teams/${teamSlug}/repos/${owner}/${repo}`, {
539
560
  method: "PUT",
540
561
  body: { permission }
@@ -870,6 +891,7 @@ function parseGitHubWebhookHeaders(headers) {
870
891
  };
871
892
  }
872
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. */
873
895
  function createGitHubClient(opts) {
874
896
  const rest = createGitHubRestClient(opts);
875
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.2",
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.2",
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/eslint-config": "^8.9.0-alpha.3",
49
- "@theholocron/tsconfig": "^8.9.0-alpha.3",
50
- "@theholocron/tsdown-config": "^8.9.0-alpha.3",
51
- "@theholocron/vitest-config": "^8.9.0-alpha.3"
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"