@leitwerk-dev/github 0.2.0 → 0.3.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.
Files changed (47) hide show
  1. package/README.md +40 -0
  2. package/dist/authorization.d.ts +4 -0
  3. package/dist/authorization.d.ts.map +1 -1
  4. package/dist/binding.d.ts +1 -0
  5. package/dist/binding.d.ts.map +1 -1
  6. package/dist/capability.d.ts +6 -1
  7. package/dist/capability.d.ts.map +1 -1
  8. package/dist/{chunk-PVE52UFH.js → chunk-OAOKE6LC.js} +162 -20
  9. package/dist/chunk-OAOKE6LC.js.map +1 -0
  10. package/dist/client.d.ts +143 -8
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/external.d.ts +66 -0
  13. package/dist/external.d.ts.map +1 -1
  14. package/dist/index.d.ts +13 -11
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +160 -168
  17. package/dist/index.js.map +1 -1
  18. package/dist/issue-provider.d.ts.map +1 -1
  19. package/dist/issue-watcher.d.ts +12 -0
  20. package/dist/issue-watcher.d.ts.map +1 -1
  21. package/dist/poll-report.d.ts +2 -18
  22. package/dist/poll-report.d.ts.map +1 -1
  23. package/dist/provider.d.ts +3 -1
  24. package/dist/provider.d.ts.map +1 -1
  25. package/dist/testing/tool-fixture.d.ts +192 -0
  26. package/dist/testing/tool-fixture.d.ts.map +1 -0
  27. package/dist/testing.d.ts +67 -3
  28. package/dist/testing.d.ts.map +1 -1
  29. package/dist/testing.js +46 -4
  30. package/dist/testing.js.map +1 -1
  31. package/dist/tools.d.ts +1 -2
  32. package/dist/tools.d.ts.map +1 -1
  33. package/package.json +6 -7
  34. package/src/authorization.ts +9 -1
  35. package/src/binding.ts +1 -0
  36. package/src/capability.ts +6 -1
  37. package/src/client.ts +315 -28
  38. package/src/external.ts +54 -0
  39. package/src/index.ts +33 -11
  40. package/src/issue-provider.ts +4 -12
  41. package/src/issue-watcher.ts +16 -1
  42. package/src/poll-report.ts +5 -23
  43. package/src/provider.ts +1 -1
  44. package/src/testing/tool-fixture.ts +137 -0
  45. package/src/testing.ts +108 -9
  46. package/src/tools.ts +183 -175
  47. package/dist/chunk-PVE52UFH.js.map +0 -1
package/src/client.ts CHANGED
@@ -12,58 +12,128 @@ import { actionableFeedback, authorizedTrigger } from "./authorization.js";
12
12
 
13
13
  export type { GitHubFeedbackItem, GitHubIssue, GitHubPullRequest };
14
14
 
15
+ /** @internal */
16
+ interface GitHubLabel {
17
+ /** @internal */
18
+ id: number;
19
+ /** @internal */
20
+ name: string;
21
+ }
22
+
23
+ /** @public */
15
24
  export interface GitHubRepository {
25
+ /** @public */
16
26
  name: string;
27
+ /** @internal */
17
28
  full_name: string;
18
- owner: { login: string };
29
+ /** @public */
30
+ /** @public */
31
+ owner: {
32
+ /** @public */
33
+ login: string;
34
+ };
35
+ /** @public */
19
36
  ssh_url: string;
37
+ /** @public */
20
38
  default_branch: string;
39
+ /** @internal */
21
40
  html_url: string;
41
+ /** @internal */
22
42
  archived: boolean;
43
+ /** @internal */
23
44
  has_issues: boolean;
24
45
  }
46
+ /** @public */
25
47
  export interface GitHubGitIdentity {
48
+ /** @internal */
26
49
  provider: "github";
50
+ /** @internal */
27
51
  profile: string;
52
+ /** @internal */
28
53
  login: string;
54
+ /** @public */
29
55
  name: string;
56
+ /** @public */
30
57
  email: string;
31
58
  }
