forges 0.0.0 → 0.1.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/LICENCE +21 -0
- package/README.md +72 -0
- package/dist/azure-devops/index.d.mts +2 -0
- package/dist/azure-devops/index.mjs +1 -0
- package/dist/azure-devops-DwQvL4TV.mjs +1355 -0
- package/dist/bitbucket/index.d.mts +2 -0
- package/dist/bitbucket/index.mjs +1 -0
- package/dist/bitbucket-CpcfJlYi.mjs +1171 -0
- package/dist/crypto-CQNEyYHD.mjs +156 -0
- package/dist/cursor-origin/index.d.mts +2 -0
- package/dist/cursor-origin/index.mjs +1 -0
- package/dist/cursor-origin-BhqYx2oW.mjs +980 -0
- package/dist/define-B2_4ob2i.d.mts +307 -0
- package/dist/define-D3yEXtKK.mjs +2276 -0
- package/dist/env.d.mts +46 -0
- package/dist/env.mjs +283 -0
- package/dist/fake/index.d.mts +227 -0
- package/dist/fake/index.mjs +1001 -0
- package/dist/fetch-D4pSRvvA.d.mts +1723 -0
- package/dist/forgejo/index.d.mts +2 -0
- package/dist/forgejo/index.mjs +1 -0
- package/dist/forgejo-BCefbHUN.mjs +2005 -0
- package/dist/gitea/index.d.mts +2 -0
- package/dist/gitea/index.mjs +22 -0
- package/dist/gitee/index.d.mts +2 -0
- package/dist/gitee/index.mjs +1 -0
- package/dist/gitee-CA-f7Rs8.mjs +1272 -0
- package/dist/github/index.d.mts +2 -0
- package/dist/github/index.mjs +1 -0
- package/dist/github-B0umL8_f.mjs +3259 -0
- package/dist/gitlab/index.d.mts +2 -0
- package/dist/gitlab/index.mjs +1 -0
- package/dist/gitlab-Bsr__Z0C.mjs +2378 -0
- package/dist/graphql-D7uGzZTf.mjs +366 -0
- package/dist/index-BQ6VS31s.d.mts +32 -0
- package/dist/index-C-jz9Mo3.d.mts +16 -0
- package/dist/index-C4fYzmK3.d.mts +102 -0
- package/dist/index-CQiIX4SH.d.mts +27 -0
- package/dist/index-CTj5gQzl.d.mts +35 -0
- package/dist/index-CliBWzOF.d.mts +23 -0
- package/dist/index-Cz_y-t3d.d.mts +36 -0
- package/dist/index-DEt25E1w.d.mts +77 -0
- package/dist/index-DIuS0EOy.d.mts +43 -0
- package/dist/index-uSpsMCrC.d.mts +26 -0
- package/dist/index.d.mts +41 -0
- package/dist/index.mjs +13 -0
- package/dist/kit.d.mts +183 -0
- package/dist/kit.mjs +4 -0
- package/dist/provider-CoZ7cCxp.d.mts +1439 -0
- package/dist/provider-Ed1YhkQN.mjs +169 -0
- package/dist/pushin/index.d.mts +2 -0
- package/dist/pushin/index.mjs +1 -0
- package/dist/pushin-CkxgJ2cU.mjs +343 -0
- package/dist/schema/Actor.json +96 -0
- package/dist/schema/AlertSupport.json +49 -0
- package/dist/schema/AuthKind.json +15 -0
- package/dist/schema/Branch.json +31 -0
- package/dist/schema/ChangedFile.json +58 -0
- package/dist/schema/Check.json +169 -0
- package/dist/schema/CheckRef.json +114 -0
- package/dist/schema/CheckState.json +14 -0
- package/dist/schema/ChecksSummary.json +34 -0
- package/dist/schema/CiJob.json +186 -0
- package/dist/schema/CiJobRef.json +132 -0
- package/dist/schema/CiRun.json +234 -0
- package/dist/schema/CiRunRef.json +103 -0
- package/dist/schema/CodeFragment.json +19 -0
- package/dist/schema/CodeMatch.json +128 -0
- package/dist/schema/Collaborator.json +169 -0
- package/dist/schema/Comment.json +336 -0
- package/dist/schema/CommentRef.json +158 -0
- package/dist/schema/Commit.json +307 -0
- package/dist/schema/CommitRef.json +104 -0
- package/dist/schema/CommitSignature.json +118 -0
- package/dist/schema/Comparison.json +355 -0
- package/dist/schema/Cursor.json +21 -0
- package/dist/schema/EventAction.json +33 -0
- package/dist/schema/EventDetail.json +649 -0
- package/dist/schema/EventKind.json +26 -0
- package/dist/schema/FileContent.json +73 -0
- package/dist/schema/FileStatus.json +15 -0
- package/dist/schema/ForgeCapabilities.json +737 -0
- package/dist/schema/ForgeEvent.json +789 -0
- package/dist/schema/ForgeInstance.json +7 -0
- package/dist/schema/ForgeKind.json +32 -0
- package/dist/schema/ForgeWarning.json +49 -0
- package/dist/schema/ForgeWarningCode.json +7 -0
- package/dist/schema/GetManyResult.json +699 -0
- package/dist/schema/Installation.json +131 -0
- package/dist/schema/InstallationToken.json +31 -0
- package/dist/schema/KnownForgeKind.json +19 -0
- package/dist/schema/Label.json +22 -0
- package/dist/schema/MergeMethod.json +14 -0
- package/dist/schema/Milestone.json +40 -0
- package/dist/schema/Notification.json +498 -0
- package/dist/schema/NotificationReason.json +28 -0
- package/dist/schema/NotificationRef.json +60 -0
- package/dist/schema/NotificationSubject.json +376 -0
- package/dist/schema/PerKind.json +49 -0
- package/dist/schema/PullBranches.json +125 -0
- package/dist/schema/PushCommit.json +24 -0
- package/dist/schema/Reaction.json +148 -0
- package/dist/schema/ReactionContent.json +17 -0
- package/dist/schema/ReactionSummary.json +70 -0
- package/dist/schema/Release.json +286 -0
- package/dist/schema/ReleaseAsset.json +169 -0
- package/dist/schema/ReleaseAssetRef.json +138 -0
- package/dist/schema/ReleaseRef.json +107 -0
- package/dist/schema/Repo.json +354 -0
- package/dist/schema/RepoFeatures.json +35 -0
- package/dist/schema/RepoPermissions.json +35 -0
- package/dist/schema/RepoRef.json +77 -0
- package/dist/schema/RepoRole.json +15 -0
- package/dist/schema/RepoVisibility.json +12 -0
- package/dist/schema/Review.json +371 -0
- package/dist/schema/ReviewComment.json +280 -0
- package/dist/schema/ReviewCommentInput.json +34 -0
- package/dist/schema/ReviewRef.json +158 -0
- package/dist/schema/ReviewState.json +15 -0
- package/dist/schema/Reviewer.json +133 -0
- package/dist/schema/SecurityAlert.json +219 -0
- package/dist/schema/SecurityAlertKind.json +14 -0
- package/dist/schema/SecurityAlertRef.json +122 -0
- package/dist/schema/SecuritySeverity.json +14 -0
- package/dist/schema/SourceKind.json +12 -0
- package/dist/schema/SubscriptionState.json +12 -0
- package/dist/schema/Support.json +23 -0
- package/dist/schema/Tag.json +25 -0
- package/dist/schema/TextLimits.json +18 -0
- package/dist/schema/Thread.json +653 -0
- package/dist/schema/ThreadKind.json +14 -0
- package/dist/schema/ThreadRef.json +131 -0
- package/dist/schema/ThreadStack.json +146 -0
- package/dist/schema/ThreadState.json +13 -0
- package/dist/schema/TreeEntry.json +46 -0
- package/dist/schema/TreeEntryType.json +13 -0
- package/dist/schema/UpsertCommentResult.json +355 -0
- package/dist/schema/User.json +123 -0
- package/dist/schema/Webhook.json +188 -0
- package/dist/schema/WebhookDeliveryRecord.json +173 -0
- package/dist/schema/WebhookDeliveryRef.json +135 -0
- package/dist/schema/WebhookRef.json +105 -0
- package/dist/schema/index.d.mts +4 -0
- package/dist/schema/index.mjs +3219 -0
- package/dist/tangled/index.d.mts +2 -0
- package/dist/tangled/index.mjs +1 -0
- package/dist/tangled-ChdPmiv-.mjs +1570 -0
- package/dist/testing/index.d.mts +123 -0
- package/dist/testing/index.mjs +242 -0
- package/dist/webhooks-rn9-8lxT.mjs +70 -0
- package/package.json +115 -3
- package/dist/.gitkeep +0 -0
|
@@ -0,0 +1,1439 @@
|
|
|
1
|
+
import { $ as CiRunQuery, $n as WebhookInput, At as GetManyResult, B as Actor, Bt as Notification, Ct as ForgeEvent, Dn as SecurityAlertListOptions, Dt as ForgeOrigin, En as SecurityAlertKind, Et as ForgeKind, Fn as Thread, Ft as LabelInput, G as Check, Gn as TreeOptions, Gt as Page, H as BaseOptions, Hn as ThreadUpdateInput, In as ThreadCreateInput, It as ListOptions, Jn as User, K as CheckRef, Kn as UpsertCommentInput, Kt as PageOptions, Ln as ThreadKind, Mn as Support, Mt as InstallationToken, Nn as Tag, Ot as ForgeWarning, Pn as TextLimits, Pt as Label, Q as CiRun, Qn as WebhookEventType, Qt as ReactionContent, Rn as ThreadQuery, Rt as MergeOptions, Tn as SecurityAlert, Tt as ForgeInstance, U as Branch, Un as TreeEntry, Ut as NotificationRef, V as ApproveAndMergeOptions, Vt as NotificationListOptions, W as ChangedFile, X as CiJob, Xn as WebhookDeliveryRecord, Yn as Webhook, Z as CiJobRef, Zn as WebhookDeliveryRef, Zt as Reaction, a as FetcherOptions, an as ReleaseUpdate, at as Comment, bn as ReviewInput, ct as CommitQuery, dn as RepoRef, en as Release, er as WebhookRef, et as CiRunRef, fn as RepoRole, ft as Comparison, gn as Review, hn as ResolvedThreadRef, in as ReleaseRef, it as Collaborator, jn as SubscriptionState, jt as Installation, n as FetchLike, nn as ReleaseAssetRef, nt as CodeMatch, on as Repo, ot as CommentRef, pn as RepoSearchQuery, q as CheckReportInput, qn as UpsertCommentResult, rn as ReleaseInput, rt as CodeSearchQuery, s as ForgeRequest, st as Commit, tr as WebhookUpdate, un as RepoQuery, ut as CommitSearchQuery, vt as FileContent, wn as SearchQuery, xn as ReviewRef, xt as FileOptions, yn as ReviewEvent, zn as ThreadRef, zt as Milestone } from "./fetch-D4pSRvvA.mjs";
|
|
2
|
+
//#region src/capability-table.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* One row of the capability table: where a capability is declared on `ProviderSpec`,
|
|
5
|
+
* where it lands on `ForgeCapabilities`, and which `ForgeProvider` verbs it covers.
|
|
6
|
+
* `capabilitiesOf()`, `supports()` and the capability matrix derive from the table.
|
|
7
|
+
*/
|
|
8
|
+
interface CapabilityEntry {
|
|
9
|
+
/** Where the support lands on `ForgeCapabilities`, dot-separated. */
|
|
10
|
+
capability: string;
|
|
11
|
+
/** Where the verb is declared on `ProviderSpec`, dot-separated. */
|
|
12
|
+
spec?: string;
|
|
13
|
+
/** Verbs on `ForgeProvider` this capability covers. */
|
|
14
|
+
verbs?: readonly string[];
|
|
15
|
+
/** Support is declared per thread kind. */
|
|
16
|
+
perKind?: boolean;
|
|
17
|
+
/** The capability is computed by core rather than read from a declared verb. */
|
|
18
|
+
derived?: "experimental" | "poll" | "webhook" | "threadEvents" | "upsertComment" | "subscriptionSet" | "approve" | "approveAndMerge" | "alertKinds" | "eventKinds" | "authKinds" | "limits";
|
|
19
|
+
/** The verbs change state, so `readOnly` and anonymous providers reject them. */
|
|
20
|
+
write?: boolean;
|
|
21
|
+
/** The verbs need an account, so anonymous providers reject them. */
|
|
22
|
+
account?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Rows omit what follows from the rest. `spec` defaults to the capability's
|
|
26
|
+
* path, with `writes.*` declared on `threads.*` and a `listing` declared as its
|
|
27
|
+
* page. `verbs` defaults to the `spec` path, plus its iterable when the path
|
|
28
|
+
* names a page (`repos.labelsPage` also covers `repos.labels`). An explicit
|
|
29
|
+
* `spec` marks a capability grouped apart from its verbs.
|
|
30
|
+
*/
|
|
31
|
+
declare const TABLE: readonly [{
|
|
32
|
+
readonly capability: "experimental";
|
|
33
|
+
readonly derived: "experimental";
|
|
34
|
+
}, {
|
|
35
|
+
readonly capability: "sources.poll";
|
|
36
|
+
readonly derived: "poll";
|
|
37
|
+
}, {
|
|
38
|
+
readonly capability: "sources.webhook";
|
|
39
|
+
readonly derived: "webhook";
|
|
40
|
+
readonly verbs: readonly ["webhooks.verify", "webhooks.ingest"];
|
|
41
|
+
}, {
|
|
42
|
+
readonly capability: "sources.subscribe";
|
|
43
|
+
}, {
|
|
44
|
+
readonly capability: "repos.get";
|
|
45
|
+
}, {
|
|
46
|
+
readonly capability: "users.get";
|
|
47
|
+
}, {
|
|
48
|
+
readonly capability: "users.me";
|
|
49
|
+
readonly account: true;
|
|
50
|
+
}, {
|
|
51
|
+
readonly capability: "repos.list";
|
|
52
|
+
readonly account: true;
|
|
53
|
+
readonly listing: true;
|
|
54
|
+
}, {
|
|
55
|
+
readonly capability: "repos.labels";
|
|
56
|
+
readonly listing: true;
|
|
57
|
+
}, {
|
|
58
|
+
readonly capability: "repos.createLabel";
|
|
59
|
+
readonly write: true;
|
|
60
|
+
}, {
|
|
61
|
+
readonly capability: "repos.milestones";
|
|
62
|
+
readonly listing: true;
|
|
63
|
+
}, {
|
|
64
|
+
readonly capability: "repos.collaborators";
|
|
65
|
+
readonly listing: true;
|
|
66
|
+
}, {
|
|
67
|
+
readonly capability: "repos.permissionFor";
|
|
68
|
+
}, {
|
|
69
|
+
readonly capability: "repos.addCollaborator";
|
|
70
|
+
readonly write: true;
|
|
71
|
+
}, {
|
|
72
|
+
readonly capability: "repos.assignableUsers";
|
|
73
|
+
readonly listing: true;
|
|
74
|
+
}, {
|
|
75
|
+
readonly capability: "repos.reviewerCandidates";
|
|
76
|
+
readonly listing: true;
|
|
77
|
+
}, {
|
|
78
|
+
readonly capability: "threads.get";
|
|
79
|
+
readonly perKind: true;
|
|
80
|
+
}, {
|
|
81
|
+
readonly capability: "threads.list";
|
|
82
|
+
readonly listing: true;
|
|
83
|
+
readonly perKind: true;
|
|
84
|
+
}, {
|
|
85
|
+
readonly capability: "threads.getMany";
|
|
86
|
+
}, {
|
|
87
|
+
readonly capability: "threads.events";
|
|
88
|
+
readonly spec: "threads.eventsPage";
|
|
89
|
+
readonly derived: "threadEvents";
|
|
90
|
+
}, {
|
|
91
|
+
readonly capability: "comments.list";
|
|
92
|
+
readonly spec: "threads.commentsPage";
|
|
93
|
+
readonly perKind: true;
|
|
94
|
+
}, {
|
|
95
|
+
readonly capability: "comments.edit";
|
|
96
|
+
readonly write: true;
|
|
97
|
+
readonly spec: "threads.editComment";
|
|
98
|
+
readonly perKind: true;
|
|
99
|
+
}, {
|
|
100
|
+
readonly capability: "comments.delete";
|
|
101
|
+
readonly write: true;
|
|
102
|
+
readonly spec: "threads.deleteComment";
|
|
103
|
+
readonly perKind: true;
|
|
104
|
+
}, {
|
|
105
|
+
readonly capability: "reactions.list";
|
|
106
|
+
readonly spec: "threads.reactionsPage";
|
|
107
|
+
readonly perKind: true;
|
|
108
|
+
}, {
|
|
109
|
+
readonly capability: "notifications.list";
|
|
110
|
+
readonly account: true;
|
|
111
|
+
readonly listing: true;
|
|
112
|
+
}, {
|
|
113
|
+
readonly capability: "notifications.markRead";
|
|
114
|
+
readonly account: true;
|
|
115
|
+
readonly write: true;
|
|
116
|
+
}, {
|
|
117
|
+
readonly capability: "notifications.markDone";
|
|
118
|
+
readonly account: true;
|
|
119
|
+
readonly write: true;
|
|
120
|
+
}, {
|
|
121
|
+
readonly capability: "notifications.unsubscribe";
|
|
122
|
+
readonly account: true;
|
|
123
|
+
readonly write: true;
|
|
124
|
+
}, {
|
|
125
|
+
readonly capability: "notifications.markAllRead";
|
|
126
|
+
readonly account: true;
|
|
127
|
+
readonly write: true;
|
|
128
|
+
}, {
|
|
129
|
+
readonly capability: "notifications.markAllDone";
|
|
130
|
+
readonly account: true;
|
|
131
|
+
readonly write: true;
|
|
132
|
+
}, {
|
|
133
|
+
readonly capability: "notifications.unreadCount";
|
|
134
|
+
readonly account: true;
|
|
135
|
+
}, {
|
|
136
|
+
readonly capability: "writes.comment";
|
|
137
|
+
readonly write: true;
|
|
138
|
+
readonly perKind: true;
|
|
139
|
+
}, {
|
|
140
|
+
readonly capability: "writes.upsertComment";
|
|
141
|
+
readonly write: true;
|
|
142
|
+
readonly derived: "upsertComment";
|
|
143
|
+
readonly verbs: readonly ["threads.upsertComment"];
|
|
144
|
+
}, {
|
|
145
|
+
readonly capability: "writes.close";
|
|
146
|
+
readonly write: true;
|
|
147
|
+
readonly perKind: true;
|
|
148
|
+
}, {
|
|
149
|
+
readonly capability: "writes.reopen";
|
|
150
|
+
readonly write: true;
|
|
151
|
+
readonly perKind: true;
|
|
152
|
+
}, {
|
|
153
|
+
readonly capability: "writes.create";
|
|
154
|
+
readonly write: true;
|
|
155
|
+
readonly perKind: true;
|
|
156
|
+
}, {
|
|
157
|
+
readonly capability: "writes.update";
|
|
158
|
+
readonly write: true;
|
|
159
|
+
readonly perKind: true;
|
|
160
|
+
}, {
|
|
161
|
+
readonly capability: "writes.setLabels";
|
|
162
|
+
readonly write: true;
|
|
163
|
+
readonly perKind: true;
|
|
164
|
+
}, {
|
|
165
|
+
readonly capability: "writes.addLabels";
|
|
166
|
+
readonly write: true;
|
|
167
|
+
readonly perKind: true;
|
|
168
|
+
}, {
|
|
169
|
+
readonly capability: "writes.removeLabels";
|
|
170
|
+
readonly write: true;
|
|
171
|
+
readonly perKind: true;
|
|
172
|
+
}, {
|
|
173
|
+
readonly capability: "writes.setMilestone";
|
|
174
|
+
readonly write: true;
|
|
175
|
+
readonly perKind: true;
|
|
176
|
+
}, {
|
|
177
|
+
readonly capability: "writes.react";
|
|
178
|
+
readonly write: true;
|
|
179
|
+
readonly spec: "threads.reactions";
|
|
180
|
+
readonly perKind: true;
|
|
181
|
+
readonly verbs: readonly ["threads.react", "threads.unreact"];
|
|
182
|
+
}, {
|
|
183
|
+
readonly capability: "writes.setAssignees";
|
|
184
|
+
readonly write: true;
|
|
185
|
+
readonly perKind: true;
|
|
186
|
+
}, {
|
|
187
|
+
readonly capability: "writes.requestReview";
|
|
188
|
+
readonly write: true;
|
|
189
|
+
readonly perKind: true;
|
|
190
|
+
}, {
|
|
191
|
+
readonly capability: "writes.merge";
|
|
192
|
+
readonly write: true;
|
|
193
|
+
}, {
|
|
194
|
+
readonly capability: "writes.approveAndMerge";
|
|
195
|
+
readonly write: true;
|
|
196
|
+
readonly derived: "approveAndMerge";
|
|
197
|
+
readonly verbs: readonly ["threads.approveAndMerge"];
|
|
198
|
+
}, {
|
|
199
|
+
readonly capability: "writes.transfer";
|
|
200
|
+
readonly write: true;
|
|
201
|
+
}, {
|
|
202
|
+
readonly capability: "writes.markDuplicate";
|
|
203
|
+
readonly write: true;
|
|
204
|
+
}, {
|
|
205
|
+
readonly capability: "subscriptions.get";
|
|
206
|
+
readonly account: true;
|
|
207
|
+
readonly spec: "threads.subscriptions";
|
|
208
|
+
readonly perKind: true;
|
|
209
|
+
readonly verbs: readonly ["threads.subscription"];
|
|
210
|
+
}, {
|
|
211
|
+
readonly capability: "subscriptions.set";
|
|
212
|
+
readonly write: true;
|
|
213
|
+
readonly derived: "subscriptionSet";
|
|
214
|
+
readonly verbs: readonly ["threads.subscribe", "threads.unsubscribe"];
|
|
215
|
+
}, {
|
|
216
|
+
readonly capability: "installations";
|
|
217
|
+
readonly account: true;
|
|
218
|
+
readonly verbs: readonly ["installations.list", "installations.listPage", "installations.get", "installations.token", "installations.repos", "installations.reposPage", "installations.provider", "installations.providers"];
|
|
219
|
+
}, {
|
|
220
|
+
readonly capability: "checks.thread";
|
|
221
|
+
readonly spec: "threads.checks";
|
|
222
|
+
readonly perKind: true;
|
|
223
|
+
}, {
|
|
224
|
+
readonly capability: "checks.list";
|
|
225
|
+
}, {
|
|
226
|
+
readonly capability: "checks.report";
|
|
227
|
+
readonly write: true;
|
|
228
|
+
}, {
|
|
229
|
+
readonly capability: "checks.rerun";
|
|
230
|
+
readonly write: true;
|
|
231
|
+
}, {
|
|
232
|
+
readonly capability: "ci.runs";
|
|
233
|
+
readonly listing: true;
|
|
234
|
+
}, {
|
|
235
|
+
readonly capability: "ci.run";
|
|
236
|
+
}, {
|
|
237
|
+
readonly capability: "ci.jobs";
|
|
238
|
+
readonly listing: true;
|
|
239
|
+
}, {
|
|
240
|
+
readonly capability: "ci.log";
|
|
241
|
+
}, {
|
|
242
|
+
readonly capability: "contents.file";
|
|
243
|
+
}, {
|
|
244
|
+
readonly capability: "contents.tree";
|
|
245
|
+
readonly listing: true;
|
|
246
|
+
}, {
|
|
247
|
+
readonly capability: "contents.branches";
|
|
248
|
+
readonly listing: true;
|
|
249
|
+
}, {
|
|
250
|
+
readonly capability: "contents.tags";
|
|
251
|
+
readonly listing: true;
|
|
252
|
+
}, {
|
|
253
|
+
readonly capability: "contents.resolveRef";
|
|
254
|
+
}, {
|
|
255
|
+
readonly capability: "contents.commits";
|
|
256
|
+
readonly listing: true;
|
|
257
|
+
}, {
|
|
258
|
+
readonly capability: "contents.commit";
|
|
259
|
+
}, {
|
|
260
|
+
readonly capability: "contents.compare";
|
|
261
|
+
}, {
|
|
262
|
+
readonly capability: "contents.threadFiles";
|
|
263
|
+
readonly spec: "threads.filesPage";
|
|
264
|
+
}, {
|
|
265
|
+
readonly capability: "contents.threadCommits";
|
|
266
|
+
readonly spec: "threads.commitsPage";
|
|
267
|
+
}, {
|
|
268
|
+
readonly capability: "reviews.list";
|
|
269
|
+
readonly spec: "threads.reviewsPage";
|
|
270
|
+
}, {
|
|
271
|
+
readonly capability: "reviews.create";
|
|
272
|
+
readonly write: true;
|
|
273
|
+
readonly spec: "threads.createReview";
|
|
274
|
+
}, {
|
|
275
|
+
readonly capability: "reviews.submit";
|
|
276
|
+
readonly write: true;
|
|
277
|
+
readonly spec: "threads.submitReview";
|
|
278
|
+
}, {
|
|
279
|
+
readonly capability: "reviews.approve";
|
|
280
|
+
readonly write: true;
|
|
281
|
+
readonly spec: "threads.approve";
|
|
282
|
+
readonly derived: "approve";
|
|
283
|
+
}, {
|
|
284
|
+
readonly capability: "reviews.resolveThread";
|
|
285
|
+
readonly write: true;
|
|
286
|
+
readonly spec: "threads.reviewThreads";
|
|
287
|
+
readonly verbs: readonly ["threads.resolveReviewThread", "threads.unresolveReviewThread"];
|
|
288
|
+
}, {
|
|
289
|
+
readonly capability: "releases.list";
|
|
290
|
+
readonly listing: true;
|
|
291
|
+
}, {
|
|
292
|
+
readonly capability: "releases.get";
|
|
293
|
+
}, {
|
|
294
|
+
readonly capability: "releases.latest";
|
|
295
|
+
}, {
|
|
296
|
+
readonly capability: "releases.getByTag";
|
|
297
|
+
}, {
|
|
298
|
+
readonly capability: "releases.downloadAsset";
|
|
299
|
+
}, {
|
|
300
|
+
readonly capability: "releases.create";
|
|
301
|
+
readonly write: true;
|
|
302
|
+
}, {
|
|
303
|
+
readonly capability: "releases.update";
|
|
304
|
+
readonly write: true;
|
|
305
|
+
}, {
|
|
306
|
+
readonly capability: "webhooks.list";
|
|
307
|
+
readonly account: true;
|
|
308
|
+
readonly listing: true;
|
|
309
|
+
}, {
|
|
310
|
+
readonly capability: "webhooks.create";
|
|
311
|
+
readonly write: true;
|
|
312
|
+
}, {
|
|
313
|
+
readonly capability: "webhooks.update";
|
|
314
|
+
readonly write: true;
|
|
315
|
+
}, {
|
|
316
|
+
readonly capability: "webhooks.delete";
|
|
317
|
+
readonly write: true;
|
|
318
|
+
}, {
|
|
319
|
+
readonly capability: "webhooks.rotateSecret";
|
|
320
|
+
readonly write: true;
|
|
321
|
+
}, {
|
|
322
|
+
readonly capability: "webhooks.deliveries";
|
|
323
|
+
readonly account: true;
|
|
324
|
+
readonly listing: true;
|
|
325
|
+
}, {
|
|
326
|
+
readonly capability: "webhooks.redeliver";
|
|
327
|
+
readonly write: true;
|
|
328
|
+
}, {
|
|
329
|
+
readonly capability: "search.threads";
|
|
330
|
+
readonly listing: true;
|
|
331
|
+
}, {
|
|
332
|
+
readonly capability: "search.repos";
|
|
333
|
+
readonly listing: true;
|
|
334
|
+
}, {
|
|
335
|
+
readonly capability: "search.commits";
|
|
336
|
+
readonly listing: true;
|
|
337
|
+
}, {
|
|
338
|
+
readonly capability: "search.code";
|
|
339
|
+
readonly listing: true;
|
|
340
|
+
}, {
|
|
341
|
+
readonly capability: "securityAlerts";
|
|
342
|
+
readonly derived: "alertKinds";
|
|
343
|
+
readonly verbs: readonly ["securityAlerts.list", "securityAlerts.listPage"];
|
|
344
|
+
}, {
|
|
345
|
+
readonly capability: "eventKinds";
|
|
346
|
+
readonly derived: "eventKinds";
|
|
347
|
+
}, {
|
|
348
|
+
readonly capability: "authKinds";
|
|
349
|
+
readonly derived: "authKinds";
|
|
350
|
+
}, {
|
|
351
|
+
readonly capability: "limits";
|
|
352
|
+
readonly derived: "limits";
|
|
353
|
+
}];
|
|
354
|
+
type DefaultSpec<C> = C extends `writes.${infer Name}` ? `threads.${Name}` : C;
|
|
355
|
+
type SpecOf<R> = R extends {
|
|
356
|
+
spec: infer S extends string;
|
|
357
|
+
} ? S : R extends {
|
|
358
|
+
derived: string;
|
|
359
|
+
} ? never : R extends {
|
|
360
|
+
capability: infer C extends string;
|
|
361
|
+
} ? R extends {
|
|
362
|
+
listing: true;
|
|
363
|
+
} ? `${DefaultSpec<C>}Page` : DefaultSpec<C> : never;
|
|
364
|
+
type WithIterable<S> = S extends `${infer Iterable}Page` ? Iterable | S : S;
|
|
365
|
+
type VerbsOf<R> = R extends {
|
|
366
|
+
verbs: readonly (infer V extends string)[];
|
|
367
|
+
} ? V : WithIterable<SpecOf<R>>;
|
|
368
|
+
/** A provider verb, named by its path on `ForgeProvider`. */
|
|
369
|
+
type ForgeVerb = VerbsOf<(typeof TABLE)[number]>;
|
|
370
|
+
/**
|
|
371
|
+
* Every capability with the verbs it covers and the flags that gate it, in the order the capability matrix lists them.
|
|
372
|
+
*/
|
|
373
|
+
declare const CAPABILITY_TABLE: readonly CapabilityEntry[];
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/web.d.ts
|
|
376
|
+
/** Something with a web page. */
|
|
377
|
+
type UrlTarget = {
|
|
378
|
+
repo: RepoRef;
|
|
379
|
+
} | {
|
|
380
|
+
thread: ThreadRef;
|
|
381
|
+
} | {
|
|
382
|
+
comment: CommentRef;
|
|
383
|
+
} | {
|
|
384
|
+
release: ReleaseRef;
|
|
385
|
+
} | {
|
|
386
|
+
file: {
|
|
387
|
+
repo: RepoRef;
|
|
388
|
+
path: string;
|
|
389
|
+
at: string;
|
|
390
|
+
line?: number;
|
|
391
|
+
};
|
|
392
|
+
} | {
|
|
393
|
+
compare: {
|
|
394
|
+
repo: RepoRef;
|
|
395
|
+
base: string;
|
|
396
|
+
head: string;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
/** What a forge web URL points at. `repo` is always set; the rest when the URL is that specific. */
|
|
400
|
+
interface ParsedForgeUrl {
|
|
401
|
+
repo: RepoRef;
|
|
402
|
+
thread?: ThreadRef;
|
|
403
|
+
comment?: CommentRef;
|
|
404
|
+
release?: ReleaseRef;
|
|
405
|
+
}
|
|
406
|
+
/** Options for `provider.referenceTo()`. */
|
|
407
|
+
interface ReferenceOptions {
|
|
408
|
+
/** Repository the reference is written in; a reference within it is the short form. */
|
|
409
|
+
from?: RepoRef;
|
|
410
|
+
/** Request the reference expanded to its title, where the forge supports it (GitLab's `+` suffix). */
|
|
411
|
+
expand?: boolean;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* How a provider builds and reads its web URLs. Paths are relative to
|
|
415
|
+
* `origin`; any builder may return `undefined` when the forge has no such page.
|
|
416
|
+
*/
|
|
417
|
+
interface WebLinks {
|
|
418
|
+
/** The origin of the forge website, such as `https://github.com`. */
|
|
419
|
+
origin: string;
|
|
420
|
+
/** The page of a repository. */
|
|
421
|
+
repo: (repo: RepoRef) => string;
|
|
422
|
+
/** The page of an issue or pull request. */
|
|
423
|
+
thread: (ref: ResolvedThreadRef) => string | undefined;
|
|
424
|
+
/** The page of a comment, anchored on its thread. */
|
|
425
|
+
comment?: (ref: CommentRef & {
|
|
426
|
+
thread: ResolvedThreadRef;
|
|
427
|
+
}) => string | undefined;
|
|
428
|
+
/** The page of a release. */
|
|
429
|
+
release?: (ref: ReleaseRef) => string | undefined;
|
|
430
|
+
/** The page of a file at a revision, optionally at a line. */
|
|
431
|
+
file?: (repo: RepoRef, path: string, at: string, line?: number) => string | undefined;
|
|
432
|
+
/** The page that compares two revisions. */
|
|
433
|
+
compare?: (repo: RepoRef, base: string, head: string) => string | undefined;
|
|
434
|
+
/** Reads a URL already known to be on `origin`, split into path segments. */
|
|
435
|
+
parse: (segments: string[], url: URL, origin: ForgeOrigin) => ParsedForgeUrl | undefined;
|
|
436
|
+
/** The forge's cross-reference syntax; `undefined` falls back to the thread URL. */
|
|
437
|
+
reference?: (ref: ResolvedThreadRef, sameRepo: boolean, expand: boolean) => string | undefined;
|
|
438
|
+
}
|
|
439
|
+
/** How a forge that lays out its website like GitHub differs from GitHub. */
|
|
440
|
+
interface GitHubShape {
|
|
441
|
+
/** The path segment of pull requests, such as `pull` or `pulls`. */
|
|
442
|
+
pull: string;
|
|
443
|
+
/** The forge has discussions, which are addressed like issues. */
|
|
444
|
+
discussions?: boolean;
|
|
445
|
+
/** Fragment for a comment id, for example `issuecomment-` or `note_`. */
|
|
446
|
+
commentFragment: string;
|
|
447
|
+
/** The path segment that leads to a file at a revision. */
|
|
448
|
+
file: (at: string) => string;
|
|
449
|
+
/** The URL fragment that selects a line of a file. */
|
|
450
|
+
lineFragment: (line: number) => string;
|
|
451
|
+
/** Reference prefix for pulls when it differs from issues. */
|
|
452
|
+
pullPrefix?: string;
|
|
453
|
+
/** Reserved owner segments. */
|
|
454
|
+
reserved?: readonly string[];
|
|
455
|
+
}
|
|
456
|
+
/** Web links for forges laid out like GitHub: `/{owner}/{name}/issues/{n}` and friends. */
|
|
457
|
+
declare function githubShapedWeb(origin: string, shape: GitHubShape): WebLinks;
|
|
458
|
+
/**
|
|
459
|
+
* Reads `url` with whichever of `providers` serves it.
|
|
460
|
+
* @param url The web URL to read.
|
|
461
|
+
* @param providers The providers to ask. The first that serves the URL answers.
|
|
462
|
+
*/
|
|
463
|
+
declare function parseForgeUrl(url: string | URL, providers: ReadonlyArray<{
|
|
464
|
+
parseUrl: (url: string | URL) => ParsedForgeUrl | undefined;
|
|
465
|
+
}>): ParsedForgeUrl | undefined;
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/provider.d.ts
|
|
468
|
+
/** No credentials: public reads only. Every write, notifications and subscriptions are unsupported. */
|
|
469
|
+
interface AnonymousAuth {
|
|
470
|
+
type: "anonymous";
|
|
471
|
+
}
|
|
472
|
+
/** A bearer or personal access token. */
|
|
473
|
+
interface TokenAuth {
|
|
474
|
+
type: "token";
|
|
475
|
+
/**
|
|
476
|
+
* Personal access token or OAuth access token. A function is called before
|
|
477
|
+
* every request, so a refreshed token applies without a new provider.
|
|
478
|
+
*/
|
|
479
|
+
token: string | (() => string | Promise<string>);
|
|
480
|
+
}
|
|
481
|
+
/** HTTP Basic credentials, for example a Bitbucket app password or Atlassian API token. */
|
|
482
|
+
interface BasicAuth {
|
|
483
|
+
type: "basic";
|
|
484
|
+
username: string;
|
|
485
|
+
/** The password, app password or API token. */
|
|
486
|
+
password: string;
|
|
487
|
+
}
|
|
488
|
+
/** App credentials. Omit `installationId` to act as the app itself. */
|
|
489
|
+
interface AppAuth {
|
|
490
|
+
type: "app";
|
|
491
|
+
appId: string | number;
|
|
492
|
+
/** PEM private key: RSA (PKCS#1 or PKCS#8) on GitHub, Ed25519 PKCS#8 on Cursor Origin. */
|
|
493
|
+
privateKey: string;
|
|
494
|
+
/** The installation to act as. Omit it to act as the app itself. */
|
|
495
|
+
installationId?: string | number;
|
|
496
|
+
}
|
|
497
|
+
/** The credential types that a provider can accept. */
|
|
498
|
+
type AuthKind = "token" | "basic" | "app" | "app_password" | "oauth" | "anonymous";
|
|
499
|
+
/** Options that every provider accepts. */
|
|
500
|
+
interface ForgeOptionsBase {
|
|
501
|
+
/** API base URL. Defaults to the forge's public instance. */
|
|
502
|
+
baseUrl?: string;
|
|
503
|
+
/** Host used in refs and keys. Defaults to the host of `baseUrl`, with API subdomains mapped to the public host. */
|
|
504
|
+
instance?: string;
|
|
505
|
+
/** A `fetch` to use instead of the global one, for tests and for runtimes without one. */
|
|
506
|
+
fetch?: FetchLike;
|
|
507
|
+
/**
|
|
508
|
+
* Request timeout in milliseconds.
|
|
509
|
+
* @default 30000
|
|
510
|
+
*/
|
|
511
|
+
timeout?: number;
|
|
512
|
+
/** Shared secret used to verify inbound webhook deliveries. */
|
|
513
|
+
webhookSecret?: string;
|
|
514
|
+
/**
|
|
515
|
+
* The `user-agent` header. Defaults to `forges`, except in a browser, which sends its own.
|
|
516
|
+
* Setting it in a browser can trigger a CORS preflight that some forges reject.
|
|
517
|
+
*/
|
|
518
|
+
userAgent?: string;
|
|
519
|
+
/**
|
|
520
|
+
* Version of the forge instance, when the caller already knows it. Gates
|
|
521
|
+
* version-dependent capabilities without the network call
|
|
522
|
+
* `refreshCapabilities()` makes.
|
|
523
|
+
*/
|
|
524
|
+
instanceVersion?: string;
|
|
525
|
+
/** Every write, including a mutating `request()`, rejects with `ReadOnlyError` and reports `false`. */
|
|
526
|
+
readOnly?: boolean;
|
|
527
|
+
/** Called before a request is retried after a secondary rate limit, with the wait in milliseconds. */
|
|
528
|
+
onRetry?: FetcherOptions["onRetry"];
|
|
529
|
+
}
|
|
530
|
+
/** Per-thread-kind support. `'other'` subjects have no verbs, so they have no entry. */
|
|
531
|
+
type PerKind = Record<Exclude<ThreadKind, "other">, Support>;
|
|
532
|
+
/** Support per security alert kind. */
|
|
533
|
+
type AlertSupport = Record<"dependency" | "code_scanning" | "secret" | "advisory", Support>;
|
|
534
|
+
/**
|
|
535
|
+
* What a provider supports, operation by operation. It is computed without a request, and
|
|
536
|
+
* `refreshCapabilities()` refines it with the instance version. Each group holds one entry per
|
|
537
|
+
* capability, and the [capability matrix](/reference/capability-matrix) lists them for every forge.
|
|
538
|
+
*/
|
|
539
|
+
interface ForgeCapabilities {
|
|
540
|
+
/** Instance version the capabilities were computed for, when known. */
|
|
541
|
+
version?: string;
|
|
542
|
+
/** The forge's API as a whole is unstable, so the provider can change with it. */
|
|
543
|
+
experimental?: true;
|
|
544
|
+
/** `subscribe` is a long-lived push stream; see {@link SourcesApi}. */
|
|
545
|
+
sources: Record<"poll" | "webhook" | "subscribe", Support>;
|
|
546
|
+
repos: {
|
|
547
|
+
/** Support for `repos.get()`. */
|
|
548
|
+
get: Support;
|
|
549
|
+
/** Support for `repos.list()` and `repos.listPage()`. */
|
|
550
|
+
list: Support;
|
|
551
|
+
/** Support for `repos.labels()` and `repos.labelsPage()`. */
|
|
552
|
+
labels: Support;
|
|
553
|
+
/** Support for `repos.createLabel()`. */
|
|
554
|
+
createLabel: Support;
|
|
555
|
+
/** Support for `repos.milestones()` and `repos.milestonesPage()`. */
|
|
556
|
+
milestones: Support;
|
|
557
|
+
/** Support for `repos.collaborators()` and `repos.collaboratorsPage()`. */
|
|
558
|
+
collaborators: Support;
|
|
559
|
+
/** Support for `repos.permissionFor()`. */
|
|
560
|
+
permissionFor: Support;
|
|
561
|
+
/** Support for `repos.addCollaborator()`. */
|
|
562
|
+
addCollaborator: Support;
|
|
563
|
+
/** Support for `repos.assignableUsers()` and `repos.assignableUsersPage()`. */
|
|
564
|
+
assignableUsers: Support;
|
|
565
|
+
/** Support for `repos.reviewerCandidates()` and `repos.reviewerCandidatesPage()`. */
|
|
566
|
+
reviewerCandidates: Support;
|
|
567
|
+
};
|
|
568
|
+
users: {
|
|
569
|
+
/** Support for `users.get()`. */
|
|
570
|
+
get: Support;
|
|
571
|
+
/** Support for `users.me()`. */
|
|
572
|
+
me: Support;
|
|
573
|
+
};
|
|
574
|
+
threads: {
|
|
575
|
+
/** Support for `threads.get()`, per thread kind. */
|
|
576
|
+
get: PerKind;
|
|
577
|
+
/** Support for `threads.list()` and `threads.listPage()`, per thread kind. */
|
|
578
|
+
list: PerKind;
|
|
579
|
+
/** Support for `threads.getMany()`. */
|
|
580
|
+
getMany: Support;
|
|
581
|
+
/** Support for `threads.events()` and `threads.eventsPage()`, per thread kind. */
|
|
582
|
+
events: PerKind;
|
|
583
|
+
};
|
|
584
|
+
comments: {
|
|
585
|
+
/** Support for `threads.comments()` and `threads.commentsPage()`, per thread kind. */
|
|
586
|
+
list: PerKind;
|
|
587
|
+
/** Support for `threads.editComment()`, per thread kind. */
|
|
588
|
+
edit: PerKind;
|
|
589
|
+
/** Support for `threads.deleteComment()`, per thread kind. */
|
|
590
|
+
delete: PerKind;
|
|
591
|
+
};
|
|
592
|
+
/** Listing the reactions on a thread or one of its comments, per thread kind. */
|
|
593
|
+
reactions: {
|
|
594
|
+
/** Support for `threads.reactions()` and `threads.reactionsPage()`, per thread kind. */
|
|
595
|
+
list: PerKind;
|
|
596
|
+
};
|
|
597
|
+
notifications: {
|
|
598
|
+
/** Support for `notifications.list()` and `notifications.listPage()`. */
|
|
599
|
+
list: Support;
|
|
600
|
+
/** Support for `notifications.markRead()`. */
|
|
601
|
+
markRead: Support;
|
|
602
|
+
/** Support for `notifications.markDone()`. */
|
|
603
|
+
markDone: Support;
|
|
604
|
+
/** Support for `notifications.unsubscribe()`. */
|
|
605
|
+
unsubscribe: Support;
|
|
606
|
+
/** Support for `notifications.markAllRead()`. */
|
|
607
|
+
markAllRead: Support;
|
|
608
|
+
/** Support for `notifications.markAllDone()`. */
|
|
609
|
+
markAllDone: Support;
|
|
610
|
+
/** Support for `notifications.unreadCount()`. */
|
|
611
|
+
unreadCount: Support;
|
|
612
|
+
};
|
|
613
|
+
/** Write verbs, per thread kind except `merge`, `approveAndMerge`, `transfer` and `markDuplicate`. */
|
|
614
|
+
writes: {
|
|
615
|
+
/** Support for `threads.comment()`, per thread kind. */
|
|
616
|
+
comment: PerKind;
|
|
617
|
+
/** Composed from `comment`, `comments.list` and `comments.edit`, so `'emulated'` where it works at all, or `'unverified'` where a part is. */
|
|
618
|
+
upsertComment: PerKind;
|
|
619
|
+
/** Support for `threads.close()`, per thread kind. */
|
|
620
|
+
close: PerKind;
|
|
621
|
+
/** Support for `threads.reopen()`, per thread kind. */
|
|
622
|
+
reopen: PerKind;
|
|
623
|
+
/** Support for `threads.create()`, per thread kind. */
|
|
624
|
+
create: PerKind;
|
|
625
|
+
/** Support for `threads.update()`, per thread kind. */
|
|
626
|
+
update: PerKind;
|
|
627
|
+
/** Support for `threads.setLabels()`, per thread kind. */
|
|
628
|
+
setLabels: PerKind;
|
|
629
|
+
/** Support for `threads.addLabels()`, per thread kind. */
|
|
630
|
+
addLabels: PerKind;
|
|
631
|
+
/** Support for `threads.removeLabels()`, per thread kind. */
|
|
632
|
+
removeLabels: PerKind;
|
|
633
|
+
/** Support for `threads.setMilestone()`, per thread kind. */
|
|
634
|
+
setMilestone: PerKind;
|
|
635
|
+
/** Support for `threads.react()` and `threads.unreact()`, per thread kind. */
|
|
636
|
+
react: PerKind;
|
|
637
|
+
/** Support for `threads.setAssignees()`, per thread kind. */
|
|
638
|
+
setAssignees: PerKind;
|
|
639
|
+
/** Support for `threads.requestReview()`, per thread kind. */
|
|
640
|
+
requestReview: PerKind;
|
|
641
|
+
/** Support for `threads.merge()`. */
|
|
642
|
+
merge: Support;
|
|
643
|
+
/** Composed from `merge` and `reviews.approve`. */
|
|
644
|
+
approveAndMerge: Support;
|
|
645
|
+
/** Support for `threads.transfer()`. */
|
|
646
|
+
transfer: Support;
|
|
647
|
+
/** Support for `threads.markDuplicate()`. */
|
|
648
|
+
markDuplicate: Support;
|
|
649
|
+
};
|
|
650
|
+
/** Reading a thread subscription (`get`) and changing it (`set`), per kind. Distinct from notification unsubscribe. */
|
|
651
|
+
subscriptions: {
|
|
652
|
+
/** Support for `threads.subscription()`, per thread kind. */
|
|
653
|
+
get: PerKind;
|
|
654
|
+
/** Support for `threads.subscribe()` and `threads.unsubscribe()`, per thread kind. */
|
|
655
|
+
set: PerKind;
|
|
656
|
+
};
|
|
657
|
+
/**
|
|
658
|
+
* `thread` covers `Thread.checks` and `threads.checks()` (pull requests
|
|
659
|
+
* only); the rest are the commit-level surface. `report` is a commit
|
|
660
|
+
* status unless the credential can write check runs.
|
|
661
|
+
*/
|
|
662
|
+
checks: {
|
|
663
|
+
/** Support for `threads.checks()`, per thread kind. */
|
|
664
|
+
thread: PerKind;
|
|
665
|
+
/** Support for `checks.list()`. */
|
|
666
|
+
list: Support;
|
|
667
|
+
/** Support for `checks.report()`. */
|
|
668
|
+
report: Support;
|
|
669
|
+
/** Support for `checks.rerun()`. */
|
|
670
|
+
rerun: Support;
|
|
671
|
+
};
|
|
672
|
+
/** Read-only CI surface. `log` is `false` where job logs are not reachable over the API. */
|
|
673
|
+
ci: {
|
|
674
|
+
/** Support for `ci.runs()` and `ci.runsPage()`. */
|
|
675
|
+
runs: Support;
|
|
676
|
+
/** Support for `ci.run()`. */
|
|
677
|
+
run: Support;
|
|
678
|
+
/** Support for `ci.jobs()` and `ci.jobsPage()`. */
|
|
679
|
+
jobs: Support;
|
|
680
|
+
/** Support for `ci.log()`. */
|
|
681
|
+
log: Support;
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* Reviews on a pull request. `list` is `'emulated'` where reviews are
|
|
685
|
+
* synthesised from approvals or votes; `create` then covers only the events
|
|
686
|
+
* the forge's approval endpoint can express.
|
|
687
|
+
*/
|
|
688
|
+
reviews: {
|
|
689
|
+
/** Support for `threads.reviews()` and `threads.reviewsPage()`. */
|
|
690
|
+
list: Support;
|
|
691
|
+
/** Support for `threads.createReview()`. */
|
|
692
|
+
create: Support;
|
|
693
|
+
/** Support for `threads.submitReview()`. */
|
|
694
|
+
submit: Support;
|
|
695
|
+
/** Support for `threads.approve()`. */
|
|
696
|
+
approve: Support;
|
|
697
|
+
/** Support for `threads.resolveReviewThread()` and `threads.unresolveReviewThread()`. */
|
|
698
|
+
resolveThread: Support;
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Repository contents. `tree` is `'emulated'` where recursion is walked
|
|
702
|
+
* level by level rather than by the forge.
|
|
703
|
+
*/
|
|
704
|
+
contents: {
|
|
705
|
+
/** Support for `contents.file()`. */
|
|
706
|
+
file: Support;
|
|
707
|
+
/** Support for `contents.tree()` and `contents.treePage()`. */
|
|
708
|
+
tree: Support;
|
|
709
|
+
/** Support for `contents.branches()` and `contents.branchesPage()`. */
|
|
710
|
+
branches: Support;
|
|
711
|
+
/** Support for `contents.tags()` and `contents.tagsPage()`. */
|
|
712
|
+
tags: Support;
|
|
713
|
+
/** Support for `contents.resolveRef()`. */
|
|
714
|
+
resolveRef: Support;
|
|
715
|
+
/** Support for `contents.commits()` and `contents.commitsPage()`. */
|
|
716
|
+
commits: Support;
|
|
717
|
+
/** Support for `contents.commit()`. */
|
|
718
|
+
commit: Support;
|
|
719
|
+
/** Support for `contents.compare()`. */
|
|
720
|
+
compare: Support;
|
|
721
|
+
/** `threads.files` and `threads.commits` on a pull request. */
|
|
722
|
+
threadFiles: Support;
|
|
723
|
+
/** Support for `threads.commits()` and `threads.commitsPage()`. */
|
|
724
|
+
threadCommits: Support;
|
|
725
|
+
};
|
|
726
|
+
/** Managing registered webhooks, beside receiving deliveries. */
|
|
727
|
+
webhooks: {
|
|
728
|
+
/** Support for `webhooks.list()` and `webhooks.listPage()`. */
|
|
729
|
+
list: Support;
|
|
730
|
+
/** Support for `webhooks.create()`. */
|
|
731
|
+
create: Support;
|
|
732
|
+
/** Support for `webhooks.update()`. */
|
|
733
|
+
update: Support;
|
|
734
|
+
/** Support for `webhooks.delete()`. */
|
|
735
|
+
delete: Support;
|
|
736
|
+
/** Support for `webhooks.rotateSecret()`. */
|
|
737
|
+
rotateSecret: Support;
|
|
738
|
+
/** Support for `webhooks.deliveries()` and `webhooks.deliveriesPage()`. */
|
|
739
|
+
deliveries: Support;
|
|
740
|
+
/** Support for `webhooks.redeliver()`. */
|
|
741
|
+
redeliver: Support;
|
|
742
|
+
};
|
|
743
|
+
releases: {
|
|
744
|
+
/** Support for `releases.list()` and `releases.listPage()`. */
|
|
745
|
+
list: Support;
|
|
746
|
+
/** Support for `releases.get()`. */
|
|
747
|
+
get: Support;
|
|
748
|
+
/** Support for `releases.latest()`. */
|
|
749
|
+
latest: Support;
|
|
750
|
+
/** Support for `releases.getByTag()`. */
|
|
751
|
+
getByTag: Support;
|
|
752
|
+
/** Support for `releases.downloadAsset()`. */
|
|
753
|
+
downloadAsset: Support;
|
|
754
|
+
/** Support for `releases.create()`. */
|
|
755
|
+
create: Support;
|
|
756
|
+
/** Support for `releases.update()`. */
|
|
757
|
+
update: Support;
|
|
758
|
+
};
|
|
759
|
+
/** Cross-repository search of issues and pull requests, repositories, commits and code. */
|
|
760
|
+
search: {
|
|
761
|
+
/** Support for `search.threads()` and `search.threadsPage()`. */
|
|
762
|
+
threads: Support;
|
|
763
|
+
/** Support for `search.repos()` and `search.reposPage()`. */
|
|
764
|
+
repos: Support;
|
|
765
|
+
/** Support for `search.commits()` and `search.commitsPage()`. */
|
|
766
|
+
commits: Support;
|
|
767
|
+
/** Support for `search.code()` and `search.codePage()`. */
|
|
768
|
+
code: Support;
|
|
769
|
+
};
|
|
770
|
+
/** Per alert kind, since each needs its own token scope on GitHub. */
|
|
771
|
+
securityAlerts: AlertSupport;
|
|
772
|
+
/** Enumerating app installations and deriving one provider per installation. */
|
|
773
|
+
installations: Support;
|
|
774
|
+
/**
|
|
775
|
+
* `'heuristic'` when event kinds are inferred from free text (GitLab system
|
|
776
|
+
* notes) rather than reported by the forge, so `kind` may be `'other'` or
|
|
777
|
+
* wrong for unrecognised wording; `kindRaw` and `payload` stay exact.
|
|
778
|
+
*/
|
|
779
|
+
eventKinds: "native" | "heuristic";
|
|
780
|
+
/** Auth types the provider accepts. The type this provider was created with is `ForgeProvider.authKind`. */
|
|
781
|
+
authKinds: readonly AuthKind[];
|
|
782
|
+
/** Maximum text lengths the forge accepts. */
|
|
783
|
+
limits?: TextLimits;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* An async iterable that also collects non-fatal warnings as it runs. Read
|
|
787
|
+
* `warnings` during or after iteration.
|
|
788
|
+
*/
|
|
789
|
+
interface ForgeIterable<T> extends AsyncIterable<T> {
|
|
790
|
+
/** The non-fatal warnings collected so far. Read it during or after iteration. */
|
|
791
|
+
readonly warnings: ForgeWarning[];
|
|
792
|
+
}
|
|
793
|
+
/** A webhook delivery as received: its headers, its raw body and, optionally, the secret to verify it with. */
|
|
794
|
+
interface WebhookDelivery {
|
|
795
|
+
/** The request headers, which carry the signature and the event name. */
|
|
796
|
+
headers: Headers | Record<string, string>;
|
|
797
|
+
/** Raw body exactly as received; signatures are computed over these bytes. */
|
|
798
|
+
body: string | Uint8Array;
|
|
799
|
+
/** Overrides the provider-level `webhookSecret` for this delivery. */
|
|
800
|
+
secret?: string;
|
|
801
|
+
}
|
|
802
|
+
/** Options for `markAllRead()` and `markAllDone()`. */
|
|
803
|
+
interface BulkNotificationOptions extends BaseOptions {
|
|
804
|
+
/** Limit to one repository. */
|
|
805
|
+
repo?: RepoRef;
|
|
806
|
+
/** Only notifications updated before this time. */
|
|
807
|
+
before?: Date;
|
|
808
|
+
}
|
|
809
|
+
/** Reading and clearing the notifications of the authenticated account. */
|
|
810
|
+
interface NotificationsApi {
|
|
811
|
+
/** Lists the account's notifications. */
|
|
812
|
+
list: (options?: NotificationListOptions) => ForgeIterable<Notification>;
|
|
813
|
+
/** One page of `list()`. Pass the `cursor` of the previous page to read the next. */
|
|
814
|
+
listPage: (options?: NotificationListOptions) => Promise<Page<Notification>>;
|
|
815
|
+
/** Marks a notification as read. */
|
|
816
|
+
markRead: (ref: NotificationRef, options?: BaseOptions) => Promise<void>;
|
|
817
|
+
/** Marks a notification as done, which clears it from the inbox where the forge has that state. */
|
|
818
|
+
markDone: (ref: NotificationRef, options?: NotificationWriteOptions) => Promise<void>;
|
|
819
|
+
/** Stops notifications for the notification's thread, and on some forges also clears the notification. */
|
|
820
|
+
unsubscribe: (ref: NotificationRef, options?: NotificationWriteOptions) => Promise<void>;
|
|
821
|
+
/** Marks every notification as read, or those of one repository. */
|
|
822
|
+
markAllRead: (options?: BulkNotificationOptions) => Promise<void>;
|
|
823
|
+
/** Marks every notification as done, or those of one repository. */
|
|
824
|
+
markAllDone: (options?: BulkNotificationOptions) => Promise<void>;
|
|
825
|
+
/** The number of unread notifications. */
|
|
826
|
+
unreadCount: (options?: BaseOptions) => Promise<number>;
|
|
827
|
+
}
|
|
828
|
+
/** Options for changing one notification. */
|
|
829
|
+
interface NotificationWriteOptions extends BaseOptions {
|
|
830
|
+
/**
|
|
831
|
+
* The thread the notification points at, when the caller already holds it.
|
|
832
|
+
* Providers that would otherwise look it up skip that request.
|
|
833
|
+
*/
|
|
834
|
+
thread?: ThreadRef;
|
|
835
|
+
}
|
|
836
|
+
/** Why a thread was closed. */
|
|
837
|
+
type CloseReason = "completed" | "not_planned" | "duplicate";
|
|
838
|
+
/** Options for `threads.close()`. */
|
|
839
|
+
interface CloseOptions extends BaseOptions {
|
|
840
|
+
/**
|
|
841
|
+
* Mapped to the forge's own reason where it has one; forges without close
|
|
842
|
+
* reasons close the thread without one.
|
|
843
|
+
*/
|
|
844
|
+
reason?: CloseReason;
|
|
845
|
+
/** Forge-native reason, sent as is; takes precedence over `reason`. */
|
|
846
|
+
reasonRaw?: string;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Issues, pull requests and the other kinds of discussion: reading, creating, commenting, labelling,
|
|
850
|
+
* reviewing and merging them.
|
|
851
|
+
*/
|
|
852
|
+
interface ThreadsApi {
|
|
853
|
+
/**
|
|
854
|
+
* Reads an issue, pull request or discussion by its ref. Rejects with `NotFoundError` when it does not exist or the
|
|
855
|
+
* credential cannot see it.
|
|
856
|
+
*/
|
|
857
|
+
get: (ref: ThreadRef, options?: BaseOptions) => Promise<Thread>;
|
|
858
|
+
/** Reads several threads, batched where the forge allows. Failures become per-item warnings. */
|
|
859
|
+
getMany: (refs: ThreadRef[], options?: BaseOptions) => Promise<GetManyResult[]>;
|
|
860
|
+
/** Lists the threads of a repository. */
|
|
861
|
+
list: (repo: RepoRef, query?: ThreadQuery) => ForgeIterable<Thread>;
|
|
862
|
+
/** One page of `list`; pass `cursor` back in `query` to read the next. */
|
|
863
|
+
listPage: (repo: RepoRef, query?: ThreadQuery) => Promise<Page<Thread>>;
|
|
864
|
+
/** Lists the events on a thread, such as comments, label changes and state changes. */
|
|
865
|
+
events: (ref: ThreadRef, options?: ListOptions) => ForgeIterable<ForgeEvent>;
|
|
866
|
+
/** One page of `events()`. */
|
|
867
|
+
eventsPage: (ref: ThreadRef, options?: ListOptions) => Promise<Page<ForgeEvent>>;
|
|
868
|
+
/** Conversation comments. Inline review comments are events, not comments. */
|
|
869
|
+
comments: (ref: ThreadRef, options?: ListOptions) => ForgeIterable<Comment>;
|
|
870
|
+
/** One page of `comments()`. */
|
|
871
|
+
commentsPage: (ref: ThreadRef, options?: ListOptions) => Promise<Page<Comment>>;
|
|
872
|
+
/** Adds a comment to a thread. */
|
|
873
|
+
comment: (ref: ThreadRef, body: string, options?: BaseOptions) => Promise<Comment>;
|
|
874
|
+
/**
|
|
875
|
+
* Creates the comment, or edits the one an earlier call with the same `key`
|
|
876
|
+
* left behind. The key is carried in the body as a hidden marker; see
|
|
877
|
+
* {@link commentMarker}. Composed from `comments`, `comment` and
|
|
878
|
+
* `editComment`, so it costs a listing on every call.
|
|
879
|
+
* @param ref The thread to comment on.
|
|
880
|
+
* @param input The `key` that identifies the comment across runs, and its `body`.
|
|
881
|
+
* @example
|
|
882
|
+
* ```ts
|
|
883
|
+
* await provider.threads.upsertComment(ref, { key: 'preview', body: 'Preview: https://pr-42.example.com' })
|
|
884
|
+
* ```
|
|
885
|
+
*/
|
|
886
|
+
upsertComment: (ref: ThreadRef, input: UpsertCommentInput, options?: BaseOptions) => Promise<UpsertCommentResult>;
|
|
887
|
+
/** Replaces the body of a comment. */
|
|
888
|
+
editComment: (ref: CommentRef, body: string, options?: BaseOptions) => Promise<Comment>;
|
|
889
|
+
/** Deletes a comment. */
|
|
890
|
+
deleteComment: (ref: CommentRef, options?: BaseOptions) => Promise<void>;
|
|
891
|
+
/** Creates an issue, pull request or discussion. A pull request needs `head` and `base`. */
|
|
892
|
+
create: (repo: RepoRef, input: ThreadCreateInput, options?: BaseOptions) => Promise<Thread>;
|
|
893
|
+
/** Changes the title, body or other fields of a thread. Fields left out stay as they are. */
|
|
894
|
+
update: (ref: ThreadRef, input: ThreadUpdateInput, options?: BaseOptions) => Promise<Thread>;
|
|
895
|
+
/** Replaces the thread's labels. */
|
|
896
|
+
setLabels: (ref: ThreadRef, labels: string[], options?: BaseOptions) => Promise<void>;
|
|
897
|
+
/** Adds labels, leaving the rest in place. */
|
|
898
|
+
addLabels: (ref: ThreadRef, labels: string[], options?: BaseOptions) => Promise<void>;
|
|
899
|
+
/** Removes labels, leaving the rest in place. Labels the thread does not carry are ignored. */
|
|
900
|
+
removeLabels: (ref: ThreadRef, labels: string[], options?: BaseOptions) => Promise<void>;
|
|
901
|
+
/** Sets the thread's milestone, by milestone, id or title, or clears it with `undefined`. */
|
|
902
|
+
setMilestone: (ref: ThreadRef, milestone: Milestone | string | undefined, options?: BaseOptions) => Promise<void>;
|
|
903
|
+
/** Reactions left on the thread or on one of its comments. */
|
|
904
|
+
reactions: (target: ThreadRef | CommentRef, options?: ListOptions) => ForgeIterable<Reaction>;
|
|
905
|
+
/** One page of `reactions()`. */
|
|
906
|
+
reactionsPage: (target: ThreadRef | CommentRef, options?: ListOptions) => Promise<Page<Reaction>>;
|
|
907
|
+
/**
|
|
908
|
+
* Reacts as the authenticated account, to the thread or to one of its comments.
|
|
909
|
+
* @param target The thread or comment to react to.
|
|
910
|
+
* @param reaction The reaction to leave.
|
|
911
|
+
*/
|
|
912
|
+
react: (target: ThreadRef | CommentRef, reaction: ReactionContent, options?: BaseOptions) => Promise<void>;
|
|
913
|
+
/** Removes the account's reaction from the thread or comment. */
|
|
914
|
+
unreact: (target: ThreadRef | CommentRef, reaction: ReactionContent, options?: BaseOptions) => Promise<void>;
|
|
915
|
+
/** Moves the thread to another repository, and returns its ref there. */
|
|
916
|
+
transfer: (ref: ThreadRef, repo: RepoRef, options?: BaseOptions) => Promise<ThreadRef>;
|
|
917
|
+
/** Marks the thread a duplicate of `canonical`, which must be in the same repository on most forges. */
|
|
918
|
+
markDuplicate: (ref: ThreadRef, canonical: ThreadRef, options?: BaseOptions) => Promise<void>;
|
|
919
|
+
/** Replaces the thread's assignees. */
|
|
920
|
+
setAssignees: (ref: ThreadRef, assignees: Array<string | Actor>, options?: BaseOptions) => Promise<void>;
|
|
921
|
+
/** Adds reviewers to a pull request. */
|
|
922
|
+
requestReview: (ref: ThreadRef, reviewers: Array<string | Actor>, options?: BaseOptions) => Promise<void>;
|
|
923
|
+
/** Closes a thread, optionally with a reason. */
|
|
924
|
+
close: (ref: ThreadRef, options?: CloseOptions) => Promise<void>;
|
|
925
|
+
/** Reopens a closed thread. */
|
|
926
|
+
reopen: (ref: ThreadRef, options?: BaseOptions) => Promise<void>;
|
|
927
|
+
/**
|
|
928
|
+
* Merges a pull request. Without a merge method, the repository must allow exactly one.
|
|
929
|
+
* @param ref The pull request to merge.
|
|
930
|
+
* @param options The merge method, the head `sha` to expect and the commit message.
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* await provider.threads.merge(ref, { method: 'squash' })
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
merge: (ref: ThreadRef, options?: MergeOptions) => Promise<void>;
|
|
937
|
+
/** Approves, then merges. The merge method is checked before the approval is sent. */
|
|
938
|
+
approveAndMerge: (ref: ThreadRef, options?: ApproveAndMergeOptions) => Promise<void>;
|
|
939
|
+
/** The authenticated account's subscription to the thread. */
|
|
940
|
+
subscription: (ref: ThreadRef, options?: BaseOptions) => Promise<SubscriptionState>;
|
|
941
|
+
/** Subscribes the account to the notifications of a thread. */
|
|
942
|
+
subscribe: (ref: ThreadRef, options?: BaseOptions) => Promise<void>;
|
|
943
|
+
/** Stops the account's notifications for a thread, leaving existing notifications alone. */
|
|
944
|
+
unsubscribe: (ref: ThreadRef, options?: BaseOptions) => Promise<void>;
|
|
945
|
+
/** Every check on the pull's head, in one page; `warnings` names the sources that could not be read. */
|
|
946
|
+
checks: (ref: ThreadRef, options?: BaseOptions) => Promise<Page<Check>>;
|
|
947
|
+
/**
|
|
948
|
+
* Reviews on a pull request. Forges with approvals but no review objects
|
|
949
|
+
* (GitLab approvals, Azure DevOps votes, Bitbucket participants) synthesise
|
|
950
|
+
* one review per approver, with `comments: false`.
|
|
951
|
+
*/
|
|
952
|
+
reviews: (ref: ThreadRef, options?: PageOptions) => ForgeIterable<Review>;
|
|
953
|
+
/** One page of `reviews()`. */
|
|
954
|
+
reviewsPage: (ref: ThreadRef, options?: PageOptions) => Promise<Page<Review>>;
|
|
955
|
+
/** Creates a review. Without `event` the review is pending where the forge has pending reviews. */
|
|
956
|
+
createReview: (ref: ThreadRef, input: ReviewInput, options?: BaseOptions) => Promise<Review>;
|
|
957
|
+
/** Submits a pending review. */
|
|
958
|
+
submitReview: (ref: ReviewRef, event: ReviewEvent, body?: string, options?: BaseOptions) => Promise<Review>;
|
|
959
|
+
/** Approves without merging; `createReview({ event: 'approve' })` with nothing else to say. */
|
|
960
|
+
approve: (ref: ThreadRef, body?: string, options?: BaseOptions) => Promise<void>;
|
|
961
|
+
/** Files a pull request changes, with a per-file `patch` where the forge returns one. */
|
|
962
|
+
files: (ref: ThreadRef, options?: PageOptions) => ForgeIterable<ChangedFile>;
|
|
963
|
+
/** One page of `files()`. */
|
|
964
|
+
filesPage: (ref: ThreadRef, options?: PageOptions) => Promise<Page<ChangedFile>>;
|
|
965
|
+
/** Commits on a pull request. */
|
|
966
|
+
commits: (ref: ThreadRef, options?: PageOptions) => ForgeIterable<Commit>;
|
|
967
|
+
/** One page of `commits()`. */
|
|
968
|
+
commitsPage: (ref: ThreadRef, options?: PageOptions) => Promise<Page<Commit>>;
|
|
969
|
+
/** Resolves a review conversation, by the id on {@link ReviewComment.thread} or {@link Comment.thread}. */
|
|
970
|
+
resolveReviewThread: (ref: ThreadRef, id: string, options?: BaseOptions) => Promise<void>;
|
|
971
|
+
/** Reopens a resolved review conversation, by the id on `ReviewComment.thread` or `Comment.thread`. */
|
|
972
|
+
unresolveReviewThread: (ref: ThreadRef, id: string, options?: BaseOptions) => Promise<void>;
|
|
973
|
+
}
|
|
974
|
+
/** Reading and reporting the checks on a commit. */
|
|
975
|
+
interface ChecksApi {
|
|
976
|
+
/** Every check on a commit: check runs, commit statuses, jobs or policy evaluations. */
|
|
977
|
+
list: (repo: RepoRef, sha: string, options?: BaseOptions) => Promise<Page<Check>>;
|
|
978
|
+
/** Writes a commit status, or a check run where the credential can (GitHub app auth). */
|
|
979
|
+
report: (repo: RepoRef, sha: string, input: CheckReportInput, options?: BaseOptions) => Promise<Check>;
|
|
980
|
+
/** Re-runs a check. Rejects for a `CheckRef.type` the forge cannot re-run. */
|
|
981
|
+
rerun: (ref: CheckRef, options?: BaseOptions) => Promise<void>;
|
|
982
|
+
}
|
|
983
|
+
/** Reading CI runs and their jobs. CI is read-only. */
|
|
984
|
+
interface CiApi {
|
|
985
|
+
/** Lists the CI runs of a repository. */
|
|
986
|
+
runs: (repo: RepoRef, query?: CiRunQuery) => ForgeIterable<CiRun>;
|
|
987
|
+
/** One page of `runs()`. */
|
|
988
|
+
runsPage: (repo: RepoRef, query?: CiRunQuery) => Promise<Page<CiRun>>;
|
|
989
|
+
/** Reads one CI run. */
|
|
990
|
+
run: (ref: CiRunRef, options?: BaseOptions) => Promise<CiRun>;
|
|
991
|
+
/** Lists the jobs of a CI run. */
|
|
992
|
+
jobs: (ref: CiRunRef, options?: PageOptions) => ForgeIterable<CiJob>;
|
|
993
|
+
/** One page of `jobs()`. */
|
|
994
|
+
jobsPage: (ref: CiRunRef, options?: PageOptions) => Promise<Page<CiJob>>;
|
|
995
|
+
/** The job's log as it arrives. There is no workflow dispatch: CI is read-only here. */
|
|
996
|
+
log: (ref: CiJobRef, options?: BaseOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
997
|
+
}
|
|
998
|
+
/** Files, trees, branches, tags and commits of a repository. */
|
|
999
|
+
interface ContentsApi {
|
|
1000
|
+
/**
|
|
1001
|
+
* One file's contents. Binary-safe: `content` is a `Uint8Array` unless the
|
|
1002
|
+
* forge reports text and `as: 'text'` was asked for. Files past the forge's
|
|
1003
|
+
* inline limit (1 MB on GitHub) are read from the raw or blob endpoint
|
|
1004
|
+
* instead of failing.
|
|
1005
|
+
* @param repo The repository to read from.
|
|
1006
|
+
* @param path The path of the file from the repository root.
|
|
1007
|
+
* @param options The revision to read, and whether to decode the content as text.
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* const file = await provider.contents.file(repo, 'package.json', { as: 'text' })
|
|
1011
|
+
* const manifest = JSON.parse(file.content as string)
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
file: (repo: RepoRef, path: string, options?: FileOptions) => Promise<FileContent>;
|
|
1015
|
+
/** One level, or every descendant with `recursive`. Truncated listings carry a `tree_truncated` warning. */
|
|
1016
|
+
tree: (repo: RepoRef, options?: TreeOptions) => ForgeIterable<TreeEntry>;
|
|
1017
|
+
/** One page of `tree()`. */
|
|
1018
|
+
treePage: (repo: RepoRef, options?: TreeOptions) => Promise<Page<TreeEntry>>;
|
|
1019
|
+
/** Lists the branches of a repository. */
|
|
1020
|
+
branches: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Branch>;
|
|
1021
|
+
/** One page of `branches()`. */
|
|
1022
|
+
branchesPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Branch>>;
|
|
1023
|
+
/** Lists the tags of a repository. */
|
|
1024
|
+
tags: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Tag>;
|
|
1025
|
+
/** One page of `tags()`. */
|
|
1026
|
+
tagsPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Tag>>;
|
|
1027
|
+
/** Resolves a branch, tag or sha to a full commit sha; a full sha is returned as is. */
|
|
1028
|
+
resolveRef: (repo: RepoRef, ref: string, options?: BaseOptions) => Promise<string>;
|
|
1029
|
+
/** Lists the commits that lead to `ref`, or to the default branch. */
|
|
1030
|
+
commits: (repo: RepoRef, query?: CommitQuery) => ForgeIterable<Commit>;
|
|
1031
|
+
/** One page of `commits()`. */
|
|
1032
|
+
commitsPage: (repo: RepoRef, query?: CommitQuery) => Promise<Page<Commit>>;
|
|
1033
|
+
/** One commit, with its files and stats. */
|
|
1034
|
+
commit: (repo: RepoRef, sha: string, options?: BaseOptions) => Promise<Commit>;
|
|
1035
|
+
/** Commits and files between two refs. */
|
|
1036
|
+
compare: (repo: RepoRef, base: string, head: string, options?: BaseOptions) => Promise<Comparison>;
|
|
1037
|
+
}
|
|
1038
|
+
/** Reading, creating and updating the releases of a repository, and downloading their assets. */
|
|
1039
|
+
interface ReleasesApi {
|
|
1040
|
+
/** Lists the releases of a repository, including drafts and pre-releases where the credential can see them. */
|
|
1041
|
+
list: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Release>;
|
|
1042
|
+
/** One page of `list()`. */
|
|
1043
|
+
listPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Release>>;
|
|
1044
|
+
/** Reads a release by its ref. */
|
|
1045
|
+
get: (ref: ReleaseRef, options?: BaseOptions) => Promise<Release>;
|
|
1046
|
+
/** The release for a tag name. */
|
|
1047
|
+
getByTag: (repo: RepoRef, tag: string, options?: BaseOptions) => Promise<Release>;
|
|
1048
|
+
/**
|
|
1049
|
+
* The asset's bytes as they arrive. A redirect to a CDN host is followed
|
|
1050
|
+
* without the `Authorization` header, which those hosts reject.
|
|
1051
|
+
*/
|
|
1052
|
+
downloadAsset: (ref: ReleaseAssetRef, options?: BaseOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
1053
|
+
/** The most recent published release that is not a draft or prerelease, if any. */
|
|
1054
|
+
latest: (repo: RepoRef, options?: BaseOptions) => Promise<Release | undefined>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Creates a release, and its tag from `target` when the tag does not exist yet.
|
|
1057
|
+
* @param repo The repository to release.
|
|
1058
|
+
* @param input The tag, the name, the notes and whether the release is a draft or a prerelease.
|
|
1059
|
+
* @throws `UnsupportedOperationError` for `draft: true` or `prerelease: true` on a forge without drafts or prereleases.
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```ts
|
|
1062
|
+
* const release = await provider.releases.create(repo, { tag: 'v1.2.0', body: notes, draft: true })
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
create: (repo: RepoRef, input: ReleaseInput, options?: BaseOptions) => Promise<Release>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Changes a release. Fields left out stay as they are, so `{ draft: false }` publishes a draft.
|
|
1068
|
+
* @throws `UnsupportedOperationError` for a change the forge cannot make, such as a new tag on GitLab.
|
|
1069
|
+
* @throws `ForbiddenError` with reason `immutable_release` when the forge refuses the write because the
|
|
1070
|
+
* release is immutable (GitHub); its name, notes, prerelease and `latest` flags stay editable.
|
|
1071
|
+
*/
|
|
1072
|
+
update: (ref: ReleaseRef, update: ReleaseUpdate, options?: BaseOptions) => Promise<Release>;
|
|
1073
|
+
}
|
|
1074
|
+
/** Searching issues and pull requests, repositories, commits and code across the forge. */
|
|
1075
|
+
interface SearchApi {
|
|
1076
|
+
/**
|
|
1077
|
+
* Issues and pull requests across repositories. Fields the forge cannot
|
|
1078
|
+
* filter on come back as a `filter_unsupported` warning on the page.
|
|
1079
|
+
*/
|
|
1080
|
+
threads: (query: SearchQuery) => ForgeIterable<Thread>;
|
|
1081
|
+
/** One page of `threads()`. */
|
|
1082
|
+
threadsPage: (query: SearchQuery) => Promise<Page<Thread>>;
|
|
1083
|
+
/** Searches repositories. */
|
|
1084
|
+
repos: (query: RepoSearchQuery) => ForgeIterable<Repo>;
|
|
1085
|
+
/** One page of `repos()`. */
|
|
1086
|
+
reposPage: (query: RepoSearchQuery) => Promise<Page<Repo>>;
|
|
1087
|
+
/** Commits across repositories, where the forge indexes them. */
|
|
1088
|
+
commits: (query: CommitSearchQuery) => ForgeIterable<Commit>;
|
|
1089
|
+
/** One page of `commits()`. */
|
|
1090
|
+
commitsPage: (query: CommitSearchQuery) => Promise<Page<Commit>>;
|
|
1091
|
+
/** Searches the contents of files, where the forge indexes them. */
|
|
1092
|
+
code: (query: CodeSearchQuery) => ForgeIterable<CodeMatch>;
|
|
1093
|
+
/** One page of `code()`. */
|
|
1094
|
+
codePage: (query: CodeSearchQuery) => Promise<Page<CodeMatch>>;
|
|
1095
|
+
}
|
|
1096
|
+
/** Reading the security alerts of a repository. */
|
|
1097
|
+
interface SecurityAlertsApi {
|
|
1098
|
+
/** Lists the security alerts of a repository. */
|
|
1099
|
+
list: (repo: RepoRef, options?: SecurityAlertListOptions) => ForgeIterable<SecurityAlert>;
|
|
1100
|
+
/** One page of `list()`. */
|
|
1101
|
+
listPage: (repo: RepoRef, options?: SecurityAlertListOptions) => Promise<Page<SecurityAlert>>;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Options for `repos.get()`.
|
|
1105
|
+
*/
|
|
1106
|
+
interface RepoGetOptions extends BaseOptions {
|
|
1107
|
+
/**
|
|
1108
|
+
* Includes the repository's licence in `Repo.licence`. GitLab reports it only on request, because detecting it
|
|
1109
|
+
* scans the repository; other forges ignore this option.
|
|
1110
|
+
*/
|
|
1111
|
+
licence?: boolean;
|
|
1112
|
+
}
|
|
1113
|
+
/** Repositories, and the labels, milestones and collaborators that belong to them. */
|
|
1114
|
+
interface ReposApi {
|
|
1115
|
+
/**
|
|
1116
|
+
* Reads a repository by its ref. Rejects with `NotFoundError` when it does not exist or the credential cannot see
|
|
1117
|
+
* it.
|
|
1118
|
+
*/
|
|
1119
|
+
get: (ref: RepoRef, options?: RepoGetOptions) => Promise<Repo>;
|
|
1120
|
+
/** The authenticated account's repositories, or the installation's under app auth. */
|
|
1121
|
+
list: (options?: RepoQuery) => ForgeIterable<Repo>;
|
|
1122
|
+
/** One page of `list()`. */
|
|
1123
|
+
listPage: (options?: RepoQuery) => Promise<Page<Repo>>;
|
|
1124
|
+
/** Every label defined on the repository, whether or not a thread carries it. */
|
|
1125
|
+
labels: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Label>;
|
|
1126
|
+
/** One page of `labels()`. */
|
|
1127
|
+
labelsPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Label>>;
|
|
1128
|
+
/** Creates a label in a repository. */
|
|
1129
|
+
createLabel: (repo: RepoRef, label: LabelInput, options?: BaseOptions) => Promise<Label>;
|
|
1130
|
+
/** Lists the milestones of a repository. */
|
|
1131
|
+
milestones: (repo: RepoRef, options?: MilestoneListOptions) => ForgeIterable<Milestone>;
|
|
1132
|
+
/** One page of `milestones()`. */
|
|
1133
|
+
milestonesPage: (repo: RepoRef, options?: MilestoneListOptions) => Promise<Page<Milestone>>;
|
|
1134
|
+
/** Lists the collaborators of a repository, with their roles. */
|
|
1135
|
+
collaborators: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Collaborator>;
|
|
1136
|
+
/** One page of `collaborators()`. */
|
|
1137
|
+
collaboratorsPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Collaborator>>;
|
|
1138
|
+
/** One account's role on the repository; `'none'` when it has no access. */
|
|
1139
|
+
permissionFor: (repo: RepoRef, actor: string | Actor, options?: BaseOptions) => Promise<RepoRole>;
|
|
1140
|
+
/** Gives an account a role on a repository. */
|
|
1141
|
+
addCollaborator: (repo: RepoRef, actor: string | Actor, role: RepoRole, options?: BaseOptions) => Promise<void>;
|
|
1142
|
+
/** Accounts that can be assigned to a thread in the repository. */
|
|
1143
|
+
assignableUsers: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Actor>;
|
|
1144
|
+
/** One page of `assignableUsers()`. */
|
|
1145
|
+
assignableUsersPage: (repo: RepoRef, options?: PageOptions) => Promise<Page<Actor>>;
|
|
1146
|
+
/** Accounts that can be asked to review a given pull request. */
|
|
1147
|
+
reviewerCandidates: (ref: ThreadRef, options?: PageOptions) => ForgeIterable<Actor>;
|
|
1148
|
+
/** One page of `reviewerCandidates()`. */
|
|
1149
|
+
reviewerCandidatesPage: (ref: ThreadRef, options?: PageOptions) => Promise<Page<Actor>>;
|
|
1150
|
+
}
|
|
1151
|
+
/** Options for `repos.milestones()`. */
|
|
1152
|
+
interface MilestoneListOptions extends PageOptions {
|
|
1153
|
+
/**
|
|
1154
|
+
* @default 'open'
|
|
1155
|
+
*/
|
|
1156
|
+
state?: "open" | "closed" | "all";
|
|
1157
|
+
}
|
|
1158
|
+
/** The installations of the app that the provider authenticates as. */
|
|
1159
|
+
interface InstallationsApi {
|
|
1160
|
+
/** Lists the installations of the app. */
|
|
1161
|
+
list: (options?: PageOptions) => ForgeIterable<Installation>;
|
|
1162
|
+
/** One page of `list()`. */
|
|
1163
|
+
listPage: (options?: PageOptions) => Promise<Page<Installation>>;
|
|
1164
|
+
/** Reads one installation. */
|
|
1165
|
+
get: (installation: Installation | string, options?: BaseOptions) => Promise<Installation>;
|
|
1166
|
+
/** Mints (or reuses a cached) installation token. */
|
|
1167
|
+
token: (installation: Installation | string, options?: BaseOptions) => Promise<InstallationToken>;
|
|
1168
|
+
/** Lists the repositories that an installation can access. */
|
|
1169
|
+
repos: (installation: Installation | string, options?: PageOptions) => ForgeIterable<Repo>;
|
|
1170
|
+
/** One page of `repos()`. */
|
|
1171
|
+
reposPage: (installation: Installation | string, options?: PageOptions) => Promise<Page<Repo>>;
|
|
1172
|
+
/** Provider authenticated as one installation, sharing this instance's app credentials. */
|
|
1173
|
+
provider: (installation: Installation | string) => ForgeProvider;
|
|
1174
|
+
/** One provider per installation. */
|
|
1175
|
+
providers: () => AsyncIterable<{
|
|
1176
|
+
installation: Installation;
|
|
1177
|
+
provider: ForgeProvider;
|
|
1178
|
+
}>;
|
|
1179
|
+
}
|
|
1180
|
+
/** Receiving webhook deliveries, and managing the hooks registered on the forge. */
|
|
1181
|
+
interface WebhooksApi {
|
|
1182
|
+
/** Checks a delivery's signature or token against the secret. */
|
|
1183
|
+
verify: (delivery: WebhookDelivery) => Promise<boolean>;
|
|
1184
|
+
/**
|
|
1185
|
+
* Verifies the delivery, then translates it into normalised events.
|
|
1186
|
+
* @param delivery The headers and the raw body of the request, exactly as received.
|
|
1187
|
+
* @example
|
|
1188
|
+
* ```ts
|
|
1189
|
+
* const events = await provider.webhooks.ingest({
|
|
1190
|
+
* headers: request.headers,
|
|
1191
|
+
* body: await request.text(),
|
|
1192
|
+
* })
|
|
1193
|
+
* ```
|
|
1194
|
+
*/
|
|
1195
|
+
ingest: (delivery: WebhookDelivery) => Promise<ForgeEvent[]>;
|
|
1196
|
+
/** Normalised kinds and actions this provider can deliver, whatever a hook is subscribed to. */
|
|
1197
|
+
readonly events: WebhookEventType[];
|
|
1198
|
+
/** Hooks on a repository, or on an organisation or workspace when `target` is a namespace ref. */
|
|
1199
|
+
list: (target: RepoRef, options?: PageOptions) => ForgeIterable<Webhook>;
|
|
1200
|
+
/** One page of `list()`. */
|
|
1201
|
+
listPage: (target: RepoRef, options?: PageOptions) => Promise<Page<Webhook>>;
|
|
1202
|
+
/** Registers a webhook. */
|
|
1203
|
+
create: (target: RepoRef, input: WebhookInput, options?: BaseOptions) => Promise<Webhook>;
|
|
1204
|
+
/** Changes a webhook. */
|
|
1205
|
+
update: (ref: WebhookRef, update: WebhookUpdate, options?: BaseOptions) => Promise<Webhook>;
|
|
1206
|
+
/** Deletes a webhook. */
|
|
1207
|
+
delete: (ref: WebhookRef, options?: BaseOptions) => Promise<void>;
|
|
1208
|
+
/** Replaces the signing secret in place. `false` where the forge can only do it by recreating the hook. */
|
|
1209
|
+
rotateSecret: (ref: WebhookRef, secret: string, options?: BaseOptions) => Promise<Webhook>;
|
|
1210
|
+
/** Lists the recent deliveries of a webhook. */
|
|
1211
|
+
deliveries: (ref: WebhookRef, options?: PageOptions) => ForgeIterable<WebhookDeliveryRecord>;
|
|
1212
|
+
/** One page of `deliveries()`. */
|
|
1213
|
+
deliveriesPage: (ref: WebhookRef, options?: PageOptions) => Promise<Page<WebhookDeliveryRecord>>;
|
|
1214
|
+
/** Sends a past delivery again. */
|
|
1215
|
+
redeliver: (ref: WebhookDeliveryRef, options?: BaseOptions) => Promise<void>;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* What a credential needs for a verb, as data. Nothing in the library reads
|
|
1219
|
+
* it; it is there so a consumer can build a consent screen or explain a 403.
|
|
1220
|
+
*/
|
|
1221
|
+
interface VerbScopes {
|
|
1222
|
+
/** OAuth or personal access token scopes. */
|
|
1223
|
+
token?: string[];
|
|
1224
|
+
/** Fine-grained token or app permissions, by permission name. */
|
|
1225
|
+
permissions?: Record<string, "read" | "write" | "admin">;
|
|
1226
|
+
/** How the forge expresses access where scopes do not apply. */
|
|
1227
|
+
note?: string;
|
|
1228
|
+
}
|
|
1229
|
+
/** Options for `sources.subscribe()`. */
|
|
1230
|
+
interface SubscribeOptions {
|
|
1231
|
+
/** Resume after this cursor, as yielded by an earlier {@link SubscriptionItem}. */
|
|
1232
|
+
cursor?: string;
|
|
1233
|
+
/** Aborting closes the connection and ends iteration without an error. */
|
|
1234
|
+
signal?: AbortSignal;
|
|
1235
|
+
}
|
|
1236
|
+
/** One item from a push subscription. */
|
|
1237
|
+
interface SubscriptionItem {
|
|
1238
|
+
event: ForgeEvent;
|
|
1239
|
+
/** Opaque position after `event`; persist it and pass it back to resume. */
|
|
1240
|
+
cursor: string;
|
|
1241
|
+
}
|
|
1242
|
+
/** Reading accounts. */
|
|
1243
|
+
interface UsersApi {
|
|
1244
|
+
/** Reads an account by login, without needing a credential where the forge allows it. */
|
|
1245
|
+
get: (login: string, options?: BaseOptions) => Promise<User>;
|
|
1246
|
+
/**
|
|
1247
|
+
* The account the provider's credential belongs to.
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```ts
|
|
1250
|
+
* const me = await provider.users.me()
|
|
1251
|
+
* console.log(me.login)
|
|
1252
|
+
* ```
|
|
1253
|
+
*/
|
|
1254
|
+
me: (options?: BaseOptions) => Promise<User>;
|
|
1255
|
+
}
|
|
1256
|
+
/** Ways to receive events: polling, webhooks and push subscriptions. */
|
|
1257
|
+
interface SourcesApi {
|
|
1258
|
+
/**
|
|
1259
|
+
* Push delivery over a long-lived connection. Iteration ends when the signal
|
|
1260
|
+
* aborts or the consumer stops iterating; a dropped connection throws
|
|
1261
|
+
* `SubscriptionClosedError` carrying the last cursor. There is no automatic
|
|
1262
|
+
* reconnection.
|
|
1263
|
+
*/
|
|
1264
|
+
subscribe: (options?: SubscribeOptions) => AsyncIterable<SubscriptionItem>;
|
|
1265
|
+
}
|
|
1266
|
+
/** A connection to one forge, with its identity, its capabilities and the namespaces of operations. */
|
|
1267
|
+
interface ForgeProvider {
|
|
1268
|
+
/**
|
|
1269
|
+
* Requests endpoints relative to `baseUrl` or absolute HTTP(S) URLs.
|
|
1270
|
+
* Other origins omit default headers and provider credentials; explicit headers apply.
|
|
1271
|
+
*/
|
|
1272
|
+
readonly request: ForgeRequest;
|
|
1273
|
+
/** The forge this provider sends requests to; matches `forge` on every ref it returns. */
|
|
1274
|
+
readonly forge: ForgeKind;
|
|
1275
|
+
readonly instance: ForgeInstance;
|
|
1276
|
+
readonly baseUrl: string;
|
|
1277
|
+
/** The `auth.type` the provider was created with; `'anonymous'` when it sends no credentials. */
|
|
1278
|
+
readonly authKind: AuthKind;
|
|
1279
|
+
/** Static, no-network capabilities until `refreshCapabilities()` resolves. */
|
|
1280
|
+
readonly capabilities: ForgeCapabilities;
|
|
1281
|
+
/**
|
|
1282
|
+
* Re-derives capabilities from the instance version. The version is read
|
|
1283
|
+
* once per provider (GHES `/meta`, GitLab, Forgejo and Gitea `/version`).
|
|
1284
|
+
* Updates `capabilities` and returns it.
|
|
1285
|
+
*/
|
|
1286
|
+
refreshCapabilities: () => Promise<ForgeCapabilities>;
|
|
1287
|
+
/** Rewrites Markdown into the dialect the forge renders; returns it unchanged where the forge renders CommonMark. */
|
|
1288
|
+
normaliseMarkdown: (body: string) => string;
|
|
1289
|
+
readonly repos: ReposApi;
|
|
1290
|
+
readonly notifications: NotificationsApi;
|
|
1291
|
+
readonly sources: SourcesApi;
|
|
1292
|
+
readonly threads: ThreadsApi;
|
|
1293
|
+
readonly webhooks: WebhooksApi;
|
|
1294
|
+
readonly installations: InstallationsApi;
|
|
1295
|
+
readonly releases: ReleasesApi;
|
|
1296
|
+
readonly contents: ContentsApi;
|
|
1297
|
+
readonly checks: ChecksApi;
|
|
1298
|
+
readonly ci: CiApi;
|
|
1299
|
+
readonly users: UsersApi;
|
|
1300
|
+
readonly search: SearchApi;
|
|
1301
|
+
readonly securityAlerts: SecurityAlertsApi;
|
|
1302
|
+
/**
|
|
1303
|
+
* Whether `verb` is supported, for `kind` where support differs by kind,
|
|
1304
|
+
* including version gates. Every verb is always present and rejects with
|
|
1305
|
+
* `UnsupportedOperationError` when this is `false`: the capability is the
|
|
1306
|
+
* question, the method is the action.
|
|
1307
|
+
* @param verb The operation, named by its path on the provider, such as `threads.comment`.
|
|
1308
|
+
* @param kind The thread kind, for an operation whose support differs by kind.
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```ts
|
|
1311
|
+
* if (provider.can('threads.merge')) {
|
|
1312
|
+
* await provider.threads.merge(ref)
|
|
1313
|
+
* }
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
can: (verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind) => boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* How well `verb` is supported: `true`, `'experimental'`, `'emulated'`,
|
|
1319
|
+
* `'unverified'` or `false`, for `kind` where support differs by kind. `can()` is `true` for
|
|
1320
|
+
* every level but `false`. Without `kind`, a per-kind verb reports its
|
|
1321
|
+
* strongest level across kinds.
|
|
1322
|
+
* @param verb The operation, named by its path on the provider, such as `threads.comment`.
|
|
1323
|
+
* @param kind The thread kind, for an operation whose support differs by kind.
|
|
1324
|
+
*/
|
|
1325
|
+
support: (verb: ForgeVerb, kind?: ThreadKind | SecurityAlertKind) => Support;
|
|
1326
|
+
/**
|
|
1327
|
+
* The web page for `target`, built without a request; `undefined` when the forge has no such page.
|
|
1328
|
+
* @param target What to link to: a repository, thread, comment, release, file or comparison.
|
|
1329
|
+
*/
|
|
1330
|
+
urlFor: (target: UrlTarget) => string | undefined;
|
|
1331
|
+
/**
|
|
1332
|
+
* Token scopes or app permissions `verb` needs on this forge, as data for a
|
|
1333
|
+
* consent screen or a 403 explanation. Nothing in the library reads it, and
|
|
1334
|
+
* an unmapped verb returns `{}`.
|
|
1335
|
+
* @param verb The operation, named by its path on the provider.
|
|
1336
|
+
*/
|
|
1337
|
+
scopesFor: (verb: ForgeVerb) => VerbScopes;
|
|
1338
|
+
/**
|
|
1339
|
+
* Reads a web URL, clone URL or npm `repository` value (`git+https://`, `github:owner/name`) on this provider's instance into refs; `undefined` for anything else.
|
|
1340
|
+
* @param url The URL to read.
|
|
1341
|
+
*/
|
|
1342
|
+
parseUrl: (url: string | URL) => ParsedForgeUrl | undefined;
|
|
1343
|
+
/**
|
|
1344
|
+
* How to mention `ref` in Markdown on this forge (`#42`, `!42`,
|
|
1345
|
+
* `acme/widgets#42`), short when written in `from`; the thread URL where the
|
|
1346
|
+
* forge has no reference syntax.
|
|
1347
|
+
* @param ref The thread to mention.
|
|
1348
|
+
* @param options The repository the reference is written in, so that a reference within it is short.
|
|
1349
|
+
*/
|
|
1350
|
+
referenceTo: (ref: ThreadRef, options?: ReferenceOptions) => string | undefined;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Lazily constructed provider. `createForges` calls `create()`; nothing
|
|
1354
|
+
* touches the network before that.
|
|
1355
|
+
*/
|
|
1356
|
+
interface ForgeProviderFactory<T extends ForgeProvider = ForgeProvider> {
|
|
1357
|
+
readonly forge: ForgeKind;
|
|
1358
|
+
/** The provider has not reached parity; see `ForgeCapabilities.experimental`. */
|
|
1359
|
+
readonly experimental?: true;
|
|
1360
|
+
/** Creates the provider. Nothing touches the network before this. */
|
|
1361
|
+
create: () => T;
|
|
1362
|
+
}
|
|
1363
|
+
/** A registry of providers that routes each ref to the provider it belongs to. */
|
|
1364
|
+
interface Forges {
|
|
1365
|
+
readonly providers: ForgeProvider[];
|
|
1366
|
+
/** First provider for `forge`, optionally narrowed to a single instance host. */
|
|
1367
|
+
get: (forge: ForgeKind, instance?: ForgeInstance) => ForgeProvider | undefined;
|
|
1368
|
+
/** Every provider for a forge. */
|
|
1369
|
+
all: (forge: ForgeKind) => ForgeProvider[];
|
|
1370
|
+
/** The provider a ref belongs to, by `forge` and `instance`. */
|
|
1371
|
+
for: (ref: ForgeOrigin) => ForgeProvider | undefined;
|
|
1372
|
+
/** The provider whose instance serves `url`. */
|
|
1373
|
+
forUrl: (url: string | URL) => ForgeProvider | undefined;
|
|
1374
|
+
/** Reads a web URL, clone URL or npm `repository` value on any registered instance. */
|
|
1375
|
+
parseUrl: (url: string | URL) => (ParsedForgeUrl & {
|
|
1376
|
+
provider: ForgeProvider;
|
|
1377
|
+
}) | undefined;
|
|
1378
|
+
/** Notifications from every registered provider, provider by provider. */
|
|
1379
|
+
notifications: {
|
|
1380
|
+
/** Lists the notifications of every provider, provider by provider. */
|
|
1381
|
+
list: (options?: Omit<NotificationListOptions, "cursor">) => ForgeIterable<Notification>;
|
|
1382
|
+
};
|
|
1383
|
+
/** Reads routed to the provider each ref belongs to; an unregistered origin throws `UnknownForgeError`. */
|
|
1384
|
+
repos: {
|
|
1385
|
+
/** Reads a repository from the provider it belongs to. */
|
|
1386
|
+
get: (ref: RepoRef, options?: RepoGetOptions) => Promise<Repo>;
|
|
1387
|
+
};
|
|
1388
|
+
threads: {
|
|
1389
|
+
/** Reads a thread from the provider it belongs to. */
|
|
1390
|
+
get: (ref: ThreadRef, options?: BaseOptions) => Promise<Thread>;
|
|
1391
|
+
/** Grouped per provider, results in input order. An unregistered origin is a per-item warning. */
|
|
1392
|
+
getMany: (refs: ThreadRef[], options?: BaseOptions) => Promise<GetManyResult[]>;
|
|
1393
|
+
};
|
|
1394
|
+
releases: {
|
|
1395
|
+
/** Lists the releases of a repository. */
|
|
1396
|
+
list: (repo: RepoRef, options?: PageOptions) => ForgeIterable<Release>;
|
|
1397
|
+
/** The latest release of a repository, if any. */
|
|
1398
|
+
latest: (repo: RepoRef, options?: BaseOptions) => Promise<Release | undefined>;
|
|
1399
|
+
};
|
|
1400
|
+
securityAlerts: {
|
|
1401
|
+
list: SecurityAlertsApi["list"];
|
|
1402
|
+
};
|
|
1403
|
+
/**
|
|
1404
|
+
* Searches every provider that supports search, reading pages as the
|
|
1405
|
+
* iteration needs them and merging by `updatedAt`, or by `createdAt` with
|
|
1406
|
+
* `sort: 'created'`, newest first unless `direction: 'asc'`. Each provider is
|
|
1407
|
+
* asked to sort the same way; results from one that cannot are only in order
|
|
1408
|
+
* within each page. A provider that rejects adds a `search_failed` warning
|
|
1409
|
+
* and no further items.
|
|
1410
|
+
*/
|
|
1411
|
+
search: {
|
|
1412
|
+
/** Searches issues and pull requests on every provider that supports search. */
|
|
1413
|
+
threads: (query?: Omit<SearchQuery, "cursor" | "sort"> & {
|
|
1414
|
+
sort?: "created" | "updated";
|
|
1415
|
+
}) => ForgeIterable<Thread>;
|
|
1416
|
+
/** Searches repositories on every provider that supports search. */
|
|
1417
|
+
repos: (query?: Omit<RepoSearchQuery, "cursor" | "sort"> & {
|
|
1418
|
+
sort?: "created" | "updated";
|
|
1419
|
+
}) => ForgeIterable<Repo>;
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Combines providers into a registry. Pass factories such as `github()`, or providers that already exist.
|
|
1424
|
+
* @param factories Factories such as `github()`, or providers that already exist.
|
|
1425
|
+
* @example
|
|
1426
|
+
* ```ts
|
|
1427
|
+
* import { createForges, github, gitlab } from 'forges'
|
|
1428
|
+
*
|
|
1429
|
+
* const forges = createForges([
|
|
1430
|
+
* github({ auth: { type: 'token', token: process.env.GITHUB_TOKEN! } }),
|
|
1431
|
+
* gitlab(),
|
|
1432
|
+
* ])
|
|
1433
|
+
*
|
|
1434
|
+
* const repo = await forges.repos.get({ forge: 'github', instance: 'github.com', owner: 'danielroe', name: 'forges' })
|
|
1435
|
+
* ```
|
|
1436
|
+
*/
|
|
1437
|
+
declare function createForges(factories: Array<ForgeProviderFactory | ForgeProvider>): Forges;
|
|
1438
|
+
//#endregion
|
|
1439
|
+
export { SubscriptionItem as A, ReferenceOptions as B, ReleasesApi as C, SecurityAlertsApi as D, SearchApi as E, WebhookDelivery as F, CAPABILITY_TABLE as G, WebLinks as H, WebhooksApi as I, CapabilityEntry as K, createForges as L, TokenAuth as M, UsersApi as N, SourcesApi as O, VerbScopes as P, GitHubShape as R, PerKind as S, ReposApi as T, githubShapedWeb as U, UrlTarget as V, parseForgeUrl as W, Forges as _, BasicAuth as a, NotificationWriteOptions as b, CiApi as c, ContentsApi as d, ForgeCapabilities as f, ForgeProviderFactory as g, ForgeProvider as h, AuthKind as i, ThreadsApi as j, SubscribeOptions as k, CloseOptions as l, ForgeOptionsBase as m, AnonymousAuth as n, BulkNotificationOptions as o, ForgeIterable as p, ForgeVerb as q, AppAuth as r, ChecksApi as s, AlertSupport as t, CloseReason as u, InstallationsApi as v, RepoGetOptions as w, NotificationsApi as x, MilestoneListOptions as y, ParsedForgeUrl as z };
|