@leitwerk-dev/github 0.2.0 → 0.2.1
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/README.md +26 -0
- package/dist/authorization.d.ts +4 -0
- package/dist/authorization.d.ts.map +1 -1
- package/dist/binding.d.ts +1 -0
- package/dist/binding.d.ts.map +1 -1
- package/dist/capability.d.ts +4 -1
- package/dist/capability.d.ts.map +1 -1
- package/dist/{chunk-PVE52UFH.js → chunk-6X3F3VHK.js} +48 -22
- package/dist/chunk-6X3F3VHK.js.map +1 -0
- package/dist/client.d.ts +98 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/external.d.ts +65 -0
- package/dist/external.d.ts.map +1 -1
- package/dist/index.d.ts +13 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +120 -139
- package/dist/index.js.map +1 -1
- package/dist/issue-watcher.d.ts +12 -0
- package/dist/issue-watcher.d.ts.map +1 -1
- package/dist/provider.d.ts +3 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/testing/tool-fixture.d.ts +45 -0
- package/dist/testing/tool-fixture.d.ts.map +1 -0
- package/dist/testing.d.ts +67 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +29 -4
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/authorization.ts +9 -1
- package/src/binding.ts +1 -0
- package/src/capability.ts +4 -1
- package/src/client.ts +135 -30
- package/src/external.ts +53 -0
- package/src/index.ts +31 -11
- package/src/issue-watcher.ts +16 -1
- package/src/testing/tool-fixture.ts +126 -0
- package/src/testing.ts +91 -9
- package/src/tools.ts +158 -175
- package/dist/chunk-PVE52UFH.js.map +0 -1
package/src/client.ts
CHANGED
|
@@ -12,58 +12,124 @@ import { actionableFeedback, authorizedTrigger } from "./authorization.js";
|
|
|
12
12
|
|
|
13
13
|
export type { GitHubFeedbackItem, GitHubIssue, GitHubPullRequest };
|
|
14
14
|
|
|
15
|
+
/** @public */
|
|
15
16
|
export interface GitHubRepository {
|
|
17
|
+
/** @public */
|
|
16
18
|
name: string;
|
|
19
|
+
/** @internal */
|
|
17
20
|
full_name: string;
|
|
18
|
-
|
|
21
|
+
/** @public */
|
|
22
|
+
owner: {
|
|
23
|
+
/** @public */
|
|
24
|
+
login: string;
|
|
25
|
+
};
|
|
26
|
+
/** @public */
|
|
19
27
|
ssh_url: string;
|
|
28
|
+
/** @public */
|
|
20
29
|
default_branch: string;
|
|
30
|
+
/** @internal */
|
|
21
31
|
html_url: string;
|
|
32
|
+
/** @internal */
|
|
22
33
|
archived: boolean;
|
|
34
|
+
/** @internal */
|
|
23
35
|
has_issues: boolean;
|
|
24
36
|
}
|
|
37
|
+
/** @public */
|
|
25
38
|
export interface GitHubGitIdentity {
|
|
39
|
+
/** @internal */
|
|
26
40
|
provider: "github";
|
|
41
|
+
/** @internal */
|
|
27
42
|
profile: string;
|
|
43
|
+
/** @internal */
|
|
28
44
|
login: string;
|
|
45
|
+
/** @public */
|
|
29
46
|
name: string;
|
|
47
|
+
/** @public */
|
|
30
48
|
email: string;
|
|
31
49
|
}
|
|
50
|
+
/** @public */
|
|
32
51
|
export interface GitHubLabelEvent {
|
|
52
|
+
/** @internal */
|
|
33
53
|
id: number;
|
|
54
|
+
/** @internal */
|
|
34
55
|
event: string;
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
/** @internal */
|
|
57
|
+
label?: {
|
|
58
|
+
/** @internal */
|
|
59
|
+
name: string;
|
|
60
|
+
};
|
|
61
|
+
/** @internal */
|
|
62
|
+
actor: {
|
|
63
|
+
/** @internal */
|
|
64
|
+
login: string;
|
|
65
|
+
} | null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** @internal */
|
|
69
|
+
interface GitHubLabel {
|
|
70
|
+
/** @internal */
|
|
71
|
+
id: number;
|
|
72
|
+
/** @internal */
|
|
73
|
+
name: string;
|
|
37
74
|
}
|
|
38
75
|
|
|
76
|
+
/** @internal */
|
|
39
77
|
export interface GitHubProfile {
|
|
78
|
+
/** @internal */
|
|
40
79
|
apiBaseUrl: string;
|
|
80
|
+
/** @internal */
|
|
41
81
|
token: string;
|
|
82
|
+
/** @internal */
|
|
42
83
|
botLogin: string;
|
|
84
|
+
/** @internal */
|
|
43
85
|
allowedOrganization?: string;
|
|
44
86
|
}
|
|
45
87
|
|
|
88
|
+
/** @public */
|
|
46
89
|
export interface GitHubCheckSummary {
|
|
90
|
+
/** @public */
|
|
47
91
|
headSha: string;
|
|
92
|
+
/** @public */
|
|
48
93
|
status: "pending" | "success" | "failure";
|
|
94
|
+
/** @public */
|
|
49
95
|
total: number;
|
|
96
|
+
/** @public */
|
|
50
97
|
failed: Array<{
|
|
98
|
+
/** @public */
|
|
51
99
|
name: string;
|
|
100
|
+
/** @public */
|
|
52
101
|
conclusion: string | null;
|
|
102
|
+
/** @public */
|
|
53
103
|
url: string | null;
|
|
54
104
|
}>;
|
|
55
105
|
}
|
|
56
106
|
|
|
107
|
+
/** @public */
|
|
57
108
|
export interface GitHubRelease {
|
|
109
|
+
/** @internal */
|
|
58
110
|
id: number;
|
|
111
|
+
/** @public */
|
|
59
112
|
tag_name: string;
|
|
113
|
+
/** @internal */
|
|
60
114
|
target_commitish: string;
|
|
115
|
+
/** @internal */
|
|
61
116
|
draft: boolean;
|
|
117
|
+
/** @internal */
|
|
62
118
|
prerelease: boolean;
|
|
119
|
+
/** @internal */
|
|
63
120
|
html_url: string;
|
|
64
|
-
|
|
121
|
+
/** @public */
|
|
122
|
+
assets: Array<{
|
|
123
|
+
/** @internal */
|
|
124
|
+
name: string;
|
|
125
|
+
/** @internal */
|
|
126
|
+
url: string;
|
|
127
|
+
/** @internal */
|
|
128
|
+
browser_download_url: string;
|
|
129
|
+
}>;
|
|
65
130
|
}
|
|
66
131
|
|
|
132
|
+
/** @internal */
|
|
67
133
|
export function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile> {
|
|
68
134
|
const profiles = new Map<string, GitHubProfile>();
|
|
69
135
|
for (const [name, raw] of Object.entries(
|
|
@@ -99,6 +165,7 @@ export function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile>
|
|
|
99
165
|
return profiles;
|
|
100
166
|
}
|
|
101
167
|
|
|
168
|
+
/** @internal */
|
|
102
169
|
export function assertGitHubRepository(profile: GitHubProfile, owner: string, repo: string): void {
|
|
103
170
|
if (
|
|
104
171
|
!/^[a-z0-9-]+$/i.test(owner) ||
|
|
@@ -116,8 +183,13 @@ export function assertGitHubRepository(profile: GitHubProfile, owner: string, re
|
|
|
116
183
|
}
|
|
117
184
|
}
|
|
118
185
|
|
|
186
|
+
/** @public */
|
|
119
187
|
export class GitHubClient extends RepositoryHttpClient {
|
|
120
|
-
|
|
188
|
+
/** @internal */
|
|
189
|
+
constructor(
|
|
190
|
+
/** @internal */
|
|
191
|
+
readonly profile: GitHubProfile,
|
|
192
|
+
) {
|
|
121
193
|
super("GitHub", profile.apiBaseUrl, {
|
|
122
194
|
Accept: "application/vnd.github+json",
|
|
123
195
|
Authorization: `Bearer ${profile.token}`,
|
|
@@ -125,6 +197,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
125
197
|
});
|
|
126
198
|
}
|
|
127
199
|
|
|
200
|
+
/** @internal */
|
|
128
201
|
protected override response(path: string, init: RequestInit = {}): Promise<Response> {
|
|
129
202
|
return super.response(path, {
|
|
130
203
|
...init,
|
|
@@ -133,11 +206,13 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
133
206
|
});
|
|
134
207
|
}
|
|
135
208
|
|
|
209
|
+
/** @internal */
|
|
136
210
|
protected override repositoryPath(owner: string, repo: string): string {
|
|
137
211
|
assertGitHubRepository(this.profile, owner, repo);
|
|
138
212
|
return super.repositoryPath(owner, repo);
|
|
139
213
|
}
|
|
140
214
|
|
|
215
|
+
/** @internal */
|
|
141
216
|
async listRepositories() {
|
|
142
217
|
return (
|
|
143
218
|
await this.pages<GitHubRepository>(
|
|
@@ -153,18 +228,24 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
153
228
|
repo.has_issues,
|
|
154
229
|
);
|
|
155
230
|
}
|
|
231
|
+
/** @internal */
|
|
156
232
|
async listOpenIssues(owner: string, repo: string) {
|
|
157
233
|
return (
|
|
158
|
-
await this.pages<
|
|
159
|
-
|
|
160
|
-
|
|
234
|
+
await this.pages<
|
|
235
|
+
GitHubIssue & {
|
|
236
|
+
/** @internal */
|
|
237
|
+
pull_request?: unknown;
|
|
238
|
+
}
|
|
239
|
+
>(`${this.repositoryPath(owner, repo)}/issues?state=open`)
|
|
161
240
|
).filter((issue) => !issue.pull_request);
|
|
162
241
|
}
|
|
242
|
+
/** @internal */
|
|
163
243
|
listIssueEvents(owner: string, repo: string, number: number) {
|
|
164
244
|
return this.pages<GitHubLabelEvent>(
|
|
165
245
|
`${this.repositoryPath(owner, repo)}/issues/${number}/events`,
|
|
166
246
|
);
|
|
167
247
|
}
|
|
248
|
+
/** @internal */
|
|
168
249
|
async isOrganizationMember(login: string): Promise<boolean> {
|
|
169
250
|
if (!this.profile.allowedOrganization) return true;
|
|
170
251
|
if (!/^[a-z0-9-]+$/i.test(login)) return false;
|
|
@@ -181,6 +262,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
181
262
|
throw error;
|
|
182
263
|
}
|
|
183
264
|
}
|
|
265
|
+
/** @internal */
|
|
184
266
|
async authorizedTrigger(
|
|
185
267
|
owner: string,
|
|
186
268
|
repo: string,
|
|
@@ -190,6 +272,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
190
272
|
) {
|
|
191
273
|
return authorizedTrigger(this, owner, repo, number, trigger, done);
|
|
192
274
|
}
|
|
275
|
+
/** @public */
|
|
193
276
|
async resolveGitIdentity(profile: string): Promise<GitHubGitIdentity> {
|
|
194
277
|
const user = await this.request<{ login: string; name: string | null; id: number }>("/user");
|
|
195
278
|
if (user.login !== this.profile.botLogin)
|
|
@@ -202,24 +285,30 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
202
285
|
email: `${user.id}+${user.login}@users.noreply.github.com`,
|
|
203
286
|
};
|
|
204
287
|
}
|
|
288
|
+
/** @public */
|
|
205
289
|
updateIssue(owner: string, repo: string, number: number, patch: Record<string, unknown>) {
|
|
206
290
|
return this.request<GitHubIssue>(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
|
|
207
291
|
method: "PATCH",
|
|
208
292
|
body: JSON.stringify(patch),
|
|
209
293
|
});
|
|
210
294
|
}
|
|
295
|
+
/** @internal */
|
|
296
|
+
listLabels(owner: string, repo: string) {
|
|
297
|
+
return this.pages<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`);
|
|
298
|
+
}
|
|
299
|
+
/** @internal */
|
|
300
|
+
createLabel(owner: string, repo: string, name: string) {
|
|
301
|
+
return this.request<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`, {
|
|
302
|
+
method: "POST",
|
|
303
|
+
body: JSON.stringify({ name, color: "238636" }),
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/** @internal */
|
|
211
307
|
async ensureLabel(owner: string, repo: string, name: string) {
|
|
212
|
-
const labels = await this.
|
|
213
|
-
|
|
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
|
-
);
|
|
308
|
+
const labels = await this.listLabels(owner, repo);
|
|
309
|
+
return labels.find((label) => label.name === name) ?? this.createLabel(owner, repo, name);
|
|
222
310
|
}
|
|
311
|
+
/** @internal */
|
|
223
312
|
addFeedbackReaction(owner: string, repo: string, kind: string, id: number) {
|
|
224
313
|
const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
|
|
225
314
|
return this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {
|
|
@@ -227,6 +316,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
227
316
|
body: JSON.stringify({ content: "eyes" }),
|
|
228
317
|
});
|
|
229
318
|
}
|
|
319
|
+
/** @internal */
|
|
230
320
|
async replyFeedback(
|
|
231
321
|
owner: string,
|
|
232
322
|
repo: string,
|
|
@@ -236,22 +326,23 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
236
326
|
body: string,
|
|
237
327
|
) {
|
|
238
328
|
if (kind === "inline")
|
|
239
|
-
return this.
|
|
329
|
+
return this.writeJson(
|
|
240
330
|
`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
body: JSON.stringify({ body }),
|
|
244
|
-
},
|
|
331
|
+
"POST",
|
|
332
|
+
{ body },
|
|
245
333
|
);
|
|
246
334
|
return this.addIssueComment(owner, repo, pr, body);
|
|
247
335
|
}
|
|
248
336
|
|
|
337
|
+
/** @internal */
|
|
249
338
|
getCommit(owner: string, repo: string, ref: string) {
|
|
250
|
-
return this.request<{
|
|
251
|
-
|
|
252
|
-
|
|
339
|
+
return this.request<{
|
|
340
|
+
/** @internal */
|
|
341
|
+
sha: string;
|
|
342
|
+
}>(`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`);
|
|
253
343
|
}
|
|
254
344
|
|
|
345
|
+
/** @public */
|
|
255
346
|
async isAncestor(owner: string, repo: string, ancestor: string, descendant: string) {
|
|
256
347
|
const comparison = await this.request<{ status: string }>(
|
|
257
348
|
`${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`,
|
|
@@ -259,6 +350,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
259
350
|
return comparison.status === "identical" || comparison.status === "ahead";
|
|
260
351
|
}
|
|
261
352
|
|
|
353
|
+
/** @public */
|
|
262
354
|
async listPullRequestFeedback(
|
|
263
355
|
owner: string,
|
|
264
356
|
repo: string,
|
|
@@ -350,6 +442,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
350
442
|
return feedback;
|
|
351
443
|
}
|
|
352
444
|
|
|
445
|
+
/** @public */
|
|
353
446
|
async getCheckSummary(owner: string, repo: string, headSha: string): Promise<GitHubCheckSummary> {
|
|
354
447
|
const runs: Array<Record<string, unknown>> = [];
|
|
355
448
|
for (let page = 1; ; page++) {
|
|
@@ -376,7 +469,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
376
469
|
};
|
|
377
470
|
}
|
|
378
471
|
|
|
379
|
-
/** Human feedback checked against current membership; delivery receipts use raw reads. */
|
|
472
|
+
/** Human feedback checked against current membership; delivery receipts use raw reads. @internal */
|
|
380
473
|
async listActionablePullRequestFeedback(
|
|
381
474
|
owner: string,
|
|
382
475
|
repo: string,
|
|
@@ -389,6 +482,7 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
389
482
|
);
|
|
390
483
|
}
|
|
391
484
|
|
|
485
|
+
/** @internal */
|
|
392
486
|
listFeedbackReplies(owner: string, repo: string, pr: number, kind: string) {
|
|
393
487
|
return kind === "inline"
|
|
394
488
|
? this.pages<Record<string, unknown>>(
|
|
@@ -397,19 +491,30 @@ export class GitHubClient extends RepositoryHttpClient {
|
|
|
397
491
|
: this.listIssueComments(owner, repo, pr);
|
|
398
492
|
}
|
|
399
493
|
|
|
494
|
+
/** @internal */
|
|
400
495
|
listFeedbackReactions(owner: string, repo: string, kind: string, id: number) {
|
|
401
496
|
if (kind !== "inline" && kind !== "conversation")
|
|
402
497
|
throw new Error("Reviews do not support reactions");
|
|
403
498
|
const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
|
|
404
|
-
return this.pages<{
|
|
405
|
-
|
|
406
|
-
|
|
499
|
+
return this.pages<{
|
|
500
|
+
/** @internal */
|
|
501
|
+
id: number;
|
|
502
|
+
/** @internal */
|
|
503
|
+
content: string;
|
|
504
|
+
/** @internal */
|
|
505
|
+
user: {
|
|
506
|
+
/** @internal */
|
|
507
|
+
login: string;
|
|
508
|
+
};
|
|
509
|
+
}>(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`);
|
|
407
510
|
}
|
|
408
511
|
|
|
512
|
+
/** @internal */
|
|
409
513
|
listReleases(owner: string, repo: string) {
|
|
410
514
|
return this.pages<GitHubRelease>(`${this.repositoryPath(owner, repo)}/releases`);
|
|
411
515
|
}
|
|
412
516
|
|
|
517
|
+
/** @public */
|
|
413
518
|
downloadReleaseAsset(asset: GitHubRelease["assets"][number]): Promise<string> {
|
|
414
519
|
const url = new URL(asset.url);
|
|
415
520
|
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,39 +85,65 @@ 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<{
|
|
100
148
|
profile: string;
|
|
101
149
|
owner: string;
|
|
@@ -107,29 +155,34 @@ export const githubExternal = {
|
|
|
107
155
|
describeEvent: describeGitHubEvent,
|
|
108
156
|
label: "GitHub Actions failures",
|
|
109
157
|
}),
|
|
158
|
+
/** @public */
|
|
110
159
|
issueCancelled: defineExternalActionSource<GitHubIssueCancelledSourceConfig>({
|
|
111
160
|
kind: GITHUB_ISSUE_CANCELLED_KIND,
|
|
112
161
|
describeEvent: () => ({ summary: "Source issue cancelled" }),
|
|
113
162
|
label: "GitHub source issue cancelled",
|
|
114
163
|
description: "Fires when the source issue closes or loses its trigger label",
|
|
115
164
|
}),
|
|
165
|
+
/** @public */
|
|
116
166
|
pullRequestTerminal: defineExternalActionSource<GitHubPullRequestTerminalSourceConfig>({
|
|
117
167
|
kind: GITHUB_PR_TERMINAL_KIND,
|
|
118
168
|
describeEvent: describeGitHubEvent,
|
|
119
169
|
label: "GitHub pull request merged or closed",
|
|
120
170
|
description: "Fires when the tracked pull request reaches a terminal state",
|
|
121
171
|
}),
|
|
172
|
+
/** @public */
|
|
122
173
|
pullRequestFeedback: defineExternalActionSource<GitHubFeedbackSourceConfig>({
|
|
123
174
|
kind: GITHUB_PR_FEEDBACK_KIND,
|
|
124
175
|
describeEvent: () => ({ summary: "Pull request feedback received" }),
|
|
125
176
|
label: "GitHub pull request feedback",
|
|
126
177
|
description: "Fires after unseen human feedback has been quiet long enough to batch",
|
|
127
178
|
}),
|
|
179
|
+
/** @internal */
|
|
128
180
|
releaseContaining: defineExternalActionSource<GitHubReleaseSourceConfig>({
|
|
129
181
|
kind: GITHUB_RELEASE_KIND,
|
|
130
182
|
label: "Published GitHub release",
|
|
131
183
|
description: "Fires when a published release contains the tracked merge commit",
|
|
132
184
|
}),
|
|
185
|
+
/** @public */
|
|
133
186
|
pullRequestState: defineExternalActionSource<GitHubPullRequestSourceConfig>({
|
|
134
187
|
kind: GITHUB_PR_STATE_KIND,
|
|
135
188
|
describeEvent: describeGitHubEvent,
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import type { ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes";
|
|
2
1
|
import { coreHostCapabilities, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
3
2
|
import { type GitHubIntegration, githubIntegration } from "./capability.js";
|
|
4
3
|
import { GitHubClient, parseGitHubProfiles } from "./client.js";
|
|
5
4
|
import { createGitHubProvider } from "./provider.js";
|
|
6
5
|
import { registerGitHubTools } from "./tools.js";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
/** @internal */
|
|
8
|
+
const manifest = {
|
|
9
|
+
id: "github",
|
|
10
|
+
/** @internal */
|
|
11
|
+
version: "0.1.9",
|
|
12
|
+
} as const;
|
|
9
13
|
|
|
14
|
+
/** @public */
|
|
10
15
|
const extension: LeitwerkExtensionModule = {
|
|
11
16
|
manifest,
|
|
12
17
|
setupServer(api, config) {
|
|
@@ -22,24 +27,39 @@ const extension: LeitwerkExtensionModule = {
|
|
|
22
27
|
},
|
|
23
28
|
};
|
|
24
29
|
|
|
25
|
-
export * from "./capability.js";
|
|
26
|
-
export * from "./client.js";
|
|
27
|
-
export * from "./external.js";
|
|
28
30
|
export default extension;
|
|
29
31
|
|
|
30
|
-
/** Register shared tools and polling with an explicit integration. */
|
|
32
|
+
/** Register shared tools and polling with an explicit integration. @public */
|
|
31
33
|
export function setupGitHubIntegration(
|
|
32
34
|
api: Parameters<NonNullable<LeitwerkExtensionModule["setupServer"]>>[0],
|
|
33
35
|
integration: GitHubIntegration,
|
|
34
|
-
options: {
|
|
36
|
+
options: {
|
|
37
|
+
/** @public */
|
|
38
|
+
now?: () => number;
|
|
39
|
+
} = {},
|
|
35
40
|
) {
|
|
36
41
|
api.provide(githubIntegration, integration);
|
|
37
42
|
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
38
43
|
if (!deps || Array.isArray(deps)) return;
|
|
39
|
-
registerGitHubTools(api, integration
|
|
44
|
+
registerGitHubTools(api, integration);
|
|
40
45
|
return createGitHubProvider(deps, integration, options);
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
export
|
|
48
|
+
export { resolveGitHubProjectBinding } from "./binding.js";
|
|
49
|
+
export type { GitHubIntegration } from "./capability.js";
|
|
50
|
+
export { githubIntegration } from "./capability.js";
|
|
51
|
+
export type {
|
|
52
|
+
GitHubCheckSummary,
|
|
53
|
+
GitHubGitIdentity,
|
|
54
|
+
GitHubIssue,
|
|
55
|
+
GitHubPullRequest,
|
|
56
|
+
} from "./client.js";
|
|
57
|
+
export {
|
|
58
|
+
GITHUB_CHECKS_KIND,
|
|
59
|
+
GITHUB_ISSUE_CANCELLED_KIND,
|
|
60
|
+
GITHUB_PR_FEEDBACK_KIND,
|
|
61
|
+
GITHUB_PR_STATE_KIND,
|
|
62
|
+
GITHUB_PR_TERMINAL_KIND,
|
|
63
|
+
githubExternal,
|
|
64
|
+
} from "./external.js";
|
|
65
|
+
export { githubIssueWatcherSource } from "./issue-watcher.js";
|
package/src/issue-watcher.ts
CHANGED
|
@@ -6,19 +6,34 @@ import {
|
|
|
6
6
|
} from "@leitwerk-dev/process-sdk";
|
|
7
7
|
import type { GitHubIssue, GitHubRepository } from "./client.js";
|
|
8
8
|
|
|
9
|
+
/** @public */
|
|
9
10
|
export interface GitHubIssueWatcherConfig extends RepositoryIssueWatcherConfig {}
|
|
10
11
|
|
|
12
|
+
/** @public */
|
|
11
13
|
export interface GitHubIssueWatcherEvent {
|
|
12
|
-
|
|
14
|
+
/** @public */
|
|
15
|
+
authorization: {
|
|
16
|
+
/** @internal */
|
|
17
|
+
actor: string;
|
|
18
|
+
/** @internal */
|
|
19
|
+
eventId: number;
|
|
20
|
+
};
|
|
21
|
+
/** @public */
|
|
13
22
|
profile: string;
|
|
23
|
+
/** @public */
|
|
14
24
|
repository: GitHubRepository;
|
|
25
|
+
/** @public */
|
|
15
26
|
issue: GitHubIssue;
|
|
27
|
+
/** @public */
|
|
16
28
|
labels: {
|
|
29
|
+
/** @public */
|
|
17
30
|
trigger: string;
|
|
31
|
+
/** @public */
|
|
18
32
|
done: string;
|
|
19
33
|
};
|
|
20
34
|
}
|
|
21
35
|
|
|
36
|
+
/** @public */
|
|
22
37
|
export const githubIssueWatcherSource = defineProcessWatcherSource<
|
|
23
38
|
GitHubIssueWatcherConfig,
|
|
24
39
|
GitHubIssueWatcherEvent
|