59
+ /** @public */
32
60
  export interface GitHubLabelEvent {
61
+ /** @internal */
33
62
  id: number;
63
+ /** @internal */
34
64
  event: string;
35
- label?: { name: string };
36
- actor: { login: string } | null;
65
+ /** @public */
66
+ /** @public */
67
+ label?: {
68
+ /** @public */
69
+ name: string;
70
+ };
71
+ /** @public */
72
+ /** @public */
73
+ actor: {
74
+ /** @public */
75
+ login: string;
76
+ } | null;
37
77
  }
38
78
 
79
+ /** @internal */
39
80
  export interface GitHubProfile {
81
+ /** @internal */
40
82
  apiBaseUrl: string;
83
+ /** @internal */
41
84
  token: string;
85
+ /** @internal */
42
86
  botLogin: string;
87
+ /** @internal */
43
88
  allowedOrganization?: string;
44
89
  }
45
90
 
91
+ /** @public */
46
92
  export interface GitHubCheckSummary {
93
+ /** @public */
47
94
  headSha: string;
95
+ /** @public */
48
96
  status: "pending" | "success" | "failure";
97
+ /** @public */
49
98
  total: number;
99
+ /** @public */
50
100
  failed: Array<{
101
+ /** @internal */
51
102
  name: string;
103
+ /** @public */
52
104
  conclusion: string | null;
105
+ /** @public */
53
106
  url: string | null;
54
107
  }>;
55
108
  }
56
109
 
110
+ /** @public */
57
111
  export interface GitHubRelease {
112
+ /** @internal */
58
113
  id: number;
114
+ /** @public */
59
115
  tag_name: string;
116
+ /** @internal */
60
117
  target_commitish: string;
118
+ /** @internal */
61
119
  draft: boolean;
120
+ /** @internal */
62
121
  prerelease: boolean;
122
+ /** @internal */
63
123
  html_url: string;
64
- assets: Array<{ name: string; url: string; browser_download_url: string }>;
124
+ /** @public */
125
+ /** @public */
126
+ assets: Array<{
127
+ /** @public */
128
+ name: string;
129
+ /** @public */
130
+ url: string;
131
+ /** @public */
132
+ browser_download_url: string;
133
+ }>;
65
134
  }
66
135
 
136
+ /** @internal */
67
137
  export function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile> {
68
138
  const profiles = new Map<string, GitHubProfile>();
69
139
  for (const [name, raw] of Object.entries(
@@ -99,6 +169,7 @@ export function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile>
99
169
  return profiles;
100
170
  }
101
171
 
172
+ /** @internal */
102
173
  export function assertGitHubRepository(profile: GitHubProfile, owner: string, repo: string): void {
103
174
  if (
104
175
  !/^[a-z0-9-]+$/i.test(owner) ||
@@ -116,8 +187,10 @@ export function assertGitHubRepository(profile: GitHubProfile, owner: string, re
116
187
  }
117
188
  }
118
189
 
190
+ /** @public */
119
191
  export class GitHubClient extends RepositoryHttpClient {
120
- constructor(readonly profile: GitHubProfile) {
192
+ /** @internal */
193
+ constructor(/** @internal */ readonly profile: GitHubProfile) {
121
194
  super("GitHub", profile.apiBaseUrl, {
122
195
  Accept: "application/vnd.github+json",
123
196
  Authorization: `Bearer ${profile.token}`,
@@ -125,6 +198,7 @@ export class GitHubClient extends RepositoryHttpClient {
125
198
  });
126
199
  }
127
200
 
201
+ /** @internal */
128
202
  protected override response(path: string, init: RequestInit = {}): Promise<Response> {
129
203
  return super.response(path, {
130
204
  ...init,
@@ -133,11 +207,13 @@ export class GitHubClient extends RepositoryHttpClient {
133
207
  });
134
208
  }
135
209
 
210
+ /** @internal */
136
211
  protected override repositoryPath(owner: string, repo: string): string {
137
212
  assertGitHubRepository(this.profile, owner, repo);
138
213
  return super.repositoryPath(owner, repo);
139
214
  }
140
215
 
216
+ /** @internal */
141
217
  async listRepositories() {
142
218
  return (
143
219
  await this.pages<GitHubRepository>(
@@ -153,18 +229,24 @@ export class GitHubClient extends RepositoryHttpClient {
153
229
  repo.has_issues,
154
230
  );
155
231
  }
232
+ /** @internal */
156
233
  async listOpenIssues(owner: string, repo: string) {
157
234
  return (
158
- await this.pages<GitHubIssue & { pull_request?: unknown }>(
159
- `${this.repositoryPath(owner, repo)}/issues?state=open`,
160
- )
235
+ await this.pages<
236
+ GitHubIssue & {
237
+ /** @internal */
238
+ pull_request?: unknown;
239
+ }
240
+ >(`${this.repositoryPath(owner, repo)}/issues?state=open`)
161
241
  ).filter((issue) => !issue.pull_request);
162
242
  }
243
+ /** @internal */
163
244
  listIssueEvents(owner: string, repo: string, number: number) {
164
245
  return this.pages<GitHubLabelEvent>(
165
246
  `${this.repositoryPath(owner, repo)}/issues/${number}/events`,
166
247
  );
167
248
  }
249
+ /** @internal */
168
250
  async isOrganizationMember(login: string): Promise<boolean> {
169
251
  if (!this.profile.allowedOrganization) return true;
170
252
  if (!/^[a-z0-9-]+$/i.test(login)) return false;
@@ -181,6 +263,7 @@ export class GitHubClient extends RepositoryHttpClient {
181
263
  throw error;
182
264
  }
183
265
  }
266
+ /** @internal */
184
267
  async authorizedTrigger(
185
268
  owner: string,
186
269
  repo: string,
@@ -190,6 +273,7 @@ export class GitHubClient extends RepositoryHttpClient {
190
273
  ) {
191
274
  return authorizedTrigger(this, owner, repo, number, trigger, done);
192
275
  }
276
+ /** @public */
193
277
  async resolveGitIdentity(profile: string): Promise<GitHubGitIdentity> {
194
278
  const user = await this.request<{ login: string; name: string | null; id: number }>("/user");
195
279
  if (user.login !== this.profile.botLogin)
@@ -202,24 +286,30 @@ export class GitHubClient extends RepositoryHttpClient {
202
286
  email: `${user.id}+${user.login}@users.noreply.github.com`,
203
287
  };
204
288
  }
289
+ /** @public */
205
290
  updateIssue(owner: string, repo: string, number: number, patch: Record<string, unknown>) {
206
291
  return this.request<GitHubIssue>(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
207
292
  method: "PATCH",
208
293
  body: JSON.stringify(patch),
209
294
  });
210
295
  }
296
+ /** @internal */
297
+ listLabels(owner: string, repo: string) {
298
+ return this.pages<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`);
299
+ }
300
+ /** @internal */
301
+ createLabel(owner: string, repo: string, name: string) {
302
+ return this.request<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`, {
303
+ method: "POST",
304
+ body: JSON.stringify({ name, color: "238636" }),
305
+ });
306
+ }
307
+ /** @internal */
211
308
  async ensureLabel(owner: string, repo: string, name: string) {
212
- const labels = await this.pages<{ id: number; name: string }>(
213
- `${this.repositoryPath(owner, repo)}/labels`,
214
- );
215
- return (
216
- labels.find((label) => label.name === name) ??
217
- this.request<{ id: number; name: string }>(`${this.repositoryPath(owner, repo)}/labels`, {
218
- method: "POST",
219
- body: JSON.stringify({ name, color: "238636" }),
220
- })
221
- );
309
+ const labels = await this.listLabels(owner, repo);
310
+ return labels.find((label) => label.name === name) ?? this.createLabel(owner, repo, name);
222
311
  }
312
+ /** @internal */
223
313
  addFeedbackReaction(owner: string, repo: string, kind: string, id: number) {
224
314
  const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
225
315
  return this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {
@@ -227,6 +317,7 @@ export class GitHubClient extends RepositoryHttpClient {
227
317
  body: JSON.stringify({ content: "eyes" }),
228
318
  });
229
319
  }
320
+ /** @internal */
230
321
  async replyFeedback(
231
322
  owner: string,
232
323
  repo: string,
@@ -236,22 +327,23 @@ export class GitHubClient extends RepositoryHttpClient {
236
327
  body: string,
237
328
  ) {
238
329
  if (kind === "inline")
239
- return this.request(
330
+ return this.writeJson(
240
331
  `${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,
241
- {
242
- method: "POST",
243
- body: JSON.stringify({ body }),
244
- },
332
+ "POST",
333
+ { body },
245
334
  );
246
335
  return this.addIssueComment(owner, repo, pr, body);
247
336
  }
248
337
 
338
+ /** @internal */
249
339
  getCommit(owner: string, repo: string, ref: string) {
250
- return this.request<{ sha: string }>(
251
- `${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`,
252
- );
340
+ return this.request<{
341
+ /** @internal */
342
+ sha: string;
343
+ }>(`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`);
253
344
  }
254
345
 
346
+ /** @public */
255
347
  async isAncestor(owner: string, repo: string, ancestor: string, descendant: string) {
256
348
  const comparison = await this.request<{ status: string }>(
257
349
  `${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`,
@@ -259,6 +351,7 @@ export class GitHubClient extends RepositoryHttpClient {
259
351
  return comparison.status === "identical" || comparison.status === "ahead";
260
352
  }
261
353
 
354
+ /** @public */
262
355
  async listPullRequestFeedback(
263
356
  owner: string,
264
357
  repo: string,
@@ -350,6 +443,7 @@ export class GitHubClient extends RepositoryHttpClient {
350
443
  return feedback;
351
444
  }
352
445
 
446
+ /** @public */
353
447
  async getCheckSummary(owner: string, repo: string, headSha: string): Promise<GitHubCheckSummary> {
354
448
  const runs: Array<Record<string, unknown>> = [];
355
449
  for (let page = 1; ; page++) {
@@ -377,6 +471,7 @@ export class GitHubClient extends RepositoryHttpClient {
377
471
  }
378
472
 
379
473
  /** Human feedback checked against current membership; delivery receipts use raw reads. */
474
+ /** @internal */
380
475
  async listActionablePullRequestFeedback(
381
476
  owner: string,
382
477
  repo: string,
@@ -389,6 +484,7 @@ export class GitHubClient extends RepositoryHttpClient {
389
484
  );
390
485
  }
391
486
 
487
+ /** @internal */
392
488
  listFeedbackReplies(owner: string, repo: string, pr: number, kind: string) {
393
489
  return kind === "inline"
394
490
  ? this.pages<Record<string, unknown>>(
@@ -397,19 +493,210 @@ export class GitHubClient extends RepositoryHttpClient {
397
493
  : this.listIssueComments(owner, repo, pr);
398
494
  }
399
495
 
496
+ /** @internal */
400
497
  listFeedbackReactions(owner: string, repo: string, kind: string, id: number) {
401
498
  if (kind !== "inline" && kind !== "conversation")
402
499
  throw new Error("Reviews do not support reactions");
403
500
  const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
404
- return this.pages<{ id: number; content: string; user: { login: string } }>(
405
- `${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`,
501
+ return this.pages<{
502
+ /** @internal */
503
+ id: number;
504
+ /** @internal */
505
+ content: string;
506
+ /** @internal */
507
+ user: {
508
+ /** @internal */
509
+ login: string;
510
+ };
511
+ }>(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`);
512
+ }
513
+
514
+ /** @public */
515
+ async getCiDiagnostics(
516
+ owner: string,
517
+ repo: string,
518
+ pullRequestNumber: number,
519
+ headSha: string,
520
+ signal?: AbortSignal,
521
+ ) {
522
+ const pr = await this.getPullRequest(owner, repo, pullRequestNumber, signal);
523
+ if (pr.state !== "open" || pr.merged || pr.head.sha !== headSha)
524
+ throw new Error("CI diagnostics target a stale pull request revision");
525
+ const prefix = this.repositoryPath(owner, repo);
526
+ const checks: Array<{
527
+ /** @internal */
528
+ id: number;
529
+ name: string;
530
+ conclusion: string | null;
531
+ /** @public */
532
+ /** @public */
533
+ output?: {
534
+ /** @public */
535
+ title?: string;
536
+ /** @public */
537
+ summary?: string;
538
+ /** @public */
539
+ text?: string;
540
+ };
541
+ }> = [];
542
+ for (let page = 1; ; page++) {
543
+ const batch = await this.request<{ check_runs: typeof checks }>(
544
+ `${prefix}/commits/${encodeURIComponent(headSha)}/check-runs?filter=latest&per_page=100&page=${page}`,
545
+ { signal },
546
+ );
547
+ checks.push(...batch.check_runs);
548
+ if (batch.check_runs.length < 100) break;
549
+ }
550
+ const failed = checks.filter(
551
+ (c) => c.conclusion && !["success", "neutral", "skipped"].includes(c.conclusion),
552
+ );
553
+ const annotations = await Promise.all(
554
+ failed.slice(0, 10).map(async (check) => ({
555
+ /** @public */
556
+ id: check.id,
557
+ /** @public */
558
+ name: check.name,
559
+ /** @public */
560
+ output: check.output,
561
+ /** @public */
562
+ annotations: (
563
+ await this.pages<unknown>(`${prefix}/check-runs/${check.id}/annotations`, signal)
564
+ ).slice(0, 100),
565
+ })),
566
+ );
567
+ const jobs: Array<{
568
+ /** @public */
569
+ id: number;
570
+ /** @public */
571
+ name: string;
572
+ /** @public */
573
+ html_url: string;
574
+ /** @public */
575
+ /** @public */
576
+ log: {
577
+ /** @public */
578
+ text: string;
579
+ /** @public */
580
+ truncated: boolean;
581
+ };
582
+ }> = [];
583
+ for (let page = 1; jobs.length < 10; page++) {
584
+ const runs = await this.request<{
585
+ workflow_runs: Array<{
586
+ id: number;
587
+ head_sha: string;
588
+ head_branch: string;
589
+ conclusion: string | null;
590
+ }>;
591
+ }>(
592
+ `${prefix}/actions/runs?head_sha=${encodeURIComponent(headSha)}&per_page=100&page=${page}`,
593
+ { signal },
594
+ );
595
+ for (const run of runs.workflow_runs) {
596
+ if (
597
+ run.head_sha !== headSha ||
598
+ run.head_branch !== pr.head.ref ||
599
+ !run.conclusion ||
600
+ ["success", "neutral", "skipped"].includes(run.conclusion)
601
+ )
602
+ continue;
603
+ for (let jobPage = 1; jobs.length < 10; jobPage++) {
604
+ const batch = await this.request<{
605
+ jobs: Array<{ id: number; name: string; html_url: string; conclusion: string | null }>;
606
+ }>(`${prefix}/actions/runs/${run.id}/jobs?filter=latest&per_page=100&page=${jobPage}`, {
607
+ signal,
608
+ });
609
+ for (const job of batch.jobs) {
610
+ if (
611
+ !job.conclusion ||
612
+ ["success", "neutral", "skipped"].includes(job.conclusion) ||
613
+ jobs.length >= 10
614
+ )
615
+ continue;
616
+ jobs.push({
617
+ id: job.id,
618
+ name: job.name,
619
+ html_url: job.html_url,
620
+ log: await this.readJobLog(owner, repo, job.id, signal),
621
+ });
622
+ }
623
+ if (batch.jobs.length < 100) break;
624
+ }
625
+ }
626
+ if (runs.workflow_runs.length < 100) break;
627
+ }
628
+ const refreshed = await this.getPullRequest(owner, repo, pullRequestNumber, signal);
629
+ if (refreshed.head.sha !== headSha || refreshed.state !== "open" || refreshed.merged)
630
+ throw new Error("CI diagnostics were superseded");
631
+ return {
632
+ /** @public */
633
+ headSha,
634
+ /** @public */
635
+ checks: annotations,
636
+ /** @public */
637
+ jobs,
638
+ /** @public */
639
+ truncated: failed.length > 10 || jobs.length >= 10,
640
+ };
641
+ }
642
+ private async readJobLog(
643
+ owner: string,
644
+ repo: string,
645
+ job: number,
646
+ signal?: AbortSignal,
647
+ ): Promise<{ text: string; truncated: boolean }> {
648
+ const timeout = signal
649
+ ? AbortSignal.any([signal, AbortSignal.timeout(30000)])
650
+ : AbortSignal.timeout(30000);
651
+ let response = await fetch(
652
+ `${this.profile.apiBaseUrl}${this.repositoryPath(owner, repo)}/actions/jobs/${job}/logs`,
653
+ {
654
+ headers: {
655
+ Authorization: `Bearer ${this.profile.token}`,
656
+ Accept: "application/vnd.github+json",
657
+ },
658
+ redirect: "manual",
659
+ signal: timeout,
660
+ },
406
661
  );
662
+ if (response.status === 302) {
663
+ const location = new URL(response.headers.get("location") ?? "");
664
+ if (location.protocol !== "https:" || location.username || location.password)
665
+ throw new Error("Invalid GitHub log download URL");
666
+ await response.body?.cancel();
667
+ // Signed storage URLs must never receive the GitHub credential.
668
+ response = await fetch(location, { redirect: "error", signal: timeout });
669
+ }
670
+ if (!response.ok) throw new IntegrationHttpError(response.status, "GitHub job log unavailable");
671
+ const reader = response.body?.getReader();
672
+ if (!reader) return { text: "", truncated: false };
673
+ const chunks: Uint8Array[] = [];
674
+ let bytes = 0;
675
+ let truncated = false;
676
+ try {
677
+ for (;;) {
678
+ const next = await reader.read();
679
+ if (next.done) break;
680
+ const part = next.value.slice(0, 65536 - bytes);
681
+ chunks.push(part);
682
+ bytes += part.length;
683
+ if (bytes === 65536) {
684
+ truncated = true;
685
+ break;
686
+ }
687
+ }
688
+ } finally {
689
+ await reader.cancel();
690
+ }
691
+ return { text: Buffer.concat(chunks).toString("utf8"), truncated };
407
692
  }
408
693
 
694
+ /** @internal */
409
695
  listReleases(owner: string, repo: string) {
410
696
  return this.pages<GitHubRelease>(`${this.repositoryPath(owner, repo)}/releases`);
411
697
  }
412
698
 
699
+ /** @public */
413
700
  downloadReleaseAsset(asset: GitHubRelease["assets"][number]): Promise<string> {
414
701
  const url = new URL(asset.url);
415
702
  if (`${url.protocol}//${url.host}` !== this.profile.apiBaseUrl)
package/src/external.ts CHANGED
@@ -4,33 +4,55 @@ import {
4
4
  } from "@leitwerk-dev/process-sdk";
5
5
  import { describeConflict } from "@leitwerk-dev/repository-rebase";
6
6
 
7
+ /** @internal */
7
8
  export const GITHUB_PR_STATE_KIND = "@leitwerk-private/github.pr_state";
8
9
 
10
+ /** @public */
9
11
  export interface GitHubPullRequestSourceConfig {
12
+ /** @public */
10
13
  profile: string;
14
+ /** @public */
11
15
  owner: string;
16
+ /** @public */
12
17
  repo: string;
18
+ /** @public */
13
19
  prNumber: number;
20
+ /** @public */
14
21
  headSha: string;
22
+ /** @public */
15
23
  feedbackCursor: number;
24
+ /** @public */
16
25
  lastConflictKey?: string | null;
26
+ /** @public */
17
27
  pollInterval?: string;
28
+ /** @internal */
18
29
  disabled?: boolean;
30
+ /** @public */
19
31
  eventKinds?: Array<"checks" | "feedback" | "merged" | "closed" | "merge_conflict">;
32
+ /** @internal */
20
33
  checkStatuses?: Array<"pending" | "success" | "failure">;
21
34
  }
22
35
 
36
+ /** @internal */
23
37
  export const GITHUB_RELEASE_KIND = "@leitwerk-private/github.release";
24
38
 
39
+ /** @internal */
25
40
  export interface GitHubReleaseSourceConfig {
41
+ /** @internal */
26
42
  profile: string;
43
+ /** @internal */
27
44
  owner: string;
45
+ /** @internal */
28
46
  repo: string;
47
+ /** @internal */
29
48
  mergeSha: string;
49
+ /** @internal */
30
50
  pollInterval?: string;
51
+ /** @internal */
31
52
  disabled?: boolean;
32
53
  }
33
54
 
55
+ /** @internal */
34
56
  export function describeGitHubEvent(event: unknown): ExternalEventDescription {
35
57
  const value = event as {
36
58
  kind?: string;
@@ -63,40 +85,67 @@ export function describeGitHubEvent(event: unknown): ExternalEventDescription {
63
85
  };
64
86
  }
65
87
 
88
+ /** @public */
66
89
  export const GITHUB_PR_TERMINAL_KIND = "@leitwerk-public/github.pr_terminal";
90
+ /** @public */
67
91
  export const GITHUB_PR_FEEDBACK_KIND = "@leitwerk-public/github.pr_feedback";
92
+ /** @public */
68
93
  export const GITHUB_ISSUE_CANCELLED_KIND = "@leitwerk-public/github.issue_cancelled";
69
94
 
95
+ /** @public */
70
96
  export interface GitHubPullRequestTerminalSourceConfig {
97
+ /** @public */
71
98
  profile: string;
99
+ /** @public */
72
100
  owner: string;
101
+ /** @public */
73
102
  repo: string;
103
+ /** @public */
74
104
  prNumber: number;
105
+ /** @public */
75
106
  pollInterval?: string;
107
+ /** @public */
76
108
  terminalOutcome?: "merged" | "closed";
109
+ /** @internal */
77
110
  disabled?: boolean;
78
111
  }
79
112
 
113
+ /** @public */
80
114
  export interface GitHubFeedbackSourceConfig extends GitHubPullRequestTerminalSourceConfig {
115
+ /** @public */
81
116
  conversationCursor: number;
117
+ /** @public */
82
118
  reviewCursor: number;
119
+ /** @public */
83
120
  inlineCursor: number;
121
+ /** @public */
84
122
  quietPeriodMs: number;
85
123
  }
86
124
 
125
+ /** @public */
87
126
  export interface GitHubIssueCancelledSourceConfig {
127
+ /** @public */
88
128
  profile: string;
129
+ /** @public */
89
130
  owner: string;
131
+ /** @public */
90
132
  repo: string;
133
+ /** @public */
91
134
  issueNumber: number;
135
+ /** @public */
92
136
  triggerLabel: string;
137
+ /** @public */
93
138
  pollInterval?: string;
94
139
  }
95
140
 
141
+ /** @public */
96
142
  export const GITHUB_CHECKS_KIND = "@leitwerk-public/github.checks";
97
143
 
144
+ /** @public */
98
145
  export const githubExternal = {
146
+ /** @public */
99
147
  checks: defineExternalActionSource<{
148
+ afterKey?: string;
100
149
  profile: string;
101
150
  owner: string;
102
151
  repo: string;
@@ -107,29 +156,34 @@ export const githubExternal = {
107
156
  describeEvent: describeGitHubEvent,
108
157
  label: "GitHub Actions failures",
109
158
  }),
159
+ /** @public */
110
160
  issueCancelled: defineExternalActionSource<GitHubIssueCancelledSourceConfig>({
111
161
  kind: GITHUB_ISSUE_CANCELLED_KIND,
112
162
  describeEvent: () => ({ summary: "Source issue cancelled" }),
113
163
  label: "GitHub source issue cancelled",
114
164
  description: "Fires when the source issue closes or loses its trigger label",
115
165
  }),
166
+ /** @public */
116
167
  pullRequestTerminal: defineExternalActionSource<GitHubPullRequestTerminalSourceConfig>({
117
168
  kind: GITHUB_PR_TERMINAL_KIND,
118
169
  describeEvent: describeGitHubEvent,
119
170
  label: "GitHub pull request merged or closed",
120
171
  description: "Fires when the tracked pull request reaches a terminal state",
121
172
  }),
173
+ /** @public */
122
174
  pullRequestFeedback: defineExternalActionSource<GitHubFeedbackSourceConfig>({
123
175
  kind: GITHUB_PR_FEEDBACK_KIND,
124
176
  describeEvent: () => ({ summary: "Pull request feedback received" }),
125
177
  label: "GitHub pull request feedback",
126
178
  description: "Fires after unseen human feedback has been quiet long enough to batch",
127
179
  }),
180
+ /** @internal */
128
181
  releaseContaining: defineExternalActionSource<GitHubReleaseSourceConfig>({
129
182
  kind: GITHUB_RELEASE_KIND,
130
183
  label: "Published GitHub release",
131
184
  description: "Fires when a published release contains the tracked merge commit",
132
185
  }),
186
+ /** @public */
133
187
  pullRequestState: defineExternalActionSource<GitHubPullRequestSourceConfig>({
134
188
  kind: GITHUB_PR_STATE_KIND,
135
189
  describeEvent: describeGitHubEvent,